Skip to content

Commit 48444cb

Browse files
committed
Merge #240: Make entire Setting clickable, and engage ActionItem when clicked
4ee8c36 qml: engage the actionItem when the Setting is clicked (jarolrod) f8db323 qml: expose the currently loaded action item (jarolrod) 3d984a6 qml: refactor Setting and ExternalLink controls to be AbstractButtons (jarolrod) Pull request description: This makes the entire Setting a clickable object, and when it is clicked it will engage its actionItem. This means: - For ExternalLinks, it will go to the link - Will toggle options with have a Switch - Will give focus to ValueInputs [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/240) [![Intel macOS](https://img.shields.io/badge/OS-Intel%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/240) [![Apple Silicon macOS](https://img.shields.io/badge/OS-Apple%20Silicon%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos_arm64/insecure_mac_arm64_gui.zip?branch=pull/240) [![ARM64 Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/240) ACKs for top commit: johnny9: ACK 4ee8c36 Tree-SHA512: 6a75950b71b22086223ef1456d72b02ce471c6d382d124b30866c4e6d14f348f64623d4a1859f2821008db522502cebd0e8803f646d3c0e68195488c83cae14b
2 parents f3150f7 + 4ee8c36 commit 48444cb

File tree

7 files changed

+65
-27
lines changed

7 files changed

+65
-27
lines changed

src/qml/components/AboutOptions.qml

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ColumnLayout {
1717
link: "https://bitcoincore.org"
1818
iconSource: "image://images/caret-right"
1919
}
20+
onClicked: loadedItem.clicked()
2021
}
2122
Setting {
2223
Layout.fillWidth: true
@@ -26,6 +27,7 @@ ColumnLayout {
2627
link: "https://github.com/bitcoin/bitcoin"
2728
iconSource: "image://images/caret-right"
2829
}
30+
onClicked: loadedItem.clicked()
2931
}
3032
Setting {
3133
Layout.fillWidth: true
@@ -35,6 +37,7 @@ ColumnLayout {
3537
link: "https://opensource.org/licenses/MIT"
3638
iconSource: "image://images/caret-right"
3739
}
40+
onClicked: loadedItem.clicked()
3841
}
3942
Setting {
4043
Layout.fillWidth: true
@@ -44,6 +47,7 @@ ColumnLayout {
4447
link: "https://bitcoin.org/en/download"
4548
iconSource: "image://images/caret-right"
4649
}
50+
onClicked: loadedItem.clicked()
4751
}
4852
Setting {
4953
Layout.fillWidth: true
@@ -59,5 +63,6 @@ ColumnLayout {
5963
aboutSwipe.incrementCurrentIndex()
6064
}
6165
}
66+
onClicked: loadedItem.clicked()
6267
}
6368
}

src/qml/components/ConnectionSettings.qml

+16
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ ColumnLayout {
1717
checked: optionsModel.listen
1818
onToggled: optionsModel.listen = checked
1919
}
20+
onClicked: {
21+
loadedItem.toggle()
22+
loadedItem.toggled()
23+
}
2024
}
2125
Setting {
2226
Layout.fillWidth: true
@@ -25,6 +29,10 @@ ColumnLayout {
2529
checked: optionsModel.upnp
2630
onToggled: optionsModel.upnp = checked
2731
}
32+
onClicked: {
33+
loadedItem.toggle()
34+
loadedItem.toggled()
35+
}
2836
}
2937
Setting {
3038
Layout.fillWidth: true
@@ -33,6 +41,10 @@ ColumnLayout {
3341
checked: optionsModel.natpmp
3442
onToggled: optionsModel.natpmp = checked
3543
}
44+
onClicked: {
45+
loadedItem.toggle()
46+
loadedItem.toggled()
47+
}
3648
}
3749
Setting {
3850
Layout.fillWidth: true
@@ -41,6 +53,10 @@ ColumnLayout {
4153
checked: optionsModel.server
4254
onToggled: optionsModel.server = checked
4355
}
56+
onClicked: {
57+
loadedItem.toggle()
58+
loadedItem.toggled()
59+
}
4460
}
4561
Setting {
4662
last: true

src/qml/components/DeveloperOptions.qml

+4
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,23 @@ ColumnLayout {
1818
iconHeight: 30
1919
link: "https://bitcoin.org/en/bitcoin-core/contribute/documentation"
2020
}
21+
onClicked: loadedItem.clicked()
2122
}
2223
Setting {
2324
Layout.fillWidth: true
2425
header: qsTr("Database cache size")
2526
actionItem: ValueInput {
2627
description: ("450 MiB")
2728
}
29+
onClicked: loadedItem.forceActiveFocus()
2830
}
2931
Setting {
3032
Layout.fillWidth: true
3133
header: qsTr("Script verification threads")
3234
actionItem: ValueInput {
3335
description: ("0")
3436
}
37+
onClicked: loadedItem.forceActiveFocus()
3538
}
3639
Setting {
3740
Layout.fillWidth: true
@@ -40,5 +43,6 @@ ColumnLayout {
4043
checked: Theme.dark
4144
onToggled: Theme.toggleDark()
4245
}
46+
onClicked: loadedItem.toggled()
4347
}
4448
}

