diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-03-31 09:40:28 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-03-31 20:33:11 -0700 |
commit | 2bf394581f9e9127c720494488952fa09ec35026 (patch) | |
tree | ad2f1fbd3a7fc2df4270b4013c7616f6b6020b65 /mobile-widgets/qml | |
parent | 91f7689787345735cfaac516ce2e77311f32f011 (diff) | |
download | subsurface-2bf394581f9e9127c720494488952fa09ec35026.tar.gz |
mobile/dive-details: if menu is open, close that with back button
A second tap on the back button will then end add/edit or close the dive
details and get us back to the dive list.
This fixes an issue where tapping on back with the context menu open
would bring you back to the dive list with the context menu still open,
and because then change the text in the context menu as those are
designed differently.
Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qml')
-rw-r--r-- | mobile-widgets/qml/DiveDetails.qml | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml index b102d7206..9970a9455 100644 --- a/mobile-widgets/qml/DiveDetails.qml +++ b/mobile-widgets/qml/DiveDetails.qml @@ -261,15 +261,27 @@ Kirigami.Page { } onBackRequested: { - if (state === "edit") { - endEditMode() - event.accepted = true; - } else if (state === "add") { - endEditMode() - pageStack.pop() - event.accepted = true; + // if one of the drawers/menus is open, the back button should close those + if (globalDrawer.visible) { + globalDrawer.close() + event.accepted = true + } + if (contextDrawer.visible) { + contextDrawer.close() + event.accepted = true + } + // if we didn't close either of the drawer, check if we need to close add/edit + if (event.accepted === false) { + if (state === "edit") { + endEditMode() + event.accepted = true; + } else if (state === "add") { + endEditMode() + pageStack.pop() + event.accepted = true; + } } - // if we were in view mode, don't accept the event and pop the page + // if we were in view mode and no menus are open, don't accept the event and pop the page } onCurrentItemChanged: { |