Skip to content

Commit 3596450

Browse files
committed
Settings: rename visible to userVisible, show shortDesc, improve UX
- Rename SettingsFact::visible and SettingsGroup::visible properties to userVisible across C++, QML, and JSON to clarify intent and eliminate the duplicate Q_PROPERTY on SettingsFact. - Show shortDescription text below each generated settings control. - Add label and shortDesc to the settings search index. - Rewrite all shortDesc values across 12 SettingsGroup.json files and UnitsSettings.cc to be informative, user-facing descriptions. - Fix settings sidebar: clicking an expanded group now collapses it, and collapsing the selected group resets the section filter. - Rename generated page QML files to match their display names (e.g. AppSettings.qml -> GeneralSettings.qml). - Remove bogus QGroundControl.Palette imports from NTRIP QML files.
1 parent 8921187 commit 3596450

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+290
-257
lines changed

custom-example/src/CustomPlugin.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,20 @@ void CustomPlugin::_addSettingsEntry(const QString &title, const char *qmlFile,
7373
);
7474
}
7575

76-
void CustomPlugin::adjustSettingMetaData(const QString& settingsGroup, FactMetaData& metaData, bool &visible)
76+
void CustomPlugin::adjustSettingMetaData(const QString& settingsGroup, FactMetaData& metaData, bool &userVisible)
7777
{
78-
QGCCorePlugin::adjustSettingMetaData(settingsGroup, metaData, visible);
78+
QGCCorePlugin::adjustSettingMetaData(settingsGroup, metaData, userVisible);
7979

8080
if (settingsGroup == AppSettings::settingsGroup) {
8181
// This tells QGC than when you are creating Plans while not connected to a vehicle
8282
// the specific firmware/vehicle the plan is for.
8383
if (metaData.name() == AppSettings::offlineEditingFirmwareClassName) {
8484
metaData.setRawDefaultValue(QGCMAVLink::FirmwareClassPX4);
85-
visible = false;
85+
userVisible = false;
8686
return;
8787
} else if (metaData.name() == AppSettings::offlineEditingVehicleClassName) {
8888
metaData.setRawDefaultValue(QGCMAVLink::VehicleClassMultiRotor);
89-
visible = false;
89+
userVisible = false;
9090
return;
9191
}
9292
}

custom-example/src/CustomPlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class CustomPlugin : public QGCCorePlugin
6565
void cleanup() final;
6666
QGCOptions *options() final { return _options; }
6767
/// This allows you to override/hide QGC Application settings
68-
void adjustSettingMetaData(const QString &settingsGroup, FactMetaData &metaData, bool &visible) final;
68+
void adjustSettingMetaData(const QString &settingsGroup, FactMetaData &metaData, bool &userVisible) final;
6969
/// This modifies QGC colors palette to match possible custom corporate branding
7070
void paletteOverride(const QString &colorName, QGCPalette::PaletteColorInfo_t &colorInfo) final;
7171
/// We override this so we can get access to QQmlApplicationEngine and use it to register our qml module

src/API/QGCCorePlugin.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ const QmlObjectListModel *QGCCorePlugin::customMapItems()
101101
return _emptyCustomMapItems;
102102
}
103103

