You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
1.8 KiB

10 years ago
/*
* Display a row containing :
* - The amount of Ether.
* - The unit used.
* - User-friendly string representation of the amout of Ether (if displayFormattedValue == true).
* 'value' has to be a QEther obj.
*/
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.1
10 years ago
RowLayout {
id: etherEdition
property bool displayFormattedValue;
property bool edit;
property variant value;
onValueChanged: update()
Component.onCompleted: update()
function update()
{
if (value)
10 years ago
{
etherValueEdit.text = value.value;
selectUnit(value.unit);
}
}
function selectUnit(unit)
{
10 years ago
units.currentIndex = unit;
}
DefaultTextField
{
10 years ago
implicitWidth: 200
onTextChanged:
{
10 years ago
if (value !== undefined)
{
10 years ago
value.setValue(text)
formattedValue.text = value.format();
}
}
10 years ago
readOnly: !edit
visible: edit
id: etherValueEdit;
}
10 years ago
ComboBox
{
id: units
onCurrentTextChanged:
{
if (value)
{
10 years ago
value.setUnit(currentText);
formattedValue.text = value.format();
}
}
10 years ago
model: ListModel {
id: unitsModel
ListElement { text: "Uether"; }
ListElement { text: "Vether"; }
ListElement { text: "Dether"; }
ListElement { text: "Nether"; }
ListElement { text: "Yether"; }
ListElement { text: "Zether"; }
ListElement { text: "Eether"; }
ListElement { text: "Pether"; }
ListElement { text: "Tether"; }
ListElement { text: "Gether"; }
ListElement { text: "Mether"; }
ListElement { text: "grand"; }
ListElement { text: "ether"; }
ListElement { text: "finney"; }
ListElement { text: "szabo"; }
ListElement { text: "Gwei"; }
ListElement { text: "Mwei"; }
ListElement { text: "Kwei"; }
ListElement { text: "wei"; }
}
}
10 years ago
Text
{
visible: displayFormattedValue
id: formattedValue
}
}