[PATCH] Mobile components: use back button to close global and context drawers

Rick Walsh rickmwalsh at gmail.com
Wed Jan 6 12:46:06 UTC 2016


ApplicationWindow catches Qt.Key_Back. By using it to close the global and
context drawers ahead of stackView.pop(), we get expected behaviour in
Subsurface-mobile, similar to other apps.

Signed-off-by: Rick Walsh <rickmwalsh at gmail.com>
---

Sebastian,
You said you'd rather any changes to qt-mobile/qml/mobilecomponents/* are made upstream, so I'm sending this patch to you as well as the Subsurface list. I couldn't find a tidy way to make the drawers close with the back button without touching qt-mobile/qml/mobilecomponents/. Of course, you are much more familiar with the code than I am, and may know a better way to achieve the same goal.

Rick

qt-mobile/qml/mobilecomponents/ApplicationWindow.qml | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/qt-mobile/qml/mobilecomponents/ApplicationWindow.qml b/qt-mobile/qml/mobilecomponents/ApplicationWindow.qml
index 0eaa81e..911f885 100644
--- a/qt-mobile/qml/mobilecomponents/ApplicationWindow.qml
+++ b/qt-mobile/qml/mobilecomponents/ApplicationWindow.qml
@@ -65,9 +65,17 @@ inputMethod.keyboardRectangle.y) : 0
         }
         focus: true
         Keys.onReleased: {
-            if (event.key == Qt.Key_Back && stackView.depth > 1) {
-                stackView.pop();
-                event.accepted = true;
+            if (event.key == Qt.Key_Back) {
+                if (root.contextDrawer && root.contextDrawer.opened) {
+                    root.contextDrawer.close();
+                    event.accepted = true;
+                } else if (root.globalDrawer && root.globalDrawer.opened) {
+                    root.globalDrawer.close();
+                    event.accepted = true;
+                } else if (stackView.depth > 1) {
+                    stackView.pop();
+                    event.accepted = true;
+                }
             }
         }
     }
-- 
2.5.0



More information about the Plasma-devel mailing list