Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/FactSystem/FactMetaData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1385,16 +1385,17 @@ FactMetaData *FactMetaData::createFromJsonObject(const QJsonObject &json, const
}
metaData->setVehicleRebootRequired(rebootRequired);

bool readOnly = false;
if (json.contains(_readOnlyJsonKey)) {
readOnly = json[_readOnlyJsonKey].toBool();
}
metaData->setReadOnly(readOnly);

bool volatileValue = false;
if (json.contains(_volatileJsonKey)) {
volatileValue = json[_volatileJsonKey].toBool();
}
metaData->setVolatileValue(volatileValue);

if (json.contains(_readOnlyJsonKey)) {
metaData->setReadOnly(json[_readOnlyJsonKey].toBool());
}

if (json.contains(_groupJsonKey)) {
metaData->setGroup(json[_groupJsonKey].toString());
}
Expand Down Expand Up @@ -1479,9 +1480,6 @@ QVariant FactMetaData::cookedMin() const
void FactMetaData::setVolatileValue(bool bValue)
{
_volatile = bValue;
if (_volatile) {
_readOnly = true;
}
}

QStringList FactMetaData::splitTranslatedList(const QString &translatedList)
Expand Down
34 changes: 33 additions & 1 deletion src/QmlControls/ParameterEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ Item {
clearTimer.start()
}
}

QGCCheckBox {
text: qsTr("Hide read-only")
checked: controller.hideReadOnly
onClicked: controller.hideReadOnly = checked
}
}

