From fad9bd72e586237bb3ca6de7bca27c47392d547d Mon Sep 17 00:00:00 2001 From: jarolrod Date: Fri, 18 Oct 2024 20:02:08 -0400 Subject: [PATCH 1/5] qml: signal based navigation in onboarding Pages exist within a view, in this page <-> view dependency, somewhere inside of there, at least for views that are 'flows' or 'wizards,' there needs to be logic on: a) when to move to a new page b) what page to move to. We are currently handling this navigation logic primarily inside the definition of a page itself. Inside of the page, we assume a hard-coded ID for a parent view and call navigation function directly to the view from within the page itself telling it to: a) to pop or push b) the id of the page we want to push. This is bad because: 1. It creates a dependency between page declarations that does not need to exist. As in, PageB.qml doesn't really exist unless PageA.qml includes code to go to it. 2. This prevents us from being able to 'statically' define and clearly contain pages. Clearly containing pages makes it so that when we want to reason about PageA.qml, we only have to look inside of PageA.qml and the components that are used within that file; we don't have to go on a chase for interlinked dependencies on id's or properties that are hidden or at least not easy to find in other pages. 3. We should never assume outside id's from within a page, as these can change, and when they change, the page that assumes said outside id is now broken, and debugging can be annoying. All of this is unnecessary. In this commit, we address the issue of the logic for navigation being contained within the page definitions. This proposes a new navigation model based on signals and first applies it to the onboarding flow. Pages within our onboarding flow now: 1. Emit a signal when it's time to go to a new page 2. The parent View itself handles the signals and contains the logic for navigation. This removes the dependence on having a hardcoded outside ID within a a page, and is one step to moving us to pages with no dependency on other pages. --- src/qml/controls/InformationPage.qml | 4 ++- src/qml/pages/main.qml | 29 +++++++++++++++---- .../pages/onboarding/OnboardingBlockclock.qml | 3 +- .../pages/onboarding/OnboardingConnection.qml | 6 +++- src/qml/pages/onboarding/OnboardingCover.qml | 3 ++ .../onboarding/OnboardingStorageAmount.qml | 6 +++- .../onboarding/OnboardingStorageLocation.qml | 3 +- .../pages/onboarding/OnboardingStrengthen.qml | 3 +- 8 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/qml/controls/InformationPage.qml b/src/qml/controls/InformationPage.qml index 4139fab9a6..5db8f604a0 100644 --- a/src/qml/controls/InformationPage.qml +++ b/src/qml/controls/InformationPage.qml @@ -9,6 +9,8 @@ import org.bitcoincore.qt 1.0 Page { id: root + signal back + signal next implicitHeight: information.height + continueButton.height + buttonMargin property alias bannerItem: banner_loader.sourceComponent property alias detailItem: detail_loader.sourceComponent @@ -106,7 +108,7 @@ Page { anchors.rightMargin: 20 anchors.horizontalCenter: parent.horizontalCenter text: root.buttonText - onClicked: root.lastPage ? swipeView.finished = true : swipeView.incrementCurrentIndex() + onClicked: root.next() } } diff --git a/src/qml/pages/main.qml b/src/qml/pages/main.qml index 67526c80ae..80cb25a623 100644 --- a/src/qml/pages/main.qml +++ b/src/qml/pages/main.qml @@ -70,12 +70,29 @@ ApplicationWindow { property bool finished: false interactive: false - OnboardingCover {} - OnboardingStrengthen {} - OnboardingBlockclock {} - OnboardingStorageLocation {} - OnboardingStorageAmount {} - OnboardingConnection {} + OnboardingCover { + onNext: swipeView.incrementCurrentIndex() + } + OnboardingStrengthen { + onBack: swipeView.decrementCurrentIndex() + onNext: swipeView.incrementCurrentIndex() + } + OnboardingBlockclock { + onBack: swipeView.decrementCurrentIndex() + onNext: swipeView.incrementCurrentIndex() + } + OnboardingStorageLocation { + onBack: swipeView.decrementCurrentIndex() + onNext: swipeView.incrementCurrentIndex() + } + OnboardingStorageAmount { + onBack: swipeView.decrementCurrentIndex() + onNext: swipeView.incrementCurrentIndex() + } + OnboardingConnection { + onBack: swipeView.decrementCurrentIndex() + onNext: swipeView.finished = true + } onFinishedChanged: { optionsModel.onboard() diff --git a/src/qml/pages/onboarding/OnboardingBlockclock.qml b/src/qml/pages/onboarding/OnboardingBlockclock.qml index 91950fa9c3..dbddfd192f 100644 --- a/src/qml/pages/onboarding/OnboardingBlockclock.qml +++ b/src/qml/pages/onboarding/OnboardingBlockclock.qml @@ -8,10 +8,11 @@ import QtQuick.Layouts 1.15 import "../../controls" InformationPage { + id: root navLeftDetail: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") - onClicked: swipeView.decrementCurrentIndex() + onClicked: root.back() } bannerItem: Image { source: Theme.image.blocktime diff --git a/src/qml/pages/onboarding/OnboardingConnection.qml b/src/qml/pages/onboarding/OnboardingConnection.qml index d5c5b5875c..2bc860d477 100644 --- a/src/qml/pages/onboarding/OnboardingConnection.qml +++ b/src/qml/pages/onboarding/OnboardingConnection.qml @@ -10,6 +10,9 @@ import "../../components" import "../settings" Page { + id: root + signal back + signal next background: null clip: true SwipeView { @@ -21,7 +24,7 @@ Page { navLeftDetail: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") - onClicked: swipeView.decrementCurrentIndex() + onClicked: root.back() } bannerItem: Image { Layout.topMargin: 20 @@ -47,6 +50,7 @@ Page { lastPage: true buttonText: qsTr("Next") buttonMargin: 20 + onNext: root.next() } SettingsConnection { navRightDetail: NavButton { diff --git a/src/qml/pages/onboarding/OnboardingCover.qml b/src/qml/pages/onboarding/OnboardingCover.qml index 2a7dcbd237..632a46a642 100644 --- a/src/qml/pages/onboarding/OnboardingCover.qml +++ b/src/qml/pages/onboarding/OnboardingCover.qml @@ -10,6 +10,8 @@ import "../../components" import "../settings" Page { + id: root + signal next background: null clip: true SwipeView { @@ -48,6 +50,7 @@ Page { descriptionSize: 24 subtext: qsTr("100% open-source & open-design") buttonText: qsTr("Start") + onNext: root.next() } SettingsAbout { navLeftDetail: NavButton { diff --git a/src/qml/pages/onboarding/OnboardingStorageAmount.qml b/src/qml/pages/onboarding/OnboardingStorageAmount.qml index e4cdf06e20..419f1d2f50 100644 --- a/src/qml/pages/onboarding/OnboardingStorageAmount.qml +++ b/src/qml/pages/onboarding/OnboardingStorageAmount.qml @@ -10,6 +10,9 @@ import "../../components" import "../settings" Page { + id: root + signal back + signal next background: null clip: true SwipeView { @@ -21,7 +24,7 @@ Page { navLeftDetail: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") - onClicked: swipeView.decrementCurrentIndex() + onClicked: root.back() } bannerActive: false bold: true @@ -47,6 +50,7 @@ Page { } buttonText: qsTr("Next") buttonMargin: 20 + onNext: root.next() } SettingsStorage { id: advancedStorage diff --git a/src/qml/pages/onboarding/OnboardingStorageLocation.qml b/src/qml/pages/onboarding/OnboardingStorageLocation.qml index b2c3aa1e00..bff2070c59 100644 --- a/src/qml/pages/onboarding/OnboardingStorageLocation.qml +++ b/src/qml/pages/onboarding/OnboardingStorageLocation.qml @@ -10,10 +10,11 @@ import "../../controls" import "../../components" InformationPage { + id: root navLeftDetail: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") - onClicked: swipeView.decrementCurrentIndex() + onClicked: root.back() } bannerActive: false bold: true diff --git a/src/qml/pages/onboarding/OnboardingStrengthen.qml b/src/qml/pages/onboarding/OnboardingStrengthen.qml index df4b803c71..eecb8a3d6c 100644 --- a/src/qml/pages/onboarding/OnboardingStrengthen.qml +++ b/src/qml/pages/onboarding/OnboardingStrengthen.qml @@ -8,10 +8,11 @@ import QtQuick.Layouts 1.15 import "../../controls" InformationPage { + id: root navLeftDetail: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") - onClicked: swipeView.decrementCurrentIndex() + onClicked: root.back() } bannerItem: Image { source: Theme.image.network From 02a3b2519155ef77aea081e1c5b21f9fb08e12c3 Mon Sep 17 00:00:00 2001 From: jarolrod Date: Fri, 18 Oct 2024 22:02:49 -0400 Subject: [PATCH 2/5] qml: use signal based navigation in settings with subpages Here, pages are clearly contained, but the logic of moving to SettingsDeveloper from within SettingsAbout and SettingsProxy from within SettingsConnection is still contained here within the definitions of SettingsAbout and SettingsConnection. While all pages are independently still usable, we do want to iron out this one kink in a follow-up. --- src/qml/components/AboutOptions.qml | 4 +++- src/qml/components/ConnectionSettings.qml | 4 +++- src/qml/pages/settings/SettingsAbout.qml | 4 +++- src/qml/pages/settings/SettingsConnection.qml | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/qml/components/AboutOptions.qml b/src/qml/components/AboutOptions.qml index e20adf9609..23f5a59c37 100644 --- a/src/qml/components/AboutOptions.qml +++ b/src/qml/components/AboutOptions.qml @@ -8,6 +8,8 @@ import QtQuick.Layouts 1.15 import "../controls" ColumnLayout { + id: root + signal next spacing: 4 Setting { id: websiteLink @@ -69,7 +71,7 @@ ColumnLayout { color: gotoDeveloper.stateColor } onClicked: { - aboutSwipe.incrementCurrentIndex() + root.next() } } ExternalPopup { diff --git a/src/qml/components/ConnectionSettings.qml b/src/qml/components/ConnectionSettings.qml index 90625a7def..35e78b7a6e 100644 --- a/src/qml/components/ConnectionSettings.qml +++ b/src/qml/components/ConnectionSettings.qml @@ -8,6 +8,8 @@ import QtQuick.Layouts 1.15 import "../controls" ColumnLayout { + id: root + signal next spacing: 4 Setting { Layout.fillWidth: true @@ -69,6 +71,6 @@ ColumnLayout { actionItem: CaretRightIcon { color: gotoProxy.stateColor } - onClicked: connectionSwipe.incrementCurrentIndex() + onClicked: root.next() } } diff --git a/src/qml/pages/settings/SettingsAbout.qml b/src/qml/pages/settings/SettingsAbout.qml index 53fe08e0ab..58fcd15db3 100644 --- a/src/qml/pages/settings/SettingsAbout.qml +++ b/src/qml/pages/settings/SettingsAbout.qml @@ -32,7 +32,9 @@ Item { description: qsTr("Bitcoin Core is an open source project.\nIf you find it useful, please contribute.\n\n This is experimental software.") descriptionMargin: 20 detailActive: true - detailItem: AboutOptions {} + detailItem: AboutOptions { + onNext: aboutSwipe.incrementCurrentIndex() + } } SettingsDeveloper { id: about_developer diff --git a/src/qml/pages/settings/SettingsConnection.qml b/src/qml/pages/settings/SettingsConnection.qml index 9ff9094f11..be6a93e844 100644 --- a/src/qml/pages/settings/SettingsConnection.qml +++ b/src/qml/pages/settings/SettingsConnection.qml @@ -31,7 +31,9 @@ Item { headerText: qsTr("Connection settings") headerMargin: 0 detailActive: true - detailItem: ConnectionSettings {} + detailItem: ConnectionSettings { + onNext: connectionSwipe.incrementCurrentIndex() + } } SettingsProxy { onBackClicked: { From a77c7f138deda42076892c6a6c1d5c4869064b73 Mon Sep 17 00:00:00 2001 From: jarolrod Date: Fri, 18 Oct 2024 21:21:08 -0400 Subject: [PATCH 3/5] qml: use signal based navigation in CreateWallet pages, introduce wizard Makes our CreateWallet flow into a wizard, as that is what it should be. The CreateWalletWizard is introduced as a StackView with the associated pages implementing signal based navigation. Previously, there was an interlinked dependency between CreateName and CreatePassword in that CreateName would pass a string for walletName to CreatePassword. This dependency is removed by having CreateName set the string in a property contained in the CreateWalletWizard StackView, and CreatePassword pulling in this property to satisfy its requirement for walletName. This is a temporary workaround so that we can still have clearly contained pages here. A follow-up should move this into a more appropriate backend object --- src/Makefile.qt.include | 2 +- src/qml/bitcoin_qml.qrc | 2 +- src/qml/pages/main.qml | 6 +-- src/qml/pages/wallet/CreateBackup.qml | 6 ++- src/qml/pages/wallet/CreateConfirm.qml | 6 ++- src/qml/pages/wallet/CreateIntro.qml | 6 ++- src/qml/pages/wallet/CreateName.qml | 15 +++--- src/qml/pages/wallet/CreatePassword.qml | 8 ++-- .../{AddWallet.qml => CreateWalletWizard.qml} | 48 +++++++++++++++++-- 9 files changed, 72 insertions(+), 27 deletions(-) rename src/qml/pages/wallet/{AddWallet.qml => CreateWalletWizard.qml} (71%) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 1e27ddee98..33f4e26f24 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -428,12 +428,12 @@ QML_RES_QML = \ qml/pages/settings/SettingsProxy.qml \ qml/pages/settings/SettingsStorage.qml \ qml/pages/settings/SettingsTheme.qml \ - qml/pages/wallet/AddWallet.qml \ qml/pages/wallet/CreateBackup.qml \ qml/pages/wallet/CreateConfirm.qml \ qml/pages/wallet/CreateIntro.qml \ qml/pages/wallet/CreateName.qml \ qml/pages/wallet/CreatePassword.qml \ + qml/pages/wallet/CreateWalletWizard.qml \ qml/pages/wallet/DesktopWallets.qml \ qml/pages/wallet/WalletBadge.qml \ qml/pages/wallet/WalletSelect.qml diff --git a/src/qml/bitcoin_qml.qrc b/src/qml/bitcoin_qml.qrc index ec48e0c74d..e64fab65e1 100644 --- a/src/qml/bitcoin_qml.qrc +++ b/src/qml/bitcoin_qml.qrc @@ -68,12 +68,12 @@ pages/settings/SettingsProxy.qml pages/settings/SettingsStorage.qml pages/settings/SettingsTheme.qml - pages/wallet/AddWallet.qml pages/wallet/CreateBackup.qml pages/wallet/CreateConfirm.qml pages/wallet/CreateIntro.qml pages/wallet/CreateName.qml pages/wallet/CreatePassword.qml + pages/wallet/CreateWalletWizard.qml pages/wallet/DesktopWallets.qml pages/wallet/WalletBadge.qml pages/wallet/WalletSelect.qml diff --git a/src/qml/pages/main.qml b/src/qml/pages/main.qml index 80cb25a623..428e5f7527 100644 --- a/src/qml/pages/main.qml +++ b/src/qml/pages/main.qml @@ -98,7 +98,7 @@ ApplicationWindow { optionsModel.onboard() if (AppMode.walletEnabled && AppMode.isDesktop) { main.push(desktopWallets) - main.push(addWallet) + main.push(createWalletWizard) } else { main.push(node) } @@ -112,8 +112,8 @@ ApplicationWindow { } Component { - id: addWallet - AddWallet { + id: createWalletWizard + CreateWalletWizard { onFinished: { main.pop() } diff --git a/src/qml/pages/wallet/CreateBackup.qml b/src/qml/pages/wallet/CreateBackup.qml index fe01bed443..603b5ae989 100644 --- a/src/qml/pages/wallet/CreateBackup.qml +++ b/src/qml/pages/wallet/CreateBackup.qml @@ -12,6 +12,8 @@ import "../settings" Page { id: root + signal back + signal next background: null header: NavigationBar2 { @@ -20,7 +22,7 @@ Page { iconSource: "image://images/caret-left" text: qsTr("Back") onClicked: { - root.StackView.view.pop() + root.back() } } } @@ -83,7 +85,7 @@ Page { Layout.alignment: Qt.AlignCenter text: qsTr("Done") onClicked: { - root.StackView.view.finished() + root.next() } } } diff --git a/src/qml/pages/wallet/CreateConfirm.qml b/src/qml/pages/wallet/CreateConfirm.qml index 64a2e37e98..d99e7d41a6 100644 --- a/src/qml/pages/wallet/CreateConfirm.qml +++ b/src/qml/pages/wallet/CreateConfirm.qml @@ -12,6 +12,8 @@ import "../settings" Page { id: root + signal back + signal next background: null header: NavigationBar2 { @@ -20,7 +22,7 @@ Page { iconSource: "image://images/caret-left" text: qsTr("Back") onClicked: { - root.StackView.view.pop() + root.back() } } } @@ -67,7 +69,7 @@ Page { Layout.alignment: Qt.AlignCenter text: qsTr("Next") onClicked: { - root.StackView.view.push("qrc:/qml/pages/wallet/CreateBackup.qml") + root.next() } } } diff --git a/src/qml/pages/wallet/CreateIntro.qml b/src/qml/pages/wallet/CreateIntro.qml index ee1cb8bdf2..802a1d2a63 100644 --- a/src/qml/pages/wallet/CreateIntro.qml +++ b/src/qml/pages/wallet/CreateIntro.qml @@ -12,6 +12,8 @@ import "../settings" Page { id: root + signal back + signal next background: null header: NavigationBar2 { @@ -20,7 +22,7 @@ Page { iconSource: "image://images/caret-left" text: qsTr("Back") onClicked: { - root.StackView.view.pop() + root.back() } } } @@ -107,7 +109,7 @@ Page { Layout.alignment: Qt.AlignCenter text: qsTr("Start") onClicked: { - root.StackView.view.push("qrc:/qml/pages/wallet/CreateName.qml") + root.next() } } } diff --git a/src/qml/pages/wallet/CreateName.qml b/src/qml/pages/wallet/CreateName.qml index 5410cf3ba3..a780f23f76 100644 --- a/src/qml/pages/wallet/CreateName.qml +++ b/src/qml/pages/wallet/CreateName.qml @@ -12,6 +12,9 @@ import "../settings" Page { id: root + signal back + signal next + property string walletName: "" background: null header: NavigationBar2 { @@ -20,7 +23,7 @@ Page { iconSource: "image://images/caret-left" text: qsTr("Back") onClicked: { - root.StackView.view.pop() + root.back() } } } @@ -62,14 +65,8 @@ Page { text: qsTr("Continue") onClicked: { console.log("Creating wallet with name: " + walletNameInput.text) - root.StackView.view.push(createPassword) - } - } - - Component { - id: createPassword - CreatePassword { - walletName: walletNameInput.text + root.walletName = walletNameInput.text + root.next() } } } diff --git a/src/qml/pages/wallet/CreatePassword.qml b/src/qml/pages/wallet/CreatePassword.qml index 6b6cfcd624..595443e2ac 100644 --- a/src/qml/pages/wallet/CreatePassword.qml +++ b/src/qml/pages/wallet/CreatePassword.qml @@ -12,6 +12,8 @@ import "../settings" Page { id: root + signal back + signal next background: null required property string walletName; @@ -22,14 +24,14 @@ Page { iconSource: "image://images/caret-left" text: qsTr("Back") onClicked: { - root.StackView.view.pop() + root.back() } } rightItem: NavButton { text: qsTr("Skip") onClicked: { walletController.createSingleSigWallet(walletName, "") - root.StackView.view.push("qrc:/qml/pages/wallet/CreateConfirm.qml") + root.next() } } } @@ -108,7 +110,7 @@ Page { enabled: password.text != "" && passwordRepeat.text != "" && password.text == passwordRepeat.text && confirmToggle.loadedItem.checked onClicked: { walletController.createSingleSigWallet(walletName, password.text) - root.StackView.view.push("qrc:/qml/pages/wallet/CreateConfirm.qml") + root.next() } } } diff --git a/src/qml/pages/wallet/AddWallet.qml b/src/qml/pages/wallet/CreateWalletWizard.qml similarity index 71% rename from src/qml/pages/wallet/AddWallet.qml rename to src/qml/pages/wallet/CreateWalletWizard.qml index f77fc7ebf3..ff60b637f7 100644 --- a/src/qml/pages/wallet/AddWallet.qml +++ b/src/qml/pages/wallet/CreateWalletWizard.qml @@ -11,9 +11,10 @@ import "../settings" import "../wallet" StackView { - id: addWalletStack + id: root signal finished() + property string walletName: "" initialItem: Page { background: null @@ -23,7 +24,7 @@ StackView { rightItem: NavButton { text: qsTr("Skip") onClicked: { - addWalletStack.finished() + root.finished() } } } @@ -59,7 +60,7 @@ StackView { Layout.alignment: Qt.AlignCenter text: qsTr("Create wallet") onClicked: { - addWalletStack.push("qrc:/qml/pages/wallet/CreateIntro.qml"); + root.push(intro) } } @@ -79,5 +80,44 @@ StackView { } } } + Component { + id: intro + CreateIntro { + onBack: root.pop() + onNext: root.push(name) + } + } + Component { + id: name + CreateName { + id: createName + onBack: root.pop() + onNext: { + root.walletName = createName.walletName + root.push(password) + } + } + } + Component { + id: password + CreatePassword { + walletName: root.walletName + onBack: root.pop() + onNext: root.push(confirm) + } + } + Component { + id: confirm + CreateConfirm { + onBack: root.pop() + onNext: root.push(backup) + } + } + Component { + id: backup + CreateBackup { + onBack: root.pop() + onNext: root.finished() + } + } } - From 7b5f9c106ddbc514a5b48daeb52fc356988ecbbe Mon Sep 17 00:00:00 2001 From: jarolrod Date: Sat, 19 Oct 2024 19:38:03 -0400 Subject: [PATCH 4/5] qml: Use signal based navigation in NodeSettings, don't alias nav elems In containing pages, everything a page needs should be defined where the page is declared. Allowing to alias nav elements into a page breaks the idea of pages being statically defined. The action of aliasing down nav elements means that the real declaration of a page is not in its 'filename.qml', but instead where the page is used, meaning a page can be defined an infinite amount of times in an infinite amount of ways; we don't want this. The only reason that we were aliasing down nav elements is that we have reusable pages for settings and what elements the nav bar will contain is different depending on whether we are onboarding or not. So, we should treat that as the navbar for the page has two states, so we should have logic for these states instead of defining the page in different locations in different ways. This state logic is handled by setting a property of onboarding or not, a follow-up can potentially move this into an appropriate backend object such as AppMode. --- src/qml/pages/node/NetworkTraffic.qml | 11 +++- src/qml/pages/node/NodeSettings.qml | 60 ++----------------- .../pages/onboarding/OnboardingConnection.qml | 8 +-- src/qml/pages/onboarding/OnboardingCover.qml | 9 +-- .../onboarding/OnboardingStorageAmount.qml | 8 +-- src/qml/pages/settings/SettingsAbout.qml | 60 ++++++++++++++----- src/qml/pages/settings/SettingsConnection.qml | 59 +++++++++++++++--- src/qml/pages/settings/SettingsDeveloper.qml | 36 +++++++++++ src/qml/pages/settings/SettingsStorage.qml | 47 +++++++++++++++ 9 files changed, 198 insertions(+), 100 deletions(-) diff --git a/src/qml/pages/node/NetworkTraffic.qml b/src/qml/pages/node/NetworkTraffic.qml index c85bbf1b25..6937d58453 100644 --- a/src/qml/pages/node/NetworkTraffic.qml +++ b/src/qml/pages/node/NetworkTraffic.qml @@ -19,7 +19,16 @@ InformationPage { id: settings property alias trafficGraphScale: root.trafficGraphScale } - + navLeftDetail: NavButton { + iconSource: "image://images/caret-left" + text: qsTr("Back") + onClicked: root.back() + } + navMiddleDetail: Header { + headerBold: true + headerSize: 18 + header: qsTr("Network traffic") + } bannerActive: false bold: true headerText: qsTr("Network Traffic") diff --git a/src/qml/pages/node/NodeSettings.qml b/src/qml/pages/node/NodeSettings.qml index 19b207320d..45c1f0eda8 100644 --- a/src/qml/pages/node/NodeSettings.qml +++ b/src/qml/pages/node/NodeSettings.qml @@ -122,24 +122,7 @@ Item { Component { id: about_page SettingsAbout { - showHeader: false - navLeftDetail: NavButton { - iconSource: "image://images/caret-left" - text: qsTr("Back") - onClicked: { - nodeSettingsView.pop() - } - } - navMiddleDetail: Header { - headerBold: true - headerSize: 18 - header: qsTr("About") - } - devMiddleDetail: Header { - headerBold: true - headerSize: 18 - header: qsTr("Developer settings") - } + onBack: nodeSettingsView.pop() } } Component { @@ -153,37 +136,13 @@ Item { Component { id: storage_page SettingsStorage { - showHeader: false - navLeftDetail: NavButton { - iconSource: "image://images/caret-left" - text: qsTr("Back") - onClicked: { - nodeSettingsView.pop() - } - } - navMiddleDetail: Header { - headerBold: true - headerSize: 18 - header: qsTr("Storage settings") - } + onBack: nodeSettingsView.pop() } } Component { id: connection_page SettingsConnection { - showHeader: false - navLeftDetail: NavButton { - iconSource: "image://images/caret-left" - text: qsTr("Back") - onClicked: { - nodeSettingsView.pop() - } - } - navMiddleDetail: Header { - headerBold: true - headerSize: 18 - header: qsTr("Connection settings") - } + onBack: nodeSettingsView.pop() } } Component { @@ -210,18 +169,7 @@ Item { id: networktraffic_page NetworkTraffic { showHeader: false - navLeftDetail: NavButton { - iconSource: "image://images/caret-left" - text: qsTr("Back") - onClicked: { - nodeSettingsView.pop() - } - } - navMiddleDetail: Header { - headerBold: true - headerSize: 18 - header: qsTr("Network traffic") - } + onBack: nodeSettingsView.pop() } } } diff --git a/src/qml/pages/onboarding/OnboardingConnection.qml b/src/qml/pages/onboarding/OnboardingConnection.qml index 2bc860d477..e4b6bb75e7 100644 --- a/src/qml/pages/onboarding/OnboardingConnection.qml +++ b/src/qml/pages/onboarding/OnboardingConnection.qml @@ -53,12 +53,8 @@ Page { onNext: root.next() } SettingsConnection { - navRightDetail: NavButton { - text: qsTr("Done") - onClicked: { - connections.decrementCurrentIndex() - } - } + onboarding: true + onBack: connections.decrementCurrentIndex() } } } diff --git a/src/qml/pages/onboarding/OnboardingCover.qml b/src/qml/pages/onboarding/OnboardingCover.qml index 632a46a642..cadff79cb8 100644 --- a/src/qml/pages/onboarding/OnboardingCover.qml +++ b/src/qml/pages/onboarding/OnboardingCover.qml @@ -53,13 +53,8 @@ Page { onNext: root.next() } SettingsAbout { - navLeftDetail: NavButton { - iconSource: "image://images/caret-left" - text: qsTr("Back") - onClicked: { - introductions.decrementCurrentIndex() - } - } + onboarding: true + onBack: introductions.decrementCurrentIndex() } } } diff --git a/src/qml/pages/onboarding/OnboardingStorageAmount.qml b/src/qml/pages/onboarding/OnboardingStorageAmount.qml index 419f1d2f50..e590eff4ea 100644 --- a/src/qml/pages/onboarding/OnboardingStorageAmount.qml +++ b/src/qml/pages/onboarding/OnboardingStorageAmount.qml @@ -54,12 +54,8 @@ Page { } SettingsStorage { id: advancedStorage - navRightDetail: NavButton { - text: qsTr("Done") - onClicked: { - storages.decrementCurrentIndex() - } - } + onboarding: true + onBack: storages.decrementCurrentIndex() } } } diff --git a/src/qml/pages/settings/SettingsAbout.qml b/src/qml/pages/settings/SettingsAbout.qml index 58fcd15db3..b42d3973ee 100644 --- a/src/qml/pages/settings/SettingsAbout.qml +++ b/src/qml/pages/settings/SettingsAbout.qml @@ -9,16 +9,11 @@ import "../../controls" import "../../components" Item { - property alias navLeftDetail: aboutSwipe.navLeftDetail - property alias navMiddleDetail: aboutSwipe.navMiddleDetail - property alias devMiddleDetail: aboutSwipe.devMiddleDetail - property alias showHeader: aboutSwipe.showHeader + id: root + signal back + property bool onboarding: false SwipeView { id: aboutSwipe - property alias navLeftDetail: about_settings.navLeftDetail - property alias navMiddleDetail: about_settings.navMiddleDetail - property alias devMiddleDetail: about_developer.navMiddleDetail - property alias showHeader: about_settings.showHeader anchors.fill: parent interactive: false orientation: Qt.Horizontal @@ -27,6 +22,7 @@ Item { bannerActive: false bannerMargin: 0 bold: true + showHeader: root.onboarding headerText: qsTr("About") headerMargin: 0 description: qsTr("Bitcoin Core is an open source project.\nIf you find it useful, please contribute.\n\n This is experimental software.") @@ -35,17 +31,49 @@ Item { detailItem: AboutOptions { onNext: aboutSwipe.incrementCurrentIndex() } + + states: [ + State { + when: root.onboarding + PropertyChanges { + target: about_settings + navLeftDetail: backButton + navMiddleDetail: null + } + }, + State { + when: !root.onboarding + PropertyChanges { + target: about_settings + navLeftDetail: backButton + navMiddleDetail: header + } + } + ] + + Component { + id: backButton + NavButton { + iconSource: "image://images/caret-left" + text: qsTr("Back") + onClicked: root.back() + } + } + Component { + id: header + Header { + headerBold: true + headerSize: 18 + header: qsTr("About") + } + } } SettingsDeveloper { id: about_developer - showHeader: about_settings.showHeader - navLeftDetail: NavButton { - iconSource: "image://images/caret-left" - text: qsTr("Back") - onClicked: { - aboutSwipe.decrementCurrentIndex() - } - } + onboarding: root.onboarding + onBack: aboutSwipe.decrementCurrentIndex() } } } + + diff --git a/src/qml/pages/settings/SettingsConnection.qml b/src/qml/pages/settings/SettingsConnection.qml index be6a93e844..b729271e4a 100644 --- a/src/qml/pages/settings/SettingsConnection.qml +++ b/src/qml/pages/settings/SettingsConnection.qml @@ -9,16 +9,12 @@ import "../../controls" import "../../components" Item { - property alias navRightDetail: connectionSwipe.navRightDetail - property alias navMiddleDetail: connectionSwipe.navMiddleDetail - property alias navLeftDetail: connectionSwipe.navLeftDetail - property alias showHeader: connectionSwipe.showHeader + id: root + signal back + property bool onboarding: false SwipeView { id: connectionSwipe - property alias navRightDetail: connection_settings.navRightDetail - property alias navMiddleDetail: connection_settings.navMiddleDetail - property alias navLeftDetail: connection_settings.navLeftDetail - property alias showHeader: connection_settings.showHeader + property bool onboarding: false anchors.fill: parent interactive: false orientation: Qt.Horizontal @@ -28,12 +24,59 @@ Item { clip: true bannerActive: false bold: true + showHeader: root.onboarding headerText: qsTr("Connection settings") headerMargin: 0 detailActive: true detailItem: ConnectionSettings { onNext: connectionSwipe.incrementCurrentIndex() } + + states: [ + State { + when: root.onboarding + PropertyChanges { + target: connection_settings + navLeftDetail: null + navMiddleDetail: null + navRightDetail: doneButton + } + }, + State { + when: !root.onboarding + PropertyChanges { + target: connection_settings + navLeftDetail: backButton + navMiddleDetail: header + navRightDetail: null + } + } + ] + + Component { + id: backButton + NavButton { + iconSource: "image://images/caret-left" + text: qsTr("Back") + onClicked: root.back() + } + } + Component { + id: header + Header { + headerBold: true + headerSize: 18 + header: qsTr("Connection settings") + } + } + + Component { + id: doneButton + NavButton { + text: qsTr("Done") + onClicked: root.back() + } + } } SettingsProxy { onBackClicked: { diff --git a/src/qml/pages/settings/SettingsDeveloper.qml b/src/qml/pages/settings/SettingsDeveloper.qml index 598c1420e4..6eda0e5ff8 100644 --- a/src/qml/pages/settings/SettingsDeveloper.qml +++ b/src/qml/pages/settings/SettingsDeveloper.qml @@ -9,10 +9,46 @@ import "../../controls" import "../../components" InformationPage { + id: root + property bool onboarding: false + navLeftDetail: NavButton { + iconSource: "image://images/caret-left" + text: qsTr("Back") + onClicked: { + root.back() + } + } bannerActive: false bold: true + showHeader: root.onboarding headerText: qsTr("Developer options") headerMargin: 0 detailActive: true detailItem: DeveloperOptions {} + + states: [ + State { + when: root.onboarding + PropertyChanges { + target: root + navMiddleDetail: null + } + }, + State { + when: !root.onboarding + PropertyChanges { + target: root + navMiddleDetail: header + } + } + ] + + Component { + id: header + Header { + headerBold: true + headerSize: 18 + header: qsTr("Developer settings") + } + } } diff --git a/src/qml/pages/settings/SettingsStorage.qml b/src/qml/pages/settings/SettingsStorage.qml index 3c880b416c..6dffbc49b8 100644 --- a/src/qml/pages/settings/SettingsStorage.qml +++ b/src/qml/pages/settings/SettingsStorage.qml @@ -9,10 +9,57 @@ import "../../controls" import "../../components" InformationPage { + id: root + property bool onboarding: false bannerActive: false bold: true + showHeader: root.onboarding headerText: qsTr("Storage settings") headerMargin: 0 detailActive: true detailItem: StorageSettings {} + states: [ + State { + when: root.onboarding + PropertyChanges { + target: root + navLeftDetail: null + navMiddleDetail: null + navRightDetail: doneButton + } + }, + State { + when: !root.onboarding + PropertyChanges { + target: root + navLeftDetail: backButton + navMiddleDetail: header + navRightDetail: null + } + } + ] + + Component { + id: backButton + NavButton { + iconSource: "image://images/caret-left" + text: qsTr("Back") + onClicked: root.back() + } + } + Component { + id: header + Header { + headerBold: true + headerSize: 18 + header: qsTr("Storage Settings") + } + } + Component { + id: doneButton + NavButton { + text: qsTr("Done") + onClicked: root.back() + } + } } From 3f9424042b7bcaa9a4bafc6a466b3e8d0283325c Mon Sep 17 00:00:00 2001 From: jarolrod Date: Sat, 19 Oct 2024 02:29:26 -0400 Subject: [PATCH 5/5] qml: rename backClicked signal to back Renaming for consistency with other pages that 'back' signal and handles the 'back' signal. No reason to have some pages call this differently. --- src/qml/pages/node/NodeSettings.qml | 6 +++--- src/qml/pages/node/PeerDetails.qml | 6 +++--- src/qml/pages/node/Peers.qml | 4 ++-- src/qml/pages/settings/SettingsBlockClockDisplayMode.qml | 4 ++-- src/qml/pages/settings/SettingsConnection.qml | 2 +- src/qml/pages/settings/SettingsDisplay.qml | 8 ++++---- src/qml/pages/settings/SettingsProxy.qml | 4 ++-- src/qml/pages/settings/SettingsTheme.qml | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/qml/pages/node/NodeSettings.qml b/src/qml/pages/node/NodeSettings.qml index 45c1f0eda8..527da7dff4 100644 --- a/src/qml/pages/node/NodeSettings.qml +++ b/src/qml/pages/node/NodeSettings.qml @@ -128,7 +128,7 @@ Item { Component { id: display_page SettingsDisplay { - onBackClicked: { + onBack: { nodeSettingsView.pop() } } @@ -148,7 +148,7 @@ Item { Component { id: peers_page Peers { - onBackClicked: { + onBack: { nodeSettingsView.pop() peerTableModel.stopAutoRefresh(); } @@ -160,7 +160,7 @@ Item { Component { id: peer_details PeerDetails { - onBackClicked: { + onBack: { nodeSettingsView.pop() } } diff --git a/src/qml/pages/node/PeerDetails.qml b/src/qml/pages/node/PeerDetails.qml index c68dc36486..21d1364fbe 100644 --- a/src/qml/pages/node/PeerDetails.qml +++ b/src/qml/pages/node/PeerDetails.qml @@ -11,14 +11,14 @@ import "../../components" Page { id: root - signal backClicked() + signal back() property PeerDetailsModel details Connections { target: details function onDisconnected() { - root.backClicked() + root.back() } } @@ -27,7 +27,7 @@ Page { leftItem: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") - onClicked: root.backClicked() + onClicked: root.back() } centerItem: Header { headerBold: true diff --git a/src/qml/pages/node/Peers.qml b/src/qml/pages/node/Peers.qml index 173029ec7d..02d0e9aebb 100644 --- a/src/qml/pages/node/Peers.qml +++ b/src/qml/pages/node/Peers.qml @@ -11,7 +11,7 @@ import "../../controls" import "../../components" Page { - signal backClicked + signal back signal peerSelected(PeerDetailsModel peerDetails) id: root @@ -21,7 +21,7 @@ Page { leftItem: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") - onClicked: root.backClicked() + onClicked: root.back() } centerItem: Header { headerBold: true diff --git a/src/qml/pages/settings/SettingsBlockClockDisplayMode.qml b/src/qml/pages/settings/SettingsBlockClockDisplayMode.qml index 49c3badfc0..8cbf96231d 100644 --- a/src/qml/pages/settings/SettingsBlockClockDisplayMode.qml +++ b/src/qml/pages/settings/SettingsBlockClockDisplayMode.qml @@ -9,7 +9,7 @@ import "../../controls" import "../../components" Page { - signal backClicked + signal back id: root background: null @@ -22,7 +22,7 @@ Page { leftItem: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") - onClicked: root.backClicked() + onClicked: root.back() } centerItem: Header { headerBold: true diff --git a/src/qml/pages/settings/SettingsConnection.qml b/src/qml/pages/settings/SettingsConnection.qml index b729271e4a..c98b343a44 100644 --- a/src/qml/pages/settings/SettingsConnection.qml +++ b/src/qml/pages/settings/SettingsConnection.qml @@ -79,7 +79,7 @@ Item { } } SettingsProxy { - onBackClicked: { + onBack: { connectionSwipe.decrementCurrentIndex() } } diff --git a/src/qml/pages/settings/SettingsDisplay.qml b/src/qml/pages/settings/SettingsDisplay.qml index fc95b55e05..2c8d543452 100644 --- a/src/qml/pages/settings/SettingsDisplay.qml +++ b/src/qml/pages/settings/SettingsDisplay.qml @@ -9,7 +9,7 @@ import "../../controls" import "../../components" Item { - signal backClicked + signal back id: root @@ -29,7 +29,7 @@ Item { leftItem: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") - onClicked: root.backClicked() + onClicked: root.back() } centerItem: Header { headerBold: true @@ -70,7 +70,7 @@ Item { Component { id: theme_page SettingsTheme { - onBackClicked: { + onBack: { nodeSettingsView.pop() } } @@ -78,7 +78,7 @@ Item { Component { id: blockclocksize_page SettingsBlockClockDisplayMode { - onBackClicked: { + onBack: { nodeSettingsView.pop() } } diff --git a/src/qml/pages/settings/SettingsProxy.qml b/src/qml/pages/settings/SettingsProxy.qml index ce8a906f10..2f2d847a5b 100644 --- a/src/qml/pages/settings/SettingsProxy.qml +++ b/src/qml/pages/settings/SettingsProxy.qml @@ -9,7 +9,7 @@ import "../../controls" import "../../components" Page { - signal backClicked + signal back id: root @@ -23,7 +23,7 @@ Page { leftItem: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") - onClicked: root.backClicked() + onClicked: root.back() } centerItem: Header { headerBold: true diff --git a/src/qml/pages/settings/SettingsTheme.qml b/src/qml/pages/settings/SettingsTheme.qml index a65cd31881..4b223eb99f 100644 --- a/src/qml/pages/settings/SettingsTheme.qml +++ b/src/qml/pages/settings/SettingsTheme.qml @@ -9,7 +9,7 @@ import "../../controls" import "../../components" Page { - signal backClicked + signal back id: root background: null @@ -22,7 +22,7 @@ Page { leftItem: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") - onClicked: root.backClicked() + onClicked: root.back() } centerItem: Header { headerBold: true