Commit c2d5bb78 authored by Don Gagne's avatar Don Gagne

Fork window close handling for Native/Hybrid

parent 256a5ab7
...@@ -23,6 +23,7 @@ along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>. ...@@ -23,6 +23,7 @@ along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
import QtQuick 2.5 import QtQuick 2.5
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QGroundControl.Controls 1.0 import QGroundControl.Controls 1.0
...@@ -41,7 +42,7 @@ Item { ...@@ -41,7 +42,7 @@ Item {
} }
function showWindowCloseMessage() { function showWindowCloseMessage() {
mainWindowInner.item.showWindowCloseMessage() windowCloseDialog.open()
} }
// The following are use for unit testing only // The following are use for unit testing only
...@@ -71,5 +72,16 @@ Item { ...@@ -71,5 +72,16 @@ Item {
anchors.fill: parent anchors.fill: parent
source: "MainWindowInner.qml" source: "MainWindowInner.qml"
} }
MessageDialog {
id: windowCloseDialog
title: "QGroundControl close"
text: "There are still active connections to vehicles. Do you want to disconnect these before closing?"
standardButtons: StandardButton.Yes | StandardButton.Cancel
modality: Qt.ApplicationModal
visible: false
onYes: controller.acceptWindowClose()
}
} }
...@@ -64,7 +64,7 @@ Item { ...@@ -64,7 +64,7 @@ Item {
flightView.visible = true flightView.visible = true
setupViewLoader.visible = false setupViewLoader.visible = false
planViewLoader.visible = false planViewLoader.visible = false
toolbar.checkFlyButton() toolBar.checkFlyButton()
} }
function showPlanView() { function showPlanView() {
...@@ -93,10 +93,6 @@ Item { ...@@ -93,10 +93,6 @@ Item {
toolBar.checkSetupButton() toolBar.checkSetupButton()
} }
function showWindowCloseMessage() {
windowCloseDialog.open()
}
// The following are use for unit testing only // The following are use for unit testing only
function showSetupFirmware() { function showSetupFirmware() {
...@@ -204,17 +200,6 @@ Item { ...@@ -204,17 +200,6 @@ Item {
currentPopUp = indicatorDropdown currentPopUp = indicatorDropdown
} }
MessageDialog {
id: windowCloseDialog
title: "QGroundControl close"
text: "There are still active connections to vehicles. Do you want to disconnect these before closing?"
standardButtons: StandardButton.Yes | StandardButton.Cancel
modality: Qt.ApplicationModal
visible: false
onYes: controller.acceptWindowClose()
}
//-- Left Settings Menu //-- Left Settings Menu
Loader { Loader {
id: leftPanel id: leftPanel
......
...@@ -23,12 +23,14 @@ along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>. ...@@ -23,12 +23,14 @@ along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
import QtQuick 2.5 import QtQuick 2.5
import QtQuick.Window 2.2 import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QGroundControl 1.0 import QGroundControl 1.0
/// Native QML top level window /// Native QML top level window
Window { Window {
visible: true id: _rootWindow
visible: true
onClosing: { onClosing: {
// Disallow window close if there are active connections // Disallow window close if there are active connections
...@@ -56,7 +58,7 @@ Window { ...@@ -56,7 +58,7 @@ Window {
} }
function showWindowCloseMessage() { function showWindowCloseMessage() {
mainWindowInner.item.showWindowCloseMessage() windowCloseDialog.open()
} }
// The following are use for unit testing only // The following are use for unit testing only
...@@ -86,5 +88,32 @@ Window { ...@@ -86,5 +88,32 @@ Window {
anchors.fill: parent anchors.fill: parent
source: "MainWindowInner.qml" source: "MainWindowInner.qml"
} }
MessageDialog {
id: windowCloseDialog
title: "QGroundControl close"
text: "There are still active connections to vehicles. Do you want to disconnect these before closing?"
standardButtons: StandardButton.Yes | StandardButton.Cancel
modality: Qt.ApplicationModal
visible: false
onYes: {
QGroundControl.linkManager.shutdown()
// The above shutdown causes a flurry of activity as the vehicle components are removed. This in turn
// causes the Windows Version of Qt to crash if you allow the close event to be accepted. In order to prevent
// the crash, we ignore the close event and setup a delayed timer to close the window after things settle down.
delayedWindowCloseTimer.start()
}
}
Timer {
id: delayedWindowCloseTimer
interval: 1500
running: false
repeat: false
onTriggered: _rootWindow.close()
}
} }
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