QGCButton {
Expand Down Expand Up @@ -344,6 +350,7 @@ Item {

delegate: Rectangle {
implicitWidth: column === 0 ? ScreenTools.implicitCheckBoxHeight + ScreenTools.defaultFontPixelWidth
: column === 1 ? nameRow.implicitWidth + ScreenTools.defaultFontPixelWidth
: column === 2 ? ScreenTools.defaultFontPixelWidth * 16
: label.contentWidth + ScreenTools.defaultFontPixelWidth
implicitHeight: label.contentHeight + ScreenTools.defaultFontPixelHeight * 0.5
Expand Down Expand Up @@ -383,9 +390,34 @@ Item {
onClicked: controller.toggleFavorite(fact.name)
}

Row {
id: nameRow
visible: column === 1
anchors.left: parent.left
anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
anchors.verticalCenter: parent.verticalCenter
spacing: lockIcon.visible ? ScreenTools.defaultFontPixelWidth / 3 : 0

QGCLabel {
text: column === 1 ? display : ""
anchors.verticalCenter: parent.verticalCenter
}

QGCColoredImage {
id: lockIcon
visible: fact.readOnly
source: "qrc:/InstrumentValueIcons/lock-closed.svg"
color: qgcPal.text
width: ScreenTools.defaultFontPixelHeight * 0.8
height: width
sourceSize.width: width
anchors.verticalCenter: parent.verticalCenter
}
}

QGCLabel {
id: label
visible: column !== 0
visible: column !== 0 && column !== 1
anchors.left: parent.left
anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
anchors.verticalCenter: parent.verticalCenter
Expand Down
32 changes: 32 additions & 0 deletions src/QmlControls/ParameterEditorController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ ParameterEditorController::ParameterEditorController(QObject *parent)
connect(this, &ParameterEditorController::searchTextChanged, this, &ParameterEditorController::_searchTextChanged);
connect(this, &ParameterEditorController::showModifiedOnlyChanged, this, &ParameterEditorController::_searchTextChanged);
connect(this, &ParameterEditorController::showFavoritesOnlyChanged, this, &ParameterEditorController::_searchTextChanged);
connect(this, &ParameterEditorController::hideReadOnlyChanged, this, &ParameterEditorController::_hideReadOnlyChanged);
connect(&_searchTimer, &QTimer::timeout, this, &ParameterEditorController::_performSearch);
connect(_parameterMgr, &ParameterManager::factAdded, this, &ParameterEditorController::_factAdded);

Expand All @@ -184,6 +185,10 @@ void ParameterEditorController::_buildListsForComponent(int compId)
for (const QString& factName: _parameterMgr->parameterNames(compId)) {
Fact* fact = _parameterMgr->getParameter(compId, factName);

if (_hideReadOnly && fact->readOnly()) {
continue;
}

ParameterEditorCategory* category = nullptr;
if (_mapCategoryName2Category.contains(fact->category())) {
category = _mapCategoryName2Category[fact->category()];
Expand Down Expand Up @@ -211,6 +216,13 @@ void ParameterEditorController::_buildListsForComponent(int compId)

void ParameterEditorController::_buildLists(void)
{
_currentCategory = nullptr;
_currentGroup = nullptr;
_parameters = nullptr;
_mapCategoryName2Category.clear();
_categories.clearAndDeleteContents();
emit parametersChanged();

// Autopilot component should always be first list
_buildListsForComponent(MAV_COMP_ID_AUTOPILOT1);

Expand Down Expand Up @@ -261,6 +273,10 @@ void ParameterEditorController::_buildLists(void)

void ParameterEditorController::_factAdded(int compId, Fact* fact)
{
if (_hideReadOnly && fact->readOnly()) {
return;
}

bool inserted = false;
ParameterEditorCategory* category = nullptr;

Expand Down Expand Up @@ -475,6 +491,9 @@ void ParameterEditorController::resetAllToVehicleConfiguration(void)

bool ParameterEditorController::_shouldShow(Fact* fact) const
{
if (_hideReadOnly && fact->readOnly()) {
return false;
}
if (_showModifiedOnly) {
if (!fact->defaultValueAvailable() || fact->valueEqualsDefault()) {
return false;
Expand All @@ -493,6 +512,19 @@ void ParameterEditorController::_searchTextChanged(void)
_searchTimer.start();
}

void ParameterEditorController::_hideReadOnlyChanged(void)
{
_buildLists();

ParameterEditorCategory* category = _categories.count() ? _categories.value<ParameterEditorCategory*>(0) : nullptr;
setCurrentCategory(category);

// Re-trigger search if active
if (!_searchText.isEmpty() || _showModifiedOnly) {
_performSearch();
}
}

void ParameterEditorController::_performSearch(void)
{
QObjectList newParameterList;
Expand Down
4 changes: 4 additions & 0 deletions src/QmlControls/ParameterEditorController.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class ParameterEditorController : public FactPanelController
Q_PROPERTY(QAbstractTableModel* parameters MEMBER _parameters NOTIFY parametersChanged)
Q_PROPERTY(bool showModifiedOnly MEMBER _showModifiedOnly NOTIFY showModifiedOnlyChanged)
Q_PROPERTY(bool showFavoritesOnly MEMBER _showFavoritesOnly NOTIFY showFavoritesOnlyChanged)
Q_PROPERTY(bool hideReadOnly MEMBER _hideReadOnly NOTIFY hideReadOnlyChanged)
Q_PROPERTY(QStringList favoriteParameterNames READ favoriteParameterNames NOTIFY favoritesChanged)

// These property are related to the diff associated with a load from file
Expand Down Expand Up @@ -171,6 +172,7 @@ class ParameterEditorController : public FactPanelController
void currentGroupChanged (void);
void showModifiedOnlyChanged (void);
void showFavoritesOnlyChanged (void);
void hideReadOnlyChanged (void);
void favoritesChanged (void);
void diffOtherVehicleChanged (bool diffOtherVehicle);
void diffMultipleComponentsChanged (bool diffMultipleComponents);
Expand All @@ -180,6 +182,7 @@ private slots:
void _currentCategoryChanged(void);
void _currentGroupChanged (void);
void _searchTextChanged (void);
void _hideReadOnlyChanged (void);
void _buildLists (void);
void _buildListsForComponent(int compId);
void _factAdded (int compId, Fact* fact);
Expand All @@ -198,6 +201,7 @@ private slots:
ParameterEditorGroup* _currentGroup = nullptr;
bool _showModifiedOnly = false;
bool _showFavoritesOnly = false;
bool _hideReadOnly = false;
bool _diffOtherVehicle = false;
bool _diffMultipleComponents = false;
QSet<QString> _favoriteNames;
Expand Down
22 changes: 18 additions & 4 deletions src/QmlControls/ParameterEditorDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ QGCPopupDialog {
id: root
title: fact.componentId > 0 ? fact.name : qsTr("Value Editor")

buttons: Dialog.Save | (validate ? 0 : Dialog.Cancel)
buttons: fact.readOnly ? Dialog.Close : (Dialog.Save | (validate ? 0 : Dialog.Cancel))

property Fact fact
property bool showRCToParam: false
Expand All @@ -31,6 +31,7 @@ QGCPopupDialog {
QGCPalette { id: qgcPal; colorGroupEnabled: true }

onAccepted: {
if (fact.readOnly) return
if (bitmaskColumn.visible && !manualEntry.checked) {
fact.value = bitmaskValue();
fact.valueChanged(fact.value)
Expand Down Expand Up @@ -78,6 +79,13 @@ QGCPopupDialog {
width: Math.min(mainWindow.width * .75, Math.max(ScreenTools.defaultFontPixelWidth * 60, editRow.width))
spacing: globals.defaultTextHeight

QGCLabel {
Layout.fillWidth: true
wrapMode: Text.WordWrap
text: qsTr("This parameter is read-only and cannot be modified.")
visible: fact.readOnly
}

QGCLabel {
id: validationError
Layout.fillWidth: true
Expand All @@ -89,6 +97,7 @@ QGCPopupDialog {
RowLayout {
id: editRow
spacing: ScreenTools.defaultFontPixelWidth
visible: !fact.readOnly

QGCTextField {
id: valueField
Expand Down Expand Up @@ -137,10 +146,15 @@ QGCPopupDialog {
}
}

QGCLabel {
visible: fact.readOnly
text: qsTr("Value: ") + fact.valueString + (fact.units != "" ? (" " + fact.units) : "")
}

Column {
id: bitmaskColumn
spacing: ScreenTools.defaultFontPixelHeight / 2
visible: fact.bitmaskStrings.length > 0
visible: fact.bitmaskStrings.length > 0 && !fact.readOnly

Repeater {
id: bitmaskRepeater
Expand Down Expand Up @@ -207,7 +221,7 @@ QGCPopupDialog {
wrapMode: Text.WordWrap
text: qsTr("Warning: Modifying values while vehicle is in flight can lead to vehicle instability and possible vehicle loss. ") +
qsTr("Make sure you know what you are doing and double-check your values before Save!")
visible: fact.componentId != -1
visible: fact.componentId != -1 && !fact.readOnly
}

QGCCheckBox {
Expand All @@ -219,7 +233,7 @@ QGCPopupDialog {
QGCCheckBox {
id: _advanced
text: qsTr("Advanced settings")
visible: showRCToParam || factCombo.visible || bitmaskColumn.visible
visible: !fact.readOnly && (showRCToParam || factCombo.visible || bitmaskColumn.visible)
}

// Checkbox to allow manual entry of enumerated or bitmask parameters
Expand Down
Loading