From e5f95daee80a45f4300c129e38a2681d83bef3d7 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 6 Jan 2016 18:11:24 -0800 Subject: 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 --- qt-mobile/qml/DiveDetails.qml | 85 +++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 31 deletions(-) (limited to 'qt-mobile/qml/DiveDetails.qml') 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 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 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 -- cgit v1.2.3-70-g09d2