aboutsummaryrefslogtreecommitdiffstats
path: root/qt-mobile/qml/DiveDetails.qml
diff options
context:
space:
mode:
Diffstat (limited to 'qt-mobile/qml/DiveDetails.qml')
-rw-r--r--qt-mobile/qml/DiveDetails.qml71
1 files changed, 43 insertions, 28 deletions
diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml
index 555e5ba0c..22cffdd6d 100644
--- a/qt-mobile/qml/DiveDetails.qml
+++ b/qt-mobile/qml/DiveDetails.qml
@@ -38,45 +38,57 @@ Kirigami.Page {
states: [
State {
name: "view"
- PropertyChanges { target: diveDetailsPage; contextualActions: deleteAction }
- PropertyChanges { target: detailsEditScroll; opened: false }
+ PropertyChanges { target: diveDetailsPage; contextualActions: Qt.platform.os == "ios" ? [ deleteAction, backAction ] : [ deleteAction ] }
+ PropertyChanges { target: detailsEditScroll; visible: false }
},
State {
name: "edit"
- PropertyChanges { target: diveDetailsPage; contextualActions: null }
- PropertyChanges { target: detailsEditScroll; opened: true }
+ PropertyChanges { target: diveDetailsPage; contextualActions: Qt.platform.os == "ios" ? [ cancelAction ] : null }
+ PropertyChanges { target: detailsEditScroll; visible: true }
},
State {
name: "add"
- PropertyChanges { target: diveDetailsPage; contextualActions: null }
- PropertyChanges { target: detailsEditScroll; opened: true }
+ PropertyChanges { target: diveDetailsPage; contextualActions: Qt.platform.os == "ios" ? [ cancelAction ] : null }
+ PropertyChanges { target: detailsEditScroll; visible: true }
}
]
- 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"
+ onTriggered: {
+ contextDrawer.close()
+ var deletedId = diveDetailsListView.currentItem.modelData.dive.id
+ manager.deleteDive(deletedId)
+ stackView.pop()
+ showPassiveNotification("Dive deleted", 3000, "Undo",
+ function() {
+ manager.undoDelete(deletedId)
+ });
+ }
}
- property list<QtObject> deleteAction: [
- Kirigami.Action {
- text: "Delete dive"
- iconName: "trash-empty"
- onTriggered: {
- var deletedId = diveDetailsListView.currentItem.modelData.dive.id
- manager.deleteDive(deletedId)
- showPassiveNotification("Dive deleted", 3000, "Undo",
- function() {
- manager.undoDelete(deletedId)
- });
- contextDrawer.close()
- stackView.pop()
- }
+ property QtObject cancelAction: Kirigami.Action {
+ text: state === "edit" ? "Cancel edit" : "Cancel dive add"
+ iconName: "dialog-cancel"
+ onTriggered: {
+ contextDrawer.close()
+ if (state === "add")
+ returnTopPage()
+ else
+ endEditMode()
}
- ]
+ }
+
+ property QtObject backAction: Action {
+ text: "Back to dive list"
+ iconName: "go-previous"
+ onTriggered: {
+ contextDrawer.close()
+ returnTopPage()
+ }
+ }
mainAction: Action {
iconName: state !== "view" ? "document-save" : "document-edit"
@@ -94,7 +106,7 @@ Kirigami.Page {
endEditMode()
event.accepted = true;
} else if (state === "add") {
- endAddMode()
+ endEditMode()
stackView.pop()
event.accepted = true;
}
@@ -107,7 +119,10 @@ Kirigami.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();
}