on xenial help sign in
Propagate orientation to all child surfaces, update tests to suit
dd79fb9Gerry Boland
qml/Stages/ApplicationWindow.qml+1−6
@@ -112,6 +112,7 @@ Item {
112 id: sessionContainer
112 id: sessionContainer
113 session: application ? application.session : null
113 session: application ? application.session : null
114 anchors.fill: parent
114 anchors.fill: parent
115+ orientation: root.orientation
115
116
116 onSurfaceChanged: {
117 onSurfaceChanged: {
117 if (sessionContainer.surface) {
118 if (sessionContainer.surface) {
@@ -121,12 +122,6 @@ Item {
121 d.surfaceInitialized = false;
122 d.surfaceInitialized = false;
122 }
123 }
123 }
124 }
124−
125− Binding {
126− target: sessionContainer.surface
127− property: "orientation"
128− value: root.orientation
129− }
130 }
125 }
131
126
132 StateGroup {
127 StateGroup {
qml/Stages/SessionContainer.qml+7
@@ -24,12 +24,14 @@ Item {
24 readonly property var childSessions: session ? session.childSessions : null
24 readonly property var childSessions: session ? session.childSessions : null
25 readonly property alias surface: _surfaceContainer.surface
25 readonly property alias surface: _surfaceContainer.surface
26 property bool interactive: true
26 property bool interactive: true
27+ property int orientation
27
28
28 readonly property alias surfaceContainer: _surfaceContainer
29 readonly property alias surfaceContainer: _surfaceContainer
29 SurfaceContainer {
30 SurfaceContainer {
30 id: _surfaceContainer
31 id: _surfaceContainer
31 anchors.fill: parent
32 anchors.fill: parent
32 surface: session ? session.surface : null
33 surface: session ? session.surface : null
34+ orientation: root.orientation
33 }
35 }
34
36
35 Binding {
37 Binding {
@@ -74,6 +76,11 @@ Item {
74 target: item; when: item
76 target: item; when: item
75 property: "height"; value: root.height
77 property: "height"; value: root.height
76 }
78 }
79+
80+ Binding {
81+ target: item; when: item
82+ property: "orientation"; value: root.orientation
83+ }
77 }
84 }
78 }
85 }
79
86
qml/Stages/SurfaceContainer.qml+5
@@ -22,6 +22,7 @@ Item {
22 objectName: "surfaceContainer"
22 objectName: "surfaceContainer"
23 property Item surface: null
23 property Item surface: null
24 property bool hadSurface: false
24 property bool hadSurface: false
25+ property int orientation
25
26
26 onSurfaceChanged: {
27 onSurfaceChanged: {
27 if (surface) {
28 if (surface) {
@@ -34,6 +35,10 @@ Item {
34 target: surface
35 target: surface
35 property: "anchors.fill"; value: root
36 property: "anchors.fill"; value: root
36 }
37 }
38+ Binding {
39+ target: surface
40+ property: "orientation"; value: root.orientation
41+ }
37
42
38 states: [
43 states: [
39 State {
44 State {
tests/qmltests/Stages/tst_ApplicationWindow.qml+19
@@ -50,6 +50,7 @@ Rectangle {
50 ApplicationWindow {
50 ApplicationWindow {
51 anchors.fill: parent
51 anchors.fill: parent
52 application: fakeApplication
52 application: fakeApplication
53+ orientation: Qt.PortraitOrientation
53 }
54 }
54 }
55 }
55 FocusScope {
56 FocusScope {
@@ -147,6 +148,24 @@ Rectangle {
147 }
148 }
148 }
149 }
149
150
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+
150 }
169 }
151 }
170 }
152
171
tests/qmltests/Stages/tst_PhoneStage.qml+2−1
@@ -32,6 +32,7 @@ Item {
32 dragAreaWidth: units.gu(2)
32 dragAreaWidth: units.gu(2)
33 maximizedAppTopMargin: units.gu(3) + units.dp(2)
33 maximizedAppTopMargin: units.gu(3) + units.dp(2)
34 interactive: true
34 interactive: true
35+ orientation: Qt.PortraitOrientation
35 }
36 }
36
37
37 Binding {
38 Binding {
@@ -70,7 +71,7 @@ Item {
70 }
71 }
71 Button {
72 Button {
72 anchors { left: parent.left; right: parent.right }
73 anchors { left: parent.left; right: parent.right }
73− text: "Rotate device \u27F2"
74+ text: "Rotate device \u27F3"
74 onClicked: {
75 onClicked: {
75 if (phoneStage.orientation == Qt.PortraitOrientation) {
76 if (phoneStage.orientation == Qt.PortraitOrientation) {
76 phoneStage.orientation = Qt.LandscapeOrientation;
77 phoneStage.orientation = Qt.LandscapeOrientation;