Skip to content

Commit 7b5f9c1

Browse files
committed
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.
1 parent a77c7f1 commit 7b5f9c1

9 files changed

+198
-100
lines changed

src/qml/pages/node/NetworkTraffic.qml

+10-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@ InformationPage {
1919
id: settings
2020
property alias trafficGraphScale: root.trafficGraphScale
2121
}
22-
22+
navLeftDetail: NavButton {
23+
iconSource: "image://images/caret-left"
24+
text: qsTr("Back")
25+
onClicked: root.back()
26+
}
27+
navMiddleDetail: Header {
28+
headerBold: true
29+
headerSize: 18
30+
header: qsTr("Network traffic")
31+
}
2332
bannerActive: false
2433
bold: true
2534
headerText: qsTr("Network Traffic")

src/qml/pages/node/NodeSettings.qml

+4-56
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,7 @@ Item {
122122
Component {
123123
id: about_page
124124
SettingsAbout {
125-
showHeader: false
126-
navLeftDetail: NavButton {
127-
iconSource: "image://images/caret-left"
128-
text: qsTr("Back")
129-
onClicked: {
130-
nodeSettingsView.pop()
131-
}
132-
}
133-
navMiddleDetail: Header {
134-
headerBold: true
135-
headerSize: 18
136-
header: qsTr("About")
137-
}
138-
devMiddleDetail: Header {
139-
headerBold: true
140-
headerSize: 18
141-
header: qsTr("Developer settings")
142-
}
125+
onBack: nodeSettingsView.pop()
143126
}
144127
}
145128
Component {
@@ -153,37 +136,13 @@ Item {
153136
Component {
154137
id: storage_page
155138
SettingsStorage {
156-
showHeader: false
157-
navLeftDetail: NavButton {
158-
iconSource: "image://images/caret-left"
159-
text: qsTr("Back")
160-
onClicked: {
161-
nodeSettingsView.pop()
162-
}
163-
}
164-
navMiddleDetail: Header {
165-
headerBold: true
166-
headerSize: 18
167-
header: qsTr("Storage settings")
168-
}
139+
onBack: nodeSettingsView.pop()
169140
}
170141
}
171142
Component {
172143
id: connection_page
173144
SettingsConnection {
174-
showHeader: false
175-
navLeftDetail: NavButton {
176-
iconSource: "image://images/caret-left"
177-
text: qsTr("Back")
178-
onClicked: {
179-
nodeSettingsView.pop()
180-
}
181-
}
182-
navMiddleDetail: Header {
183-
headerBold: true
184-
headerSize: 18
185-
header: qsTr("Connection settings")
186-
}
145+
onBack: nodeSettingsView.pop()
187146
}
188147
}
189148
Component {
@@ -210,18 +169,7 @@ Item {
210169
id: networktraffic_page
211170
NetworkTraffic {
212171
showHeader: false
213-
navLeftDetail: NavButton {
214-
iconSource: "image://images/caret-left"
215-
text: qsTr("Back")
216-
onClicked: {
217-
nodeSettingsView.pop()
218-
}
219-
}
220-
navMiddleDetail: Header {
221-
headerBold: true
222-
headerSize: 18
223-
header: qsTr("Network traffic")
224-
}
172+
onBack: nodeSettingsView.pop()
225173
}
226174
}
227175
}

src/qml/pages/onboarding/OnboardingConnection.qml

+2-6
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,8 @@ Page {
5353
onNext: root.next()
5454
}
5555
SettingsConnection {
56-
navRightDetail: NavButton {
57-
text: qsTr("Done")
58-
onClicked: {
59-
connections.decrementCurrentIndex()
60-
}
61-
}
56+
onboarding: true
57+
onBack: connections.decrementCurrentIndex()
6258
}
6359
}
6460
}

src/qml/pages/onboarding/OnboardingCover.qml

+2-7
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,8 @@ Page {
5353
onNext: root.next()
5454
}
5555
SettingsAbout {
56-
navLeftDetail: NavButton {
57-
iconSource: "image://images/caret-left"
58-
text: qsTr("Back")
59-
onClicked: {
60-
introductions.decrementCurrentIndex()
61-
}
62-
}
56+
onboarding: true
57+
onBack: introductions.decrementCurrentIndex()
6358
}
6459
}
6560
}

src/qml/pages/onboarding/OnboardingStorageAmount.qml

+2-6
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,8 @@ Page {
5454
}
5555
SettingsStorage {
5656
id: advancedStorage
57-
navRightDetail: NavButton {
58-
text: qsTr("Done")
59-
onClicked: {
60-
storages.decrementCurrentIndex()
61-
}
62-
}
57+
onboarding: true
58+
onBack: storages.decrementCurrentIndex()
6359
}
6460
}
6561
}

src/qml/pages/settings/SettingsAbout.qml

+44-16
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,11 @@ import "../../controls"
99
import "../../components"
1010

