@@ -17,23 +17,17 @@
1717import QtQuick 2.0
1818import QtQuick.Window 2.0
1919import Ubuntu.Components 0.1
20+import "Components"
2021
2122Item {
2223 id: orientedShell
2324
2425 // this is only here to select the width / height of the window if not running fullscreen
25− property bool tablet: false
26− width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
27− height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
26+ //property bool tablet: false
27+ //width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
28+ //height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
2829
2930 property int acceptedOrientationAngle: {
30− // check device name and fix orientation if necessary
31− if (applicationArguments.device() === "flo") {
32− return Screen.angleBetween(Screen.primaryOrientation, Qt.InvertedLandscapeOrientation);
33− } else if (applicationArguments.device() === "manta") {
34− return Screen.angleBetween(Screen.primaryOrientation, Qt.LandscapeOrientation);
35− }
36−
3731 var screenOrientation = Screen.orientation;
3832 var acceptedOrientation;
3933
@@ -90,13 +84,25 @@ Item {
9084 name: "0"
9185 PropertyChanges {
9286 target: shell
93− rotation: 0
87+ transformRotationAngle: 0
9488 x: 0
9589 y: 0
9690 width: orientedShell.width
9791 height: orientedShell.height
9892 }
9993 },
94+ State {
95+ name: "90"
96+ PropertyChanges {
97+ target: shell
98+ transformRotationAngle: 90
99+ x: 0
100+ y: 0
101+ width: orientedShell.height
102+ height: orientedShell.width
103+ }
104+ },
105+ // FIXME: 180 and 270 need to be updated
100106 State {
101107 name: "180"
102108 PropertyChanges {
@@ -118,22 +124,78 @@ Item {
118124 width: orientedShell.height
119125 height: orientedShell.width
120126 }
127+ }
128+ ]
129+
130+
131+ property int rotationDuration: 450
132+ property int rotationEasing: Easing.InOutCubic
133+ // Those values are good for debugging/development
134+ //property int rotationDuration: 6000
135+ //property int rotationEasing: Easing.Linear
136+
137+ transitions: [
138+ Transition {
139+ from: "90"
140+ to: "0"
141+ enabled: ready
142+ SequentialAnimation {
143+ ScriptAction { script: { windowScreenshot.take(); } }
144+ PropertyAction { target: windowScreenshot; property: "visible"; value: true }
145+ PropertyAction { target: shell; property: "width"; value: orientedShell.width }
146+ PropertyAction { target: shell; property: "height"; value: orientedShell.height }
147+ PropertyAction { target: shell; property: "transformRotationAngle"; value: 90 }
148+ ParallelAnimation {
149+ NumberAnimation { target: shell; property: "opacity"; from: 0; to: 1; duration: rotationDuration; easing.type: rotationEasing }
150+ NumberAnimation { target: shell; property: "transformRotationAngle"; to: 0; duration: rotationDuration; easing.type: rotationEasing }
151+
152+ NumberAnimation { target: windowScreenshot; property: "opacity"; from: 1; to: 0; duration: rotationDuration; easing.type: rotationEasing }
153+ NumberAnimation { target: windowScreenshot; property: "transformRotationAngle"; from: 0; to: -90; duration: rotationDuration; easing.type: rotationEasing }
154+ }
155+ PropertyAction { target: windowScreenshot; property: "visible"; value: false }
156+ }
121157 },
122− State {
123− name: "90"
124− PropertyChanges {
125− target: shell
126− rotation: 90
127− x: orientedShell.width
128− y: 0
129− width: orientedShell.height
130− height: orientedShell.width
158+ Transition {
159+ from: "0"
160+ to: "90"
161+ enabled: ready
162+ SequentialAnimation {
163+ ScriptAction { script: { windowScreenshot.take(); } }
164+ PropertyAction { target: windowScreenshot; property: "visible"; value: true }
165+ PropertyAction { target: shell; property: "width"; value: orientedShell.height }
166+ PropertyAction { target: shell; property: "height"; value: orientedShell.width }
167+ PropertyAction { target: shell; property: "transformRotationAngle"; value: 0 }
168+ ParallelAnimation {
169+ NumberAnimation { target: shell; property: "opacity"; from: 0; to: 1; duration: rotationDuration; easing.type: rotationEasing }
170+ NumberAnimation { target: shell; property: "transformRotationAngle"; to: 90; duration: rotationDuration; easing.type: rotationEasing }
171+
172+ NumberAnimation { target: windowScreenshot; property: "opacity"; from: 1; to: 0; duration: rotationDuration; easing.type: rotationEasing }
173+ NumberAnimation { target: windowScreenshot; property: "transformRotationAngle"; from: 0; to: 90; duration: rotationDuration; easing.type: rotationEasing }
174+ }
175+ PropertyAction { target: windowScreenshot; property: "visible"; value: false }
131176 }
132177 }
133178 ]
134179
135180 Shell {
136181 id: shell
137− transformOrigin: Item.TopLeft
182+ property real transformRotationAngle: 0
183+
184+ transform: Rotation {
185+ origin.x: orientedShell.width / 2; origin.y: orientedShell.width / 2; axis { x: 0; y: 0; z: 1 }
186+ angle: shell.transformRotationAngle
187+ }
188+ }
189+
190+ WindowScreenshot {
191+ id: windowScreenshot
192+ visible: false
193+
194+ property real transformRotationAngle: 0
195+
196+ transform: Rotation {
197+ origin.x: orientedShell.width / 2; origin.y: orientedShell.width / 2; axis { x: 0; y: 0; z: 1 }
198+ angle: windowScreenshot.transformRotationAngle
199+ }
138200 }
139201}