Commit 4273d0c4 authored by Don Gagne's avatar Don Gagne

New parameter editor

- You can now cancel parameter change
- Tablete friendly
parent df144d9e
...@@ -43,7 +43,7 @@ Rectangle { ...@@ -43,7 +43,7 @@ Rectangle {
QGCPalette { id: __qgcPal; colorGroupEnabled: true } QGCPalette { id: __qgcPal; colorGroupEnabled: true }
ScreenTools { id: __screenTools } ScreenTools { id: __screenTools }
ParameterEditorController { id: __controller } 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 __leftMargin: 10
readonly property real __rightMargin: 20 readonly property real __rightMargin: 20
...@@ -56,107 +56,247 @@ Rectangle { ...@@ -56,107 +56,247 @@ Rectangle {
id: __exclusiveEditorGroup 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 anchors.fill: parent
visible: false visible: false
title: "Parameter Properties" 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 color: __qgcPal.window
implicitWidth: 500 }
implicitHeight: longDescription.y + longDescription.height + 20
Rectangle {
Grid { id: editorDialog
id: grid width: fullMode ? __textWidth * 50 : parent.width
x: 10 height: parent.height
y: 10 anchors.right: parent.right
columns: 2 color: __qgcPal.windowShadeDark
spacing: 5
Column {
QGCLabel { spacing: __textHeight
text: "Parameter:" anchors.fill: parent
}
QGCLabel { Rectangle {
text: __propertiesDialogFact.name width: parent.width
} height: saveButton.height
QGCLabel { color: __qgcPal.windowShade
text: "Group:"
} QGCLabel {
QGCLabel { x: __textWidth
text: __propertiesDialogFact.group height: parent.height
} verticalAlignment: Text.AlignVCenter
QGCLabel { text: "Edit Parameter"
text: "Units:" }
}
QGCLabel { QGCButton {
text: __propertiesDialogFact.units ? __propertiesDialogFact.units : "none" anchors.right: saveButton.left
} anchors.bottom: parent.bottom
QGCLabel { text: "Cancel"
text: "Default value:"
} onClicked: {
QGCLabel { editorOverlay.visible = false
text: __propertiesDialogFact.defaultValueAvailable ? __propertiesDialogFact.defaultValue : "none" }
} }
QGCLabel {
text: "Minimum value:" QGCButton {
} id: saveButton
QGCLabel { anchors.right: parent.right
text: __propertiesDialogFact.min primary: true
} text: "Save"
QGCLabel {
text: "Maximum value:" onClicked: {
} __editorOverlayFact.value = valueField.text
QGCLabel { editorOverlay.visible = false
text: __propertiesDialogFact.max }
} }
QGCLabel {
text: "Description:"
}
QGCLabel {
text: __propertiesDialogFact.shortDescription ? __propertiesDialogFact.shortDescription : "none"
}
QGCLabel {
text: "Description (long):"
} }
QGCLabel {
id: longDescription Column {
width: 500 - 20 - x spacing: __textHeight
wrapMode: Text.WordWrap anchors.leftMargin: __textWidth * 2
text: __propertiesDialogFact.longDescription ? __propertiesDialogFact.longDescription : "none" 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 { Component {
anchors.fill:parent id: factRowsComponent
Row { Column {
spacing: 10 id: factColumn
layoutDirection: Qt.RightToLeft x: __leftMargin
width: parent.width
QGCButton { QGCLabel {
text: "Clear RC to Param" height: __textHeight + (__screenTools.pixelSizeFactor * (9))
onClicked: __controller.clearRCToParam() text: group
verticalAlignment: Text.AlignVCenter
font.pointSize: __screenTools.fontPointFactor * (16);
} }
QGCButton {
text: "Save to file" Rectangle {
visible: fullMode width: parent.width
onClicked: __controller.saveToFile() height: 1
color: __qgcPal.text
} }
QGCButton {
text: "Load from file" Repeater {
visible: fullMode model: __controller.getFactsForGroup(componentId, group)
onClicked: __controller.loadFromFile()
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 Row {
text: "Refresh" spacing: 10
onClicked: __controller.refresh() 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 { } ...@@ -166,156 +306,79 @@ property Fact __propertiesDialogFact: Fact { }
width: 5 width: 5
} }
ScrollView { Item {
id : scrollView width: parent.width
width: parent.width
height: parent.height - (lastSpacer.y + lastSpacer.height) height: parent.height - (lastSpacer.y + lastSpacer.height)
Column { ScrollView {
Repeater { id : groupScroll
model: __controller.componentIds width: __textWidth * 25
height: parent.height
Column {
id: componentColumn Column {
Repeater {
property int componentId: parseInt(modelData) model: __controller.componentIds
QGCLabel { Column {
text: "Component #: " + componentId.toString() id: componentColumn
font.pointSize: __screenTools.fontPointFactor * (16);
} readonly property int componentId: parseInt(modelData)
Item { QGCLabel {
height: 10 height: contentHeight + (__screenTools.pixelSizeFactor * (9))
width: 10 text: "Component #: " + componentId.toString()
} verticalAlignment: Text.AlignVCenter
font.pointSize: __screenTools.fontPointFactor * (16);
Repeater { }
model: __controller.getGroupsForComponent(componentColumn.componentId)
Repeater {
Column { model: __controller.getGroupsForComponent(componentColumn.componentId)
Rectangle {
id: groupRect Column {
color: __qgcPal.windowShade QGCButton {
height: groupBlock.height x: __leftMargin
width: scrollView.viewport.width - __rightMargin width: groupScroll.width - __leftMargin - __rightMargin
text: modelData
Column {
id: groupBlock onClicked: {
factRowsLoader.sourceComponent = null
Rectangle { factRowsLoader.componentId = componentId
color: __qgcPal.windowShadeDark factRowsLoader.group = modelData
height: groupLabel.height factRowsLoader.sourceComponent = factRowsComponent
width: groupRect.width
QGCLabel {
id: groupLabel
height: contentHeight + 5
x: __leftMargin
text: modelData
verticalAlignment: Text.AlignVCenter
font.pointSize: __screenTools.fontPointFactor * (__qgcPal.defaultFontPointSize + 2);
}
} }
}
Repeater {
model: __controller.getFactsForGroup(componentColumn.componentId, modelData) Item {
width: 1
Row { height: __screenTools.pixelSizeFactor * (3)
spacing: 10 }
x: __leftMargin } // Column - Group
} // Repeater - Groups
Fact { id: modelFact; name: modelData + ":" + componentColumn.componentId }
Item {
QGCLabel { height: 10
text: modelFact.name width: 10
width: __charWidth.contentWidth * (__maxParamChars + 2) }
} } // Column - Component
} // Repeater - Components
QGCLabel { } // Column - Component
} // ScrollView - Groups
text: modelFact.valueString + " " + modelFact.units
width: __charWidth.contentWidth * 20 ScrollView {
height: contentHeight id: factScrollView
color: modelFact.valueEqualsDefault ? __qgcPal.text : "orange" anchors.left: groupScroll.right
anchors.right: parent.right
Menu { height: parent.height
id: rightClickMenu
visible: false Loader {
id: factRowsLoader
MenuItem { width: factScrollView.width
id: resetToDefaultMenuItem
text: "Reset to default" property int componentId: __controller.componentIds[0]
enabled: modelFact.defaultValueAvailable property string group: __controller.getGroupsForComponent(__controller.componentIds[0])[0]
onTriggered: modelFact.value = modelFact.defaultValue sourceComponent: factRowsComponent
} }
MenuItem { } // ScrollView - Facts
text: "Set RC to Param..." } // Item - Group ScrollView + Facts
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
} // Column - Outer } // Column - Outer
} }
...@@ -28,40 +28,6 @@ import QGroundControl.Controls 1.0 ...@@ -28,40 +28,6 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
Rectangle { ParameterEditor {
QGCPalette { id: qgcPal; colorGroupEnabled: true } fullMode: 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)
}
}
} }
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