Commit f26504f5 authored by dogmaphobic's avatar dogmaphobic

Saving and Restoring "Map Is Main"

parent 8a9f0c1a
......@@ -56,8 +56,9 @@ Item {
readonly property string _mapName: "FlightDisplayView"
readonly property string _showMapBackgroundKey: "/showMapBackground"
readonly property string _mainIsMapKey: "MainFlyWindowIsMap"
property bool _mainIsMap: !_controller.hasVideo
property bool _mainIsMap: QGroundControl.loadBoolGlobalSetting(_mainIsMapKey, true)
property real _roll: _activeVehicle ? (isNaN(_activeVehicle.roll) ? _defaultRoll : _activeVehicle.roll) : _defaultRoll
property real _pitch: _activeVehicle ? (isNaN(_activeVehicle.pitch) ? _defaultPitch : _activeVehicle.pitch) : _defaultPitch
......@@ -158,6 +159,7 @@ Item {
_mainIsMap = !_mainIsMap
pip.visible = false
reloadContents();
QGroundControl.saveBoolGlobalSetting(_mainIsMapKey, _mainIsMap)
}
}
}
......
......@@ -88,7 +88,7 @@ Item {
horizontalAlignment: TextEdit.AlignHCenter
}
QGCLabel {
text: altitude
text: altitude.toFixed(1)
font.weight: Font.DemiBold
color: isSatellite ? "black" : "white"
}
......@@ -110,7 +110,7 @@ Item {
horizontalAlignment: TextEdit.AlignHCenter
}
QGCLabel {
text: groundSpeed
text: groundSpeed.toFixed(1)
font.weight: Font.DemiBold
color: isSatellite ? "black" : "white"
}
......@@ -134,7 +134,7 @@ Item {
horizontalAlignment: TextEdit.AlignHCenter
}
QGCLabel {
text: airSpeed
text: airSpeed.toFixed(1)
font.weight: Font.DemiBold
color: isSatellite ? "black" : "white"
}
......@@ -156,7 +156,7 @@ Item {
horizontalAlignment: TextEdit.AlignHCenter
}
QGCLabel {
text: climbRate
text: climbRate.toFixed(1)
font.weight: Font.DemiBold
color: isSatellite ? "black" : "white"
}
......
......@@ -26,6 +26,8 @@
#include "QGroundControlQmlGlobal.h"
static const char* kQmlGlobalKeyName = "QGCQml";
QGroundControlQmlGlobal::QGroundControlQmlGlobal(QObject* parent)
: QObject(parent)
, _homePositionManager(HomePositionManager::instance())
......@@ -38,3 +40,31 @@ QGroundControlQmlGlobal::~QGroundControlQmlGlobal()
{
}
void QGroundControlQmlGlobal::saveGlobalSetting (const QString& key, const QString& value)
{
QSettings settings;
settings.beginGroup(kQmlGlobalKeyName);
settings.setValue(key, value);
}
QString QGroundControlQmlGlobal::loadGlobalSetting (const QString& key, const QString& defaultValue)
{
QSettings settings;
settings.beginGroup(kQmlGlobalKeyName);
return settings.value(key, defaultValue).toString();
}
void QGroundControlQmlGlobal::saveBoolGlobalSetting (const QString& key, bool value)
{
QSettings settings;
settings.beginGroup(kQmlGlobalKeyName);
settings.setValue(key, value);
}
bool QGroundControlQmlGlobal::loadBoolGlobalSetting (const QString& key, bool defaultValue)
{
QSettings settings;
settings.beginGroup(kQmlGlobalKeyName);
return settings.value(key, defaultValue).toBool();
}
......@@ -47,6 +47,11 @@ 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
Q_INVOKABLE void saveGlobalSetting (const QString& key, const QString& value);
Q_INVOKABLE QString loadGlobalSetting (const QString& key, const QString& defaultValue);
Q_INVOKABLE void saveBoolGlobalSetting (const QString& key, bool value);
Q_INVOKABLE bool loadBoolGlobalSetting (const QString& key, bool defaultValue);
// Property accesors
HomePositionManager* homePositionManager () { return _homePositionManager; }
......
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