src/qml/components/StorageSettings.qml

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ ColumnLayout {
1616
checked: optionsModel.prune
1717
onToggled: optionsModel.prune = checked
1818
}
19+
onClicked: {
20+
loadedItem.toggle()
21+
loadedItem.toggled()
22+
}
1923
}
2024
Setting {
2125
Layout.fillWidth: true
@@ -24,5 +28,6 @@ ColumnLayout {
2428
description: optionsModel.pruneSizeGB
2529
onEditingFinished: optionsModel.pruneSizeGB = parseInt(text)
2630
}
31+
onClicked: loadedItem.forceActiveFocus()
2732
}
2833
}

src/qml/controls/ExternalLink.qml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import QtQuick 2.15
66
import QtQuick.Controls 2.15
77
import QtQuick.Layouts 1.15
88

9-
Control {
9+
AbstractButton {
1010
id: root
1111
required property string link
1212
property string description: ""
@@ -29,7 +29,6 @@ Control {
2929
color: Theme.color.neutral7
3030
textFormat: Text.RichText
3131
text: "<style>a:link { color: " + Theme.color.neutral7 + "; text-decoration: none;}</style>" + "<a href=\"" + link + "\">" + root.description + "</a>"
32-
onLinkActivated: Qt.openUrlExternally(link)
3332
}
3433
}
3534
Loader {
@@ -42,8 +41,9 @@ Control {
4241
icon.height: root.iconHeight
4342
icon.width: root.iconWidth
4443
background: null
45-
onClicked: Qt.openUrlExternally(link)
44+
onClicked: root.clicked()
4645
}
4746
}
4847
}
48+
onClicked: Qt.openUrlExternally(link)
4949
}

src/qml/controls/Setting.qml

+28-24
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,43 @@ import QtQuick 2.15
66
import QtQuick.Controls 2.15
77
import QtQuick.Layouts 1.15
88

9-
ColumnLayout {
9+
AbstractButton {
1010
id: root
1111
property bool last: parent && root === parent.children[parent.children.length - 1]
1212
required property string header
1313
property alias actionItem: action_loader.sourceComponent
14+
property alias loadedItem: action_loader.item
1415
property string description
1516

16-
spacing: 20
17-
RowLayout {
18-
Header {
19-
Layout.fillWidth: true
20-
center: false
21-
header: root.header
22-
headerSize: 18
23-
description: root.description
24-
descriptionSize: 15
25-
descriptionMargin: 0
17+
contentItem: ColumnLayout {
18+
spacing: 20
19+
width: parent.width
20+
RowLayout {
21+
Header {
22+
Layout.fillWidth: true
23+
center: false
24+
header: root.header
25+
headerSize: 18
26+
description: root.description
27+
descriptionSize: 15
28+
descriptionMargin: 0
29+
}
30+
Loader {
31+
id: action_loader
32+
active: true
33+
visible: active
34+
sourceComponent: root.actionItem
35+
}
2636
}
2737
Loader {
28-
id: action_loader
29-
active: true
38+
Layout.fillWidth: true
39+
Layout.columnSpan: 2
40+
active: !last
3041
visible: active
31-
sourceComponent: root.actionItem
32-
}
33-
}
34-
Loader {
35-
Layout.fillWidth: true
36-
Layout.columnSpan: 2
37-
active: !last
38-
visible: active
39-
sourceComponent: Rectangle {
40-
height: 1
41-
color: Theme.color.neutral5
42+
sourceComponent: Rectangle {
43+
height: 1
44+
color: Theme.color.neutral5
45+
}
4246
}
4347
}
4448
}

src/qml/pages/node/NodeSettings.qml

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Item {
4444
checked: Theme.dark
4545
onToggled: Theme.toggleDark()
4646
}
47+
onClicked: loadedItem.toggled()
4748
}
4849
Setting {
4950
Layout.fillWidth: true
@@ -58,6 +59,7 @@ Item {
5859
nodeSettingsView.push(about_page)
5960
}
6061
}
62+
onClicked: loadedItem.clicked()
6163
}
6264
Setting {
6365
Layout.fillWidth: true
@@ -72,6 +74,7 @@ Item {
7274
nodeSettingsView.push(storage_page)
7375
}
7476
}
77+
onClicked: loadedItem.clicked()
7578
}
7679
Setting {
7780
Layout.fillWidth: true
@@ -86,6 +89,7 @@ Item {
8689
nodeSettingsView.push(connection_page)
8790
}
8891
}
92+
onClicked: loadedItem.clicked()
8993
}
9094
}
9195
}

0 commit comments

Comments
 (0)