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,83 +56,222 @@ Rectangle { ...@@ -56,83 +56,222 @@ 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 {
id: editorDialog
width: fullMode ? __textWidth * 50 : parent.width
height: parent.height
anchors.right: parent.right
color: __qgcPal.windowShadeDark
Grid { Column {
id: grid spacing: __textHeight
x: 10 anchors.fill: parent
y: 10
columns: 2 Rectangle {
spacing: 5 width: parent.width
height: saveButton.height
color: __qgcPal.windowShade
QGCLabel { QGCLabel {
text: "Parameter:" x: __textWidth
height: parent.height
verticalAlignment: Text.AlignVCenter
text: "Edit Parameter"
} }
QGCLabel {
text: __propertiesDialogFact.name QGCButton {
anchors.right: saveButton.left
anchors.bottom: parent.bottom
text: "Cancel"
onClicked: {
editorOverlay.visible = false
} }
QGCLabel {
text: "Group:"
} }
QGCLabel {
text: __propertiesDialogFact.group QGCButton {
id: saveButton
anchors.right: parent.right
primary: true
text: "Save"
onClicked: {
__editorOverlayFact.value = valueField.text
editorOverlay.visible = false
} }
QGCLabel {
text: "Units:"
} }
QGCLabel {
text: __propertiesDialogFact.units ? __propertiesDialogFact.units : "none"
} }
Column {
spacing: __textHeight
anchors.leftMargin: __textWidth * 2
anchors.rightMargin: __textWidth
anchors.left: parent.left
anchors.right: parent.right
QGCLabel { QGCLabel {
text: "Default value:" width: parent.width
wrapMode: Text.WordWrap
text: __editorOverlayFact.shortDescription ? __editorOverlayFact.shortDescription : "Description missing"
} }
QGCLabel { QGCLabel {
text: __propertiesDialogFact.defaultValueAvailable ? __propertiesDialogFact.defaultValue : "none" width: parent.width
wrapMode: Text.WordWrap
visible: __editorOverlayFact.longDescription
text: __editorOverlayFact.longDescription
} }
QGCLabel {
text: "Minimum value:" QGCTextField {
id: valueField
text: __editorOverlayFact.valueString
} }
QGCLabel {
text: __propertiesDialogFact.min 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" }
} }
QGCLabel {
text: "Maximum value:"
} }
QGCLabel {
text: __propertiesDialogFact.max
} }
}
}
Component {
id: factRowsComponent
Column {
id: factColumn
x: __leftMargin
QGCLabel { QGCLabel {
text: "Description:" height: __textHeight + (__screenTools.pixelSizeFactor * (9))
text: group
verticalAlignment: Text.AlignVCenter
font.pointSize: __screenTools.fontPointFactor * (16);
}
Rectangle {
width: parent.width
height: 1
color: __qgcPal.text
} }
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 { QGCLabel {
text: __propertiesDialogFact.shortDescription ? __propertiesDialogFact.shortDescription : "none" id: nameLabel
width: __textWidth * (__maxParamChars + 1)
height: parent.height
verticalAlignment: Text.AlignVCenter
text: modelFact.name
} }
QGCLabel { QGCLabel {
text: "Description (long):" 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 { QGCLabel {
id: longDescription height: parent.height
width: 500 - 20 - x anchors.left: valueLabel.right
wrapMode: Text.WordWrap verticalAlignment: Text.AlignVCenter
text: __propertiesDialogFact.longDescription ? __propertiesDialogFact.longDescription : "none" 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 { Column {
anchors.fill:parent anchors.fill: parent
Item {
width: parent.width
height: firstButton.height
QGCLabel {
font.pointSize: __screenTools.fontPointFactor * (20)
visible: fullMode
text: "PARAMETER EDITOR"
}
Row { Row {
spacing: 10 spacing: 10
...@@ -159,6 +298,7 @@ property Fact __propertiesDialogFact: Fact { } ...@@ -159,6 +298,7 @@ property Fact __propertiesDialogFact: Fact { }
onClicked: __controller.refresh() onClicked: __controller.refresh()
} }
} }
}
Item { Item {
id: lastSpacer id: lastSpacer
...@@ -166,11 +306,15 @@ property Fact __propertiesDialogFact: Fact { } ...@@ -166,11 +306,15 @@ 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)
ScrollView {
id : groupScroll
width: __textWidth * 25
height: parent.height
Column { Column {
Repeater { Repeater {
model: __controller.componentIds model: __controller.componentIds
...@@ -178,133 +322,35 @@ property Fact __propertiesDialogFact: Fact { } ...@@ -178,133 +322,35 @@ property Fact __propertiesDialogFact: Fact { }
Column { Column {
id: componentColumn id: componentColumn
property int componentId: parseInt(modelData) readonly property int componentId: parseInt(modelData)
QGCLabel { QGCLabel {
height: contentHeight + (__screenTools.pixelSizeFactor * (9))
text: "Component #: " + componentId.toString() text: "Component #: " + componentId.toString()
verticalAlignment: Text.AlignVCenter
font.pointSize: __screenTools.fontPointFactor * (16); font.pointSize: __screenTools.fontPointFactor * (16);
} }
Item {
height: 10
width: 10
}
Repeater { Repeater {
model: __controller.getGroupsForComponent(componentColumn.componentId) model: __controller.getGroupsForComponent(componentColumn.componentId)
Column { Column {
Rectangle { QGCButton {
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 x: __leftMargin
width: groupScroll.width - __leftMargin - __rightMargin
text: modelData text: modelData
verticalAlignment: Text.AlignVCenter
font.pointSize: __screenTools.fontPointFactor * (__qgcPal.defaultFontPointSize + 2);
}
}
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: { onClicked: {
if (mouse.button == Qt.LeftButton) { factRowsLoader.sourceComponent = null
editor.checked = true factRowsLoader.componentId = componentId
editor.focus = true factRowsLoader.group = modelData
} else if (mouse.button == Qt.RightButton) { factRowsLoader.sourceComponent = factRowsComponent
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 { Item {
height: 10 width: 1
width: 10 height: __screenTools.pixelSizeFactor * (3)
} }
} // Column - Group } // Column - Group
} // Repeater - Groups } // Repeater - Groups
...@@ -316,6 +362,23 @@ property Fact __propertiesDialogFact: Fact { } ...@@ -316,6 +362,23 @@ property Fact __propertiesDialogFact: Fact { }
} // Column - Component } // Column - Component
} // Repeater - Components } // Repeater - Components
} // Column - Component } // Column - Component
} // ScrollView } // 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 } // 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