mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
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>
This commit is contained in:
parent
6a3e761d8f
commit
cc2b815a4d
1 changed files with 8 additions and 14 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue