Unverified Commit 17e713b5 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #9009 from DonLakeFlyer/ValueGridTwitch

Fly: Less twitchy value grid width sizing
parents 76b58cbc 1313a698
......@@ -670,7 +670,6 @@ 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 \
......@@ -890,7 +889,6 @@ 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 \
......
......@@ -183,7 +183,6 @@
<file alias="QGroundControl/Controls/TransectStyleComplexItemTerrainFollow.qml">src/PlanView/TransectStyleComplexItemTerrainFollow.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/VTOLLandingPatternMapVisual.qml">src/PlanView/VTOLLandingPatternMapVisual.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>
......
......@@ -77,7 +77,6 @@
#include "MAVLinkInspectorController.h"
#endif
#include "HorizontalFactValueGrid.h"
#include "VerticalFactValueGrid.h"
#include "InstrumentValueData.h"
#include "AppMessages.h"
#include "SimulatedPosition.h"
......@@ -553,7 +552,6 @@ void QGCApplication::_initCommon()
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");
......
......@@ -15,9 +15,7 @@
#include <QSettings>
const char* FactValueGrid::_rowsKey = "rows";
const char* FactValueGrid::_columnsKey = "columns";
const char* FactValueGrid::_fontSizeKey = "fontSize";
const char* FactValueGrid::_orientationKey = "orientation";
const char* FactValueGrid::_versionKey = "version";
const char* FactValueGrid::_factGroupNameKey = "groupName";
const char* FactValueGrid::_factNameKey = "factName";
......@@ -44,7 +42,7 @@ const QStringList FactValueGrid::_fontSizeNames = {
FactValueGrid::FactValueGrid(QQuickItem* parent)
: QQuickItem(parent)
, _rows (new QmlObjectListModel(this))
, _columns (new QmlObjectListModel(this))
{
if (_iconNames.isEmpty()) {
QDir iconDir(":/InstrumentValueIcons/");
......@@ -57,7 +55,7 @@ FactValueGrid::FactValueGrid(QQuickItem* parent)
FactValueGrid::FactValueGrid(const QString& defaultSettingsGroup)
: QQuickItem (nullptr)
, _defaultSettingsGroup (defaultSettingsGroup)
, _rows (new QmlObjectListModel(this))
, _columns (new QmlObjectListModel(this))
{
_init();
}
......@@ -189,46 +187,46 @@ void FactValueGrid::_connectSaveSignals(InstrumentValueData* value)
connect(value, &InstrumentValueData::rangeIconsChanged, this, &FactValueGrid::_saveSettings);
}
void FactValueGrid::appendColumn(void)
void FactValueGrid::appendRow(void)
{
for (int rowIndex=0; rowIndex<_rows->count(); rowIndex++) {
QmlObjectListModel* list = _rows->value<QmlObjectListModel*>(rowIndex);
for (int colIndex=0; colIndex<_columns->count(); colIndex++) {
QmlObjectListModel* list = _columns->value<QmlObjectListModel*>(colIndex);
list->append(_createNewInstrumentValueWorker(list));
}
_columnCount++;
emit columnCountChanged(_columnCount);
_rowCount++;
emit rowCountChanged(_rowCount);
_saveSettings();
}
void FactValueGrid::deleteLastColumn(void)
void FactValueGrid::deleteLastRow(void)
{
if (_columnCount <= 1) {
if (_rowCount <= 1) {
return;
}
for (int rowIndex=0; rowIndex<_rows->count(); rowIndex++) {
QmlObjectListModel* list = _rows->value<QmlObjectListModel*>(rowIndex);
for (int colIndex=0; colIndex<_columns->count(); colIndex++) {
QmlObjectListModel* list = _columns->value<QmlObjectListModel*>(colIndex);
list->removeAt(list->count() - 1)->deleteLater();
}
_columnCount--;
emit columnCountChanged(_columnCount);
_rowCount--;
emit rowCountChanged(_rowCount);
_saveSettings();
}
QmlObjectListModel* FactValueGrid::appendRow(void)
QmlObjectListModel* FactValueGrid::appendColumn(void)
{
QmlObjectListModel* newList = new QmlObjectListModel(_rows);
_rows->append(newList);
QmlObjectListModel* newList = new QmlObjectListModel(_columns);
_columns->append(newList);
// If this is the first row then we automatically add the first column as well
int cColsToAdd = qMax(_columnCount, 1);
for (int i=0; i<cColsToAdd; i++) {
int cRowsToAdd = qMax(_rowCount, 1);
for (int i=0; i<cRowsToAdd; i++) {
newList->append(_createNewInstrumentValueWorker(newList));
}
if (cColsToAdd != _columnCount) {
_columnCount = cColsToAdd;
emit columnCountChanged(_columnCount);
if (cRowsToAdd != _rowCount) {
_rowCount = cRowsToAdd;
emit rowCountChanged(_rowCount);
}
_saveSettings();
......@@ -236,10 +234,10 @@ QmlObjectListModel* FactValueGrid::appendRow(void)
return newList;
}
void FactValueGrid::deleteLastRow(void)
void FactValueGrid::deleteLastColumn(void)
{
if (_rows->count() > 1) {
_rows->removeAt(_rows->count() - 1)->deleteLater();
if (_columns->count() > 1) {
_columns->removeAt(_columns->count() - 1)->deleteLater();
}
}
......@@ -272,17 +270,16 @@ void FactValueGrid::_saveSettings(void)
settings.remove(""); // Remove any previous settings
settings.setValue(_versionKey, 1);
settings.setValue(_fontSizeKey, _fontSize);
settings.setValue(_orientationKey, _orientation);
settings.setValue(_columnsKey, _columnCount);
settings.setValue(_versionKey, 1);
settings.setValue(_fontSizeKey, _fontSize);
settings.setValue(_rowsKey, _rowCount);
settings.beginWriteArray(_rowsKey);
for (int rowIndex=0; rowIndex<_rows->count(); rowIndex++) {
QmlObjectListModel* columns = _rows->value<QmlObjectListModel*>(rowIndex);
for (int colIndex=0; colIndex<_columns->count(); colIndex++) {
QmlObjectListModel* columns = _columns->value<QmlObjectListModel*>(colIndex);
settings.setArrayIndex(rowIndex);
settings.beginWriteArray(_columnsKey);
settings.setArrayIndex(colIndex);
settings.beginWriteArray(_rowsKey);
for (int colIndex=0; colIndex<columns->count(); colIndex++) {
InstrumentValueData* value = columns->value<InstrumentValueData*>(colIndex);
......@@ -299,10 +296,10 @@ void FactValueGrid::_loadSettings(void)
{
_preventSaveSettings = true;
_rows->deleteLater();
_columns->deleteLater();
_rows = new QmlObjectListModel(this);
_columnCount = 0;
_columns = new QmlObjectListModel(this);
_rowCount = 0;
QSettings settings;
QString groupNameFormat("%1-%2");
......@@ -325,27 +322,26 @@ void FactValueGrid::_loadSettings(void)
qgcApp()->toolbox()->corePlugin()->factValueGridCreateDefaultSettings(_defaultSettingsGroup);
}
_fontSize = settings.value(_fontSizeKey, DefaultFontSize).value<FontSize>();
_orientation = settings.value(_orientationKey, VerticalOrientation).value<Orientation>();
// Initial setup of empty items
int cColumns = settings.value(_columnsKey).toInt();
int cColumns = settings.value(_rowsKey).toInt();
int cModelLists = settings.beginReadArray(_rowsKey);
if (cModelLists && cColumns) {
appendRow();
appendColumn();
for (int itemIndex=1; itemIndex<cColumns; itemIndex++) {
appendColumn();
}
for (int rowIndex=1; rowIndex<cModelLists; rowIndex++) {
appendRow();
}
for (int colIndex=1; colIndex<cModelLists; colIndex++) {
appendColumn();
}
}
// Fill in the items from settings
for (int rowIndex=0; rowIndex<cModelLists; rowIndex++) {
settings.setArrayIndex(rowIndex);
int cItems = settings.beginReadArray(_columnsKey);
for (int colIndex=0; colIndex<cModelLists; colIndex++) {
settings.setArrayIndex(colIndex);
int cItems = settings.beginReadArray(_rowsKey);
for (int itemIndex=0; itemIndex<cItems; itemIndex++) {
QmlObjectListModel* list = _rows->value<QmlObjectListModel*>(rowIndex);
QmlObjectListModel* list = _columns->value<QmlObjectListModel*>(colIndex);
InstrumentValueData* value = list->value<InstrumentValueData*>(itemIndex);
settings.setArrayIndex(itemIndex);
_loadValueData(settings, value);
......@@ -354,7 +350,7 @@ void FactValueGrid::_loadSettings(void)
}
settings.endArray();
emit rowsChanged(_rows);
emit columnsChanged(_columns);
_preventSaveSettings = false;
}
......@@ -26,12 +26,6 @@ public:
FactValueGrid(QQuickItem *parent = nullptr);
FactValueGrid(const QString& defaultSettingsGroup);
enum Orientation {
HorizontalOrientation=0, // Labels will be to the left of the value
VerticalOrientation // Labels will be above the value
};
Q_ENUMS(Orientation)
enum FontSize {
DefaultFontSize=0,
SmallFontSize,
......@@ -50,22 +44,21 @@ public:
// The combination of the two valuePage*SettingsGroup values allows each FactValueGrid to have it's own persistence space.
Q_PROPERTY(QmlObjectListModel* rows MEMBER _rows NOTIFY rowsChanged)
Q_PROPERTY(int columnCount MEMBER _columnCount NOTIFY columnCountChanged)
Q_PROPERTY(QmlObjectListModel* columns MEMBER _columns NOTIFY columnsChanged)
Q_PROPERTY(int rowCount MEMBER _rowCount NOTIFY rowCountChanged)
Q_PROPERTY(QString userSettingsGroup MEMBER _userSettingsGroup NOTIFY userSettingsGroupChanged)
Q_PROPERTY(QString defaultSettingsGroup MEMBER _defaultSettingsGroup NOTIFY defaultSettingsGroupChanged)
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_INVOKABLE void resetToDefaults (void);
Q_INVOKABLE QmlObjectListModel* appendRow (void);
Q_INVOKABLE void deleteLastRow (void);
Q_INVOKABLE void appendColumn (void);
Q_INVOKABLE void deleteLastColumn (void);
Q_INVOKABLE void resetToDefaults (void);
Q_INVOKABLE QmlObjectListModel* appendColumn (void);
Q_INVOKABLE void deleteLastColumn(void);
Q_INVOKABLE void appendRow (void);
Q_INVOKABLE void deleteLastRow (void);
QmlObjectListModel* rows (void) const { return _rows; }
QmlObjectListModel* columns (void) const { return _columns; }
FontSize fontSize (void) const { return _fontSize; }
QStringList iconNames (void) const { return _iconNames; }
QGCMAVLink::VehicleClass_t vehicleClass(void) const { return _vehicleClass; }
......@@ -79,8 +72,8 @@ signals:
void userSettingsGroupChanged (const QString& userSettingsGroup);
void defaultSettingsGroupChanged(const QString& defaultSettingsGroup);
void fontSizeChanged (FontSize fontSize);
void rowsChanged (QmlObjectListModel* model);
void columnCountChanged (int columnCount);
void columnsChanged (QmlObjectListModel* model);
void rowCountChanged (int rowCount);
protected:
Q_DISABLE_COPY(FactValueGrid)
......@@ -88,11 +81,10 @@ protected:
QGCMAVLink::VehicleClass_t _vehicleClass = QGCMAVLink::VehicleClassGeneric;
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;
bool _preventSaveSettings = false;
QmlObjectListModel* _rows = nullptr;
int _columnCount = 0;
QmlObjectListModel* _columns = nullptr;
int _rowCount = 0;
private slots:
void _offlineVehicleTypeChanged(void);
......@@ -113,8 +105,6 @@ private:
static const char* _versionKey;
static const char* _rowsKey;
static const char* _columnsKey;
static const char* _orientationKey;
static const char* _fontSizeKey;
static const char* _factGroupNameKey;
static const char* _factNameKey;
......@@ -133,4 +123,3 @@ private:
QML_DECLARE_TYPE(FactValueGrid)
Q_DECLARE_METATYPE(FactValueGrid::FontSize)
Q_DECLARE_METATYPE(FactValueGrid::Orientation)
......@@ -14,17 +14,17 @@
#include <QSettings>
const QString HorizontalFactValueGrid::_toolbarUserSettingsGroup ("TelemetryBarUserSettingsWIP0");
const QString HorizontalFactValueGrid::telemetryBarDefaultSettingsGroup ("TelemetryBarDefaultSettingsWIP0");
const QString HorizontalFactValueGrid::_toolbarUserSettingsGroup ("TelemetryBarUserSettingsWIP01");
const QString HorizontalFactValueGrid::telemetryBarDefaultSettingsGroup ("TelemetryBarDefaultSettingsWIP01");
HorizontalFactValueGrid::HorizontalFactValueGrid(QQuickItem* parent)
: FactValueGrid(parent)
{
_orientation = HorizontalOrientation;
}
HorizontalFactValueGrid::HorizontalFactValueGrid(const QString& defaultSettingsGroup)
: FactValueGrid(defaultSettingsGroup)
{
_orientation = HorizontalOrientation;
}
......@@ -71,11 +71,11 @@ T.HorizontalFactValueGrid {
GridLayout {
id: valueGrid
rows: _root.rows.count
rows: _root.columns.count
rowSpacing: 0
Repeater {
model: _root.rows
model: _root.columns
Repeater {
id: labelRepeater
......@@ -84,8 +84,8 @@ T.HorizontalFactValueGrid {
property real _index: index
InstrumentValueLabel {
Layout.row: labelRepeater._index
Layout.column: index * 3
Layout.row: index
Layout.column: labelRepeater._index * 3
Layout.fillHeight: true
Layout.alignment: Qt.AlignRight
instrumentValueData: object
......@@ -94,26 +94,55 @@ T.HorizontalFactValueGrid {
}
Repeater {
model: _root.rows
model: _root.columns
Repeater {
id: valueRepeater
model: object
property real _index: index
property real _index: index
property real maxWidth: 0
property var lastCheck: new Date().getTime()
function recalcWidth() {
var newMaxWidth = 0
for (var i=0; i<valueRepeater.count; i++) {
newMaxWidth = Math.max(newMaxWidth, valueRepeater.itemAt(0).contentWidth)
}
console.log("recalcWidth", newMaxWidth, maxWidth)
maxWidth = Math.min(maxWidth, newMaxWidth)
}
InstrumentValueValue {
Layout.row: valueRepeater._index
Layout.column: (index * 3) + 1
Layout.row: index
Layout.column: (valueRepeater._index * 3) + 1
Layout.fillHeight: true
Layout.alignment: Qt.AlignLeft
Layout.preferredWidth: maxWidth
instrumentValueData: object
property real lastContentWidth
Component.onCompleted: {
maxWidth = Math.max(maxWidth, contentWidth)
lastContentWidth = contentWidth
}
onContentWidthChanged: {
maxWidth = Math.max(maxWidth, contentWidth)
lastContentWidth = contentWidth
var currentTime = new Date().getTime()
if (currentTime - lastCheck > 30 * 1000) {
lastCheck = currentTime
valueRepeater.recalcWidth()
}
}
}
}
}
Repeater {
model: _root.rows
model: _root.columns
Repeater {
id: spacerRepeater
......@@ -122,8 +151,8 @@ T.HorizontalFactValueGrid {
property real _index: index
Item {
Layout.row: spacerRepeater._index
Layout.column: (index * 3) + 2
Layout.row: index
Layout.column: (spacerRepeater._index * 3) + 2
Layout.preferredWidth: ScreenTools.defaultFontPixelWidth
Layout.preferredHeight: 1
}
......@@ -150,7 +179,7 @@ T.HorizontalFactValueGrid {
Layout.fillWidth: true
Layout.preferredHeight: parent.height
text: qsTr("-")
enabled: _root.rows.count > 1
enabled: _root.rowCount > 1
onClicked: deleteLastRow()
}
}
......@@ -177,7 +206,7 @@ T.HorizontalFactValueGrid {
Layout.preferredHeight: ScreenTools.minTouchPixels
Layout.preferredWidth: parent.width
text: qsTr("-")
enabled: _root.columnCount > 1
enabled: _root.columns.count > 1
onClicked: deleteLastColumn()
}
}
......
......@@ -21,6 +21,7 @@ import QGroundControl.Palette 1.0
ColumnLayout {
property var instrumentValueData: null
property bool settingsUnlocked: false
property alias contentWidth: label.contentWidth
property bool _verticalOrientation: instrumentValueData.factValueGrid.orientation === FactValueGrid.VerticalOrientation
property var _rgFontSizes: [ ScreenTools.defaultFontPointSize, ScreenTools.smallFontPointSize, ScreenTools.mediumFontPointSize, ScreenTools.largeFontPointSize ]
......@@ -36,6 +37,7 @@ ColumnLayout {
property real _height: 0
QGCLabel {
id: label
Layout.alignment: _verticalOrientation ? Qt.AlignHCenter : Qt.AlignVCenter
font.pointSize: _fontSize
text: instrumentValueData.fact.enumOrValueString + (instrumentValueData.showUnits ? " " + instrumentValueData.fact.units : "")
......
......@@ -107,6 +107,5 @@ TransectStyleMapVisuals 1.0 TransectStyleMapVisuals.qml
ToolStrip 1.0 ToolStrip.qml
VehicleRotationCal 1.0 VehicleRotationCal.qml
VehicleSummaryRow 1.0 VehicleSummaryRow.qml
VerticalFactValueGrid 1.0 VerticalFactValueGrid.qml
QGCHoverButton 1.0 QGCHoverButton.qml
MAVLinkChart 1.0 MAVLinkChart.qml
/****************************************************************************
*
* (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 "VerticalFactValueGrid.h"
#include "InstrumentValueData.h"
#include "QGCApplication.h"
#include "QGCCorePlugin.h"
#include <QSettings>
const QString VerticalFactValueGrid::_valuePageUserSettingsGroup ("ValuePageUserSettings2");
const QString VerticalFactValueGrid::valuePageDefaultSettingsGroup("ValuePageDefaultSettings2");
VerticalFactValueGrid::VerticalFactValueGrid(QQuickItem* parent)
: FactValueGrid(parent)
{
_orientation = VerticalOrientation;
}
VerticalFactValueGrid::VerticalFactValueGrid(const QString& defaultSettingsGroup)
: FactValueGrid(defaultSettingsGroup)
{
_orientation = VerticalOrientation;
}
/****************************************************************************
*
* (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 VerticalFactValueGrid : public FactValueGrid
{
Q_OBJECT
public:
VerticalFactValueGrid(QQuickItem *parent = nullptr);
VerticalFactValueGrid(const QString& defaultSettingsGroup);
Q_PROPERTY(QString valuePageDefaultSettingsGroup MEMBER valuePageDefaultSettingsGroup CONSTANT)
Q_PROPERTY(QString valuePageUserSettingsGroup MEMBER _valuePageUserSettingsGroup CONSTANT)
static const QString valuePageDefaultSettingsGroup;
private:
Q_DISABLE_COPY(VerticalFactValueGrid)
static const QString _valuePageUserSettingsGroup;
};
QML_DECLARE_TYPE(VerticalFactValueGrid)
/****************************************************************************
*
* (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.VerticalFactValueGrid {
id: _root
height: childrenRect.height
property bool settingsUnlocked: false
QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
QGCFlickable {
width: parent.width
height: topLevelRowLayout.height
flickableDirection: QGCFlickable.HorizontalFlick
contentWidth: topLevelRowLayout.width
RowLayout {
id: topLevelRowLayout
spacing: 0
ColumnLayout {
spacing: 0
GridLayout {
id: valueGrid
Layout.minimumWidth: _root.width - (columnButtons.visible? columnButtons.width + columnSpacing : 0)
rows: _root.rows.count * 2
rowSpacing: 0
columnSpacing: 5
Repeater {
model: _root.rows
Repeater {
id: labelRepeater
model: object
property real _index: index
InstrumentValueLabel {
Layout.row: labelRepeater._index * 2
Layout.column: index
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
instrumentValueData: object
}
}
}
Repeater {
model: _root.rows
Repeater {
id: valueRepeater
model: object
property real _index: index
InstrumentValueValue {
Layout.row: valueRepeater._index * 2 + 1
Layout.column: index
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
instrumentValueData: object
}
}
}
}
RowLayout {
id: rowButtons
height: ScreenTools.minTouchPixels / 2
Layout.fillWidth: true
spacing: 1
visible: 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 {
id: columnButtons
Layout.fillHeight: true
Layout.bottomMargin: rowButtons.height
width: ScreenTools.minTouchPixels / 2
spacing: 1
visible: 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
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.showPopupDialogFromComponent(valueEditDialog, { instrumentValueData: item.instrumentValueData })
}
}
/*Rectangle {
anchors.fill: parent
border.color: "green"
border.width: 1
color: "transparent"
}*/
}
}
Component {
id: valueEditDialog
InstrumentValueEditDialog { }
}
}
......@@ -23,7 +23,6 @@
#include "QGCLoggingCategory.h"
#include "QGCCameraManager.h"
#include "HorizontalFactValueGrid.h"
#include "VerticalFactValueGrid.h"
#include "InstrumentValueData.h"
#include <QtQml>
......@@ -298,65 +297,70 @@ void QGCCorePlugin::factValueGridCreateDefaultSettings(const QString& defaultSet
factValueGrid.setFontSize(FactValueGrid::LargeFontSize);
factValueGrid.appendRow();
factValueGrid.appendRow();
factValueGrid.appendColumn();
factValueGrid.appendColumn();
factValueGrid.appendColumn();
if (includeFWValues) {
factValueGrid.appendColumn();
}
factValueGrid.appendRow();
int colIndex = 0;
QmlObjectListModel* row = factValueGrid.rows()->value<QmlObjectListModel*>(0);
int rowIndex = 0;
QmlObjectListModel* column = factValueGrid.columns()->value<QmlObjectListModel*>(0);
InstrumentValueData* value = row->value<InstrumentValueData*>(colIndex++);
InstrumentValueData* value = column->value<InstrumentValueData*>(rowIndex++);
value->setFact("Vehicle", "AltitudeRelative");
value->setIcon("arrow-thick-up.svg");
value->setText(value->fact()->shortDescription());
value->setShowUnits(true);
value = row->value<InstrumentValueData*>(colIndex++);
value->setFact("Vehicle", "ClimbRate");
value->setIcon("arrow-simple-up.svg");
value = column->value<InstrumentValueData*>(rowIndex++);
value->setFact("Vehicle", "DistanceToHome");
value->setIcon("bookmark copy 3.svg");
value->setText(value->fact()->shortDescription());
value->setShowUnits(true);
if (includeFWValues) {
value = row->value<InstrumentValueData*>(colIndex++);
value->setFact("Vehicle", "AirSpeed");
value->setText("AirSpd");
value->setShowUnits(true);
}
value = row->value<InstrumentValueData*>(colIndex++);
value->setFact("Vehicle", "FlightTime");
value->setIcon("timer.svg");
value->setText(value->fact()->shortDescription());
value->setShowUnits(false);
rowIndex = 0;
column = factValueGrid.columns()->value<QmlObjectListModel*>(1);
colIndex = 0;
row = factValueGrid.rows()->value<QmlObjectListModel*>(1);
value = row->value<InstrumentValueData*>(colIndex++);
value->setFact("Vehicle", "DistanceToHome");
value->setIcon("bookmark copy 3.svg");
value = column->value<InstrumentValueData*>(rowIndex++);
value->setFact("Vehicle", "ClimbRate");
value->setIcon("arrow-simple-up.svg");
value->setText(value->fact()->shortDescription());
value->setShowUnits(true);
value = row->value<InstrumentValueData*>(colIndex++);
value = column->value<InstrumentValueData*>(rowIndex++);
value->setFact("Vehicle", "GroundSpeed");
value->setIcon("arrow-simple-right.svg");
value->setText(value->fact()->shortDescription());
value->setShowUnits(true);
if (includeFWValues) {
value = row->value<InstrumentValueData*>(colIndex++);
rowIndex = 0;
column = factValueGrid.columns()->value<QmlObjectListModel*>(2);
value = column->value<InstrumentValueData*>(rowIndex++);
value->setFact("Vehicle", "AirSpeed");
value->setText("AirSpd");
value->setShowUnits(true);
value = column->value<InstrumentValueData*>(rowIndex++);
value->setFact("Vehicle", "ThrottlePct");
value->setText("Thr");
value->setShowUnits(true);
}
value = row->value<InstrumentValueData*>(colIndex++);
rowIndex = 0;
column = factValueGrid.columns()->value<QmlObjectListModel*>(includeFWValues ? 3 : 2);
value = column->value<InstrumentValueData*>(rowIndex++);
value->setFact("Vehicle", "FlightTime");
value->setIcon("timer.svg");
value->setText(value->fact()->shortDescription());
value->setShowUnits(false);
value = column->value<InstrumentValueData*>(rowIndex++);
value->setFact("Vehicle", "FlightDistance");
value->setIcon("travel-walk.svg");
value->setText(value->fact()->shortDescription());
......
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