Skip to content

Commit 3d984a6

Browse files
committed
qml: refactor Setting and ExternalLink controls to be AbstractButtons
This will allow us to make the entire setting clickable, engaging the action item. Will also allow for color interaction states.
1 parent f3150f7 commit 3d984a6

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

src/qml/controls/ExternalLink.qml

Lines changed: 3 additions & 3 deletions
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

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,42 @@ 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
1414
property string description
1515

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
16+
contentItem: ColumnLayout {
17+
spacing: 20
18+
width: parent.width
19+
RowLayout {
20+
Header {
21+
Layout.fillWidth: true
22+
center: false
23+
header: root.header
24+
headerSize: 18
25+
description: root.description
26+
descriptionSize: 15
27+
descriptionMargin: 0
28+
}
29+
Loader {
30+
id: action_loader
31+
active: true
32+
visible: active
33+
sourceComponent: root.actionItem
34+
}
2635
}
2736
Loader {
28-
id: action_loader
29-
active: true
37+
Layout.fillWidth: true
38+
Layout.columnSpan: 2
39+
active: !last
3040
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
41+
sourceComponent: Rectangle {
42+
height: 1
43+
color: Theme.color.neutral5
44+
}
4245
}
4346
}
4447
}

0 commit comments

Comments
 (0)