diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index 6136453..93c3e0b 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -77,7 +77,6 @@
src/VehicleSetup/PX4FlowSensor.qml
src/FlightMap/Widgets/QGCInstrumentWidget.qml
src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml
- src/QmlControls/QGCViewDialogContainer.qml
src/AnalyzeView/AnalyzePage.qml
src/QmlControls/AppMessages.qml
src/QmlControls/AxisMonitor.qml
@@ -162,6 +161,7 @@
src/QmlControls/QGCToolBarButton.qml
src/QmlControls/QGCToolInsets.qml
src/QmlControls/QGCViewDialog.qml
+ src/QmlControls/QGCViewDialogContainer.qml
src/QmlControls/QGCViewMessage.qml
src/QmlControls/QGroundControl/Controls/qmldir
src/PlanView/RallyPointEditorHeader.qml
diff --git a/src/QmlControls/QGCViewDialog.qml b/src/QmlControls/QGCViewDialog.qml
index f593c60..b2878aa 100644
--- a/src/QmlControls/QGCViewDialog.qml
+++ b/src/QmlControls/QGCViewDialog.qml
@@ -9,6 +9,7 @@
import QtQuick 2.3
import QtQuick.Controls 1.2
+import QtQuick.Dialogs 1.3
import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
@@ -17,6 +18,7 @@ import QGroundControl.FactControls 1.0
import QGroundControl.ScreenTools 1.0
Item {
+ property var buttons: StandardButton.NoButton
signal hideDialog
diff --git a/src/QmlControls/QGCViewDialogContainer.qml b/src/QmlControls/QGCViewDialogContainer.qml
index bad30fc..a2b205a 100644
--- a/src/QmlControls/QGCViewDialogContainer.qml
+++ b/src/QmlControls/QGCViewDialogContainer.qml
@@ -15,16 +15,20 @@ import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0
-Item {
- anchors.fill: parent
+Drawer {
+ edge: Qt.RightEdge
+ interactive: false
+
+ property var dialogComponent
+ property string dialogTitle
+ property var dialogButtons: StandardButton.NoButton
property real _defaultTextHeight: _textMeasure.contentHeight
property real _defaultTextWidth: _textMeasure.contentWidth
- function setupDialogButtons() {
+ function setupDialogButtons(buttons) {
_acceptButton.visible = false
_rejectButton.visible = false
- var buttons = mainWindowDialog.dialogButtons
// Accept role buttons
if (buttons & StandardButton.Ok) {
_acceptButton.text = qsTr("Ok")
@@ -81,18 +85,33 @@ Item {
_rejectButton.text = qsTr("Abort")
_rejectButton.visible = true
}
+
+ if (buttons & StandardButton.Cancel || buttons & StandardButton.Close || buttons & StandardButton.Discard || buttons & StandardButton.Abort || buttons & StandardButton.Ignore) {
+ closePolicy = Popup.NoAutoClose;
+ interactive = false;
+ } else {
+ closePolicy = Popup.CloseOnEscape | Popup.CloseOnPressOutside;
+ interactive = true;
+ }
}
Connections {
target: _dialogComponentLoader.item
onHideDialog: {
Qt.inputMethod.hide()
- mainWindowDialog.close()
+ close()
}
}
+ Component.onCompleted: setupDialogButtons(dialogButtons)
+
QGCLabel { id: _textMeasure; text: "X"; visible: false }
+
+ background: Rectangle {
+ color: qgcPal.windowShadeDark
+ }
+
// This is the main dialog panel
Item {
id: _dialogPanel
@@ -103,9 +122,8 @@ Item {
height: _acceptButton.visible ? _acceptButton.height : _rejectButton.height
color: qgcPal.windowShade
QGCLabel {
- id: titleLabel
x: _defaultTextWidth
- text: mainWindowDialog.dialogTitle
+ text: dialogTitle
height: parent.height
verticalAlignment: Text.AlignVCenter
}
@@ -136,7 +154,7 @@ Item {
anchors.right: parent.right
anchors.top: _spacer.bottom
anchors.bottom: parent.bottom
- sourceComponent: mainWindowDialog.dialogComponent
+ sourceComponent: dialogComponent
focus: true
property bool acceptAllowed: _acceptButton.visible
property bool rejectAllowed: _rejectButton.visible
diff --git a/src/ui/MainRootWindow.qml b/src/ui/MainRootWindow.qml
index 96010ba..bf305fe 100644
--- a/src/ui/MainRootWindow.qml
+++ b/src/ui/MainRootWindow.qml
@@ -196,52 +196,18 @@ ApplicationWindow {
readonly property int showDialogDefaultWidth: 40 ///< Use for default dialog width
function showComponentDialog(component, title, charWidth, buttons) {
- if (mainWindowDialog.visible) {
- console.warn(("showComponentDialog called while dialog is already visible"))
- return
- }
var dialogWidth = charWidth === showDialogFullWidth ? mainWindow.width : ScreenTools.defaultFontPixelWidth * charWidth
- mainWindowDialog.width = dialogWidth
- mainWindowDialog.dialogComponent = component
- mainWindowDialog.dialogTitle = title
- mainWindowDialog.dialogButtons = buttons
+ var dialog = dialogDrawerComponent.createObject(mainWindow, { width: dialogWidth, dialogComponent: component, dialogTitle: title, dialogButtons: buttons })
mainWindow.pushPreventViewSwitch()
- mainWindowDialog.open()
- if (buttons & StandardButton.Cancel || buttons & StandardButton.Close || buttons & StandardButton.Discard || buttons & StandardButton.Abort || buttons & StandardButton.Ignore) {
- mainWindowDialog.closePolicy = Popup.NoAutoClose;
- mainWindowDialog.interactive = false;
- } else {
- mainWindowDialog.closePolicy = Popup.CloseOnEscape | Popup.CloseOnPressOutside;
- mainWindowDialog.interactive = true;
- }
+ dialog.open()
}
- Drawer {
- id: mainWindowDialog
- y: mainWindow.header.height
- height: mainWindow.height - mainWindow.header.height
- edge: Qt.RightEdge
- interactive: false
- background: Rectangle {
- color: qgcPal.windowShadeDark
- }
- property var dialogComponent: null
- property var dialogButtons: null
- property string dialogTitle: ""
- Loader {
- id: dlgLoader
- anchors.fill: parent
- onLoaded: {
- item.setupDialogButtons()
- }
- }
- onOpened: {
- dlgLoader.source = "QGCViewDialogContainer.qml"
- }
- onClosed: {
- //console.log("View switch ok")
- mainWindow.popPreventViewSwitch()
- dlgLoader.source = ""
+ Component {
+ id: dialogDrawerComponent
+ QGCViewDialogContainer {
+ y: mainWindow.header.height
+ height: mainWindow.height - mainWindow.header.height
+ onClosed: mainWindow.popPreventViewSwitch()
}
}