diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index aa51b6443f38cb2b35170e39b6d4bb746c5d5f27..e1ed7e03f2b7d15b14b550b43fbaa00d93a2734f 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -209,6 +209,8 @@
src/FlightMap/MapItems/CustomMapItems.qml
src/FlightMap/FlightMap.qml
src/FlightMap/Widgets/InstrumentSwipeView.qml
+ src/FlightMap/Widgets/InstrumentValue.qml
+ src/FlightMap/Widgets/InstrumentValueEditDialog.qml
src/FlightMap/Widgets/MapFitFunctions.qml
src/FlightMap/MapScale.qml
src/FlightMap/MapItems/MissionItemIndicator.qml
diff --git a/src/FlightMap/Widgets/InstrumentValue.cc b/src/FlightMap/Widgets/InstrumentValue.cc
index 4d32d88979cd6e3d931fe66d6f4cd1151623661e..b0324641890b07e656f094fcf2e27f73669fb3cf 100644
--- a/src/FlightMap/Widgets/InstrumentValue.cc
+++ b/src/FlightMap/Widgets/InstrumentValue.cc
@@ -16,12 +16,12 @@
const char* InstrumentValue::_versionKey = "version";
const char* InstrumentValue::_factGroupNameKey = "groupName";
-const char* InstrumentValue::_factNameKey = "factName";
-const char* InstrumentValue::_labelKey = "label";
+const char* InstrumentValue::_factNameKey = "factName";
+const char* InstrumentValue::_textKey = "text";
const char* InstrumentValue::_fontSizeKey = "fontSize";
const char* InstrumentValue::_showUnitsKey = "showUnits";
const char* InstrumentValue::_iconKey = "icon";
-const char* InstrumentValue::_iconPositionKey = "iconPosition";
+const char* InstrumentValue::_labelPositionKey = "labelPosition";
const char* InstrumentValue::_rangeTypeKey = "rangeType";
const char* InstrumentValue::_rangeValuesKey = "rangeValues";
const char* InstrumentValue::_rangeColorsKey = "rangeColors";
@@ -31,8 +31,8 @@ const char* InstrumentValue::_vehicleFactGroupName = "Vehicle";
QStringList InstrumentValue::_iconNames;
-// Important: The indices of these strings must match the InstrumentValue::IconPosition enumconst QStringList InstrumentValue::_iconPositionNames
-const QStringList InstrumentValue::_iconPositionNames = {
+// Important: The indices of these strings must match the InstrumentValue::LabelPosition enumconst QStringList InstrumentValue::_labelPositionNames
+const QStringList InstrumentValue::_labelPositionNames = {
QT_TRANSLATE_NOOP("InstrumentValue", "Above"),
QT_TRANSLATE_NOOP("InstrumentValue", "Left"),
};
@@ -182,13 +182,13 @@ void InstrumentValue::setFontSize(FontSize fontSize)
void InstrumentValue::saveToSettings(QSettings& settings) const
{
- settings.setValue(_versionKey, 1);
- settings.setValue(_labelKey, _label);
- settings.setValue(_fontSizeKey, _fontSize);
- settings.setValue(_showUnitsKey, _showUnits);
- settings.setValue(_iconKey, _icon);
- settings.setValue(_iconPositionKey, _iconPosition);
- settings.setValue(_rangeTypeKey, _rangeType);
+ settings.setValue(_versionKey, 1);
+ settings.setValue(_textKey, _text);
+ settings.setValue(_fontSizeKey, _fontSize);
+ settings.setValue(_showUnitsKey, _showUnits);
+ settings.setValue(_iconKey, _icon);
+ settings.setValue(_labelPositionKey, _labelPosition);
+ settings.setValue(_rangeTypeKey, _rangeType);
if (_rangeType != NoRangeInfo) {
settings.setValue(_rangeValuesKey, _rangeValues);
@@ -198,13 +198,13 @@ void InstrumentValue::saveToSettings(QSettings& settings) const
case NoRangeInfo:
break;
case ColorRange:
- settings.setValue(_rangeColorsKey, _rangeColors);
+ settings.setValue(_rangeColorsKey, _rangeColors);
break;
case OpacityRange:
- settings.setValue(_rangeOpacitiesKey, _rangeOpacities);
+ settings.setValue(_rangeOpacitiesKey, _rangeOpacities);
break;
case IconSelectRange:
- settings.setValue(_rangeIconsKey, _rangeIcons);
+ settings.setValue(_rangeIconsKey, _rangeIcons);
break;
}
@@ -220,11 +220,11 @@ void InstrumentValue::saveToSettings(QSettings& settings) const
void InstrumentValue::readFromSettings(const QSettings& settings)
{
_factGroupName = settings.value(_factGroupNameKey, QString()).toString();
- _label = settings.value(_labelKey, QString()).toString();
+ _text = settings.value(_textKey, QString()).toString();
_fontSize = settings.value(_fontSizeKey, DefaultFontSize).value();
_showUnits = settings.value(_showUnitsKey, true).toBool();
_icon = settings.value(_iconKey, QString()).toString();
- _iconPosition = settings.value(_iconPositionKey, IconLeft).value();
+ _labelPosition = settings.value(_labelPositionKey, LabelLeft).value();
_rangeType = settings.value(_rangeTypeKey, NoRangeInfo).value();
// Do this now, since the signal will cause _resetRangeInfo to be called trashing values
@@ -258,22 +258,22 @@ void InstrumentValue::readFromSettings(const QSettings& settings)
emit factChanged (_fact);
emit factGroupNameChanged (_factGroupName);
- emit labelChanged (_label);
+ emit textChanged (_text);
emit fontSizeChanged (_fontSize);
emit showUnitsChanged (_showUnits);
emit iconChanged (_icon);
- emit iconPositionChanged (_iconPosition);
+ emit labelPositionChanged (_labelPosition);
emit rangeValuesChanged (_rangeValues);
emit rangeColorsChanged (_rangeColors);
emit rangeOpacitiesChanged (_rangeOpacities);
emit rangeIconsChanged (_rangeIcons);
}
-void InstrumentValue::setLabel(const QString& label)
+void InstrumentValue::setText(const QString& text)
{
- if (label != _label) {
- _label = label;
- emit labelChanged(label);
+ if (text != _text) {
+ _text = text;
+ emit textChanged(text);
}
}
@@ -289,13 +289,13 @@ void InstrumentValue::clearFact(void)
{
_fact = nullptr;
_factGroupName.clear();
- _label.clear();
+ _text.clear();
_icon.clear();
_showUnits = true;
emit factChanged (_fact);
emit factGroupNameChanged (_factGroupName);
- emit labelChanged (_label);
+ emit textChanged (_text);
emit iconChanged (_icon);
emit showUnitsChanged (_showUnits);
}
@@ -308,11 +308,11 @@ void InstrumentValue::setIcon(const QString& icon)
}
}
-void InstrumentValue::setIconPosition(IconPosition iconPosition)
+void InstrumentValue::setLabelPosition(LabelPosition labelPosition)
{
- if (iconPosition != _iconPosition) {
- _iconPosition = iconPosition;
- emit iconPositionChanged(iconPosition);
+ if (labelPosition != _labelPosition) {
+ _labelPosition = labelPosition;
+ emit labelPositionChanged(labelPosition);
}
}
diff --git a/src/FlightMap/Widgets/InstrumentValue.h b/src/FlightMap/Widgets/InstrumentValue.h
index e389fc2b570d566b392f70cd12866f559fe60643..2c40dd3de146a33ff5c3a72aa305964fc1c3fbb6 100644
--- a/src/FlightMap/Widgets/InstrumentValue.h
+++ b/src/FlightMap/Widgets/InstrumentValue.h
@@ -28,11 +28,11 @@ public:
};
Q_ENUMS(FontSize)
- enum IconPosition {
- IconAbove = 0,
- IconLeft,
+ enum LabelPosition {
+ LabelAbove = 0,
+ LabelLeft,
};
- Q_ENUMS(IconPosition)
+ Q_ENUMS(LabelPosition)
enum RangeType {
NoRangeInfo = 0,
@@ -44,28 +44,28 @@ public:
InstrumentValue(Vehicle* activeVehicle, FontSize fontSize, QmlObjectListModel* rowModel);
- Q_PROPERTY(QStringList factGroupNames MEMBER _factGroupNames NOTIFY factGroupNamesChanged)
- Q_PROPERTY(QStringList factValueNames MEMBER _factValueNames NOTIFY factValueNamesChanged)
- Q_PROPERTY(QString factGroupName MEMBER _factGroupName NOTIFY factGroupNameChanged)
- Q_PROPERTY(QString factName MEMBER _factName NOTIFY factNameChanged)
- Q_PROPERTY(Fact* fact READ fact NOTIFY factChanged)
- Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
- Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged) ///< If !isEmpty icon will be show instead of label
- Q_PROPERTY(IconPosition iconPosition READ iconPosition WRITE setIconPosition NOTIFY iconPositionChanged)
- Q_PROPERTY(QStringList iconPositionNames MEMBER _iconPositionNames CONSTANT)
- Q_PROPERTY(QStringList iconNames MEMBER _iconNames CONSTANT)
- Q_PROPERTY(FontSize fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
- Q_PROPERTY(QStringList fontSizeNames MEMBER _fontSizeNames CONSTANT)
- Q_PROPERTY(bool showUnits READ showUnits WRITE setShowUnits NOTIFY showUnitsChanged)
- Q_PROPERTY(QStringList rangeTypeNames MEMBER _rangeTypeNames CONSTANT)
- Q_PROPERTY(RangeType rangeType READ rangeType WRITE setRangeType NOTIFY rangeTypeChanged)
- Q_PROPERTY(QVariantList rangeValues READ rangeValues WRITE setRangeValues NOTIFY rangeValuesChanged)
- Q_PROPERTY(QVariantList rangeColors READ rangeColors WRITE setRangeColors NOTIFY rangeColorsChanged)
- Q_PROPERTY(QVariantList rangeIcons READ rangeIcons WRITE setRangeIcons NOTIFY rangeIconsChanged)
- Q_PROPERTY(QVariantList rangeOpacities READ rangeOpacities WRITE setRangeOpacities NOTIFY rangeOpacitiesChanged)
- Q_PROPERTY(QColor currentColor MEMBER _currentColor NOTIFY currentColorChanged)
- Q_PROPERTY(double currentOpacity MEMBER _currentOpacity NOTIFY currentOpacityChanged)
- Q_PROPERTY(QString currentIcon MEMBER _currentIcon NOTIFY currentIconChanged)
+ Q_PROPERTY(QStringList factGroupNames MEMBER _factGroupNames NOTIFY factGroupNamesChanged)
+ Q_PROPERTY(QStringList factValueNames MEMBER _factValueNames NOTIFY factValueNamesChanged)
+ Q_PROPERTY(QString factGroupName MEMBER _factGroupName NOTIFY factGroupNameChanged)
+ Q_PROPERTY(QString factName MEMBER _factName NOTIFY factNameChanged)
+ Q_PROPERTY(Fact* fact READ fact NOTIFY factChanged)
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged) ///< If !isEmpty icon will be show instead of label
+ Q_PROPERTY(LabelPosition labelPosition READ labelPosition WRITE setLabelPosition NOTIFY labelPositionChanged)
+ Q_PROPERTY(QStringList labelPositionNames MEMBER _labelPositionNames CONSTANT)
+ Q_PROPERTY(QStringList iconNames MEMBER _iconNames CONSTANT)
+ Q_PROPERTY(FontSize fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
+ Q_PROPERTY(QStringList fontSizeNames MEMBER _fontSizeNames CONSTANT)
+ Q_PROPERTY(bool showUnits READ showUnits WRITE setShowUnits NOTIFY showUnitsChanged)
+ Q_PROPERTY(QStringList rangeTypeNames MEMBER _rangeTypeNames CONSTANT)
+ Q_PROPERTY(RangeType rangeType READ rangeType WRITE setRangeType NOTIFY rangeTypeChanged)
+ Q_PROPERTY(QVariantList rangeValues READ rangeValues WRITE setRangeValues NOTIFY rangeValuesChanged)
+ Q_PROPERTY(QVariantList rangeColors READ rangeColors WRITE setRangeColors NOTIFY rangeColorsChanged)
+ Q_PROPERTY(QVariantList rangeIcons READ rangeIcons WRITE setRangeIcons NOTIFY rangeIconsChanged)
+ Q_PROPERTY(QVariantList rangeOpacities READ rangeOpacities WRITE setRangeOpacities NOTIFY rangeOpacitiesChanged)
+ Q_PROPERTY(QColor currentColor MEMBER _currentColor NOTIFY currentColorChanged)
+ Q_PROPERTY(double currentOpacity MEMBER _currentOpacity NOTIFY currentOpacityChanged)
+ Q_PROPERTY(QString currentIcon MEMBER _currentIcon NOTIFY currentIconChanged)
Q_INVOKABLE void setFact (const QString& factGroupName, const QString& factName);
Q_INVOKABLE void clearFact (void);
@@ -76,20 +76,20 @@ public:
Fact* fact (void) { return _fact; }
FontSize fontSize (void) const { return _fontSize; }
- QString label (void) const { return _label; }
+ QString text (void) const { return _text; }
bool showUnits (void) const { return _showUnits; }
QString icon (void) const { return _icon; }
- IconPosition iconPosition (void) const { return _iconPosition; }
+ LabelPosition labelPosition (void) const { return _labelPosition; }
RangeType rangeType (void) const { return _rangeType; }
QVariantList rangeValues (void) const { return _rangeValues; }
QVariantList rangeColors (void) const { return _rangeColors; }
QVariantList rangeIcons (void) const { return _rangeIcons; }
QVariantList rangeOpacities (void) const { return _rangeOpacities; }
void setFontSize (FontSize fontSize);
- void setLabel (const QString& label);
+ void setText (const QString& text);
void setShowUnits (bool showUnits);
void setIcon (const QString& icon);
- void setIconPosition (IconPosition iconPosition);
+ void setLabelPosition (LabelPosition labelPosition);
void setRangeType (RangeType rangeType);
void setRangeValues (const QVariantList& rangeValues);
void setRangeColors (const QVariantList& rangeColors);
@@ -103,11 +103,11 @@ signals:
void factChanged (Fact* fact);
void factNameChanged (const QString& factName);
void factGroupNameChanged (const QString& factGroup);
- void labelChanged (QString label);
+ void textChanged (QString text);
void fontSizeChanged (FontSize fontSize);
void showUnitsChanged (bool showUnits);
void iconChanged (const QString& icon);
- void iconPositionChanged (IconPosition iconPosition);
+ void labelPositionChanged (LabelPosition labelPosition);
void factGroupNamesChanged (const QStringList& factGroupNames);
void factValueNamesChanged (const QStringList& factValueNames);
void rangeTypeChanged (RangeType rangeType);
@@ -135,11 +135,11 @@ private:
Fact* _fact = nullptr;
QString _factName;
QString _factGroupName;
- QString _label;
+ QString _text;
bool _showUnits = true;
FontSize _fontSize = DefaultFontSize;
QString _icon;
- IconPosition _iconPosition = IconLeft;
+ LabelPosition _labelPosition = LabelLeft;
QStringList _factGroupNames;
QStringList _factValueNames;
QColor _currentColor;
@@ -162,18 +162,18 @@ private:
// These are user facing string for the various enums.
static const QStringList _rangeTypeNames;
- static const QStringList _iconPositionNames;
+ static const QStringList _labelPositionNames;
static QStringList _iconNames;
static const QStringList _fontSizeNames;
static const char* _versionKey;
static const char* _factGroupNameKey;
static const char* _factNameKey;
- static const char* _labelKey;
+ static const char* _textKey;
static const char* _fontSizeKey;
static const char* _showUnitsKey;
static const char* _iconKey;
- static const char* _iconPositionKey;
+ static const char* _labelPositionKey;
static const char* _rangeTypeKey;
static const char* _rangeValuesKey;
static const char* _rangeColorsKey;
@@ -183,5 +183,5 @@ private:
};
Q_DECLARE_METATYPE(InstrumentValue::FontSize)
-Q_DECLARE_METATYPE(InstrumentValue::IconPosition)
+Q_DECLARE_METATYPE(InstrumentValue::LabelPosition)
Q_DECLARE_METATYPE(InstrumentValue::RangeType)
diff --git a/src/FlightMap/Widgets/InstrumentValue.qml b/src/FlightMap/Widgets/InstrumentValue.qml
new file mode 100644
index 0000000000000000000000000000000000000000..348e4a374818c896822704edcd545be9a5297aca
--- /dev/null
+++ b/src/FlightMap/Widgets/InstrumentValue.qml
@@ -0,0 +1,145 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * 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 QGroundControl.Controls 1.0
+import QGroundControl.ScreenTools 1.0
+import QGroundControl.Palette 1.0
+
+Item {
+ id: root
+ height: value.y + value.height
+
+ property var instrumentValue: null
+ property bool recalcOk: false
+
+ property var _rgFontSizes: [ ScreenTools.defaultFontPointSize, ScreenTools.smallFontPointSize, ScreenTools.mediumFontPointSize, ScreenTools.largeFontPointSize ]
+ property var _rgFontSizeRatios: [ 1, ScreenTools.smallFontPointRatio, ScreenTools.mediumFontPointRatio, ScreenTools.largeFontPointRatio ]
+ 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 _blankEntryHeight: ScreenTools.defaultFontPixelHeight * 2
+
+ // 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) {
+ valueIcon.x = (width - valueIcon.width) / 2
+ valueIcon.y = 0
+ value.x = (width - value.width) / 2
+ value.y = valueIcon.height + smallSpacing
+ } else {
+ var iconPlusValueWidth = valueIcon.width + value.width + ScreenTools.defaultFontPixelWidth
+ valueIcon.x = (width - iconPlusValueWidth) / 2
+ valueIcon.y = (value.height - valueIcon.height) / 2
+ value.x = valueIcon.x + valueIcon.width + (ScreenTools.defaultFontPixelWidth / 2)
+ value.y = 0
+ }
+ 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
+ } else {
+ value.y = 0
+ }
+ value.x = (width - value.width) / 2
+ valueIcon.x = valueIcon.y = 0
+ }
+ }
+
+ onRecalcOkChanged: recalcPositions()
+ onWidthChanged: recalcPositions()
+
+ Connections {
+ target: instrumentValue
+ onIconChanged: recalcPositions()
+ onLabelPositionChanged: recalcPositions()
+ }
+
+ QGCColoredImage {
+ id: valueIcon
+ height: _rgFontSizeTightHeights[instrumentValue.fontSize]
+ 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
+ onWidthChanged: root.recalcPositions()
+ onHeightChanged: root.recalcPositions()
+
+ property string icon
+ readonly property string iconPrefix: "/InstrumentValueIcons/"
+
+ function updateIcon() {
+ if (instrumentValue.rangeType == InstrumentValue.IconSelectRange) {
+ icon = iconPrefix + instrumentValue.currentIcon
+ } else if (instrumentValue.icon) {
+ icon = iconPrefix + instrumentValue.icon
+ } else {
+ icon = ""
+ }
+ }
+
+ Connections {
+ target: instrumentValue
+ onRangeTypeChanged: valueIcon.updateIcon()
+ onCurrentIconChanged: valueIcon.updateIcon()
+ onIconChanged: valueIcon.updateIcon()
+ }
+ Component.onCompleted: updateIcon();
+ }
+
+ QGCLabel {
+ id: blank
+ anchors.horizontalCenter: parent.horizontalCenter
+ height: _columnButtonsTotalHeight
+ font.pointSize: ScreenTools.smallFontPointSize
+ text: _settingsUnlocked ? qsTr("BLANK") : ""
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ visible: !instrumentValue.fact
+ onWidthChanged: root.recalcPositions()
+ onHeightChanged: root.recalcPositions()
+ }
+
+ QGCLabel {
+ id: label
+ height: _rgFontSizeTightHeights[InstrumentValue.SmallFontSize]
+ font.pointSize: ScreenTools.smallFontPointSize
+ text: instrumentValue.text.toUpperCase()
+ verticalAlignment: Text.AlignVCenter
+ visible: instrumentValue.fact && instrumentValue.text && !instrumentValue.icon
+ onWidthChanged: root.recalcPositions()
+ onHeightChanged: root.recalcPositions()
+ }
+
+ QGCLabel {
+ id: value
+ font.pointSize: _rgFontSizes[instrumentValue.fontSize]
+ text: visible ? (instrumentValue.fact.enumOrValueString + (instrumentValue.showUnits ? instrumentValue.fact.units : "")) : ""
+ verticalAlignment: Text.AlignVCenter
+ visible: instrumentValue.fact
+ onWidthChanged: root.recalcPositions()
+ onHeightChanged: root.recalcPositions()
+ }
+}
diff --git a/src/FlightMap/Widgets/InstrumentValueEditDialog.qml b/src/FlightMap/Widgets/InstrumentValueEditDialog.qml
new file mode 100644
index 0000000000000000000000000000000000000000..1d6f119101785318198405a1b7a8e2331cf5d358
--- /dev/null
+++ b/src/FlightMap/Widgets/InstrumentValueEditDialog.qml
@@ -0,0 +1,548 @@
+/****************************************************************************
+ *
+ * (c) 2009-2020 QGROUNDCONTROL PROJECT
+ *
+ * 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.Dialogs 1.3
+import QtQuick.Layouts 1.2
+import QtQuick.Controls 2.5
+
+import QGroundControl.Controls 1.0
+import QGroundControl.ScreenTools 1.0
+import QGroundControl.FactSystem 1.0
+import QGroundControl.FactControls 1.0
+import QGroundControl.Controllers 1.0
+import QGroundControl.Palette 1.0
+
+QGCPopupDialog {
+ id: root
+ title: qsTr("Value Display")
+ buttons: StandardButton.Close
+
+ property var instrumentValue: dialogProperties.instrumentValue
+
+ GridLayout {
+ rowSpacing: _margins
+ columnSpacing: _margins
+ columns: 3
+
+ QGCCheckBox {
+ id: valueCheckBox
+ text: qsTr("Value")
+ checked: instrumentValue.fact
+ onClicked: {
+ if (checked) {
+ instrumentValue.setFact(instrumentValue.factGroupNames[0], instrumentValue.factValueNames[0])
+ } else {
+ instrumentValue.clearFact()
+ }
+ }
+ }
+
+ QGCComboBox {
+ model: instrumentValue.factGroupNames
+ sizeToContents: true
+ enabled: valueCheckBox.enabled
+ onModelChanged: currentIndex = find(instrumentValue.factGroupName)
+ Component.onCompleted: currentIndex = find(instrumentValue.factGroupName)
+ onActivated: {
+ instrumentValue.setFact(currentText, "")
+ instrumentValue.icon = ""
+ instrumentValue.text = instrumentValue.fact.shortDescription
+ }
+ }
+
+ QGCComboBox {
+ model: instrumentValue.factValueNames
+ sizeToContents: true
+ enabled: valueCheckBox.enabled
+ onModelChanged: currentIndex = instrumentValue.fact ? find(instrumentValue.factName) : -1
+ Component.onCompleted: currentIndex = instrumentValue.fact ? find(instrumentValue.factName) : -1
+ onActivated: {
+ instrumentValue.setFact(instrumentValue.factGroupName, currentText)
+ instrumentValue.icon = ""
+ instrumentValue.text = instrumentValue.fact.shortDescription
+ }
+ }
+
+ QGCRadioButton {
+ id: iconCheckBox
+ text: qsTr("Icon")
+ Component.onCompleted: checked = instrumentValue.icon != ""
+ onClicked: {
+ instrumentValue.text = ""
+ instrumentValue.icon = instrumentValue.iconNames[0]
+ var updateFunction = function(icon){ instrumentValue.icon = icon }
+ mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValue.iconNames, icon: instrumentValue.icon, updateIconFunction: updateFunction })
+ }
+ }
+
+ QGCColoredImage {
+ Layout.alignment: Qt.AlignHCenter
+ height: labelPositionCombo.height
+ width: height
+ source: "/InstrumentValueIcons/" + (instrumentValue.icon ? instrumentValue.icon : instrumentValue.iconNames[0])
+ sourceSize.height: height
+ fillMode: Image.PreserveAspectFit
+ mipmap: true
+ smooth: true
+ color: enabled ? qgcPal.text : qgcPalDisabled.text
+ enabled: iconCheckBox.checked
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ var updateFunction = function(icon){ instrumentValue.icon = icon }
+ mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValue.iconNames, icon: instrumentValue.icon, updateIconFunction: updateFunction })
+ }
+ }
+ }
+
+ QGCComboBox {
+ id: labelPositionCombo
+ model: instrumentValue.labelPositionNames
+ currentIndex: instrumentValue.labelPosition
+ sizeToContents: true
+ onActivated: instrumentValue.lanelPosition = index
+ enabled: iconCheckBox.checked
+ }
+
+ QGCRadioButton {
+ id: labelCheckBox
+ text: qsTr("Text")
+ Component.onCompleted: checked = instrumentValue.text != ""
+ onClicked: {
+ instrumentValue.icon = ""
+ instrumentValue.text = instrumentValue.fact ? instrumentValue.fact.shortDescription : qsTr("Label")
+ }
+ }
+
+ QGCTextField {
+ id: labelTextField
+ Layout.fillWidth: true
+ Layout.columnSpan: 2
+ text: instrumentValue.text
+ enabled: labelCheckBox.checked
+ }
+
+ QGCLabel { text: qsTr("Size") }
+
+ QGCComboBox {
+ id: fontSizeCombo
+ model: instrumentValue.fontSizeNames
+ currentIndex: instrumentValue.fontSize
+ sizeToContents: true
+ onActivated: instrumentValue.fontSize = index
+ }
+
+ QGCCheckBox {
+ text: qsTr("Show Units")
+ checked: instrumentValue.showUnits
+ onClicked: instrumentValue.showUnits = checked
+ }
+
+ QGCLabel { text: qsTr("Range") }
+
+ QGCComboBox {
+ id: rangeTypeCombo
+ Layout.columnSpan: 2
+ model: instrumentValue.rangeTypeNames
+ currentIndex: instrumentValue.rangeType
+ sizeToContents: true
+ onActivated: instrumentValue.rangeType = index
+ }
+
+ Loader {
+ id: rangeLoader
+ Layout.columnSpan: 3
+ Layout.fillWidth: true
+ Layout.preferredWidth: item ? item.width : 0
+ Layout.preferredHeight: item ? item.height : 0
+
+ property var instrumentValue: root.instrumentValue
+
+ function updateSourceComponent() {
+ switch (instrumentValue.rangeType) {
+ case InstrumentValue.NoRangeInfo:
+ sourceComponent = undefined
+ break
+ case InstrumentValue.ColorRange:
+ sourceComponent = colorRangeDialog
+ break
+ case InstrumentValue.OpacityRange:
+ sourceComponent = opacityRangeDialog
+ break
+ case InstrumentValue.IconSelectRange:
+ sourceComponent = iconRangeDialog
+ break
+ }
+ }
+
+ Component.onCompleted: updateSourceComponent()
+
+ Connections {
+ target: instrumentValue
+ onRangeTypeChanged: rangeLoader.updateSourceComponent()
+ }
+
+ }
+ }
+
+ Component {
+ id: colorRangeDialog
+
+ Item {
+ width: childrenRect.width
+ height: childrenRect.height
+
+ function updateRangeValue(index, text) {
+ var newValues = instrumentValue.rangeValues
+ newValues[index] = parseFloat(text)
+ instrumentValue.rangeValues = newValues
+ }
+
+ function updateColorValue(index, color) {
+ var newColors = instrumentValue.rangeColors
+ newColors[index] = color
+ instrumentValue.rangeColors = newColors
+ }
+
+ ColorDialog {
+ id: colorPickerDialog
+ modality: Qt.ApplicationModal
+ currentColor: instrumentValue.rangeColors.length ? instrumentValue.rangeColors[colorIndex] : "white"
+ onAccepted: updateColorValue(colorIndex, color)
+
+ property int colorIndex: 0
+ }
+
+ Column {
+ id: mainColumn
+ spacing: ScreenTools.defaultFontPixelHeight / 2
+
+ QGCLabel {
+ width: rowLayout.width
+ text: qsTr("Specify the color you want to apply based on value ranges. The color will be applied to the icon if available, otherwise to the value itself.")
+ wrapMode: Text.WordWrap
+ }
+
+ Row {
+ id: rowLayout
+ spacing: _margins
+
+ Column {
+ anchors.verticalCenter: parent.verticalCenter
+ spacing: _margins
+
+ Repeater {
+ model: instrumentValue.rangeValues.length
+
+ QGCButton {
+ width: ScreenTools.implicitTextFieldHeight
+ height: width
+ text: qsTr("-")
+ onClicked: instrumentValue.removeRangeValue(index)
+ }
+ }
+ }
+
+ Column {
+ anchors.verticalCenter: parent.verticalCenter
+ spacing: _margins
+
+ Repeater {
+ model: instrumentValue.rangeValues.length
+
+ QGCTextField {
+ text: instrumentValue.rangeValues[index]
+ onEditingFinished: updateRangeValue(index, text)
+ }
+ }
+ }
+
+ Column {
+ spacing: _margins
+ Repeater {
+ model: instrumentValue.rangeColors
+
+ QGCCheckBox {
+ height: ScreenTools.implicitTextFieldHeight
+ checked: instrumentValue.isValidColor(instrumentValue.rangeColors[index])
+ onClicked: updateColorValue(index, checked ? "green" : instrumentValue.invalidColor())
+ }
+ }
+ }
+
+ Column {
+ spacing: _margins
+ Repeater {
+ model: instrumentValue.rangeColors
+
+ Rectangle {
+ width: ScreenTools.implicitTextFieldHeight
+ height: width
+ border.color: qgcPal.text
+ color: instrumentValue.isValidColor(modelData) ? modelData : qgcPal.text
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ colorPickerDialog.colorIndex = index
+ colorPickerDialog.open()
+ }
+ }
+ }
+ }
+ }
+ }
+
+ QGCButton {
+ text: qsTr("Add Row")
+ onClicked: instrumentValue.addRangeValue()
+ }
+ }
+ }
+ }
+
+ Component {
+ id: iconRangeDialog
+
+ Item {
+ width: childrenRect.width
+ height: childrenRect.height
+
+ function updateRangeValue(index, text) {
+ var newValues = instrumentValue.rangeValues
+ newValues[index] = parseFloat(text)
+ instrumentValue.rangeValues = newValues
+ }
+
+ function updateIconValue(index, icon) {
+ var newIcons = instrumentValue.rangeIcons
+ newIcons[index] = icon
+ instrumentValue.rangeIcons = newIcons
+ }
+
+ Column {
+ id: mainColumn
+ spacing: ScreenTools.defaultFontPixelHeight / 2
+
+ QGCLabel {
+ width: rowLayout.width
+ text: qsTr("Specify the icon you want to display based on value ranges.")
+ wrapMode: Text.WordWrap
+ }
+
+ Row {
+ id: rowLayout
+ spacing: _margins
+
+ Column {
+ anchors.verticalCenter: parent.verticalCenter
+ spacing: _margins
+
+ Repeater {
+ model: instrumentValue.rangeValues.length
+
+ QGCButton {
+ width: ScreenTools.implicitTextFieldHeight
+ height: width
+ text: qsTr("-")
+ onClicked: instrumentValue.removeRangeValue(index)
+ }
+ }
+ }
+
+ Column {
+ anchors.verticalCenter: parent.verticalCenter
+ spacing: _margins
+
+ Repeater {
+ model: instrumentValue.rangeValues.length
+
+ QGCTextField {
+ text: instrumentValue.rangeValues[index]
+ onEditingFinished: updateRangeValue(index, text)
+ }
+ }
+ }
+
+ Column {
+ spacing: _margins
+
+ Repeater {
+ model: instrumentValue.rangeIcons
+
+ QGCColoredImage {
+ height: ScreenTools.implicitTextFieldHeight
+ width: height
+ source: "/InstrumentValueIcons/" + modelData
+ sourceSize.height: height
+ fillMode: Image.PreserveAspectFit
+ mipmap: true
+ smooth: true
+ color: qgcPal.text
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ var updateFunction = function(icon){ updateIconValue(index, icon) }
+ mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValue.iconNames, icon: modelData, updateIconFunction: updateFunction })
+ }
+ }
+ }
+ }
+ }
+ }
+
+ QGCButton {
+ text: qsTr("Add Row")
+ onClicked: instrumentValue.addRangeValue()
+ }
+ }
+ }
+ }
+
+ Component {
+ id: opacityRangeDialog
+
+ Item {
+ width: childrenRect.width
+ height: childrenRect.height
+
+ function updateRangeValue(index, text) {
+ var newValues = instrumentValue.rangeValues
+ newValues[index] = parseFloat(text)
+ instrumentValue.rangeValues = newValues
+ }
+
+ function updateOpacityValue(index, opacity) {
+ var newOpacities = instrumentValue.rangeOpacities
+ newOpacities[index] = opacity
+ instrumentValue.rangeOpacities = newOpacities
+ }
+
+ Column {
+ id: mainColumn
+ spacing: ScreenTools.defaultFontPixelHeight / 2
+
+ QGCLabel {
+ width: rowLayout.width
+ text: qsTr("Specify the icon opacity you want based on value ranges.")
+ wrapMode: Text.WordWrap
+ }
+
+ Row {
+ id: rowLayout
+ spacing: _margins
+
+ Column {
+ anchors.verticalCenter: parent.verticalCenter
+ spacing: _margins
+
+ Repeater {
+ model: instrumentValue.rangeValues.length
+
+ QGCButton {
+ width: ScreenTools.implicitTextFieldHeight
+ height: width
+ text: qsTr("-")
+ onClicked: instrumentValue.removeRangeValue(index)
+ }
+ }
+ }
+
+ Column {
+ anchors.verticalCenter: parent.verticalCenter
+ spacing: _margins
+
+ Repeater {
+ model: instrumentValue.rangeValues
+
+ QGCTextField {
+ text: modelData
+ onEditingFinished: updateRangeValue(index, text)
+ }
+ }
+ }
+
+ Column {
+ spacing: _margins
+
+ Repeater {
+ model: instrumentValue.rangeOpacities
+
+ QGCTextField {
+ text: modelData
+ onEditingFinished: updateOpacityValue(index, text)
+ }
+ }
+ }
+ }
+
+ QGCButton {
+ text: qsTr("Add Row")
+ onClicked: instrumentValue.addRangeValue()
+ }
+ }
+ }
+ }
+
+ Component {
+ id: iconPickerDialog
+
+ QGCPopupDialog {
+ property var iconNames: dialogProperties.iconNames
+ property string icon: dialogProperties.icon
+ property var updateIconFunction: dialogProperties.updateIconFunction
+
+ title: qsTr("Select Icon")
+ buttons: StandardButton.Close
+
+ GridLayout {
+ columns: 10
+ columnSpacing: 0
+ rowSpacing: 0
+
+ Repeater {
+ model: iconNames
+
+ Rectangle {
+ height: ScreenTools.minTouchPixels
+ width: height
+ color: currentSelection ? qgcPal.text : qgcPal.window
+
+ property bool currentSelection: icon == modelData
+
+ QGCColoredImage {
+ anchors.centerIn: parent
+ height: parent.height * 0.75
+ width: height
+ source: "/InstrumentValueIcons/" + modelData
+ sourceSize.height: height
+ fillMode: Image.PreserveAspectFit
+ mipmap: true
+ smooth: true
+ color: currentSelection ? qgcPal.window : qgcPal.text
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ icon = modelData
+ updateIconFunction(modelData)
+ hideDialog()
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
diff --git a/src/FlightMap/Widgets/ValuePageWidget.qml b/src/FlightMap/Widgets/ValuePageWidget.qml
index 2da67e98fb31df3eda34f72299f560f281fd7781..31fd20cc6bf917f8578d3ad78d88b7cede5ed470 100644
--- a/src/FlightMap/Widgets/ValuePageWidget.qml
+++ b/src/FlightMap/Widgets/ValuePageWidget.qml
@@ -19,6 +19,7 @@ import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Controllers 1.0
import QGroundControl.Palette 1.0
+import QGroundControl.FlightMap 1.0
import QGroundControl 1.0
/// Value page for InstrumentPanel PageView
@@ -34,13 +35,7 @@ Column {
property real _margins: ScreenTools.defaultFontPixelWidth / 2
property int _colMax: 4
property bool _settingsUnlocked: false
- property var instrumentValue: null
- property var _rgFontSizes: [ ScreenTools.defaultFontPointSize, ScreenTools.smallFontPointSize, ScreenTools.mediumFontPointSize, ScreenTools.largeFontPointSize ]
- property var _rgFontSizeRatios: [ 1, ScreenTools.smallFontPointRatio, ScreenTools.mediumFontPointRatio, ScreenTools.largeFontPointRatio ]
- 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 _blankEntryHeight: ScreenTools.defaultFontPixelHeight * 2
+ property var instrumentValue: null
property real _columnButtonWidth: ScreenTools.minTouchPixels / 2
property real _columnButtonHeight: ScreenTools.minTouchPixels
property real _columnButtonSpacing: 2
@@ -110,128 +105,12 @@ Column {
Component.onCompleted: componentCompleted = true
onItemAdded: valueItemMouseAreaComponent.createObject(item, { "instrumentValue": object.get(index), "rowIndex": index })
- Item {
+ InstrumentValue {
id: columnItem
anchors.verticalCenter: parent.verticalCenter
width: columnRepeater.columnWidth
- height: value.y + value.height
-
- property real columnWidth: columnRepeater.columnWidth
- property bool repeaterComponentCompleted: columnRepeater.componentCompleted
-
- // 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 (!repeaterComponentCompleted) {
- return
- }
- var smallSpacing = 2
- if (object.icon) {
- if (object.iconPosition === InstrumentValue.IconAbove) {
- valueIcon.x = (width - valueIcon.width) / 2
- valueIcon.y = 0
- value.x = (width - value.width) / 2
- value.y = valueIcon.height + smallSpacing
- } else {
- var iconPlusValueWidth = valueIcon.width + value.width + ScreenTools.defaultFontPixelWidth
- valueIcon.x = (width - iconPlusValueWidth) / 2
- valueIcon.y = (value.height - valueIcon.height) / 2
- value.x = valueIcon.x + valueIcon.width + (ScreenTools.defaultFontPixelWidth / 2)
- value.y = 0
- }
- label.x = label.y = 0
- } else {
- // label above value
- if (object.label) {
- label.x = (width - label.width) / 2
- label.y = 0
- value.y = label.height + smallSpacing
- } else {
- value.y = 0
- }
- value.x = (width - value.width) / 2
- valueIcon.x = valueIcon.y = 0
- }
- }
-
- onRepeaterComponentCompletedChanged: recalcPositions()
- onColumnWidthChanged: recalcPositions()
-
- Connections {
- target: object
- onIconChanged: recalcPositions()
- onIconPositionChanged: recalcPositions()
- }
-
- QGCColoredImage {
- id: valueIcon
- height: _rgFontSizeTightHeights[object.fontSize]
- width: height
- source: icon
- sourceSize.height: height
- fillMode: Image.PreserveAspectFit
- mipmap: true
- smooth: true
- color: object.isValidColor(object.currentColor) ? object.currentColor : qgcPal.text
- opacity: object.currentOpacity
- visible: object.icon
- onWidthChanged: columnItem.recalcPositions()
- onHeightChanged: columnItem.recalcPositions()
-
- property string icon
- readonly property string iconPrefix: "/InstrumentValueIcons/"
-
- function updateIcon() {
- if (object.rangeType == InstrumentValue.IconSelectRange) {
- icon = iconPrefix + object.currentIcon
- } else if (object.icon) {
- icon = iconPrefix + object.icon
- } else {
- icon = ""
- }
- }
-
- Connections {
- target: object
- onRangeTypeChanged: valueIcon.updateIcon()
- onCurrentIconChanged: valueIcon.updateIcon()
- onIconChanged: valueIcon.updateIcon()
- }
- Component.onCompleted: updateIcon();
- }
-
- QGCLabel {
- id: blank
- anchors.horizontalCenter: parent.horizontalCenter
- height: _columnButtonsTotalHeight
- font.pointSize: ScreenTools.smallFontPointSize
- text: _settingsUnlocked ? qsTr("BLANK") : ""
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- visible: !object.fact
- onWidthChanged: columnItem.recalcPositions()
- onHeightChanged: columnItem.recalcPositions()
- }
-
- QGCLabel {
- id: label
- height: _rgFontSizeTightHeights[InstrumentValue.SmallFontSize]
- font.pointSize: ScreenTools.smallFontPointSize
- text: object.label.toUpperCase()
- verticalAlignment: Text.AlignVCenter
- visible: object.fact && object.label && !object.icon
- onWidthChanged: columnItem.recalcPositions()
- onHeightChanged: columnItem.recalcPositions()
- }
-
- QGCLabel {
- id: value
- font.pointSize: _rgFontSizes[object.fontSize]
- text: visible ? (object.fact.enumOrValueString + (object.showUnits ? object.fact.units : "")) : ""
- verticalAlignment: Text.AlignVCenter
- visible: object.fact
- onWidthChanged: columnItem.recalcPositions()
- onHeightChanged: columnItem.recalcPositions()
- }
+ recalcOk: columnRepeater.componentCompleted
+ instrumentValue: object
}
} // Repeater - columns
@@ -295,531 +174,6 @@ Column {
Component {
id: valueDialogComponent
- QGCPopupDialog {
- id: valueDisplayDialog
- title: qsTr("Value Display")
- buttons: StandardButton.Close
-
- property var instrumentValue: dialogProperties.instrumentValue
-
- GridLayout {
- rowSpacing: _margins
- columnSpacing: _margins
- columns: 3
-
- QGCCheckBox {
- id: valueCheckBox
- text: qsTr("Value")
- checked: instrumentValue.fact
- onClicked: {
- if (checked) {
- instrumentValue.setFact(instrumentValue.factGroupNames[0], instrumentValue.factValueNames[0])
- } else {
- instrumentValue.clearFact()
- }
- }
- }
-
- QGCComboBox {
- model: instrumentValue.factGroupNames
- sizeToContents: true
- enabled: valueCheckBox.enabled
- onModelChanged: currentIndex = find(instrumentValue.factGroupName)
- Component.onCompleted: currentIndex = find(instrumentValue.factGroupName)
- onActivated: {
- instrumentValue.setFact(currentText, "")
- instrumentValue.icon = ""
- instrumentValue.label = instrumentValue.fact.shortDescription
- }
- }
-
- QGCComboBox {
- model: instrumentValue.factValueNames
- sizeToContents: true
- enabled: valueCheckBox.enabled
- onModelChanged: currentIndex = instrumentValue.fact ? find(instrumentValue.factName) : -1
- Component.onCompleted: currentIndex = instrumentValue.fact ? find(instrumentValue.factName) : -1
- onActivated: {
- instrumentValue.setFact(instrumentValue.factGroupName, currentText)
- instrumentValue.icon = ""
- instrumentValue.label = instrumentValue.fact.shortDescription
- }
- }
-
- QGCRadioButton {
- id: iconCheckBox
- text: qsTr("Icon")
- Component.onCompleted: checked = instrumentValue.icon != ""
- onClicked: {
- instrumentValue.label = ""
- instrumentValue.icon = instrumentValue.iconNames[0]
- var updateFunction = function(icon){ instrumentValue.icon = icon }
- mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValue.iconNames, icon: instrumentValue.icon, updateIconFunction: updateFunction })
- }
- }
-
- QGCColoredImage {
- Layout.alignment: Qt.AlignHCenter
- height: iconPositionCombo.height
- width: height
- source: "/InstrumentValueIcons/" + (instrumentValue.icon ? instrumentValue.icon : instrumentValue.iconNames[0])
- sourceSize.height: height
- fillMode: Image.PreserveAspectFit
- mipmap: true
- smooth: true
- color: enabled ? qgcPal.text : qgcPalDisabled.text
- enabled: iconCheckBox.checked
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- var updateFunction = function(icon){ instrumentValue.icon = icon }
- mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValue.iconNames, icon: instrumentValue.icon, updateIconFunction: updateFunction })
- }
- }
- }
-
- QGCComboBox {
- id: iconPositionCombo
- model: instrumentValue.iconPositionNames
- currentIndex: instrumentValue.iconPosition
- sizeToContents: true
- onActivated: instrumentValue.iconPosition = index
- enabled: iconCheckBox.checked
- }
-
- QGCRadioButton {
- id: labelCheckBox
- text: qsTr("Label")
- Component.onCompleted: checked = instrumentValue.label != ""
- onClicked: {
- instrumentValue.icon = ""
- instrumentValue.label = instrumentValue.fact ? instrumentValue.fact.shortDescription : qsTr("Label")
- }
- }
-
- QGCTextField {
- id: labelTextField
- Layout.fillWidth: true
- Layout.columnSpan: 2
- text: instrumentValue.label
- enabled: labelCheckBox.checked
- }
-
- QGCLabel { text: qsTr("Size") }
-
- QGCComboBox {
- id: fontSizeCombo
- model: instrumentValue.fontSizeNames
- currentIndex: instrumentValue.fontSize
- sizeToContents: true
- onActivated: instrumentValue.fontSize = index
- }
-
- QGCCheckBox {
- text: qsTr("Show Units")
- checked: instrumentValue.showUnits
- onClicked: instrumentValue.showUnits = checked
- }
-
- QGCLabel { text: qsTr("Range") }
-
- QGCComboBox {
- id: rangeTypeCombo
- Layout.columnSpan: 2
- model: instrumentValue.rangeTypeNames
- currentIndex: instrumentValue.rangeType
- sizeToContents: true
- onActivated: instrumentValue.rangeType = index
- }
-
- Loader {
- id: rangeLoader
- Layout.columnSpan: 3
- Layout.fillWidth: true
- Layout.preferredWidth: item ? item.width : 0
- Layout.preferredHeight: item ? item.height : 0
-
- property var instrumentValue: valueDisplayDialog.instrumentValue
-
- function updateSourceComponent() {
- switch (instrumentValue.rangeType) {
- case InstrumentValue.NoRangeInfo:
- sourceComponent = undefined
- break
- case InstrumentValue.ColorRange:
- sourceComponent = colorRangeDialog
- break
- case InstrumentValue.OpacityRange:
- sourceComponent = opacityRangeDialog
- break
- case InstrumentValue.IconSelectRange:
- sourceComponent = iconRangeDialog
- break
- }
- }
-
- Component.onCompleted: updateSourceComponent()
-
- Connections {
- target: instrumentValue
- onRangeTypeChanged: rangeLoader.updateSourceComponent()
- }
-
- }
- }
- }
- }
-
- Component {
- id: iconPickerDialog
-
- QGCPopupDialog {
- property var iconNames: dialogProperties.iconNames
- property string icon: dialogProperties.icon
- property var updateIconFunction: dialogProperties.updateIconFunction
-
- title: qsTr("Select Icon")
- buttons: StandardButton.Close
-
- GridLayout {
- columns: 10
- columnSpacing: 0
- rowSpacing: 0
-
- Repeater {
- model: iconNames
-
- Rectangle {
- height: ScreenTools.minTouchPixels
- width: height
- color: currentSelection ? qgcPal.text : qgcPal.window
-
- property bool currentSelection: icon == modelData
-
- QGCColoredImage {
- anchors.centerIn: parent
- height: parent.height * 0.75
- width: height
- source: "/InstrumentValueIcons/" + modelData
- sourceSize.height: height
- fillMode: Image.PreserveAspectFit
- mipmap: true
- smooth: true
- color: currentSelection ? qgcPal.window : qgcPal.text
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- icon = modelData
- updateIconFunction(modelData)
- hideDialog()
- }
- }
- }
- }
- }
- }
- }
- }
-
- Component {
- id: colorRangeDialog
-
- Item {
- width: childrenRect.width
- height: childrenRect.height
-
- function updateRangeValue(index, text) {
- var newValues = instrumentValue.rangeValues
- newValues[index] = parseFloat(text)
- instrumentValue.rangeValues = newValues
- }
-
- function updateColorValue(index, color) {
- var newColors = instrumentValue.rangeColors
- newColors[index] = color
- instrumentValue.rangeColors = newColors
- }
-
- ColorDialog {
- id: colorPickerDialog
- modality: Qt.ApplicationModal
- currentColor: instrumentValue.rangeColors.length ? instrumentValue.rangeColors[colorIndex] : "white"
- onAccepted: updateColorValue(colorIndex, color)
-
- property int colorIndex: 0
- }
-
- Column {
- id: mainColumn
- spacing: ScreenTools.defaultFontPixelHeight / 2
-
- QGCLabel {
- width: rowLayout.width
- text: qsTr("Specify the color you want to apply based on value ranges. The color will be applied to the icon if available, otherwise to the value itself.")
- wrapMode: Text.WordWrap
- }
-
- Row {
- id: rowLayout
- spacing: _margins
-
- Column {
- anchors.verticalCenter: parent.verticalCenter
- spacing: _margins
-
- Repeater {
- model: instrumentValue.rangeValues.length
-
- QGCButton {
- width: ScreenTools.implicitTextFieldHeight
- height: width
- text: qsTr("-")
- onClicked: instrumentValue.removeRangeValue(index)
- }
- }
- }
-
- Column {
- anchors.verticalCenter: parent.verticalCenter
- spacing: _margins
-
- Repeater {
- model: instrumentValue.rangeValues.length
-
- QGCTextField {
- text: instrumentValue.rangeValues[index]
- onEditingFinished: updateRangeValue(index, text)
- }
- }
- }
-
- Column {
- spacing: _margins
- Repeater {
- model: instrumentValue.rangeColors
-
- QGCCheckBox {
- height: ScreenTools.implicitTextFieldHeight
- checked: instrumentValue.isValidColor(instrumentValue.rangeColors[index])
- onClicked: updateColorValue(index, checked ? "green" : instrumentValue.invalidColor())
- }
- }
- }
-
- Column {
- spacing: _margins
- Repeater {
- model: instrumentValue.rangeColors
-
- Rectangle {
- width: ScreenTools.implicitTextFieldHeight
- height: width
- border.color: qgcPal.text
- color: instrumentValue.isValidColor(modelData) ? modelData : qgcPal.text
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- colorPickerDialog.colorIndex = index
- colorPickerDialog.open()
- }
- }
- }
- }
- }
- }
-
- QGCButton {
- text: qsTr("Add Row")
- onClicked: instrumentValue.addRangeValue()
- }
- }
- }
- }
-
- Component {
- id: iconRangeDialog
-
- Item {
- width: childrenRect.width
- height: childrenRect.height
-
- function updateRangeValue(index, text) {
- var newValues = instrumentValue.rangeValues
- newValues[index] = parseFloat(text)
- instrumentValue.rangeValues = newValues
- }
-
- function updateIconValue(index, icon) {
- var newIcons = instrumentValue.rangeIcons
- newIcons[index] = icon
- instrumentValue.rangeIcons = newIcons
- }
-
- Column {
- id: mainColumn
- spacing: ScreenTools.defaultFontPixelHeight / 2
-
- QGCLabel {
- width: rowLayout.width
- text: qsTr("Specify the icon you want to display based on value ranges.")
- wrapMode: Text.WordWrap
- }
-
- Row {
- id: rowLayout
- spacing: _margins
-
- Column {
- anchors.verticalCenter: parent.verticalCenter
- spacing: _margins
-
- Repeater {
- model: instrumentValue.rangeValues.length
-
- QGCButton {
- width: ScreenTools.implicitTextFieldHeight
- height: width
- text: qsTr("-")
- onClicked: instrumentValue.removeRangeValue(index)
- }
- }
- }
-
- Column {
- anchors.verticalCenter: parent.verticalCenter
- spacing: _margins
-
- Repeater {
- model: instrumentValue.rangeValues.length
-
- QGCTextField {
- text: instrumentValue.rangeValues[index]
- onEditingFinished: updateRangeValue(index, text)
- }
- }
- }
-
- Column {
- spacing: _margins
-
- Repeater {
- model: instrumentValue.rangeIcons
-
- QGCColoredImage {
- height: ScreenTools.implicitTextFieldHeight
- width: height
- source: "/InstrumentValueIcons/" + modelData
- sourceSize.height: height
- fillMode: Image.PreserveAspectFit
- mipmap: true
- smooth: true
- color: qgcPal.text
-
- MouseArea {
- anchors.fill: parent
- onClicked: {
- var updateFunction = function(icon){ updateIconValue(index, icon) }
- mainWindow.showPopupDialog(iconPickerDialog, { iconNames: instrumentValue.iconNames, icon: modelData, updateIconFunction = updateFunction })
- }
- }
- }
- }
- }
- }
-
- QGCButton {
- text: qsTr("Add Row")
- onClicked: instrumentValue.addRangeValue()
- }
- }
- }
- }
-
- Component {
- id: opacityRangeDialog
-
- Item {
- width: childrenRect.width
- height: childrenRect.height
-
- function updateRangeValue(index, text) {
- var newValues = instrumentValue.rangeValues
- newValues[index] = parseFloat(text)
- instrumentValue.rangeValues = newValues
- }
-
- function updateOpacityValue(index, opacity) {
- var newOpacities = instrumentValue.rangeOpacities
- newOpacities[index] = opacity
- instrumentValue.rangeOpacities = newOpacities
- }
-
- Column {
- id: mainColumn
- spacing: ScreenTools.defaultFontPixelHeight / 2
-
- QGCLabel {
- width: rowLayout.width
- text: qsTr("Specify the icon opacity you want based on value ranges.")
- wrapMode: Text.WordWrap
- }
-
- Row {
- id: rowLayout
- spacing: _margins
-
- Column {
- anchors.verticalCenter: parent.verticalCenter
- spacing: _margins
-
- Repeater {
- model: instrumentValue.rangeValues.length
-
- QGCButton {
- width: ScreenTools.implicitTextFieldHeight
- height: width
- text: qsTr("-")
- onClicked: instrumentValue.removeRangeValue(index)
- }
- }
- }
-
- Column {
- anchors.verticalCenter: parent.verticalCenter
- spacing: _margins
-
- Repeater {
- model: instrumentValue.rangeValues
-
- QGCTextField {
- text: modelData
- onEditingFinished: updateRangeValue(index, text)
- }
- }
- }
-
- Column {
- spacing: _margins
-
- Repeater {
- model: instrumentValue.rangeOpacities
-
- QGCTextField {
- text: modelData
- onEditingFinished: updateOpacityValue(index, text)
- }
- }
- }
- }
-
- QGCButton {
- text: qsTr("Add Row")
- onClicked: instrumentValue.addRangeValue()
- }
- }
- }
+ InstrumentValueEditDialog { }
}
}
diff --git a/src/FlightMap/Widgets/ValuesWidgetController.cc b/src/FlightMap/Widgets/ValuesWidgetController.cc
index 65fb21d043dcb2ebb9db1a600ccc26aa547c8ec3..0e8e0184be1580032d70c03eefdb4062e59c9b58 100644
--- a/src/FlightMap/Widgets/ValuesWidgetController.cc
+++ b/src/FlightMap/Widgets/ValuesWidgetController.cc
@@ -40,11 +40,11 @@ void ValuesWidgetController::_connectSignalsToController(InstrumentValue* value,
{
connect(value, &InstrumentValue::factNameChanged, controller, &ValuesWidgetController::_saveSettings);
connect(value, &InstrumentValue::factGroupNameChanged, controller, &ValuesWidgetController::_saveSettings);
- connect(value, &InstrumentValue::labelChanged, controller, &ValuesWidgetController::_saveSettings);
+ connect(value, &InstrumentValue::textChanged, controller, &ValuesWidgetController::_saveSettings);
connect(value, &InstrumentValue::fontSizeChanged, controller, &ValuesWidgetController::_saveSettings);
connect(value, &InstrumentValue::showUnitsChanged, controller, &ValuesWidgetController::_saveSettings);
connect(value, &InstrumentValue::iconChanged, controller, &ValuesWidgetController::_saveSettings);
- connect(value, &InstrumentValue::iconPositionChanged, controller, &ValuesWidgetController::_saveSettings);
+ connect(value, &InstrumentValue::labelPositionChanged, controller, &ValuesWidgetController::_saveSettings);
connect(value, &InstrumentValue::rangeTypeChanged, controller, &ValuesWidgetController::_saveSettings);
connect(value, &InstrumentValue::rangeValuesChanged, controller, &ValuesWidgetController::_saveSettings);
connect(value, &InstrumentValue::rangeColorsChanged, controller, &ValuesWidgetController::_saveSettings);
@@ -229,7 +229,7 @@ void ValuesWidgetController::_loadSettings(void)
InstrumentValue* colValue = appendColumn(rowIndex);
colValue->setFact(factGroupName, factName);
- colValue->setLabel(colValue->fact()->shortDescription());
+ colValue->setText(colValue->fact()->shortDescription());
colValue->setShowUnits(true);
colValue->setFontSize(altitudeProperties.contains(factName) ? InstrumentValue::LargeFontSize : InstrumentValue::DefaultFontSize);
}
@@ -248,7 +248,7 @@ void ValuesWidgetController::_loadSettings(void)
InstrumentValue* colValue = appendColumn(rowIndex);
colValue->setFact(factGroupName, factName);
- colValue->setLabel(colValue->fact()->shortDescription());
+ colValue->setText(colValue->fact()->shortDescription());
colValue->setShowUnits(true);
colValue->setFontSize(InstrumentValue::SmallFontSize);
}
diff --git a/src/QmlControls/QGroundControl/FlightMap/qmldir b/src/QmlControls/QGroundControl/FlightMap/qmldir
index c356917dd58d1325585a9cb0dd5de2d56bf826cf..f04544e4feb045fffd35cbdcf25e454caca8d890 100644
--- a/src/QmlControls/QGroundControl/FlightMap/qmldir
+++ b/src/QmlControls/QGroundControl/FlightMap/qmldir
@@ -5,18 +5,20 @@ FlightMap 1.0 FlightMap.qml
QGCVideoBackground 1.0 QGCVideoBackground.qml
# Widgets
-CenterMapDropButton 1.0 CenterMapDropButton.qml
-CenterMapDropPanel 1.0 CenterMapDropPanel.qml
-CompassRing 1.0 CompassRing.qml
-InstrumentSwipeView 1.0 InstrumentSwipeView.qml
-MapFitFunctions 1.0 MapFitFunctions.qml
-MapLineArrow 1.0 MapLineArrow.qml
-MapScale 1.0 MapScale.qml
-QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml
-QGCAttitudeHUD 1.0 QGCAttitudeHUD.qml
-QGCAttitudeWidget 1.0 QGCAttitudeWidget.qml
-QGCCompassWidget 1.0 QGCCompassWidget.qml
-QGCPitchIndicator 1.0 QGCPitchIndicator.qml
+CenterMapDropButton 1.0 CenterMapDropButton.qml
+CenterMapDropPanel 1.0 CenterMapDropPanel.qml
+CompassRing 1.0 CompassRing.qml
+InstrumentSwipeView 1.0 InstrumentSwipeView.qml
+InstrumentValue 1.0 InstrumentValue.qml
+InstrumentValueEditDialog 1.0 InstrumentValueEditDialog.qml
+MapFitFunctions 1.0 MapFitFunctions.qml
+MapLineArrow 1.0 MapLineArrow.qml
+MapScale 1.0 MapScale.qml
+QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml
+QGCAttitudeHUD 1.0 QGCAttitudeHUD.qml
+QGCAttitudeWidget 1.0 QGCAttitudeWidget.qml
+QGCCompassWidget 1.0 QGCCompassWidget.qml
+QGCPitchIndicator 1.0 QGCPitchIndicator.qml
# Map items
CameraTriggerIndicator 1.0 CameraTriggerIndicator.qml
diff --git a/src/api/QGCCorePlugin.cc b/src/api/QGCCorePlugin.cc
index 789ab3656454928c6358a1ce6713318306db7cd5..cf9b3df364f23bd9b93e174664dcd37e7770b002 100644
--- a/src/api/QGCCorePlugin.cc
+++ b/src/api/QGCCorePlugin.cc
@@ -418,21 +418,21 @@ QmlObjectListModel* QGCCorePlugin::valuesWidgetDefaultSettings(ValuesWidgetContr
QmlObjectListModel* columnModel = controller.appendRow();
InstrumentValue* colValue = columnModel->value(0);
colValue->setFact("Vehicle", "AltitudeRelative");
- colValue->setLabel(colValue->fact()->shortDescription());
+ colValue->setText(colValue->fact()->shortDescription());
colValue->setShowUnits(true);
colValue->setFontSize(InstrumentValue::LargeFontSize);
columnModel = controller.appendRow();
colValue = columnModel->value(0);
colValue->setFact("Vehicle", "GroundSpeed");
- colValue->setLabel(colValue->fact()->shortDescription());
+ colValue->setText(colValue->fact()->shortDescription());
colValue->setShowUnits(true);
colValue->setFontSize(InstrumentValue::DefaultFontSize);
columnModel = controller.appendRow();
colValue = columnModel->value(0);
colValue->setFact("Vehicle", "FlightTime");
- colValue->setLabel(colValue->fact()->shortDescription());
+ colValue->setText(colValue->fact()->shortDescription());
colValue->setShowUnits(false);
colValue->setFontSize(InstrumentValue::DefaultFontSize);