mobile/page-selection: consistently use showPage to select a page

We still used pageStack.push() all over the place.

Also, in showPage, disable the map hack if the user actively picks a
different page.

This should fix an issue where the user picked the map and then tried to
add a dive to the dive list - and instead of the dive edit was shown the
map again.

Reported-by: Hartley Horwitz <hhrwtz@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-03-25 20:29:05 -07:00
parent 69272eefa8
commit f2a48e813f
2 changed files with 17 additions and 20 deletions

View file

@ -65,12 +65,7 @@ Kirigami.ScrollablePage {
manager.appendTextToLog("clicked on dive")
if (detailsWindow.state === "view") {
manager.selectRow(model.row);
// switch to detailsWindow (or push it if it's not in the stack)
var i = rootItem.pageIndex(detailsWindow)
if (i === -1)
pageStack.push(detailsWindow)
else
pageStack.currentIndex = i
showPage(detailsWindow)
}
}
}
@ -305,7 +300,7 @@ Kirigami.ScrollablePage {
tripEditWindow.tripId = currentItem.myData.tripId
tripEditWindow.tripLocation = currentItem.myData.tripLocation
tripEditWindow.tripNotes = currentItem.myData.tripNotes
pageStack.push(tripEditWindow)
showPage(tripEditWindow)
}
}

View file

@ -78,6 +78,8 @@ Kirigami.ApplicationWindow {
}
function showPage(page) {
if (page !== mapPage)
hackToOpenMap = 0 // we really want a different page
if (globalDrawer.drawerOpen)
globalDrawer.close()
var i=pageIndex(page)
@ -139,7 +141,7 @@ Kirigami.ApplicationWindow {
detailsWindow.startpressure = []
detailsWindow.endpressure = []
detailsWindow.gpsCheckbox = false
pageStack.push(detailsWindow)
showPage(detailsWindow)
}
contextDrawer: Kirigami.ContextDrawer {
@ -152,7 +154,7 @@ Kirigami.ApplicationWindow {
height: rootItem.height
rightPadding: 0
enabled: (Backend.cloud_verification_status === Enums.CS_NOCLOUD ||
Backend.cloud_verification_status === Enums.CS_VERIFIED)
Backend.cloud_verification_status === Enums.CS_VERIFIED)
topContent: Image {
source: "qrc:/qml/icons/dive.jpg"
Layout.fillWidth: true
@ -269,7 +271,7 @@ Kirigami.ApplicationWindow {
onTriggered: {
globalDrawer.close()
downloadFromDc.dcImportModel.clearTable()
pageStack.push(downloadFromDc)
showPage(downloadFromDc)
}
}
Kirigami.Action {
@ -328,7 +330,7 @@ if you have network connectivity and want to sync your data to cloud storage."),
text: qsTr("Dive summary")
onTriggered: {
globalDrawer.close()
pageStack.push(diveSummaryWindow)
showPage(diveSummaryWindow)
detailsWindow.endEditMode()
}
}
@ -339,7 +341,7 @@ if you have network connectivity and want to sync your data to cloud storage."),
text: qsTr("Export")
onTriggered: {
globalDrawer.close()
pageStack.push(exportWindow)
showPage(exportWindow)
detailsWindow.endEditMode()
}
}
@ -375,7 +377,7 @@ if you have network connectivity and want to sync your data to cloud storage."),
globalDrawer.close()
returnTopPage()
manager.populateGpsData();
pageStack.push(gpsWindow)
showPage(gpsWindow)
}
}
@ -410,7 +412,7 @@ if you have network connectivity and want to sync your data to cloud storage."),
globalDrawer.close()
settingsWindow.defaultCylinderModel = manager.cylinderInit
PrefEquipment.default_cylinder === "" ? defaultCylinderIndex = "-1" : defaultCylinderIndex = settingsWindow.defaultCylinderModel.indexOf(PrefEquipment.default_cylinder)
pageStack.push(settingsWindow)
showPage(settingsWindow)
detailsWindow.endEditMode()
}
},
@ -433,7 +435,7 @@ if you have network connectivity and want to sync your data to cloud storage."),
text: qsTr("About")
onTriggered: {
globalDrawer.close()
pageStack.push(aboutWindow)
showPage(aboutWindow)
detailsWindow.endEditMode()
}
}
@ -488,7 +490,7 @@ if you have network connectivity and want to sync your data to cloud storage."),
text: qsTr("App log")
onTriggered: {
globalDrawer.close()
pageStack.push(logWindow)
showPage(logWindow)
}
}
Kirigami.Action {
@ -511,7 +513,7 @@ if you have network connectivity and want to sync your data to cloud storage."),
text: qsTr("Theme information")
onTriggered: {
globalDrawer.close()
pageStack.push(themetest)
showPage(themetest)
}
}
@ -649,7 +651,7 @@ if you have network connectivity and want to sync your data to cloud storage."),
/* I really want an enum, but those are painful in QML, so let's use numbers
* 0 (Otherpage) - the last page selected was a non-map page
* 1 (MapSelected) - the map page was selected by the user
* 2 (MapForced) - the map page was forced by out hack
* 2 (MapForced) - the map page was forced by this hack
*/
pageStack.onCurrentItemChanged: {
@ -671,8 +673,8 @@ if you have network connectivity and want to sync your data to cloud storage."),
manager.appendTextToLog("pageStack forced back to map")
}
} else if (pageStack.currentItem.objectName !== mapPage.objectName &&
pageStack.lastItem.objectName === mapPage.objectName &&
hackToOpenMap === 1 /* MapSelected */) {
pageStack.lastItem.objectName === mapPage.objectName &&
hackToOpenMap === 1 /* MapSelected */) {
// if we just picked the mapPage and are suddenly back on a different page
// force things back to the mapPage
manager.appendTextToLog("pageStack wrong page, switching back to map")