diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-03-30 20:48:50 -0500 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-03-30 20:49:00 -0500 |
commit | cc2b815a4d86f5373c32351a20edaa9dff797921 (patch) | |
tree | ec69864b046c645ee678b1b5d79cedd81496d4b5 /qt-mobile | |
parent | 6a3e761d8faf5be3bdc8a5feb8f06b69f9bdeaaf (diff) | |
download | subsurface-cc2b815a4d86f5373c32351a20edaa9dff797921.tar.gz |
QML UI: simplify the code to cancel edit / add
This way we have one function that correctly ends both modes.
As a positive side effect this fixes a bug where one could exit the
add mode by tapping Dive list in the main menu which would not delete
the partially created dive.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile')
-rw-r--r-- | qt-mobile/qml/DiveDetails.qml | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml index 525031da7..4bdd052e4 100644 --- a/qt-mobile/qml/DiveDetails.qml +++ b/qt-mobile/qml/DiveDetails.qml @@ -50,13 +50,6 @@ MobileComponents.Page { ] - function endAddMode() { - // edit was canceled - so remove the dive from the dive list - manager.addDiveAborted(dive_id) - state = "view" - Qt.inputMethod.hide() - } - property QtObject deleteAction: Action { text: "Delete dive" iconName: "trash-empty" @@ -77,12 +70,10 @@ MobileComponents.Page { iconName: "dialog-cancel" onTriggered: { contextDrawer.close() - if (state === "edit") { - endEditMode() - } else if (state === "add") { - endAddMode() + if (state === "add") returnTopPage() - } + else + endEditMode() } } @@ -111,7 +102,7 @@ MobileComponents.Page { endEditMode() event.accepted = true; } else if (state === "add") { - endAddMode() + endEditMode() stackView.pop() event.accepted = true; } @@ -124,7 +115,10 @@ MobileComponents.Page { } function endEditMode() { - // just cancel the edit state + // if we were adding a dive, we need to remove it + if (state === "add") + manager.addDiveAborted(dive_id) + // just cancel the edit/add state state = "view"; Qt.inputMethod.hide(); } |