104-
void QGCCorePlugin::adjustSettingMetaData(const QString &settingsGroup, FactMetaData &metaData, bool &visible)
104+
void QGCCorePlugin::adjustSettingMetaData(const QString &settingsGroup, FactMetaData &metaData, bool &userVisible)
105105
{
106106
#ifdef Q_OS_ANDROID
107-
Q_UNUSED(visible);
107+
Q_UNUSED(userVisible);
108108
#endif
109109

110110
if (settingsGroup == AppSettings::settingsGroup) {
@@ -126,7 +126,7 @@ void QGCCorePlugin::adjustSettingMetaData(const QString &settingsGroup, FactMeta
126126
#endif
127127
#ifndef Q_OS_ANDROID
128128
else if (metaData.name() == AppSettings::androidDontSaveToSDCardName) {
129-
visible = false;
129+
userVisible = false;
130130
return;
131131
}
132132
#endif

src/API/QGCCorePlugin.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ class QGCCorePlugin : public QObject
7070
/// Allows the core plugin to override the meta data before the fact is created.
7171
/// @param settingsGroup - QSettings group which contains this item
7272
/// @param metaData - MetaData for setting fact
73-
/// @param visible - true: Setting should be visible in ui, false: Setting should not be shown in ui (default value will be used as value)
74-
/// If not overridden, metaData and visible are left unchanged.
75-
virtual void adjustSettingMetaData(const QString &settingsGroup, FactMetaData &metaData, bool &visible);
73+
/// @param userVisible - true: Setting should be visible in ui, false: Setting should not be shown in ui (default value will be used as value)
74+
/// If not overridden, metaData and userVisible are left unchanged.
75+
virtual void adjustSettingMetaData(const QString &settingsGroup, FactMetaData &metaData, bool &userVisible);
7676

7777
/// @return The message to show to the user when they are prompted to confirm turning on advanced ui.
7878
virtual QString showAdvancedUIMessage() const;

src/AutoPilotPlugins/APM/APMRemoteSupportComponent.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SetupPage {
2323
rowSpacing: ScreenTools.defaultFontPixelWidth
2424

2525
QGCLabel {
26-
visible: QGroundControl.settingsManager.mavlinkSettings.forwardMavlinkAPMSupportHostName.visible
26+
visible: QGroundControl.settingsManager.mavlinkSettings.forwardMavlinkAPMSupportHostName.userVisible
2727
text: qsTr("Host name:")
2828
}
2929
FactTextField {

src/FactSystem/SettingsFact.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ SettingsFact::SettingsFact(const QString &settingsGroup, FactMetaData *metaData,
2626
}
2727

2828
// Allow core plugin a chance to override the default value
29-
SettingsManager::adjustSettingMetaData(settingsGroup, *metaData, _visible);
29+
SettingsManager::adjustSettingMetaData(settingsGroup, *metaData, _userVisible);
3030
setMetaData(metaData);
3131

3232
if (metaData->defaultValueAvailable()) {
@@ -36,7 +36,7 @@ SettingsFact::SettingsFact(const QString &settingsGroup, FactMetaData *metaData,
3636
if (qgcApp()->runningUnitTests()) {
3737
// Don't use saved settings
3838
resolvedValue = rawDefaultValue;
39-
} else if (_visible) {
39+
} else if (_userVisible) {
4040
QVariant typedValue;
4141
QString errorString;
4242
(void) metaData->convertAndValidateRaw(settings.value(_name, rawDefaultValue), true /* conertOnly */, typedValue, errorString);

src/FactSystem/SettingsFact.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ Q_DECLARE_LOGGING_CATEGORY(SettingsFactLog)
1212
class SettingsFact : public Fact
1313
{
1414
Q_OBJECT
15-
Q_PROPERTY(bool visible MEMBER _visible CONSTANT)
16-
Q_PROPERTY(bool userVisible MEMBER _visible CONSTANT)
15+
/// Whether this setting should be shown in the UI. When false the setting is
16+
/// hidden from the user and its value is forced to the default. Controlled by
17+
/// QGCCorePlugin::adjustSettingMetaData and settings-override JSON files.
18+
Q_PROPERTY(bool userVisible MEMBER _userVisible CONSTANT)
1719

1820
public:
1921
explicit SettingsFact(QObject *parent = nullptr);
@@ -24,12 +26,12 @@ class SettingsFact : public Fact
2426
const SettingsFact &operator=(const SettingsFact &other);
2527

2628
// Must be called before any references to fact
27-
void setVisible(bool visible) { _visible = visible; }
29+
void setUserVisible(bool userVisible) { _userVisible = userVisible; }
2830

2931
private slots:
3032
void _rawValueChanged(const QVariant &value);
3133

3234
private:
3335
QString _settingsGroup;
34-
bool _visible = true;
36+
bool _userVisible = true;
3537
};

src/QmlControls/AppLogging.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Item {
100100
anchors.leftMargin: ScreenTools.defaultFontPixelWidth
101101
anchors.verticalCenter: gstCombo.verticalCenter
102102
text: qsTr("GStreamer Debug Level")
103-
visible: QGroundControl.settingsManager.appSettings.gstDebugLevel.visible
103+
visible: QGroundControl.settingsManager.appSettings.gstDebugLevel.userVisible
104104
}
105105

106106
FactComboBox {
@@ -109,7 +109,7 @@ Item {
109109
anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
110110
anchors.bottom: parent.bottom
111111
fact: QGroundControl.settingsManager.appSettings.gstDebugLevel
112-
visible: QGroundControl.settingsManager.appSettings.gstDebugLevel.visible
112+
visible: QGroundControl.settingsManager.appSettings.gstDebugLevel.userVisible
113113
sizeToContents: true
114114
}
115115

src/QmlControls/AppSettings.qml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Rectangle {
105105
// Find and select the default page
106106
var targetUrl = globals.commingFromRIDIndicator
107107
? "qrc:/qml/QGroundControl/AppSettings/RemoteIDSettings.qml"
108-
: "qrc:/qml/QGroundControl/AppSettings/AppSettings.qml"
108+
: "qrc:/qml/QGroundControl/AppSettings/GeneralSettings.qml"
109109
globals.commingFromRIDIndicator = false
110110

111111
for (var i = 0; i < settingsPagesModel.count; i++) {
@@ -217,9 +217,13 @@ Rectangle {
217217
onClicked: {
218218
if (mainWindow.allowViewSwitch()) {
219219
settingsView._navigateTo(index, -1)
220-
// Auto-expand when selecting a page
221-
if (hasMultipleSections && !isExpanded) {
222-
settingsView._setExpanded(index, true)
220+
if (hasMultipleSections) {
221+
// Toggle expand/collapse when re-clicking the same page
222+
if (isSelected && isExpanded) {
223+
settingsView._setExpanded(index, false)
224+
} else if (!isExpanded) {
225+
settingsView._setExpanded(index, true)
226+
}
223227
}
224228
}
225229
}
@@ -228,7 +232,11 @@ Rectangle {
228232
if (!mainWindow.allowViewSwitch()) {
229233
return
230234
}
231-
settingsView._setExpanded(index, !isExpanded)
235+
var expanding = !isExpanded
236+
settingsView._setExpanded(index, expanding)
237+
if (!expanding && isSelected) {
238+
settingsView._navigateTo(index, -1)
239+
}
232240
}
233241
}
234242

src/Settings/ADSBVehicleManager.SettingsGroup.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"QGC.MetaData.Facts": [
55
{
66
"name": "adsbServerConnectEnabled",
7-
"shortDesc": "Connect to ADSB SBS server",
7+
"shortDesc": "Enable connection to an ADS-B SBS-1 server to receive nearby aircraft tracking data.",
88
"longDesc": "Connect to ADSB SBS-1 server using specified address/port",
99
"type": "bool",
1010
"default": false,
@@ -13,15 +13,15 @@
1313
},
1414
{
1515
"name": "adsbServerHostAddress",
16-
"shortDesc": "Host address",
16+
"shortDesc": "IP address or hostname of the ADS-B SBS-1 server to connect to.",
1717
"type": "string",
1818
"default": "127.0.0.1",
1919
"label": "Host address",
2020
"keywords": "adsb,server,host"
2121
},
2222
{
2323
"name": "adsbServerPort",
24-
"shortDesc": "Server port",
24+
"shortDesc": "Network port number on which the ADS-B SBS-1 server is listening.",
2525
"type": "string",
2626
"default": 30003,
2727
"label": "Server port",

0 commit comments

Comments
 (0)