From 6a3e761d8faf5be3bdc8a5feb8f06b69f9bdeaaf Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 30 Mar 2016 20:39:25 -0500 Subject: QML UI: scroll to top of dive list when tapping title bar This helps you get to the latest dive when you are stuck at the bottom of a dive list. Signed-off-by: Dirk Hohndel --- qt-mobile/qml/DiveList.qml | 5 +++++ qt-mobile/qml/TopBar.qml | 8 ++++++++ qt-mobile/qml/main.qml | 4 ++++ 3 files changed, 17 insertions(+) (limited to 'qt-mobile') diff --git a/qt-mobile/qml/DiveList.qml b/qt-mobile/qml/DiveList.qml index b3b82bc27..b80c1ec03 100644 --- a/qt-mobile/qml/DiveList.qml +++ b/qt-mobile/qml/DiveList.qml @@ -14,6 +14,11 @@ MobileComponents.Page { property int credentialStatus: manager.credentialStatus property int numDives: diveListView.count property color textColor: subsurfaceTheme.diveListTextColor + + function scrollToTop() { + diveListView.positionViewAtBeginning() + } + Component { id: diveDelegate MobileComponents.ListItem { diff --git a/qt-mobile/qml/TopBar.qml b/qt-mobile/qml/TopBar.qml index ed6f41182..964e9b8a4 100644 --- a/qt-mobile/qml/TopBar.qml +++ b/qt-mobile/qml/TopBar.qml @@ -48,4 +48,12 @@ Rectangle { Layout.fillWidth: true } } + MouseArea { + anchors.fill: topPart + onClicked: { + if (stackView.depth == 1 && showingDiveList) { + scrollToTop() + } + } + } } diff --git a/qt-mobile/qml/main.qml b/qt-mobile/qml/main.qml index e2ceab80a..7f5b30789 100644 --- a/qt-mobile/qml/main.qml +++ b/qt-mobile/qml/main.qml @@ -38,6 +38,10 @@ MobileComponents.ApplicationWindow { detailsWindow.endEditMode() } + function scrollToTop() { + diveList.scrollToTop() + } + globalDrawer: MobileComponents.GlobalDrawer { title: "Subsurface" titleIcon: "qrc:/qml/subsurface-mobile-icon.png" -- cgit v1.2.3-70-g09d2