@@ -82,12 +82,69 @@ FocusScope {
83 QtObject {
83 QtObject {
85+ objectName: "spreadDelegatePriv"
85 property bool startingUp: true
86 property bool startingUp: true
88 Component.onCompleted: { finishStartUpTimer.start(); }
89 Component.onCompleted: { finishStartUpTimer.start(); }
89 Timer { id: finishStartUpTimer; interval: 400; onTriggered: priv.startingUp = false }
90 Timer { id: finishStartUpTimer; interval: 400; onTriggered: priv.startingUp = false }
92+ // JS version of QPlatformScreen::angleBetween C++ implementation.
93+ // So don't ask me how it works because I don't know.
94+ // Calling Screen.angleBetween from within a Binding component doesn't work for some reason.
95+ function angleBetween(a, b) {
99+ var ia = Math.log(a) / Math.LN2;
100+ var ib = Math.log(b) / Math.LN2;
102+ var delta = ia - ib;
107+ var angles = [ 0, 90, 180, 270 ];
108+ return angles[delta];
111+ // Sets the initial orientationAngle of the window, when it first slides into view
112+ // (with the splash screen likely being displayed). At that point we just try to
113+ // match shell's current orientation. We need a bit of time in this state as the
114+ // information we need to decide orientationAngle may take a few cycles to
117+ target: appWindowWithShadow
118+ property: "orientationAngle"
119+ when: priv.startingUp
121+ var supportedOrientations = root.supportedOrientations;
123+ if (supportedOrientations === Qt.PrimaryOrientation) {
124+ supportedOrientations = root.orientations.primary;
127+ // If it doesn't support shell's current orientation
128+ // then simply pick some arbitraty one that it does support
129+ var chosenOrientation = 0;
130+ if (supportedOrientations & root.shellOrientation) {
131+ chosenOrientation = root.shellOrientation;
132+ } else if (supportedOrientations & Qt.PortraitOrientation) {
133+ chosenOrientation = root.orientations.portrait;
134+ } else if (supportedOrientations & Qt.LandscapeOrientation) {
135+ chosenOrientation = root.orientations.landscape;
136+ } else if (supportedOrientations & Qt.InvertedPortraitOrientation) {
137+ chosenOrientation = root.orientations.invertedPortrait;
138+ } else if (supportedOrientations & Qt.InvertedLandscapeOrientation) {
139+ chosenOrientation = root.orientations.invertedLandscape;
141+ chosenOrientation = root.orientations.primary;
144+ return angleBetween(root.orientations.native_, chosenOrientation);
91 Rectangle {
148 Rectangle {
92 id: background
149 id: background
93 color: "black"
150 color: "black"
@@ -129,9 +186,7 @@ FocusScope {
132− if (priv.startingUp) {
133− return "startingUp";
134− } else if (root.application && root.application.rotatesWindowContents) {
189+ if (root.application && root.application.rotatesWindowContents) {
135 return "counterRotate";
190 return "counterRotate";
136 } else if (orientationChangeAnimation.running) {
191 } else if (orientationChangeAnimation.running) {
137 return "animatingRotation";
192 return "animatingRotation";
@@ -149,109 +204,29 @@ FocusScope {
151 states: [
206 states: [
152− // Sets the initial orientationAngle of the window, when it first slides into view
153− // (with the splash screen likely being displayed). At that point we just try to
154− // match shell's current orientation. We need a bit of time in this state as the
155− // information we need to decide orientationAngle may take a few cycles to
160− target: appWindowWithShadow
161− restoreEntryValues: false
163− if (!root.application || root.application.rotatesWindowContents) {
167− var supportedOrientations = root.supportedOrientations;
169− if (supportedOrientations === Qt.PrimaryOrientation) {
170− supportedOrientations = root.orientations.primary;
173− // If it doesn't support shell's current orientation
174− // then simply pick some arbitraty one that it does support
175− var chosenOrientation = 0;
176− if (supportedOrientations & root.shellOrientation) {
177− chosenOrientation = root.shellOrientation;
178− } else if (supportedOrientations & Qt.PortraitOrientation) {
179− chosenOrientation = root.orientations.portrait;
180− } else if (supportedOrientations & Qt.LandscapeOrientation) {
181− chosenOrientation = root.orientations.landscape;
182− } else if (supportedOrientations & Qt.InvertedPortraitOrientation) {
183− chosenOrientation = root.orientations.invertedPortrait;
184− } else if (supportedOrientations & Qt.InvertedLandscapeOrientation) {
185− chosenOrientation = root.orientations.invertedLandscape;
187− chosenOrientation = root.orientations.primary;
190− return Screen.angleBetween(root.orientations.native_, chosenOrientation);
193− rotation: normalizeAngle(appWindowWithShadow.orientationAngle - root.shellOrientationAngle)
195− if (rotation == 0 || rotation == 180) {
202− if (rotation == 0 || rotation == 180)
209 // In this state we stick to our currently set orientationAngle, which may change only due
207 // In this state we stick to our currently set orientationAngle, which may change only due
210 // to calls made to matchShellOrientation() or animateToShellOrientation()
208 // to calls made to matchShellOrientation() or animateToShellOrientation()
212− id: keepSceneRotationState
213 name: "keepSceneRotation"
210 name: "keepSceneRotation"
215− StateChangeScript { script: {
217− appWindowWithShadow.orientationAngle = appWindowWithShadow.orientationAngle;
219 PropertyChanges {
211 PropertyChanges {
220 target: appWindowWithShadow
212 target: appWindowWithShadow
221 restoreEntryValues: false
213 restoreEntryValues: false
222 rotation: normalizeAngle(appWindowWithShadow.orientationAngle - root.shellOrientationAngle)
214 rotation: normalizeAngle(appWindowWithShadow.orientationAngle - root.shellOrientationAngle)
224− if (rotation == 0 || rotation == 180) {
231− if (rotation == 0 || rotation == 180)
238 // In this state we counteract any shell rotation so that the window, in scene coordinates,
217 // In this state we counteract any shell rotation so that the window, in scene coordinates,
239 // remains unrotated.
218 // remains unrotated.
219+ // But the splash screen should still obey the set orientationAngle set by shell
241 name: "counterRotate"
221 name: "counterRotate"
242− StateChangeScript { script: {
244− appWindowWithShadow.orientationAngle = appWindowWithShadow.orientationAngle;
246 PropertyChanges {
222 PropertyChanges {
247 target: appWindowWithShadow
223 target: appWindowWithShadow
248− width: root.shellOrientationAngle == 0 || root.shellOrientationAngle == 180 ? root.width : root.height
249− height: root.shellOrientationAngle == 0 || root.shellOrientationAngle == 180 ? root.height : root.width
250 rotation: normalizeAngle(-root.shellOrientationAngle)
224 rotation: normalizeAngle(-root.shellOrientationAngle)
252 PropertyChanges {
226 PropertyChanges {
253 target: appWindow
227 target: appWindow
254 surfaceOrientationAngle: appWindowWithShadow.orientationAngle
228 surfaceOrientationAngle: appWindowWithShadow.orientationAngle
229+ splashRotation: appWindowWithShadow.orientationAngle
@@ -259,8 +234,9 @@ FocusScope {
262− x: (parent.width - width) / 2
237+ anchors.centerIn: parent
263− y: (parent.height - height) / 2
238+ width: rotation == 0 || rotation == 180 ? root.width : root.height
239+ height: rotation == 0 || rotation == 180 ? root.height : root.width
265 BorderImage {
241 BorderImage {
266 anchors {
242 anchors {