From a8ff969ad71c2b20de4ec94c5c586a835fcf338e Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Tue, 5 Apr 2022 14:53:42 +0200 Subject: [PATCH] send/receive amounts same style --- electrum/gui/qml/components/Receive.qml | 126 ++++++++---------------- electrum/gui/qml/components/Send.qml | 42 +++++--- 2 files changed, 70 insertions(+), 98 deletions(-) diff --git a/electrum/gui/qml/components/Receive.qml b/electrum/gui/qml/components/Receive.qml index 3a5aa2ff1..cc6eac92e 100644 --- a/electrum/gui/qml/components/Receive.qml +++ b/electrum/gui/qml/components/Receive.qml @@ -13,8 +13,8 @@ Pane { GridLayout { id: form width: parent.width - rowSpacing: 10 - columnSpacing: 10 + rowSpacing: constants.paddingSmall + columnSpacing: constants.paddingSmall columns: 4 Label { @@ -23,22 +23,22 @@ Pane { TextField { id: message + placeholderText: qsTr('Description of payment request') Layout.columnSpan: 3 Layout.fillWidth: true } Label { - text: qsTr('Requested Amount') + text: qsTr('Request') wrapMode: Text.WordWrap - Layout.preferredWidth: 50 // trigger wordwrap Layout.rightMargin: constants.paddingXLarge - Layout.rowSpan: 2 } TextField { id: amount font.family: FixedFont - Layout.fillWidth: true + Layout.preferredWidth: parent.width /2 + placeholderText: qsTr('Amount') inputMethodHints: Qt.ImhPreferNumbers } @@ -47,103 +47,63 @@ Pane { color: Material.accentColor } - ColumnLayout { - Layout.rowSpan: 2 - Layout.preferredWidth: rootItem.width /3 - Layout.leftMargin: constants.paddingXLarge + Item { width: 1; height: 1; Layout.fillWidth: true } - 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 - } - } - } - } + Item { visible: Daemon.fx.enabled; width: 1; height: 1 } TextField { id: amountFiat - visible: Daemon.fx.fiatCurrency != '' + visible: Daemon.fx.enabled font.family: FixedFont - Layout.fillWidth: true + Layout.preferredWidth: parent.width /2 + placeholderText: qsTr('Amount') inputMethodHints: Qt.ImhDigitsOnly } Label { - visible: Daemon.fx.fiatCurrency != '' + visible: Daemon.fx.enabled text: Daemon.fx.fiatCurrency color: Material.accentColor } - Item { visible: Daemon.fx.fiatCurrency == ''; width: 1; height: 1; Layout.columnSpan: 2 } + Item { width: 1; height: 1; Layout.fillWidth: true } - RowLayout { - Layout.columnSpan: 4 - Layout.alignment: Qt.AlignHCenter - visible: false - 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' - } + Label { + text: qsTr('Expires after') + Layout.fillWidth: false + } + + ComboBox { + id: expires + Layout.columnSpan: 2 + + 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 } } - 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' - } - } + // redefine contentItem, as the default crops the widest item + contentItem: Label { + text: expires.currentText + padding: constants.paddingLarge + font.pixelSize: constants.fontSizeMedium } } + Item { width: 1; height: 1; Layout.fillWidth: true } + Button { Layout.columnSpan: 4 Layout.alignment: Qt.AlignHCenter diff --git a/electrum/gui/qml/components/Send.qml b/electrum/gui/qml/components/Send.qml index 4083cd41a..d2f8e96fc 100644 --- a/electrum/gui/qml/components/Send.qml +++ b/electrum/gui/qml/components/Send.qml @@ -8,10 +8,12 @@ Pane { GridLayout { width: parent.width - columns: 6 + rowSpacing: constants.paddingSmall + columnSpacing: constants.paddingSmall + columns: 4 BalanceSummary { - Layout.columnSpan: 6 + Layout.columnSpan: 4 Layout.alignment: Qt.AlignHCenter } @@ -19,19 +21,20 @@ Pane { text: qsTr('Recipient') } - TextField { + TextArea { id: address - Layout.columnSpan: 4 + Layout.columnSpan: 2 Layout.fillWidth: true font.family: FixedFont + wrapMode: Text.Wrap placeholderText: qsTr('Paste address or invoice') } ToolButton { icon.source: '../../icons/copy.png' icon.color: 'transparent' - icon.height: 16 - icon.width: 16 + icon.height: constants.iconSizeSmall + icon.width: constants.iconSizeSmall } Label { @@ -42,31 +45,38 @@ Pane { id: amount font.family: FixedFont placeholderText: qsTr('Amount') + Layout.preferredWidth: parent.width /2 inputMethodHints: Qt.ImhPreferNumbers } Label { - text: Config.baseUnit + ' ' // add spaces for easy right margin + text: Config.baseUnit color: Material.accentColor + Layout.fillWidth: true } + Item { width: 1; height: 1 } + + + Item { width: 1; height: 1; visible: Daemon.fx.enabled } + TextField { id: amountFiat - visible: Daemon.fx.fiatCurrency != '' + visible: Daemon.fx.enabled font.family: FixedFont + Layout.preferredWidth: parent.width /2 placeholderText: qsTr('Amount') inputMethodHints: Qt.ImhPreferNumbers } Label { - visible: Daemon.fx.fiatCurrency != '' + visible: Daemon.fx.enabled text: Daemon.fx.fiatCurrency color: Material.accentColor + Layout.fillWidth: true } - Item { visible: Daemon.fx.fiatCurrency == ''; height: 1; Layout.columnSpan: 2; Layout.fillWidth: true } - - Item { width: 1; height: 1 } // workaround colspan on baseunit messing up row above + Item { visible: Daemon.fx.enabled ; height: 1; width: 1 } Label { text: qsTr('Fee') @@ -76,13 +86,15 @@ Pane { id: fee font.family: FixedFont placeholderText: qsTr('sat/vB') - Layout.columnSpan: 5 + Layout.columnSpan: 2 } + Item { width: 1; height: 1 } + RowLayout { - Layout.columnSpan: 6 + Layout.columnSpan: 4 Layout.alignment: Qt.AlignHCenter - spacing: 10 + spacing: constants.paddingMedium Button { text: qsTr('Pay')