Ask / Submit
1

PageStack.backNavigation: bug when returning to first page? [answered]

asked 2014-09-06 14:24:37 +0300

mkouhia gravatar image

updated 2014-09-06 17:31:32 +0300

Background

I am trying to create application with behaviour similar to (but not identical with) Maps application. First page is for different app functions, where user can enter map page. PageStack navigation is disabled when drawer is closed, but again enabled when drawer is opened.

Problem

When PageStack.backNavigation is manually disabled/enabled on second page level and user returns to first page, navigation indicator stays visible even though the stack contains only one page. In every other case where PageStack.backNavigation is not manually accessed, indicator disappears. In addition to this, when navigation indicator is visible on first level, user can flick back and leave first page, and the program stalls.

Is there something I am doing wrong or is this a bug in pageStack?

I guess I could somehow define on first page that on opening it, pageStack.backNavigation = false and on leaving page, pageStack.backNavigation = true, but it seems hackish. Surely it is designed to happen automatically? Or does this automation stop when backNavigation is accessed manually? If so, is there a way to turn it back on?


Example program:

FirstPage.qml

import QtQuick 2.0
import Sailfish.Silica 1.0


Page {
    id: firstpage

    SilicaFlickable {
        anchors.fill: parent

        PullDownMenu {
            MenuItem {
                text: "Page 2"
                onClicked: pageStack.push(Qt.resolvedUrl("SecondPage.qml"))
            }
        }

        ViewPlaceholder {
            text: "Go to second page and come back here"
            enabled: true
        }

    }
}

SecondPage.qml

import QtQuick 2.0
import Sailfish.Silica 1.0
import QtLocation 5.0
import QtPositioning 5.0


Page {
    id: secondpage

    Drawer {
        id: drawer
        open: false
        anchors.fill: parent

        background: SilicaListView {
            anchors.fill: parent
            model: 4

            header: PageHeader { title: "Drawer" }

            delegate: BackgroundItem {
                id: someItem
                contentHeight: Theme.itemSizeSmall

                Label {
                    x: Theme.paddingLarge
                    text: "List Item " + index
                    anchors.verticalCenter: parent.verticalCenter
                    color: someItem.highlighted ? Theme.highlightColor : Theme.primaryColor
                }
            }
        }

        Map {
            id: map
            plugin : Plugin {name : "osm"}
            anchors.fill: parent
            center: QtPositioning.coordinate(60.17, 24.95)

            MouseArea {
                anchors.fill: parent
                onClicked: {
                    drawer.open = !drawer.open
                    pageStack.backNavigation = drawer.open
                }
            }
        }
    }

    Component.onCompleted: {
        if (!drawer.open){
            pageStack.backNavigation = false
        }
    }
}

Figures showing what happens:

  • First page:

    First page

  • Second page, navigation is disabled

    Second page

  • Tap on map and drawer opens, navigation is enabled

    Drawer open

    • Navigate back to first page, navigation does not disappear

    First page again, indicator visible

  • Try to navigate "back" from first page and program ends up unresponsive

    After navigating "back" from first page

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by VDVsx
close date 2014-09-11 08:55:39.216933

1 Answer

Sort by » oldest newest most voted
0

answered 2014-09-06 18:06:24 +0300

mkouhia gravatar image

Okay, things seem to sort out when you ask them in public. Proper way seems to use backNavigation property of Page element instead of pageStack.backNavigation. With this correction everything works as it should!

Page {
    id: secondpage
    backNavigation: drawer.open
 ...
edit flag offensive delete publish link more

Question tools

Follow
1 follower

Stats

Asked: 2014-09-06 14:24:37 +0300

Seen: 446 times

Last updated: Sep 06 '14