diff --git a/src/AnalyzeView/AnalyzeView.qml b/src/AnalyzeView/AnalyzeView.qml index cb827796f4d905fbb7f66791ee6f3ac5294e9958..cd910754a9c1f1fbf2f890b1e2cece19d6ad94bf 100644 --- a/src/AnalyzeView/AnalyzeView.qml +++ b/src/AnalyzeView/AnalyzeView.qml @@ -58,8 +58,8 @@ Rectangle { // I don't know why this does not work Connections { - target: QGroundControl - onBaseFontPointSizeChanged: buttonColumn.reflowWidths() + target: QGroundControl.settingsManager.appSettings.appFontPointSize + onValueChanged: buttonColumn.reflowWidths() } function reflowWidths() { diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index 36827977150337d4e3efc89d261aaeb69f84fba6..07f4c68327bb9515c4cba56019f363a21fa46b4f 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -81,7 +81,7 @@ QGCView { } function px4JoystickCheck() { - if ( _activeVehicle && !_activeVehicle.supportsManualControl && (QGroundControl.virtualTabletJoystick || _activeVehicle.joystickEnabled)) { + if ( _activeVehicle && !_activeVehicle.supportsManualControl && (QGroundControl.settingsManager.appSettings.virtualJoystick.value || _activeVehicle.joystickEnabled)) { px4JoystickSupport.open() } } @@ -99,8 +99,8 @@ QGCView { } Connections { - target: QGroundControl - onVirtualTabletJoystickChanged: px4JoystickCheck() + target: QGroundControl.settingsManager.appSettings.virtualJoystick + onValueChanged: px4JoystickCheck() } onActiveVehicleJoystickEnabledChanged: px4JoystickCheck() @@ -302,14 +302,16 @@ QGCView { z: _panel.z + 5 width: parent.width - (_flightVideoPipControl.width / 2) height: Math.min(ScreenTools.availableHeight * 0.25, ScreenTools.defaultFontPixelWidth * 16) - visible: QGroundControl.virtualTabletJoystick + visible: _virtualJoystick.value anchors.bottom: _flightVideoPipControl.top anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * 2 anchors.horizontalCenter: flightDisplayViewWidgets.horizontalCenter source: "qrc:/qml/VirtualJoystick.qml" - active: QGroundControl.virtualTabletJoystick + active: _virtualJoystick.value property bool useLightColors: root.isBackgroundDark + + property Fact _virtualJoystick: QGroundControl.settingsManager.appSettings.virtualJoystick } } } diff --git a/src/FlightDisplay/FlightDisplayViewWidgets.qml b/src/FlightDisplay/FlightDisplayViewWidgets.qml index 6688eb6d66b332cfa6d81a250cf1d49fecea61f7..222ac38fbf42ef21e0d3242d00b68f92489064e2 100644 --- a/src/FlightDisplay/FlightDisplayViewWidgets.qml +++ b/src/FlightDisplay/FlightDisplayViewWidgets.qml @@ -63,7 +63,7 @@ Item { break; } } else { - var useAlternateInstruments = QGroundControl.virtualTabletJoystick || ScreenTools.isTinyScreen + var useAlternateInstruments = QGroundControl.settingsManager.appSettings.virtualJoystick.value || ScreenTools.isTinyScreen if(useAlternateInstruments) { instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml" instrumentsLoader.state = "topMode" @@ -75,10 +75,8 @@ Item { } Connections { - target: QGroundControl - onVirtualTabletJoystickChanged: { - _setInstrumentWidget() - } + target: QGroundControl.settingsManager.appSettings.virtualJoystick + onValueChanged: _setInstrumentWidget() } Component.onCompleted: { diff --git a/src/FlightDisplay/VirtualJoystick.qml b/src/FlightDisplay/VirtualJoystick.qml index 07248d6df162d007ab36bc99a29a79df586ebca9..f10d4e2d25e74641bcad74a40a398217fc9c9b83 100644 --- a/src/FlightDisplay/VirtualJoystick.qml +++ b/src/FlightDisplay/VirtualJoystick.qml @@ -21,7 +21,7 @@ Item { Timer { interval: 40 // 25Hz, same as real joystick rate - running: QGroundControl.virtualTabletJoystick && _activeVehicle + running: QGroundControl.settingsManager.appSettings.virtualJoystick.value && _activeVehicle repeat: true onTriggered: { if (_activeVehicle) { diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index 2e351302f5f4684f52d3c7b6bc6a3dfa19776a34..7933933f9a6c4cd85cdc739ad508fc16f950e740 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -79,6 +79,7 @@ #include "MissionCommandTree.h" #include "QGCMapPolygon.h" #include "ParameterManager.h" +#include "SettingsManager.h" #ifndef NO_SERIAL_LINK #include "SerialLink.h" @@ -115,7 +116,6 @@ const char* QGCApplication::telemetryFileExtension = "tlog"; const char* QGCApplication::_deleteAllSettingsKey = "DeleteAllSettingsNextBoot"; const char* QGCApplication::_settingsVersionKey = "SettingsVersion"; -const char* QGCApplication::_styleKey = "StyleIsDark"; const char* QGCApplication::_lastKnownHomePositionLatKey = "LastKnownHomePositionLat"; const char* QGCApplication::_lastKnownHomePositionLonKey = "LastKnownHomePositionLon"; const char* QGCApplication::_lastKnownHomePositionAltKey = "LastKnownHomePositionAlt"; @@ -166,11 +166,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) : QApplication(argc, argv) #endif , _runningUnitTests(unitTesting) -#if defined (__mobile__) - , _styleIsDark(false) -#else - , _styleIsDark(true) -#endif , _fakeMobile(false) , _settingsUpgraded(false) #ifdef QT_DEBUG @@ -409,8 +404,7 @@ bool QGCApplication::_initForNormalAppBoot(void) { QSettings settings; - _styleIsDark = settings.value(_styleKey, _styleIsDark).toBool(); - _loadCurrentStyle(); + _loadCurrentStyleSheet(); // Exit main application when last window is closed connect(this, &QGCApplication::lastWindowClosed, this, QGCApplication::quit); @@ -536,17 +530,7 @@ void QGCApplication::saveTempFlightDataLogOnMainThread(QString tempLogfile) } #endif -void QGCApplication::setStyle(bool styleIsDark) -{ - QSettings settings; - - settings.setValue(_styleKey, styleIsDark); - _styleIsDark = styleIsDark; - _loadCurrentStyle(); - emit styleChanged(_styleIsDark); -} - -void QGCApplication::_loadCurrentStyle() +void QGCApplication::_loadCurrentStyleSheet(void) { #ifndef __mobile__ bool success = true; @@ -562,7 +546,7 @@ void QGCApplication::_loadCurrentStyle() success = false; } - if (success && !_styleIsDark) { + if (success && !_toolbox->settingsManager()->appSettings()->indoorPalette()->rawValue().toBool()) { // Load the slave light stylesheet. QFile styleSheet(_lightStyleFile); if (styleSheet.open(QIODevice::ReadOnly | QIODevice::Text)) { @@ -580,8 +564,6 @@ void QGCApplication::_loadCurrentStyle() setStyle("plastique"); } #endif - - QGCPalette::setGlobalTheme(_styleIsDark ? QGCPalette::Dark : QGCPalette::Light); } void QGCApplication::reportMissingParameter(int componentId, const QString& name) diff --git a/src/QGCApplication.h b/src/QGCApplication.h index f5234c533ddb077e4659c3d62b71e3fc4a7478df..91bb3a28745a17a3833d12d508e89a9efd1b2ac2 100644 --- a/src/QGCApplication.h +++ b/src/QGCApplication.h @@ -78,12 +78,6 @@ public: /// @brief Returns truee if unit test are being run bool runningUnitTests(void) { return _runningUnitTests; } - /// @return true: dark ui style, false: light ui style - bool styleIsDark(void) { return _styleIsDark; } - - /// Set the current UI style - void setStyle(bool styleIsDark); - /// Used to report a missing Parameter. Warning will be displayed to user. Method may be called /// multiple times. void reportMissingParameter(int componentId, const QString& name); @@ -127,10 +121,6 @@ public slots: #endif signals: - /// Signals that the style has changed - /// @param darkStyle true: dark style, false: light style - void styleChanged(bool darkStyle); - /// This is connected to MAVLinkProtocol::checkForLostLogFiles. We signal this to ourselves to call the slot /// on the MAVLinkProtocol thread; void checkForLostLogFiles(void); @@ -150,6 +140,8 @@ public: /// unit tests. Although public should only be called by main. bool _initForUnitTests(void); + void _loadCurrentStyleSheet(void); + static QGCApplication* _app; ///< Our own singleton. Should be reference directly by qgcApp public: @@ -162,8 +154,7 @@ private slots: void _missingParamsDisplay(void); private: - void _loadCurrentStyle (); - QObject* _rootQmlObject (); + QObject* _rootQmlObject(void); #ifdef __mobile__ QQmlApplicationEngine* _qmlAppEngine; @@ -173,7 +164,6 @@ private: static const char* _darkStyleFile; static const char* _lightStyleFile; - bool _styleIsDark; ///< true: dark style, false: light style static const int _missingParamsDelayedDisplayTimerTimeout = 1000; ///< Timeout to wait for next missing fact to come in before display QTimer _missingParamsDelayedDisplayTimer; ///< Timer use to delay missing fact display QStringList _missingParams; ///< List of missing facts to be displayed @@ -192,7 +182,6 @@ private: static const char* _settingsVersionKey; ///< Settings key which hold settings version static const char* _deleteAllSettingsKey; ///< If this settings key is set on boot, all settings will be deleted - static const char* _styleKey; ///< Settings key for UI style static const char* _lastKnownHomePositionLatKey; static const char* _lastKnownHomePositionLonKey; static const char* _lastKnownHomePositionAltKey; diff --git a/src/QmlControls/QGroundControlQmlGlobal.cc b/src/QmlControls/QGroundControlQmlGlobal.cc index a3fb27497d1a16af723d8cd47ccfef1b6794d345..af893774ea8496833310aeb7d2c8f17394ad3c1e 100644 --- a/src/QmlControls/QGroundControlQmlGlobal.cc +++ b/src/QmlControls/QGroundControlQmlGlobal.cc @@ -19,9 +19,6 @@ static const char* kQmlGlobalKeyName = "QGCQml"; -const char* QGroundControlQmlGlobal::_virtualTabletJoystickKey = "VirtualTabletJoystick"; -const char* QGroundControlQmlGlobal::_baseFontPointSizeKey = "BaseDeviceFontPointSize"; - QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app) : QGCTool(app) , _flightMapSettings(NULL) @@ -35,13 +32,7 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app) , _corePlugin(NULL) , _firmwarePluginManager(NULL) , _settingsManager(NULL) - , _virtualTabletJoystick(false) - , _baseFontPointSize(0.0) { - QSettings settings; - _virtualTabletJoystick = settings.value(_virtualTabletJoystickKey, false).toBool(); - _baseFontPointSize = settings.value(_baseFontPointSizeKey, 0.0).toDouble(); - // We clear the parent on this object since we run into shutdown problems caused by hybrid qml app. Instead we let it leak on shutdown. setParent(NULL); } @@ -157,12 +148,6 @@ void QGroundControlQmlGlobal::stopAllMockLinks(void) #endif } -void QGroundControlQmlGlobal::setIsDarkStyle(bool dark) -{ - qgcApp()->setStyle(dark); - emit isDarkStyleChanged(dark); -} - void QGroundControlQmlGlobal::setIsVersionCheckEnabled(bool enable) { qgcApp()->toolbox()->mavlinkProtocol()->enableVersionCheck(enable); @@ -175,26 +160,6 @@ void QGroundControlQmlGlobal::setMavlinkSystemID(int id) emit mavlinkSystemIDChanged(id); } -void QGroundControlQmlGlobal::setVirtualTabletJoystick(bool enabled) -{ - if (_virtualTabletJoystick != enabled) { - QSettings settings; - settings.setValue(_virtualTabletJoystickKey, enabled); - _virtualTabletJoystick = enabled; - emit virtualTabletJoystickChanged(enabled); - } -} - -void QGroundControlQmlGlobal::setBaseFontPointSize(qreal size) -{ - if (size >= 6.0 && size <= 48.0) { - QSettings settings; - settings.setValue(_baseFontPointSizeKey, size); - _baseFontPointSize = size; - emit baseFontPointSizeChanged(size); - } -} - int QGroundControlQmlGlobal::supportedFirmwareCount() { return _firmwarePluginManager->supportedFirmwareTypes().count(); diff --git a/src/QmlControls/QGroundControlQmlGlobal.h b/src/QmlControls/QGroundControlQmlGlobal.h index dc28ca655413a85c5b0a73449d4b68f2edb494a4..047e3f86e94e6e61b3ce4b8dd6d39ba35b69ef8c 100644 --- a/src/QmlControls/QGroundControlQmlGlobal.h +++ b/src/QmlControls/QGroundControlQmlGlobal.h @@ -54,11 +54,6 @@ public: Q_PROPERTY(qreal zOrderWidgets READ zOrderWidgets CONSTANT) ///< z order value to widgets, for example: zoom controls, hud widgetss Q_PROPERTY(qreal zOrderMapItems READ zOrderMapItems CONSTANT) ///< z order value for map items, for example: mission item indicators - // Various QGC settings exposed to Qml - Q_PROPERTY(bool isDarkStyle READ isDarkStyle WRITE setIsDarkStyle NOTIFY isDarkStyleChanged) // TODO: Should be in ScreenTools? - Q_PROPERTY(bool virtualTabletJoystick READ virtualTabletJoystick WRITE setVirtualTabletJoystick NOTIFY virtualTabletJoystickChanged) - Q_PROPERTY(qreal baseFontPointSize READ baseFontPointSize WRITE setBaseFontPointSize NOTIFY baseFontPointSizeChanged) - //------------------------------------------------------------------------- // MavLink Protocol Q_PROPERTY(bool isVersionCheckEnabled READ isVersionCheckEnabled WRITE setIsVersionCheckEnabled NOTIFY isVersionCheckEnabledChanged) @@ -142,10 +137,6 @@ public: qreal zOrderWidgets () { return 100; } qreal zOrderMapItems () { return 50; } - bool isDarkStyle () { return _app->styleIsDark(); } - bool virtualTabletJoystick () { return _virtualTabletJoystick; } - qreal baseFontPointSize () { return _baseFontPointSize; } - bool isVersionCheckEnabled () { return _toolbox->mavlinkProtocol()->versionCheckEnabled(); } int mavlinkSystemID () { return _toolbox->mavlinkProtocol()->getSystemId(); } @@ -153,10 +144,6 @@ public: int supportedFirmwareCount (); - void setIsDarkStyle (bool dark); - void setVirtualTabletJoystick (bool enabled); - void setBaseFontPointSize (qreal size); - void setIsVersionCheckEnabled (bool enable); void setMavlinkSystemID (int id); @@ -170,9 +157,6 @@ public: virtual void setToolbox(QGCToolbox* toolbox); signals: - void isDarkStyleChanged (bool dark); - void virtualTabletJoystickChanged (bool enabled); - void baseFontPointSizeChanged (qreal size); void isMultiplexingEnabledChanged (bool enabled); void isVersionCheckEnabledChanged (bool enabled); void mavlinkSystemIDChanged (int id); @@ -192,13 +176,8 @@ private: FirmwarePluginManager* _firmwarePluginManager; SettingsManager* _settingsManager; - bool _virtualTabletJoystick; - qreal _baseFontPointSize; QGeoCoordinate _flightMapPosition; double _flightMapZoom; - - static const char* _virtualTabletJoystickKey; - static const char* _baseFontPointSizeKey; }; #endif diff --git a/src/QmlControls/ScreenTools.qml b/src/QmlControls/ScreenTools.qml index 9645592735af002048c58c5eb152104e6a215a7f..0eb0c55939472aab244a2da89f8cb78d6619637f 100644 --- a/src/QmlControls/ScreenTools.qml +++ b/src/QmlControls/ScreenTools.qml @@ -67,10 +67,10 @@ Item { I've disabled (in release builds) until I figure out why. Changes require a restart for now. */ Connections { - target: QGroundControl - onBaseFontPointSizeChanged: { + target: QGroundControl.settingsManager.appSettings.appFontPointSize + onValueChanged: { if(ScreenToolsController.isDebug) - _setBasePointSize(QGroundControl.baseFontPointSize) + _setBasePointSize(QGroundControl.settingsManager.appSettings.appFontPointSize.value) } } @@ -108,12 +108,10 @@ Item { property real fontWidth: contentWidth property real fontHeight: contentHeight Component.onCompleted: { - var baseSize = QGroundControl.corePlugin.options.defaultFontPointSize - if(baseSize == 0.0) { - baseSize = QGroundControl.baseFontPointSize; - } + var _appFontPointSizeFact = QGroundControl.settingsManager.appSettings.appFontPointSize + var baseSize = _appFontPointSizeFact.value //-- If this is the first time (not saved in settings) - if(baseSize < 6 || baseSize > 48) { + if(baseSize < _appFontPointSizeFact.min || baseSize > _appFontPointSizeFact.max) { //-- Init base size base on the platform if(ScreenToolsController.isMobile) { //-- Check iOS really tiny screens (iPhone 4s/5/5s) @@ -142,7 +140,7 @@ Item { else baseSize = _defaultFont.font.pointSize; } - QGroundControl.baseFontPointSize = baseSize + _appFontPointSizeFact.value = baseSize //-- Release build doesn't get signal if(!ScreenToolsController.isDebug) _screenTools._setBasePointSize(baseSize); diff --git a/src/Settings/App.SettingsGroup.json b/src/Settings/App.SettingsGroup.json index 439727ccc0cc032291a0c5b3482c1e13c544801b..a3b074c840e3453bbda5721a086abfbc59f1af76 100644 --- a/src/Settings/App.SettingsGroup.json +++ b/src/Settings/App.SettingsGroup.json @@ -82,5 +82,30 @@ "longDescription": "If this option is enabled all audio output will be muted.", "type": "bool", "defaultValue": false +}, +{ + "name": "VirtualTabletJoystick", + "shortDescription": "Show virtual joystick", + "longDescription": "If this option is enabled the virtual joystick will be shown on the Fly view.", + "type": "bool", + "defaultValue": false +}, +{ + "name": "BaseDeviceFontPointSize", + "shortDescription": "QGroundControl font size", + "longDescription": "The point size for the default font used in QGroundControl.", + "type": "uint32", + "units": "pt", + "min": 6, + "max": 48, + "defaultValue": 0 +}, +{ + "name": "StyleIsDark", + "shortDescription": "QGroundControl color scheme", + "longDescription": "The color scheme for the QGroundControl user interface.", + "type": "uint32", + "enumStrings": "Indoor,Outdoor", + "enumValues": "1,0" } ] diff --git a/src/Settings/AppSettings.cc b/src/Settings/AppSettings.cc index d2284a7b3e29f86c94cce6a9ae2c9c05dcc7546f..74feaa27063e7ce9edebaa3be2ab221449083aac 100644 --- a/src/Settings/AppSettings.cc +++ b/src/Settings/AppSettings.cc @@ -8,6 +8,8 @@ ****************************************************************************/ #include "AppSettings.h" +#include "QGCPalette.h" +#include "QGCApplication.h" #include #include @@ -23,6 +25,9 @@ const char* AppSettings::missionAutoLoadDirSettingsName = "Mission const char* AppSettings::promptFlightTelemetrySaveName = "PromptFLightDataSave"; const char* AppSettings::promptFlightTelemetrySaveNotArmedName = "PromptFLightDataSaveNotArmed"; const char* AppSettings::audioMutedName = "AudioMuted"; +const char* AppSettings::virtualJoystickName = "VirtualTabletJoystick"; +const char* AppSettings::appFontPointSizeName = "BaseDeviceFontPointSize"; +const char* AppSettings::indoorPaletteName = "StyleIsDark"; AppSettings::AppSettings(QObject* parent) : SettingsGroup(appSettingsGroupName, QString() /* root settings group */, parent) @@ -33,12 +38,24 @@ AppSettings::AppSettings(QObject* parent) , _batteryPercentRemainingAnnounceFact(NULL) , _defaultMissionItemAltitudeFact(NULL) , _missionAutoLoadDirFact(NULL) - , _promptFlightTelemetrySave(NULL) - , _promptFlightTelemetrySaveNotArmed(NULL) - , _audioMuted(NULL) + , _promptFlightTelemetrySaveFact(NULL) + , _promptFlightTelemetrySaveNotArmedFact(NULL) + , _audioMutedFact(NULL) + , _virtualJoystickFact(NULL) + , _appFontPointSizeFact(NULL) + , _indoorPaletteFact(NULL) { QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only"); + + // Set up correct default for palette setting + QVariant outdoorPalette; +#if defined (__mobile__) + outdoorPalette = 0; +#else + outdoorPalette = 1; +#endif + _nameToMetaDataMap[indoorPaletteName]->setRawDefaultValue(outdoorPalette); } Fact* AppSettings::offlineEditingFirmwareType(void) @@ -104,27 +121,61 @@ Fact* AppSettings::missionAutoLoadDir(void) Fact* AppSettings::promptFlightTelemetrySave(void) { - if (!_promptFlightTelemetrySave) { - _promptFlightTelemetrySave = _createSettingsFact(promptFlightTelemetrySaveName); + if (!_promptFlightTelemetrySaveFact) { + _promptFlightTelemetrySaveFact = _createSettingsFact(promptFlightTelemetrySaveName); } - return _promptFlightTelemetrySave; + return _promptFlightTelemetrySaveFact; } Fact* AppSettings::promptFlightTelemetrySaveNotArmed(void) { - if (!_promptFlightTelemetrySaveNotArmed) { - _promptFlightTelemetrySaveNotArmed = _createSettingsFact(promptFlightTelemetrySaveNotArmedName); + if (!_promptFlightTelemetrySaveNotArmedFact) { + _promptFlightTelemetrySaveNotArmedFact = _createSettingsFact(promptFlightTelemetrySaveNotArmedName); } - return _promptFlightTelemetrySaveNotArmed; + return _promptFlightTelemetrySaveNotArmedFact; } Fact* AppSettings::audioMuted(void) { - if (!_audioMuted) { - _audioMuted = _createSettingsFact(audioMutedName); + if (!_audioMutedFact) { + _audioMutedFact = _createSettingsFact(audioMutedName); + } + + return _audioMutedFact; +} + +Fact* AppSettings::appFontPointSize(void) +{ + if (!_appFontPointSizeFact) { + _appFontPointSizeFact = _createSettingsFact(appFontPointSizeName); } - return _audioMuted; + return _appFontPointSizeFact; +} + +Fact* AppSettings::virtualJoystick(void) +{ + if (!_virtualJoystickFact) { + _virtualJoystickFact = _createSettingsFact(virtualJoystickName); + } + + return _virtualJoystickFact; +} + +Fact* AppSettings::indoorPalette(void) +{ + if (!_indoorPaletteFact) { + _indoorPaletteFact = _createSettingsFact(indoorPaletteName); + connect(_indoorPaletteFact, &Fact::rawValueChanged, this, &AppSettings::_indoorPaletteChanged); + } + + return _indoorPaletteFact; +} + +void AppSettings::_indoorPaletteChanged(void) +{ + qgcApp()->_loadCurrentStyleSheet(); + QGCPalette::setGlobalTheme(_indoorPaletteFact->rawValue().toBool() ? QGCPalette::Dark : QGCPalette::Light); } diff --git a/src/Settings/AppSettings.h b/src/Settings/AppSettings.h index c9bbae84ac269b5d1df0b9545f3af3331fa97429..7e39514cab3f651ea39b15e94fb7e7e776205313 100644 --- a/src/Settings/AppSettings.h +++ b/src/Settings/AppSettings.h @@ -29,6 +29,9 @@ public: Q_PROPERTY(Fact* promptFlightTelemetrySave READ promptFlightTelemetrySave CONSTANT) Q_PROPERTY(Fact* promptFlightTelemetrySaveNotArmed READ promptFlightTelemetrySaveNotArmed CONSTANT) Q_PROPERTY(Fact* audioMuted READ audioMuted CONSTANT) + Q_PROPERTY(Fact* virtualJoystick READ virtualJoystick CONSTANT) + Q_PROPERTY(Fact* appFontPointSize READ appFontPointSize CONSTANT) + Q_PROPERTY(Fact* indoorPalette READ indoorPalette CONSTANT) Fact* offlineEditingFirmwareType (void); Fact* offlineEditingVehicleType (void); @@ -39,7 +42,10 @@ public: Fact* missionAutoLoadDir (void); Fact* promptFlightTelemetrySave (void); Fact* promptFlightTelemetrySaveNotArmed (void); - Fact* audioMuted (void); + Fact* audioMuted (void); + Fact* virtualJoystick (void); + Fact* appFontPointSize (void); + Fact* indoorPalette (void); static const char* appSettingsGroupName; @@ -53,6 +59,12 @@ public: static const char* promptFlightTelemetrySaveName; static const char* promptFlightTelemetrySaveNotArmedName; static const char* audioMutedName; + static const char* virtualJoystickName; + static const char* appFontPointSizeName; + static const char* indoorPaletteName; + +private slots: + void _indoorPaletteChanged(void); private: SettingsFact* _offlineEditingFirmwareTypeFact; @@ -62,9 +74,12 @@ private: SettingsFact* _batteryPercentRemainingAnnounceFact; SettingsFact* _defaultMissionItemAltitudeFact; SettingsFact* _missionAutoLoadDirFact; - SettingsFact* _promptFlightTelemetrySave; - SettingsFact* _promptFlightTelemetrySaveNotArmed; - SettingsFact* _audioMuted; + SettingsFact* _promptFlightTelemetrySaveFact; + SettingsFact* _promptFlightTelemetrySaveNotArmedFact; + SettingsFact* _audioMutedFact; + SettingsFact* _virtualJoystickFact; + SettingsFact* _appFontPointSizeFact; + SettingsFact* _indoorPaletteFact; }; #endif diff --git a/src/VehicleSetup/SetupView.qml b/src/VehicleSetup/SetupView.qml index 54e0e0ffca0e88399ec81fda03280c05453be6d7..ac1156397cb78ccee0f1f832a597d2e21b20ae6a 100644 --- a/src/VehicleSetup/SetupView.qml +++ b/src/VehicleSetup/SetupView.qml @@ -233,8 +233,8 @@ Rectangle { // I don't know why this does not work Connections { - target: QGroundControl - onBaseFontPointSizeChanged: buttonColumn.reflowWidths() + target: QGroundControl.settingsManager.appSettings.appFontPointSize + onValueChanged: buttonColumn.reflowWidths() } function reflowWidths() { diff --git a/src/ui/linechart/ChartPlot.cc b/src/ui/linechart/ChartPlot.cc index 736120dcb9cdda04c2de05a9f01938d3272407f7..574be4c639dd9e0376e1e506d746e4df358dd457 100644 --- a/src/ui/linechart/ChartPlot.cc +++ b/src/ui/linechart/ChartPlot.cc @@ -1,5 +1,6 @@ #include "ChartPlot.h" #include "QGCApplication.h" +#include "SettingsManager.h" const QColor ChartPlot::baseColors[numColors] = { QColor(242, 255, 128), @@ -44,7 +45,7 @@ ChartPlot::ChartPlot(QWidget* parent): _colors.append(baseColors[i]); } // Now that all objects have been initialized, color everything. - styleChanged(qgcApp()->styleIsDark()); + styleChanged(qgcApp()->toolbox()->settingsManager()->appSettings()->indoorPalette()->rawValue().toBool()); } ChartPlot::~ChartPlot() diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index 339e1f84f7b25a8dd0e7df85618e0637a2ebb3ce..f0d1a3a3b7e4721653f72b9ce810d5817da4f149 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -40,6 +40,7 @@ #include "QGCFileDialog.h" #include "QGCMessageBox.h" #include "QGCApplication.h" +#include "SettingsManager.h" LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent), sysid(systemid), @@ -116,7 +117,7 @@ LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent createLayout(); // And make sure we're listening for future style changes - connect(qgcApp(), &QGCApplication::styleChanged, this, &LinechartWidget::recolor); + connect(qgcApp()->toolbox()->settingsManager()->appSettings()->indoorPalette(), &Fact::rawValueChanged, this, &LinechartWidget::recolor); updateTimer->setInterval(updateInterval); connect(updateTimer, &QTimer::timeout, this, &LinechartWidget::refresh); @@ -637,7 +638,7 @@ void LinechartWidget::removeCurve(QString curve) void LinechartWidget::recolor() { - activePlot->styleChanged(qgcApp()->styleIsDark()); + activePlot->styleChanged(qgcApp()->toolbox()->settingsManager()->appSettings()->indoorPalette()->rawValue().toBool()); foreach (const QString &key, colorIcons.keys()) { QWidget* colorIcon = colorIcons.value(key, 0); diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index a83ceb588b5c6c1b54113e88fd8d026e0aaf82b3..486ab00cf7b6c0916512f428a661cb15e8ea5a54 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -34,6 +34,7 @@ QGCView { property Fact _percentRemainingAnnounce: QGroundControl.settingsManager.appSettings.batteryPercentRemainingAnnounce property Fact _autoLoadDir: QGroundControl.settingsManager.appSettings.missionAutoLoadDir + property Fact _appFontPointSize: QGroundControl.settingsManager.appSettings.appFontPointSize property real _labelWidth: ScreenTools.defaultFontPixelWidth * 15 property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 30 @@ -135,11 +136,11 @@ QGCView { //----------------------------------------------------------------- //-- Base UI Font Point Size Row { - visible: QGroundControl.corePlugin.options.defaultFontPointSize < 1.0 + visible: _appFontPointSize.visible spacing: ScreenTools.defaultFontPixelWidth QGCLabel { id: baseFontLabel - text: qsTr("Base UI font size:") + text: qsTr("Font size:") anchors.verticalCenter: parent.verticalCenter } Row { @@ -152,32 +153,23 @@ QGCView { height: baseFontEdit.height text: "-" onClicked: { - if(ScreenTools.defaultFontPointSize > 6) { - QGroundControl.baseFontPointSize = QGroundControl.baseFontPointSize - 1 + if (_appFontPointSize.value > _appFontPointSize.min) { + _appFontPointSize.value = _appFontPointSize.value - 1 } } } - QGCTextField { - id: baseFontEdit - width: _editFieldWidth - (decrementButton.width * 2) - (baseFontRow.spacing * 2) - text: QGroundControl.baseFontPointSize - showUnits: true - unitsLabel: "pt" - maximumLength: 6 - validator: DoubleValidator {bottom: 6.0; top: 48.0; decimals: 2;} - onEditingFinished: { - var point = parseFloat(text) - if(point >= 6.0 && point <= 48.0) - QGroundControl.baseFontPointSize = point; - } + FactTextField { + id: baseFontEdit + width: _editFieldWidth - (decrementButton.width * 2) - (baseFontRow.spacing * 2) + fact: QGroundControl.settingsManager.appSettings.appFontPointSize } QGCButton { width: height height: baseFontEdit.height text: "+" onClicked: { - if(ScreenTools.defaultFontPointSize < 49) { - QGroundControl.baseFontPointSize = QGroundControl.baseFontPointSize + 1 + if (_appFontPointSize.value < _appFontPointSize.max) { + _appFontPointSize.value = _appFontPointSize.value + 1 } } } @@ -191,45 +183,47 @@ QGCView { //-- Palette Styles Row { spacing: ScreenTools.defaultFontPixelWidth + visible: QGroundControl.settingsManager.appSettings.indoorPalette.visible QGCLabel { anchors.baseline: paletteCombo.baseline - text: qsTr("UI Style:") + text: qsTr("Color scheme:") width: _labelWidth } - QGCComboBox { - id: paletteCombo - width: _editFieldWidth - model: [ qsTr("Indoor"), qsTr("Outdoor") ] - currentIndex: QGroundControl.isDarkStyle ? 0 : 1 - onActivated: { - if (index != -1) { - currentIndex = index - QGroundControl.isDarkStyle = index === 0 ? true : false - } - } + FactComboBox { + id: paletteCombo + width: _editFieldWidth + fact: QGroundControl.settingsManager.appSettings.indoorPalette + indexModel: false } } //----------------------------------------------------------------- //-- Audio preferences FactCheckBox { - text: qsTr("Mute all audio output") - fact: QGroundControl.settingsManager.appSettings.audioMuted + text: qsTr("Mute all audio output") + fact: _audioMuted + visible: _audioMuted.visible + + property Fact _audioMuted: QGroundControl.settingsManager.appSettings.audioMuted } //----------------------------------------------------------------- //-- Prompt Save Log FactCheckBox { id: promptSaveLog text: qsTr("Prompt to save Flight Data Log after each flight") - fact: QGroundControl.settingsManager.appSettings.promptFlightTelemetrySave - visible: !ScreenTools.isMobile + fact: _promptFlightTelemetrySave + visible: !ScreenTools.isMobile && _promptFlightTelemetrySave.visible + + property Fact _promptFlightTelemetrySave: QGroundControl.settingsManager.appSettings.promptFlightTelemetrySave } //----------------------------------------------------------------- //-- Prompt Save even if not armed FactCheckBox { text: qsTr("Prompt to save Flight Data Log even if vehicle was not armed") - fact: QGroundControl.settingsManager.appSettings.promptFlightTelemetrySaveNotArmed - visible: !ScreenTools.isMobile + fact: _promptFlightTelemetrySaveNotArmed + visible: !ScreenTools.isMobile && _promptFlightTelemetrySaveNotArmed.visible enabled: promptSaveLog.checked + + property Fact _promptFlightTelemetrySaveNotArmed: QGroundControl.settingsManager.appSettings.promptFlightTelemetrySaveNotArmed } //----------------------------------------------------------------- //-- Clear settings @@ -283,11 +277,12 @@ QGCView { } //----------------------------------------------------------------- //-- Virtual joystick settings - QGCCheckBox { + FactCheckBox { text: qsTr("Virtual Joystick") - checked: QGroundControl.virtualTabletJoystick - onClicked: QGroundControl.virtualTabletJoystick = checked - visible: QGroundControl.corePlugin.options.enableVirtualJoystick + visible: _virtualJoystick.visible + fact: _virtualJoystick + + property Fact _virtualJoystick: QGroundControl.settingsManager.appSettings.virtualJoystick } //----------------------------------------------------------------- //-- Default mission item altitude