Commit 00fa796f authored by DoinLakeFlyer's avatar DoinLakeFlyer

parent c5695488
......@@ -571,8 +571,6 @@ HEADERS += \
src/Camera/QGCCameraManager.h \
src/CmdLineOptParser.h \
src/FirmwarePlugin/PX4/px4_custom_mode.h \
src/FlightMap/Widgets/InstrumentValue.h \
src/FlightMap/Widgets/ValuesWidgetController.h \
src/FollowMe/FollowMe.h \
src/Joystick/Joystick.h \
src/Joystick/JoystickManager.h \
......@@ -645,6 +643,8 @@ HEADERS += \
src/QmlControls/AppMessages.h \
src/QmlControls/CoordinateVector.h \
src/QmlControls/EditPositionDialogController.h \
src/QmlControls/InstrumentValueData.h \
src/QmlControls/InstrumentValueArea.h \
src/QmlControls/ParameterEditorController.h \
src/QmlControls/QGCFileDialogController.h \
src/QmlControls/QGCImageProvider.h \
......@@ -780,8 +780,6 @@ SOURCES += \
src/Camera/QGCCameraIO.cc \
src/Camera/QGCCameraManager.cc \
src/CmdLineOptParser.cc \
src/FlightMap/Widgets/InstrumentValue.cc \
src/FlightMap/Widgets/ValuesWidgetController.cc \
src/FollowMe/FollowMe.cc \
src/Joystick/Joystick.cc \
src/Joystick/JoystickManager.cc \
......@@ -851,6 +849,8 @@ SOURCES += \
src/QmlControls/AppMessages.cc \
src/QmlControls/CoordinateVector.cc \
src/QmlControls/EditPositionDialogController.cc \
src/QmlControls/InstrumentValueData.cc \
src/QmlControls/InstrumentValueArea.cc \
src/QmlControls/ParameterEditorController.cc \
src/QmlControls/QGCFileDialogController.cc \
src/QmlControls/QGCImageProvider.cc \
......
......@@ -99,6 +99,9 @@
<file alias="QGroundControl/Controls/GeoFenceEditor.qml">src/PlanView/GeoFenceEditor.qml</file>
<file alias="QGroundControl/Controls/GeoFenceMapVisuals.qml">src/PlanView/GeoFenceMapVisuals.qml</file>
<file alias="QGroundControl/Controls/IndicatorButton.qml">src/QmlControls/IndicatorButton.qml</file>
<file alias="QGroundControl/Controls/InstrumentValue.qml">src/QmlControls/InstrumentValue.qml</file>
<file alias="QGroundControl/Controls/InstrumentValueArea.qml">src/QmlControls/InstrumentValueArea.qml</file>
<file alias="QGroundControl/Controls/InstrumentValueEditDialog.qml">src/QmlControls/InstrumentValueEditDialog.qml</file>
<file alias="QGroundControl/Controls/JoystickThumbPad.qml">src/QmlControls/JoystickThumbPad.qml</file>
<file alias="QGroundControl/Controls/KMLOrSHPFileDialog.qml">src/QmlControls/KMLOrSHPFileDialog.qml</file>
<file alias="QGroundControl/Controls/LogReplayStatusBar.qml">src/QmlControls/LogReplayStatusBar.qml</file>
......@@ -209,8 +212,6 @@
<file alias="QGroundControl/FlightMap/CustomMapItems.qml">src/FlightMap/MapItems/CustomMapItems.qml</file>
<file alias="QGroundControl/FlightMap/FlightMap.qml">src/FlightMap/FlightMap.qml</file>
<file alias="QGroundControl/FlightMap/InstrumentSwipeView.qml">src/FlightMap/Widgets/InstrumentSwipeView.qml</file>
<file alias="QGroundControl/FlightMap/InstrumentValue.qml">src/FlightMap/Widgets/InstrumentValue.qml</file>
<file alias="QGroundControl/FlightMap/InstrumentValueEditDialog.qml">src/FlightMap/Widgets/InstrumentValueEditDialog.qml</file>
<file alias="QGroundControl/FlightMap/MapFitFunctions.qml">src/FlightMap/Widgets/MapFitFunctions.qml</file>
<file alias="QGroundControl/FlightMap/MapScale.qml">src/FlightMap/MapScale.qml</file>
<file alias="QGroundControl/FlightMap/MissionItemIndicator.qml">src/FlightMap/MapItems/MissionItemIndicator.qml</file>
......
......@@ -23,157 +23,17 @@ import QGroundControl.FlightMap 1.0
import QGroundControl 1.0
/// Value page for InstrumentPanel PageView
Column {
id: _root
width: pageWidth
spacing: ScreenTools.defaultFontPixelHeight / 2
InstrumentValueArea {
id: _root
width: pageWidth
userSettingsGroup: valuePageUserSettingsGroup
defaultSettingsGroup: valuePageDefaultSettingsGroup
orientation: InstrumentValueArea.VerticalOrientation
property bool showSettingsIcon: true
property bool showLockIcon: true
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
property real _margins: ScreenTools.defaultFontPixelWidth / 2
property int _colMax: 4
property bool _settingsUnlocked: false
property var instrumentValue: null
property real _columnButtonWidth: ScreenTools.minTouchPixels / 2
property real _columnButtonHeight: ScreenTools.minTouchPixels
property real _columnButtonSpacing: 2
property real _columnButtonsTotalHeight: (_columnButtonHeight * 2) + _columnButtonSpacing
QGCPalette { id:qgcPal; colorGroupEnabled: true }
QGCPalette { id:qgcPalDisabled; colorGroupEnabled: false }
ValuesWidgetController { id: controller }
function showSettings(settingsUnlocked) {
_settingsUnlocked = settingsUnlocked
}
function listContains(list, value) {
for (var i=0; i<list.length; i++) {
if (list[i] === value) {
return true
}
}
return false
}
ButtonGroup { id: factRadioGroup }
Component {
id: valueItemMouseAreaComponent
MouseArea {
anchors.centerIn: parent
width: parent.width
height: _columnButtonsTotalHeight
visible: _settingsUnlocked
property var instrumentValue
property int rowIndex
onClicked: {
instrumentValue = instrumentValue
mainWindow.showPopupDialog(valueDialogComponent, { instrumentValue: instrumentValue })
}
}
}
Repeater {
id: rowRepeater
model: controller.valuesModel
Column {
id: rowRepeaterLayout
spacing: 1
property int rowIndex: index
Row {
id: columnRow
spacing: 1
Repeater {
id: columnRepeater
model: object
property real _interColumnSpacing: (columnRepeater.count - (_settingsUnlocked ? 0 : 1)) * columnRow.spacing
property real columnWidth: (pageWidth - (_settingsUnlocked ? _columnButtonWidth : 0) - _interColumnSpacing) / columnRepeater.count
property bool componentCompleted: false
Component.onCompleted: componentCompleted = true
onItemAdded: valueItemMouseAreaComponent.createObject(item, { "instrumentValue": object.get(index), "rowIndex": index })
InstrumentValue {
id: columnItem
anchors.verticalCenter: parent.verticalCenter
width: columnRepeater.columnWidth
recalcOk: columnRepeater.componentCompleted
instrumentValue: object
}
} // Repeater - columns
ColumnLayout {
id: columnsButtonsLayout
width: _columnButtonWidth
spacing: _columnButtonSpacing
visible: _settingsUnlocked
QGCButton {
Layout.fillHeight: true
Layout.preferredHeight: ScreenTools.minTouchPixels
Layout.preferredWidth: parent.width
text: qsTr("+")
onClicked: controller.appendColumn(rowRepeaterLayout.rowIndex)
}
QGCButton {
Layout.fillHeight: true
Layout.preferredHeight: ScreenTools.minTouchPixels
Layout.preferredWidth: parent.width
text: qsTr("-")
enabled: index !== 0 || columnRepeater.count !== 1
onClicked: controller.deleteLastColumn(rowRepeaterLayout.rowIndex)
}
}
} // RowLayout
RowLayout {
width: parent.width
height: ScreenTools.defaultFontPixelWidth * 2
spacing: 1
visible: _settingsUnlocked
QGCButton {
Layout.fillWidth: true
Layout.preferredHeight: ScreenTools.defaultFontPixelWidth * 2
text: qsTr("+")
onClicked: controller.insertRow(index + 1)
}
QGCButton {
Layout.fillWidth: true
Layout.preferredHeight: ScreenTools.defaultFontPixelWidth * 2
text: qsTr("-")
enabled: index !== 0
onClicked: controller.deleteRow(index)
}
}
}
} // Repeater - rows
QGCButton {
anchors.left: parent.left
anchors.right: parent.right
text: qsTr("Reset To Defaults")
visible: _settingsUnlocked
onClicked: controller.resetToDefaults()
}
Component {
id: valueDialogComponent
InstrumentValueEditDialog { }
_root.settingsUnlocked = settingsUnlocked
}
}
This diff is collapsed.
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#pragma once
#include "FactSystem.h"
#include "QmlObjectListModel.h"
#include "QGCApplication.h"
#include "InstrumentValue.h"
#include <QObject>
class ValuesWidgetController : public QObject
{
Q_OBJECT
public:
ValuesWidgetController(bool forDefaultSettingsCreation = false);
Q_PROPERTY(QmlObjectListModel* valuesModel READ valuesModel NOTIFY valuesModelChanged)
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);
QmlObjectListModel* valuesModel(void) { return _valuesModel; }
/// Turn on/off saving changes to QSettings
void setPreventSaveSettings(bool preventSaveSettings);
/// Allows the ownership of the _valuesModel to be re-parented to a different controller
void setValuesModelParentController(ValuesWidgetController* newParentController);
signals:
void valuesModelChanged(QmlObjectListModel* valuesModel);
private slots:
void _activeVehicleChanged(Vehicle* activeVehicle);
Vehicle* _currentActiveVehicle(void);
void _saveSettings (void);
private:
bool _validRowIndex (int rowIndex);
InstrumentValue* _createNewInstrumentValueWorker (Vehicle* activeVehicle, InstrumentValue::FontSize fontSize, QmlObjectListModel* rowModel);
void _loadSettings (void);
void _connectSignalsToController (InstrumentValue* value, ValuesWidgetController* controller);
QString _pascalCase (const QString& text);
MultiVehicleManager* _multiVehicleMgr = nullptr;
QmlObjectListModel* _valuesModel = nullptr;
QVariantList _rgFontSizeByRow;
bool _preventSaveSettings = false;
static const char* _groupKey;
static const char* _rowsKey;
static const char* _columnsKey;
static const char* _deprecatedGroupKey;
static const char* _deprecatedLargeValuesKey;
static const char* _deprecatedSmallValuesKey;
};
......@@ -77,7 +77,8 @@
#if defined(QGC_ENABLE_MAVLINK_INSPECTOR)
#include "MAVLinkInspectorController.h"
#endif
#include "ValuesWidgetController.h"
#include "InstrumentValueArea.h"
#include "InstrumentValueData.h"
#include "AppMessages.h"
#include "SimulatedPosition.h"
#include "PositionManager.h"
......@@ -101,7 +102,6 @@
#include "LogReplayLink.h"
#include "VehicleObjectAvoidance.h"
#include "TrajectoryPoints.h"
#include "ValuesWidgetController.h"
#include "RCToParamDialogController.h"
#include "QGCImageProvider.h"
......@@ -483,6 +483,7 @@ void QGCApplication::_initCommon()
static const char* kQGroundControl = "QGroundControl";
static const char* kQGCControllers = "QGroundControl.Controllers";
static const char* kQGCVehicle = "QGroundControl.Vehicle";
static const char* kQGCTemplates = "QGroundControl.Templates";
QSettings settings;
......@@ -510,6 +511,7 @@ void QGCApplication::_initCommon()
qmlRegisterUncreatableType<MissionCommandTree> (kQGroundControl, 1, 0, "MissionCommandTree", kRefOnly);
qmlRegisterUncreatableType<CameraCalc> (kQGroundControl, 1, 0, "CameraCalc", kRefOnly);
qmlRegisterUncreatableType<LogReplayLink> (kQGroundControl, 1, 0, "LogReplayLink", kRefOnly);
qmlRegisterUncreatableType<InstrumentValueData> (kQGroundControl, 1, 0, "InstrumentValueData", kRefOnly);
qmlRegisterType<LogReplayLinkController> (kQGroundControl, 1, 0, "LogReplayLinkController");
#if defined(QGC_ENABLE_MAVLINK_INSPECTOR)
qmlRegisterUncreatableType<MAVLinkChartController> (kQGroundControl, 1, 0, "MAVLinkChart", kRefOnly);
......@@ -528,7 +530,8 @@ 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<InstrumentValueArea> (kQGCTemplates, 1, 0, "InstrumentValueArea");
qmlRegisterType<QGCMapCircle> ("QGroundControl.FlightMap", 1, 0, "QGCMapCircle");
......@@ -536,7 +539,7 @@ void QGCApplication::_initCommon()
qmlRegisterType<ESP8266ComponentController> (kQGCControllers, 1, 0, "ESP8266ComponentController");
qmlRegisterType<ScreenToolsController> (kQGCControllers, 1, 0, "ScreenToolsController");
qmlRegisterType<PlanMasterController> (kQGCControllers, 1, 0, "PlanMasterController");
qmlRegisterType<ValuesWidgetController> (kQGCControllers, 1, 0, "ValuesWidgetController");
qmlRegisterType<InstrumentValueArea> (kQGCTemplates, 1, 0, "InstrumentValueArea");
qmlRegisterType<QGCFileDialogController> (kQGCControllers, 1, 0, "QGCFileDialogController");
qmlRegisterType<RCChannelMonitorController> (kQGCControllers, 1, 0, "RCChannelMonitorController");
qmlRegisterType<JoystickConfigController> (kQGCControllers, 1, 0, "JoystickConfigController");
......
......@@ -11,6 +11,7 @@ import QtQuick 2.12
import QtQuick.Layouts 1.2
import QtQuick.Controls 2.5
import QGroundControl 1.0
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
......@@ -19,7 +20,7 @@ Item {
id: root
height: value.y + value.height
property var instrumentValue: null
property var instrumentValueData: null
property bool recalcOk: false
property var _rgFontSizes: [ ScreenTools.defaultFontPointSize, ScreenTools.smallFontPointSize, ScreenTools.mediumFontPointSize, ScreenTools.largeFontPointSize ]
......@@ -27,63 +28,74 @@ Item {
property real _doubleDescent: ScreenTools.defaultFontDescent * 2
property real _tightDefaultFontHeight: ScreenTools.defaultFontPixelHeight - _doubleDescent
property var _rgFontSizeTightHeights: [ _tightDefaultFontHeight * _rgFontSizeRatios[0] + 2, _tightDefaultFontHeight * _rgFontSizeRatios[1] + 2, _tightDefaultFontHeight * _rgFontSizeRatios[2] + 2, _tightDefaultFontHeight * _rgFontSizeRatios[3] + 2 ]
property real _tightHeight: _rgFontSizeTightHeights[instrumentValueData.instrumentValueArea.fontSize]
property real _fontSize: _rgFontSizes[instrumentValueData.instrumentValueArea.fontSize]
property real _horizontalLabelSpacing: ScreenTools.defaultFontPixelWidth
property real _blankEntryHeight: ScreenTools.defaultFontPixelHeight * 2
property bool _showIcon: instrumentValueData.icon || instrumentValueData.rangeType === InstrumentValueData.IconSelectRange
// After fighting with using layout and/or anchors I gave up and just do a manual recalc to position items which ends up being much simpler
function recalcPositions() {
if (!recalcOk) {
return
}
var smallSpacing = 2
if (instrumentValue.icon) {
if (instrumentValue.labelPosition === InstrumentValue.LabelAbove) {
var smallVerticalSpacing = 2
var halfWidth = width / 2
var halfHorizontalSpacing = _horizontalLabelSpacing / 2
if (_showIcon) {
if (instrumentValueData.instrumentValueArea.orientation === InstrumentValueArea.VerticalOrientation) {
valueIcon.x = (width - valueIcon.width) / 2
valueIcon.y = 0
value.x = (width - value.width) / 2
value.y = valueIcon.height + smallSpacing
value.y = valueIcon.height + smallVerticalSpacing
} else {
var iconPlusValueWidth = valueIcon.width + value.width + ScreenTools.defaultFontPixelWidth
valueIcon.x = (width - iconPlusValueWidth) / 2
value.y = 0 // value assumed to be taller
valueIcon.y = (value.height - valueIcon.height) / 2
value.x = valueIcon.x + valueIcon.width + (ScreenTools.defaultFontPixelWidth / 2)
value.y = 0
value.x = halfWidth + halfHorizontalSpacing
valueIcon.x = halfWidth - halfHorizontalSpacing - valueIcon.width
}
label.x = label.y = 0
} else {
// label above value
if (instrumentValue.text) {
label.x = (width - label.width) / 2
label.y = 0
value.y = label.height + smallSpacing
if (instrumentValueData.text) {
if (instrumentValueData.instrumentValueArea.orientation === InstrumentValueArea.VerticalOrientation) {
label.x = (width - label.width) / 2
label.y = 0
value.x = (width - value.width) / 2
value.y = label.height + smallVerticalSpacing
} else {
value.y = 0 // value assumed to be taller
label.y = (value.height - label.height) / 2
value.x = halfWidth + halfHorizontalSpacing
label.x = halfWidth - halfHorizontalSpacing - label.width
}
} else {
value.y = 0
value.x = (width - value.width) / 2
value.y = (height - value.height) / 2
}
value.x = (width - value.width) / 2
valueIcon.x = valueIcon.y = 0
}
}
onRecalcOkChanged: recalcPositions()
onWidthChanged: recalcPositions()
onWidthChanged: recalcPositions()
Connections {
target: instrumentValue
onIconChanged: recalcPositions()
onLabelPositionChanged: recalcPositions()
target: instrumentValueData
onIconChanged: recalcPositions()
}
QGCColoredImage {
id: valueIcon
height: _rgFontSizeTightHeights[instrumentValue.fontSize]
height: _tightHeight
width: height
source: icon
sourceSize.height: height
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
color: instrumentValue.isValidColor(instrumentValue.currentColor) ? instrumentValue.currentColor : qgcPal.text
opacity: instrumentValue.currentOpacity
visible: instrumentValue.icon
color: instrumentValueData.isValidColor(instrumentValueData.currentColor) ? instrumentValueData.currentColor : qgcPal.text
opacity: instrumentValueData.currentOpacity
visible: _showIcon
onWidthChanged: root.recalcPositions()
onHeightChanged: root.recalcPositions()
......@@ -91,17 +103,17 @@ Item {
readonly property string iconPrefix: "/InstrumentValueIcons/"
function updateIcon() {
if (instrumentValue.rangeType == InstrumentValue.IconSelectRange) {
icon = iconPrefix + instrumentValue.currentIcon
} else if (instrumentValue.icon) {
icon = iconPrefix + instrumentValue.icon
if (instrumentValueData.rangeType === InstrumentValueData.IconSelectRange) {
icon = iconPrefix + instrumentValueData.currentIcon
} else if (instrumentValueData.icon) {
icon = iconPrefix + instrumentValueData.icon
} else {
icon = ""
}
}
Connections {
target: instrumentValue
target: instrumentValueData
onRangeTypeChanged: valueIcon.updateIcon()
onCurrentIconChanged: valueIcon.updateIcon()
onIconChanged: valueIcon.updateIcon()
......@@ -117,28 +129,27 @@ Item {
text: _settingsUnlocked ? qsTr("BLANK") : ""
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
visible: !instrumentValue.fact
visible: !instrumentValueData.fact
onWidthChanged: root.recalcPositions()
onHeightChanged: root.recalcPositions()
}
QGCLabel {
id: label
height: _rgFontSizeTightHeights[InstrumentValue.SmallFontSize]
font.pointSize: ScreenTools.smallFontPointSize
text: instrumentValue.text.toUpperCase()
height: _tightHeight
text: instrumentValueData.text
verticalAlignment: Text.AlignVCenter
visible: instrumentValue.fact && instrumentValue.text && !instrumentValue.icon
visible: !_showIcon
onWidthChanged: root.recalcPositions()
onHeightChanged: root.recalcPositions()
}
QGCLabel {
id: value
font.pointSize: _rgFontSizes[instrumentValue.fontSize]
text: visible ? (instrumentValue.fact.enumOrValueString + (instrumentValue.showUnits ? instrumentValue.fact.units : "")) : ""
font.pointSize: _fontSize
text: visible ? (instrumentValueData.fact.enumOrValueString + (instrumentValueData.showUnits ? instrumentValueData.fact.units : "")) : ""
verticalAlignment: Text.AlignVCenter
visible: instrumentValue.fact
visible: instrumentValueData.fact
onWidthChanged: root.recalcPositions()
onHeightChanged: root.recalcPositions()
}
......
This diff is collapsed.
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#pragma once
#include "FactSystem.h"
#include "QmlObjectListModel.h"
#include "QGCApplication.h"
#include <QQuickItem>
class InstrumentValueData;
class InstrumentValueArea : public QQuickItem
{
Q_OBJECT
public:
InstrumentValueArea(QQuickItem *parent = nullptr);
InstrumentValueArea(const QString& defaultSettingsGroup);
enum Orientation {
HorizontalOrientation=0, // Labels will be to the left of the value
VerticalOrientation // Labels will be above the value
};
Q_ENUMS(Orientation)
enum FontSize {
DefaultFontSize=0,
SmallFontSize,
MediumFontSize,
LargeFontSize,
};
Q_ENUMS(FontSize)
// valuePageDefaultSettingsGroup:
// This is the setting group name for default settings which are used when the user has not modified anything from the default setup. These settings will be overwritten
// prior to each use by the call to QGCCorePlugin::instrumentValueAreaCreateDefaultSettings.
// valuePageUserSettingsGroup:
// This is the settings group name for user modified settings. Settings will be saved to here whenever the user modified anything. Also at that point in time the
// defaults settings group will be removed.
// The combination of the two valuePage*SettingsGroup values allows each InstrumentValueArea to have it's own persistence space.
Q_PROPERTY(QString valuePageDefaultSettingsGroup MEMBER valuePageDefaultSettingsGroup CONSTANT)
Q_PROPERTY(QString valuePageUserSettingsGroup MEMBER _valuePageUserSettingsGroup CONSTANT)
Q_PROPERTY(QString userSettingsGroup MEMBER _userSettingsGroup NOTIFY userSettingsGroupChanged)
Q_PROPERTY(QString defaultSettingsGroup MEMBER _defaultSettingsGroup NOTIFY defaultSettingsGroupChanged)
Q_PROPERTY(Orientation orientation MEMBER _orientation NOTIFY orientationChanged)
Q_PROPERTY(QStringList iconNames READ iconNames CONSTANT)
Q_PROPERTY(FontSize fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
Q_PROPERTY(QStringList fontSizeNames MEMBER _fontSizeNames CONSTANT)
Q_PROPERTY(QmlObjectListModel* rowValues MEMBER _rowValues NOTIFY rowValuesChanged)
Q_INVOKABLE InstrumentValueData* 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 void resetToDefaults (void);
FontSize fontSize (void) const { return _fontSize; }
QmlObjectListModel* rowValues (void) { return _rowValues; }
QStringList iconNames (void) const { return _iconNames; }
void setFontSize(FontSize fontSize);
// Override from QQmlParserStatus
void componentComplete(void) final;
static const QString valuePageDefaultSettingsGroup;
signals:
void userSettingsGroupChanged (const QString& userSettingsGroup);
void defaultSettingsGroupChanged(const QString& defaultSettingsGroup);
void rowValuesChanged (QmlObjectListModel* rowValues);
void orientationChanged (Orientation orientation);
void fontSizeChanged (FontSize fontSize);
private slots:
void _saveSettings(void);
private:
void _connectSignals (void);
void _checkForDeprecatedSettings (void);
bool _validRowIndex (int rowIndex);
InstrumentValueData* _createNewInstrumentValueWorker (QmlObjectListModel* rowModel);
void _loadSettings (void);
QString _pascalCase (const QString& text);
Q_DISABLE_COPY(InstrumentValueArea)
QString _defaultSettingsGroup; // Settings group to read from if the user has not modified from the default settings
QString _userSettingsGroup; // Settings group to read from for user modified settings
Orientation _orientation = VerticalOrientation;
FontSize _fontSize = DefaultFontSize;
QmlObjectListModel* _rowValues = nullptr;
bool _preventSaveSettings = false;
// These are user facing string for the various enums.
static QStringList _iconNames;
static const QStringList _fontSizeNames;
static const QString _valuePageUserSettingsGroup;
static const char* _versionKey;
static const char* _rowsKey;
static const char* _columnsKey;
static const char* _orientationKey;
static const char* _fontSizeKey;
static const char* _factGroupNameKey;
static const char* _factNameKey;
static const char* _textKey;
static const char* _showUnitsKey;
static const char* _iconKey;
static const char* _rangeTypeKey;
static const char* _rangeValuesKey;
static const char* _rangeColorsKey;
static const char* _rangeIconsKey;
static const char* _rangeOpacitiesKey;
static const char* _deprecatedGroupKey;
};
QML_DECLARE_TYPE(InstrumentValueArea)
Q_DECLARE_METATYPE(InstrumentValueArea::FontSize)
Q_DECLARE_METATYPE(InstrumentValueArea::Orientation)
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.12
import QtQuick.Layouts 1.2
import QtQuick.Controls 2.5
import QtQml 2.12
import QGroundControl.Templates 1.0 as T
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controllers 1.0
import QGroundControl.Palette 1.0
import QGroundControl.FlightMap 1.0
import QGroundControl 1.0
T.InstrumentValueArea {
id: _root
height: innerColumn.height
property bool settingsUnlocked: false
property real _margins: ScreenTools.defaultFontPixelWidth / 2
property int _colMax: 4
property real _columnButtonWidth: ScreenTools.minTouchPixels / 2
property real _columnButtonHeight: ScreenTools.minTouchPixels
property real _columnButtonSpacing: 2
property real _columnButtonsTotalHeight: (_columnButtonHeight * 2) + _columnButtonSpacing
Column {
id: innerColumn
width: parent.width
spacing: Math.round(ScreenTools.defaultFontPixelHeight / 2)
Repeater {
id: rowRepeater
model: rowValues