1111
Item {
12-
property alias navLeftDetail: aboutSwipe.navLeftDetail
13-
property alias navMiddleDetail: aboutSwipe.navMiddleDetail
14-
property alias devMiddleDetail: aboutSwipe.devMiddleDetail
15-
property alias showHeader: aboutSwipe.showHeader
12+
id: root
13+
signal back
14+
property bool onboarding: false
1615
SwipeView {
1716
id: aboutSwipe
18-
property alias navLeftDetail: about_settings.navLeftDetail
19-
property alias navMiddleDetail: about_settings.navMiddleDetail
20-
property alias devMiddleDetail: about_developer.navMiddleDetail
21-
property alias showHeader: about_settings.showHeader
2217
anchors.fill: parent
2318
interactive: false
2419
orientation: Qt.Horizontal
@@ -27,6 +22,7 @@ Item {
2722
bannerActive: false
2823
bannerMargin: 0
2924
bold: true
25+
showHeader: root.onboarding
3026
headerText: qsTr("About")
3127
headerMargin: 0
3228
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 {
3531
detailItem: AboutOptions {
3632
onNext: aboutSwipe.incrementCurrentIndex()
3733
}
34+
35+
states: [
36+
State {
37+
when: root.onboarding
38+
PropertyChanges {
39+
target: about_settings
40+
navLeftDetail: backButton
41+
navMiddleDetail: null
42+
}
43+
},
44+
State {
45+
when: !root.onboarding
46+
PropertyChanges {
47+
target: about_settings
48+
navLeftDetail: backButton
49+
navMiddleDetail: header
50+
}
51+
}
52+
]
53+
54+
Component {
55+
id: backButton
56+
NavButton {
57+
iconSource: "image://images/caret-left"
58+
text: qsTr("Back")
59+
onClicked: root.back()
60+
}
61+
}
62+
Component {
63+
id: header
64+
Header {
65+
headerBold: true
66+
headerSize: 18
67+
header: qsTr("About")
68+
}
69+
}
3870
}
3971
SettingsDeveloper {
4072
id: about_developer
41-
showHeader: about_settings.showHeader
42-
navLeftDetail: NavButton {
43-
iconSource: "image://images/caret-left"
44-
text: qsTr("Back")
45-
onClicked: {
46-
aboutSwipe.decrementCurrentIndex()
47-
}
48-
}
73+
onboarding: root.onboarding
74+
onBack: aboutSwipe.decrementCurrentIndex()
4975
}
5076
}
5177
}
78+
79+

src/qml/pages/settings/SettingsConnection.qml

+51-8
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,12 @@ import "../../controls"
99
import "../../components"
1010

1111
Item {
12-
property alias navRightDetail: connectionSwipe.navRightDetail
13-
property alias navMiddleDetail: connectionSwipe.navMiddleDetail
14-
property alias navLeftDetail: connectionSwipe.navLeftDetail
15-
property alias showHeader: connectionSwipe.showHeader
12+
id: root
13+
signal back
14+
property bool onboarding: false
1615
SwipeView {
1716
id: connectionSwipe
18-
property alias navRightDetail: connection_settings.navRightDetail
19-
property alias navMiddleDetail: connection_settings.navMiddleDetail
20-
property alias navLeftDetail: connection_settings.navLeftDetail
21-
property alias showHeader: connection_settings.showHeader
17+
property bool onboarding: false
2218
anchors.fill: parent
2319
interactive: false
2420
orientation: Qt.Horizontal
@@ -28,12 +24,59 @@ Item {
2824
clip: true
2925
bannerActive: false
3026
bold: true
27+
showHeader: root.onboarding
3128
headerText: qsTr("Connection settings")
3229
headerMargin: 0
3330
detailActive: true
3431
detailItem: ConnectionSettings {
3532
onNext: connectionSwipe.incrementCurrentIndex()
3633
}
34+
35+
states: [
36+
State {
37+
when: root.onboarding
38+
PropertyChanges {
39+
target: connection_settings
40+
navLeftDetail: null
41+
navMiddleDetail: null
42+
navRightDetail: doneButton
43+
}
44+
},
45+
State {
46+
when: !root.onboarding
47+
PropertyChanges {
48+
target: connection_settings
49+
navLeftDetail: backButton
50+
navMiddleDetail: header
51+
navRightDetail: null
52+
}
53+
}
54+
]
55+
56+
Component {
57+
id: backButton
58+
NavButton {
59+
iconSource: "image://images/caret-left"
60+
text: qsTr("Back")
61+
onClicked: root.back()
62+
}
63+
}
64+
Component {
65+
id: header
66+
Header {
67+
headerBold: true
68+
headerSize: 18
69+
header: qsTr("Connection settings")
70+
}
71+
}
72+
73+
Component {
74+
id: doneButton
75+
NavButton {
76+
text: qsTr("Done")
77+
onClicked: root.back()
78+
}
79+
}
3780
}
3881
SettingsProxy {
3982
onBackClicked: {

src/qml/pages/settings/SettingsDeveloper.qml

+36
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,46 @@ import "../../controls"
99
import "../../components"
1010

1111
InformationPage {
12+
id: root
13+
property bool onboarding: false
14+
navLeftDetail: NavButton {
15+
iconSource: "image://images/caret-left"
16+
text: qsTr("Back")
17+
onClicked: {
18+
root.back()
19+
}
20+
}
1221
bannerActive: false
1322
bold: true
23+
showHeader: root.onboarding
1424
headerText: qsTr("Developer options")
1525
headerMargin: 0
1626
detailActive: true
1727
detailItem: DeveloperOptions {}
28+
29+
states: [
30+
State {
31+
when: root.onboarding
32+
PropertyChanges {
33+
target: root
34+
navMiddleDetail: null
35+
}
36+
},
37+
State {
38+
when: !root.onboarding
39+
PropertyChanges {
40+
target: root
41+
navMiddleDetail: header
42+
}
43+
}
44+
]
45+
46+
Component {
47+
id: header
48+
Header {
49+
headerBold: true
50+
headerSize: 18
51+
header: qsTr("Developer settings")
52+
}
53+
}
1854
}

0 commit comments

Comments
 (0)