From 3b9c009e43131e473ce024fdbbccb6aeb16b1ee2 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Tue, 26 Jul 2022 16:20:17 +0200 Subject: [PATCH] qml: include dialogs in back button navigation --- electrum/gui/qml/components/Channels.qml | 2 +- .../gui/qml/components/CloseChannelDialog.qml | 2 +- electrum/gui/qml/components/ConfirmTxDialog.qml | 2 +- .../gui/qml/components/GenericShareDialog.qml | 2 +- electrum/gui/qml/components/InvoiceDialog.qml | 2 +- .../LightningPaymentProgressDialog.qml | 2 +- electrum/gui/qml/components/MessageDialog.qml | 4 +++- electrum/gui/qml/components/PasswordDialog.qml | 2 +- electrum/gui/qml/components/Pin.qml | 4 +++- electrum/gui/qml/components/RequestDialog.qml | 2 +- .../qml/components/{Swap.qml => SwapDialog.qml} | 2 +- .../gui/qml/components/controls/ElDialog.qml | 17 +++++++++++++++++ electrum/gui/qml/components/main.qml | 10 ++++++++++ 13 files changed, 42 insertions(+), 11 deletions(-) rename electrum/gui/qml/components/{Swap.qml => SwapDialog.qml} (99%) create mode 100644 electrum/gui/qml/components/controls/ElDialog.qml diff --git a/electrum/gui/qml/components/Channels.qml b/electrum/gui/qml/components/Channels.qml index 4962d10dd..e02e6eec2 100644 --- a/electrum/gui/qml/components/Channels.qml +++ b/electrum/gui/qml/components/Channels.qml @@ -157,6 +157,6 @@ Pane { Component { id: swapDialog - Swap {} + SwapDialog {} } } diff --git a/electrum/gui/qml/components/CloseChannelDialog.qml b/electrum/gui/qml/components/CloseChannelDialog.qml index 66029c150..dcd5e776f 100644 --- a/electrum/gui/qml/components/CloseChannelDialog.qml +++ b/electrum/gui/qml/components/CloseChannelDialog.qml @@ -7,7 +7,7 @@ import org.electrum 1.0 import "controls" -Dialog { +ElDialog { id: dialog width: parent.width height: parent.height diff --git a/electrum/gui/qml/components/ConfirmTxDialog.qml b/electrum/gui/qml/components/ConfirmTxDialog.qml index e649fcaf2..af2e6ad5a 100644 --- a/electrum/gui/qml/components/ConfirmTxDialog.qml +++ b/electrum/gui/qml/components/ConfirmTxDialog.qml @@ -7,7 +7,7 @@ import org.electrum 1.0 import "controls" -Dialog { +ElDialog { id: dialog required property QtObject finalizer diff --git a/electrum/gui/qml/components/GenericShareDialog.qml b/electrum/gui/qml/components/GenericShareDialog.qml index ac2286fc2..0e4924e5f 100644 --- a/electrum/gui/qml/components/GenericShareDialog.qml +++ b/electrum/gui/qml/components/GenericShareDialog.qml @@ -5,7 +5,7 @@ import QtQuick.Controls.Material 2.0 import "controls" -Dialog { +ElDialog { id: dialog property string text diff --git a/electrum/gui/qml/components/InvoiceDialog.qml b/electrum/gui/qml/components/InvoiceDialog.qml index 48b8daee5..d92f6a0ee 100644 --- a/electrum/gui/qml/components/InvoiceDialog.qml +++ b/electrum/gui/qml/components/InvoiceDialog.qml @@ -7,7 +7,7 @@ import org.electrum 1.0 import "controls" -Dialog { +ElDialog { id: dialog property Invoice invoice diff --git a/electrum/gui/qml/components/LightningPaymentProgressDialog.qml b/electrum/gui/qml/components/LightningPaymentProgressDialog.qml index 3dc4191fe..aa4303c95 100644 --- a/electrum/gui/qml/components/LightningPaymentProgressDialog.qml +++ b/electrum/gui/qml/components/LightningPaymentProgressDialog.qml @@ -7,7 +7,7 @@ import org.electrum 1.0 import "controls" -Dialog { +ElDialog { id: dialog required property string invoice_key diff --git a/electrum/gui/qml/components/MessageDialog.qml b/electrum/gui/qml/components/MessageDialog.qml index cf8d86772..1307b7639 100644 --- a/electrum/gui/qml/components/MessageDialog.qml +++ b/electrum/gui/qml/components/MessageDialog.qml @@ -3,7 +3,9 @@ import QtQuick.Layouts 1.0 import QtQuick.Controls 2.3 import QtQuick.Controls.Material 2.0 -Dialog { +import "controls" + +ElDialog { id: dialog title: qsTr("Message") diff --git a/electrum/gui/qml/components/PasswordDialog.qml b/electrum/gui/qml/components/PasswordDialog.qml index aedcafd5f..5e53eaad9 100644 --- a/electrum/gui/qml/components/PasswordDialog.qml +++ b/electrum/gui/qml/components/PasswordDialog.qml @@ -7,7 +7,7 @@ import org.electrum 1.0 import "controls" -Dialog { +ElDialog { id: passworddialog title: qsTr("Enter Password") diff --git a/electrum/gui/qml/components/Pin.qml b/electrum/gui/qml/components/Pin.qml index 7c7b94cd8..3ab7d1af0 100644 --- a/electrum/gui/qml/components/Pin.qml +++ b/electrum/gui/qml/components/Pin.qml @@ -7,7 +7,7 @@ import org.electrum 1.0 import "controls" -Dialog { +ElDialog { id: root title: qsTr('PIN') @@ -31,6 +31,8 @@ Dialog { property bool canCancel: true + allowClose: canCancel + property string mode // [check, enter, change] property string pincode // old one passed in when change, new one passed out diff --git a/electrum/gui/qml/components/RequestDialog.qml b/electrum/gui/qml/components/RequestDialog.qml index 8c4a3c49a..1379bc689 100644 --- a/electrum/gui/qml/components/RequestDialog.qml +++ b/electrum/gui/qml/components/RequestDialog.qml @@ -7,7 +7,7 @@ import org.electrum 1.0 import "controls" -Dialog { +ElDialog { id: dialog title: qsTr('Payment Request') diff --git a/electrum/gui/qml/components/Swap.qml b/electrum/gui/qml/components/SwapDialog.qml similarity index 99% rename from electrum/gui/qml/components/Swap.qml rename to electrum/gui/qml/components/SwapDialog.qml index 3879c6d0f..e46642df2 100644 --- a/electrum/gui/qml/components/Swap.qml +++ b/electrum/gui/qml/components/SwapDialog.qml @@ -7,7 +7,7 @@ import org.electrum 1.0 import "controls" -Dialog { +ElDialog { id: root width: parent.width diff --git a/electrum/gui/qml/components/controls/ElDialog.qml b/electrum/gui/qml/components/controls/ElDialog.qml new file mode 100644 index 000000000..e059b0a3d --- /dev/null +++ b/electrum/gui/qml/components/controls/ElDialog.qml @@ -0,0 +1,17 @@ +import QtQuick 2.6 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 2.3 + +Dialog { + id: abstractdialog + + property bool allowClose: true + + onOpenedChanged: { + if (opened) { + app.activeDialog = abstractdialog + } else { + app.activeDialog = null + } + } +} diff --git a/electrum/gui/qml/components/main.qml b/electrum/gui/qml/components/main.qml index b90d74919..88f1f3f7f 100644 --- a/electrum/gui/qml/components/main.qml +++ b/electrum/gui/qml/components/main.qml @@ -27,6 +27,8 @@ ApplicationWindow property alias stack: mainStackView + property Dialog activeDialog: null + header: ToolBar { id: toolbar @@ -205,6 +207,14 @@ ApplicationWindow } onClosing: { + if (activeDialog) { + console.log('dialog on top') + if (activeDialog.allowClose) { + activeDialog.close() + } + close.accepted = false + return + } if (stack.depth > 1) { close.accepted = false stack.pop()