diff options
author | Kai Uwe Broulik <kde@privat.broulik.de> | 2014-01-09 21:04:58 +0100 |
---|---|---|
committer | Kai Uwe Broulik <kde@privat.broulik.de> | 2014-01-23 17:52:05 +0100 |
commit | 28bc8dcf3a1523658c3d16be45809b7aed188b3c (patch) | |
tree | 93d7bae1ce4b5ff113f064a3e909bb556ef8d444 | |
parent | af7950fa94781c74184300de594046a22572b217 (diff) |
Enable back navigation using physical buttons
This especially helps to make the Android back button work.
If we cannot go back further, we let the platform decide whether
to quit or to do nothing.
It also reacts on Alt+Left shortcut but not the backspace key, since
this can cause unwanted navigation when typing in a textfield (ie.
mashing the backspace key to clear it)
Change-Id: I4c0c01285628d8f810a781c79ffb3fdee0489b8e
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
-rw-r--r-- | android/AndroidManifest.xml | 2 | ||||
-rw-r--r-- | qml/main.qml | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 7e189fd..221fa6d 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,5 +1,5 @@ <?xml version='1.0' encoding='utf-8'?> -<manifest android:versionCode="3" android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android" package="org.qtproject.quickforecast" android:versionName="1.1"> +<manifest android:versionCode="4" android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android" package="org.qtproject.quickforecast" android:versionName="1.2"> <application android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/app_name" android:icon="@drawable/icon"> <activity android:screenOrientation="unspecified" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="@string/app_name" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation"> <intent-filter> diff --git a/qml/main.qml b/qml/main.qml index fbd300b..6228b0a 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -81,6 +81,17 @@ ApplicationWindow { StackView { id: pageView anchors.fill: parent + focus: true + Keys.onReleased: { + if ((event.key === Qt.Key_Back || + (event.key === Qt.Key_Left && (event.modifiers & Qt.AltModifier))) && + pageView.depth > 1) { + event.accepted = true + if (!currentItem.isLocked) + currentItem.previousPage() + } + } + initialItem: citiesPage delegate: StackViewDelegate { pushTransition: StackViewTransition { |