diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-01-06 18:11:24 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-01-06 18:21:09 -0800 |
commit | e5f95daee80a45f4300c129e38a2681d83bef3d7 (patch) | |
tree | 5ed3bee58059f3995c29b86665f06b099b965508 /qt-mobile/qml/DiveDetails.qml | |
parent | 9a28807dd39adf499d4bfaf94b4356e319e55f67 (diff) | |
download | subsurface-e5f95daee80a45f4300c129e38a2681d83bef3d7.tar.gz |
QML UI: reimplement context menu for dive details
With the mobile components fixed we can now simply switch between different
menu content - no need to play games and redefine the actions on the fly. This
also adds a cancel button for editing and cleans up when the user hits cancel.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile/qml/DiveDetails.qml')
-rw-r--r-- | qt-mobile/qml/DiveDetails.qml | 85 |
1 files changed, 54 insertions, 31 deletions
diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml index 27a8996da..c464551db 100644 --- a/qt-mobile/qml/DiveDetails.qml +++ b/qt-mobile/qml/DiveDetails.qml @@ -27,8 +27,6 @@ MobileComponents.Page { property string date property string number property string weight - property alias viewEditText: viewEditSelector.text - state: "view" states: [ @@ -43,41 +41,66 @@ MobileComponents.Page { PropertyChanges { target: detailsEdit; opacity: 1 } } ] - - contextualActions: [ + property list<Action> viewActions: [ Action { - id: viewEditSelector - text: checked ? "View" : "Edit" - checkable: true - iconName: checked ? "view-readermode" : "document-edit" + id: editSelector + text: "Edit" + iconName: "document-edit" onTriggered: { - if (diveDetailsWindow.state == "edit") { - manager.commitChanges(dive_id, detailsEdit.dateText, detailsEdit.locationText, detailsEdit.gpsText, detailsEdit.durationText, - detailsEdit.depthText, detailsEdit.airtempText, detailsEdit.watertempText, detailsEdit.suitText, - detailsEdit.buddyText, detailsEdit.divemasterText, detailsEdit.notesText) - date = detailsEdit.dateText - location = detailsEdit.locationText - // gps = detailsEdit.gps - duration = detailsEdit.durationText - depth = detailsEdit.depthText - airtemp = detailsEdit.airtempText - watertemp = detailsEdit.watertempText - suit = detailsEdit.suitText - buddy = detailsEdit.buddyText - divemaster = detailsEdit.divemasterText - notes = detailsEdit.notesText - diveDetailsWindow.viewEditText = "Edit" - diveDetailsWindow.state = "view" - } else { - diveDetailsWindow.viewEditText = "Save" - diveDetailsWindow.state = "edit" - } + diveDetailsWindow.state = "edit" + contextDrawer.close() + } + } + ] + property list<Action> editActions: [ + Action { + id: cancelSelector + text: "Cancel" + iconName: "dialog-cancel" + onTriggered: { + // reset the fields in the edit screen + detailsEdit.dateText = date + detailsEdit.locationText = location + detailsEdit.durationText = duration + detailsEdit.depthText = depth + detailsEdit.airtempText = airtemp + detailsEdit.watertempText = watertemp + detailsEdit.suitText = suit + detailsEdit.buddyText = buddy + detailsEdit.divemasterText = divemaster + detailsEdit.notesText = notes + // back to view state and close the drawer + diveDetailsWindow.state = "view" + contextDrawer.close() + } + }, + Action { + id: saveSelector + text: "Save" + iconName: "document-save" + onTriggered: { + // apply the changes to the dive_table + manager.commitChanges(dive_id, detailsEdit.dateText, detailsEdit.locationText, detailsEdit.gpsText, detailsEdit.durationText, + detailsEdit.depthText, detailsEdit.airtempText, detailsEdit.watertempText, detailsEdit.suitText, + detailsEdit.buddyText, detailsEdit.divemasterText, detailsEdit.notesText) + // apply the changes to the dive detail view + date = detailsEdit.dateText + location = detailsEdit.locationText + duration = detailsEdit.durationText + depth = detailsEdit.depthText + airtemp = detailsEdit.airtempText + watertemp = detailsEdit.watertempText + suit = detailsEdit.suitText + buddy = detailsEdit.buddyText + divemaster = detailsEdit.divemasterText + notes = detailsEdit.notesText + // back to view state and close the drawer + diveDetailsWindow.state = "view" contextDrawer.close() - // close drawer? } } - ] + contextualActions: diveDetailsWindow.state === "view" ? viewActions : editActions ScrollView { anchors.fill: parent |