Skip to content

Commit 46e93de

Browse files
committed
Merge #358: NavigationBar2 control
b5b73b0 qml: use NavigationBar2 in SettingsBlockClockDisplayMode (João Barbosa) a8cbe34 qml: use NavigationBar2 in SettingsDisplay (João Barbosa) 06ac24e qml: use NavigationBar2 in NodeSettings (João Barbosa) 3881dbc qml: use NavigationBar2 in SettingsProxy (João Barbosa) e0376f8 qml: use NavigationBar2 in SettingsTheme (João Barbosa) d3e3c0c qml: use NavigationBar2 in NodeRunner (João Barbosa) 416c994 qml: use NavigationBar2 in Peers (João Barbosa) 3505b2c qml: add NavigationBar2 (João Barbosa) Pull request description: This is an alternative to the existing `NavigationBar` component. The layout is such that the center section is horizontally centered when possible, and the right section is right aligned. Also, `Loader`s are avoided with this new approach. Since the approach is quite different from the other navigation bar, a full refactor would be substantial, harder to test and subject to breaking changes. For that reason, both implementations will be available for a short period of time. More pull requests will follow to replace the old implementation once this is accepted. Finally, the new navigation bar is used on the `Peers`, `NodeRunner`, and `ThemeSettings` pages. ACKs for top commit: jarolrod: tACK b5b73b0 Tree-SHA512: 91c072b715a4d6eafc520bee6ed1e820efc3c91541b3c7f56dab7617a13d1fd934d46ab11350e187aa22f8e29ce5e18eb4382b4b2784b1b3cdb7d79060866e21
2 parents 6caffba + b5b73b0 commit 46e93de

12 files changed

+172
-108
lines changed

src/Makefile.qt.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ QML_RES_QML = \
367367
qml/controls/NavButton.qml \
368368
qml/controls/PageIndicator.qml \
369369
qml/controls/NavigationBar.qml \
370+
qml/controls/NavigationBar2.qml \
370371
qml/controls/OptionButton.qml \
371372
qml/controls/OptionSwitch.qml \
372373
qml/controls/OutlineButton.qml \

src/qml/bitcoin_qml.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<file>controls/NavButton.qml</file>
2929
<file>controls/PageIndicator.qml</file>
3030
<file>controls/NavigationBar.qml</file>
31+
<file>controls/NavigationBar2.qml</file>
3132
<file>controls/OptionButton.qml</file>
3233
<file>controls/OptionSwitch.qml</file>
3334
<file>controls/OutlineButton.qml</file>

src/qml/controls/NavigationBar2.qml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Copyright (c) 2023 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
import QtQuick 2.15
6+
import QtQuick.Controls 2.15
7+
import QtQuick.Layouts 1.15
8+
9+
Pane {
10+
property alias leftItem: left_section.contentItem
11+
property alias centerItem: center_section.contentItem
12+
property alias rightItem: right_section.contentItem
13+
14+
background: null
15+
padding: 4
16+
contentItem: RowLayout {
17+
Div {
18+
id: left_div
19+
Layout.preferredWidth: Math.floor(Math.max(left_div.implicitWidth, right_div.implicitWidth))
20+
contentItem: RowLayout {
21+
Section {
22+
id: left_section
23+
}
24+
Spacer {
25+
}
26+
}
27+
}
28+
Section {
29+
id: center_section
30+
}
31+
Div {
32+
id: right_div
33+
Layout.preferredWidth: Math.floor(Math.max(left_div.implicitWidth, right_div.implicitWidth))
34+
contentItem: RowLayout {
35+
Spacer {
36+
}
37+
Section {
38+
id: right_section
39+
}
40+
}
41+
}
42+
}
43+
44+
component Div: Pane {
45+
Layout.alignment: Qt.AlignCenter
46+
Layout.fillWidth: true
47+
Layout.minimumWidth: implicitWidth
48+
background: null
49+
padding: 0
50+
}
51+
52+
component Section: Pane {
53+
Layout.alignment: Qt.AlignCenter
54+
Layout.minimumWidth: implicitWidth
55+
background: null
56+
padding: 0
57+
}
58+
59+
component Spacer: Item {
60+
Layout.alignment: Qt.AlignCenter
61+
Layout.fillWidth: true
62+
height: 1
63+
}
64+
}

