From 4273d0c4a0ee000dbd38b341c0ae89457367b916 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Tue, 28 Apr 2015 16:42:32 -0700 Subject: [PATCH] New parameter editor - You can now cancel parameter change - Tablete friendly --- src/QmlControls/ParameterEditor.qml | 533 ++++++++++++---------- src/VehicleSetup/SetupParameterEditor.qml | 38 +- 2 files changed, 300 insertions(+), 271 deletions(-) diff --git a/src/QmlControls/ParameterEditor.qml b/src/QmlControls/ParameterEditor.qml index 6c242293b..aa9520f5d 100644 --- a/src/QmlControls/ParameterEditor.qml +++ b/src/QmlControls/ParameterEditor.qml @@ -43,7 +43,7 @@ Rectangle { QGCPalette { id: __qgcPal; colorGroupEnabled: true } ScreenTools { id: __screenTools } ParameterEditorController { id: __controller } - QGCLabel { id: __charWidth; text: "X"; visible: false } + QGCLabel { id: __textControl; text: "X"; visible: false } readonly property real __leftMargin: 10 readonly property real __rightMargin: 20 @@ -56,107 +56,247 @@ Rectangle { id: __exclusiveEditorGroup } -property Fact __propertiesDialogFact: Fact { } + property Fact __editorOverlayFact: Fact { } + property real __textHeight: __textControl.contentHeight + property real __textWidth: __textControl.contentWidth - Dialog { + Item { + id: editorOverlay - id: propertiesDialog - visible: false - title: "Parameter Properties" + anchors.fill: parent + visible: false + z: 100 - contentItem: Rectangle { + Rectangle { + width: __textWidth * 75 + height: parent.height + anchors.left: parent.left + anchors.right: editorDialog.left + opacity: 0.80 color: __qgcPal.window - implicitWidth: 500 - implicitHeight: longDescription.y + longDescription.height + 20 - - Grid { - id: grid - x: 10 - y: 10 - columns: 2 - spacing: 5 - - QGCLabel { - text: "Parameter:" - } - QGCLabel { - text: __propertiesDialogFact.name - } - QGCLabel { - text: "Group:" - } - QGCLabel { - text: __propertiesDialogFact.group - } - QGCLabel { - text: "Units:" - } - QGCLabel { - text: __propertiesDialogFact.units ? __propertiesDialogFact.units : "none" - } - QGCLabel { - text: "Default value:" - } - QGCLabel { - text: __propertiesDialogFact.defaultValueAvailable ? __propertiesDialogFact.defaultValue : "none" - } - QGCLabel { - text: "Minimum value:" - } - QGCLabel { - text: __propertiesDialogFact.min - } - QGCLabel { - text: "Maximum value:" - } - QGCLabel { - text: __propertiesDialogFact.max - } - QGCLabel { - text: "Description:" - } - QGCLabel { - text: __propertiesDialogFact.shortDescription ? __propertiesDialogFact.shortDescription : "none" - } - QGCLabel { - text: "Description (long):" + } + + Rectangle { + id: editorDialog + width: fullMode ? __textWidth * 50 : parent.width + height: parent.height + anchors.right: parent.right + color: __qgcPal.windowShadeDark + + Column { + spacing: __textHeight + anchors.fill: parent + + Rectangle { + width: parent.width + height: saveButton.height + color: __qgcPal.windowShade + + QGCLabel { + x: __textWidth + height: parent.height + verticalAlignment: Text.AlignVCenter + text: "Edit Parameter" + } + + QGCButton { + anchors.right: saveButton.left + anchors.bottom: parent.bottom + text: "Cancel" + + onClicked: { + editorOverlay.visible = false + } + } + + QGCButton { + id: saveButton + anchors.right: parent.right + primary: true + text: "Save" + + onClicked: { + __editorOverlayFact.value = valueField.text + editorOverlay.visible = false + } + } } - QGCLabel { - id: longDescription - width: 500 - 20 - x - wrapMode: Text.WordWrap - text: __propertiesDialogFact.longDescription ? __propertiesDialogFact.longDescription : "none" + + Column { + spacing: __textHeight + anchors.leftMargin: __textWidth * 2 + anchors.rightMargin: __textWidth + anchors.left: parent.left + anchors.right: parent.right + + QGCLabel { + width: parent.width + wrapMode: Text.WordWrap + text: __editorOverlayFact.shortDescription ? __editorOverlayFact.shortDescription : "Description missing" + } + + QGCLabel { + width: parent.width + wrapMode: Text.WordWrap + visible: __editorOverlayFact.longDescription + text: __editorOverlayFact.longDescription + } + + QGCTextField { + id: valueField + text: __editorOverlayFact.valueString + } + + QGCLabel { text: __editorOverlayFact.name } + + Row { + spacing: __textWidth + + QGCLabel { text: "Units:" } + QGCLabel { text: __editorOverlayFact.units ? __editorOverlayFact.units : "none" } + } + + Row { + spacing: __textWidth + + QGCLabel { text: "Minimum value:" } + QGCLabel { text: __editorOverlayFact.min } + } + + Row { + spacing: __textWidth + + QGCLabel { text: "Maxmimum value:" } + QGCLabel { text: __editorOverlayFact.max } + } + + Row { + spacing: __textWidth + + QGCLabel { text: "Default value:" } + QGCLabel { text: __editorOverlayFact.defaultValueAvailable ? __editorOverlayFact.defaultValue : "none" } + } } } } } - Column { - anchors.fill:parent + Component { + id: factRowsComponent - Row { - spacing: 10 - layoutDirection: Qt.RightToLeft - width: parent.width + Column { + id: factColumn + x: __leftMargin - QGCButton { - text: "Clear RC to Param" - onClicked: __controller.clearRCToParam() + QGCLabel { + height: __textHeight + (__screenTools.pixelSizeFactor * (9)) + text: group + verticalAlignment: Text.AlignVCenter + font.pointSize: __screenTools.fontPointFactor * (16); } - QGCButton { - text: "Save to file" - visible: fullMode - onClicked: __controller.saveToFile() + + Rectangle { + width: parent.width + height: 1 + color: __qgcPal.text } - QGCButton { - text: "Load from file" - visible: fullMode - onClicked: __controller.loadFromFile() + + Repeater { + model: __controller.getFactsForGroup(componentId, group) + + Column { + Item { + x: __leftMargin + width: parent.width + height: __textHeight + (__screenTools.pixelSizeFactor * (9)) + + Fact { id: modelFact; name: modelData + ":" + componentId } + + QGCLabel { + id: nameLabel + width: __textWidth * (__maxParamChars + 1) + height: parent.height + verticalAlignment: Text.AlignVCenter + text: modelFact.name + } + + QGCLabel { + id: valueLabel + width: __textWidth * 20 + height: parent.height + anchors.left: nameLabel.right + verticalAlignment: Text.AlignVCenter + color: modelFact.valueEqualsDefault ? __qgcPal.text : "orange" + text: modelFact.valueString + " " + modelFact.units + } + + QGCLabel { + height: parent.height + anchors.left: valueLabel.right + verticalAlignment: Text.AlignVCenter + visible: fullMode + text: modelFact.shortDescription + } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton + + onClicked: { + __editorOverlayFact = modelFact + editorOverlay.visible = true + } + } + } + + Rectangle { + x: __leftMargin + width: factColumn.width - __leftMargin - __rightMargin + height: 1 + color: __qgcPal.windowShade + } + } // Column - Fact + } // Repeater - Facts + } // Column - Facts + } // Component - factRowsComponent + + Column { + anchors.fill: parent + + Item { + width: parent.width + height: firstButton.height + + QGCLabel { + font.pointSize: __screenTools.fontPointFactor * (20) + visible: fullMode + text: "PARAMETER EDITOR" } - QGCButton { - id: firstButton - text: "Refresh" - onClicked: __controller.refresh() + + Row { + spacing: 10 + layoutDirection: Qt.RightToLeft + width: parent.width + + QGCButton { + text: "Clear RC to Param" + onClicked: __controller.clearRCToParam() + } + QGCButton { + text: "Save to file" + visible: fullMode + onClicked: __controller.saveToFile() + } + QGCButton { + text: "Load from file" + visible: fullMode + onClicked: __controller.loadFromFile() + } + QGCButton { + id: firstButton + text: "Refresh" + onClicked: __controller.refresh() + } } } @@ -166,156 +306,79 @@ property Fact __propertiesDialogFact: Fact { } width: 5 } - ScrollView { - id : scrollView - width: parent.width + Item { + width: parent.width height: parent.height - (lastSpacer.y + lastSpacer.height) - Column { - Repeater { - model: __controller.componentIds - - Column { - id: componentColumn - - property int componentId: parseInt(modelData) - - QGCLabel { - text: "Component #: " + componentId.toString() - font.pointSize: __screenTools.fontPointFactor * (16); - } - - Item { - height: 10 - width: 10 - } - - Repeater { - model: __controller.getGroupsForComponent(componentColumn.componentId) - - Column { - Rectangle { - id: groupRect - color: __qgcPal.windowShade - height: groupBlock.height - width: scrollView.viewport.width - __rightMargin - - Column { - id: groupBlock - - Rectangle { - color: __qgcPal.windowShadeDark - height: groupLabel.height - width: groupRect.width - - QGCLabel { - id: groupLabel - height: contentHeight + 5 - x: __leftMargin - text: modelData - verticalAlignment: Text.AlignVCenter - font.pointSize: __screenTools.fontPointFactor * (__qgcPal.defaultFontPointSize + 2); - } + ScrollView { + id : groupScroll + width: __textWidth * 25 + height: parent.height + + Column { + Repeater { + model: __controller.componentIds + + Column { + id: componentColumn + + readonly property int componentId: parseInt(modelData) + + QGCLabel { + height: contentHeight + (__screenTools.pixelSizeFactor * (9)) + text: "Component #: " + componentId.toString() + verticalAlignment: Text.AlignVCenter + font.pointSize: __screenTools.fontPointFactor * (16); + } + + Repeater { + model: __controller.getGroupsForComponent(componentColumn.componentId) + + Column { + QGCButton { + x: __leftMargin + width: groupScroll.width - __leftMargin - __rightMargin + text: modelData + + onClicked: { + factRowsLoader.sourceComponent = null + factRowsLoader.componentId = componentId + factRowsLoader.group = modelData + factRowsLoader.sourceComponent = factRowsComponent } - - Repeater { - model: __controller.getFactsForGroup(componentColumn.componentId, modelData) - - Row { - spacing: 10 - x: __leftMargin - - Fact { id: modelFact; name: modelData + ":" + componentColumn.componentId } - - QGCLabel { - text: modelFact.name - width: __charWidth.contentWidth * (__maxParamChars + 2) - } - - QGCLabel { - - text: modelFact.valueString + " " + modelFact.units - width: __charWidth.contentWidth * 20 - height: contentHeight - color: modelFact.valueEqualsDefault ? __qgcPal.text : "orange" - - Menu { - id: rightClickMenu - visible: false - - MenuItem { - id: resetToDefaultMenuItem - text: "Reset to default" - enabled: modelFact.defaultValueAvailable - onTriggered: modelFact.value = modelFact.defaultValue - } - MenuItem { - text: "Set RC to Param..." - onTriggered: __controller.setRCToParam(modelData) - } - MenuItem { - text: "Properties..." - onTriggered: { __propertiesDialogFact = modelFact; propertiesDialog.open() } - } - } - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - - onClicked: { - if (mouse.button == Qt.LeftButton) { - editor.checked = true - editor.focus = true - } else if (mouse.button == Qt.RightButton) { - rightClickMenu.popup() - } - } - } - - FactTextField { - id: editor - y: (parent.height - height) / 2 - width: parent.width - visible: checked - focus: true - fact: modelFact - showUnits: true - onEditingFinished: checked = false - - // We use an ExclusiveGroup to manage visibility - property bool checked: false - property ExclusiveGroup exclusiveGroup: __exclusiveEditorGroup - onExclusiveGroupChanged: { - if (exclusiveGroup) - exclusiveGroup.bindCheckable(editor) - } - } - } - - QGCLabel { - text: modelFact.shortDescription - visible: fullMode - } - } // Row - Fact value - } // Repeater - Facts - } // Column - Fact rows - } // Rectangle - Group - - Item { - height: 10 - width: 10 - } - } // Column - Group - } // Repeater - Groups - - Item { - height: 10 - width: 10 - } - } // Column - Component - } // Repeater - Components - } // Column - Component - } // ScrollView + } + + Item { + width: 1 + height: __screenTools.pixelSizeFactor * (3) + } + } // Column - Group + } // Repeater - Groups + + Item { + height: 10 + width: 10 + } + } // Column - Component + } // Repeater - Components + } // Column - Component + } // ScrollView - Groups + + ScrollView { + id: factScrollView + anchors.left: groupScroll.right + anchors.right: parent.right + height: parent.height + + Loader { + id: factRowsLoader + width: factScrollView.width + + property int componentId: __controller.componentIds[0] + property string group: __controller.getGroupsForComponent(__controller.componentIds[0])[0] + sourceComponent: factRowsComponent + } + } // ScrollView - Facts + } // Item - Group ScrollView + Facts } // Column - Outer } diff --git a/src/VehicleSetup/SetupParameterEditor.qml b/src/VehicleSetup/SetupParameterEditor.qml index e4c708e93..5856f086b 100644 --- a/src/VehicleSetup/SetupParameterEditor.qml +++ b/src/VehicleSetup/SetupParameterEditor.qml @@ -28,40 +28,6 @@ import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 import QGroundControl.Palette 1.0 -Rectangle { - QGCPalette { id: qgcPal; colorGroupEnabled: true } - ScreenTools { id: screenTools } - - color: qgcPal.window - - // We use an ExclusiveGroup to maintain the visibility of a single editing control at a time - ExclusiveGroup { - id: exclusiveEditorGroup - } - - Column { - anchors.fill:parent - - QGCLabel { - text: "PARAMETER EDITOR" - font.pointSize: screenTools.fontPointFactor * (20) - } - - Item { - height: 20 - width: 5 - } - - QGCLabel { - id: infoLabel - width: parent.width - wrapMode: Text.WordWrap - text: "Click a parameter value to modify. Right-click for additional options. Values which have been modified from the default are shown in orange. Use caution when modifying parameters here since the values are not checked for validity." - } - - ParameterEditor { - width: parent.width - height: parent.height - (infoLabel.y + infoLabel.height) - } - } +ParameterEditor { + fullMode: true } -- 2.22.0