@@ -1,459 +0,0 @@
2− * Copyright (C) 2014 Canonical, Ltd.
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18−import QtQuick.Window 2.0
19−import Ubuntu.Components 0.1
23− // white background when dash is shown to better match Dashes own background, making for
24− // a nicer rotation animation effect. If gives the illusion that the dash is always taking the entire
25− // screen during the rotation.
26− color: shell.dashShown ? "white" : "black"
29− // this is only here to select the width / height of the window if not running fullscreen
30− property bool tablet: false
31− width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
32− height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
34− // Hack to avoid animating during startup
35− property bool ready: false
36− Timer { id: readyTimer; interval: 50; onTriggered: ready = true }
37− Component.onCompleted: readyTimer.start()
39− property int acceptedOrientationAngle: {
40− var screenOrientation = Screen.orientation;
41− var acceptedOrientation;
43− if (screenOrientation & shell.supportedScreenOrientations) {
44− acceptedOrientation = screenOrientation;
46− // try orientations at -90, 90 and 180
47− switch (screenOrientation) {
48− case Qt.PortraitOrientation:
49− if (Qt.LandscapeOrientation & shell.supportedScreenOrientations) {
50− acceptedOrientation = Qt.LandscapeOrientation;
51− } else if (Qt.InvertedLandscapeOrientation & shell.supportedScreenOrientations) {
52− acceptedOrientation = Qt.InvertedLandscapeOrientation;
54− acceptedOrientation = Qt.InvertedPortraitOrientation;
57− case Qt.InvertedPortraitOrientation:
58− if (Qt.LandscapeOrientation & shell.supportedScreenOrientations) {
59− acceptedOrientation = Qt.LandscapeOrientation;
60− } else if (Qt.InvertedLandscapeOrientation & shell.supportedScreenOrientations) {
61− acceptedOrientation = Qt.InvertedLandscapeOrientation;
63− acceptedOrientation = Qt.PortraitOrientation;
66− case Qt.LandscapeOrientation:
67− if (Qt.PortraitOrientation & shell.supportedScreenOrientations) {
68− acceptedOrientation = Qt.PortraitOrientation;
69− } else if (Qt.InvertedPortraitOrientation & shell.supportedScreenOrientations) {
70− acceptedOrientation = Qt.InvertedPortraitOrientation;
72− acceptedOrientation = Qt.InvertedLandscapeOrientation;
75− default: // Qt.InvertedLandscapeOrientation
76− if (Qt.PortraitOrientation & shell.supportedScreenOrientations) {
77− acceptedOrientation = Qt.PortraitOrientation;
78− } else if (Qt.InvertedPortraitOrientation & shell.supportedScreenOrientations) {
79− acceptedOrientation = Qt.InvertedPortraitOrientation;
81− acceptedOrientation = Qt.LandscapeOrientation;
87− return Screen.angleBetween(Screen.primaryOrientation, acceptedOrientation);
90− state: acceptedOrientationAngle.toString()
96− transformRotationAngle: 0
97− transformOriginX: orientedShell.width / 2
98− transformOriginY: orientedShell.width / 2
101− width: orientedShell.width
102− height: orientedShell.height
109− transformRotationAngle: 90
110− transformOriginX: orientedShell.width / 2
111− transformOriginY: orientedShell.width / 2
114− width: orientedShell.height
115− height: orientedShell.width
122− transformRotationAngle: 180
123− transformOriginX: orientedShell.width / 2
124− transformOriginY: orientedShell.width / 2
126− y: orientedShell.height - orientedShell.width
127− width: orientedShell.width
128− height: orientedShell.height
135− transformRotationAngle: -90
136− transformOriginX: orientedShell.height / 2
137− transformOriginY: orientedShell.height / 2
140− width: orientedShell.height
141− height: orientedShell.width
147− property int rotationDuration: 450
148− property int rotationEasing: Easing.InOutCubic
149− // Those values are good for debugging/development
150− //property int rotationDuration: 6000
151− //property int rotationEasing: Easing.Linear
158− SequentialAnimation {
159− ScriptAction { script: { windowScreenshot.take(); } }
160− PropertyAction { target: windowScreenshot; property: "visible"; value: true }
161− PropertyAction { target: shell; property: "width"; value: orientedShell.width }
162− PropertyAction { target: shell; property: "height"; value: orientedShell.height }
163− PropertyAction { target: shell; property: "transformRotationAngle"; value: 90 }
164− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.width / 2 }
165− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.width / 2 }
166− PropertyAction { target: windowScreenshot; property: "transformOriginX"; value: orientedShell.width / 2 }
167− PropertyAction { target: windowScreenshot; property: "transformOriginY"; value: orientedShell.width / 2 }
168− PropertyAction { target: windowScreenshot; property: "y"; value: 0 }
170− NumberAnimation { target: shell; property: "opacity"; from: 0; to: 1; duration: rotationDuration; easing.type: rotationEasing }
171− NumberAnimation { target: shell; property: "transformRotationAngle"; to: 0; duration: rotationDuration; easing.type: rotationEasing }
173− NumberAnimation { target: windowScreenshot; property: "opacity"; from: 1; to: 0; duration: rotationDuration; easing.type: rotationEasing }
174− NumberAnimation { target: windowScreenshot; property: "transformRotationAngle"; from: 0; to: -90; duration: rotationDuration; easing.type: rotationEasing }
176− PropertyAction { target: windowScreenshot; property: "visible"; value: false }
177− ScriptAction { script: { windowScreenshot.discard(); } }
184− SequentialAnimation {
185− ScriptAction { script: { windowScreenshot.take(); } }
186− PropertyAction { target: windowScreenshot; property: "visible"; value: true }
187− PropertyAction { target: shell; property: "width"; value: orientedShell.height }
188− PropertyAction { target: shell; property: "height"; value: orientedShell.width }
189− PropertyAction { target: shell; property: "transformRotationAngle"; value: 0 }
190− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.width / 2 }
191− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.width / 2 }
192− PropertyAction { target: windowScreenshot; property: "transformOriginX"; value: orientedShell.width / 2 }
193− PropertyAction { target: windowScreenshot; property: "transformOriginY"; value: orientedShell.width / 2 }
194− PropertyAction { target: windowScreenshot; property: "y"; value: 0 }
196− NumberAnimation { target: shell; property: "opacity"; from: 0; to: 1; duration: rotationDuration; easing.type: rotationEasing }
197− NumberAnimation { target: shell; property: "transformRotationAngle"; to: 90; duration: rotationDuration; easing.type: rotationEasing }
199− NumberAnimation { target: windowScreenshot; property: "opacity"; from: 1; to: 0; duration: rotationDuration; easing.type: rotationEasing }
200− NumberAnimation { target: windowScreenshot; property: "transformRotationAngle"; from: 0; to: 90; duration: rotationDuration; easing.type: rotationEasing }
202− PropertyAction { target: windowScreenshot; property: "visible"; value: false }
203− ScriptAction { script: { windowScreenshot.discard(); } }
210− SequentialAnimation {
211− ScriptAction { script: { windowScreenshot.take(); } }
212− PropertyAction { target: windowScreenshot; property: "visible"; value: true }
213− PropertyAction { target: shell; property: "width"; value: orientedShell.height }
214− PropertyAction { target: shell; property: "height"; value: orientedShell.width }
215− PropertyAction { target: shell; property: "transformRotationAngle"; value: 0 }
216− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.height / 2 }
217− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.height / 2 }
218− PropertyAction { target: windowScreenshot; property: "transformOriginX"; value: orientedShell.height / 2 }
219− PropertyAction { target: windowScreenshot; property: "transformOriginY"; value: orientedShell.height / 2 }
220− PropertyAction { target: windowScreenshot; property: "y"; value: 0 }
222− NumberAnimation { target: shell; property: "opacity"; from: 0; to: 1; duration: rotationDuration; easing.type: rotationEasing }
223− NumberAnimation { target: shell; property: "transformRotationAngle"; to: -90; duration: rotationDuration; easing.type: rotationEasing }
225− NumberAnimation { target: windowScreenshot; property: "opacity"; from: 1; to: 0; duration: rotationDuration; easing.type: rotationEasing }
226− NumberAnimation { target: windowScreenshot; property: "transformRotationAngle"; from: 0; to: -90; duration: rotationDuration; easing.type: rotationEasing }
228− PropertyAction { target: windowScreenshot; property: "visible"; value: false }
229− ScriptAction { script: { windowScreenshot.discard(); } }
236− SequentialAnimation {
237− ScriptAction { script: { windowScreenshot.take(); } }
238− PropertyAction { target: windowScreenshot; property: "visible"; value: true }
239− PropertyAction { target: shell; property: "width"; value: orientedShell.width }
240− PropertyAction { target: shell; property: "height"; value: orientedShell.height }
241− PropertyAction { target: shell; property: "transformRotationAngle"; value: -90 }
242− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.height / 2 }
243− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.height / 2 }
244− PropertyAction { target: windowScreenshot; property: "transformOriginX"; value: orientedShell.height / 2 }
245− PropertyAction { target: windowScreenshot; property: "transformOriginY"; value: orientedShell.height / 2 }
246− PropertyAction { target: windowScreenshot; property: "y"; value: 0 }
248− NumberAnimation { target: shell; property: "opacity"; from: 0; to: 1; duration: rotationDuration; easing.type: rotationEasing }
249− NumberAnimation { target: shell; property: "transformRotationAngle"; to: 0; duration: rotationDuration; easing.type: rotationEasing }
251− NumberAnimation { target: windowScreenshot; property: "opacity"; from: 1; to: 0; duration: rotationDuration; easing.type: rotationEasing }
252− NumberAnimation { target: windowScreenshot; property: "transformRotationAngle"; from: 0; to: 90; duration: rotationDuration; easing.type: rotationEasing }
254− PropertyAction { target: windowScreenshot; property: "visible"; value: false }
255− ScriptAction { script: { windowScreenshot.discard(); } }
262− SequentialAnimation {
263− ScriptAction { script: { windowScreenshot.take(); } }
264− PropertyAction { target: windowScreenshot; property: "visible"; value: true }
265− PropertyAction { target: shell; property: "width"; value: orientedShell.width }
266− PropertyAction { target: shell; property: "height"; value: orientedShell.height }
267− PropertyAction { target: shell; property: "transformRotationAngle"; value: 90 }
268− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.width / 2 }
269− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.width / 2 }
270− PropertyAction { target: windowScreenshot; property: "transformOriginX"; value: orientedShell.width / 2 }
271− PropertyAction { target: windowScreenshot; property: "transformOriginY"; value: orientedShell.width / 2 }
272− PropertyAction { target: windowScreenshot; property: "y"; value: 0 }
274− NumberAnimation { target: shell; property: "opacity"; from: 0; to: 1; duration: rotationDuration; easing.type: rotationEasing }
275− NumberAnimation { target: shell; property: "transformRotationAngle"; to: 180; duration: rotationDuration; easing.type: rotationEasing }
276− NumberAnimation { target: shell; property: "y"; from: 0; to: orientedShell.height - orientedShell.width; duration: rotationDuration; easing.type: rotationEasing }
278− NumberAnimation { target: windowScreenshot; property: "opacity"; from: 1; to: 0; duration: rotationDuration; easing.type: rotationEasing }
279− NumberAnimation { target: windowScreenshot; property: "transformRotationAngle"; from: 0; to: 90; duration: rotationDuration; easing.type: rotationEasing }
280− NumberAnimation { target: windowScreenshot; property: "y"; from: 0; to: orientedShell.height - orientedShell.width; duration: rotationDuration; easing.type: rotationEasing }
282− PropertyAction { target: windowScreenshot; property: "visible"; value: false }
283− ScriptAction { script: { windowScreenshot.discard(); } }
290− SequentialAnimation {
291− ScriptAction { script: { windowScreenshot.take(); } }
292− PropertyAction { target: windowScreenshot; property: "visible"; value: true }
293− PropertyAction { target: shell; property: "width"; value: orientedShell.height }
294− PropertyAction { target: shell; property: "height"; value: orientedShell.width }
295− PropertyAction { target: shell; property: "transformRotationAngle"; value: 180 }
296− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.width / 2 }
297− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.width / 2 }
298− PropertyAction { target: windowScreenshot; property: "transformOriginX"; value: orientedShell.width / 2 }
299− PropertyAction { target: windowScreenshot; property: "transformOriginY"; value: orientedShell.height - (orientedShell.width / 2) }
300− PropertyAction { target: windowScreenshot; property: "y"; value: 0 }
302− NumberAnimation { target: shell; property: "opacity"; from: 0; to: 1; duration: rotationDuration; easing.type: rotationEasing }
303− NumberAnimation { target: shell; property: "transformRotationAngle"; to: 90; duration: rotationDuration; easing.type: rotationEasing }
304− NumberAnimation { target: shell; property: "y"; from: orientedShell.height - orientedShell.width; to: 0; duration: rotationDuration; easing.type: rotationEasing }
306− NumberAnimation { target: windowScreenshot; property: "opacity"; from: 1; to: 0; duration: rotationDuration; easing.type: rotationEasing }
307− NumberAnimation { target: windowScreenshot; property: "transformRotationAngle"; from: 0; to: -90; duration: rotationDuration; easing.type: rotationEasing }
308− NumberAnimation { target: windowScreenshot; property: "y"; from: 0; to: -orientedShell.height + orientedShell.width; duration: rotationDuration; easing.type: rotationEasing }
310− PropertyAction { target: windowScreenshot; property: "visible"; value: false }
311− ScriptAction { script: { windowScreenshot.discard(); } }
318− SequentialAnimation {
319− ScriptAction { script: { windowScreenshot.take(); } }
320− PropertyAction { target: windowScreenshot; property: "visible"; value: true }
321− PropertyAction { target: shell; property: "width"; value: orientedShell.height }
322− PropertyAction { target: shell; property: "height"; value: orientedShell.width }
323− PropertyAction { target: shell; property: "y"; value: orientedShell.height - orientedShell.width }
324− PropertyAction { target: shell; property: "transformRotationAngle"; value: 180 }
325− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.width / 2 }
326− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.width / 2 }
327− PropertyAction { target: windowScreenshot; property: "transformOriginX"; value: orientedShell.width / 2 }
328− PropertyAction { target: windowScreenshot; property: "transformOriginY"; value: orientedShell.height - (orientedShell.width / 2) }
329− PropertyAction { target: windowScreenshot; property: "y"; value: 0 }
331− NumberAnimation { target: shell; property: "opacity"; from: 0; to: 1; duration: rotationDuration; easing.type: rotationEasing }
332− NumberAnimation { target: shell; property: "transformRotationAngle"; to: 270; duration: rotationDuration; easing.type: rotationEasing }
334− NumberAnimation { target: windowScreenshot; property: "opacity"; from: 1; to: 0; duration: rotationDuration; easing.type: rotationEasing }
335− NumberAnimation { target: windowScreenshot; property: "transformRotationAngle"; from: 0; to: 90; duration: rotationDuration; easing.type: rotationEasing }
337− PropertyAction { target: windowScreenshot; property: "visible"; value: false }
338− ScriptAction { script: { windowScreenshot.discard(); } }
345− SequentialAnimation {
346− ScriptAction { script: { windowScreenshot.take(); } }
347− PropertyAction { target: windowScreenshot; property: "visible"; value: true }
348− PropertyAction { target: shell; property: "width"; value: orientedShell.width }
349− PropertyAction { target: shell; property: "height"; value: orientedShell.height }
350− PropertyAction { target: shell; property: "y"; value: orientedShell.height - orientedShell.width }
351− PropertyAction { target: shell; property: "transformRotationAngle"; value: 270 }
352− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.width / 2 }
353− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.width / 2 }
354− PropertyAction { target: windowScreenshot; property: "transformOriginX"; value: orientedShell.width / 2 }
355− PropertyAction { target: windowScreenshot; property: "transformOriginY"; value: orientedShell.height - (orientedShell.width / 2) }
356− PropertyAction { target: windowScreenshot; property: "y"; value: 0 }
358− NumberAnimation { target: shell; property: "opacity"; from: 0; to: 1; duration: rotationDuration; easing.type: rotationEasing }
359− NumberAnimation { target: shell; property: "transformRotationAngle"; to: 180; duration: rotationDuration; easing.type: rotationEasing }
361− NumberAnimation { target: windowScreenshot; property: "opacity"; from: 1; to: 0; duration: rotationDuration; easing.type: rotationEasing }
362− NumberAnimation { target: windowScreenshot; property: "transformRotationAngle"; from: 0; to: -90; duration: rotationDuration; easing.type: rotationEasing }
364− PropertyAction { target: windowScreenshot; property: "visible"; value: false }
365− ScriptAction { script: { windowScreenshot.discard(); } }
372− SequentialAnimation {
373− PropertyAction { target: shell; property: "y"; value: 0 }
374− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.width / 2 }
375− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.height / 2 }
377− NumberAnimation { target: shell; property: "transformRotationAngle"; from: 0; to: 180; duration: rotationDuration; easing.type: rotationEasing }
384− SequentialAnimation {
385− PropertyAction { target: shell; property: "y"; value: 0 }
386− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.width / 2 }
387− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.height / 2 }
389− NumberAnimation { target: shell; property: "transformRotationAngle"; from: 180; to: 0; duration: rotationDuration; easing.type: rotationEasing }
396− SequentialAnimation {
397− PropertyAction { target: shell; property: "x"; value: -(orientedShell.height - orientedShell.width) / 2 }
398− PropertyAction { target: shell; property: "y"; value: (orientedShell.height - orientedShell.width) / 2 }
399− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.height / 2 }
400− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.width / 2 }
402− NumberAnimation { target: shell; property: "transformRotationAngle"; from: 90; to: 270; duration: rotationDuration; easing.type: rotationEasing }
404− // Explicitly apply state "270" values as Qt doesn't seem to properly apply them after the transition is done
405− PropertyAction { target: shell; property: "x"; value: 0 }
406− PropertyAction { target: shell; property: "y"; value: 0 }
407− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.height / 2 }
408− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.height / 2 }
415− SequentialAnimation {
416− PropertyAction { target: shell; property: "x"; value: -(orientedShell.height - orientedShell.width) / 2 }
417− PropertyAction { target: shell; property: "y"; value: (orientedShell.height - orientedShell.width) / 2 }
418− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.height / 2 }
419− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.width / 2 }
421− NumberAnimation { target: shell; property: "transformRotationAngle"; from: 270; to: 90; duration: rotationDuration; easing.type: rotationEasing }
423− // Explicitly apply state "90" values as Qt doesn't seem to properly apply them after the transition is done
424− PropertyAction { target: shell; property: "x"; value: 0 }
425− PropertyAction { target: shell; property: "y"; value: 0 }
426− PropertyAction { target: shell; property: "transformOriginX"; value: orientedShell.width / 2 }
427− PropertyAction { target: shell; property: "transformOriginY"; value: orientedShell.width / 2 }
434− property real transformRotationAngle
435− property real transformOriginX
436− property real transformOriginY
438− transform: Rotation {
439− origin.x: shell.transformOriginX; origin.y: shell.transformOriginY; axis { x: 0; y: 0; z: 1 }
440− angle: shell.transformRotationAngle
445− id: windowScreenshot
447− width: orientedShell.width
448− height: orientedShell.height
450− property real transformRotationAngle
451− property real transformOriginX
452− property real transformOriginY
454− transform: Rotation {
455− origin.x: windowScreenshot.transformOriginX; origin.y: windowScreenshot.transformOriginY; axis { x: 0; y: 0; z: 1 }
456− angle: windowScreenshot.transformRotationAngle