From cc2b815a4d86f5373c32351a20edaa9dff797921 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 30 Mar 2016 20:48:50 -0500 Subject: 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 --- qt-mobile/qml/DiveDetails.qml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'qt-mobile/qml') 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(); } -- cgit v1.2.3-70-g09d2