src/qml/pages/main.qml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,13 @@ ApplicationWindow {
8282
interactive: false
8383
orientation: Qt.Vertical
8484
NodeRunner {
85-
navRightDetail: NavButton {
86-
iconSource: "image://images/gear"
87-
iconHeight: 24
88-
iconWidth: 24
89-
onClicked: node_swipe.incrementCurrentIndex()
85+
onSettingsClicked: {
86+
node_swipe.incrementCurrentIndex()
9087
}
9188
}
9289
NodeSettings {
93-
navMiddleDetail: Header {
94-
headerBold: true
95-
headerSize: 18
96-
header: "Settings"
97-
}
98-
navRightDetail: NavButton {
99-
text: qsTr("Done")
100-
onClicked: node_swipe.decrementCurrentIndex()
90+
onDoneClicked: {
91+
node_swipe.decrementCurrentIndex()
10192
}
10293
}
10394
}

src/qml/pages/node/NodeRunner.qml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ import "../../controls"
99
import "../../components"
1010

1111
Page {
12+
signal settingsClicked
13+
id: root
1214
background: null
1315
clip: true
14-
property alias navRightDetail: navbar.rightDetail
15-
header: NavigationBar {
16-
id: navbar
16+
header: NavigationBar2 {
17+
rightItem: NavButton {
18+
iconSource: "image://images/gear"
19+
iconHeight: 24
20+
iconWidth: 24
21+
onClicked: root.settingsClicked()
22+
}
1723
}
1824

1925
Component.onCompleted: nodeModel.startNodeInitializionThread();

src/qml/pages/node/NodeSettings.qml

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,32 @@ import "../../components"
1010
import "../settings"
1111

1212
Item {
13-
id: nodeSettings
14-
property alias navMiddleDetail: nodeSettingsView.navMiddleDetail
15-
property alias navRightDetail: nodeSettingsView.navRightDetail
13+
signal doneClicked
14+
15+
id: root
1616

1717
StackView {
1818
id: nodeSettingsView
19-
property alias navMiddleDetail: node_settings.navMiddleDetail
20-
property alias navRightDetail: node_settings.navRightDetail
2119
anchors.fill: parent
2220

2321
initialItem: Page {
2422
id: node_settings
25-
property alias navMiddleDetail: navbar.middleDetail
26-
property alias navRightDetail: navbar.rightDetail
2723
background: null
2824
implicitWidth: 450
2925
leftPadding: 20
3026
rightPadding: 20
3127
topPadding: 30
3228

33-
header: NavigationBar {
34-
id: navbar
29+
header: NavigationBar2 {
30+
centerItem: Header {
31+
headerBold: true
32+
headerSize: 18
33+
header: "Settings"
34+
}
35+
rightItem: NavButton {
36+
text: qsTr("Done")
37+
onClicked: root.doneClicked()
38+
}
3539
}
3640
ColumnLayout {
3741
spacing: 4
@@ -138,17 +142,8 @@ Item {
138142
Component {
139143
id: display_page
140144
SettingsDisplay {
141-
navLeftDetail: NavButton {
142-
iconSource: "image://images/caret-left"
143-
text: qsTr("Back")
144-
onClicked: {
145-
nodeSettingsView.pop()
146-
}
147-
}
148-
navMiddleDetail: Header {
149-
headerBold: true
150-
headerSize: 18
151-
header: qsTr("Display settings")
145+
onBackClicked: {
146+
nodeSettingsView.pop()
152147
}
153148
}
154149
}
@@ -191,18 +186,9 @@ Item {
191186
Component {
192187
id: peers_page
193188
Peers {
194-
navLeftDetail: NavButton {
195-
iconSource: "image://images/caret-left"
196-
text: qsTr("Back")
197-
onClicked: {
198-
nodeSettingsView.pop()
199-
peerTableModel.stopAutoRefresh();
200-
}
201-
}
202-
navMiddleDetail: Header {
203-
headerBold: true
204-
headerSize: 18
205-
header: qsTr("Peers")
189+
onBackClicked: {
190+
nodeSettingsView.pop()
191+
peerTableModel.stopAutoRefresh();
206192
}
207193
}
208194
}

src/qml/pages/node/Peers.qml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,22 @@ import "../../controls"
99
import "../../components"
1010

1111
Page {
12+
signal backClicked
13+
14+
id: root
1215
background: null
13-
property alias navLeftDetail: navbar.leftDetail
14-
property alias navMiddleDetail: navbar.middleDetail
1516

16-
header: NavigationBar {
17-
id: navbar
17+
header: NavigationBar2 {
18+
leftItem: NavButton {
19+
iconSource: "image://images/caret-left"
20+
text: qsTr("Back")
21+
onClicked: root.backClicked()
22+
}
23+
centerItem: Header {
24+
headerBold: true
25+
headerSize: 18
26+
header: qsTr("Peers")
27+
}
1828
}
1929

2030
ListView {

src/qml/pages/settings/SettingsBlockClockDisplayMode.qml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,26 @@ import "../../controls"
99
import "../../components"
1010

1111
Page {
12-
property alias navLeftDetail: navbar.leftDetail
13-
property alias navMiddleDetail: navbar.middleDetail
12+
signal backClicked
1413

14+
id: root
1515
background: null
1616
implicitWidth: 450
1717
leftPadding: 20
1818
rightPadding: 20
1919
topPadding: 30
2020

21-
header: NavigationBar {
22-
id: navbar
21+
header: NavigationBar2 {
22+
leftItem: NavButton {
23+
iconSource: "image://images/caret-left"
24+
text: qsTr("Back")
25+
onClicked: root.backClicked()
26+
}
27+
centerItem: Header {
28+
headerBold: true
29+
headerSize: 18
30+
header: qsTr("Block clock display mode")
31+
}
2332
}
2433
BlockClockDisplayMode {
2534
width: Math.min(parent.width, 450)

src/qml/pages/settings/SettingsConnection.qml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,8 @@ Item {
3434
detailItem: ConnectionSettings {}
3535
}
3636
SettingsProxy {
37-
navLeftDetail: NavButton {
38-
iconSource: "image://images/caret-left"
39-
text: qsTr("Back")
40-
onClicked: {
41-
connectionSwipe.decrementCurrentIndex()
42-
}
43-
}
44-
navMiddleDetail: Header {
45-
headerBold: true
46-
headerSize: 18
47-
header: qsTr("Proxy Settings")
37+
onBackClicked: {
38+
connectionSwipe.decrementCurrentIndex()
4839
}
4940
}
5041
}

src/qml/pages/settings/SettingsDisplay.qml

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,33 @@ import "../../controls"
99
import "../../components"
1010

1111
Item {
12-
property alias navLeftDetail: displaySettingsView.navLeftDetail
13-
property alias navMiddleDetail: displaySettingsView.navMiddleDetail
12+
signal backClicked
13+
14+
id: root
15+
1416
StackView {
1517
id: displaySettingsView
16-
property alias navLeftDetail: displaySettings.navLeftDetail
17-
property alias navMiddleDetail: displaySettings.navMiddleDetail
18-
property bool newcompilebool: false
1918
anchors.fill: parent
2019

21-
2220
initialItem: Page {
2321
id: displaySettings
24-
property alias navLeftDetail: navbar.leftDetail
25-
property alias navMiddleDetail: navbar.middleDetail
2622
background: null
2723
implicitWidth: 450
2824
leftPadding: 20
2925
rightPadding: 20
3026
topPadding: 30
3127

32-
header: NavigationBar {
33-
id: navbar
28+
header: NavigationBar2 {
29+
leftItem: NavButton {
30+
iconSource: "image://images/caret-left"
31+
text: qsTr("Back")
32+
onClicked: root.backClicked()
33+
}
34+
centerItem: Header {
35+
headerBold: true
36+
headerSize: 18
37+
header: qsTr("Display settings")
38+
}
3439
}
3540
ColumnLayout {
3641
spacing: 4
@@ -65,34 +70,16 @@ Item {
6570
Component {
6671
id: theme_page
6772
SettingsTheme {
68-
navLeftDetail: NavButton {
69-
iconSource: "image://images/caret-left"
70-
text: qsTr("Back")
71-
onClicked: {
72-
nodeSettingsView.pop()
73-
}
74-
}
75-
navMiddleDetail: Header {
76-
headerBold: true
77-
headerSize: 18
78-
header: qsTr("Theme")
73+
onBackClicked: {
74+
nodeSettingsView.pop()
7975
}
8076
}
8177
}
8278
Component {
8379
id: blockclocksize_page
8480
SettingsBlockClockDisplayMode {
85-
navLeftDetail: NavButton {
86-
iconSource: "image://images/caret-left"
87-
text: qsTr("Back")
88-
onClicked: {
89-
nodeSettingsView.pop()
90-
}
91-
}
92-
navMiddleDetail: Header {
93-
headerBold: true
94-
headerSize: 18
95-
header: qsTr("Block clock display mode")
81+
onBackClicked: {
82+
nodeSettingsView.pop()
9683
}
9784
}
9885
}

0 commit comments

Comments
 (0)