on xenial help sign in
Propagate orientation to all child surfaces, update tests to suit
commitdd79fb9c25e219913be3d1b136e70fcd8de7be9a authorGerry Boland <gerry.boland@canonical.com> dateThu 11 Sep 2014, 11:41 (12 years ago) parente74a121
5 files changed+34−7
qml/Stages/ApplicationWindow.qml+1−6 qml/Stages/SessionContainer.qml+7 qml/Stages/SurfaceContainer.qml+5 tests/qmltests/Stages/tst_ApplicationWindow.qml+19 tests/qmltests/Stages/tst_PhoneStage.qml+2−1
qml/Stages/ApplicationWindow.qml+1−6
@@ -112,6 +112,7 @@ Item {
112112 id: sessionContainer
113113 session: application ? application.session : null
114114 anchors.fill: parent
115+ orientation: root.orientation
115116
116117 onSurfaceChanged: {
117118 if (sessionContainer.surface) {
@@ -121,12 +122,6 @@ Item {
121122 d.surfaceInitialized = false;
122123 }
123124 }
124−
125− Binding {
126− target: sessionContainer.surface
127− property: "orientation"
128− value: root.orientation
129− }
130125 }
131126
132127 StateGroup {
qml/Stages/SessionContainer.qml+7
@@ -24,12 +24,14 @@ Item {
2424 readonly property var childSessions: session ? session.childSessions : null
2525 readonly property alias surface: _surfaceContainer.surface
2626 property bool interactive: true
27+ property int orientation
2728
2829 readonly property alias surfaceContainer: _surfaceContainer
2930 SurfaceContainer {
3031 id: _surfaceContainer
3132 anchors.fill: parent
3233 surface: session ? session.surface : null
34+ orientation: root.orientation
3335 }
3436
3537 Binding {
@@ -74,6 +76,11 @@ Item {
7476 target: item; when: item
7577 property: "height"; value: root.height
7678 }
79+
80+ Binding {
81+ target: item; when: item
82+ property: "orientation"; value: root.orientation
83+ }
7784 }
7885 }
7986
qml/Stages/SurfaceContainer.qml+5
@@ -22,6 +22,7 @@ Item {
2222 objectName: "surfaceContainer"
2323 property Item surface: null
2424 property bool hadSurface: false
25+ property int orientation
2526
2627 onSurfaceChanged: {
2728 if (surface) {
@@ -34,6 +35,10 @@ Item {
3435 target: surface
3536 property: "anchors.fill"; value: root
3637 }
38+ Binding {
39+ target: surface
40+ property: "orientation"; value: root.orientation
41+ }
3742
3843 states: [
3944 State {
tests/qmltests/Stages/tst_ApplicationWindow.qml+19
@@ -50,6 +50,7 @@ Rectangle {
5050 ApplicationWindow {
5151 anchors.fill: parent
5252 application: fakeApplication
53+ orientation: Qt.PortraitOrientation
5354 }
5455 }
5556 FocusScope {
@@ -147,6 +148,24 @@ Rectangle {
147148 }
148149 }
149150
151+ Button {
152+ anchors { left: parent.left; right: parent.right }
153+ text: "Rotate device \u27F3"
154+ onClicked: {
155+ var orientation = applicationWindowLoader.item.orientation
156+ if (orientation == Qt.PortraitOrientation) {
157+ orientation = Qt.LandscapeOrientation;
158+ } else if (orientation == Qt.LandscapeOrientation) {
159+ orientation = Qt.InvertedPortraitOrientation;
160+ } else if (orientation == Qt.InvertedPortraitOrientation) {
161+ orientation = Qt.InvertedLandscapeOrientation;
162+ } else {
163+ orientation = Qt.PortraitOrientation;
164+ }
165+ applicationWindowLoader.item.orientation = orientation;
166+ }
167+ }
168+
150169 }
151170 }
152171
tests/qmltests/Stages/tst_PhoneStage.qml+2−1
@@ -32,6 +32,7 @@ Item {
3232 dragAreaWidth: units.gu(2)
3333 maximizedAppTopMargin: units.gu(3) + units.dp(2)
3434 interactive: true
35+ orientation: Qt.PortraitOrientation
3536 }
3637
3738 Binding {
@@ -70,7 +71,7 @@ Item {
7071 }
7172 Button {
7273 anchors { left: parent.left; right: parent.right }
73− text: "Rotate device \u27F2"
74+ text: "Rotate device \u27F3"
7475 onClicked: {
7576 if (phoneStage.orientation == Qt.PortraitOrientation) {
7677 phoneStage.orientation = Qt.LandscapeOrientation;