From 5e29b945612b0cfea1fea0a47edd2d01f0d4964d Mon Sep 17 00:00:00 2001 From: ThomasV Date: Tue, 18 Apr 2023 14:07:41 +0200 Subject: [PATCH] qml MessageDialog: split messages into title and header message. hide header if it is empty. --- electrum/gui/qml/components/ChannelBackups.qml | 2 +- electrum/gui/qml/components/ChannelDetails.qml | 5 ++--- electrum/gui/qml/components/Channels.qml | 2 +- electrum/gui/qml/components/MessageDialog.qml | 3 ++- electrum/gui/qml/components/OpenChannelDialog.qml | 2 +- electrum/gui/qml/components/Preferences.qml | 6 ++++-- electrum/gui/qml/components/TxDetails.qml | 13 ++++++++----- electrum/gui/qml/components/WalletDetails.qml | 8 ++++---- electrum/gui/qml/components/WalletMainView.qml | 4 ++-- electrum/gui/qml/components/main.qml | 6 +++--- 10 files changed, 28 insertions(+), 23 deletions(-) diff --git a/electrum/gui/qml/components/ChannelBackups.qml b/electrum/gui/qml/components/ChannelBackups.qml index 496509bee..73003a77a 100644 --- a/electrum/gui/qml/components/ChannelBackups.qml +++ b/electrum/gui/qml/components/ChannelBackups.qml @@ -93,7 +93,7 @@ Pane { Connections { target: Daemon.currentWallet function onImportChannelBackupFailed(message) { - var dialog = app.messageDialog.createObject(root, { text: message }) + var dialog = app.messageDialog.createObject(root, { title: qstr('Error'), text: message }) dialog.open() } } diff --git a/electrum/gui/qml/components/ChannelDetails.qml b/electrum/gui/qml/components/ChannelDetails.qml index 99965410f..d1f11c090 100644 --- a/electrum/gui/qml/components/ChannelDetails.qml +++ b/electrum/gui/qml/components/ChannelDetails.qml @@ -283,9 +283,8 @@ Pane { visible: channeldetails.canDelete onClicked: { var dialog = app.messageDialog.createObject(root, { - text: channeldetails.isBackup - ? qsTr('Are you sure you want to delete this channel backup?') - : qsTr('Are you sure you want to delete this channel? This will purge associated transactions from your wallet history.'), + title: qsTr('Are you sure?'), + text: channeldetails.isBackup ? '' : qsTr('This will purge associated transactions from your wallet history.'), yesno: true }) dialog.accepted.connect(function() { diff --git a/electrum/gui/qml/components/Channels.qml b/electrum/gui/qml/components/Channels.qml index b2a8f5628..dbe3d7888 100644 --- a/electrum/gui/qml/components/Channels.qml +++ b/electrum/gui/qml/components/Channels.qml @@ -163,7 +163,7 @@ Pane { Connections { target: Daemon.currentWallet function onImportChannelBackupFailed(message) { - var dialog = app.messageDialog.createObject(root, { text: message }) + var dialog = app.messageDialog.createObject(root, { title: qsTr('Error'), text: message }) dialog.open() } } diff --git a/electrum/gui/qml/components/MessageDialog.qml b/electrum/gui/qml/components/MessageDialog.qml index 1fcc74f30..06a6f0a0f 100644 --- a/electrum/gui/qml/components/MessageDialog.qml +++ b/electrum/gui/qml/components/MessageDialog.qml @@ -24,6 +24,7 @@ ElDialog { ColumnLayout { ColumnLayout { + visible: text Layout.margins: constants.paddingMedium Layout.alignment: Qt.AlignHCenter TextArea { @@ -39,7 +40,7 @@ ElDialog { } ButtonContainer { - Layout.fillWidth: true + Layout.preferredWidth: dialog.parent.width * 2/3 FlatButton { Layout.fillWidth: true diff --git a/electrum/gui/qml/components/OpenChannelDialog.qml b/electrum/gui/qml/components/OpenChannelDialog.qml index a14a3da2c..279e11792 100644 --- a/electrum/gui/qml/components/OpenChannelDialog.qml +++ b/electrum/gui/qml/components/OpenChannelDialog.qml @@ -214,7 +214,7 @@ ElDialog { } onValidationError: { if (code == 'invalid_nodeid') { - var dialog = app.messageDialog.createObject(app, { 'text': message }) + var dialog = app.messageDialog.createObject(app, { title: qsTr('Error'), 'text': message }) dialog.open() } } diff --git a/electrum/gui/qml/components/Preferences.qml b/electrum/gui/qml/components/Preferences.qml index c7ffe8cf3..c2cba8dd7 100644 --- a/electrum/gui/qml/components/Preferences.qml +++ b/electrum/gui/qml/components/Preferences.qml @@ -256,7 +256,8 @@ Pane { if (activeFocus) { if (!checked) { var dialog = app.messageDialog.createObject(app, { - text: qsTr('Using plain gossip mode is not recommended on mobile. Are you sure?'), + title: qsTr('Are you sure?'), + text: qsTr('Electrum will have to download the Lightning Network graph, which is not recommended on mobile.'), yesno: true }) dialog.accepted.connect(function() { @@ -291,7 +292,8 @@ Pane { if (activeFocus) { if (!checked) { var dialog = app.messageDialog.createObject(app, { - text: qsTr('Are you sure? This option allows you to recover your lightning funds if you lose your device, or if you uninstall this app while lightning channels are active. Do not disable it unless you know how to recover channels from backups.'), + title: qsTr('Are you sure?'), + text: qsTr('This option allows you to recover your lightning funds if you lose your device, or if you uninstall this app while lightning channels are active. Do not disable it unless you know how to recover channels from backups.'), yesno: true }) dialog.accepted.connect(function() { diff --git a/electrum/gui/qml/components/TxDetails.qml b/electrum/gui/qml/components/TxDetails.qml index 723d5e395..1435cf370 100644 --- a/electrum/gui/qml/components/TxDetails.qml +++ b/electrum/gui/qml/components/TxDetails.qml @@ -414,8 +414,8 @@ Pane { if (txid != txdetails.txid) return var dialog = app.messageDialog.createObject(app, { - text: qsTr('Transaction added to wallet history.') + '\n\n' + - qsTr('Note: this is an offline transaction, if you want the network to see it, you need to broadcast it.') + title: qsTr('Transaction added to wallet history.'), + text: qsTr('Note: this is an offline transaction, if you want the network to see it, you need to broadcast it.') }) dialog.open() root.close() @@ -446,7 +446,8 @@ Pane { txdetails.sign_and_broadcast() } else { var dialog = app.messageDialog.createObject(app, { - text: qsTr('Transaction fee updated.') + '\n\n' + qsTr('You still need to sign and broadcast this transaction.') + title: qsTr('Transaction fee updated.'), + text: qsTr('You still need to sign and broadcast this transaction.') }) dialog.open() } @@ -472,7 +473,8 @@ Pane { txdetails.sign_and_broadcast() } else { var dialog = app.messageDialog.createObject(app, { - text: qsTr('CPFP fee bump transaction created.') + '\n\n' + qsTr('You still need to sign and broadcast this transaction.') + title: qsTr('CPFP fee bump transaction created.'), + text: qsTr('You still need to sign and broadcast this transaction.') }) dialog.open() } @@ -497,7 +499,8 @@ Pane { txdetails.sign_and_broadcast() } else { var dialog = app.messageDialog.createObject(app, { - text: qsTr('Cancel transaction created.') + '\n\n' + qsTr('You still need to sign and broadcast this transaction.') + title: qsTr('Cancel transaction created.'), + text: qsTr('You still need to sign and broadcast this transaction.') }) dialog.open() } diff --git a/electrum/gui/qml/components/WalletDetails.qml b/electrum/gui/qml/components/WalletDetails.qml index f33fdf640..6d32a06e0 100644 --- a/electrum/gui/qml/components/WalletDetails.qml +++ b/electrum/gui/qml/components/WalletDetails.qml @@ -17,7 +17,7 @@ Pane { function enableLightning() { var dialog = app.messageDialog.createObject(rootItem, - {'text': qsTr('Enable Lightning for this wallet?'), 'yesno': true}) + {'title': qsTr('Enable Lightning for this wallet?'), 'yesno': true}) dialog.accepted.connect(function() { Daemon.currentWallet.enableLightning() }) @@ -466,19 +466,19 @@ Pane { } function onWalletDeleteError(code, message) { if (code == 'unpaid_requests') { - var dialog = app.messageDialog.createObject(app, {text: message, yesno: true }) + var dialog = app.messageDialog.createObject(app, {title: qsTr('Error'), text: message, yesno: true }) dialog.accepted.connect(function() { Daemon.checkThenDeleteWallet(Daemon.currentWallet, true) }) dialog.open() } else if (code == 'balance') { - var dialog = app.messageDialog.createObject(app, {text: message, yesno: true }) + var dialog = app.messageDialog.createObject(app, {title: qsTr('Error'), text: message, yesno: true }) dialog.accepted.connect(function() { Daemon.checkThenDeleteWallet(Daemon.currentWallet, true, true) }) dialog.open() } else { - var dialog = app.messageDialog.createObject(app, {text: message }) + var dialog = app.messageDialog.createObject(app, {title: qsTr('Error'), text: message }) dialog.open() } } diff --git a/electrum/gui/qml/components/WalletMainView.qml b/electrum/gui/qml/components/WalletMainView.qml index 8769c35e3..0940365b9 100644 --- a/electrum/gui/qml/components/WalletMainView.qml +++ b/electrum/gui/qml/components/WalletMainView.qml @@ -252,7 +252,7 @@ Item { dialog.open() } onLnurlError: { - var dialog = app.messageDialog.createObject(app, { text: message }) + var dialog = app.messageDialog.createObject(app, { title: qsTr('Error'), text: message }) dialog.open() } } @@ -370,7 +370,7 @@ Item { } onChannelBackupFound: { var dialog = app.messageDialog.createObject(app, { - text: qsTr('Import Channel backup?'), + title: qsTr('Import Channel backup?'), yesno: true }) dialog.accepted.connect(function() { diff --git a/electrum/gui/qml/components/main.qml b/electrum/gui/qml/components/main.qml index cbece771b..15eb7ed0f 100644 --- a/electrum/gui/qml/components/main.qml +++ b/electrum/gui/qml/components/main.qml @@ -375,7 +375,7 @@ ApplicationWindow app.handleAuthRequired(_swaphelper, method, authMessage) } onError: { - var dialog = app.messageDialog.createObject(app, { text: message }) + var dialog = app.messageDialog.createObject(app, { title: qsTr('Error'), text: message }) dialog.open() } } @@ -452,7 +452,7 @@ ApplicationWindow mainStackView.clear() } else { var dialog = app.messageDialog.createObject(app, { - text: qsTr('Close Electrum?'), + title: qsTr('Close Electrum?'), yesno: true }) dialog.accepted.connect(function() { @@ -578,7 +578,7 @@ ApplicationWindow qtobject.authProceed() return } - var dialog = app.messageDialog.createObject(app, {text: authMessage, yesno: true}) + var dialog = app.messageDialog.createObject(app, {title: authMessage, yesno: true}) dialog.accepted.connect(function() { qtobject.authProceed() })