Skip to content

Commit 97ab51f

Browse files
committed
Slight rework of App Settings list
* Add divider support for spacing between groups * Alphabetize center group
1 parent c4ea24c commit 97ab51f

File tree

3 files changed

+66
-33
lines changed

3 files changed

+66
-33
lines changed

src/QmlControls/AppSettings.qml

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ Rectangle {
3535

3636
function showSettingsPage(settingsPage) {
3737
for (var i=0; i<buttonRepeater.count; i++) {
38-
var button = buttonRepeater.itemAt(i)
39-
if (button.text === settingsPage) {
40-
button.clicked()
38+
var loader = buttonRepeater.itemAt(i)
39+
if (loader && loader.item && loader.item.text === settingsPage) {
40+
loader.item.clicked()
4141
break
4242
}
4343
}
@@ -60,9 +60,10 @@ Rectangle {
6060
}
6161
}
6262

63-
6463
SettingsPagesModel { id: settingsPagesModel }
6564

65+
ButtonGroup { id: buttonGroup }
66+
6667
QGCFlickable {
6768
id: buttonList
6869
width: buttonColumn.width
@@ -77,24 +78,29 @@ Rectangle {
7778

7879
ColumnLayout {
7980
id: buttonColumn
80-
spacing: ScreenTools.defaultFontPixelHeight / 4
81+
spacing: 0
8182

8283
property real _maxButtonWidth: 0
8384

84-
Repeater {
85-
id: buttonRepeater
86-
model: settingsPagesModel
85+
Component {
86+
id: dividerComponent
87+
88+
Item { height: ScreenTools.defaultFontPixelHeight / 2 }
89+
}
90+
91+
Component {
92+
id: buttonComponent
8793

8894
SettingsButton {
89-
Layout.fillWidth: true
90-
text: name
91-
icon.source: iconUrl
92-
visible: pageVisible()
95+
text: modelName
96+
icon.source: modelIconUrl
97+
visible: modelPageVisible()
98+
ButtonGroup.group: buttonGroup
9399

94100
onClicked: {
95101
if (mainWindow.allowViewSwitch()) {
96-
if (rightPanel.source !== url) {
97-
rightPanel.source = url
102+
if (rightPanel.source !== modelUrl) {
103+
rightPanel.source = modelUrl
98104
}
99105
checked = true
100106
}
@@ -111,13 +117,28 @@ Rectangle {
111117
if (_commingFromRIDSettings) {
112118
checked = false
113119
_commingFromRIDSettings = false
114-
if (modelData.url == "qrc:/qml/QGroundControl/AppSettings/RemoteIDSettings.qml") {
120+
if (modelUrl == "qrc:/qml/QGroundControl/AppSettings/RemoteIDSettings.qml") {
115121
checked = true
116122
}
117123
}
118124
}
119125
}
120126
}
127+
128+
Repeater {
129+
id: buttonRepeater
130+
model: settingsPagesModel
131+
132+
Loader {
133+
Layout.fillWidth: true
134+
sourceComponent: name === "Divider" ? dividerComponent : buttonComponent
135+
136+
property var modelName: name
137+
property var modelIconUrl: iconUrl
138+
property var modelUrl: url
139+
property var modelPageVisible: pageVisible
140+
}
141+
}
121142
}
122143
}
123144

src/QmlControls/SettingsButton.qml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import QtQuick.Layouts
1414
import QGroundControl
1515
import QGroundControl.Controls
1616

17-
18-
1917
Button {
2018
id: control
2119
padding: ScreenTools.defaultFontPixelWidth * 0.75

src/UI/AppSettings/SettingsPagesModel.qml

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ ListModel {
4242
}
4343

4444
ListElement {
45-
name: qsTr("Telemetry")
46-
url: "qrc:/qml/QGroundControl/AppSettings/TelemetrySettings.qml"
47-
iconUrl: "qrc:/InstrumentValueIcons/drone.svg"
48-
pageVisible: function() { return true }
45+
name: "Divider"
4946
}
5047

5148
ListElement {
@@ -54,29 +51,38 @@ ListModel {
5451
iconUrl: "qrc:/InstrumentValueIcons/airplane.svg"
5552
pageVisible: function() { return true }
5653
}
57-
ListElement {
58-
name: qsTr("NTRIP/RTK")
59-
url: "qrc:/qml/QGroundControl/AppSettings/NTRIPSettings.qml"
60-
iconUrl: "qrc:/InstrumentValueIcons/globe.svg"
61-
pageVisible: function() {
62-
return QGroundControl.settingsManager &&
63-
QGroundControl.settingsManager.ntripSettings !== undefined
64-
}
65-
}
54+
6655
ListElement {
6756
name: qsTr("Comm Links")
6857
url: "qrc:/qml/QGroundControl/AppSettings/LinkSettings.qml"
6958
iconUrl: "qrc:/InstrumentValueIcons/usb.svg"
7059
pageVisible: function() { return true }
7160
}
7261

62+
ListElement {
63+
name: qsTr("Logging")
64+
url: "qrc:/qml/QGroundControl/Controls/AppLogging.qml"
65+
iconUrl: "qrc:/InstrumentValueIcons/conversation.svg"
66+
pageVisible: function() { return true }
67+
}
68+
7369
ListElement {
7470
name: qsTr("Maps")
7571
url: "qrc:/qml/QGroundControl/AppSettings/MapSettings.qml"
7672
iconUrl: "qrc:/InstrumentValueIcons/globe.svg"
7773
pageVisible: function() { return true }
7874
}
7975

76+
ListElement {
77+
name: qsTr("NTRIP/RTK")
78+
url: "qrc:/qml/QGroundControl/AppSettings/NTRIPSettings.qml"
79+
iconUrl: "qrc:/InstrumentValueIcons/globe.svg"
80+
pageVisible: function() {
81+
return QGroundControl.settingsManager &&
82+
QGroundControl.settingsManager.ntripSettings !== undefined
83+
}
84+
}
85+
8086
ListElement {
8187
name: qsTr("PX4 Log Transfer")
8288
url: "qrc:/qml/QGroundControl/AppSettings/PX4LogTransferSettings.qml"
@@ -97,19 +103,27 @@ ListModel {
97103
}
98104

99105
ListElement {
100-
name: qsTr("Logging")
101-
url: "qrc:/qml/QGroundControl/Controls/AppLogging.qml"
102-
iconUrl: "qrc:/InstrumentValueIcons/conversation.svg"
106+
name: qsTr("Telemetry")
107+
url: "qrc:/qml/QGroundControl/AppSettings/TelemetrySettings.qml"
108+
iconUrl: "qrc:/InstrumentValueIcons/drone.svg"
103109
pageVisible: function() { return true }
104110
}
105111

112+
ListElement {
113+
name: "Divider"
114+
}
115+
106116
ListElement {
107117
name: qsTr("Help")
108118
url: "qrc:/qml/QGroundControl/AppSettings/HelpSettings.qml"
109119
iconUrl: "qrc:/InstrumentValueIcons/question.svg"
110120
pageVisible: function() { return true }
111121
}
112122

123+
ListElement {
124+
name: "Divider"
125+
}
126+
113127
ListElement {
114128
name: qsTr("Mock Link")
115129
url: "qrc:/qml/QGroundControl/AppSettings/MockLink.qml"

0 commit comments

Comments
 (0)