From b2a02dd047f409757a25aba0f0b1483807f81a78 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Fri, 3 Feb 2023 13:33:17 +0100 Subject: [PATCH] qml: put FlatButtons in ButtonContainer where (potentially) more buttons are grouped --- .../gui/qml/components/ChannelDetails.qml | 84 ++++++++++--------- electrum/gui/qml/components/Channels.qml | 50 ++++++----- .../gui/qml/components/ExportTxDialog.qml | 4 +- electrum/gui/qml/components/InvoiceDialog.qml | 65 +++++++------- .../gui/qml/components/NetworkOverview.qml | 35 ++++---- electrum/gui/qml/components/ReceiveDialog.qml | 2 +- electrum/gui/qml/components/SendDialog.qml | 37 ++++---- electrum/gui/qml/components/TxDetails.qml | 25 +++--- electrum/gui/qml/components/WalletDetails.qml | 58 +++++++------ .../gui/qml/components/WalletMainView.qml | 42 +++++----- 10 files changed, 221 insertions(+), 181 deletions(-) diff --git a/electrum/gui/qml/components/ChannelDetails.qml b/electrum/gui/qml/components/ChannelDetails.qml index 2ba369398..243f033a5 100644 --- a/electrum/gui/qml/components/ChannelDetails.qml +++ b/electrum/gui/qml/components/ChannelDetails.qml @@ -203,58 +203,60 @@ Pane { } } - FlatButton { + ButtonContainer { Layout.fillWidth: true - visible: !channeldetails.isBackup - text: qsTr('Backup'); - onClicked: { - var dialog = app.genericShareDialog.createObject(root, - { + + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + visible: !channeldetails.isBackup + text: qsTr('Backup') + onClicked: { + var dialog = app.genericShareDialog.createObject(root, { title: qsTr('Channel Backup for %1').arg(channeldetails.short_cid), text: channeldetails.channelBackup(), text_help: channeldetails.channelBackupHelpText(), iconSource: Qt.resolvedUrl('../../icons/file.png') - } - ) - dialog.open() + }) + dialog.open() + } + icon.source: '../../icons/file.png' } - icon.source: '../../icons/file.png' - } - FlatButton { - Layout.fillWidth: true - Layout.preferredWidth: 1 - text: qsTr('Close channel'); - visible: channeldetails.canClose - onClicked: { - var dialog = closechannel.createObject(root, { 'channelid': channelid }) - dialog.open() + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Close channel'); + visible: channeldetails.canClose + onClicked: { + var dialog = closechannel.createObject(root, { channelid: channelid }) + dialog.open() + } + icon.source: '../../icons/closebutton.png' } - icon.source: '../../icons/closebutton.png' - } - FlatButton { - Layout.fillWidth: true - Layout.preferredWidth: 1 - text: qsTr('Delete channel'); - visible: channeldetails.canDelete - onClicked: { - var dialog = app.messageDialog.createObject(root, - { - 'text': qsTr('Are you sure you want to delete this channel? This will purge associated transactions from your wallet history.'), - 'yesno': true - } - ) - dialog.yesClicked.connect(function() { - channeldetails.deleteChannel() - app.stack.pop() - Daemon.currentWallet.historyModel.init_model(true) // needed here? - Daemon.currentWallet.channelModel.remove_channel(channelid) - }) - dialog.open() + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Delete channel'); + visible: channeldetails.canDelete + onClicked: { + var dialog = app.messageDialog.createObject(root, { + text: qsTr('Are you sure you want to delete this channel? This will purge associated transactions from your wallet history.'), + yesno: true + }) + dialog.yesClicked.connect(function() { + channeldetails.deleteChannel() + app.stack.pop() + Daemon.currentWallet.historyModel.init_model(true) // needed here? + Daemon.currentWallet.channelModel.remove_channel(channelid) + }) + dialog.open() + } + icon.source: '../../icons/delete.png' } - icon.source: '../../icons/delete.png' } + } ChannelDetails { diff --git a/electrum/gui/qml/components/Channels.qml b/electrum/gui/qml/components/Channels.qml index c05c14c8b..3e04d9cc4 100644 --- a/electrum/gui/qml/components/Channels.qml +++ b/electrum/gui/qml/components/Channels.qml @@ -103,34 +103,40 @@ Pane { } - FlatButton { + ButtonContainer { Layout.fillWidth: true - text: qsTr('Swap'); - visible: Daemon.currentWallet.lightningCanSend.satsInt > 0 || Daemon.currentWallet.lightningCanReceive.satInt > 0 - icon.source: '../../icons/status_waiting.png' - onClicked: { - var dialog = swapDialog.createObject(root) - dialog.open() + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Swap'); + visible: Daemon.currentWallet.lightningCanSend.satsInt > 0 || Daemon.currentWallet.lightningCanReceive.satInt > 0 + icon.source: '../../icons/status_waiting.png' + onClicked: { + var dialog = swapDialog.createObject(root) + dialog.open() + } } - } - FlatButton { - Layout.fillWidth: true - text: qsTr('Open Channel') - onClicked: { - var dialog = openChannelDialog.createObject(root) - dialog.open() + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Open Channel') + onClicked: { + var dialog = openChannelDialog.createObject(root) + dialog.open() + } + icon.source: '../../icons/lightning.png' } - icon.source: '../../icons/lightning.png' - } - FlatButton { - Layout.fillWidth: true - text: qsTr('Channel backups') - onClicked: { - app.stack.push(Qt.resolvedUrl('ChannelBackups.qml')) + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Channel backups') + onClicked: { + app.stack.push(Qt.resolvedUrl('ChannelBackups.qml')) + } + icon.source: '../../icons/file.png' } - icon.source: '../../icons/file.png' } } diff --git a/electrum/gui/qml/components/ExportTxDialog.qml b/electrum/gui/qml/components/ExportTxDialog.qml index 3170c3448..e745b81ba 100644 --- a/electrum/gui/qml/components/ExportTxDialog.qml +++ b/electrum/gui/qml/components/ExportTxDialog.qml @@ -64,8 +64,8 @@ ElDialog { color: Material.accentColor } - RowLayout { - Layout.fillWidth: true + ButtonContainer { + // Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter FlatButton { diff --git a/electrum/gui/qml/components/InvoiceDialog.qml b/electrum/gui/qml/components/InvoiceDialog.qml index 7a23b7768..a36db7c6a 100644 --- a/electrum/gui/qml/components/InvoiceDialog.qml +++ b/electrum/gui/qml/components/InvoiceDialog.qml @@ -337,39 +337,46 @@ ElDialog { } } - FlatButton { + ButtonContainer { Layout.fillWidth: true - text: qsTr('Pay') - icon.source: '../../icons/confirmed.png' - enabled: invoice.invoiceType != Invoice.Invalid && invoice.canPay && !amountContainer.editmode - onClicked: { - if (invoice_key == '') // save invoice if not retrieved from key - invoice.save_invoice() - dialog.close() - doPay() // only signal here + + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Pay') + icon.source: '../../icons/confirmed.png' + enabled: invoice.invoiceType != Invoice.Invalid && invoice.canPay && !amountContainer.editmode + onClicked: { + if (invoice_key == '') // save invoice if not retrieved from key + invoice.save_invoice() + dialog.close() + doPay() // only signal here + } } - } - FlatButton { - Layout.fillWidth: true - text: qsTr('Delete') - icon.source: '../../icons/delete.png' - visible: invoice_key != '' - onClicked: { - invoice.wallet.delete_invoice(invoice_key) - dialog.close() + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Delete') + icon.source: '../../icons/delete.png' + visible: invoice_key != '' + onClicked: { + invoice.wallet.delete_invoice(invoice_key) + dialog.close() + } } - } - FlatButton { - Layout.fillWidth: true - text: qsTr('Save') - icon.source: '../../icons/save.png' - visible: invoice_key == '' - enabled: invoice.canSave - onClicked: { - app.stack.push(Qt.resolvedUrl('Invoices.qml')) - invoice.save_invoice() - dialog.close() + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Save') + icon.source: '../../icons/save.png' + visible: invoice_key == '' + enabled: invoice.canSave + onClicked: { + app.stack.push(Qt.resolvedUrl('Invoices.qml')) + invoice.save_invoice() + dialog.close() + } } } diff --git a/electrum/gui/qml/components/NetworkOverview.qml b/electrum/gui/qml/components/NetworkOverview.qml index bcf78f52e..2ce5da262 100644 --- a/electrum/gui/qml/components/NetworkOverview.qml +++ b/electrum/gui/qml/components/NetworkOverview.qml @@ -161,26 +161,31 @@ Pane { } - FlatButton { + ButtonContainer { Layout.fillWidth: true - text: qsTr('Server Settings'); - icon.source: '../../icons/network.png' - onClicked: { - var dialog = serverConfig.createObject(root) - dialog.open() + + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Server Settings'); + icon.source: '../../icons/network.png' + onClicked: { + var dialog = serverConfig.createObject(root) + dialog.open() + } } - } - FlatButton { - Layout.fillWidth: true - text: qsTr('Proxy Settings'); - icon.source: '../../icons/status_connected_proxy.png' - onClicked: { - var dialog = proxyConfig.createObject(root) - dialog.open() + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Proxy Settings'); + icon.source: '../../icons/status_connected_proxy.png' + onClicked: { + var dialog = proxyConfig.createObject(root) + dialog.open() + } } } - } function setFeeHistogram() { diff --git a/electrum/gui/qml/components/ReceiveDialog.qml b/electrum/gui/qml/components/ReceiveDialog.qml index 2e89c7fd4..54bfa0477 100644 --- a/electrum/gui/qml/components/ReceiveDialog.qml +++ b/electrum/gui/qml/components/ReceiveDialog.qml @@ -241,7 +241,7 @@ ElDialog { color: Material.accentColor } - RowLayout { + ButtonContainer { id: buttons Layout.alignment: Qt.AlignHCenter FlatButton { diff --git a/electrum/gui/qml/components/SendDialog.qml b/electrum/gui/qml/components/SendDialog.qml index 656784cd3..56e4457a0 100644 --- a/electrum/gui/qml/components/SendDialog.qml +++ b/electrum/gui/qml/components/SendDialog.qml @@ -49,25 +49,32 @@ ElDialog { onFound: dialog.dispatch(scanData) } - FlatButton { + ButtonContainer { Layout.fillWidth: true - icon.source: '../../icons/pen.png' - text: qsTr('Manual input') - onClicked: { - var _mid = manualInputDialog.createObject(mainView) - _mid.accepted.connect(function() { - dialog.dispatch(_mid.recipient) - }) - _mid.open() + + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + icon.source: '../../icons/pen.png' + text: qsTr('Manual input') + onClicked: { + var _mid = manualInputDialog.createObject(mainView) + _mid.accepted.connect(function() { + dialog.dispatch(_mid.recipient) + }) + _mid.open() + } } - } - FlatButton { - Layout.fillWidth: true - icon.source: '../../icons/paste.png' - text: qsTr('Paste from clipboard') - onClicked: dialog.dispatch(AppController.clipboardToText()) + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + icon.source: '../../icons/paste.png' + text: qsTr('Paste from clipboard') + onClicked: dialog.dispatch(AppController.clipboardToText()) + } } + } Component { diff --git a/electrum/gui/qml/components/TxDetails.qml b/electrum/gui/qml/components/TxDetails.qml index 06c6602b3..afb85f2ab 100644 --- a/electrum/gui/qml/components/TxDetails.qml +++ b/electrum/gui/qml/components/TxDetails.qml @@ -315,8 +315,10 @@ Pane { } - RowLayout { + ButtonContainer { + Layout.fillWidth: true visible: txdetails.canSign || txdetails.canBroadcast + FlatButton { Layout.fillWidth: true Layout.preferredWidth: 1 @@ -333,7 +335,9 @@ Pane { } } - RowLayout { + ButtonContainer { + Layout.fillWidth: true + FlatButton { Layout.fillWidth: true Layout.preferredWidth: 1 @@ -359,15 +363,16 @@ Pane { visible: txdetails.canRemove onClicked: txdetails.removeLocalTx() } - } - FlatButton { - Layout.fillWidth: true - text: qsTr('Cancel Tx') - visible: txdetails.canCancel - onClicked: { - var dialog = rbfCancelDialog.createObject(root, { txid: root.txid }) - dialog.open() + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Cancel Tx') + visible: txdetails.canCancel + onClicked: { + var dialog = rbfCancelDialog.createObject(root, { txid: root.txid }) + dialog.open() + } } } diff --git a/electrum/gui/qml/components/WalletDetails.qml b/electrum/gui/qml/components/WalletDetails.qml index b8389d49d..ba908f70f 100644 --- a/electrum/gui/qml/components/WalletDetails.qml +++ b/electrum/gui/qml/components/WalletDetails.qml @@ -460,32 +460,40 @@ Pane { } } - FlatButton { + ButtonContainer { Layout.fillWidth: true - visible: Daemon.currentWallet.walletType == 'imported' - text: Daemon.currentWallet.isWatchOnly - ? qsTr('Import additional addresses') - : qsTr('Import additional keys') - onClicked: rootItem.importAddressesKeys() - } - FlatButton { - Layout.fillWidth: true - text: qsTr('Change Password') - onClicked: rootItem.changePassword() - icon.source: '../../icons/lock.png' - } - FlatButton { - Layout.fillWidth: true - text: qsTr('Delete Wallet') - onClicked: rootItem.deleteWallet() - icon.source: '../../icons/delete.png' - } - FlatButton { - Layout.fillWidth: true - text: qsTr('Enable Lightning') - onClicked: rootItem.enableLightning() - visible: Daemon.currentWallet && Daemon.currentWallet.canHaveLightning && !Daemon.currentWallet.isLightning - icon.source: '../../icons/lightning.png' + + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + visible: Daemon.currentWallet.walletType == 'imported' + text: Daemon.currentWallet.isWatchOnly + ? qsTr('Import additional addresses') + : qsTr('Import additional keys') + onClicked: rootItem.importAddressesKeys() + } + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Change Password') + onClicked: rootItem.changePassword() + icon.source: '../../icons/lock.png' + } + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Delete Wallet') + onClicked: rootItem.deleteWallet() + icon.source: '../../icons/delete.png' + } + FlatButton { + Layout.fillWidth: true + Layout.preferredWidth: 1 + text: qsTr('Enable Lightning') + onClicked: rootItem.enableLightning() + visible: Daemon.currentWallet && Daemon.currentWallet.canHaveLightning && !Daemon.currentWallet.isLightning + icon.source: '../../icons/lightning.png' + } } } diff --git a/electrum/gui/qml/components/WalletMainView.qml b/electrum/gui/qml/components/WalletMainView.qml index 08f8c079e..731d9ed07 100644 --- a/electrum/gui/qml/components/WalletMainView.qml +++ b/electrum/gui/qml/components/WalletMainView.qml @@ -154,8 +154,8 @@ Item { } } - RowLayout { - spacing: 0 + ButtonContainer { + Layout.fillWidth: true FlatButton { Layout.fillWidth: false @@ -169,17 +169,17 @@ Item { mainView.menu.y = mainView.height - mainView.menu.height } } - Rectangle { - Layout.fillWidth: false - Layout.preferredWidth: 2 - Layout.preferredHeight: parent.height * 2/3 - Layout.alignment: Qt.AlignVCenter - color: constants.darkerBackground - } - Item { - visible: !Daemon.currentWallet - Layout.fillWidth: true - } + // Rectangle { + // Layout.fillWidth: false + // Layout.preferredWidth: 2 + // Layout.preferredHeight: parent.height * 2/3 + // Layout.alignment: Qt.AlignVCenter + // color: constants.darkerBackground + // } + // Item { + // visible: !Daemon.currentWallet + // Layout.fillWidth: true + // } FlatButton { visible: Daemon.currentWallet Layout.fillWidth: true @@ -191,14 +191,14 @@ Item { dialog.open() } } - Rectangle { - visible: Daemon.currentWallet - Layout.fillWidth: false - Layout.preferredWidth: 2 - Layout.preferredHeight: parent.height * 2/3 - Layout.alignment: Qt.AlignVCenter - color: constants.darkerBackground - } + // Rectangle { + // visible: Daemon.currentWallet + // Layout.fillWidth: false + // Layout.preferredWidth: 2 + // Layout.preferredHeight: parent.height * 2/3 + // Layout.alignment: Qt.AlignVCenter + // color: constants.darkerBackground + // } FlatButton { visible: Daemon.currentWallet Layout.fillWidth: true