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 <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Henrik Brautaset Aronsen 2016-02-07 22:23:06 +01:00 committed by Dirk Hohndel
parent e174389618
commit d976310094
5 changed files with 92 additions and 25 deletions

View file

@ -56,6 +56,17 @@ MobileComponents.Page {
state = "view" state = "view"
Qt.inputMethod.hide() Qt.inputMethod.hide()
} else { } else {
startEditMode()
}
}
}
function showDiveIndex(index) {
currentIndex = index;
diveDetailsListView.positionViewAtIndex(index, ListView.Beginning);
}
function startEditMode() {
// set things up for editing - so make sure that the detailsEdit has // set things up for editing - so make sure that the detailsEdit has
// all the right data (using the property aliases set up above) // all the right data (using the property aliases set up above)
dive_id = diveDetailsListView.currentItem.modelData.dive.id dive_id = diveDetailsListView.currentItem.modelData.dive.id
@ -80,13 +91,7 @@ MobileComponents.Page {
diveDetailsPage.state = "edit" diveDetailsPage.state = "edit"
} }
}
}
function showDiveIndex(index) {
currentIndex = index;
diveDetailsListView.positionViewAtIndex(index, ListView.Beginning);
}
onWidthChanged: diveDetailsListView.positionViewAtIndex(diveDetailsListView.currentIndex, ListView.Beginning); onWidthChanged: diveDetailsListView.positionViewAtIndex(diveDetailsListView.currentIndex, ListView.Beginning);
ScrollView { ScrollView {

View file

@ -81,6 +81,67 @@ Rectangle {
Item { Item {
Layout.fillWidth: true 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 { Item {
id: contextMenu id: contextMenu
visible: contextDrawer.enabled visible: contextDrawer.enabled
@ -108,6 +169,5 @@ Rectangle {
} }
} }
} }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View file

@ -19,6 +19,8 @@
<file alias="subsurface-mobile-icon.png">../../icons/subsurface-mobile-icon.png</file> <file alias="subsurface-mobile-icon.png">../../icons/subsurface-mobile-icon.png</file>
<file alias="main-menu.png">icons/main-menu.png</file> <file alias="main-menu.png">icons/main-menu.png</file>
<file alias="context-menu.png">icons/context-menu.png</file> <file alias="context-menu.png">icons/context-menu.png</file>
<file alias="menu-edit.png">icons/menu-edit.png</file>
<file alias="menu-back.png">icons/menu-back.png</file>
</qresource> </qresource>
<qresource prefix="/imports"> <qresource prefix="/imports">
<file alias="org/kde/plasma/mobilecomponents/qmldir">mobilecomponents/qmldir</file> <file alias="org/kde/plasma/mobilecomponents/qmldir">mobilecomponents/qmldir</file>