Commit 7800a06a authored by Don Gagne's avatar Don Gagne

Add virtual joystick settings

Also reflow settings pane to take less space
parent dbaa604b
......@@ -29,7 +29,9 @@
#include <QSettings>
static const char* kQmlGlobalKeyName = "QGCQml";
static const char* kQmlGlobalKeyName = "QGCQml";
const char* QGroundControlQmlGlobal::_virtualTabletJoystickKey = "VirtualTabletJoystick";
QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCToolbox* toolbox, QObject* parent)
: QObject(parent)
......@@ -37,8 +39,10 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCToolbox* toolbox, QObject* p
, _linkManager(toolbox->linkManager())
, _homePositionManager(toolbox->homePositionManager())
, _flightMapSettings(toolbox->flightMapSettings())
, _virtualTabletJoystick(false)
{
QSettings settings;
_virtualTabletJoystick = settings.value(_virtualTabletJoystickKey, false). toBool();
}
void QGroundControlQmlGlobal::saveGlobalSetting (const QString& key, const QString& value)
......@@ -204,3 +208,13 @@ void QGroundControlQmlGlobal::setIsVersionCheckEnabled(bool enable)
qgcApp()->toolbox()->mavlinkProtocol()->enableVersionCheck(enable);
emit isVersionCheckEnabledChanged(enable);
}
void QGroundControlQmlGlobal::setVirtualTabletJoystick(bool enabled)
{
if (_virtualTabletJoystick != enabled) {
QSettings settings;
settings.setValue(_virtualTabletJoystickKey, enabled);
_virtualTabletJoystick = enabled;
emit virtualTabletJoystickChanged(enabled);
}
}
......@@ -67,6 +67,7 @@ public:
Q_PROPERTY(bool isHeartBeatEnabled READ isHeartBeatEnabled WRITE setIsHeartBeatEnabled NOTIFY isHeartBeatEnabledChanged)
Q_PROPERTY(bool isMultiplexingEnabled READ isMultiplexingEnabled WRITE setIsMultiplexingEnabled NOTIFY isMultiplexingEnabledChanged)
Q_PROPERTY(bool isVersionCheckEnabled READ isVersionCheckEnabled WRITE setIsVersionCheckEnabled NOTIFY isVersionCheckEnabledChanged)
Q_PROPERTY(bool virtualTabletJoystick READ virtualTabletJoystick WRITE setVirtualTabletJoystick NOTIFY virtualTabletJoystickChanged)
Q_INVOKABLE void saveGlobalSetting (const QString& key, const QString& value);
Q_INVOKABLE QString loadGlobalSetting (const QString& key, const QString& defaultValue);
......@@ -101,6 +102,7 @@ public:
bool isHeartBeatEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->heartbeatsEnabled(); }
bool isMultiplexingEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->multiplexingEnabled(); }
bool isVersionCheckEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->versionCheckEnabled(); }
bool virtualTabletJoystick () { return _virtualTabletJoystick; }
//-- TODO: Make this into an actual preference.
bool isAdvancedMode () { return false; }
......@@ -113,6 +115,7 @@ public:
void setIsHeartBeatEnabled (bool enable);
void setIsMultiplexingEnabled (bool enable);
void setIsVersionCheckEnabled (bool enable);
void setVirtualTabletJoystick (bool enabled);
signals:
void isDarkStyleChanged (bool dark);
......@@ -123,6 +126,7 @@ signals:
void isHeartBeatEnabledChanged (bool enabled);
void isMultiplexingEnabledChanged (bool enabled);
void isVersionCheckEnabledChanged (bool enabled);
void virtualTabletJoystickChanged (bool enabled);
private:
#ifdef QT_DEBUG
......@@ -133,6 +137,10 @@ private:
LinkManager* _linkManager;
HomePositionManager* _homePositionManager;
FlightMapSettings* _flightMapSettings;
bool _virtualTabletJoystick;
static const char* _virtualTabletJoystickKey;
};
#endif
......@@ -54,17 +54,19 @@ Rectangle {
Column {
id: settingsColumn
width: _generalRoot.width
spacing: ScreenTools.defaultFontPixelHeight
anchors.margins: ScreenTools.defaultFontPixelWidth
spacing: ScreenTools.defaultFontPixelHeight / 2
QGCLabel {
text: "General Settings"
font.pixelSize: ScreenTools.mediumFontPixelSize
}
Rectangle {
height: 1
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
color: qgcPal.button
}
//-----------------------------------------------------------------
//-- Audio preferences
QGCCheckBox {
......@@ -131,6 +133,12 @@ Rectangle {
}
}
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
//-----------------------------------------------------------------
//-- Map Providers
Row {
......@@ -182,6 +190,11 @@ Rectangle {
}
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
//-----------------------------------------------------------------
//-- Autoconnect settings
QGCLabel { text: "Autoconnect to the following devices:" }
......@@ -209,6 +222,20 @@ Rectangle {
checked: QGroundControl.linkManager.autoconnectUDP
onClicked: QGroundControl.linkManager.autoconnectUDP = checked
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
//-----------------------------------------------------------------
//-- Virtual joystick settings
QGCCheckBox {
text: "Thumb Joystick (WIP - be careful!)"
checked: QGroundControl.virtualTabletJoystick
onClicked: QGroundControl.virtualTabletJoystick = checked
visible: ScreenTools.isMobile
}
}
}
}
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