summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-10-21 20:46:44 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-10-21 21:12:58 (GMT)
commite49eae6925f342185f891cd9faec0f8e1b4b5b26 (patch)
tree80fbed70e3bd0533d749596d3fbd7f9054d1a566
parentf5319d7e4329a5654486364fe6895b69f10c4199 (diff)
Prevent unwanted direct quit from search dialog
Also changes behavior on desktop such that window close button mimics Android's back button. (cherry picked from commit bc69d3ac680f63bf8bc1429f9d61ab378173c137)
-rw-r--r--src/apps/marble-maps/MainScreen.qml88
-rw-r--r--src/apps/marble-maps/Search.qml2
2 files changed, 42 insertions, 48 deletions
diff --git a/src/apps/marble-maps/MainScreen.qml b/src/apps/marble-maps/MainScreen.qml
index 3bad3c5..7aa8fde 100644
--- a/src/apps/marble-maps/MainScreen.qml
+++ b/src/apps/marble-maps/MainScreen.qml
@@ -152,50 +152,6 @@ ApplicationWindow {
routingManager: routing
visible: !navigationManager.visible
}
-
- BoxedText {
- id: quitHelper
- visible: false
- text: qsTr("Press again to close.")
- anchors.bottom: parent.bottom
- anchors.bottomMargin: Screen.pixelDensity * 5
- anchors.horizontalCenter: parent.horizontalCenter
- onVisibleChanged: {
- if (visible) {
- quitTimer.restart()
- }
- }
-
- Timer {
- id: quitTimer
- interval: 3000;
- running: false;
- repeat: false
- onTriggered: {
- marbleMaps.state = ""
- quitHelper.visible = false
- }
- }
- }
-
- Keys.onBackPressed: {
- if (marbleMaps.state === "aboutToQuit") {
- event.accepted = false // we will quit
- } else if (navigationManager.visible) {
- navigationManager.visible = false
- event.accepted = true
- } else if (dialogContainer.visible) {
- dialogContainer.currentIndex = dialogContainer.none
- event.accepted = true
- } else if (marbleMaps.state === "") {
- marbleMaps.state = "aboutToQuit"
- quitHelper.visible = true
- event.accepted = true
- } else {
- marbleMaps.state = ""
- event.accepted = true
- }
- }
}
NavigationManager {
@@ -304,7 +260,6 @@ ApplicationWindow {
readonly property int developer: 4
property int currentIndex: none
- Keys.onBackPressed: currentIndex = none
onCurrentIndexChanged:
{
@@ -316,7 +271,6 @@ ApplicationWindow {
case settings: contentItem = settingsDialog; break;
case developer: contentItem = developerDialog; break;
}
-
}
RouteEditor {
@@ -365,5 +319,45 @@ ApplicationWindow {
source: "qrc:///border_shadow.png"
}
- Keys.onBackPressed: event.accepted = true
+ BoxedText {
+ id: quitHelper
+ visible: false
+ text: qsTr("Press again to close.")
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: Screen.pixelDensity * 5
+ anchors.horizontalCenter: parent.horizontalCenter
+ onVisibleChanged: {
+ if (visible) {
+ quitTimer.restart()
+ }
+ }
+
+ Timer {
+ id: quitTimer
+ interval: 3000;
+ running: false;
+ repeat: false
+ onTriggered: {
+ root.aboutToQuit = false
+ quitHelper.visible = false
+ }
+ }
+ }
+
+ property bool aboutToQuit: false
+
+ onClosing: {
+ if (root.aboutToQuit === true) {
+ close.accepted = true // we will quit
+ return
+ } else if (navigationManager.visible) {
+ navigationManager.visible = false
+ } else if (dialogContainer.visible) {
+ dialogContainer.currentIndex = dialogContainer.none
+ } else {
+ root.aboutToQuit = true
+ quitHelper.visible = true
+ }
+ close.accepted = false
+ }
}
diff --git a/src/apps/marble-maps/Search.qml b/src/apps/marble-maps/Search.qml
index 2d0024f..49d0bb4 100644
--- a/src/apps/marble-maps/Search.qml
+++ b/src/apps/marble-maps/Search.qml
@@ -119,9 +119,9 @@ Item {
anchors.fill: parent
onClicked: {
bookmarksView.currentIndex = index
- dialogContainer.focus = true
placemarkDialog.placemark = bookmarks.placemark(index);
marbleMaps.centerOn(placemarkDialog.placemark.longitude, placemarkDialog.placemark.latitude)
+ dialogContainer.focus = true
}
}
}