From d9763100940cbcff297d88a0f1597ba7bd07ea01 Mon Sep 17 00:00:00 2001 From: Henrik Brautaset Aronsen Date: Sun, 7 Feb 2016 22:23:06 +0100 Subject: Add top-right edit and back buttons for mobile Adds a back button in edit mode, and an edit button for view mode. Signed-off-by: Henrik Brautaset Aronsen Signed-off-by: Dirk Hohndel --- qt-mobile/qml/DiveDetails.qml | 51 ++++++++++++++++-------------- qt-mobile/qml/TopBar.qml | 62 ++++++++++++++++++++++++++++++++++++- qt-mobile/qml/icons/menu-back.png | Bin 0 -> 3715 bytes qt-mobile/qml/icons/menu-edit.png | Bin 0 -> 7369 bytes qt-mobile/qml/mobile-resources.qrc | 4 ++- 5 files changed, 92 insertions(+), 25 deletions(-) create mode 100644 qt-mobile/qml/icons/menu-back.png create mode 100644 qt-mobile/qml/icons/menu-edit.png (limited to 'qt-mobile/qml') diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml index ef51a71b2..b2744ec1e 100644 --- a/qt-mobile/qml/DiveDetails.qml +++ b/qt-mobile/qml/DiveDetails.qml @@ -56,29 +56,7 @@ MobileComponents.Page { state = "view" Qt.inputMethod.hide() } else { - // set things up for editing - so make sure that the detailsEdit has - // all the right data (using the property aliases set up above) - dive_id = diveDetailsListView.currentItem.modelData.dive.id - number = diveDetailsListView.currentItem.modelData.dive.number - date = diveDetailsListView.currentItem.modelData.dive.date + " " + diveDetailsListView.currentItem.modelData.dive.time - location = diveDetailsListView.currentItem.modelData.dive.location - duration = diveDetailsListView.currentItem.modelData.dive.duration - depth = diveDetailsListView.currentItem.modelData.dive.depth - airtemp = diveDetailsListView.currentItem.modelData.dive.airTemp - watertemp = diveDetailsListView.currentItem.modelData.dive.waterTemp - suit = diveDetailsListView.currentItem.modelData.dive.suit - buddy = diveDetailsListView.currentItem.modelData.dive.buddy - divemaster = diveDetailsListView.currentItem.modelData.dive.divemaster - notes = diveDetailsListView.currentItem.modelData.dive.notes - if (diveDetailsListView.currentItem.modelData.dive.singleWeight) { - // we have only one weight, go ahead, have fun and edit it - weight = diveDetailsListView.currentItem.modelData.dive.sumWeight - } else { - // careful when translating, this text is "magic" in DiveDetailsEdit.qml - weight = "cannot edit multiple weight systems" - } - - diveDetailsPage.state = "edit" + startEditMode() } } } @@ -87,6 +65,33 @@ MobileComponents.Page { currentIndex = index; diveDetailsListView.positionViewAtIndex(index, ListView.Beginning); } + + function startEditMode() { + // set things up for editing - so make sure that the detailsEdit has + // all the right data (using the property aliases set up above) + dive_id = diveDetailsListView.currentItem.modelData.dive.id + number = diveDetailsListView.currentItem.modelData.dive.number + date = diveDetailsListView.currentItem.modelData.dive.date + " " + diveDetailsListView.currentItem.modelData.dive.time + location = diveDetailsListView.currentItem.modelData.dive.location + duration = diveDetailsListView.currentItem.modelData.dive.duration + depth = diveDetailsListView.currentItem.modelData.dive.depth + airtemp = diveDetailsListView.currentItem.modelData.dive.airTemp + watertemp = diveDetailsListView.currentItem.modelData.dive.waterTemp + suit = diveDetailsListView.currentItem.modelData.dive.suit + buddy = diveDetailsListView.currentItem.modelData.dive.buddy + divemaster = diveDetailsListView.currentItem.modelData.dive.divemaster + notes = diveDetailsListView.currentItem.modelData.dive.notes + if (diveDetailsListView.currentItem.modelData.dive.singleWeight) { + // we have only one weight, go ahead, have fun and edit it + weight = diveDetailsListView.currentItem.modelData.dive.sumWeight + } else { + // careful when translating, this text is "magic" in DiveDetailsEdit.qml + weight = "cannot edit multiple weight systems" + } + + diveDetailsPage.state = "edit" + } + onWidthChanged: diveDetailsListView.positionViewAtIndex(diveDetailsListView.currentIndex, ListView.Beginning); ScrollView { diff --git a/qt-mobile/qml/TopBar.qml b/qt-mobile/qml/TopBar.qml index 5eeef7da8..4f3f6fef8 100644 --- a/qt-mobile/qml/TopBar.qml +++ b/qt-mobile/qml/TopBar.qml @@ -81,6 +81,67 @@ Rectangle { Item { Layout.fillWidth: true } + Item { + id: editButton + anchors.right: parent.right + anchors.top: parent.top + Layout.preferredHeight: editButtonIcon.height + width: editButtonIcon.width + visible: (detailsWindow.state === "view" && detailsWindow.visible) + Image { + id: editButtonIcon + source: "qrc:/qml/menu-edit.png" + anchors { + top: parent.top + right: parent.right + topMargin: MobileComponents.Units.smallSpacing * -1 + rightMargin: MobileComponents.Units.smallSpacing + } + width: Math.round(MobileComponents.Units.gridUnit * 1.7) + height: width + } + MouseArea { + height: parent.height + width: parent.width + onClicked: { + detailsWindow.open() + } + } + MouseArea { + height: parent.height + width: parent.width + onClicked: { + detailsWindow.startEditMode() + } + } + } + Item { + id: backButton + anchors.right: parent.right + anchors.top: parent.top + Layout.preferredHeight: backButtonIcon.height + width: backButtonIcon.width + visible: (detailsWindow.state === "edit" && detailsWindow.visible) + Image { + id: backButtonIcon + source: "qrc:/qml/menu-back.png" + anchors { + top: parent.top + right: parent.right + topMargin: MobileComponents.Units.smallSpacing * -1 + rightMargin: MobileComponents.Units.smallSpacing + } + width: Math.round(MobileComponents.Units.gridUnit * 1.7) + height: width + } + MouseArea { + height: parent.height + width: parent.width + onClicked: { + endEditMode() + } + } + } Item { id: contextMenu visible: contextDrawer.enabled @@ -108,6 +169,5 @@ Rectangle { } } } - } } diff --git a/qt-mobile/qml/icons/menu-back.png b/qt-mobile/qml/icons/menu-back.png new file mode 100644 index 000000000..dc96b7728 Binary files /dev/null and b/qt-mobile/qml/icons/menu-back.png differ diff --git a/qt-mobile/qml/icons/menu-edit.png b/qt-mobile/qml/icons/menu-edit.png new file mode 100644 index 000000000..ea7dd055a Binary files /dev/null and b/qt-mobile/qml/icons/menu-edit.png differ diff --git a/qt-mobile/qml/mobile-resources.qrc b/qt-mobile/qml/mobile-resources.qrc index 50565e0a8..e57fa5e13 100644 --- a/qt-mobile/qml/mobile-resources.qrc +++ b/qt-mobile/qml/mobile-resources.qrc @@ -1,5 +1,5 @@ - + main.qml TextButton.qml Preferences.qml @@ -19,6 +19,8 @@ ../../icons/subsurface-mobile-icon.png icons/main-menu.png icons/context-menu.png + icons/menu-edit.png + icons/menu-back.png mobilecomponents/qmldir -- cgit v1.2.3-70-g09d2