Unverified Commit 6a0f7679 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8641 from mavlink/ValuesPageEditor

New grid based values page editor support
parents edf69f88 60d75808
......@@ -25,6 +25,8 @@
<file alias="JoystickBezel.png">resources/JoystickBezel.png</file>
<file alias="JoystickBezelLight.png">resources/JoystickBezelLight.png</file>
<file alias="land.svg">resources/land.svg</file>
<file alias="LockClosed.svg">resources/LockClosed.svg</file>
<file alias="LockOpen.svg">resources/LockOpen.svg</file>
<file alias="notile.png">resources/notile.png</file>
<file alias="Pause.svg">resources/Pause.svg</file>
<file alias="pause-mission.svg">resources/pause-mission.svg</file>
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.w3.org/2000/svg"
xmlns:cc="http://web.resource.org/cc/"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:ns1="http://sozi.baierouge.fr"
id="svg2064"
viewBox="0 0 150 150"
version="1.0"
y="0"
x="0"
>
<g
id="layer1"
>
<g
id="g2061"
transform="translate(10.641 12.191)"
>
<path
id="rect2723"
style="fill-rule:evenodd;fill:#282828"
d="m64.359 2c-20.072 0-36.231 16.159-36.231 36.231v40.256h10.064v-40.256c0-14.497 11.671-26.167 26.167-26.167s26.167 11.67 26.167 26.167v40.256h10.064v-40.256c0-20.072-16.159-36.231-36.231-36.231z"
/>
<rect
id="rect1941"
style="fill-rule:evenodd;fill:#000000"
rx="0.5"
ry=".5"
height="66.259"
width="85.603"
y="57.359"
x="21.558"
/>
</g
>
</g
>
<metadata
>
<rdf:RDF
>
<cc:Work
>
<dc:format
>image/svg+xml</dc:format
>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage"
/>
<cc:license
rdf:resource="http://creativecommons.org/licenses/publicdomain/"
/>
<dc:publisher
>
<cc:Agent
rdf:about="http://openclipart.org/"
>
<dc:title
>Openclipart</dc:title
>
</cc:Agent
>
</dc:publisher
>
<dc:title
>padlock silhouette a.j. 01</dc:title
>
<dc:date
>2011-01-20T20:53:10</dc:date
>
<dc:description
>Originally uploaded by AJ Ashton for OCAL 0.18</dc:description
>
<dc:source
>https://openclipart.org/detail/105751/padlock-silhouette-a.j.--01-by-anonymous</dc:source
>
<dc:creator
>
<cc:Agent
>
<dc:title
>Anonymous</dc:title
>
</cc:Agent
>
</dc:creator
>
<dc:subject
>
<rdf:Bag
>
<rdf:li
>fix</rdf:li
>
<rdf:li
>keyword</rdf:li
>
<rdf:li
>librarians</rdf:li
>
<rdf:li
>tag</rdf:li
>
</rdf:Bag
>
</dc:subject
>
</cc:Work
>
<cc:License
rdf:about="http://creativecommons.org/licenses/publicdomain/"
>
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction"
/>
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution"
/>
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks"
/>
</cc:License
>
</rdf:RDF
>
</metadata
>
</svg
>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.w3.org/2000/svg"
xmlns:cc="http://web.resource.org/cc/"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:ns1="http://sozi.baierouge.fr"
id="svg2064"
viewBox="0 0 150 150"
version="1.0"
y="0"
x="0"
>
<g
id="layer1"
>
<g
id="g2096"
transform="translate(-2.9648 2.5)"
>
<path
id="rect2723"
style="fill-rule:evenodd;fill:#282828"
d="m112.5 4.1909c-20.072 0-36.231 16.159-36.231 36.231v40.256h10.064v-40.256c0-14.497 11.671-26.167 26.167-26.167 14.5 0 26.17 11.67 26.17 26.167v27.756h10.06v-27.756c0-20.072-16.16-36.231-36.23-36.231z"
/>
<rect
id="rect1941"
style="fill-rule:evenodd;fill:#000000"
rx="0.5"
ry=".5"
height="66.259"
width="85.603"
y="74.55"
x="7.1987"
/>
</g
>
</g
>
<metadata
>
<rdf:RDF
>
<cc:Work
>
<dc:format
>image/svg+xml</dc:format
>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage"
/>
<cc:license
rdf:resource="http://creativecommons.org/licenses/publicdomain/"
/>
<dc:publisher
>
<cc:Agent
rdf:about="http://openclipart.org/"
>
<dc:title
>Openclipart</dc:title
>
</cc:Agent
>
</dc:publisher
>
<dc:title
>padlock unlocked silhou 01</dc:title
>
<dc:date
>2011-01-20T20:53:10</dc:date
>
<dc:description
>Originally uploaded by AJ Ashton for OCAL 0.18</dc:description
>
<dc:source
>https://openclipart.org/detail/105745/padlock-unlocked-silhou-01-by-anonymous</dc:source
>
<dc:creator
>
<cc:Agent
>
<dc:title
>Anonymous</dc:title
>
</cc:Agent
>
</dc:creator
>
<dc:subject
>
<rdf:Bag
>
<rdf:li
>fix</rdf:li
>
<rdf:li
>keyword</rdf:li
>
<rdf:li
>librarians</rdf:li
>
<rdf:li
>tag</rdf:li
>
</rdf:Bag
>
</dc:subject
>
</cc:Work
>
<cc:License
rdf:about="http://creativecommons.org/licenses/publicdomain/"
>
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction"
/>
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution"
/>
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks"
/>
</cc:License
>
</rdf:RDF
>
</metadata
>
</svg
>
This diff is collapsed.
......@@ -7,42 +7,124 @@
*
****************************************************************************/
#pragma once
#ifndef ValuesWidgetController_H
#define ValuesWidgetController_H
#include "FactSystem.h"
#include "QmlObjectListModel.h"
#include "QGCApplication.h"
#include <QObject>
class ValuesWidgetController;
class InstrumentValue : public QObject
{
Q_OBJECT
public:
enum FontSize {
DefaultFontSize=0,
SmallFontSize,
MediumFontSize,
LargeFontSize
};
InstrumentValue(Vehicle* activeVehicle, int fontSize, QmlObjectListModel* rowModel);
Q_PROPERTY(QString factGroupName MEMBER _factGroupName NOTIFY factGroupNameChanged)
Q_PROPERTY(Fact* fact READ fact NOTIFY factChanged)
Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
Q_PROPERTY(bool showUnits READ showUnits WRITE setShowUnits NOTIFY showUnitsChanged)
Q_INVOKABLE void setFact(QString factGroupName, QString factName, QString label);
Q_INVOKABLE void clearFact(void);
Fact* fact (void) { return _fact; }
int fontSize (void) const { return _fontSize; }
QString label (void) const { return _label; }
bool showUnits (void) const { return _showUnits; }
void setFontSize (int fontSize);
void setLabel (const QString& label);
void setShowUnits (bool showUnits);
void activeVehicleChanged (Vehicle* activeVehicle);
void saveToSettings (QSettings& settings) const;
void readFromSettings (const QSettings& settings);
signals:
void factChanged (Fact* fact);
void factGroupNameChanged (QString factGroup);
void labelChanged (QString label);
void fontSizeChanged (int fontSize);
void showUnitsChanged (bool showUnits);
private slots:
private:
void _setFontSize(int fontSize);
Vehicle* _activeVehicle = nullptr;
QmlObjectListModel* _rowModel = nullptr;
Fact* _fact = nullptr;
QString _factGroupName;
QString _label;
bool _showUnits = true;
int _fontSize = DefaultFontSize;
static const char* _factGroupNameKey;
static const char* _factNameKey;
static const char* _labelKey;
static const char* _fontSizeKey;
static const char* _showUnitsKey;
};
class ValuesWidgetController : public QObject
{
Q_OBJECT
public:
ValuesWidgetController(void);
ValuesWidgetController(bool forDefaultSettingsCreation = false);
Q_PROPERTY(QStringList largeValues READ largeValues WRITE setLargeValues NOTIFY largeValuesChanged)
Q_PROPERTY(QStringList smallValues READ smallValues WRITE setSmallValues NOTIFY smallValuesChanged)
Q_PROPERTY(QmlObjectListModel* valuesModel READ valuesModel NOTIFY valuesModelChanged)
Q_PROPERTY(QStringList altitudeProperties READ altitudeProperties CONSTANT)
Q_INVOKABLE InstrumentValue* appendColumn (int rowIndex);
Q_INVOKABLE void deleteLastColumn (int rowIndex);
Q_INVOKABLE QmlObjectListModel* appendRow (bool addBlanksColumn = true);
Q_INVOKABLE QmlObjectListModel* insertRow (int atIndex, bool addBlanksColumn = true);
Q_INVOKABLE void deleteRow (int rowIndex);
Q_INVOKABLE int fontSizeForRow (int rowIndex);
Q_INVOKABLE void setFontSizeForRow (int rowIndex, int fontSize);
Q_INVOKABLE void resetToDefaults (void);
QStringList largeValues(void) const { return _largeValues; }
QStringList smallValues(void) const { return _smallValues; }
void setLargeValues(const QStringList& values);
void setSmallValues(const QStringList& values);
QStringList altitudeProperties(void) const { return _altitudeProperties; }
QmlObjectListModel* valuesModel(void) { return _valuesModel; }
/// Turn on/off saving changes to QSettings
void setPreventSaveSettings(bool preventSaveSettings);
signals:
void largeValuesChanged(QStringList values);
void smallValuesChanged(QStringList values);
void valuesModelChanged(QmlObjectListModel* valuesModel);
private slots:
void _activeVehicleChanged(Vehicle* activeVehicle);
Vehicle* _currentActiveVehicle(void);
void _saveSettings (void);
private:
QStringList _largeValues;
QStringList _smallValues;
QStringList _altitudeProperties;
bool _validRowIndex (int rowIndex);
InstrumentValue* _createNewInstrumentValueWorker (Vehicle* activeVehicle, int fontSize, QmlObjectListModel* rowModel);
void _loadSettings (void);
MultiVehicleManager* _multiVehicleMgr = nullptr;
QmlObjectListModel* _valuesModel = nullptr;
QVariantList _rgFontSizeByRow;
bool _preventSaveSettings = false;
static const char* _groupKey;
static const char* _largeValuesKey;
static const char* _smallValuesKey;
};
static const char* _rowsKey;
static const char* _columnsKey;
static const char* _deprecatedGroupKey;
static const char* _deprecatedLargeValuesKey;
static const char* _deprecatedSmallValuesKey;
#endif
};
......@@ -100,6 +100,7 @@
#include "LogReplayLink.h"
#include "VehicleObjectAvoidance.h"
#include "TrajectoryPoints.h"
#include "ValuesWidgetController.h"
#if defined(QGC_ENABLE_PAIRING)
#include "PairingManager.h"
......@@ -523,6 +524,7 @@ void QGCApplication::_initCommon()
qmlRegisterUncreatableType<QGCMapPolygon> ("QGroundControl.FlightMap", 1, 0, "QGCMapPolygon", kRefOnly);
qmlRegisterUncreatableType<QGCGeoBoundingCube> ("QGroundControl.FlightMap", 1, 0, "QGCGeoBoundingCube", kRefOnly);
qmlRegisterUncreatableType<TrajectoryPoints> ("QGroundControl.FlightMap", 1, 0, "TrajectoryPoints", kRefOnly);
qmlRegisterUncreatableType<InstrumentValue> (kQGCControllers, 1, 0, "InstrumentValue", kRefOnly);
qmlRegisterType<QGCMapCircle> ("QGroundControl.FlightMap", 1, 0, "QGCMapCircle");
......
......@@ -17,6 +17,7 @@ Rectangle {
property real _margins: ScreenTools.defaultFontPixelWidth / 2
property real _pageWidth: _root.width
property var _instrumentPages: QGroundControl.corePlugin.instrumentPages
property bool _settingsUnlocked: false
QGCPalette { id:qgcPal; colorGroupEnabled: parent.enabled }
......@@ -29,11 +30,13 @@ Rectangle {
centeredLabel: true
font.pointSize: ScreenTools.smallFontPointSize
onCurrentIndexChanged: _settingsUnlocked = false
QGCColoredImage {
anchors.leftMargin: _margins
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
source: "/res/gear-black.svg"
source: pageWidgetLoader.item.showLockIcon ? (_settingsUnlocked ? "/res/LockOpen.svg" : "/res/LockClosed.svg") : "/res/gear-black.svg"
mipmap: true
height: parent.height * 0.7
width: height
......@@ -44,7 +47,14 @@ Rectangle {
QGCMouseArea {
fillItem: parent
onClicked: pageWidgetLoader.item.showSettings()
onClicked: {
if (pageWidgetLoader.item.showLockIcon) {
_settingsUnlocked = !_settingsUnlocked
pageWidgetLoader.item.showSettings(_settingsUnlocked)
} else {
pageWidgetLoader.item.showSettings()
}
}
}
}
}
......
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import QtQuick 2.12
import QtQuick.Controls 2.12
import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0
Text {
font.pointSize: ScreenTools.defaultFontPointSize
......
......@@ -22,6 +22,7 @@
#endif
#include "QGCLoggingCategory.h"
#include "QGCCameraManager.h"
#include "ValuesWidgetController.h"
#include <QtQml>
#include <QQmlEngine>
......@@ -406,10 +407,40 @@ QString QGCCorePlugin::showAdvancedUIMessage() const
"Are you sure you want to enable Advanced Mode?");
}
void QGCCorePlugin::valuesWidgetDefaultSettings(QStringList& largeValues, QStringList& smallValues)
QmlObjectListModel* QGCCorePlugin::valuesWidgetDefaultSettings(QObject* valuesModelParent)
{
Q_UNUSED(smallValues);
largeValues << "Vehicle.altitudeRelative" << "Vehicle.groundSpeed" << "Vehicle.flightTime";
ValuesWidgetController controller(true /* forDefaultSettingsCreation */);
// We don't want these to get written out to settings. This way if the user doesn't modify them
// they will get new changes to default settings from newer builds automatically on next run.
controller.setPreventSaveSettings(true);
QmlObjectListModel* columnModel = controller.appendRow();
InstrumentValue* colValue = columnModel->value<InstrumentValue*>(0);
colValue->setFact("Vehicle", "altitudeRelative", QString());
colValue->setLabel(colValue->fact()->shortDescription());
colValue->setShowUnits(true);
colValue->setFontSize(InstrumentValue::LargeFontSize);
columnModel = controller.appendRow();
colValue = columnModel->value<InstrumentValue*>(0);
colValue->setFact("Vehicle", "groundSpeed", QString());
colValue->setLabel(colValue->fact()->shortDescription());
colValue->setShowUnits(true);
colValue->setFontSize(InstrumentValue::DefaultFontSize);
columnModel = controller.appendRow();
colValue = columnModel->value<InstrumentValue*>(0);
colValue->setFact("Vehicle", "flightTime", QString());
colValue->setLabel(colValue->fact()->shortDescription());
colValue->setShowUnits(false);
colValue->setFontSize(InstrumentValue::DefaultFontSize);
controller.setPreventSaveSettings(false);
controller.valuesModel()->setParent(valuesModelParent);
return controller.valuesModel();
}
QQmlApplicationEngine* QGCCorePlugin::createRootWindow(QObject *parent)
......
......@@ -105,8 +105,9 @@ public:
/// Allows a plugin to override the specified color name from the palette
virtual void paletteOverride(QString colorName, QGCPalette::PaletteColorInfo_t& colorInfo);
/// Allows the plugin to override the default settings for the Values Widget large and small values
virtual void valuesWidgetDefaultSettings(QStringList& largeValues, QStringList& smallValues);
/// Return the default Intrument Value model for the Values Widget. The returned model will be
/// re-parented to valuesModelParent for ownership.
virtual QmlObjectListModel* valuesWidgetDefaultSettings(QObject* valuesModelParent);
/// Allows the plugin to override the creation of the root (native) window.
virtual QQmlApplicationEngine* createRootWindow(QObject* parent);
......
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