summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Olszak <olszak.tomasz@gmail.com>2013-10-04 23:19:25 +0200
committerTomasz Olszak <olszak.tomasz@gmail.com>2014-07-04 17:06:07 +0200
commited075c703c0a03c75957fcd59fc6ac77a47115f8 (patch)
tree76020c43d2d73a157c2acca65c795ce024bc1145
parent00fa1f33a86e5d1bd7ae44c4c6cfb5a7e630bb63 (diff)
downloadqtquickcontrols-ed075c703c0a03c75957fcd59fc6ac77a47115f8.tar.gz
qtquickcontrols-ed075c703c0a03c75957fcd59fc6ac77a47115f8.tar.bz2
qtquickcontrols-ed075c703c0a03c75957fcd59fc6ac77a47115f8.zip
ApplicationWindow: added content orientation handling.
On platforms that does not rotate whole screen when device orientation changes, ApplicationWindow can handle it by itslef by rotating main part of contentItem. Change-Id: I32b1611718d290eb49ab774a5c310fb12ebbfd83 Reviewed-by: Tomasz Olszak <olszak.tomasz@gmail.com>
-rw-r--r--src/controls/ApplicationWindow.qml16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml
index fa9225be..1ce4d433 100644
--- a/src/controls/ApplicationWindow.qml
+++ b/src/controls/ApplicationWindow.qml
@@ -179,6 +179,14 @@ Window {
onVisibleChanged: { if (visible && menuBar) { menuBar.__parentWindow = root } }
+ /*!
+ \qmlproperty bool ApplicationWindow::contentFollowsContentOrientation
+
+ When set to true then main scene Item is rotated by
+ Screen.angleBetween(contentOrientation, Qt.PortraitOrientation) degrees.
+ */
+ property bool contentFollowsContentOrientation: false
+
/*! \internal */
default property alias data: contentArea.data
@@ -194,7 +202,13 @@ Window {
Item {
id: backgroundItem
- anchors.fill: parent
+ anchors.centerIn: root.contentItem
+ property bool isPortrait: contentOrientation === Qt.PortraitOrientation || contentOrientation === Qt.InvertedPortraitOrientation
+ objectName: "backgroundItem"
+
+ width: (!contentFollowsContentOrientation || backgroundItem.isPortrait) ? root.width : root.height
+ height: (!contentFollowsContentOrientation || backgroundItem.isPortrait) ? root.height : root.width
+ rotation: contentFollowsContentOrientation ? Screen.angleBetween(contentOrientation, Qt.PrimaryOrientation) : 0
Keys.forwardTo: menuBar ? [menuBar.__contentItem] : []