Commit ef1911dd authored by DonLakeFlyer's avatar DonLakeFlyer

parent ff49ad04
...@@ -209,6 +209,8 @@ ...@@ -209,6 +209,8 @@
<file alias="QGroundControl/FlightMap/CustomMapItems.qml">src/FlightMap/MapItems/CustomMapItems.qml</file> <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/FlightMap.qml">src/FlightMap/FlightMap.qml</file>
<file alias="QGroundControl/FlightMap/InstrumentSwipeView.qml">src/FlightMap/Widgets/InstrumentSwipeView.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/MapFitFunctions.qml">src/FlightMap/Widgets/MapFitFunctions.qml</file>
<file alias="QGroundControl/FlightMap/MapScale.qml">src/FlightMap/MapScale.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> <file alias="QGroundControl/FlightMap/MissionItemIndicator.qml">src/FlightMap/MapItems/MissionItemIndicator.qml</file>
......
...@@ -16,12 +16,12 @@ ...@@ -16,12 +16,12 @@
const char* InstrumentValue::_versionKey = "version"; const char* InstrumentValue::_versionKey = "version";
const char* InstrumentValue::_factGroupNameKey = "groupName"; const char* InstrumentValue::_factGroupNameKey = "groupName";
const char* InstrumentValue::_factNameKey = "factName"; const char* InstrumentValue::_factNameKey = "factName";
const char* InstrumentValue::_labelKey = "label"; const char* InstrumentValue::_textKey = "text";
const char* InstrumentValue::_fontSizeKey = "fontSize"; const char* InstrumentValue::_fontSizeKey = "fontSize";
const char* InstrumentValue::_showUnitsKey = "showUnits"; const char* InstrumentValue::_showUnitsKey = "showUnits";
const char* InstrumentValue::_iconKey = "icon"; const char* InstrumentValue::_iconKey = "icon";
const char* InstrumentValue::_iconPositionKey = "iconPosition"; const char* InstrumentValue::_labelPositionKey = "labelPosition";
const char* InstrumentValue::_rangeTypeKey = "rangeType"; const char* InstrumentValue::_rangeTypeKey = "rangeType";
const char* InstrumentValue::_rangeValuesKey = "rangeValues"; const char* InstrumentValue::_rangeValuesKey = "rangeValues";
const char* InstrumentValue::_rangeColorsKey = "rangeColors"; const char* InstrumentValue::_rangeColorsKey = "rangeColors";
...@@ -31,8 +31,8 @@ const char* InstrumentValue::_vehicleFactGroupName = "Vehicle"; ...@@ -31,8 +31,8 @@ const char* InstrumentValue::_vehicleFactGroupName = "Vehicle";
QStringList InstrumentValue::_iconNames; QStringList InstrumentValue::_iconNames;
// Important: The indices of these strings must match the InstrumentValue::IconPosition enumconst QStringList InstrumentValue::_iconPositionNames // Important: The indices of these strings must match the InstrumentValue::LabelPosition enumconst QStringList InstrumentValue::_labelPositionNames
const QStringList InstrumentValue::_iconPositionNames = { const QStringList InstrumentValue::_labelPositionNames = {
QT_TRANSLATE_NOOP("InstrumentValue", "Above"), QT_TRANSLATE_NOOP("InstrumentValue", "Above"),
QT_TRANSLATE_NOOP("InstrumentValue", "Left"), QT_TRANSLATE_NOOP("InstrumentValue", "Left"),
}; };
...@@ -182,13 +182,13 @@ void InstrumentValue::setFontSize(FontSize fontSize) ...@@ -182,13 +182,13 @@ void InstrumentValue::setFontSize(FontSize fontSize)
void InstrumentValue::saveToSettings(QSettings& settings) const void InstrumentValue::saveToSettings(QSettings& settings) const
{ {
settings.setValue(_versionKey, 1); settings.setValue(_versionKey, 1);
settings.setValue(_labelKey, _label); settings.setValue(_textKey, _text);
settings.setValue(_fontSizeKey, _fontSize); settings.setValue(_fontSizeKey, _fontSize);
settings.setValue(_showUnitsKey, _showUnits); settings.setValue(_showUnitsKey, _showUnits);
settings.setValue(_iconKey, _icon); settings.setValue(_iconKey, _icon);
settings.setValue(_iconPositionKey, _iconPosition); settings.setValue(_labelPositionKey, _labelPosition);
settings.setValue(_rangeTypeKey, _rangeType); settings.setValue(_rangeTypeKey, _rangeType);
if (_rangeType != NoRangeInfo) { if (_rangeType != NoRangeInfo) {
settings.setValue(_rangeValuesKey, _rangeValues); settings.setValue(_rangeValuesKey, _rangeValues);
...@@ -198,13 +198,13 @@ void InstrumentValue::saveToSettings(QSettings& settings) const ...@@ -198,13 +198,13 @@ void InstrumentValue::saveToSettings(QSettings& settings) const
case NoRangeInfo: case NoRangeInfo:
break; break;
case ColorRange: case ColorRange:
settings.setValue(_rangeColorsKey, _rangeColors); settings.setValue(_rangeColorsKey, _rangeColors);
break; break;
case OpacityRange: case OpacityRange:
settings.setValue(_rangeOpacitiesKey, _rangeOpacities); settings.setValue(_rangeOpacitiesKey, _rangeOpacities);
break; break;
case IconSelectRange: case IconSelectRange:
settings.setValue(_rangeIconsKey, _rangeIcons); settings.setValue(_rangeIconsKey, _rangeIcons);
break; break;
} }
...@@ -220,11 +220,11 @@ void InstrumentValue::saveToSettings(QSettings& settings) const ...@@ -220,11 +220,11 @@ void InstrumentValue::saveToSettings(QSettings& settings) const
void InstrumentValue::readFromSettings(const QSettings& settings) void InstrumentValue::readFromSettings(const QSettings& settings)
{ {
_factGroupName = settings.value(_factGroupNameKey, QString()).toString(); _factGroupName = settings.value(_factGroupNameKey, QString()).toString();
_label = settings.value(_labelKey, QString()).toString(); _text = settings.value(_textKey, QString()).toString();
_fontSize = settings.value(_fontSizeKey, DefaultFontSize).value<FontSize>(); _fontSize = settings.value(_fontSizeKey, DefaultFontSize).value<FontSize>();
_showUnits = settings.value(_showUnitsKey, true).toBool(); _showUnits = settings.value(_showUnitsKey, true).toBool();
_icon = settings.value(_iconKey, QString()).toString(); _icon = settings.value(_iconKey, QString()).toString();
_iconPosition = settings.value(_iconPositionKey, IconLeft).value<IconPosition>(); _labelPosition = settings.value(_labelPositionKey, LabelLeft).value<LabelPosition>();
_rangeType = settings.value(_rangeTypeKey, NoRangeInfo).value<RangeType>(); _rangeType = settings.value(_rangeTypeKey, NoRangeInfo).value<RangeType>();
// Do this now, since the signal will cause _resetRangeInfo to be called trashing values // Do this now, since the signal will cause _resetRangeInfo to be called trashing values
...@@ -258,22 +258,22 @@ void InstrumentValue::readFromSettings(const QSettings& settings) ...@@ -258,22 +258,22 @@ void InstrumentValue::readFromSettings(const QSettings& settings)
emit factChanged (_fact); emit factChanged (_fact);
emit factGroupNameChanged (_factGroupName); emit factGroupNameChanged (_factGroupName);
emit labelChanged (_label); emit textChanged (_text);
emit fontSizeChanged (_fontSize); emit fontSizeChanged (_fontSize);
emit showUnitsChanged (_showUnits); emit showUnitsChanged (_showUnits);
emit iconChanged (_icon); emit iconChanged (_icon);
emit iconPositionChanged (_iconPosition); emit labelPositionChanged (_labelPosition);
emit rangeValuesChanged (_rangeValues); emit rangeValuesChanged (_rangeValues);
emit rangeColorsChanged (_rangeColors); emit rangeColorsChanged (_rangeColors);
emit rangeOpacitiesChanged (_rangeOpacities); emit rangeOpacitiesChanged (_rangeOpacities);
emit rangeIconsChanged (_rangeIcons); emit rangeIconsChanged (_rangeIcons);
} }
void InstrumentValue::setLabel(const QString& label) void InstrumentValue::setText(const QString& text)
{ {
if (label != _label) { if (text != _text) {
_label = label; _text = text;
emit labelChanged(label); emit textChanged(text);
} }
} }
...@@ -289,13 +289,13 @@ void InstrumentValue::clearFact(void) ...@@ -289,13 +289,13 @@ void InstrumentValue::clearFact(void)
{ {
_fact = nullptr; _fact = nullptr;
_factGroupName.clear(); _factGroupName.clear();
_label.clear(); _text.clear();
_icon.clear(); _icon.clear();
_showUnits = true; _showUnits = true;
emit factChanged (_fact); emit factChanged (_fact);
emit factGroupNameChanged (_factGroupName); emit factGroupNameChanged (_factGroupName);
emit labelChanged (_label); emit textChanged (_text);
emit iconChanged (_icon); emit iconChanged (_icon);
emit showUnitsChanged (_showUnits); emit showUnitsChanged (_showUnits);
} }
...@@ -308,11 +308,11 @@ void InstrumentValue::setIcon(const QString& icon) ...@@ -308,11 +308,11 @@ void InstrumentValue::setIcon(const QString& icon)
} }
} }
void InstrumentValue::setIconPosition(IconPosition iconPosition) void InstrumentValue::setLabelPosition(LabelPosition labelPosition)
{ {
if (iconPosition != _iconPosition) { if (labelPosition != _labelPosition) {
_iconPosition = iconPosition; _labelPosition = labelPosition;
emit iconPositionChanged(iconPosition); emit labelPositionChanged(labelPosition);
} }
} }
......
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.
*
****************************************************************************/
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()
}
}
This diff is collapsed.
This diff is collapsed.
...@@ -40,11 +40,11 @@ void ValuesWidgetController::_connectSignalsToController(InstrumentValue* value, ...@@ -40,11 +40,11 @@ void ValuesWidgetController::_connectSignalsToController(InstrumentValue* value,
{ {
connect(value, &InstrumentValue::factNameChanged, controller, &ValuesWidgetController::_saveSettings); connect(value, &InstrumentValue::factNameChanged, controller, &ValuesWidgetController::_saveSettings);
connect(value, &InstrumentValue::factGroupNameChanged, 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::fontSizeChanged, controller, &ValuesWidgetController::_saveSettings);
connect(value, &InstrumentValue::showUnitsChanged, controller, &ValuesWidgetController::_saveSettings); connect(value, &InstrumentValue::showUnitsChanged, controller, &ValuesWidgetController::_saveSettings);
connect(value, &InstrumentValue::iconChanged, 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::rangeTypeChanged, controller, &ValuesWidgetController::_saveSettings);
connect(value, &InstrumentValue::rangeValuesChanged, controller, &ValuesWidgetController::_saveSettings); connect(value, &InstrumentValue::rangeValuesChanged, controller, &ValuesWidgetController::_saveSettings);
connect(value, &InstrumentValue::rangeColorsChanged, controller, &ValuesWidgetController::_saveSettings); connect(value, &InstrumentValue::rangeColorsChanged, controller, &ValuesWidgetController::_saveSettings);
...@@ -229,7 +229,7 @@ void ValuesWidgetController::_loadSettings(void) ...@@ -229,7 +229,7 @@ void ValuesWidgetController::_loadSettings(void)
InstrumentValue* colValue = appendColumn(rowIndex); InstrumentValue* colValue = appendColumn(rowIndex);
colValue->setFact(factGroupName, factName); colValue->setFact(factGroupName, factName);
colValue->setLabel(colValue->fact()->shortDescription()); colValue->setText(colValue->fact()->shortDescription());
colValue->setShowUnits(true); colValue->setShowUnits(true);
colValue->setFontSize(altitudeProperties.contains(factName) ? InstrumentValue::LargeFontSize : InstrumentValue::DefaultFontSize); colValue->setFontSize(altitudeProperties.contains(factName) ? InstrumentValue::LargeFontSize : InstrumentValue::DefaultFontSize);
} }
...@@ -248,7 +248,7 @@ void ValuesWidgetController::_loadSettings(void) ...@@ -248,7 +248,7 @@ void ValuesWidgetController::_loadSettings(void)
InstrumentValue* colValue = appendColumn(rowIndex); InstrumentValue* colValue = appendColumn(rowIndex);
colValue->setFact(factGroupName, factName); colValue->setFact(factGroupName, factName);
colValue->setLabel(colValue->fact()->shortDescription()); colValue->setText(colValue->fact()->shortDescription());
colValue->setShowUnits(true); colValue->setShowUnits(true);
colValue->setFontSize(InstrumentValue::SmallFontSize); colValue->setFontSize(InstrumentValue::SmallFontSize);
} }
......
...@@ -5,18 +5,20 @@ FlightMap 1.0 FlightMap.qml ...@@ -5,18 +5,20 @@ FlightMap 1.0 FlightMap.qml
QGCVideoBackground 1.0 QGCVideoBackground.qml QGCVideoBackground 1.0 QGCVideoBackground.qml
# Widgets # Widgets
CenterMapDropButton 1.0 CenterMapDropButton.qml CenterMapDropButton 1.0 CenterMapDropButton.qml
CenterMapDropPanel 1.0 CenterMapDropPanel.qml CenterMapDropPanel 1.0 CenterMapDropPanel.qml
CompassRing 1.0 CompassRing.qml CompassRing 1.0 CompassRing.qml
InstrumentSwipeView 1.0 InstrumentSwipeView.qml InstrumentSwipeView 1.0 InstrumentSwipeView.qml
MapFitFunctions 1.0 MapFitFunctions.qml InstrumentValue 1.0 InstrumentValue.qml
MapLineArrow 1.0 MapLineArrow.qml InstrumentValueEditDialog 1.0 InstrumentValueEditDialog.qml
MapScale 1.0 MapScale.qml MapFitFunctions 1.0 MapFitFunctions.qml
QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml MapLineArrow 1.0 MapLineArrow.qml
QGCAttitudeHUD 1.0 QGCAttitudeHUD.qml MapScale 1.0 MapScale.qml
QGCAttitudeWidget 1.0 QGCAttitudeWidget.qml QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml
QGCCompassWidget 1.0 QGCCompassWidget.qml QGCAttitudeHUD 1.0 QGCAttitudeHUD.qml
QGCPitchIndicator 1.0 QGCPitchIndicator.qml QGCAttitudeWidget 1.0 QGCAttitudeWidget.qml
QGCCompassWidget 1.0 QGCCompassWidget.qml
QGCPitchIndicator 1.0 QGCPitchIndicator.qml
# Map items # Map items
CameraTriggerIndicator 1.0 CameraTriggerIndicator.qml CameraTriggerIndicator 1.0 CameraTriggerIndicator.qml
......
...@@ -418,21 +418,21 @@ QmlObjectListModel* QGCCorePlugin::valuesWidgetDefaultSettings(ValuesWidgetContr ...@@ -418,21 +418,21 @@ QmlObjectListModel* QGCCorePlugin::valuesWidgetDefaultSettings(ValuesWidgetContr
QmlObjectListModel* columnModel = controller.appendRow(); QmlObjectListModel* columnModel = controller.appendRow();
InstrumentValue* colValue = columnModel->value<InstrumentValue*>(0); InstrumentValue* colValue = columnModel->value<InstrumentValue*>(0);
colValue->setFact("Vehicle", "AltitudeRelative"); colValue->setFact("Vehicle", "AltitudeRelative");
colValue->setLabel(colValue->fact()->shortDescription()); colValue->setText(colValue->fact()->shortDescription());
colValue->setShowUnits(true); colValue->setShowUnits(true);
colValue->setFontSize(InstrumentValue::LargeFontSize); colValue->setFontSize(InstrumentValue::LargeFontSize);
columnModel = controller.appendRow(); columnModel = controller.appendRow();
colValue = columnModel->value<InstrumentValue*>(0); colValue = columnModel->value<InstrumentValue*>(0);
colValue->setFact("Vehicle", "GroundSpeed"); colValue->setFact("Vehicle", "GroundSpeed");
colValue->setLabel(colValue->fact()->shortDescription()); colValue->setText(colValue->fact()->shortDescription());
colValue->setShowUnits(true); colValue->setShowUnits(true);
colValue->setFontSize(InstrumentValue::DefaultFontSize); colValue->setFontSize(InstrumentValue::DefaultFontSize);
columnModel = controller.appendRow(); columnModel = controller.appendRow();
colValue = columnModel->value<InstrumentValue*>(0); colValue = columnModel->value<InstrumentValue*>(0);
colValue->setFact("Vehicle", "FlightTime"); colValue->setFact("Vehicle", "FlightTime");
colValue->setLabel(colValue->fact()->shortDescription()); colValue->setText(colValue->fact()->shortDescription());
colValue->setShowUnits(false); colValue->setShowUnits(false);
colValue->setFontSize(InstrumentValue::DefaultFontSize); colValue->setFontSize(InstrumentValue::DefaultFontSize);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment