From 9d425b5b236cee724c399d76e7ad086d895fc78d Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Thu, 23 Feb 2023 20:57:45 +0100 Subject: [PATCH] qml: move remaining buttons to bottom of dialogs --- .../gui/qml/components/ExportTxDialog.qml | 102 +++++++-------- .../gui/qml/components/GenericShareDialog.qml | 119 ++++++++++-------- .../qml/components/LoadingWalletDialog.qml | 2 + electrum/gui/qml/components/ReceiveDialog.qml | 98 ++++++++------- .../gui/qml/components/controls/Toaster.qml | 2 +- 5 files changed, 172 insertions(+), 151 deletions(-) diff --git a/electrum/gui/qml/components/ExportTxDialog.qml b/electrum/gui/qml/components/ExportTxDialog.qml index 4e4d3e35b..72d44fb9b 100644 --- a/electrum/gui/qml/components/ExportTxDialog.qml +++ b/electrum/gui/qml/components/ExportTxDialog.qml @@ -27,63 +27,67 @@ ElDialog { color: "#aa000000" } - Flickable { - anchors.fill: parent - contentHeight: rootLayout.height - clip:true - interactive: height < contentHeight + padding: 0 - ColumnLayout { - id: rootLayout - width: parent.width - spacing: constants.paddingMedium + ColumnLayout { + anchors.fill: parent + spacing: 0 + + Flickable { + Layout.fillWidth: true + Layout.fillHeight: true + + contentHeight: rootLayout.height + clip:true + interactive: height < contentHeight + + ColumnLayout { + id: rootLayout + width: parent.width + spacing: constants.paddingMedium + + Item { + Layout.fillWidth: true + Layout.preferredHeight: qr.height + Layout.topMargin: constants.paddingSmall + Layout.bottomMargin: constants.paddingSmall + QRImage { + id: qr + qrdata: dialog.text_qr + anchors.centerIn: parent + } + } - Item { - Layout.fillWidth: true - Layout.preferredHeight: qr.height - Layout.topMargin: constants.paddingSmall - Layout.bottomMargin: constants.paddingSmall - QRImage { - id: qr - qrdata: dialog.text_qr - anchors.centerIn: parent + Label { + visible: dialog.text_help + text: dialog.text_help + wrapMode: Text.Wrap + Layout.fillWidth: true } - } - Label { - visible: dialog.text_help - text: dialog.text_help - wrapMode: Text.Wrap - Layout.fillWidth: true } + } - Rectangle { - height: 1 - Layout.preferredWidth: qr.width - Layout.alignment: Qt.AlignHCenter - color: Material.accentColor - } + ButtonContainer { + Layout.fillWidth: true - ButtonContainer { - // Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter - - FlatButton { - Layout.minimumWidth: dialog.width * 1/4 - text: qsTr('Copy') - icon.source: '../../icons/copy_bw.png' - onClicked: { - AppController.textToClipboard(dialog.text) - toaster.show(this, qsTr('Copied!')) - } + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Copy') + icon.source: '../../icons/copy_bw.png' + onClicked: { + AppController.textToClipboard(dialog.text) + toaster.show(this, qsTr('Copied!')) } - FlatButton { - Layout.minimumWidth: dialog.width * 1/4 - text: qsTr('Share') - icon.source: '../../icons/share.png' - onClicked: { - AppController.doShare(dialog.text, dialog.title) - } + } + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Share') + icon.source: '../../icons/share.png' + onClicked: { + AppController.doShare(dialog.text, dialog.title) } } } diff --git a/electrum/gui/qml/components/GenericShareDialog.qml b/electrum/gui/qml/components/GenericShareDialog.qml index 1702f433d..f533e1cbe 100644 --- a/electrum/gui/qml/components/GenericShareDialog.qml +++ b/electrum/gui/qml/components/GenericShareDialog.qml @@ -25,72 +25,81 @@ ElDialog { color: "#aa000000" } - Flickable { + padding: 0 + + ColumnLayout { anchors.fill: parent - contentHeight: rootLayout.height - clip:true - interactive: height < contentHeight - - ColumnLayout { - id: rootLayout - width: parent.width - spacing: constants.paddingMedium - - QRImage { - id: qr - render: dialog.enter ? false : true - qrdata: dialog.text_qr ? dialog.text_qr : dialog.text - Layout.alignment: Qt.AlignHCenter - Layout.topMargin: constants.paddingSmall - Layout.bottomMargin: constants.paddingSmall - } + spacing: 0 + + Flickable { + Layout.fillHeight: true + Layout.fillWidth: true + + contentHeight: rootLayout.height + clip:true + interactive: height < contentHeight + + ColumnLayout { + id: rootLayout + width: parent.width + spacing: constants.paddingMedium + + QRImage { + id: qr + render: dialog.enter ? false : true + qrdata: dialog.text_qr ? dialog.text_qr : dialog.text + Layout.alignment: Qt.AlignHCenter + Layout.topMargin: constants.paddingSmall + Layout.bottomMargin: constants.paddingSmall + } + + TextHighlightPane { + Layout.alignment: Qt.AlignHCenter + Layout.fillWidth: true + Layout.maximumWidth: qr.width + Label { + width: parent.width + text: dialog.text + wrapMode: Text.Wrap + font.pixelSize: constants.fontSizeLarge + font.family: FixedFont + maximumLineCount: 4 + elide: Text.ElideRight + } + } - TextHighlightPane { - Layout.fillWidth: true Label { - width: parent.width - text: dialog.text + visible: dialog.text_help + text: dialog.text_help wrapMode: Text.Wrap - font.pixelSize: constants.fontSizeLarge - font.family: FixedFont - maximumLineCount: 4 - elide: Text.ElideRight + Layout.fillWidth: true } - } - Label { - visible: dialog.text_help - text: dialog.text_help - wrapMode: Text.Wrap - Layout.fillWidth: true } + } - Rectangle { - height: 1 - Layout.preferredWidth: qr.width - Layout.alignment: Qt.AlignHCenter - color: Material.accentColor - } + ButtonContainer { + Layout.fillWidth: true - ButtonContainer { - Layout.alignment: Qt.AlignHCenter + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 - FlatButton { - Layout.minimumWidth: dialog.width * 1/4 - text: qsTr('Copy') - icon.source: '../../icons/copy_bw.png' - onClicked: { - AppController.textToClipboard(dialog.text) - toaster.show(this, qsTr('Copied!')) - } + text: qsTr('Copy') + icon.source: '../../icons/copy_bw.png' + onClicked: { + AppController.textToClipboard(dialog.text) + toaster.show(this, qsTr('Copied!')) } - FlatButton { - Layout.minimumWidth: dialog.width * 1/4 - text: qsTr('Share') - icon.source: '../../icons/share.png' - onClicked: { - AppController.doShare(dialog.text, dialog.title) - } + } + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + + text: qsTr('Share') + icon.source: '../../icons/share.png' + onClicked: { + AppController.doShare(dialog.text, dialog.title) } } } diff --git a/electrum/gui/qml/components/LoadingWalletDialog.qml b/electrum/gui/qml/components/LoadingWalletDialog.qml index 4d0595e1e..a9f938350 100644 --- a/electrum/gui/qml/components/LoadingWalletDialog.qml +++ b/electrum/gui/qml/components/LoadingWalletDialog.qml @@ -5,6 +5,8 @@ import QtQuick.Controls.Material 2.0 import org.electrum 1.0 +import "controls" + ElDialog { id: dialog diff --git a/electrum/gui/qml/components/ReceiveDialog.qml b/electrum/gui/qml/components/ReceiveDialog.qml index 31cc4c083..79f8daca7 100644 --- a/electrum/gui/qml/components/ReceiveDialog.qml +++ b/electrum/gui/qml/components/ReceiveDialog.qml @@ -73,6 +73,7 @@ ElDialog { ] Rectangle { + id: qrbg Layout.alignment: Qt.AlignHCenter Layout.topMargin: constants.paddingSmall Layout.bottomMargin: constants.paddingSmall @@ -201,14 +202,13 @@ ElDialog { Rectangle { height: 1 Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: buttons.width + Layout.preferredWidth: qrbg.width color: Material.accentColor } GridLayout { columns: 2 - // visible: request.message || !request.amount.isEmpty - Layout.maximumWidth: buttons.width + Layout.maximumWidth: qrbg.width Layout.alignment: Qt.AlignHCenter Label { @@ -241,57 +241,63 @@ ElDialog { } Rectangle { - // visible: request.message || !request.amount.isEmpty height: 1 Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: buttons.width + Layout.preferredWidth: qrbg.width color: Material.accentColor } - ButtonContainer { - id: buttons - Layout.alignment: Qt.AlignHCenter - FlatButton { - Layout.minimumWidth: dialog.width * 1/4 - icon.source: '../../icons/copy_bw.png' - icon.color: 'transparent' - text: 'Copy' - onClicked: { - if (request.isLightning && rootLayout.state == 'bolt11') - AppController.textToClipboard(_bolt11) - else if (rootLayout.state == 'bip21uri') - AppController.textToClipboard(_bip21uri) - else - AppController.textToClipboard(_address) - toaster.show(this, qsTr('Copied!')) - } - } - FlatButton { - Layout.minimumWidth: dialog.width * 1/4 - icon.source: '../../icons/share.png' - text: 'Share' - onClicked: { - enabled = false - if (request.isLightning && rootLayout.state == 'bolt11') - AppController.doShare(_bolt11, qsTr('Payment Request')) - else if (rootLayout.state == 'bip21uri') - AppController.doShare(_bip21uri, qsTr('Payment Request')) - else - AppController.doShare(_address, qsTr('Onchain address')) - - enabled = true - } - } - FlatButton { - Layout.minimumWidth: dialog.width * 1/4 - Layout.alignment: Qt.AlignHCenter - icon.source: '../../icons/pen.png' - text: qsTr('Edit') - onClicked: receiveDetailsDialog.open() - } + } + + } + + ButtonContainer { + id: buttons + Layout.fillWidth: true + + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + + icon.source: '../../icons/copy_bw.png' + icon.color: 'transparent' + text: 'Copy' + onClicked: { + if (request.isLightning && rootLayout.state == 'bolt11') + AppController.textToClipboard(_bolt11) + else if (rootLayout.state == 'bip21uri') + AppController.textToClipboard(_bip21uri) + else + AppController.textToClipboard(_address) + toaster.show(this, qsTr('Copied!')) } } + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + + icon.source: '../../icons/share.png' + text: 'Share' + onClicked: { + enabled = false + if (request.isLightning && rootLayout.state == 'bolt11') + AppController.doShare(_bolt11, qsTr('Payment Request')) + else if (rootLayout.state == 'bip21uri') + AppController.doShare(_bip21uri, qsTr('Payment Request')) + else + AppController.doShare(_address, qsTr('Onchain address')) + + enabled = true + } + } + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + icon.source: '../../icons/pen.png' + text: qsTr('Edit') + onClicked: receiveDetailsDialog.open() + } } } diff --git a/electrum/gui/qml/components/controls/Toaster.qml b/electrum/gui/qml/components/controls/Toaster.qml index 8255187c5..c8ec99113 100644 --- a/electrum/gui/qml/components/controls/Toaster.qml +++ b/electrum/gui/qml/components/controls/Toaster.qml @@ -17,7 +17,7 @@ Item { function show(item, text) { _text = text var r = item.mapToItem(parent, item.x, item.y) - x = r.x + x = r.x - (toaster.width - item.width)/2 y = r.y - toaster.height - constants.paddingLarge toaster._y = y - 35 ani.restart()