From d2b7b785bc3c48af8885de501067ae7c600b27f4 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Wed, 9 Aug 2017 14:27:24 -0700 Subject: [PATCH] Parameter force save and default disabled in non-advanced mode --- src/FactSystem/FactControls/FactTextField.qml | 2 +- src/QmlControls/ParameterEditorDialog.qml | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/FactSystem/FactControls/FactTextField.qml b/src/FactSystem/FactControls/FactTextField.qml index 71d795fb7..99c227d68 100644 --- a/src/FactSystem/FactControls/FactTextField.qml +++ b/src/FactSystem/FactControls/FactTextField.qml @@ -36,7 +36,7 @@ QGCTextField { fact.value = text } else { _validateString = text - qgcView.showDialog(validationErrorDialogComponent, qsTr("Invalid Value"), qgcView.showDialogDefaultWidth, StandardButton.Save) + qgcView.showDialog(validationErrorDialogComponent, qsTr("Invalid Value"), qgcView.showDialogDefaultWidth, StandardButton.Save | StandardButton.Cancel) } } else { fact.value = text diff --git a/src/QmlControls/ParameterEditorDialog.qml b/src/QmlControls/ParameterEditorDialog.qml index 5ec4dbb79..f3e76069e 100644 --- a/src/QmlControls/ParameterEditorDialog.qml +++ b/src/QmlControls/ParameterEditorDialog.qml @@ -11,6 +11,7 @@ import QtQuick 2.3 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.2 +import QGroundControl 1.0 import QGroundControl.Controls 1.0 import QGroundControl.Palette 1.0 import QGroundControl.Controllers 1.0 @@ -28,6 +29,9 @@ QGCViewDialog { property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 20 property bool _longDescriptionAvailable: fact.longDescription != "" + property bool _editingParameter: fact.componentId != 0 + property bool _allowForceSave: QGroundControl.corePlugin.showAdvancedUI || !_editingParameter + property bool _allowDefaultReset: fact.defaultValueAvailable && (QGroundControl.corePlugin.showAdvancedUI || !_editingParameter) ParameterEditorController { id: controller; factPanel: parent } @@ -49,11 +53,18 @@ QGCViewDialog { hideDialog() } else { validationError.text = errorString - forceSave.visible = true + if (_allowForceSave) { + forceSave.visible = true + } } } } + function reject() { + fact.valueChanged(fact.value) + hideDialog(); + } + function bitmaskValue() { var value = 0; for (var i = 0; i < fact.bitmaskValues.length; ++i) { @@ -68,7 +79,9 @@ QGCViewDialog { Component.onCompleted: { if (validate) { validationError.text = fact.validate(validateValue, false /* convertOnly */) - forceSave.visible = true + if (_allowForceSave) { + forceSave.visible = true + } } } @@ -109,7 +122,7 @@ QGCViewDialog { QGCButton { anchors.baseline: valueField.baseline - visible: fact.defaultValueAvailable + visible: _allowDefaultReset text: qsTr("Reset to default") onClicked: { @@ -195,7 +208,7 @@ QGCViewDialog { QGCLabel { text: qsTr("Default: ") + fact.defaultValueString - visible: fact.defaultValueAvailable + visible: _allowDefaultReset } } -- 2.22.0