aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-09 10:43:22 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-09 12:40:44 -0700
commit93080f129d3092a8d1c78d43469aeef1f3e2a899 (patch)
tree3966d47e0649a11f09ebe84e2bb783bd528d0439 /mobile-widgets
parente5c62f0858ba6e08ec21e1018e4f5758ee89ab58 (diff)
downloadsubsurface-93080f129d3092a8d1c78d43469aeef1f3e2a899.tar.gz
mobile UI: add consistent way to show a page
And have the existing shortcut functions use that helper. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qml/main.qml27
1 files changed, 14 insertions, 13 deletions
diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml
index ed56f8ec6..2f16041c3 100644
--- a/mobile-widgets/qml/main.qml
+++ b/mobile-widgets/qml/main.qml
@@ -76,30 +76,31 @@ Kirigami.ApplicationWindow {
diveList.scrollToTop()
}
- function showMap() {
+ function showPage(page) {
if (globalDrawer.drawerOpen)
globalDrawer.close()
- var i=pageIndex(mapPage)
+ var i=pageIndex(page)
if (i === -1)
- pageStack.push(mapPage)
+ pageStack.push(page)
else
pageStack.currentIndex = i
+ manager.appendTextToLog("switched to page " + page.title)
+ }
+
+ function showMap() {
+ showPage(mapPage)
}
function showDiveList() {
- if (globalDrawer.drawerOpen)
- globalDrawer.close()
- var i=pageIndex(diveList)
- if (i === -1)
- pageStack.push(diveList)
- else
- pageStack.currentIndex = i
+ showPage(diveList)
}
function pageIndex(pageToFind) {
- for (var i = 0; i < pageStack.contentItem.contentChildren.length; i++) {
- if (pageStack.contentItem.contentChildren[i] === pageToFind)
- return i
+ if (pageStack.contentItem !== null) {
+ for (var i = 0; i < pageStack.contentItem.contentChildren.length; i++) {
+ if (pageStack.contentItem.contentChildren[i] === pageToFind)
+ return i
+ }
}
return -1
}