diff options
author | Stefan Wildemann <metalstrolch@users.noreply.github.com> | 2017-05-15 18:50:17 +0200 |
---|---|---|
committer | Pierre GRANDIN <pgrandin@users.noreply.github.com> | 2017-05-15 09:50:17 -0700 |
commit | e94c8264ba28b3960e6c35ddf0e4377048d82801 (patch) | |
tree | e1a4829f64d4c8cf2ffe1f59413520d41657d015 | |
parent | 5ca60166243b0671b4a7e62938b13feacd2391e2 (diff) | |
download | navit-e94c8264ba28b3960e6c35ddf0e4377048d82801.tar.gz |
graphics_qt5 QML: Add screen rotation support (#255)R7550
Now the QML qt5 graphics happily rotates according to screen
orientation. At least on Sailfish. Should do on other QML hardware as
well. Hard to test, as PC's usually don't have screen rotation support.
-rw-r--r-- | navit/graphics/qt5/loader.qml | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/navit/graphics/qt5/loader.qml b/navit/graphics/qt5/loader.qml index 6901c2c6f..ed9425bf7 100644 --- a/navit/graphics/qt5/loader.qml +++ b/navit/graphics/qt5/loader.qml @@ -4,17 +4,36 @@ import QtQuick.Window 2.0 Window { width: 200; height: 200 - - Loader { - id: navit_loader - focus: true - source: "graphics_qt5.qml" - anchors.fill: parent - objectName: "navit_loader" - } + + Screen.orientationUpdateMask: Qt.PortraitOrientation + Qt.LandscapeOrientation + Qt.InvertedPortraitOrientation + Qt.InvertedLandscapeOrientation Item { - id: root_item + id: root anchors.fill: parent + Loader { + width: root.width + height: root.height + anchors.centerIn: parent + Screen.onOrientationChanged: { + rotation = Screen.angleBetween(Screen.orientation , Screen.primaryOrientation) + switch(Screen.angleBetween(Screen.orientation , Screen.primaryOrientation)) + { + case 0: + case 180: + width = root.width + height = root.height + break + case 90: + case 270: + width = root.height + height = root.width + break + } + } + id: navit_loader + focus: true + source: "graphics_qt5.qml" + objectName: "navit_loader" + } } } |