Unverified Commit 909a9889 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8742 from DonLakeFlyer/FactValueGrid

Added configurable value grid to toolbar
parents 88575cd6 ea3f13d0
This diff is collapsed.
......@@ -359,7 +359,7 @@ CustomBuild {
$$PWD/qgroundcontrol.qrc \
$$PWD/qgcresources.qrc \
$$PWD/qgcimages.qrc \
$$PWD/InstrumentValueIcons.qrc \
$$PWD/resources/InstrumentValueIcons/InstrumentValueIcons.qrc \
}
# On Qt 5.9 android versions there is the following bug: https://bugreports.qt.io/browse/QTBUG-61424
......@@ -647,8 +647,9 @@ HEADERS += \
src/QmlControls/AppMessages.h \
src/QmlControls/EditPositionDialogController.h \
src/QmlControls/FlightPathSegment.h \
src/QmlControls/HorizontalFactValueGrid.h \
src/QmlControls/InstrumentValueData.h \
src/QmlControls/InstrumentValueArea.h \
src/QmlControls/FactValueGrid.h \
src/QmlControls/ParameterEditorController.h \
src/QmlControls/QGCFileDialogController.h \
src/QmlControls/QGCImageProvider.h \
......@@ -661,6 +662,7 @@ HEADERS += \
src/QmlControls/TerrainProfile.h \
src/QmlControls/ToolStripAction.h \
src/QmlControls/ToolStripActionList.h \
src/QmlControls/VerticalFactValueGrid.h \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h \
src/Settings/ADSBVehicleManagerSettings.h \
src/Settings/AppSettings.h \
......@@ -857,8 +859,9 @@ SOURCES += \
src/QmlControls/AppMessages.cc \
src/QmlControls/EditPositionDialogController.cc \
src/QmlControls/FlightPathSegment.cc \
src/QmlControls/HorizontalFactValueGrid.cc \
src/QmlControls/InstrumentValueData.cc \
src/QmlControls/InstrumentValueArea.cc \
src/QmlControls/FactValueGrid.cc \
src/QmlControls/ParameterEditorController.cc \
src/QmlControls/QGCFileDialogController.cc \
src/QmlControls/QGCImageProvider.cc \
......@@ -871,6 +874,7 @@ SOURCES += \
src/QmlControls/TerrainProfile.cc \
src/QmlControls/ToolStripAction.cc \
src/QmlControls/ToolStripActionList.cc \
src/QmlControls/VerticalFactValueGrid.cc \
src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc \
src/Settings/ADSBVehicleManagerSettings.cc \
src/Settings/AppSettings.cc \
......
......@@ -98,9 +98,10 @@
<file alias="QGroundControl/Controls/FWLandingPatternMapVisual.qml">src/PlanView/FWLandingPatternMapVisual.qml</file>
<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/HorizontalFactValueGrid.qml">src/QmlControls/HorizontalFactValueGrid.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/InstrumentValueLabel.qml">src/QmlControls/InstrumentValueLabel.qml</file>
<file alias="QGroundControl/Controls/InstrumentValueValue.qml">src/QmlControls/InstrumentValueValue.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>
......@@ -182,6 +183,7 @@
<file alias="QGroundControl/Controls/TransectStyleComplexItemStats.qml">src/PlanView/TransectStyleComplexItemStats.qml</file>
<file alias="QGroundControl/Controls/VehicleRotationCal.qml">src/QmlControls/VehicleRotationCal.qml</file>
<file alias="QGroundControl/Controls/VehicleSummaryRow.qml">src/QmlControls/VehicleSummaryRow.qml</file>
<file alias="QGroundControl/Controls/VerticalFactValueGrid.qml">src/QmlControls/VerticalFactValueGrid.qml</file>
<file alias="QGroundControl/Controls/ViewWidget.qml">src/ViewWidgets/ViewWidget.qml</file>
<file alias="QGroundControl/FactControls/AltitudeFactTextField.qml">src/FactSystem/FactControls/AltitudeFactTextField.qml</file>
<file alias="QGroundControl/FactControls/FactBitmask.qml">src/FactSystem/FactControls/FactBitmask.qml</file>
......
This diff is collapsed.
......@@ -10,7 +10,7 @@ def main():
files = os.listdir(".")
for filename in files:
if filename.endswith(".svg"):
qrcFile.write("\t\t<file alias=\"%s\">resources/InstrumentValueIcons/%s</file>\n" % (filename, filename))
qrcFile.write("\t\t<file alias=\"%s\">%s</file>\n" % (filename, filename))
qrcFile.write("\t</qresource>\n")
qrcFile.write("</RCC>\n")
......
......@@ -23,12 +23,11 @@ import QGroundControl.FlightMap 1.0
import QGroundControl 1.0
/// Value page for InstrumentPanel PageView
InstrumentValueArea {
VerticalFactValueGrid {
id: _root
width: pageWidth
userSettingsGroup: valuePageUserSettingsGroup
defaultSettingsGroup: valuePageDefaultSettingsGroup
orientation: InstrumentValueArea.VerticalOrientation
property bool showSettingsIcon: true
property bool showLockIcon: true
......
......@@ -78,7 +78,8 @@
#if defined(QGC_ENABLE_MAVLINK_INSPECTOR)
#include "MAVLinkInspectorController.h"
#endif
#include "InstrumentValueArea.h"
#include "HorizontalFactValueGrid.h"
#include "VerticalFactValueGrid.h"
#include "InstrumentValueData.h"
#include "AppMessages.h"
#include "SimulatedPosition.h"
......@@ -543,7 +544,9 @@ void QGCApplication::_initCommon()
qmlRegisterUncreatableType<QGCGeoBoundingCube> ("QGroundControl.FlightMap", 1, 0, "QGCGeoBoundingCube", kRefOnly);
qmlRegisterUncreatableType<TrajectoryPoints> ("QGroundControl.FlightMap", 1, 0, "TrajectoryPoints", kRefOnly);
qmlRegisterType<InstrumentValueArea> (kQGCTemplates, 1, 0, "InstrumentValueArea");
qmlRegisterUncreatableType<FactValueGrid> (kQGCTemplates, 1, 0, "FactValueGrid", kRefOnly);
qmlRegisterType<HorizontalFactValueGrid> (kQGCTemplates, 1, 0, "HorizontalFactValueGrid");
qmlRegisterType<VerticalFactValueGrid> (kQGCTemplates, 1, 0, "VerticalFactValueGrid");
qmlRegisterType<QGCMapCircle> ("QGroundControl.FlightMap", 1, 0, "QGCMapCircle");
......@@ -551,7 +554,6 @@ void QGCApplication::_initCommon()
qmlRegisterType<ESP8266ComponentController> (kQGCControllers, 1, 0, "ESP8266ComponentController");
qmlRegisterType<ScreenToolsController> (kQGCControllers, 1, 0, "ScreenToolsController");
qmlRegisterType<PlanMasterController> (kQGCControllers, 1, 0, "PlanMasterController");
qmlRegisterType<InstrumentValueArea> (kQGCTemplates, 1, 0, "InstrumentValueArea");
qmlRegisterType<QGCFileDialogController> (kQGCControllers, 1, 0, "QGCFileDialogController");
qmlRegisterType<RCChannelMonitorController> (kQGCControllers, 1, 0, "RCChannelMonitorController");
qmlRegisterType<JoystickConfigController> (kQGCControllers, 1, 0, "JoystickConfigController");
......
This diff is collapsed.
......@@ -13,17 +13,18 @@
#include "QmlObjectListModel.h"
#include "QGCApplication.h"
#include <QQuickItem>
#include <QGridLayout>
#include <QSettings>
class InstrumentValueData;
class InstrumentValueArea : public QQuickItem
class FactValueGrid : public QQuickItem
{
Q_OBJECT
public:
InstrumentValueArea(QQuickItem *parent = nullptr);
InstrumentValueArea(const QString& defaultSettingsGroup);
FactValueGrid(QQuickItem *parent = nullptr);
FactValueGrid(const QString& defaultSettingsGroup);
enum Orientation {
HorizontalOrientation=0, // Labels will be to the left of the value
......@@ -39,77 +40,72 @@ public:
};
Q_ENUMS(FontSize)
// valuePageDefaultSettingsGroup:
// defaultSettingsGroup:
// 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.
// prior to each use by the call to QGCCorePlugin::FactValueGridCreateDefaultSettings.
// valuePageUserSettingsGroup:
// userSettingsGroup:
// 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.
// The combination of the two valuePage*SettingsGroup values allows each FactValueGrid to have it's own persistence space.
Q_PROPERTY(QString valuePageDefaultSettingsGroup MEMBER valuePageDefaultSettingsGroup CONSTANT)
Q_PROPERTY(QString valuePageUserSettingsGroup MEMBER _valuePageUserSettingsGroup CONSTANT)
Q_PROPERTY(QmlObjectListModel* rows MEMBER _rows NOTIFY rowsChanged)
Q_PROPERTY(int columnCount MEMBER _columnCount NOTIFY columnCountChanged)
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(Orientation orientation MEMBER _orientation CONSTANT)
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);
Q_INVOKABLE void resetToDefaults (void);
Q_INVOKABLE QmlObjectListModel* appendRow (void);
Q_INVOKABLE void deleteLastRow (void);
Q_INVOKABLE void appendColumn (void);
Q_INVOKABLE void deleteLastColumn (void);
FontSize fontSize (void) const { return _fontSize; }
QmlObjectListModel* rowValues (void) { return _rowValues; }
QStringList iconNames (void) const { return _iconNames; }
FontSize fontSize (void) const { return _fontSize; }
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);
void rowsChanged (QmlObjectListModel* model);
void columnCountChanged (int columnCount);
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);
protected:
Q_DISABLE_COPY(InstrumentValueArea)
Q_DISABLE_COPY(FactValueGrid)
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;
QmlObjectListModel* _rows = nullptr;
int _columnCount = 0;
private:
InstrumentValueData* _createNewInstrumentValueWorker (QObject* parent);
void _saveSettings (void);
void _loadSettings (void);
void _connectSignals (void);
void _connectSaveSignals (InstrumentValueData* value);
QString _pascalCase (const QString& text);
void _saveValueData (QSettings& settings, InstrumentValueData* value);
void _loadValueData (QSettings& settings, InstrumentValueData* value);
// 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;
......@@ -129,7 +125,7 @@ private:
static const char* _deprecatedGroupKey;
};
QML_DECLARE_TYPE(InstrumentValueArea)
QML_DECLARE_TYPE(FactValueGrid)
Q_DECLARE_METATYPE(InstrumentValueArea::FontSize)
Q_DECLARE_METATYPE(InstrumentValueArea::Orientation)
Q_DECLARE_METATYPE(FactValueGrid::FontSize)
Q_DECLARE_METATYPE(FactValueGrid::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.
*
****************************************************************************/
#include "HorizontalFactValueGrid.h"
#include "InstrumentValueData.h"
#include "QGCApplication.h"
#include "QGCCorePlugin.h"
#include <QSettings>
const QString HorizontalFactValueGrid::_toolbarUserSettingsGroup ("ToolbarUserSettings2");
const QString HorizontalFactValueGrid::toolbarDefaultSettingsGroup ("ToolbarDefaultSettings2");
HorizontalFactValueGrid::HorizontalFactValueGrid(QQuickItem* parent)
: FactValueGrid(parent)
{
_orientation = HorizontalOrientation;
}
HorizontalFactValueGrid::HorizontalFactValueGrid(const QString& defaultSettingsGroup)
: FactValueGrid(defaultSettingsGroup)
{
_orientation = HorizontalOrientation;
}
/****************************************************************************
*
* (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 "FactValueGrid.h"
class InstrumentValueData;
class HorizontalFactValueGrid : public FactValueGrid
{
Q_OBJECT
public:
HorizontalFactValueGrid(QQuickItem *parent = nullptr);
HorizontalFactValueGrid(const QString& defaultSettingsGroup);
Q_PROPERTY(QString toolbarDefaultSettingsGroup MEMBER toolbarDefaultSettingsGroup CONSTANT)
Q_PROPERTY(QString toolbarUserSettingsGroup MEMBER _toolbarUserSettingsGroup CONSTANT)
static const QString toolbarDefaultSettingsGroup;
private:
Q_DISABLE_COPY(HorizontalFactValueGrid)
static const QString _toolbarUserSettingsGroup;
};
QML_DECLARE_TYPE(HorizontalFactValueGrid)
/****************************************************************************
*
* (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
// Note: This control will spit out qWarnings like this: "QGridLayoutEngine::addItem: Cell (0, 1) already taken"
// This is due to Qt bug https://bugreports.qt.io/browse/QTBUG-65121
// If this becomes a problem I'll implement our own grid layout control
T.HorizontalFactValueGrid {
id: _root
width: topLevelRowLayout.width
property bool settingsUnlocked: false
property real _margins: ScreenTools.defaultFontPixelWidth / 2
property int _rowMax: 2
property real _rowButtonWidth: ScreenTools.minTouchPixels
property real _rowButtonHeight: ScreenTools.minTouchPixels / 2
property real _editButtonSpacing: 2
QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
RowLayout {
id: topLevelRowLayout
height: parent.height
Item {
id: lockItem
Layout.fillHeight: true
width: ScreenTools.minTouchPixels
visible: settingsUnlocked
enabled: settingsUnlocked
QGCColoredImage {
anchors.centerIn: parent
source: "/res/LockOpen.svg"
mipmap: true
width: parent.width * 0.75
height: width
sourceSize.width: width
color: qgcPal.text
fillMode: Image.PreserveAspectFit
}
QGCMouseArea {
fillItem: parent
onClicked: settingsUnlocked = false
}
}
ColumnLayout {
Layout.fillHeight: true
GridLayout {
id: valueGrid
Layout.preferredHeight: _root.height
rows: _root.rows.count
rowSpacing: 0
Repeater {
model: _root.rows
Repeater {
id: labelRepeater
model: object
property real _index: index
InstrumentValueLabel {
Layout.row: labelRepeater._index
Layout.column: index * 2
Layout.fillHeight: true
Layout.alignment: Qt.AlignRight
instrumentValueData: object
}
}
}
Repeater {
model: _root.rows
Repeater {
id: valueRepeater
model: object
property real _index: index
InstrumentValueValue {
Layout.row: valueRepeater._index
Layout.column: index * 2 + 1
Layout.fillHeight: true
Layout.alignment: Qt.AlignLeft
instrumentValueData: object
}
}
}
}
RowLayout {
id: rowButtons
height: ScreenTools.minTouchPixels / 2
Layout.fillWidth: true
spacing: 1
visible: settingsUnlocked
enabled: settingsUnlocked
QGCButton {
Layout.fillWidth: true
Layout.preferredHeight: parent.height
text: qsTr("+")
onClicked: appendRow()
}
QGCButton {
Layout.fillWidth: true
Layout.preferredHeight: parent.height
text: qsTr("-")
enabled: _root.rows.count > 1
onClicked: deleteLastRow()
}
}
}
ColumnLayout {
Layout.fillHeight: true
Layout.bottomMargin: rowButtons.height
Layout.preferredWidth: ScreenTools.minTouchPixels / 2
spacing: 1
visible: settingsUnlocked
enabled: settingsUnlocked
QGCButton {
Layout.fillHeight: true
Layout.preferredHeight: ScreenTools.minTouchPixels
Layout.preferredWidth: parent.width
text: qsTr("+")
onClicked: appendColumn()
}
QGCButton {
Layout.fillHeight: true
Layout.preferredHeight: ScreenTools.minTouchPixels
Layout.preferredWidth: parent.width
text: qsTr("-")
enabled: _root.columnCount > 1
onClicked: deleteLastColumn()
}
}
}
QGCMouseArea {
x: valueGrid.x + lockItem.width + topLevelRowLayout.spacing
y: valueGrid.y
width: valueGrid.width
height: valueGrid.height
visible: settingsUnlocked
onClicked: {
var item = valueGrid.childAt(mouse.x, mouse.y)
//console.log(item, item ? item.instrumentValueData : "null", item && item.parent ? item.parent.instrumentValueData : "null")
if (item && item.instrumentValueData !== undefined) {
mainWindow.showPopupDialog(valueEditDialog, { instrumentValueData: item.instrumentValueData })
}
}
/*Rectangle {
anchors.fill: parent
border.color: "green"
border.width: 1
color: "transparent"
}*/
}
Component {
id: valueEditDialog
InstrumentValueEditDialog { }
}
}
/****************************************************************************
*
* (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 QGroundControl 1.0
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 instrumentValueData: 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 _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 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 + smallVerticalSpacing
} else {
value.y = 0 // value assumed to be taller
valueIcon.y = (value.height - valueIcon.height) / 2
value.x = halfWidth + halfHorizontalSpacing
valueIcon.x = halfWidth - halfHorizontalSpacing - valueIcon.width
}
label.x = label.y = 0
} else {
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.x = (width - value.width) / 2
value.y = (height - value.height) / 2
}
valueIcon.x = valueIcon.y = 0
}
}
onRecalcOkChanged: recalcPositions()
onWidthChanged: recalcPositions()
Connections {
target: instrumentValueData
onIconChanged: recalcPositions()
}
QGCColoredImage {
id: valueIcon
height: _tightHeight
width: height
source: icon
sourceSize.height: height
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
color: instrumentValueData.isValidColor(instrumentValueData.currentColor) ? instrumentValueData.currentColor : qgcPal.text
opacity: instrumentValueData.currentOpacity
visible: _showIcon
onWidthChanged: root.recalcPositions()
onHeightChanged: root.recalcPositions()
property string icon
readonly property string iconPrefix: "/InstrumentValueIcons/"
function updateIcon() {
if (instrumentValueData.rangeType === InstrumentValueData.IconSelectRange) {
icon = iconPrefix + instrumentValueData.currentIcon
} else if (instrumentValueData.icon) {
icon = iconPrefix + instrumentValueData.icon
} else {
icon = ""
}
}
Connections {
target: instrumentValueData
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: !instrumentValueData.fact
onWidthChanged: root.recalcPositions()
onHeightChanged: root.recalcPositions()
}
QGCLabel {
id: label
height: _tightHeight
text: instrumentValueData.text
verticalAlignment: Text.AlignVCenter
visible: !_showIcon
onWidthChanged: root.recalcPositions()
onHeightChanged: root.recalcPositions()
}
QGCLabel {
id: value
font.pointSize: _fontSize
text: visible ? (instrumentValueData.fact.enumOrValueString + (instrumentValueData.showUnits ? instrumentValueData.fact.units : "")) : ""
verticalAlignment: Text.AlignVCenter
visible: instrumentValueData.fact
onWidthChanged: root.recalcPositions()
onHeightChanged: root.recalcPositions()
}
}