Commit da928b1b authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4644 from DonLakeFlyer/MoreSettings

More moves of settings to new support
parents 6f4ebffb e6634126
...@@ -58,8 +58,8 @@ Rectangle { ...@@ -58,8 +58,8 @@ Rectangle {
// I don't know why this does not work // I don't know why this does not work
Connections { Connections {
target: QGroundControl target: QGroundControl.settingsManager.appSettings.appFontPointSize
onBaseFontPointSizeChanged: buttonColumn.reflowWidths() onValueChanged: buttonColumn.reflowWidths()
} }
function reflowWidths() { function reflowWidths() {
......
...@@ -81,7 +81,7 @@ QGCView { ...@@ -81,7 +81,7 @@ QGCView {
} }
function px4JoystickCheck() { function px4JoystickCheck() {
if ( _activeVehicle && !_activeVehicle.supportsManualControl && (QGroundControl.virtualTabletJoystick || _activeVehicle.joystickEnabled)) { if ( _activeVehicle && !_activeVehicle.supportsManualControl && (QGroundControl.settingsManager.appSettings.virtualJoystick.value || _activeVehicle.joystickEnabled)) {
px4JoystickSupport.open() px4JoystickSupport.open()
} }
} }
...@@ -99,8 +99,8 @@ QGCView { ...@@ -99,8 +99,8 @@ QGCView {
} }
Connections { Connections {
target: QGroundControl target: QGroundControl.settingsManager.appSettings.virtualJoystick
onVirtualTabletJoystickChanged: px4JoystickCheck() onValueChanged: px4JoystickCheck()
} }
onActiveVehicleJoystickEnabledChanged: px4JoystickCheck() onActiveVehicleJoystickEnabledChanged: px4JoystickCheck()
...@@ -302,14 +302,16 @@ QGCView { ...@@ -302,14 +302,16 @@ QGCView {
z: _panel.z + 5 z: _panel.z + 5
width: parent.width - (_flightVideoPipControl.width / 2) width: parent.width - (_flightVideoPipControl.width / 2)
height: Math.min(ScreenTools.availableHeight * 0.25, ScreenTools.defaultFontPixelWidth * 16) height: Math.min(ScreenTools.availableHeight * 0.25, ScreenTools.defaultFontPixelWidth * 16)
visible: QGroundControl.virtualTabletJoystick visible: _virtualJoystick.value
anchors.bottom: _flightVideoPipControl.top anchors.bottom: _flightVideoPipControl.top
anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * 2 anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * 2
anchors.horizontalCenter: flightDisplayViewWidgets.horizontalCenter anchors.horizontalCenter: flightDisplayViewWidgets.horizontalCenter
source: "qrc:/qml/VirtualJoystick.qml" source: "qrc:/qml/VirtualJoystick.qml"
active: QGroundControl.virtualTabletJoystick active: _virtualJoystick.value
property bool useLightColors: root.isBackgroundDark property bool useLightColors: root.isBackgroundDark
property Fact _virtualJoystick: QGroundControl.settingsManager.appSettings.virtualJoystick
} }
} }
} }
...@@ -63,7 +63,7 @@ Item { ...@@ -63,7 +63,7 @@ Item {
break; break;
} }
} else { } else {
var useAlternateInstruments = QGroundControl.virtualTabletJoystick || ScreenTools.isTinyScreen var useAlternateInstruments = QGroundControl.settingsManager.appSettings.virtualJoystick.value || ScreenTools.isTinyScreen
if(useAlternateInstruments) { if(useAlternateInstruments) {
instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml" instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml"
instrumentsLoader.state = "topMode" instrumentsLoader.state = "topMode"
...@@ -75,10 +75,8 @@ Item { ...@@ -75,10 +75,8 @@ Item {
} }
Connections { Connections {
target: QGroundControl target: QGroundControl.settingsManager.appSettings.virtualJoystick
onVirtualTabletJoystickChanged: { onValueChanged: _setInstrumentWidget()
_setInstrumentWidget()
}
} }
Component.onCompleted: { Component.onCompleted: {
......
...@@ -21,7 +21,7 @@ Item { ...@@ -21,7 +21,7 @@ Item {
Timer { Timer {
interval: 40 // 25Hz, same as real joystick rate interval: 40 // 25Hz, same as real joystick rate
running: QGroundControl.virtualTabletJoystick && _activeVehicle running: QGroundControl.settingsManager.appSettings.virtualJoystick.value && _activeVehicle
repeat: true repeat: true
onTriggered: { onTriggered: {
if (_activeVehicle) { if (_activeVehicle) {
......
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
#include "MissionCommandTree.h" #include "MissionCommandTree.h"
#include "QGCMapPolygon.h" #include "QGCMapPolygon.h"
#include "ParameterManager.h" #include "ParameterManager.h"
#include "SettingsManager.h"
#ifndef NO_SERIAL_LINK #ifndef NO_SERIAL_LINK
#include "SerialLink.h" #include "SerialLink.h"
...@@ -115,7 +116,6 @@ const char* QGCApplication::telemetryFileExtension = "tlog"; ...@@ -115,7 +116,6 @@ const char* QGCApplication::telemetryFileExtension = "tlog";
const char* QGCApplication::_deleteAllSettingsKey = "DeleteAllSettingsNextBoot"; const char* QGCApplication::_deleteAllSettingsKey = "DeleteAllSettingsNextBoot";
const char* QGCApplication::_settingsVersionKey = "SettingsVersion"; const char* QGCApplication::_settingsVersionKey = "SettingsVersion";
const char* QGCApplication::_styleKey = "StyleIsDark";
const char* QGCApplication::_lastKnownHomePositionLatKey = "LastKnownHomePositionLat"; const char* QGCApplication::_lastKnownHomePositionLatKey = "LastKnownHomePositionLat";
const char* QGCApplication::_lastKnownHomePositionLonKey = "LastKnownHomePositionLon"; const char* QGCApplication::_lastKnownHomePositionLonKey = "LastKnownHomePositionLon";
const char* QGCApplication::_lastKnownHomePositionAltKey = "LastKnownHomePositionAlt"; const char* QGCApplication::_lastKnownHomePositionAltKey = "LastKnownHomePositionAlt";
...@@ -166,11 +166,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) ...@@ -166,11 +166,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
: QApplication(argc, argv) : QApplication(argc, argv)
#endif #endif
, _runningUnitTests(unitTesting) , _runningUnitTests(unitTesting)
#if defined (__mobile__)
, _styleIsDark(false)
#else
, _styleIsDark(true)
#endif
, _fakeMobile(false) , _fakeMobile(false)
, _settingsUpgraded(false) , _settingsUpgraded(false)
#ifdef QT_DEBUG #ifdef QT_DEBUG
...@@ -409,8 +404,7 @@ bool QGCApplication::_initForNormalAppBoot(void) ...@@ -409,8 +404,7 @@ bool QGCApplication::_initForNormalAppBoot(void)
{ {
QSettings settings; QSettings settings;
_styleIsDark = settings.value(_styleKey, _styleIsDark).toBool(); _loadCurrentStyleSheet();
_loadCurrentStyle();
// Exit main application when last window is closed // Exit main application when last window is closed
connect(this, &QGCApplication::lastWindowClosed, this, QGCApplication::quit); connect(this, &QGCApplication::lastWindowClosed, this, QGCApplication::quit);
...@@ -536,17 +530,7 @@ void QGCApplication::saveTempFlightDataLogOnMainThread(QString tempLogfile) ...@@ -536,17 +530,7 @@ void QGCApplication::saveTempFlightDataLogOnMainThread(QString tempLogfile)
} }
#endif #endif
void QGCApplication::setStyle(bool styleIsDark) void QGCApplication::_loadCurrentStyleSheet(void)
{
QSettings settings;
settings.setValue(_styleKey, styleIsDark);
_styleIsDark = styleIsDark;
_loadCurrentStyle();
emit styleChanged(_styleIsDark);
}
void QGCApplication::_loadCurrentStyle()
{ {
#ifndef __mobile__ #ifndef __mobile__
bool success = true; bool success = true;
...@@ -562,7 +546,7 @@ void QGCApplication::_loadCurrentStyle() ...@@ -562,7 +546,7 @@ void QGCApplication::_loadCurrentStyle()
success = false; success = false;
} }
if (success && !_styleIsDark) { if (success && !_toolbox->settingsManager()->appSettings()->indoorPalette()->rawValue().toBool()) {
// Load the slave light stylesheet. // Load the slave light stylesheet.
QFile styleSheet(_lightStyleFile); QFile styleSheet(_lightStyleFile);
if (styleSheet.open(QIODevice::ReadOnly | QIODevice::Text)) { if (styleSheet.open(QIODevice::ReadOnly | QIODevice::Text)) {
...@@ -580,8 +564,6 @@ void QGCApplication::_loadCurrentStyle() ...@@ -580,8 +564,6 @@ void QGCApplication::_loadCurrentStyle()
setStyle("plastique"); setStyle("plastique");
} }
#endif #endif
QGCPalette::setGlobalTheme(_styleIsDark ? QGCPalette::Dark : QGCPalette::Light);
} }
void QGCApplication::reportMissingParameter(int componentId, const QString& name) void QGCApplication::reportMissingParameter(int componentId, const QString& name)
......
...@@ -78,12 +78,6 @@ public: ...@@ -78,12 +78,6 @@ public:
/// @brief Returns truee if unit test are being run /// @brief Returns truee if unit test are being run
bool runningUnitTests(void) { return _runningUnitTests; } 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 /// Used to report a missing Parameter. Warning will be displayed to user. Method may be called
/// multiple times. /// multiple times.
void reportMissingParameter(int componentId, const QString& name); void reportMissingParameter(int componentId, const QString& name);
...@@ -127,10 +121,6 @@ public slots: ...@@ -127,10 +121,6 @@ public slots:
#endif #endif
signals: 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 /// This is connected to MAVLinkProtocol::checkForLostLogFiles. We signal this to ourselves to call the slot
/// on the MAVLinkProtocol thread; /// on the MAVLinkProtocol thread;
void checkForLostLogFiles(void); void checkForLostLogFiles(void);
...@@ -150,6 +140,8 @@ public: ...@@ -150,6 +140,8 @@ public:
/// unit tests. Although public should only be called by main. /// unit tests. Although public should only be called by main.
bool _initForUnitTests(void); bool _initForUnitTests(void);
void _loadCurrentStyleSheet(void);
static QGCApplication* _app; ///< Our own singleton. Should be reference directly by qgcApp static QGCApplication* _app; ///< Our own singleton. Should be reference directly by qgcApp
public: public:
...@@ -162,8 +154,7 @@ private slots: ...@@ -162,8 +154,7 @@ private slots:
void _missingParamsDisplay(void); void _missingParamsDisplay(void);
private: private:
void _loadCurrentStyle (); QObject* _rootQmlObject(void);
QObject* _rootQmlObject ();
#ifdef __mobile__ #ifdef __mobile__
QQmlApplicationEngine* _qmlAppEngine; QQmlApplicationEngine* _qmlAppEngine;
...@@ -173,7 +164,6 @@ private: ...@@ -173,7 +164,6 @@ private:
static const char* _darkStyleFile; static const char* _darkStyleFile;
static const char* _lightStyleFile; 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 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 QTimer _missingParamsDelayedDisplayTimer; ///< Timer use to delay missing fact display
QStringList _missingParams; ///< List of missing facts to be displayed QStringList _missingParams; ///< List of missing facts to be displayed
...@@ -192,7 +182,6 @@ private: ...@@ -192,7 +182,6 @@ private:
static const char* _settingsVersionKey; ///< Settings key which hold settings version 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* _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* _lastKnownHomePositionLatKey;
static const char* _lastKnownHomePositionLonKey; static const char* _lastKnownHomePositionLonKey;
static const char* _lastKnownHomePositionAltKey; static const char* _lastKnownHomePositionAltKey;
......
...@@ -19,9 +19,6 @@ ...@@ -19,9 +19,6 @@
static const char* kQmlGlobalKeyName = "QGCQml"; static const char* kQmlGlobalKeyName = "QGCQml";
const char* QGroundControlQmlGlobal::_virtualTabletJoystickKey = "VirtualTabletJoystick";
const char* QGroundControlQmlGlobal::_baseFontPointSizeKey = "BaseDeviceFontPointSize";
QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app) QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app)
: QGCTool(app) : QGCTool(app)
, _flightMapSettings(NULL) , _flightMapSettings(NULL)
...@@ -35,13 +32,7 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app) ...@@ -35,13 +32,7 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app)
, _corePlugin(NULL) , _corePlugin(NULL)
, _firmwarePluginManager(NULL) , _firmwarePluginManager(NULL)
, _settingsManager(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. // 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); setParent(NULL);
} }
...@@ -157,12 +148,6 @@ void QGroundControlQmlGlobal::stopAllMockLinks(void) ...@@ -157,12 +148,6 @@ void QGroundControlQmlGlobal::stopAllMockLinks(void)
#endif #endif
} }
void QGroundControlQmlGlobal::setIsDarkStyle(bool dark)
{
qgcApp()->setStyle(dark);
emit isDarkStyleChanged(dark);
}
void QGroundControlQmlGlobal::setIsVersionCheckEnabled(bool enable) void QGroundControlQmlGlobal::setIsVersionCheckEnabled(bool enable)
{ {
qgcApp()->toolbox()->mavlinkProtocol()->enableVersionCheck(enable); qgcApp()->toolbox()->mavlinkProtocol()->enableVersionCheck(enable);
...@@ -175,26 +160,6 @@ void QGroundControlQmlGlobal::setMavlinkSystemID(int id) ...@@ -175,26 +160,6 @@ void QGroundControlQmlGlobal::setMavlinkSystemID(int id)
emit mavlinkSystemIDChanged(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() int QGroundControlQmlGlobal::supportedFirmwareCount()
{ {
return _firmwarePluginManager->supportedFirmwareTypes().count(); return _firmwarePluginManager->supportedFirmwareTypes().count();
......
...@@ -54,11 +54,6 @@ public: ...@@ -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 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 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 // MavLink Protocol
Q_PROPERTY(bool isVersionCheckEnabled READ isVersionCheckEnabled WRITE setIsVersionCheckEnabled NOTIFY isVersionCheckEnabledChanged) Q_PROPERTY(bool isVersionCheckEnabled READ isVersionCheckEnabled WRITE setIsVersionCheckEnabled NOTIFY isVersionCheckEnabledChanged)
...@@ -142,10 +137,6 @@ public: ...@@ -142,10 +137,6 @@ public:
qreal zOrderWidgets () { return 100; } qreal zOrderWidgets () { return 100; }
qreal zOrderMapItems () { return 50; } qreal zOrderMapItems () { return 50; }
bool isDarkStyle () { return _app->styleIsDark(); }
bool virtualTabletJoystick () { return _virtualTabletJoystick; }
qreal baseFontPointSize () { return _baseFontPointSize; }
bool isVersionCheckEnabled () { return _toolbox->mavlinkProtocol()->versionCheckEnabled(); } bool isVersionCheckEnabled () { return _toolbox->mavlinkProtocol()->versionCheckEnabled(); }
int mavlinkSystemID () { return _toolbox->mavlinkProtocol()->getSystemId(); } int mavlinkSystemID () { return _toolbox->mavlinkProtocol()->getSystemId(); }
...@@ -153,10 +144,6 @@ public: ...@@ -153,10 +144,6 @@ public:
int supportedFirmwareCount (); int supportedFirmwareCount ();
void setIsDarkStyle (bool dark);
void setVirtualTabletJoystick (bool enabled);
void setBaseFontPointSize (qreal size);
void setIsVersionCheckEnabled (bool enable); void setIsVersionCheckEnabled (bool enable);
void setMavlinkSystemID (int id); void setMavlinkSystemID (int id);
...@@ -170,9 +157,6 @@ public: ...@@ -170,9 +157,6 @@ public:
virtual void setToolbox(QGCToolbox* toolbox); virtual void setToolbox(QGCToolbox* toolbox);
signals: signals:
void isDarkStyleChanged (bool dark);
void virtualTabletJoystickChanged (bool enabled);
void baseFontPointSizeChanged (qreal size);
void isMultiplexingEnabledChanged (bool enabled); void isMultiplexingEnabledChanged (bool enabled);
void isVersionCheckEnabledChanged (bool enabled); void isVersionCheckEnabledChanged (bool enabled);
void mavlinkSystemIDChanged (int id); void mavlinkSystemIDChanged (int id);
...@@ -192,13 +176,8 @@ private: ...@@ -192,13 +176,8 @@ private:
FirmwarePluginManager* _firmwarePluginManager; FirmwarePluginManager* _firmwarePluginManager;
SettingsManager* _settingsManager; SettingsManager* _settingsManager;
bool _virtualTabletJoystick;
qreal _baseFontPointSize;
QGeoCoordinate _flightMapPosition; QGeoCoordinate _flightMapPosition;
double _flightMapZoom; double _flightMapZoom;
static const char* _virtualTabletJoystickKey;
static const char* _baseFontPointSizeKey;
}; };
#endif #endif
...@@ -67,10 +67,10 @@ Item { ...@@ -67,10 +67,10 @@ Item {
I've disabled (in release builds) until I figure out why. Changes require a restart for now. I've disabled (in release builds) until I figure out why. Changes require a restart for now.
*/ */
Connections { Connections {
target: QGroundControl target: QGroundControl.settingsManager.appSettings.appFontPointSize
onBaseFontPointSizeChanged: { onValueChanged: {
if(ScreenToolsController.isDebug) if(ScreenToolsController.isDebug)
_setBasePointSize(QGroundControl.baseFontPointSize) _setBasePointSize(QGroundControl.settingsManager.appSettings.appFontPointSize.value)
} }
} }
...@@ -108,12 +108,10 @@ Item { ...@@ -108,12 +108,10 @@ Item {
property real fontWidth: contentWidth property real fontWidth: contentWidth
property real fontHeight: contentHeight property real fontHeight: contentHeight
Component.onCompleted: { Component.onCompleted: {
var baseSize = QGroundControl.corePlugin.options.defaultFontPointSize var _appFontPointSizeFact = QGroundControl.settingsManager.appSettings.appFontPointSize
if(baseSize == 0.0) { var baseSize = _appFontPointSizeFact.value
baseSize = QGroundControl.baseFontPointSize;
}
//-- If this is the first time (not saved in settings) //-- 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 //-- Init base size base on the platform
if(ScreenToolsController.isMobile) { if(ScreenToolsController.isMobile) {
//-- Check iOS really tiny screens (iPhone 4s/5/5s) //-- Check iOS really tiny screens (iPhone 4s/5/5s)
...@@ -142,7 +140,7 @@ Item { ...@@ -142,7 +140,7 @@ Item {
else else
baseSize = _defaultFont.font.pointSize; baseSize = _defaultFont.font.pointSize;
} }
QGroundControl.baseFontPointSize = baseSize _appFontPointSizeFact.value = baseSize
//-- Release build doesn't get signal //-- Release build doesn't get signal
if(!ScreenToolsController.isDebug) if(!ScreenToolsController.isDebug)
_screenTools._setBasePointSize(baseSize); _screenTools._setBasePointSize(baseSize);
......
...@@ -82,5 +82,30 @@ ...@@ -82,5 +82,30 @@
"longDescription": "If this option is enabled all audio output will be muted.", "longDescription": "If this option is enabled all audio output will be muted.",
"type": "bool", "type": "bool",
"defaultValue": false "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"
} }
] ]
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
****************************************************************************/ ****************************************************************************/
#include "AppSettings.h" #include "AppSettings.h"
#include "QGCPalette.h"
#include "QGCApplication.h"
#include <QQmlEngine> #include <QQmlEngine>
#include <QtQml> #include <QtQml>
...@@ -23,6 +25,9 @@ const char* AppSettings::missionAutoLoadDirSettingsName = "Mission ...@@ -23,6 +25,9 @@ const char* AppSettings::missionAutoLoadDirSettingsName = "Mission
const char* AppSettings::promptFlightTelemetrySaveName = "PromptFLightDataSave"; const char* AppSettings::promptFlightTelemetrySaveName = "PromptFLightDataSave";
const char* AppSettings::promptFlightTelemetrySaveNotArmedName = "PromptFLightDataSaveNotArmed"; const char* AppSettings::promptFlightTelemetrySaveNotArmedName = "PromptFLightDataSaveNotArmed";
const char* AppSettings::audioMutedName = "AudioMuted"; const char* AppSettings::audioMutedName = "AudioMuted";
const char* AppSettings::virtualJoystickName = "VirtualTabletJoystick";
const char* AppSettings::appFontPointSizeName = "BaseDeviceFontPointSize";
const char* AppSettings::indoorPaletteName = "StyleIsDark";
AppSettings::AppSettings(QObject* parent) AppSettings::AppSettings(QObject* parent)
: SettingsGroup(appSettingsGroupName, QString() /* root settings group */, parent) : SettingsGroup(appSettingsGroupName, QString() /* root settings group */, parent)
...@@ -33,12 +38,24 @@ AppSettings::AppSettings(QObject* parent) ...@@ -33,12 +38,24 @@ AppSettings::AppSettings(QObject* parent)
, _batteryPercentRemainingAnnounceFact(NULL) , _batteryPercentRemainingAnnounceFact(NULL)
, _defaultMissionItemAltitudeFact(NULL) , _defaultMissionItemAltitudeFact(NULL)
, _missionAutoLoadDirFact(NULL) , _missionAutoLoadDirFact(NULL)
, _promptFlightTelemetrySave(NULL) , _promptFlightTelemetrySaveFact(NULL)
, _promptFlightTelemetrySaveNotArmed(NULL) , _promptFlightTelemetrySaveNotArmedFact(NULL)
, _audioMuted(NULL) , _audioMutedFact(NULL)
, _virtualJoystickFact(NULL)
, _appFontPointSizeFact(NULL)
, _indoorPaletteFact(NULL)
{ {
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<AppSettings>("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only"); qmlRegisterUncreatableType<AppSettings>("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) Fact* AppSettings::offlineEditingFirmwareType(void)
...@@ -104,27 +121,61 @@ Fact* AppSettings::missionAutoLoadDir(void) ...@@ -104,27 +121,61 @@ Fact* AppSettings::missionAutoLoadDir(void)
Fact* AppSettings::promptFlightTelemetrySave(void) Fact* AppSettings::promptFlightTelemetrySave(void)
{ {
if (!_promptFlightTelemetrySave) { if (!_promptFlightTelemetrySaveFact) {
_promptFlightTelemetrySave = _createSettingsFact(promptFlightTelemetrySaveName); _promptFlightTelemetrySaveFact = _createSettingsFact(promptFlightTelemetrySaveName);
} }
return _promptFlightTelemetrySave; return _promptFlightTelemetrySaveFact;
} }
Fact* AppSettings::promptFlightTelemetrySaveNotArmed(void) Fact* AppSettings::promptFlightTelemetrySaveNotArmed(void)
{ {
if (!_promptFlightTelemetrySaveNotArmed) { if (!_promptFlightTelemetrySaveNotArmedFact) {
_promptFlightTelemetrySaveNotArmed = _createSettingsFact(promptFlightTelemetrySaveNotArmedName); _promptFlightTelemetrySaveNotArmedFact = _createSettingsFact(promptFlightTelemetrySaveNotArmedName);
} }
return _promptFlightTelemetrySaveNotArmed; return _promptFlightTelemetrySaveNotArmedFact;
} }
Fact* AppSettings::audioMuted(void) Fact* AppSettings::audioMuted(void)
{ {
if (!_audioMuted) { if (!_audioMutedFact) {
_audioMuted = _createSettingsFact(audioMutedName); _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);
} }
...@@ -29,6 +29,9 @@ public: ...@@ -29,6 +29,9 @@ public:
Q_PROPERTY(Fact* promptFlightTelemetrySave READ promptFlightTelemetrySave CONSTANT) Q_PROPERTY(Fact* promptFlightTelemetrySave READ promptFlightTelemetrySave CONSTANT)
Q_PROPERTY(Fact* promptFlightTelemetrySaveNotArmed READ promptFlightTelemetrySaveNotArmed CONSTANT) Q_PROPERTY(Fact* promptFlightTelemetrySaveNotArmed READ promptFlightTelemetrySaveNotArmed CONSTANT)
Q_PROPERTY(Fact* audioMuted READ audioMuted 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* offlineEditingFirmwareType (void);
Fact* offlineEditingVehicleType (void); Fact* offlineEditingVehicleType (void);
...@@ -39,7 +42,10 @@ public: ...@@ -39,7 +42,10 @@ public:
Fact* missionAutoLoadDir (void); Fact* missionAutoLoadDir (void);
Fact* promptFlightTelemetrySave (void); Fact* promptFlightTelemetrySave (void);
Fact* promptFlightTelemetrySaveNotArmed (void); Fact* promptFlightTelemetrySaveNotArmed (void);
Fact* audioMuted (void); Fact* audioMuted (void);
Fact* virtualJoystick (void);
Fact* appFontPointSize (void);
Fact* indoorPalette (void);
static const char* appSettingsGroupName; static const char* appSettingsGroupName;
...@@ -53,6 +59,12 @@ public: ...@@ -53,6 +59,12 @@ public:
static const char* promptFlightTelemetrySaveName; static const char* promptFlightTelemetrySaveName;
static const char* promptFlightTelemetrySaveNotArmedName; static const char* promptFlightTelemetrySaveNotArmedName;
static const char* audioMutedName; static const char* audioMutedName;
static const char* virtualJoystickName;
static const char* appFontPointSizeName;
static const char* indoorPaletteName;
private slots:
void _indoorPaletteChanged(void);
private: private:
SettingsFact* _offlineEditingFirmwareTypeFact; SettingsFact* _offlineEditingFirmwareTypeFact;
...@@ -62,9 +74,12 @@ private: ...@@ -62,9 +74,12 @@ private:
SettingsFact* _batteryPercentRemainingAnnounceFact; SettingsFact* _batteryPercentRemainingAnnounceFact;
SettingsFact* _defaultMissionItemAltitudeFact; SettingsFact* _defaultMissionItemAltitudeFact;
SettingsFact* _missionAutoLoadDirFact; SettingsFact* _missionAutoLoadDirFact;
SettingsFact* _promptFlightTelemetrySave; SettingsFact* _promptFlightTelemetrySaveFact;
SettingsFact* _promptFlightTelemetrySaveNotArmed; SettingsFact* _promptFlightTelemetrySaveNotArmedFact;
SettingsFact* _audioMuted; SettingsFact* _audioMutedFact;
SettingsFact* _virtualJoystickFact;
SettingsFact* _appFontPointSizeFact;
SettingsFact* _indoorPaletteFact;
}; };
#endif #endif
...@@ -233,8 +233,8 @@ Rectangle { ...@@ -233,8 +233,8 @@ Rectangle {
// I don't know why this does not work // I don't know why this does not work
Connections { Connections {
target: QGroundControl target: QGroundControl.settingsManager.appSettings.appFontPointSize
onBaseFontPointSizeChanged: buttonColumn.reflowWidths() onValueChanged: buttonColumn.reflowWidths()
} }
function reflowWidths() { function reflowWidths() {
......
#include "ChartPlot.h" #include "ChartPlot.h"
#include "QGCApplication.h" #include "QGCApplication.h"
#include "SettingsManager.h"
const QColor ChartPlot::baseColors[numColors] = { const QColor ChartPlot::baseColors[numColors] = {
QColor(242, 255, 128), QColor(242, 255, 128),
...@@ -44,7 +45,7 @@ ChartPlot::ChartPlot(QWidget* parent): ...@@ -44,7 +45,7 @@ ChartPlot::ChartPlot(QWidget* parent):
_colors.append(baseColors[i]); _colors.append(baseColors[i]);
} }
// Now that all objects have been initialized, color everything. // Now that all objects have been initialized, color everything.
styleChanged(qgcApp()->styleIsDark()); styleChanged(qgcApp()->toolbox()->settingsManager()->appSettings()->indoorPalette()->rawValue().toBool());
} }
ChartPlot::~ChartPlot() ChartPlot::~ChartPlot()
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "QGCFileDialog.h" #include "QGCFileDialog.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
#include "QGCApplication.h" #include "QGCApplication.h"
#include "SettingsManager.h"
LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent), LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent),
sysid(systemid), sysid(systemid),
...@@ -116,7 +117,7 @@ LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent ...@@ -116,7 +117,7 @@ LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent
createLayout(); createLayout();
// And make sure we're listening for future style changes // 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); updateTimer->setInterval(updateInterval);
connect(updateTimer, &QTimer::timeout, this, &LinechartWidget::refresh); connect(updateTimer, &QTimer::timeout, this, &LinechartWidget::refresh);
...@@ -637,7 +638,7 @@ void LinechartWidget::removeCurve(QString curve) ...@@ -637,7 +638,7 @@ void LinechartWidget::removeCurve(QString curve)
void LinechartWidget::recolor() void LinechartWidget::recolor()
{ {
activePlot->styleChanged(qgcApp()->styleIsDark()); activePlot->styleChanged(qgcApp()->toolbox()->settingsManager()->appSettings()->indoorPalette()->rawValue().toBool());
foreach (const QString &key, colorIcons.keys()) foreach (const QString &key, colorIcons.keys())
{ {
QWidget* colorIcon = colorIcons.value(key, 0); QWidget* colorIcon = colorIcons.value(key, 0);
......
...@@ -34,6 +34,7 @@ QGCView { ...@@ -34,6 +34,7 @@ QGCView {
property Fact _percentRemainingAnnounce: QGroundControl.settingsManager.appSettings.batteryPercentRemainingAnnounce property Fact _percentRemainingAnnounce: QGroundControl.settingsManager.appSettings.batteryPercentRemainingAnnounce
property Fact _autoLoadDir: QGroundControl.settingsManager.appSettings.missionAutoLoadDir property Fact _autoLoadDir: QGroundControl.settingsManager.appSettings.missionAutoLoadDir
property Fact _appFontPointSize: QGroundControl.settingsManager.appSettings.appFontPointSize
property real _labelWidth: ScreenTools.defaultFontPixelWidth * 15 property real _labelWidth: ScreenTools.defaultFontPixelWidth * 15
property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 30 property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 30
...@@ -135,11 +136,11 @@ QGCView { ...@@ -135,11 +136,11 @@ QGCView {
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Base UI Font Point Size //-- Base UI Font Point Size
Row { Row {
visible: QGroundControl.corePlugin.options.defaultFontPointSize < 1.0 visible: _appFontPointSize.visible
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
QGCLabel { QGCLabel {
id: baseFontLabel id: baseFontLabel
text: qsTr("Base UI font size:") text: qsTr("Font size:")
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
Row { Row {
...@@ -152,32 +153,23 @@ QGCView { ...@@ -152,32 +153,23 @@ QGCView {
height: baseFontEdit.height height: baseFontEdit.height
text: "-" text: "-"
onClicked: { onClicked: {
if(ScreenTools.defaultFontPointSize > 6) { if (_appFontPointSize.value > _appFontPointSize.min) {
QGroundControl.baseFontPointSize = QGroundControl.baseFontPointSize - 1 _appFontPointSize.value = _appFontPointSize.value - 1
} }
} }
} }
QGCTextField { FactTextField {
id: baseFontEdit id: baseFontEdit
width: _editFieldWidth - (decrementButton.width * 2) - (baseFontRow.spacing * 2) width: _editFieldWidth - (decrementButton.width * 2) - (baseFontRow.spacing * 2)
text: QGroundControl.baseFontPointSize fact: QGroundControl.settingsManager.appSettings.appFontPointSize
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;
}
} }
QGCButton { QGCButton {
width: height width: height
height: baseFontEdit.height height: baseFontEdit.height
text: "+" text: "+"
onClicked: { onClicked: {
if(ScreenTools.defaultFontPointSize < 49) { if (_appFontPointSize.value < _appFontPointSize.max) {
QGroundControl.baseFontPointSize = QGroundControl.baseFontPointSize + 1 _appFontPointSize.value = _appFontPointSize.value + 1
} }
} }
} }
...@@ -191,45 +183,47 @@ QGCView { ...@@ -191,45 +183,47 @@ QGCView {
//-- Palette Styles //-- Palette Styles
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
visible: QGroundControl.settingsManager.appSettings.indoorPalette.visible
QGCLabel { QGCLabel {
anchors.baseline: paletteCombo.baseline anchors.baseline: paletteCombo.baseline
text: qsTr("UI Style:") text: qsTr("Color scheme:")
width: _labelWidth width: _labelWidth
} }
QGCComboBox { FactComboBox {
id: paletteCombo id: paletteCombo
width: _editFieldWidth width: _editFieldWidth
model: [ qsTr("Indoor"), qsTr("Outdoor") ] fact: QGroundControl.settingsManager.appSettings.indoorPalette
currentIndex: QGroundControl.isDarkStyle ? 0 : 1 indexModel: false
onActivated: {
if (index != -1) {
currentIndex = index
QGroundControl.isDarkStyle = index === 0 ? true : false
}
}
} }
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Audio preferences //-- Audio preferences
FactCheckBox { FactCheckBox {
text: qsTr("Mute all audio output") text: qsTr("Mute all audio output")
fact: QGroundControl.settingsManager.appSettings.audioMuted fact: _audioMuted
visible: _audioMuted.visible
property Fact _audioMuted: QGroundControl.settingsManager.appSettings.audioMuted
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Prompt Save Log //-- Prompt Save Log
FactCheckBox { FactCheckBox {
id: promptSaveLog id: promptSaveLog
text: qsTr("Prompt to save Flight Data Log after each flight") text: qsTr("Prompt to save Flight Data Log after each flight")
fact: QGroundControl.settingsManager.appSettings.promptFlightTelemetrySave fact: _promptFlightTelemetrySave
visible: !ScreenTools.isMobile visible: !ScreenTools.isMobile && _promptFlightTelemetrySave.visible
property Fact _promptFlightTelemetrySave: QGroundControl.settingsManager.appSettings.promptFlightTelemetrySave
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Prompt Save even if not armed //-- Prompt Save even if not armed
FactCheckBox { FactCheckBox {
text: qsTr("Prompt to save Flight Data Log even if vehicle was not armed") text: qsTr("Prompt to save Flight Data Log even if vehicle was not armed")
fact: QGroundControl.settingsManager.appSettings.promptFlightTelemetrySaveNotArmed fact: _promptFlightTelemetrySaveNotArmed
visible: !ScreenTools.isMobile visible: !ScreenTools.isMobile && _promptFlightTelemetrySaveNotArmed.visible
enabled: promptSaveLog.checked enabled: promptSaveLog.checked
property Fact _promptFlightTelemetrySaveNotArmed: QGroundControl.settingsManager.appSettings.promptFlightTelemetrySaveNotArmed
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Clear settings //-- Clear settings
...@@ -283,11 +277,12 @@ QGCView { ...@@ -283,11 +277,12 @@ QGCView {
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Virtual joystick settings //-- Virtual joystick settings
QGCCheckBox { FactCheckBox {
text: qsTr("Virtual Joystick") text: qsTr("Virtual Joystick")
checked: QGroundControl.virtualTabletJoystick visible: _virtualJoystick.visible
onClicked: QGroundControl.virtualTabletJoystick = checked fact: _virtualJoystick
visible: QGroundControl.corePlugin.options.enableVirtualJoystick
property Fact _virtualJoystick: QGroundControl.settingsManager.appSettings.virtualJoystick
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Default mission item altitude //-- Default mission item altitude
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment