Commit 4d3dd793 authored by Don Gagne's avatar Don Gagne

ViewWithDialog -> QGCView

- More more on making QGCView real
- Converted Parameter Editor to QGCView
parent ccc5f622
......@@ -32,7 +32,10 @@
<file alias="QGroundControl/Controls/VehicleSummaryRow.qml">src/QmlControls/VehicleSummaryRow.qml</file>
<file alias="QGroundControl/Controls/arrow-down.png">src/QmlControls/arrow-down.png</file>
<file alias="QGroundControl/Controls/ViewWidget.qml">src/ViewWidgets/ViewWidget.qml</file>
<file alias="QGroundControl/Controls/ViewWithDialog.qml">src/QmlControls/ViewWithDialog.qml</file>
<file alias="QGroundControl/Controls/QGCView.qml">src/QmlControls/QGCView.qml</file>
<file alias="QGroundControl/Controls/QGCViewPanel.qml">src/QmlControls/QGCViewPanel.qml</file>
<file alias="QGroundControl/Controls/QGCViewDialog.qml">src/QmlControls/QGCViewDialog.qml</file>
<file alias="QGroundControl/Controls/ParameterEditor.qml">src/QmlControls/ParameterEditor.qml</file>
......
......@@ -32,7 +32,8 @@ import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Controllers 1.0
ViewWithDialog {
QGCView {
id: rootQGCView
viewComponent: view
Component {
......@@ -45,11 +46,15 @@ ViewWithDialog {
signal showDialog(Component component, string title, int charWidth, int buttons)
signal hideDialog
function doWorkAfterComponentCompleted() {
Connections {
target: rootQGCView
onCompleted: {
if (controller.showCustomConfigPanel) {
panel.showDialog(customConfigDialog, "Custom Airframe Config", 50, StandardButton.Reset)
}
}
}
AirframeComponentController {
id: controller
......
......@@ -36,179 +36,30 @@ import QGroundControl.Controllers 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
Rectangle {
QGCView {
viewComponent: parameterList
/// true: show full information, false: for use in smaller widgets
property bool fullMode: true
QGCPalette { id: __qgcPal; colorGroupEnabled: true }
ParameterEditorController { id: __controller }
QGCLabel { id: __textControl; text: "X"; visible: false }
QGCLabel { id: __textMeasure; text: "X"; visible: false }
property Fact __editorDialogFact: Fact { }
readonly property real __leftMargin: 10
readonly property real __rightMargin: 20
readonly property int __maxParamChars: 16
color: __qgcPal.window
// We use an ExclusiveGroup to maintain the visibility of a single editing control at a time
ExclusiveGroup {
id: __exclusiveEditorGroup
}
property Fact __editorOverlayFact: Fact { }
property real __textHeight: __textControl.contentHeight
property real __textWidth: __textControl.contentWidth
Item {
id: __editorOverlay
anchors.fill: parent
visible: false
z: 100
Rectangle {
width: __textWidth * 75
height: parent.height
anchors.left: parent.left
anchors.right: editorDialog.left
opacity: 0.80
color: __qgcPal.window
}
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
}
}
}
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" }
}
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
text: "Warning: Modifying parameters while vehicle is in flight can lead to vehicle instability and possible vehicle loss. " +
"Make sure you know what you are doing and double-check your values before Save!"
}
} // Column - Fact information
} // Column - Header + Fact information
property real __textHeight: __textMeasure.contentHeight
property real __textWidth: __textMeasure.contentWidth
QGCButton {
anchors.rightMargin: __textWidth
anchors.right: rcButton.left
anchors.bottom: parent.bottom
visible: __editorOverlayFact.defaultValueAvailable
text: "Reset to default"
Component {
id: parameterList
onClicked: {
__editorOverlayFact.value = __editorOverlayFact.defaultValue
__editorOverlay.visible = false
}
}
QGCButton {
id: rcButton
anchors.right: parent.right
anchors.bottom: parent.bottom
visible: __editorOverlayFact.defaultValueAvailable
text: "Set RC to Param..."
onClicked: __controller.setRCToParam(__editorOverlayFact.name)
}
} // Rectangle - editorDialog
} // Item - editorOverlay
QGCViewPanel {
id: panel
Component {
id: factRowsComponent
......@@ -278,8 +129,8 @@ Rectangle {
acceptedButtons: Qt.LeftButton
onClicked: {
__editorOverlayFact = modelFact
__editorOverlay.visible = true
__editorDialogFact = modelFact
panel.showDialog(editorDialogComponent, "Parameter Editor", fullMode ? 50 : -1, StandardButton.Cancel | StandardButton.Save)
}
}
}
......@@ -416,4 +267,105 @@ Rectangle {
} // ScrollView - Facts
} // Item - Group ScrollView + Facts
} // Column - Outer
}
}
} // Component - Parameter List
Component {
id: editorDialogComponent
QGCViewDialog {
id: editorDialog
property bool fullMode: true
function accept() {
__editorDialogFact.value = valueField.text
editorDialog.hideDialog()
}
Column {
spacing: __textHeight
anchors.left: parent.left
anchors.right: parent.right
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
text: __editorDialogFact.shortDescription ? __editorDialogFact.shortDescription : "Description missing"
}
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
visible: __editorDialogFact.longDescription
text: __editorDialogFact.longDescription
}
QGCTextField {
id: valueField
text: __editorDialogFact.valueString
}
QGCLabel { text: __editorDialogFact.name }
Row {
spacing: __textWidth
QGCLabel { text: "Units:" }
QGCLabel { text: __editorDialogFact.units ? __editorDialogFact.units : "none" }
}
Row {
spacing: __textWidth
QGCLabel { text: "Minimum value:" }
QGCLabel { text: __editorDialogFact.min }
}
Row {
spacing: __textWidth
QGCLabel { text: "Maxmimum value:" }
QGCLabel { text: __editorDialogFact.max }
}
Row {
spacing: __textWidth
QGCLabel { text: "Default value:" }
QGCLabel { text: __editorDialogFact.defaultValueAvailable ? __editorDialogFact.defaultValue : "none" }
}
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
text: "Warning: Modifying parameters while vehicle is in flight can lead to vehicle instability and possible vehicle loss. " +
"Make sure you know what you are doing and double-check your values before Save!"
}
} // Column - Fact information
QGCButton {
anchors.rightMargin: __textWidth
anchors.right: rcButton.left
anchors.bottom: parent.bottom
visible: __editorDialogFact.defaultValueAvailable
text: "Reset to default"
onClicked: {
__editorDialogFact.value = __editorDialogFact.defaultValue
editorDialog.hideDialog()
}
}
QGCButton {
id: rcButton
anchors.right: parent.right
anchors.bottom: parent.bottom
visible: __editorDialogFact.defaultValueAvailable
text: "Set RC to Param..."
onClicked: __controller.setRCToParam(__editorDialogFact.name)
}
} // Rectangle - editorDialog
} // Component - Editor Dialog
} // QGCView
\ No newline at end of file
......@@ -35,14 +35,22 @@ import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
Item {
id: __rootItem
property Component viewComponent
/// This is signalled when the top level Item reaches Component.onCompleted. This allows
/// the view subcomponent to connect to this signal and do work once the full ui is ready
/// to go.
signal completed
function __showDialog(component, title, charWidth, buttons) {
__acceptButton.visible = false
__rejectButton.visible = false
__dialogCharWidth = charWidth
__dialogTitle = title
// Accept role buttons
if (buttons & StandardButton.Ok) {
__acceptButton.text = "Ok"
__acceptButton.visible = true
......@@ -52,12 +60,6 @@ Item {
} else if (buttons & StandardButton.Save) {
__acceptButton.text = "Save"
__acceptButton.visible = true
} else if (buttons & StandardButton.Cancel) {
__rejectButton.text = "Cancel"
__rejectButton.visible = true
} else if (buttons & StandardButton.Close) {
__rejectButton.text = "Cancel"
__rejectButton.visible = true
} else if (buttons & StandardButton.Apply) {
__acceptButton.text = "Apply"
__acceptButton.visible = true
......@@ -73,15 +75,6 @@ Item {
} else if (buttons & StandardButton.YesToAll) {
__acceptButton.text = "Yes to All"
__acceptButton.visible = true
} else if (buttons & StandardButton.No) {
__rejectButton.text = "No"
__rejectButton.visible = true
} else if (buttons & StandardButton.NoToAll) {
__rejectButton.text = "No to All"
__rejectButton.visible = true
} else if (buttons & StandardButton.Abort) {
__rejectButton.text = "Abort"
__rejectButton.visible = true
} else if (buttons & StandardButton.Retry) {
__acceptButton.text = "Retry"
__acceptButton.visible = true
......@@ -95,6 +88,25 @@ Item {
__acceptButton.text = "Ignore"
__acceptButton.visible = true
}
// Reject role buttons
if (buttons & StandardButton.Cancel) {
__rejectButton.text = "Cancel"
__rejectButton.visible = true
} else if (buttons & StandardButton.Close) {
__rejectButton.text = "Cancel"
__rejectButton.visible = true
} else if (buttons & StandardButton.No) {
__rejectButton.text = "No"
__rejectButton.visible = true
} else if (buttons & StandardButton.NoToAll) {
__rejectButton.text = "No to All"
__rejectButton.visible = true
} else if (buttons & StandardButton.Abort) {
__rejectButton.text = "Abort"
__rejectButton.visible = true
}
__dialogComponent = component
__viewPanel.enabled = false
__dialogOverlay.visible = true
......@@ -120,7 +132,7 @@ Item {
property Component __dialogComponent
Component.onCompleted: __viewPanel.item.doWorkAfterComponentCompleted()
Component.onCompleted: completed()
Connections {
target: __viewPanel.item
......@@ -161,7 +173,7 @@ Item {
// This is the main dialog panel which is anchored to the right edge
Rectangle {
id: __dialogPanel
width: __textWidth * __dialogCharWidth
width: __dialogCharWidth == -1 ? parent.width : __textWidth * __dialogCharWidth
height: parent.height
anchors.right: parent.right
color: __qgcPal.windowShadeDark
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
import QtQuick 2.3
import QtQuick.Controls 1.3
import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
Rectangle {
QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
signal hideDialog
function accept() {
hideDialog()
}
function reject() {
hideDialog()
}
color: qgcPal.windowShadeDark
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
import QtQuick 2.3
import QtQuick.Controls 1.3
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
Rectangle {
QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
signal showDialog(Component component, string title, int charWidth, int buttons)
signal hideDialog
color: qgcPal.window
}
......@@ -16,5 +16,8 @@ VehicleRotationCal 1.0 VehicleRotationCal.qml
VehicleSummaryRow 1.0 VehicleSummaryRow.qml
ParameterEditor 1.0 ParameterEditor.qml
ViewWidget 1.0 ViewWidget.qml
ViewWithDialog 1.0 ViewWithDialog.qml
QGCView 1.0 QGCView.qml
QGCViewPanel 1.0 QGCViewPanel.qml
QGCViewDialog 1.0 QGCViewDialog.qml
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