How to handle QML page orientation?

798 views Asked by At

I'm developing a BlackBerry 10 mobile application using the Momentics IDE 2.1.2 (native SDK).

Let's start with the example of the "orientation handler" that I'm using for my layout :

            attachedObjects: [
                    OrientationHandler {
                        id: handler

                    onOrientationAboutToChange: {

                        if (orientation == UIOrientation.Landscape) {

                            mainContainer.sideMenuLarge = ui.sdu(80.0)

                            mainEntryHeaderContainer.layoutProperties.spaceQuota = 1.6
                            mainEntryBodyContainer.layoutProperties.spaceQuota = 5.8

                        } else {

                            mainContainer.sideMenuLarge = ui.sdu(60.0)

                            mainEntryHeaderContainer.layoutProperties.spaceQuota = 1
                            mainEntryBodyContainer.layoutProperties.spaceQuota = 7.4
                        }
                    }
                }
            ]

Like you see, when the app starts in portrait mode everything is cool, it should be because all the Controls Paddings and the Containers SpaceQuota things are initialized with values that it is compatible with the portrait mode, but when it starts in Landscape mode it is different thing, it will takes the initial values of the portrait mode until I switch to portrait mode and then return it to landscape mode.

How can I fix this ? And can I have 2 pages in 1 navigation pane with differents "OrientationSupport" ? I tried but it doesn't works; for example I'm in page 1 in landscape mode and then I opened the page 2 that support only the portrait mode, it switchs to portrait but when I came back to the previous page the OrientationSupport will be fixed in portrait mode (it does not handle the landscape mode anymore)

Page 1:

OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All

Page 2:

OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.DisplayPortrait
0

There are 0 answers