diff --git a/electrum/gui/qml/components/BalanceSummary.qml b/electrum/gui/qml/components/BalanceSummary.qml index 9c452f75b..c50db3d87 100644 --- a/electrum/gui/qml/components/BalanceSummary.qml +++ b/electrum/gui/qml/components/BalanceSummary.qml @@ -2,30 +2,55 @@ import QtQuick 2.6 import QtQuick.Layouts 1.0 import QtQuick.Controls 2.0 -Item { +Frame { + id: root height: layout.height + property string formattedBalance + property string formattedUnconfirmed + + function setBalances() { + root.formattedBalance = Config.formatSats(Daemon.currentWallet.confirmedBalance, true) + root.formattedUnconfirmed = Config.formatSats(Daemon.currentWallet.unconfirmedBalance, true) + } + GridLayout { id: layout columns: 3 Label { + id: balance Layout.columnSpan: 3 - font.pointSize: 14 - text: 'Balance: ' + Daemon.currentWallet.confirmedBalance //'5.6201 mBTC' + font.pixelSize: constants.fontSizeLarge + text: 'Balance: ' + formattedBalance } Label { - font.pointSize: 8 - text: 'Confirmed: ' + Daemon.currentWallet.confirmedBalance + id: confirmed + font.pixelSize: constants.fontSizeMedium + text: 'Confirmed: ' + formattedBalance } Label { - font.pointSize: 8 - text: 'Unconfirmed: ' + Daemon.currentWallet.unconfirmedBalance + id: unconfirmed + font.pixelSize: constants.fontSizeMedium + text: 'Unconfirmed: ' + formattedUnconfirmed } Label { - font.pointSize: 8 + id: lightning + font.pixelSize: constants.fontSizeSmall text: 'Lightning: ?' } } + Connections { + target: Config + function onBaseUnitChanged() { setBalances() } + function onThousandsSeparatorChanged() { setBalances() } + } + + Connections { + target: Daemon + function onWalletLoaded() { setBalances() } + } + + Component.onCompleted: setBalances() } diff --git a/electrum/gui/qml/components/History.qml b/electrum/gui/qml/components/History.qml index 0289d81eb..538190325 100644 --- a/electrum/gui/qml/components/History.qml +++ b/electrum/gui/qml/components/History.qml @@ -59,8 +59,9 @@ Pane { color: model.label !== '' ? Material.accentColor : 'gray' } Label { + id: valueLabel font.pixelSize: 15 - text: model.bc_value + text: Config.formatSats(model.bc_value) font.bold: true color: model.incoming ? "#ff80ff80" : "#ffff8080" } @@ -112,6 +113,19 @@ Pane { } } + + // as the items in the model are not bindings to QObjects, + // hook up events that might change the appearance + Connections { + target: Config + function onBaseUnitChanged() { + valueLabel.text = Config.formatSats(model.bc_value) + } + function onThousandsSeparatorChanged() { + valueLabel.text = Config.formatSats(model.bc_value) + } + } + } // delegate } diff --git a/electrum/gui/qml/components/Receive.qml b/electrum/gui/qml/components/Receive.qml index 5e80f3b7a..4f5fc2d5c 100644 --- a/electrum/gui/qml/components/Receive.qml +++ b/electrum/gui/qml/components/Receive.qml @@ -14,7 +14,7 @@ Pane { width: parent.width rowSpacing: 10 columnSpacing: 10 - columns: 3 + columns: 4 Label { text: qsTr('Message') @@ -22,8 +22,7 @@ Pane { TextField { id: message - onTextChanged: img.source = 'image://qrgen/' + text - Layout.columnSpan: 2 + Layout.columnSpan: 3 Layout.fillWidth: true } @@ -31,53 +30,113 @@ Pane { text: qsTr('Requested Amount') wrapMode: Text.WordWrap Layout.preferredWidth: 50 // trigger wordwrap + Layout.rightMargin: constants.paddingXLarge + Layout.rowSpan: 2 } TextField { id: amount + Layout.fillWidth: true } - Item { - Layout.rowSpan: 3 - width: img.width - height: img.height - - Image { - id: img - cache: false - anchors { - top: parent.top - left: parent.left + Label { + text: Config.baseUnit + color: Material.accentColor + } + + ColumnLayout { + Layout.rowSpan: 2 + Layout.preferredWidth: rootItem.width /3 + Layout.leftMargin: constants.paddingXLarge + + Label { + text: qsTr('Expires after') + Layout.fillWidth: false + } + + ComboBox { + id: expires + Layout.fillWidth: true + textRole: 'text' + valueRole: 'value' + + model: ListModel { + id: expiresmodel + Component.onCompleted: { + // we need to fill the model like this, as ListElement can't evaluate script + expiresmodel.append({'text': qsTr('10 minutes'), 'value': 10*60}) + expiresmodel.append({'text': qsTr('1 hour'), 'value': 60*60}) + expiresmodel.append({'text': qsTr('1 day'), 'value': 24*60*60}) + expiresmodel.append({'text': qsTr('1 week'), 'value': 7*24*60*60}) + expiresmodel.append({'text': qsTr('1 month'), 'value': 31*7*24*60*60}) + expiresmodel.append({'text': qsTr('Never'), 'value': 0}) + expires.currentIndex = 0 + } } - source: 'image://qrgen/test' } } + TextField { + id: amountFiat + Layout.fillWidth: true + } + Label { - text: qsTr('Expires after') - Layout.fillWidth: false + text: qsTr('EUR') + color: Material.accentColor } - ComboBox { - id: expires - textRole: 'text' - valueRole: 'value' - model: ListModel { - id: expiresmodel - Component.onCompleted: { - // we need to fill the model like this, as ListElement can't evaluate script - expiresmodel.append({'text': qsTr('Never'), 'value': 0}) - expiresmodel.append({'text': qsTr('10 minutes'), 'value': 10*60}) - expiresmodel.append({'text': qsTr('1 hour'), 'value': 60*60}) - expiresmodel.append({'text': qsTr('1 day'), 'value': 24*60*60}) - expiresmodel.append({'text': qsTr('1 week'), 'value': 7*24*60*60}) - expires.currentIndex = 0 + RowLayout { + Layout.columnSpan: 4 + Layout.alignment: Qt.AlignHCenter + CheckBox { + id: cb_onchain + text: qsTr('Onchain') + checked: true + contentItem: RowLayout { + Text { + text: cb_onchain.text + font: cb_onchain.font + opacity: enabled ? 1.0 : 0.3 + color: Material.foreground + verticalAlignment: Text.AlignVCenter + leftPadding: cb_onchain.indicator.width + cb_onchain.spacing + } + Image { + x: 16 + Layout.preferredWidth: 16 + Layout.preferredHeight: 16 + source: '../../icons/bitcoin.png' + } + } + } + + CheckBox { + id: cb_lightning + text: qsTr('Lightning') + enabled: false + contentItem: RowLayout { + Text { + text: cb_lightning.text + font: cb_lightning.font + opacity: enabled ? 1.0 : 0.3 + color: Material.foreground + verticalAlignment: Text.AlignVCenter + leftPadding: cb_lightning.indicator.width + cb_lightning.spacing + } + Image { + x: 16 + Layout.preferredWidth: 16 + Layout.preferredHeight: 16 + source: '../../icons/lightning.png' + } } } } Button { - Layout.columnSpan: 2 + Layout.columnSpan: 4 + Layout.alignment: Qt.AlignHCenter text: qsTr('Create Request') onClicked: { createRequest() @@ -148,6 +207,12 @@ Pane { columns: 5 + Rectangle { + Layout.columnSpan: 5 + Layout.fillWidth: true + Layout.preferredHeight: constants.paddingTiny + color: 'transparent' + } Image { Layout.rowSpan: 2 Layout.preferredWidth: 32 @@ -166,7 +231,8 @@ Pane { font.pixelSize: constants.fontSizeSmall } Label { - text: model.amount + id: amount + text: Config.formatSats(model.amount, true) font.pixelSize: constants.fontSizeSmall } @@ -187,7 +253,24 @@ Pane { text: model.status font.pixelSize: constants.fontSizeSmall } + Rectangle { + Layout.columnSpan: 5 + Layout.fillWidth: true + Layout.preferredHeight: constants.paddingTiny + color: 'transparent' + } } + + Connections { + target: Config + function onBaseUnitChanged() { + amount.text = Config.formatSats(model.amount, true) + } + function onThousandsSeparatorChanged() { + amount.text = Config.formatSats(model.amount, true) + } + } + } add: Transition { @@ -198,12 +281,20 @@ Pane { NumberAnimation { properties: 'y'; duration: 100 } NumberAnimation { properties: 'opacity'; to: 1.0; duration: 700 * (1-from) } } + + ScrollBar.vertical: ScrollBar { + parent: parent.parent + anchors.top: parent.top + anchors.left: parent.right + anchors.bottom: parent.bottom + } + } } } function createRequest(ignoreGaplimit = false) { - var a = parseFloat(amount.text) + var a = Config.unitsToSats(amount.text) Daemon.currentWallet.create_invoice(a, message.text, expires.currentValue, false, ignoreGaplimit) } @@ -212,6 +303,8 @@ Pane { function onRequestCreateSuccess() { message.text = '' amount.text = '' +// var dialog = app.showAsQrDialog.createObject(app, {'text': 'test'}) +// dialog.open() } function onRequestCreateError(code, error) { if (code == 'gaplimit') { diff --git a/electrum/gui/qml/components/Send.qml b/electrum/gui/qml/components/Send.qml index e7f033031..fa71d1f4a 100644 --- a/electrum/gui/qml/components/Send.qml +++ b/electrum/gui/qml/components/Send.qml @@ -1,6 +1,7 @@ import QtQuick 2.6 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 +import QtQuick.Controls.Material 2.0 Pane { id: rootItem @@ -11,7 +12,7 @@ Pane { BalanceSummary { Layout.columnSpan: 4 - //Layout.alignment: Qt.AlignHCenter + Layout.alignment: Qt.AlignHCenter } Label { @@ -20,11 +21,18 @@ Pane { TextField { id: address - Layout.columnSpan: 3 + Layout.columnSpan: 2 placeholderText: 'Paste address or invoice' Layout.fillWidth: true } + ToolButton { + icon.source: '../../icons/copy.png' + icon.color: 'transparent' + icon.height: 16 + icon.width: 16 + } + Label { text: "Amount" } @@ -34,6 +42,12 @@ Pane { placeholderText: 'Amount' } + Label { + text: Config.baseUnit + color: Material.accentColor + Layout.columnSpan: 2 + } + Label { text: "Fee" } @@ -41,6 +55,7 @@ Pane { TextField { id: fee placeholderText: 'sat/vB' + Layout.columnSpan: 2 } Item { @@ -51,7 +66,6 @@ Pane { spacing: 10 anchors.horizontalCenter: parent.horizontalCenter Button { -// anchors.horizontalCenter: parent.horizontalCenter text: 'Pay' enabled: address.text != '' && amount.text != '' && fee.text != '' // TODO proper validation onClicked: {