peerplays_migrated/programs/light_client/qml/TransferForm.qml

85 lines
2.9 KiB
QML
Raw Normal View History

2015-07-13 18:16:02 +00:00
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.2
2015-07-14 19:06:00 +00:00
import Graphene.Client 0.1
import "."
2015-07-13 18:16:02 +00:00
Rectangle {
anchors.fill: parent
2015-07-14 19:06:00 +00:00
property alias senderAccount: senderPicker.account
property alias receiverAccount: recipientPicker.account
property GrapheneApplication app
signal finished
2015-07-13 18:16:02 +00:00
Component.onCompleted: console.log("Made a transfer form")
Component.onDestruction: console.log("Destroyed a transfer form")
2015-07-14 19:06:00 +00:00
ColumnLayout {
anchors.centerIn: parent
2015-07-14 19:06:00 +00:00
width: parent.width - Scaling.cm(2)
2015-07-15 21:55:12 +00:00
spacing: Scaling.mm(5)
2015-07-14 19:06:00 +00:00
AccountPicker {
id: senderPicker
2015-07-15 21:55:12 +00:00
Layout.fillWidth: true
Layout.minimumWidth: Scaling.cm(5)
2015-07-14 19:06:00 +00:00
Component.onCompleted: setFocus()
placeholderText: qsTr("Sender")
showBalance: balances? balances.reduce(function(foundIndex, balance, index) {
if (foundIndex >= 0) return foundIndex
2015-07-15 21:55:12 +00:00
return balance.type.symbol === assetField.currentText? index : -1
}, -1) : -1
2015-07-14 19:06:00 +00:00
}
AccountPicker {
id: recipientPicker
2015-07-15 21:55:12 +00:00
Layout.fillWidth: true
Layout.minimumWidth: Scaling.cm(5)
2015-07-14 19:06:00 +00:00
placeholderText: qsTr("Recipient")
layoutDirection: Qt.RightToLeft
}
2015-07-15 21:55:12 +00:00
TextField {
id: memoField
Layout.fillWidth: true
placeholderText: qsTr("Memo")
}
RowLayout {
2015-07-15 21:55:12 +00:00
Layout.fillWidth: true
2015-07-14 19:06:00 +00:00
SpinBox {
id: amountField
2015-07-14 19:06:00 +00:00
Layout.preferredWidth: Scaling.cm(4)
Layout.minimumWidth: Scaling.cm(1.5)
enabled: maxBalance
2015-07-14 19:06:00 +00:00
minimumValue: 0
maximumValue: maxBalance? maxBalance.amountReal() : 0
decimals: maxBalance? maxBalance.type.precision : 0
2015-07-17 20:06:07 +00:00
property Balance maxBalance: assetField.enabled && senderPicker.showBalance >= 0?
senderPicker.balances[senderPicker.showBalance] : null
2015-07-14 19:06:00 +00:00
}
ComboBox {
2015-07-15 21:55:12 +00:00
id: assetField
2015-07-14 19:06:00 +00:00
Layout.minimumWidth: Scaling.cm(3)
2015-07-17 20:06:07 +00:00
enabled: senderPicker.balances instanceof Array && senderPicker.balances.length > 0
model: enabled? senderPicker.balances.filter(function(balance) { return balance.amount > 0 })
.map(function(balance) { return balance.type.symbol })
: ["Asset Type"]
2015-07-14 19:06:00 +00:00
}
Item { Layout.fillWidth: true }
Button {
text: qsTr("Cancel")
onClicked: finished()
}
2015-07-14 19:06:00 +00:00
Button {
text: qsTr("Transfer")
2015-07-17 20:06:07 +00:00
enabled: senderPicker.account && recipientPicker.account && senderPicker.account !== recipientPicker.account && amountField.value
onClicked: console.log(amountField.value)
}
}
}
2015-07-13 18:16:02 +00:00
}