From 5380b215682758387a9858f120c083d43af50d55 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Wed, 16 Nov 2022 12:12:43 +0100 Subject: [PATCH] qml: wizard support for back button --- .../gui/qml/components/NewWalletWizard.qml | 2 +- .../qml/components/ServerConnectWizard.qml | 2 +- .../gui/qml/components/controls/ElDialog.qml | 4 ++ electrum/gui/qml/components/main.qml | 2 +- .../qml/components/wizard/WCAutoConnect.qml | 4 ++ electrum/gui/qml/components/wizard/Wizard.qml | 50 ++++++------------- 6 files changed, 26 insertions(+), 38 deletions(-) diff --git a/electrum/gui/qml/components/NewWalletWizard.qml b/electrum/gui/qml/components/NewWalletWizard.qml index a391a2525..a9789b8f7 100644 --- a/electrum/gui/qml/components/NewWalletWizard.qml +++ b/electrum/gui/qml/components/NewWalletWizard.qml @@ -9,7 +9,7 @@ import "wizard" Wizard { id: walletwizard - title: qsTr('New Wallet') + wizardTitle: qsTr('New Wallet') signal walletCreated diff --git a/electrum/gui/qml/components/ServerConnectWizard.qml b/electrum/gui/qml/components/ServerConnectWizard.qml index f126a831f..653c32bba 100644 --- a/electrum/gui/qml/components/ServerConnectWizard.qml +++ b/electrum/gui/qml/components/ServerConnectWizard.qml @@ -7,7 +7,7 @@ import "wizard" Wizard { id: serverconnectwizard - title: qsTr('How do you want to connect to a server?') + wizardTitle: qsTr('Network configuration') enter: null // disable transition diff --git a/electrum/gui/qml/components/controls/ElDialog.qml b/electrum/gui/qml/components/controls/ElDialog.qml index e1a28d6f2..9db30fcc7 100644 --- a/electrum/gui/qml/components/controls/ElDialog.qml +++ b/electrum/gui/qml/components/controls/ElDialog.qml @@ -8,6 +8,10 @@ Dialog { property bool allowClose: true property string iconSource + function doClose() { + close() + } + onOpenedChanged: { if (opened) { app.activeDialogs.push(abstractdialog) diff --git a/electrum/gui/qml/components/main.qml b/electrum/gui/qml/components/main.qml index b771b8d2b..b4730b904 100644 --- a/electrum/gui/qml/components/main.qml +++ b/electrum/gui/qml/components/main.qml @@ -276,7 +276,7 @@ ApplicationWindow if (activeDialogs.length > 0) { var activeDialog = activeDialogs[activeDialogs.length - 1] if (activeDialog.allowClose) { - activeDialog.close() + activeDialog.doClose() } else { console.log('dialog disallowed close') } diff --git a/electrum/gui/qml/components/wizard/WCAutoConnect.qml b/electrum/gui/qml/components/wizard/WCAutoConnect.qml index 51c4625a7..8bf6b1bdf 100644 --- a/electrum/gui/qml/components/wizard/WCAutoConnect.qml +++ b/electrum/gui/qml/components/wizard/WCAutoConnect.qml @@ -13,6 +13,10 @@ WizardComponent { ColumnLayout { width: parent.width + Label { + text: qsTr('How do you want to connect to a server?') + } + InfoTextArea { text: qsTr('Electrum communicates with remote servers to get information about your transactions and addresses. The servers all fulfill the same purpose only differing in hardware. In most cases you simply want to let Electrum pick one at random. However if you prefer feel free to select a server manually.') Layout.fillWidth: true diff --git a/electrum/gui/qml/components/wizard/Wizard.qml b/electrum/gui/qml/components/wizard/Wizard.qml index d6b9d40dd..fc16422df 100644 --- a/electrum/gui/qml/components/wizard/Wizard.qml +++ b/electrum/gui/qml/components/wizard/Wizard.qml @@ -2,7 +2,9 @@ import QtQuick 2.6 import QtQuick.Layouts 1.0 import QtQuick.Controls 2.1 -Dialog { +import "../controls" + +ElDialog { id: wizard modal: true focus: true @@ -10,10 +12,22 @@ Dialog { width: parent.width height: parent.height + title: wizardTitle + (pages.currentItem.title ? ' - ' + pages.currentItem.title : '') + iconSource: '../../../icons/electrum.png' + + property string wizardTitle + property var wizard_data property alias pages: pages property QtObject wiz + function doClose() { + if (pages.currentIndex == 0) + reject() + else + pages.prev() + } + function _setWizardData(wdata) { wizard_data = {} Object.assign(wizard_data, wdata) // deep copy @@ -32,7 +46,6 @@ Dialog { } var url = Qt.resolvedUrl(wiz.viewToComponent(view)) - console.log(url) var comp = Qt.createComponent(url) if (comp.status == Component.Error) { console.log(comp.errorString()) @@ -156,39 +169,6 @@ Dialog { } } - header: GridLayout { - columns: 2 - rowSpacing: 0 - - Image { - source: "../../../icons/electrum.png" - Layout.preferredWidth: constants.iconSizeXLarge - Layout.preferredHeight: constants.iconSizeXLarge - Layout.leftMargin: constants.paddingMedium - Layout.topMargin: constants.paddingMedium - Layout.bottomMargin: constants.paddingMedium - } - - Label { - text: title + (pages.currentItem.title ? ' - ' + pages.currentItem.title : '') - elide: Label.ElideRight - Layout.fillWidth: true - topPadding: constants.paddingXLarge - bottomPadding: constants.paddingXLarge - font.bold: true - font.pixelSize: constants.fontSizeMedium - } - - Rectangle { - Layout.columnSpan: 2 - Layout.fillWidth: true - Layout.leftMargin: constants.paddingTiny - Layout.rightMargin: constants.paddingTiny - height: 1 - color: Qt.rgba(0,0,0,0.5) - } - } - // make clicking the dialog background move the scope away from textedit fields // so the keyboard goes away // TODO: here it works on desktop, but not android. hmm.