on xenial help sign in
rebase on shellRotation
e835b8fMichael Zanetti
CMakeLists.txt+2
@@ -56,6 +56,8 @@ find_package(Qt5DBus 5.2 REQUIRED)
56find_package(Qt5Concurrent 5.2 REQUIRED)
56find_package(Qt5Concurrent 5.2 REQUIRED)
57find_package(Qt5Sql 5.2 REQUIRED)
57find_package(Qt5Sql 5.2 REQUIRED)
58
58
59+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=6)
60+
59# Standard install paths
61# Standard install paths
60include(GNUInstallDirs)
62include(GNUInstallDirs)
61
63
data/unity8-dash.desktop.in+1
@@ -7,3 +7,4 @@ Terminal=false
7Icon=
7Icon=
8NoDisplay=true
8NoDisplay=true
9X-Ubuntu-Touch=true
9X-Ubuntu-Touch=true
10+X-Ubuntu-Supported-Orientations=primary
debian/changelog+6
@@ -1,3 +1,9 @@
1+unity8 (8.10-0ubuntu1) UNRELEASED; urgency=medium
2+
3+ * Implement full-shell rotation (LP: #1210199)
4+
5+ -- Michał Sawicz <michal.sawicz@canonical.com> Wed, 15 Apr 2015 14:47:17 +0200
6+
1unity8 (8.02+15.04.20150511-0ubuntu1) vivid; urgency=medium
7unity8 (8.02+15.04.20150511-0ubuntu1) vivid; urgency=medium
2
8
3 [ Albert Astals Cid ]
9 [ Albert Astals Cid ]
debian/control+5−4
@@ -12,6 +12,7 @@ Build-Depends: cmake,
12# append :native to g++-4.9 so we don't try to run armhf g++
12# append :native to g++-4.9 so we don't try to run armhf g++
13# on an x86 CPU for eaxmple, when cross-compiling.
13# on an x86 CPU for eaxmple, when cross-compiling.
14 g++-4.9:native,
14 g++-4.9:native,
15+ libandroid-properties-dev,
15 graphviz,
16 graphviz,
16 gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815),
17 gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815),
17 libconnectivity-qt1-dev,
18 libconnectivity-qt1-dev,
@@ -29,7 +30,7 @@ Build-Depends: cmake,
29 libqt5xmlpatterns5-dev,
30 libqt5xmlpatterns5-dev,
30 libsystemsettings-dev,
31 libsystemsettings-dev,
31 libudev-dev,
32 libudev-dev,
32− libunity-api-dev (>= 7.96),
33+ libunity-api-dev (>= 7.97),
33 libusermetricsoutput1-dev,
34 libusermetricsoutput1-dev,
34 libxcb1-dev,
35 libxcb1-dev,
35 pkg-config,
36 pkg-config,
@@ -96,7 +97,7 @@ Depends: gsettings-desktop-schemas,
96 qml-module-qtquick-xmllistmodel,
97 qml-module-qtquick-xmllistmodel,
97 qml-module-qtsysteminfo,
98 qml-module-qtsysteminfo,
98 qtdeclarative5-gsettings1.0,
99 qtdeclarative5-gsettings1.0,
99− qtdeclarative5-qtmir-plugin (>= 0.4.4),
100+ qtdeclarative5-qtmir-plugin (>= 0.4.5),
100 qtdeclarative5-ubuntu-telephony0.1,
101 qtdeclarative5-ubuntu-telephony0.1,
101 qtdeclarative5-ubuntu-web-plugin,
102 qtdeclarative5-ubuntu-web-plugin,
102 ubuntu-system-settings,
103 ubuntu-system-settings,
@@ -126,7 +127,7 @@ Depends: qml-module-qtquick-layouts,
126 qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.1.1239) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.1.1239),
127 qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 1.1.1239) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 1.1.1239),
127 qtdeclarative5-unity-notifications-plugin (>= 0.1.2) | unity-notifications-impl,
128 qtdeclarative5-unity-notifications-plugin (>= 0.1.2) | unity-notifications-impl,
128 ubuntu-thumbnailer-impl-0,
129 ubuntu-thumbnailer-impl-0,
129− unity-application-impl-4,
130+ unity-application-impl-6,
130 unity-notifications-impl-3,
131 unity-notifications-impl-3,
131 unity-plugin-scopes | unity-scopes-impl,
132 unity-plugin-scopes | unity-scopes-impl,
132 unity-scopes-impl-6,
133 unity-scopes-impl-6,
@@ -170,7 +171,7 @@ Pre-Depends: ${misc:Pre-Depends},
170Depends: ${misc:Depends},
171Depends: ${misc:Depends},
171 ${shlibs:Depends},
172 ${shlibs:Depends},
172Provides: unity-application-impl,
173Provides: unity-application-impl,
173− unity-application-impl-4,
174+ unity-application-impl-6,
174Replaces: unity8-autopilot (<< 8.02+15.04.20150422-0ubuntu1)
175Replaces: unity8-autopilot (<< 8.02+15.04.20150422-0ubuntu1)
175Description: Fake environment for running Unity 8 shell
176Description: Fake environment for running Unity 8 shell
176 Provides fake implementations of some QML modules used by Unity 8 shell
177 Provides fake implementations of some QML modules used by Unity 8 shell
debian/unity8.install+3
@@ -8,6 +8,9 @@ usr/share/applications/unity8.desktop
8usr/share/unity8/Greeter
8usr/share/unity8/Greeter
9usr/share/unity8/Launcher
9usr/share/unity8/Launcher
10usr/share/unity8/Panel
10usr/share/unity8/Panel
11+usr/share/unity8/Rotation
12+usr/share/unity8/DeviceConfiguration.qml
13+usr/share/unity8/OrientedShell.qml
11usr/share/unity8/Shell.qml
14usr/share/unity8/Shell.qml
12usr/share/unity8/Stages
15usr/share/unity8/Stages
13usr/share/unity8/Tutorial
16usr/share/unity8/Tutorial
plugins/Greeter/Unity/Launcher/CMakeLists.txt+1−1
@@ -1,5 +1,5 @@
1pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=6)
1pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=6)
2−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=5)
2+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=6)
3pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
3pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
4
4
5add_definitions(-DSM_BUSNAME=systemBus)
5add_definitions(-DSM_BUSNAME=systemBus)
plugins/Unity/Launcher/CMakeLists.txt+1−1
@@ -1,5 +1,5 @@
1pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=6)
1pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=6)
2−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=5)
2+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=6)
3pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
3pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
4
4
5add_definitions(-DSM_BUSNAME=systemBus)
5add_definitions(-DSM_BUSNAME=systemBus)
plugins/Utils/CMakeLists.txt+1
@@ -18,6 +18,7 @@ set(QMLPLUGIN_SRC
18 Timer.cpp
18 Timer.cpp
19 unitymenumodelpaths.cpp
19 unitymenumodelpaths.cpp
20 windowkeysfilter.cpp
20 windowkeysfilter.cpp
21+ windowscreenshotprovider.cpp
21 easingcurve.cpp
22 easingcurve.cpp
22 windowstatestorage.cpp
23 windowstatestorage.cpp
23 plugin.cpp
24 plugin.cpp
plugins/Utils/plugin.cpp+4−1
@@ -23,6 +23,7 @@
23#include "plugin.h"
23#include "plugin.h"
24
24
25// local
25// local
26+#include "easingcurve.h"
26#include "HomeKeyWatcher.h"
27#include "HomeKeyWatcher.h"
27#include "inputwatcher.h"
28#include "inputwatcher.h"
28#include "qlimitproxymodelqml.h"
29#include "qlimitproxymodelqml.h"
@@ -31,7 +32,7 @@
31#include "timeformatter.h"
32#include "timeformatter.h"
32#include "unitymenumodelpaths.h"
33#include "unitymenumodelpaths.h"
33#include "windowkeysfilter.h"
34#include "windowkeysfilter.h"
34−#include "easingcurve.h"
35+#include "windowscreenshotprovider.h"
35#include "windowstatestorage.h"
36#include "windowstatestorage.h"
36#include "constants.h"
37#include "constants.h"
37
38
@@ -70,4 +71,6 @@ void UtilsPlugin::registerTypes(const char *uri)
70void UtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
71void UtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
71{
72{
72 QQmlExtensionPlugin::initializeEngine(engine, uri);
73 QQmlExtensionPlugin::initializeEngine(engine, uri);
74+
75+ engine->addImageProvider(QLatin1String("window"), new WindowScreenshotProvider);
73}
76}
plugins/Utils/windowscreenshotprovider.cppnew file+59
@@ -0,0 +1,59 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+#include "windowscreenshotprovider.h"
18+
19+#include <QGuiApplication>
20+#include <QQuickWindow>
21+
22+WindowScreenshotProvider::WindowScreenshotProvider()
23+ : QQuickImageProvider(QQmlImageProviderBase::Image, 0)
24+{
25+}
26+
27+// A very simple implementation where we assume that there's only one window and that it's a
28+// QQuickWindow. Thus the id parameter is irrelevant.
29+//
30+// Idea: Make the id contain the objectName of the QQuickWindow once we care about a multi-display
31+// compositor?
32+// Strictly speaking that could be the actual QWindow::winId(), but that's mostly a
33+// meaningless arbitrary number.
34+QImage WindowScreenshotProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
35+{
36+ Q_UNUSED(id);
37+ Q_UNUSED(requestedSize);
38+
39+ QWindowList windows = QGuiApplication::topLevelWindows();
40+
41+ if (windows.count() != 1) {
42+ size->rwidth() = 0;
43+ size->rheight() = 0;
44+ return QImage();
45+ }
46+
47+ QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(windows[0]);
48+
49+ if (!quickWindow) {
50+ size->rwidth() = 0;
51+ size->rheight() = 0;
52+ return QImage();
53+ }
54+
55+ QImage image = quickWindow->grabWindow();
56+ size->rwidth() = image.width();
57+ size->rheight() = image.height();
58+ return image;
59+}
plugins/Utils/windowscreenshotprovider.hnew file+31
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+#ifndef WINDOW_SCREENSHOT_PROVIDER_H_
18+#define WINDOW_SCREENSHOT_PROVIDER_H_
19+
20+#include <QQuickImageProvider>
21+
22+class WindowScreenshotProvider : public QQuickImageProvider
23+{
24+public:
25+ WindowScreenshotProvider();
26+
27+ // id is ignored for now
28+ QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override;
29+};
30+
31+#endif // WINDOW_SCREENSHOT_PROVIDER_H_
qml/CMakeLists.txt+1
@@ -13,6 +13,7 @@ set(QML_DIRS
13 Notifications
13 Notifications
14 Panel
14 Panel
15 Stages
15 Stages
16+ Rotation
16 Tutorial
17 Tutorial
17 Wizard
18 Wizard
18 )
19 )
qml/Components/WindowScreenshot.qmlnew file+35
@@ -0,0 +1,35 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+import QtQuick 2.2
18+
19+Item {
20+ id: root
21+
22+ function take() {
23+ var timeNow = new Date().getTime();
24+ image.source = "image://window/" + timeNow;
25+ }
26+
27+ // Unload the image to free up memory
28+ function discard() {
29+ image.source = "";
30+ }
31+
32+ Image {
33+ id: image
34+ }
35+}
qml/Dash/DashApplication.qml+3−3
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014,2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -19,8 +19,8 @@ import Ubuntu.Components 1.0
19import Ubuntu.Thumbnailer 0.1 // Register support for image://thumbnailer/ and image://albumart/
19import Ubuntu.Thumbnailer 0.1 // Register support for image://thumbnailer/ and image://albumart/
20
20
21MainView {
21MainView {
22− width: applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
22+ implicitWidth: units.gu(40)
23− height: applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(68)
23+ implicitHeight: units.gu(68)
24
24
25 useDeprecatedToolbar: false
25 useDeprecatedToolbar: false
26
26
qml/Dash/graphics/phone/screenshots/gmail-webapp.svgnew file+343
@@ -0,0 +1,343 @@
1+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+<!-- Created with Inkscape (http://www.inkscape.org/) -->
3+
4+<svg
5+ xmlns:dc="http://purl.org/dc/elements/1.1/"
6+ xmlns:cc="http://creativecommons.org/ns#"
7+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8+ xmlns:svg="http://www.w3.org/2000/svg"
9+ xmlns="http://www.w3.org/2000/svg"
10+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12+ width="768"
13+ height="1280"
14+ id="svg2"
15+ version="1.1"
16+ inkscape:version="0.48.5 r10040"
17+ sodipodi:docname="gmail-webapp.svg">
18+ <defs
19+ id="defs4" />
20+ <sodipodi:namedview
21+ id="base"
22+ pagecolor="#ffffff"
23+ bordercolor="#666666"
24+ borderopacity="1.0"
25+ inkscape:pageopacity="0.0"
26+ inkscape:pageshadow="2"
27+ inkscape:zoom="0.49497475"
28+ inkscape:cx="117.33439"
29+ inkscape:cy="668.80479"
30+ inkscape:document-units="px"
31+ inkscape:current-layer="layer1"
32+ showgrid="false"
33+ inkscape:window-width="1920"
34+ inkscape:window-height="1056"
35+ inkscape:window-x="0"
36+ inkscape:window-y="24"
37+ inkscape:window-maximized="1" />
38+ <metadata
39+ id="metadata7">
40+ <rdf:RDF>
41+ <cc:Work
42+ rdf:about="">
43+ <dc:format>image/svg+xml</dc:format>
44+ <dc:type
45+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
46+ <dc:title></dc:title>
47+ </cc:Work>
48+ </rdf:RDF>
49+ </metadata>
50+ <g
51+ inkscape:label="Layer 1"
52+ inkscape:groupmode="layer"
53+ id="layer1"
54+ transform="translate(0,227.63782)">
55+ <rect
56+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.69999999000000002;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
57+ id="rect2985"
58+ width="769.73627"
59+ height="1276.8328"
60+ x="-2.0203052"
61+ y="3.1671834"
62+ transform="translate(0,-227.63782)" />
63+ <rect
64+ style="fill:#e6e6e6;fill-opacity:1;stroke:none;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
65+ id="rect3797"
66+ width="773.77686"
67+ height="129.29953"
68+ x="-6.0609155"
69+ y="-0.87342685"
70+ transform="translate(0,-227.63782)" />
71+ <text
72+ xml:space="preserve"
73+ style="font-size:72px;font-style:normal;font-weight:500;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu Medium;font-stretch:normal;font-variant:normal"
74+ x="20.203053"
75+ y="-139.61781"
76+ id="text3755"
77+ sodipodi:linespacing="125%"><tspan
78+ sodipodi:role="line"
79+ id="tspan3757"
80+ x="20.203053"
81+ y="-139.61781">GMail</tspan></text>
82+ <text
83+ xml:space="preserve"
84+ style="font-size:72px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
85+ x="14.142137"
86+ y="-28.501045"
87+ id="text3759"
88+ sodipodi:linespacing="125%"><tspan
89+ sodipodi:role="line"
90+ id="tspan3761"
91+ x="14.142137"
92+ y="-28.501045">Inbox</tspan></text>
93+ <path
94+ sodipodi:type="arc"
95+ style="fill:#8effff;fill-opacity:1;stroke:#000000;stroke-width:0.69999999;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
96+ id="path3765"
97+ sodipodi:cx="107.07617"
98+ sodipodi:cy="337.52768"
99+ sodipodi:rx="64.649765"
100+ sodipodi:ry="61.619305"
101+ d="m 171.72594,337.52768 a 64.649765,61.619305 0 1 1 -129.299533,0 64.649765,61.619305 0 1 1 129.299533,0 z"
102+ transform="translate(-28.284271,-251.88148)" />
103+ <path
104+ style="fill:none;stroke:#000000;stroke-width:8;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
105+ d="m 14.142136,237.52257 729.330134,0"
106+ id="path3769"
107+ inkscape:connector-curvature="0"
108+ transform="translate(0,-227.63782)" />
109+ <text
110+ xml:space="preserve"
111+ style="font-size:64px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
112+ x="167.68533"
113+ y="78.575127"
114+ id="text3771"
115+ sodipodi:linespacing="125%"><tspan
116+ sodipodi:role="line"
117+ id="tspan3773"
118+ x="167.68533"
119+ y="78.575127">Lorem ipsum</tspan></text>
120+ <text
121+ xml:space="preserve"
122+ style="font-size:64px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
123+ x="167.68532"
124+ y="131.10306"
125+ id="text3775"
126+ sodipodi:linespacing="125%"><tspan
127+ sodipodi:role="line"
128+ id="tspan3777"
129+ x="167.68532"
130+ y="131.10306"
131+ style="font-size:48px;fill:#b3b3b3">bla bla bla bla bla bla bla ...</tspan></text>
132+ <path
133+ style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
134+ d="m 13.13199,165.44825 729.33013,0"
135+ id="path3769-2"
136+ inkscape:connector-curvature="0" />
137+ <path
138+ sodipodi:type="arc"
139+ style="fill:#8eff58;fill-opacity:1;stroke:#000000;stroke-width:0.69999999000000002;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
140+ id="path3765-3"
141+ sodipodi:cx="107.07617"
142+ sodipodi:cy="337.52768"
143+ sodipodi:rx="64.649765"
144+ sodipodi:ry="61.619305"
145+ d="m 171.72594,337.52768 a 64.649765,61.619305 0 1 1 -129.299533,0 64.649765,61.619305 0 1 1 129.299533,0 z"
146+ transform="translate(-26.263969,-93.102383)" />
147+ <text
148+ xml:space="preserve"
149+ style="font-size:64px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
150+ x="169.70564"
151+ y="237.35422"
152+ id="text3771-9"
153+ sodipodi:linespacing="125%"><tspan
154+ sodipodi:role="line"
155+ id="tspan3773-7"
156+ x="169.70564"
157+ y="237.35422">Lorem ipsum</tspan></text>
158+ <text
159+ xml:space="preserve"
160+ style="font-size:64px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
161+ x="169.70561"
162+ y="289.88217"
163+ id="text3775-1"
164+ sodipodi:linespacing="125%"><tspan
165+ sodipodi:role="line"
166+ id="tspan3777-1"
167+ x="169.70561"
168+ y="289.88217"
169+ style="font-size:48px;fill:#b3b3b3">bla bla bla bla bla bla bla ...</tspan></text>
170+ <path
171+ style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
172+ d="m 15.152292,324.22735 729.330128,0"
173+ id="path3769-2-6"
174+ inkscape:connector-curvature="0" />
175+ <path
176+ sodipodi:type="arc"
177+ style="fill:#8effff;fill-opacity:1;stroke:#000000;stroke-width:0.69999999;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
178+ id="path3765-7"
179+ sodipodi:cx="107.07617"
180+ sodipodi:cy="337.52768"
181+ sodipodi:rx="64.649765"
182+ sodipodi:ry="61.619305"
183+ d="m 171.72594,337.52768 a 64.649765,61.619305 0 1 1 -129.299533,0 64.649765,61.619305 0 1 1 129.299533,0 z"
184+ transform="translate(-28.284274,64.481414)" />
185+ <text
186+ xml:space="preserve"
187+ style="font-size:64px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
188+ x="167.68533"
189+ y="394.93799"
190+ id="text3771-92"
191+ sodipodi:linespacing="125%"><tspan
192+ sodipodi:role="line"
193+ id="tspan3773-0"
194+ x="167.68533"
195+ y="394.93799">Lorem ipsum</tspan></text>
196+ <text
197+ xml:space="preserve"
198+ style="font-size:64px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
199+ x="167.68532"
200+ y="447.46594"
201+ id="text3775-9"
202+ sodipodi:linespacing="125%"><tspan
203+ sodipodi:role="line"
204+ id="tspan3777-8"
205+ x="167.68532"
206+ y="447.46594"
207+ style="font-size:48px;fill:#b3b3b3">bla bla bla bla bla bla bla ...</tspan></text>
208+ <path
209+ style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
210+ d="m 13.131986,481.81114 729.330124,0"
211+ id="path3769-2-3"
212+ inkscape:connector-curvature="0" />
213+ <path
214+ sodipodi:type="arc"
215+ style="fill:#8ea2ff;fill-opacity:1;stroke:#000000;stroke-width:0.69999999000000002;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
216+ id="path3765-2"
217+ sodipodi:cx="107.07617"
218+ sodipodi:cy="337.52768"
219+ sodipodi:rx="64.649765"
220+ sodipodi:ry="61.619305"
221+ d="m 171.72594,337.52768 a 64.649765,61.619305 0 1 1 -129.299533,0 64.649765,61.619305 0 1 1 129.299533,0 z"
222+ transform="translate(-26.263969,226.10582)" />
223+ <text
224+ xml:space="preserve"
225+ style="font-size:64px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
226+ x="169.70564"
227+ y="556.56238"
228+ id="text3771-1"
229+ sodipodi:linespacing="125%"><tspan
230+ sodipodi:role="line"
231+ id="tspan3773-1"
232+ x="169.70564"
233+ y="556.56238">Lorem ipsum</tspan></text>
234+ <text
235+ xml:space="preserve"
236+ style="font-size:64px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
237+ x="169.70563"
238+ y="609.09033"
239+ id="text3775-8"
240+ sodipodi:linespacing="125%"><tspan
241+ sodipodi:role="line"
242+ id="tspan3777-85"
243+ x="169.70563"
244+ y="609.09033"
245+ style="font-size:48px;fill:#b3b3b3">bla bla bla bla bla bla bla ...</tspan></text>
246+ <path
247+ style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
248+ d="m 15.152292,643.43555 729.330128,0"
249+ id="path3769-2-1"
250+ inkscape:connector-curvature="0" />
251+ <path
252+ sodipodi:type="arc"
253+ style="fill:#8effff;fill-opacity:1;stroke:#000000;stroke-width:0.69999999;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
254+ id="path3765-8"
255+ sodipodi:cx="107.07617"
256+ sodipodi:cy="337.52768"
257+ sodipodi:rx="64.649765"
258+ sodipodi:ry="61.619305"
259+ d="m 171.72594,337.52768 a 64.649765,61.619305 0 1 1 -129.299533,0 64.649765,61.619305 0 1 1 129.299533,0 z"
260+ transform="translate(-24.243664,391.77084)" />
261+ <text
262+ xml:space="preserve"
263+ style="font-size:64px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
264+ x="171.72594"
265+ y="722.22742"
266+ id="text3771-7"
267+ sodipodi:linespacing="125%"><tspan
268+ sodipodi:role="line"
269+ id="tspan3773-6"
270+ x="171.72594"
271+ y="722.22742">Lorem ipsum</tspan></text>
272+ <text
273+ xml:space="preserve"
274+ style="font-size:64px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
275+ x="171.72592"
276+ y="774.75537"
277+ id="text3775-5"
278+ sodipodi:linespacing="125%"><tspan
279+ sodipodi:role="line"
280+ id="tspan3777-2"
281+ x="171.72592"
282+ y="774.75537"
283+ style="font-size:48px;fill:#b3b3b3">bla bla bla bla bla bla bla ...</tspan></text>
284+ <path
285+ style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
286+ d="m 17.172597,809.10057 729.330133,0"
287+ id="path3769-2-13"
288+ inkscape:connector-curvature="0" />
289+ <path
290+ sodipodi:type="arc"
291+ style="fill:#e44738;fill-opacity:1;stroke:#000000;stroke-width:0.69999999000000002;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
292+ id="path3765-9"
293+ sodipodi:cx="107.07617"
294+ sodipodi:cy="337.52768"
295+ sodipodi:rx="64.649765"
296+ sodipodi:ry="61.619305"
297+ d="m 171.72594,337.52768 a 64.649765,61.619305 0 1 1 -129.299533,0 64.649765,61.619305 0 1 1 129.299533,0 z"
298+ transform="translate(-24.243664,557.43585)" />
299+ <text
300+ xml:space="preserve"
301+ style="font-size:64px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
302+ x="171.72594"
303+ y="887.89246"
304+ id="text3771-2"
305+ sodipodi:linespacing="125%"><tspan
306+ sodipodi:role="line"
307+ id="tspan3773-8"
308+ x="171.72594"
309+ y="887.89246">Lorem ipsum</tspan></text>
310+ <text
311+ xml:space="preserve"
312+ style="font-size:64px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
313+ x="171.72592"
314+ y="940.42041"
315+ id="text3775-3"
316+ sodipodi:linespacing="125%"><tspan
317+ sodipodi:role="line"
318+ id="tspan3777-7"
319+ x="171.72592"
320+ y="940.42041"
321+ style="font-size:48px;fill:#b3b3b3">bla bla bla bla bla bla bla ...</tspan></text>
322+ <path
323+ style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
324+ d="m 17.172597,974.76558 729.330123,0"
325+ id="path3769-2-9"
326+ inkscape:connector-curvature="0" />
327+ <path
328+ sodipodi:type="arc"
329+ style="fill:none;stroke:#000000;stroke-width:8;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
330+ id="path3929"
331+ sodipodi:cx="590.93921"
332+ sodipodi:cy="-119.06127"
333+ sodipodi:rx="33.335033"
334+ sodipodi:ry="33.335033"
335+ d="m 624.27424,-119.06127 a 33.335033,33.335033 0 1 1 -66.67006,0 33.335033,33.335033 0 1 1 66.67006,0 z"
336+ transform="matrix(0.85096826,0,0,0.85096826,175.43863,-68.81729)" />
337+ <path
338+ style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:3.40387297;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
339+ d="m 692.92249,-145.20602 20.63059,24.06901 12.03451,-13.75372 -20.63059,-17.19215"
340+ id="path3931"
341+ inkscape:connector-curvature="0" />
342+ </g>
343+</svg>
qml/Dash/graphics/phone/screenshots/settings@12.pngdeleted

Binary file not shown.

qml/Dash/graphics/phone/screenshots/ubuntu-weather-app.svgnew file+201
@@ -0,0 +1,201 @@
1+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+<!-- Created with Inkscape (http://www.inkscape.org/) -->
3+
4+<svg
5+ xmlns:dc="http://purl.org/dc/elements/1.1/"
6+ xmlns:cc="http://creativecommons.org/ns#"
7+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8+ xmlns:svg="http://www.w3.org/2000/svg"
9+ xmlns="http://www.w3.org/2000/svg"
10+ xmlns:xlink="http://www.w3.org/1999/xlink"
11+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
12+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
13+ width="829"
14+ height="480"
15+ id="svg2740"
16+ sodipodi:version="0.32"
17+ inkscape:version="0.48.5 r10040"
18+ version="1.0"
19+ sodipodi:docname="ubuntu-weather-app.svg"
20+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
21+ <defs
22+ id="defs2742">
23+ <linearGradient
24+ id="linearGradient3824">
25+ <stop
26+ style="stop-color:#e6e6e6;stop-opacity:1;"
27+ offset="0"
28+ id="stop3826" />
29+ <stop
30+ style="stop-color:#23abff;stop-opacity:1;"
31+ offset="1"
32+ id="stop3828" />
33+ </linearGradient>
34+ <linearGradient
35+ inkscape:collect="always"
36+ xlink:href="#linearGradient3824"
37+ id="linearGradient3830"
38+ x1="348.55862"
39+ y1="343.23914"
40+ x2="348.55862"
41+ y2="-17.422215"
42+ gradientUnits="userSpaceOnUse" />
43+ </defs>
44+ <sodipodi:namedview
45+ id="base"
46+ pagecolor="#ffffff"
47+ bordercolor="#666666"
48+ borderopacity="1.0"
49+ gridtolerance="10000"
50+ guidetolerance="10"
51+ objecttolerance="10"
52+ inkscape:pageopacity="0.0"
53+ inkscape:pageshadow="2"
54+ inkscape:zoom="0.82625984"
55+ inkscape:cx="331.28234"
56+ inkscape:cy="125.54212"
57+ inkscape:document-units="px"
58+ inkscape:current-layer="layer1"
59+ showgrid="false"
60+ inkscape:window-width="1145"
61+ inkscape:window-height="847"
62+ inkscape:window-x="268"
63+ inkscape:window-y="63"
64+ inkscape:window-maximized="0" />
65+ <metadata
66+ id="metadata2745">
67+ <rdf:RDF>
68+ <cc:Work
69+ rdf:about="">
70+ <dc:format>image/svg+xml</dc:format>
71+ <dc:type
72+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
73+ </cc:Work>
74+ </rdf:RDF>
75+ </metadata>
76+ <g
77+ inkscape:label="Layer 1"
78+ inkscape:groupmode="layer"
79+ id="layer1"
80+ transform="translate(-321.13452,-104.68346)">
81+ <rect
82+ style="fill:url(#linearGradient3830);fill-opacity:1;stroke:#000000;stroke-width:0.69999999000000002;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
83+ id="rect2990"
84+ width="832.66785"
85+ height="480.47839"
86+ x="-1.210273"
87+ y="0.73188055"
88+ transform="translate(321.13452,104.68346)" />
89+ <path
90+ d="m 310.66382,132.06057 c -1.82703,2.0443 -22.21039,-18.38308 -24.89334,-17.37811 -2.68295,1.00497 -6.73783,33.64192 -9.57527,34.01165 -2.83744,0.36973 -7.71546,-33.08881 -10.48084,-33.88783 -2.76539,-0.79903 -18.7793,19.34152 -21.17964,17.82892 -2.40034,-1.51259 5.69972,-26.09808 4.36486,-28.67057 -1.33487,-2.57249 -31.86305,-3.78032 -32.49182,-6.6501 -0.62876,-2.86978 27.66855,-10.399376 27.90248,-13.241764 0.23394,-2.842387 -18.99828,-18.90215 -17.89698,-21.393798 1.10131,-2.491647 26.85456,8.177399 28.59429,5.99159 1.73972,-2.185809 -3.39182,-29.683489 -0.75169,-30.507098 2.64013,-0.823608 18.50306,18.485327 21.32153,18.392972 2.81847,-0.09235 11.30312,-24.287685 14.18258,-23.722317 2.87947,0.565368 1.44329,25.667631 3.67226,27.34365 2.22897,1.676019 24.27161,-6.28288 25.90675,-4.004945 1.63514,2.277936 -12.63923,24.445025 -11.77955,27.07291 0.85968,2.627885 27.01183,5.1355 26.65457,7.852474 -0.35726,2.716973 -32.69913,3.875594 -34.04684,6.507203 -1.3477,2.631613 12.32368,32.410863 10.49665,34.455163 z"
91+ id="path11949"
92+ inkscape:flatsided="false"
93+ inkscape:randomized="-0.092"
94+ inkscape:rounded="0.1"
95+ sodipodi:arg1="0.79570711"
96+ sodipodi:arg2="1.144773"
97+ sodipodi:cx="275.15002"
98+ sodipodi:cy="88.090233"
99+ sodipodi:r1="57.019234"
100+ sodipodi:r2="32.818508"
101+ sodipodi:sides="9"
102+ sodipodi:type="star"
103+ style="fill:#f5ff12;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.2;marker:none;visibility:visible;display:inline;overflow:visible"
104+ transform="matrix(2.527571,0,0,2.527571,85.214779,60.619097)" />
105+ <path
106+ d="m 194.51692,77.283737 c 0,20.659371 -17.86424,37.407103 -39.90091,37.407103 -22.03666,0 -39.90091,-16.747732 -39.90091,-37.407103 0,-20.659371 17.86425,-37.4071 39.90091,-37.4071 22.03667,0 39.90091,16.747729 39.90091,37.4071 z"
107+ id="path11951"
108+ sodipodi:cx="154.61601"
109+ sodipodi:cy="77.283737"
110+ sodipodi:rx="39.900909"
111+ sodipodi:ry="37.407101"
112+ sodipodi:type="arc"
113+ style="fill:#f5ff12;fill-opacity:1;fill-rule:nonzero;stroke:#f5ff12;stroke-width:10.27388287;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0.5;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible"
114+ transform="matrix(2.4568175,0,0,2.1990879,404.91256,120.05076)" />
115+ <path
116+ transform="matrix(3.2663208,0,0,3.4016021,515.92101,-254.59331)"
117+ style="fill:#6798e9;fill-opacity:1;fill-rule:nonzero;stroke:#6798e9;stroke-width:7.30059433;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.5;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible"
118+ sodipodi:type="inkscape:offset"
119+ inkscape:radius="0"
120+ inkscape:original="M 110.53125 144.96875 C 100.76599 144.96875 92.384060 150.03292 88.281250 157.34375 C 86.642607 156.42892 84.835190 155.87500 82.906250 155.87500 C 77.073071 155.87500 72.219030 160.56753 70.718750 166.93750 C 68.157973 165.92533 65.180470 165.31250 62.000000 165.31250 C 52.458571 165.31250 44.718750 170.53296 44.718750 176.96875 C 44.718749 182.77816 51.066430 187.55402 59.312500 188.43750 C 58.942922 189.06456 58.656250 189.68551 58.656250 190.34375 C 58.656248 196.50568 75.538140 201.53125 96.343750 201.53125 C 117.14936 201.53125 134.03126 196.50568 134.03125 190.34375 C 134.03125 189.92916 133.77393 189.55916 133.62500 189.15625 C 134.53629 189.38287 135.43860 189.62500 136.43750 189.62500 C 142.00333 189.62501 146.53125 185.84318 146.53125 181.18750 C 146.53125 176.53182 142.00332 172.75000 136.43750 172.75000 C 135.75542 172.75000 135.17544 172.98560 134.53125 173.09375 C 135.09454 171.23218 135.46875 169.33268 135.46875 167.31250 C 135.46875 154.98864 124.31330 144.96875 110.53125 144.96875 z "
121+ id="path11953"
122+ d="m 110.53125,144.96875 c -9.76526,0 -18.14719,5.06417 -22.25,12.375 -1.638643,-0.91483 -3.44606,-1.46875 -5.375,-1.46875 -5.833179,0 -10.68722,4.69253 -12.1875,11.0625 -2.560777,-1.01217 -5.53828,-1.625 -8.71875,-1.625 -9.541429,0 -17.28125,5.22046 -17.28125,11.65625 -10e-7,5.80941 6.34768,10.58527 14.59375,11.46875 -0.369578,0.62706 -0.65625,1.24801 -0.65625,1.90625 -2e-6,6.16193 16.88189,11.1875 37.6875,11.1875 20.80561,0 37.68751,-5.02557 37.6875,-11.1875 0,-0.41459 -0.25732,-0.78459 -0.40625,-1.1875 0.91129,0.22662 1.8136,0.46875 2.8125,0.46875 5.56583,1e-5 10.09375,-3.78182 10.09375,-8.4375 0,-4.65568 -4.52793,-8.4375 -10.09375,-8.4375 -0.68208,0 -1.26206,0.2356 -1.90625,0.34375 0.56329,-1.86157 0.9375,-3.76107 0.9375,-5.78125 0,-12.32386 -11.15545,-22.34375 -24.9375,-22.34375 z" />
123+ <path
124+ inkscape:connector-curvature="0"
125+ style="fill:#386195;fill-opacity:1;fill-rule:nonzero;stroke:#386195;stroke-width:24.07697487;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0.5;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible"
126+ id="path11963"
127+ d="m 975.70833,305.75079 c -17.87875,0 -33.1897,9.10731 -40.70137,22.18913 -3.00012,-1.63696 -6.34124,-2.6392 -9.87286,-2.6392 -10.67967,0 -19.5639,8.39604 -22.31073,19.7943 -4.6884,-1.81117 -10.09942,-2.93251 -15.92242,-2.93251 -17.46892,0 -31.65122,9.35352 -31.65122,20.86955 0,10.39528 11.61748,18.9466 26.71485,20.52749 -0.67665,1.12204 -1.20995,2.24338 -1.20995,3.42121 0,11.02604 30.92124,19.98985 69.01327,19.98985 38.09195,0 69.0132,-8.96381 69.0132,-19.98985 0,-0.74183 -0.5017,-1.42952 -0.7743,-2.15046 1.6684,0.40556 3.3496,0.83088 5.1784,0.83088 10.1902,0 18.439,-6.7716 18.439,-15.10234 0,-8.33078 -8.2488,-15.05348 -18.439,-15.05348 -1.2488,0 -2.3535,0.39297 -3.5329,0.58647 1.0312,-3.33102 1.7422,-6.7466 1.7422,-10.36143 0,-22.05212 -20.4533,-39.97961 -45.68617,-39.97961 z" />
128+ <path
129+ inkscape:connector-curvature="0"
130+ style="fill:#6798e9;fill-opacity:1;fill-rule:nonzero;stroke:#6798e9;stroke-width:15.64964962;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:3.20000005;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible"
131+ sodipodi:nodetypes="cccc"
132+ id="path11965"
133+ d="m 717.80594,482.73655 c -32.27924,28.4432 5.62151,52.69793 20.03284,13.63938 l 11.08203,-36.22961 -31.11487,22.59023 z" />
134+ <path
135+ inkscape:connector-curvature="0"
136+ style="fill:#6798e9;fill-opacity:1;fill-rule:nonzero;stroke:#6798e9;stroke-width:15.64964962;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:3.20000005;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible"
137+ sodipodi:nodetypes="cccc"
138+ id="path11967"
139+ d="m 799.47,485.76116 c -32.27925,28.4432 5.62151,52.69792 20.03284,13.63937 l 11.08202,-36.2296 -31.11486,22.59023 z" />
140+ <text
141+ xml:space="preserve"
142+ style="font-size:32px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
143+ x="68.985565"
144+ y="92.712631"
145+ id="text2992"
146+ sodipodi:linespacing="125%"
147+ transform="translate(321.13452,104.68346)"><tspan
148+ sodipodi:role="line"
149+ id="tspan2994"
150+ x="68.985565"
151+ y="92.712631" /></text>
152+ <text
153+ xml:space="preserve"
154+ style="font-size:10px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
155+ x="-202.1156"
156+ y="155.64684"
157+ id="text2996"
158+ sodipodi:linespacing="125%"
159+ transform="translate(321.13452,104.68346)"><tspan
160+ sodipodi:role="line"
161+ id="tspan2998"
162+ x="-202.1156"
163+ y="155.64684" /></text>
164+ <text
165+ xml:space="preserve"
166+ style="font-size:24px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
167+ x="342.91943"
168+ y="155.03653"
169+ id="text3000"
170+ sodipodi:linespacing="125%"><tspan
171+ sodipodi:role="line"
172+ id="tspan3002"
173+ x="342.91943"
174+ y="155.03653"
175+ style="font-size:32px;font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-family:Ubuntu;-inkscape-font-specification:Ubuntu Medium">Wheather App</tspan></text>
176+ <text
177+ xml:space="preserve"
178+ style="font-size:24px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
179+ x="460.31592"
180+ y="358.3624"
181+ id="text3004"
182+ sodipodi:linespacing="125%"><tspan
183+ sodipodi:role="line"
184+ id="tspan3006"
185+ x="460.31592"
186+ y="358.3624"
187+ style="font-size:48px;fill:#ff0000;-inkscape-font-specification:Ubuntu;font-family:Ubuntu;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal">22C</tspan></text>
188+ <text
189+ xml:space="preserve"
190+ style="font-size:24px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
191+ x="460.19751"
192+ y="412.14325"
193+ id="text3004-0"
194+ sodipodi:linespacing="125%"><tspan
195+ sodipodi:role="line"
196+ id="tspan3006-4"
197+ x="460.19751"
198+ y="412.14325"
199+ style="font-size:48px;fill:#0000ff;-inkscape-font-specification:Ubuntu Medium;font-family:Ubuntu;font-weight:500;font-style:normal;font-stretch:normal;font-variant:normal">14C</tspan></text>
200+ </g>
201+</svg>
qml/DeviceConfiguration.qmlnew file+81
@@ -0,0 +1,81 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+import QtQuick 2.0
18+
19+StateGroup {
20+ id: root
21+
22+ readonly property int useNativeOrientation: -1
23+
24+ property int primaryOrientation: useNativeOrientation
25+
26+ property int supportedOrientations: Qt.PortraitOrientation
27+ | Qt.InvertedPortraitOrientation
28+ | Qt.LandscapeOrientation
29+ | Qt.InvertedLandscapeOrientation
30+
31+ // Supported values so far:
32+ // "phone", "tablet" or "desktop"
33+ property string category: "phone"
34+
35+
36+ property alias name: root.state
37+
38+ states: [
39+ State {
40+ name: "mako"
41+ PropertyChanges {
42+ target: root
43+ supportedOrientations: Qt.PortraitOrientation
44+ | Qt.LandscapeOrientation
45+ | Qt.InvertedLandscapeOrientation
46+ }
47+ },
48+ State {
49+ name: "krillin"
50+ PropertyChanges {
51+ target: root
52+ supportedOrientations: Qt.PortraitOrientation
53+ | Qt.LandscapeOrientation
54+ | Qt.InvertedLandscapeOrientation
55+ }
56+ },
57+ State {
58+ name: "manta"
59+ PropertyChanges {
60+ target: root
61+ category: "tablet"
62+ }
63+ },
64+ State {
65+ name: "flo"
66+ PropertyChanges {
67+ target: root
68+ primaryOrientation: Qt.InvertedLandscapeOrientation
69+ category: "tablet"
70+ }
71+ },
72+ State {
73+ name: "desktop"
74+ PropertyChanges {
75+ target: root
76+ category: "desktop"
77+ }
78+ }
79+ ]
80+
81+}
qml/Greeter/Greeter.qml+2
@@ -52,6 +52,8 @@ Showable {
52 property int failedLoginsDelayAttempts: 7 // number of failed logins
52 property int failedLoginsDelayAttempts: 7 // number of failed logins
53 property real failedLoginsDelayMinutes: 5 // minutes of forced waiting
53 property real failedLoginsDelayMinutes: 5 // minutes of forced waiting
54
54
55+ readonly property bool animating: loader.item ? loader.item.animating : false
56+
55 signal tease()
57 signal tease()
56 signal sessionStarted()
58 signal sessionStarted()
57 signal emergencyCall()
59 signal emergencyCall()
qml/Greeter/NarrowView.qml+1
@@ -33,6 +33,7 @@ FocusScope {
33 property alias infographicModel: coverPage.infographicModel
33 property alias infographicModel: coverPage.infographicModel
34 readonly property bool fullyShown: coverPage.showProgress === 1 || lockscreen.shown
34 readonly property bool fullyShown: coverPage.showProgress === 1 || lockscreen.shown
35 readonly property bool required: coverPage.required || lockscreen.required
35 readonly property bool required: coverPage.required || lockscreen.required
36+ readonly property bool animating: coverPage.showAnimation.running || coverPage.hideAnimation.running
36
37
37 signal selected(int index) // unused
38 signal selected(int index) // unused
38 signal responded(string response)
39 signal responded(string response)
qml/Greeter/WideView.qml+1
@@ -32,6 +32,7 @@ FocusScope {
32 property alias infographicModel: coverPage.infographicModel
32 property alias infographicModel: coverPage.infographicModel
33 readonly property bool fullyShown: coverPage.showProgress === 1
33 readonly property bool fullyShown: coverPage.showProgress === 1
34 readonly property bool required: coverPage.required
34 readonly property bool required: coverPage.required
35+ readonly property bool animating: coverPage.showAnimation.running || coverPage.hideAnimation.running
35
36
36 // so that it can be replaced in tests with a mock object
37 // so that it can be replaced in tests with a mock object
37 property var inputMethod: Qt.inputMethod
38 property var inputMethod: Qt.inputMethod
qml/OrientedShell.qmlnew file+185
@@ -0,0 +1,185 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+import QtQuick 2.0
18+import QtQuick.Window 2.0
19+import Unity.Session 0.1
20+import GSettings 1.0
21+import "Components"
22+import "Rotation"
23+
24+Rectangle {
25+ id: root
26+ color: "black"
27+
28+ implicitWidth: units.gu(40)
29+ implicitHeight: units.gu(71)
30+
31+ // NB: native and primary orientations here don't map exactly to their QScreen counterparts
32+ readonly property int nativeOrientation: width > height ? Qt.LandscapeOrientation : Qt.PortraitOrientation
33+
34+ readonly property int primaryOrientation:
35+ deviceConfiguration.primaryOrientation == deviceConfiguration.useNativeOrientation
36+ ? nativeOrientation : deviceConfiguration.primaryOrientation
37+
38+ DeviceConfiguration {
39+ id: deviceConfiguration
40+ name: applicationArguments.deviceName
41+ }
42+
43+ // to be overwritten by tests
44+ property var usageModeSettings: GSettings { schema.id: "com.canonical.Unity8" }
45+ property int physicalOrientation: Screen.orientation
46+ property bool orientationLocked: OrientationLock.enabled
47+ property var orientationLock: OrientationLock
48+
49+ property int orientation
50+ onPhysicalOrientationChanged: {
51+ if (!orientationLocked) {
52+ orientation = physicalOrientation;
53+ }
54+ }
55+ onOrientationLockedChanged: {
56+ if (orientationLocked) {
57+ orientationLock.savedOrientation = physicalOrientation;
58+ } else {
59+ orientation = physicalOrientation;
60+ }
61+ }
62+ Component.onCompleted: {
63+ if (orientationLocked) {
64+ orientation = orientationLock.savedOrientation;
65+ }
66+ }
67+
68+ readonly property int supportedOrientations: shell.supportedOrientations
69+ & deviceConfiguration.supportedOrientations
70+ property int acceptedOrientationAngle: {
71+ if (orientation & supportedOrientations) {
72+ return Screen.angleBetween(nativeOrientation, orientation);
73+ } else if (shell.orientation & supportedOrientations) {
74+ // stay where we are
75+ return shell.orientationAngle;
76+ } else if (angleToOrientation(shell.mainAppWindowOrientationAngle) & supportedOrientations) {
77+ return shell.mainAppWindowOrientationAngle;
78+ } else {
79+ // rotate to some supported orientation as we can't stay where we currently are
80+ // TODO: Choose the closest to the current one
81+ if (supportedOrientations & Qt.PortraitOrientation) {
82+ return Screen.angleBetween(nativeOrientation, Qt.PortraitOrientation);
83+ } else if (supportedOrientations & Qt.LandcscapeOrientation) {
84+ return Screen.angleBetween(nativeOrientation, Qt.LandscapeOrientation);
85+ } else if (supportedOrientations & Qt.InvertedPortraitOrientation) {
86+ return Screen.angleBetween(nativeOrientation, Qt.InvertedPortraitOrientation);
87+ } else if (supportedOrientations & Qt.InvertedLandscapeOrientation) {
88+ return Screen.angleBetween(nativeOrientation, Qt.InvertedLandscapeOrientation);
89+ } else {
90+ // if all fails, fallback to primary orientation
91+ return Screen.angleBetween(nativeOrientation, primaryOrientation);
92+ }
93+ }
94+ }
95+
96+ function angleToOrientation(angle) {
97+ switch (angle) {
98+ case 0:
99+ return nativeOrientation;
100+ break;
101+ case 90:
102+ return nativeOrientation === Qt.PortraitOrientation ? Qt.InvertedLandscapeOrientation
103+ : Qt.PortraitOrientation;
104+ break;
105+ case 180:
106+ return nativeOrientation === Qt.PortraitOrientation ? Qt.InvertedPortraitOrientation
107+ : Qt.InvertedLandscapeOrientation;
108+ break;
109+ case 270:
110+ return nativeOrientation === Qt.PortraitOrientation ? Qt.LandscapeOrientation
111+ : Qt.InvertedPortraitOrientation;
112+ break;
113+ default:
114+ console.warn("angleToOrientation: Invalid orientation angle: " + angle);
115+ return primaryOrientation;
116+ }
117+ }
118+
119+ RotationStates {
120+ id: rotationStates
121+ objectName: "rotationStates"
122+ orientedShell: root
123+ shell: shell
124+ shellCover: shellCover
125+ windowScreenshot: windowScreenshot
126+ }
127+
128+ Shell {
129+ id: shell
130+ objectName: "shell"
131+ width: root.width
132+ height: root.height
133+ orientation: root.angleToOrientation(orientationAngle)
134+ primaryOrientation: root.primaryOrientation
135+ nativeOrientation: root.nativeOrientation
136+ nativeWidth: root.width
137+ nativeHeight: root.height
138+
139+ // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
140+ // what's the output device (eg: big TV, desktop monitor, phone display), etc.
141+ usageScenario: {
142+ if (root.usageModeSettings.usageMode === "Windowed") {
143+ return "desktop";
144+ } else if (root.usageModeSettings.usageMode === "Staged"
145+ && deviceConfiguration.category === "desktop") {
146+ return "tablet";
147+ } else {
148+ return deviceConfiguration.category;
149+ }
150+ }
151+
152+ property real transformRotationAngle
153+ property real transformOriginX
154+ property real transformOriginY
155+
156+ transform: Rotation {
157+ origin.x: shell.transformOriginX; origin.y: shell.transformOriginY; axis { x: 0; y: 0; z: 1 }
158+ angle: shell.transformRotationAngle
159+ }
160+ }
161+
162+ Rectangle {
163+ id: shellCover
164+ color: "black"
165+ anchors.fill: parent
166+ visible: false
167+ }
168+
169+ WindowScreenshot {
170+ id: windowScreenshot
171+ visible: false
172+ width: root.width
173+ height: root.height
174+
175+ property real transformRotationAngle
176+ property real transformOriginX
177+ property real transformOriginY
178+
179+ transform: Rotation {
180+ origin.x: windowScreenshot.transformOriginX; origin.y: windowScreenshot.transformOriginY;
181+ axis { x: 0; y: 0; z: 1 }
182+ angle: windowScreenshot.transformRotationAngle
183+ }
184+ }
185+}
qml/Panel/Panel.qml+9
@@ -27,6 +27,9 @@ Item {
27 property alias indicators: __indicators
27 property alias indicators: __indicators
28 property alias callHint: __callHint
28 property alias callHint: __callHint
29 property bool fullscreenMode: false
29 property bool fullscreenMode: false
30+ property real indicatorAreaShowProgress: 1.0
31+
32+ opacity: fullscreenMode && indicators.fullyClosed ? 0.0 : 1.0
30
33
31 Rectangle {
34 Rectangle {
32 id: darkenedArea
35 id: darkenedArea
@@ -58,6 +61,12 @@ Item {
58 NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
61 NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
59 }
62 }
60
63
64+ transform: Translate {
65+ y: indicators.state === "initial"
66+ ? (1.0 - indicatorAreaShowProgress) * -d.indicatorHeight
67+ : 0
68+ }
69+
61 BorderImage {
70 BorderImage {
62 id: dropShadow
71 id: dropShadow
63 anchors {
72 anchors {
qml/Rotation/HalfLoopRotationAnimation.qmlnew file+46
@@ -0,0 +1,46 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+import QtQuick 2.3
18+
19+SequentialAnimation {
20+ id: root
21+
22+ // set from outside
23+ property int fromAngle
24+ property int toAngle
25+ property var info
26+ property var shell
27+
28+ readonly property bool flipShellDimensions: toAngle == 90 || toAngle == 270
29+
30+ ScriptAction { script: {
31+ info.transitioning = true;
32+ shell.orientationAngle = root.toAngle;
33+ shell.x = (orientedShell.width - shell.width) / 2
34+ shell.y = (orientedShell.height - shell.height) / 2;
35+ shell.transformOriginX = shell.width / 2;
36+ shell.transformOriginY = shell.height / 2;
37+ shell.updateFocusedAppOrientation();
38+ } }
39+ NumberAnimation {
40+ target: shell
41+ property: "transformRotationAngle"
42+ from: root.fromAngle; to: root.toAngle
43+ duration: rotationDuration; easing.type: rotationEasing
44+ }
45+ ScriptAction { script: { info.transitioning = false; } }
46+}
qml/Rotation/ImmediateRotationAction.qmlnew file+45
@@ -0,0 +1,45 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+import QtQuick 2.3
18+
19+ScriptAction {
20+ property var info
21+ property var shell
22+
23+ script: {
24+ info.transitioning = true;
25+ shell.orientationAngle = info.requestedOrientationAngle;
26+ shell.transformRotationAngle = info.requestedOrientationAngle;
27+
28+ // Making bindings as orientedShell's dimensions might wiggle during startup.
29+ if (info.requestedOrientationAngle === 90 || info.requestedOrientationAngle === 270) {
30+ shell.width = Qt.binding(function() { return orientedShell.height; });
31+ shell.height = Qt.binding(function() { return orientedShell.width; });
32+ } else {
33+ shell.width = Qt.binding(function() { return orientedShell.width; });
34+ shell.height = Qt.binding(function() { return orientedShell.height; });
35+ }
36+
37+ shell.x = Qt.binding(function() { return (orientedShell.width - shell.width) / 2; });
38+ shell.y = Qt.binding(function() { return (orientedShell.height - shell.height) / 2; });
39+ shell.transformOriginX = Qt.binding(function() { return shell.width / 2; });
40+ shell.transformOriginY = Qt.binding(function() { return shell.height / 2; });
41+
42+ shell.updateFocusedAppOrientation();
43+ info.transitioning = false;
44+ }
45+}
qml/Rotation/NinetyRotationAnimation.qmlnew file+90
@@ -0,0 +1,90 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+import QtQuick 2.3
18+
19+SequentialAnimation {
20+ id: root
21+
22+ property int fromAngle
23+ property int toAngle
24+ property var info
25+ property var shell
26+
27+ readonly property real fromY: fromAngle === 0 || fromAngle === 90 ? 0 : orientedShell.height - orientedShell.width;
28+ readonly property real toY: toAngle === 0 || toAngle === 90 ? 0 : orientedShell.height - orientedShell.width;
29+ readonly property bool flipShellDimensions: toAngle == 90 || toAngle == 270
30+
31+ ScriptAction { script: {
32+ info.transitioning = true;
33+ windowScreenshot.take();
34+ windowScreenshot.visible = true;
35+ shell.orientationAngle = root.toAngle;
36+ shell.x = 0;
37+ shell.width = flipShellDimensions ? orientedShell.height : orientedShell.width;
38+ shell.height = flipShellDimensions ? orientedShell.width : orientedShell.height;
39+ shell.transformOriginX = orientedShell.width / 2;
40+ shell.transformOriginY = orientedShell.width / 2;
41+ shell.updateFocusedAppOrientation();
42+ shellCover.visible = true;
43+
44+ windowScreenshot.transformOriginX = orientedShell.width / 2;
45+ if (fromAngle == 180 || fromAngle == 270) {
46+ windowScreenshot.transformOriginY = orientedShell.height - (orientedShell.width / 2);
47+ } else {
48+ windowScreenshot.transformOriginY = orientedShell.width / 2;
49+ }
50+ } }
51+ ParallelAnimation {
52+ NumberAnimation {
53+ target: shellCover; property: "opacity"; from: 1; to: 0;
54+ duration: rotationDuration; easing.type: rotationEasing
55+ }
56+ RotationAnimation {
57+ target: shell; property: "transformRotationAngle";
58+ from: root.fromAngle; to: root.toAngle
59+ direction: RotationAnimation.Shortest
60+ duration: rotationDuration; easing.type: rotationEasing
61+ }
62+ NumberAnimation {
63+ target: shell; property: "y"
64+ from: root.fromY; to: root.toY
65+ duration: rotationDuration; easing.type: rotationEasing
66+ }
67+
68+ NumberAnimation {
69+ target: windowScreenshot; property: "opacity"; from: 1; to: 0;
70+ duration: rotationDuration; easing.type: rotationEasing
71+ }
72+ RotationAnimation {
73+ target: windowScreenshot; property: "transformRotationAngle";
74+ from: 0; to: root.toAngle - root.fromAngle
75+ direction: RotationAnimation.Shortest
76+ duration: rotationDuration; easing.type: rotationEasing
77+ }
78+ NumberAnimation {
79+ target: windowScreenshot; property: "y"
80+ from: 0; to: root.toY - root.fromY
81+ duration: rotationDuration; easing.type: rotationEasing
82+ }
83+ }
84+ ScriptAction { script: {
85+ windowScreenshot.visible = false;
86+ windowScreenshot.discard();
87+ shellCover.visible = false;
88+ info.transitioning = false;
89+ } }
90+}
qml/Rotation/RotationStates.qmlnew file+278
@@ -0,0 +1,278 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+import QtQuick 2.0
18+import Ubuntu.Components 1.1
19+import Powerd 0.1
20+
21+// Why the state machine is done that way:
22+// We cannot use regular PropertyChanges{} inside the State elements as steps in the
23+// transition animations must take place in a well defined order.
24+// Which means that we also cannot jump to a new state in the middle of a transition
25+// as that would make hell brake loose.
26+StateGroup {
27+ id: root
28+
29+ // to be set from the outside
30+ property Item orientedShell
31+ property Item shell
32+ property Item shellCover
33+ property Item windowScreenshot
34+
35+ property int rotationDuration: 450
36+ property int rotationEasing: Easing.InOutCubic
37+ // Those values are good for debugging/development
38+ //property int rotationDuration: 3000
39+ //property int rotationEasing: Easing.Linear
40+
41+ state: "0"
42+ states: [
43+ State { name: "0" },
44+ State { name: "90" },
45+ State { name: "180" },
46+ State { name: "270" }
47+ ]
48+
49+ property QtObject d: QtObject {
50+ id: d
51+
52+ property bool startingUp: true
53+ property var finishStartUpTimer: Timer {
54+ interval: 500
55+ onTriggered: d.startingUp = false
56+ }
57+ Component.onCompleted: {
58+ finishStartUpTimer.start();
59+ }
60+
61+ property bool transitioning: false
62+ onTransitioningChanged: {
63+ d.tryUpdateState();
64+ }
65+
66+ readonly property int requestedOrientationAngle: root.orientedShell.acceptedOrientationAngle
67+
68+ // Avoiding a direct call to tryUpdateState() as the state change might trigger an immediate
69+ // change to Shell.orientationAngle which, in its turn, causes a reevaluation of
70+ // requestedOrientationAngle (ie., OrientedShell.acceptedOrientationAngle). A reentrant evaluation
71+ // of a binding is detected by QML as a binding loop and QML will deny the reevalutation, which
72+ // will leave us in a bogus state.
73+ //
74+ // To avoid this mess we update the state in the next event loop iteration, ensuring a clean
75+ // call stack.
76+ onRequestedOrientationAngleChanged: {
77+ stateUpdateTimer.start();
78+ }
79+ property Timer stateUpdateTimer: Timer {
80+ id: stateUpdateTimer
81+ interval: 1
82+ onTriggered: { d.tryUpdateState(); }
83+ }
84+
85+ function tryUpdateState() {
86+ if (d.transitioning || (!d.startingUp && !root.shell.orientationChangesEnabled)) {
87+ return;
88+ }
89+
90+ var requestedState = d.requestedOrientationAngle.toString();
91+ if (requestedState !== root.state) {
92+ d.resolveAnimationType();
93+ root.state = requestedState;
94+ }
95+ }
96+
97+ property Connections shellConnections: Connections {
98+ target: root.shell
99+ onOrientationChangesEnabledChanged: {
100+ d.tryUpdateState();
101+ }
102+ }
103+
104+ property var shellBeingResized: Binding {
105+ target: root.shell
106+ property: "beingResized"
107+ value: d.transitioning
108+ }
109+
110+ readonly property int fullAnimation: 0
111+ readonly property int indicatorsBarAnimation: 1
112+ readonly property int noAnimation: 2
113+
114+ property int animationType
115+
116+ // animationType update *must* take place *before* the state update.
117+ // If animationType and state were updated through bindings, as with normal qml code,
118+ // there would be no guarantee in the order of the binding updates, which could then
119+ // cause the wrong transitions to be chosen for the state changes.
120+ function resolveAnimationType() {
121+ if (d.startingUp) {
122+ // During start up, inital property values are still settling while we're still
123+ // to render the very first frame
124+ d.animationType = d.noAnimation;
125+ } else if (Powerd.status === Powerd.Off) {
126+ // There's no point in animating if the user can't see it (display is off).
127+ d.animationType = d.noAnimation;
128+ } else if (root.shell.showingGreeter) {
129+ // A rotating greeter looks weird.
130+ d.animationType = d.noAnimation;
131+ } else {
132+ if (!root.shell.mainApp) {
133+ // shouldn't happen but, anyway
134+ d.animationType = d.fullAnimation;
135+ return;
136+ }
137+
138+ if (root.shell.mainApp.rotatesWindowContents) {
139+ // The application will animate its own GUI, so we don't have to do anything ourselves.
140+ d.animationType = d.noAnimation;
141+ } else if (root.shell.mainAppWindowOrientationAngle == d.requestedOrientationAngle) {
142+ // The app window is already on its final orientation angle.
143+ // So we just animate the indicators bar
144+ // TODO: what if the app is fullscreen?
145+ d.animationType = d.indicatorsBarAnimation;
146+ } else {
147+ d.animationType = d.fullAnimation;
148+ }
149+ }
150+ }
151+
152+ // When an application switch takes place, d.requestedOrientationAngle and
153+ // root.shell.mainAppWindowOrientationAngle get updated separately, at different moments.
154+ // So, when one of those properties change, we shouldn't make a decision straight away
155+ // as the other might be stale and about to be changed. So let's give it a bit of time for
156+ // them to get properly updated.
157+ // This approach is indeed a bit hacky.
158+ property bool appWindowOrientationAngleNeedsUpdateUnstable:
159+ root.shell.orientationAngle === d.requestedOrientationAngle
160+ && root.shell.mainApp
161+ && root.shell.mainAppWindowOrientationAngle !== root.shell.orientationAngle
162+ && !d.transitioning
163+ onAppWindowOrientationAngleNeedsUpdateUnstableChanged: {
164+ stableTimer.restart();
165+ }
166+ property Timer stableTimer: Timer {
167+ interval: 200
168+ onTriggered: {
169+ if (d.appWindowOrientationAngleNeedsUpdateUnstable) {
170+ shell.updateFocusedAppOrientationAnimated();
171+ }
172+ }
173+ }
174+ }
175+
176+ transitions: [
177+ Transition {
178+ from: "90"; to: "0"
179+ enabled: d.animationType == d.fullAnimation
180+ NinetyRotationAnimation { fromAngle: 90; toAngle: 0
181+ info: d; shell: root.shell }
182+ },
183+ Transition {
184+ from: "0"; to: "90"
185+ enabled: d.animationType == d.fullAnimation
186+ NinetyRotationAnimation { fromAngle: 0; toAngle: 90
187+ info: d; shell: root.shell }
188+ },
189+ Transition {
190+ from: "0"; to: "270"
191+ enabled: d.animationType == d.fullAnimation
192+ NinetyRotationAnimation { fromAngle: 0; toAngle: 270
193+ info: d; shell: root.shell }
194+ },
195+ Transition {
196+ from: "270"; to: "0"
197+ enabled: d.animationType == d.fullAnimation
198+ NinetyRotationAnimation { fromAngle: 270; toAngle: 0
199+ info: d; shell: root.shell }
200+ },
201+ Transition {
202+ from: "90"; to: "180"
203+ enabled: d.animationType == d.fullAnimation
204+ NinetyRotationAnimation { fromAngle: 90; toAngle: 180
205+ info: d; shell: root.shell }
206+ },
207+ Transition {
208+ from: "180"; to: "90"
209+ enabled: d.animationType == d.fullAnimation
210+ NinetyRotationAnimation { fromAngle: 180; toAngle: 90
211+ info: d; shell: root.shell }
212+ },
213+ Transition {
214+ from: "180"; to: "270"
215+ enabled: d.animationType == d.fullAnimation
216+ NinetyRotationAnimation { fromAngle: 180; toAngle: 270
217+ info: d; shell: root.shell }
218+ },
219+ Transition {
220+ from: "270"; to: "180"
221+ enabled: d.animationType == d.fullAnimation
222+ NinetyRotationAnimation { fromAngle: 270; toAngle: 180
223+ info: d; shell: root.shell }
224+ },
225+ Transition {
226+ from: "0"; to: "180"
227+ enabled: d.animationType == d.fullAnimation
228+ HalfLoopRotationAnimation { fromAngle: 0; toAngle: 180
229+ info: d; shell: root.shell }
230+ },
231+ Transition {
232+ from: "180"; to: "0"
233+ enabled: d.animationType == d.fullAnimation
234+ HalfLoopRotationAnimation { fromAngle: 180; toAngle: 0
235+ info: d; shell: root.shell }
236+ },
237+ Transition {
238+ from: "90"; to: "270"
239+ enabled: d.animationType == d.fullAnimation
240+ HalfLoopRotationAnimation { fromAngle: 90; toAngle: 270
241+ info: d; shell: root.shell }
242+ },
243+ Transition {
244+ from: "270"; to: "90"
245+ enabled: d.animationType == d.fullAnimation
246+ HalfLoopRotationAnimation { fromAngle: 270; toAngle: 90
247+ info: d; shell: root.shell }
248+ },
249+ Transition {
250+ objectName: "immediateTransition"
251+ enabled: d.animationType == d.noAnimation
252+ ImmediateRotationAction { info: d; shell: root.shell }
253+ },
254+ Transition {
255+ enabled: d.animationType == d.indicatorsBarAnimation
256+ SequentialAnimation {
257+ ScriptAction { script: {
258+ d.transitioning = true;
259+ } }
260+ NumberAnimation {
261+ duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing
262+ target: root.shell; property: "indicatorAreaShowProgress"
263+ from: 1.0; to: 0.0
264+ }
265+ ImmediateRotationAction { info: d; shell: root.shell }
266+ NumberAnimation {
267+ duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing
268+ target: root.shell; property: "indicatorAreaShowProgress"
269+ from: 0.0; to: 1.0
270+ }
271+ ScriptAction { script: {
272+ d.transitioning = false;
273+ }}
274+ }
275+ }
276+ ]
277+
278+}
qml/Shell.qml+112−49
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013-2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -45,39 +45,69 @@ import Unity.Indicators 0.1 as Indicators
45Item {
45Item {
46 id: shell
46 id: shell
47
47
48+ // to be set from outside
49+ property int orientationAngle: 0
50+ property int orientation
51+ property int primaryOrientation
52+ property int nativeOrientation
53+ property real nativeWidth
54+ property real nativeHeight
55+ property alias indicatorAreaShowProgress: panel.indicatorAreaShowProgress
56+ property bool beingResized
57+ property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
58+ function updateFocusedAppOrientation() {
59+ applicationsDisplayLoader.item.updateFocusedAppOrientation();
60+ }
61+ function updateFocusedAppOrientationAnimated() {
62+ applicationsDisplayLoader.item.updateFocusedAppOrientationAnimated();
63+ }
64+
65+ // to be read from outside
66+ readonly property int mainAppWindowOrientationAngle:
67+ applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainAppWindowOrientationAngle : 0
68+
69+ readonly property bool orientationChangesEnabled: panel.indicators.fullyClosed
70+ && (applicationsDisplayLoader.item && applicationsDisplayLoader.item.orientationChangesEnabled)
71+ && !greeter.animating
72+
73+ readonly property bool showingGreeter: greeter.shown
74+
75+ property bool startingUp: true
76+ Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
77+
78+ property int supportedOrientations: {
79+ if (startingUp) {
80+ // Ensure we don't rotate during start up
81+ return Qt.PrimaryOrientation;
82+ } else if (greeter.shown) {
83+ return Qt.PrimaryOrientation;
84+ } else if (mainApp) {
85+ return mainApp.supportedOrientations;
86+ } else {
87+ // we just don't care
88+ return Qt.PortraitOrientation
89+ | Qt.LandscapeOrientation
90+ | Qt.InvertedPortraitOrientation
91+ | Qt.InvertedLandscapeOrientation;
92+ }
93+ }
94+
95+ // For autopilot consumption
96+ readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
97+
98+ // internal props from here onwards
99+ readonly property var mainApp:
100+ applicationsDisplayLoader.item ? applicationsDisplayLoader.item.mainApp : null
101+
48 // Disable everything while greeter is waiting, so that the user can't swipe
102 // Disable everything while greeter is waiting, so that the user can't swipe
49 // the greeter or launcher until we know whether the session is locked.
103 // the greeter or launcher until we know whether the session is locked.
50 enabled: !greeter.waiting
104 enabled: !greeter.waiting
51
105
52− // this is only here to select the width / height of the window if not running fullscreen
53− property bool tablet: false
54− width: tablet ? units.gu(160) : applicationArguments.hasGeometry() ? applicationArguments.width() : units.gu(40)
55− height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
56−
57 property real edgeSize: units.gu(2)
106 property real edgeSize: units.gu(2)
58 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
107 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
59 property url background: asImageTester.status == Image.Ready ? asImageTester.source
108 property url background: asImageTester.status == Image.Ready ? asImageTester.source
60 : gsImageTester.status == Image.Ready ? gsImageTester.source : defaultBackground
109 : gsImageTester.status == Image.Ready ? gsImageTester.source : defaultBackground
61
110
62− property bool sideStageEnabled: shell.width >= units.gu(100)
63− readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
64−
65− property int orientation
66− readonly property int deviceOrientationAngle: Screen.angleBetween(Screen.primaryOrientation, Screen.orientation)
67− onDeviceOrientationAngleChanged: {
68− if (!OrientationLock.enabled) {
69− orientation = Screen.orientation;
70− }
71− }
72− readonly property bool orientationLockEnabled: OrientationLock.enabled
73− onOrientationLockEnabledChanged: {
74− if (orientationLockEnabled) {
75− OrientationLock.savedOrientation = Screen.orientation;
76− } else {
77− orientation = Screen.orientation;
78− }
79− }
80−
81 // This is _only_ used to expose the property to autopilot tests
111 // This is _only_ used to expose the property to autopilot tests
82 readonly property string testShellMode: shellMode
112 readonly property string testShellMode: shellMode
83
113
@@ -85,7 +115,8 @@ Item {
85 if (ApplicationManager.findApplication(appId)) {
115 if (ApplicationManager.findApplication(appId)) {
86 ApplicationManager.requestFocusApplication(appId);
116 ApplicationManager.requestFocusApplication(appId);
87 } else {
117 } else {
88− var execFlags = shell.sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
118+ var execFlags = shell.usageScenario === "phone" ? ApplicationManager.ForceMainStage
119+ : ApplicationManager.NoFlag;
89 ApplicationManager.startApplication(appId, execFlags);
120 ApplicationManager.startApplication(appId, execFlags);
90 }
121 }
91 }
122 }
@@ -123,11 +154,6 @@ Item {
123 sourceSize.width: 0
154 sourceSize.width: 0
124 }
155 }
125
156
126− GSettings {
127− id: usageModeSettings
128− schema.id: "com.canonical.Unity8"
129− }
130−
131 Binding {
157 Binding {
132 target: LauncherModel
158 target: LauncherModel
133 property: "applicationManager"
159 property: "applicationManager"
@@ -139,9 +165,7 @@ Item {
139 if (ApplicationManager.count > 0) {
165 if (ApplicationManager.count > 0) {
140 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
166 ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
141 }
167 }
142− if (orientationLockEnabled) {
168+ finishStartUpTimer.start();
143− orientation = OrientationLock.savedOrientation;
144− }
145 }
169 }
146
170
147 VolumeControl {
171 VolumeControl {
@@ -234,9 +258,19 @@ Item {
234 // theoretical attack where user enters lockedApp mode, then makes
258 // theoretical attack where user enters lockedApp mode, then makes
235 // the screen larger (maybe connects to monitor) and tries to enter
259 // the screen larger (maybe connects to monitor) and tries to enter
236 // tablet mode.
260 // tablet mode.
261+
237− property bool tabletMode: shell.sideStageEnabled && !greeter.hasLockedApp
262+ property string usageScenario: shell.usageScenario === "phone" || greeter.hasLockedApp
238− source: usageModeSettings.usageMode === "Windowed" ? "Stages/DesktopStage.qml"
263+ ? "phone"
264+ : shell.usageScenario
265+ source: {
266+ if (applicationsDisplayLoader.usageScenario === "phone") {
267+ return "Stages/PhoneStage.qml";
268+ } else if (applicationsDisplayLoader.usageScenario === "tablet") {
239− : tabletMode ? "Stages/TabletStage.qml" : "Stages/PhoneStage.qml"
269+ return "Stages/TabletStage.qml";
270+ } else {
271+ return "Stages/DesktopStage.qml";
272+ }
273+ }
240
274
241 property bool interactive: tutorial.spreadEnabled
275 property bool interactive: tutorial.spreadEnabled
242 && !greeter.shown
276 && !greeter.shown
@@ -279,7 +313,12 @@ Item {
279 }
313 }
280 Binding {
314 Binding {
281 target: applicationsDisplayLoader.item
315 target: applicationsDisplayLoader.item
282− property: "orientation"
316+ property: "shellOrientationAngle"
317+ value: shell.orientationAngle
318+ }
319+ Binding {
320+ target: applicationsDisplayLoader.item
321+ property: "shellOrientation"
283 value: shell.orientation
322 value: shell.orientation
284 }
323 }
285 Binding {
324 Binding {
@@ -287,6 +326,31 @@ Item {
287 property: "background"
326 property: "background"
288 value: shell.background
327 value: shell.background
289 }
328 }
329+ Binding {
330+ target: applicationsDisplayLoader.item
331+ property: "shellPrimaryOrientation"
332+ value: shell.primaryOrientation
333+ }
334+ Binding {
335+ target: applicationsDisplayLoader.item
336+ property: "nativeOrientation"
337+ value: shell.nativeOrientation
338+ }
339+ Binding {
340+ target: applicationsDisplayLoader.item
341+ property: "nativeWidth"
342+ value: shell.nativeWidth
343+ }
344+ Binding {
345+ target: applicationsDisplayLoader.item
346+ property: "nativeHeight"
347+ value: shell.nativeHeight
348+ }
349+ Binding {
350+ target: applicationsDisplayLoader.item
351+ property: "beingResized"
352+ value: shell.beingResized
353+ }
290 }
354 }
291
355
292 Tutorial {
356 Tutorial {
@@ -356,7 +420,7 @@ Item {
356 objectName: "greeter"
420 objectName: "greeter"
357
421
358 hides: [launcher, panel.indicators]
422 hides: [launcher, panel.indicators]
359− tabletMode: shell.sideStageEnabled
423+ tabletMode: shell.usageScenario !== "phone"
360 launcherOffset: launcher.progress
424 launcherOffset: launcher.progress
361 forcedUnlock: tutorial.running
425 forcedUnlock: tutorial.running
362 background: shell.background
426 background: shell.background
@@ -483,20 +547,18 @@ Item {
483 expandedPanelHeight: units.gu(7)
547 expandedPanelHeight: units.gu(7)
484
548
485 indicatorsModel: Indicators.IndicatorsModel {
549 indicatorsModel: Indicators.IndicatorsModel {
486− // TODO: This should be sourced by device type (e.g. "desktop", "tablet", "phone"...)
550+ // tablet and phone both use the same profile
487− profile: indicatorProfile
551+ profile: shell.usageScenario === "desktop" ? "desktop" : "phone"
488− Component.onCompleted: load()
552+ Component.onCompleted: load();
489 }
553 }
490 }
554 }
555+
491 callHint {
556 callHint {
492 greeterShown: greeter.shown
557 greeterShown: greeter.shown
493 }
558 }
494
559
495− property bool topmostApplicationIsFullscreen:
560+ property bool mainAppIsFullscreen: shell.mainApp && shell.mainApp.fullscreen
496− ApplicationManager.focusedApplicationId &&
497− ApplicationManager.findApplication(ApplicationManager.focusedApplicationId).fullscreen
498−
499− fullscreenMode: (topmostApplicationIsFullscreen && !LightDM.Greeter.active && launcher.progress == 0)
561+ fullscreenMode: (mainAppIsFullscreen && !LightDM.Greeter.active && launcher.progress == 0)
500 || greeter.hasLockedApp
562 || greeter.hasLockedApp
501 }
563 }
502
564
@@ -514,7 +576,7 @@ Item {
514 available: tutorial.launcherEnabled
576 available: tutorial.launcherEnabled
515 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
577 && (!greeter.locked || AccountsService.enableLauncherWhileLocked)
516 && !greeter.hasLockedApp
578 && !greeter.hasLockedApp
517− inverted: usageModeSettings.usageMode === "Staged"
579+ inverted: shell.usageScenario !== "desktop"
518 shadeBackground: !tutorial.running
580 shadeBackground: !tutorial.running
519
581
520 onShowDashHome: showHome()
582 onShowDashHome: showHome()
@@ -556,7 +618,7 @@ Item {
556 Rectangle {
618 Rectangle {
557 id: modalNotificationBackground
619 id: modalNotificationBackground
558
620
559− visible: notifications.useModal && (notifications.state == "narrow")
621+ visible: notifications.useModal
560 color: "#000000"
622 color: "#000000"
561 anchors.fill: parent
623 anchors.fill: parent
562 opacity: 0.9
624 opacity: 0.9
@@ -601,6 +663,7 @@ Item {
601
663
602 Dialogs {
664 Dialogs {
603 id: dialogs
665 id: dialogs
666+ objectName: "dialogs"
604 anchors.fill: parent
667 anchors.fill: parent
605 z: overlay.z + 10
668 z: overlay.z + 10
606 onPowerOffClicked: {
669 onPowerOffClicked: {
qml/Stages/ApplicationWindow.qml+53−18
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2014 Canonical Ltd.
2+ * Copyright 2014-2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -24,10 +24,11 @@ FocusScope {
24 // to be read from outside
24 // to be read from outside
25 readonly property bool fullscreen: application ? application.fullscreen : false
25 readonly property bool fullscreen: application ? application.fullscreen : false
26 property alias interactive: sessionContainer.interactive
26 property alias interactive: sessionContainer.interactive
27+ property bool orientationChangesEnabled: d.supportsSurfaceResize ? d.surfaceOldEnoughToBeResized : true
27
28
28 // to be set from outside
29 // to be set from outside
29 property QtObject application
30 property QtObject application
30− property int orientation
31+ property int surfaceOrientationAngle
31
32
32 QtObject {
33 QtObject {
33 id: d
34 id: d
@@ -62,6 +63,15 @@ FocusScope {
62 // Remove this when possible
63 // Remove this when possible
63 property bool surfaceInitialized: false
64 property bool surfaceInitialized: false
64
65
66+ property bool supportsSurfaceResize:
67+ application &&
68+ ((application.supportedOrientations & Qt.PortraitOrientation)
69+ || (application.supportedOrientations & Qt.InvertedPortraitOrientation))
70+ &&
71+ ((application.supportedOrientations & Qt.LandscapeOrientation)
72+ || (application.supportedOrientations & Qt.InvertedLandscapeOrientation))
73+
74+ property bool surfaceOldEnoughToBeResized: false
65 }
75 }
66
76
67 Timer {
77 Timer {
@@ -70,6 +80,12 @@ FocusScope {
70 onTriggered: { if (sessionContainer.surface) {d.surfaceInitialized = true;} }
80 onTriggered: { if (sessionContainer.surface) {d.surfaceInitialized = true;} }
71 }
81 }
72
82
83+ Timer {
84+ id: surfaceIsOldTimer
85+ interval: 1000
86+ onTriggered: { if (stateGroup.state === "surface") { d.surfaceOldEnoughToBeResized = true; } }
87+ }
88+
73 Image {
89 Image {
74 id: screenshotImage
90 id: screenshotImage
75 objectName: "screenshotImage"
91 objectName: "screenshotImage"
@@ -113,7 +129,8 @@ FocusScope {
113 // A fake application might not even have a session property.
129 // A fake application might not even have a session property.
114 session: application && application.session ? application.session : null
130 session: application && application.session ? application.session : null
115 anchors.fill: parent
131 anchors.fill: parent
116− orientation: root.orientation
132+
133+ surfaceOrientationAngle: application && application.rotatesWindowContents ? root.surfaceOrientationAngle : 0
117
134
118 onSurfaceChanged: {
135 onSurfaceChanged: {
119 if (sessionContainer.surface) {
136 if (sessionContainer.surface) {
@@ -179,15 +196,21 @@ FocusScope {
179 UbuntuNumberAnimation { target: sessionContainer.surfaceContainer; property: "opacity";
196 UbuntuNumberAnimation { target: sessionContainer.surfaceContainer; property: "opacity";
180 from: 0.0; to: 1.0
197 from: 0.0; to: 1.0
181 duration: UbuntuAnimation.BriskDuration }
198 duration: UbuntuAnimation.BriskDuration }
199+ ScriptAction { script: {
182− PropertyAction { target: splashLoader; property: "active"; value: false }
200+ splashLoader.active = false;
201+ surfaceIsOldTimer.start();
202+ } }
183 }
203 }
184 },
204 },
185 Transition {
205 Transition {
186 from: "surface"; to: "splashScreen"
206 from: "surface"; to: "splashScreen"
187 SequentialAnimation {
207 SequentialAnimation {
208+ ScriptAction { script: {
209+ surfaceIsOldTimer.stop();
210+ d.surfaceOldEnoughToBeResized = false;
188− PropertyAction { target: splashLoader; property: "active"; value: true }
211+ splashLoader.active = true;
189− PropertyAction { target: sessionContainer.surfaceContainer
212+ sessionContainer.surfaceContainer.visible = true;
190− property: "visible"; value: true }
213+ } }
191 UbuntuNumberAnimation { target: splashLoader; property: "opacity";
214 UbuntuNumberAnimation { target: splashLoader; property: "opacity";
192 from: 0.0; to: 1.0
215 from: 0.0; to: 1.0
193 duration: UbuntuAnimation.BriskDuration }
216 duration: UbuntuAnimation.BriskDuration }
@@ -198,14 +221,18 @@ FocusScope {
198 Transition {
221 Transition {
199 from: "surface"; to: "screenshot"
222 from: "surface"; to: "screenshot"
200 SequentialAnimation {
223 SequentialAnimation {
224+ ScriptAction { script: {
225+ surfaceIsOldTimer.stop();
226+ d.surfaceOldEnoughToBeResized = false;
201− PropertyAction { target: screenshotImage
227+ screenshotImage.visible = true;
202− property: "visible"; value: true }
228+ } }
203 UbuntuNumberAnimation { target: screenshotImage; property: "opacity";
229 UbuntuNumberAnimation { target: screenshotImage; property: "opacity";
204 from: 0.0; to: 1.0
230 from: 0.0; to: 1.0
205 duration: UbuntuAnimation.BriskDuration }
231 duration: UbuntuAnimation.BriskDuration }
232+ ScriptAction { script: {
206− PropertyAction { target: sessionContainer.surfaceContainer
233+ sessionContainer.surfaceContainer.visible = false;
207− property: "visible"; value: false }
208− ScriptAction { script: { if (sessionContainer.session) { sessionContainer.session.release(); } } }
234+ if (sessionContainer.session) { sessionContainer.session.release(); }
235+ } }
209 }
236 }
210 },
237 },
211 Transition {
238 Transition {
@@ -216,8 +243,11 @@ FocusScope {
216 UbuntuNumberAnimation { target: screenshotImage; property: "opacity";
243 UbuntuNumberAnimation { target: screenshotImage; property: "opacity";
217 from: 1.0; to: 0.0
244 from: 1.0; to: 0.0
218 duration: UbuntuAnimation.BriskDuration }
245 duration: UbuntuAnimation.BriskDuration }
246+ ScriptAction { script: {
219− PropertyAction { target: screenshotImage; property: "visible"; value: false }
247+ screenshotImage.visible = false;
220− PropertyAction { target: screenshotImage; property: "source"; value: "" }
248+ screenshotImage.source = "";
249+ surfaceIsOldTimer.start();
250+ } }
221 }
251 }
222 },
252 },
223 Transition {
253 Transition {
@@ -233,10 +263,12 @@ FocusScope {
233 },
263 },
234 Transition {
264 Transition {
235 from: "surface"; to: "void"
265 from: "surface"; to: "void"
236− SequentialAnimation {
266+ ScriptAction { script: {
237− PropertyAction { target: sessionContainer.surfaceContainer; property: "visible"; value: false }
267+ surfaceIsOldTimer.stop();
268+ d.surfaceOldEnoughToBeResized = false;
269+ sessionContainer.surfaceContainer.visible = false;
238− ScriptAction { script: { if (sessionContainer.session) { sessionContainer.session.release(); } } }
270+ if (sessionContainer.session) { sessionContainer.session.release(); }
239− }
271+ } }
240 },
272 },
241 Transition {
273 Transition {
242 from: "void"; to: "surface"
274 from: "void"; to: "surface"
@@ -246,6 +278,9 @@ FocusScope {
246 UbuntuNumberAnimation { target: sessionContainer.surfaceContainer; property: "opacity";
278 UbuntuNumberAnimation { target: sessionContainer.surfaceContainer; property: "opacity";
247 from: 0.0; to: 1.0
279 from: 0.0; to: 1.0
248 duration: UbuntuAnimation.BriskDuration }
280 duration: UbuntuAnimation.BriskDuration }
281+ ScriptAction { script: {
282+ surfaceIsOldTimer.start();
283+ } }
249 }
284 }
250 }
285 }
251 ]
286 ]
qml/Stages/DesktopStage.qml+23
@@ -27,6 +27,29 @@ FocusScope {
27
27
28 anchors.fill: parent
28 anchors.fill: parent
29
29
30+ // Controls to be set from outside
31+ property int dragAreaWidth // just to comply with the interface shared between stages
32+ property real maximizedAppTopMargin
33+ property bool interactive
34+ property bool spreadEnabled // just to comply with the interface shared between stages
35+ property real inverseProgress: 0 // just to comply with the interface shared between stages
36+ property int shellOrientationAngle: 0
37+ property int shellOrientation
38+ property int shellPrimaryOrientation
39+ property int nativeOrientation
40+ property bool beingResized: false
41+
42+ // functions to be called from outside
43+ function updateFocusedAppOrientation() { /* TODO */ }
44+ function updateFocusedAppOrientationAnimated() { /* TODO */}
45+
46+ // To be read from outside
47+ readonly property var mainApp: ApplicationManager.focusedApplicationId
48+ ? ApplicationManager.findApplication(ApplicationManager.focusedApplicationId)
49+ : null
50+ property int mainAppWindowOrientationAngle: 0
51+ readonly property bool orientationChangesEnabled: false
52+
30 property alias background: wallpaper.source
53 property alias background: wallpaper.source
31
54
32 property var windowStateStorage: WindowStateStorage
55 property var windowStateStorage: WindowStateStorage
qml/Stages/OrientationChangeAnimation.qmlnew file+241
@@ -0,0 +1,241 @@
1+/*
2+ * Copyright 2015 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
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 Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.3
18+
19+QtObject {
20+ id: root
21+
22+ // to be set from outside
23+ property Item spreadDelegate
24+ property Item background
25+ property Item window
26+ property Item screenshot
27+
28+ function start() {
29+ if (window.orientationAngle === 0) {
30+ if (spreadDelegate.shellOrientationAngle === 90) {
31+ chosenAnimation = simple90Animation;
32+ } else if (spreadDelegate.shellOrientationAngle === 180) {
33+ chosenAnimation = halfLoopAnimation;
34+ } else if (spreadDelegate.shellOrientationAngle === 270) {
35+ chosenAnimation = moving90Animation;
36+ } else {
37+ chosenAnimation = null;
38+ }
39+ } else if (window.orientationAngle === 90) {
40+ if (spreadDelegate.shellOrientationAngle === 0) {
41+ chosenAnimation = simple90Animation;
42+ } else if (spreadDelegate.shellOrientationAngle === 180) {
43+ chosenAnimation = moving90Animation;
44+ } else if (spreadDelegate.shellOrientationAngle === 270) {
45+ chosenAnimation = halfLoopAnimation;
46+ } else {
47+ chosenAnimation = null;
48+ }
49+ } else if (window.orientationAngle === 180) {
50+ if (spreadDelegate.shellOrientationAngle === 0) {
51+ chosenAnimation = halfLoopAnimation;
52+ } else if (spreadDelegate.shellOrientationAngle === 90) {
53+ chosenAnimation = moving90Animation;
54+ } else if (spreadDelegate.shellOrientationAngle === 270) {
55+ chosenAnimation = simple90Animation;
56+ } else {
57+ chosenAnimation = null;
58+ }
59+ } else if (window.orientationAngle === 270) {
60+ if (spreadDelegate.shellOrientationAngle === 0) {
61+ chosenAnimation = moving90Animation;
62+ } else if (spreadDelegate.shellOrientationAngle === 90) {
63+ chosenAnimation = halfLoopAnimation;
64+ } else if (spreadDelegate.shellOrientationAngle === 180) {
65+ chosenAnimation = simple90Animation;
66+ } else {
67+ chosenAnimation = null;
68+ }
69+ }
70+
71+ if (chosenAnimation)
72+ chosenAnimation.start();
73+ }
74+
75+ // to be read from outside
76+ property bool running: chosenAnimation ? chosenAnimation.running : false
77+
78+ property int duration: 450
79+ property int easingType: Easing.InOutCubic
80+
81+ property int shortestDimension: spreadDelegate.width < spreadDelegate.height
82+ ? spreadDelegate.width : spreadDelegate.height
83+ property int longestDimension: spreadDelegate.width > spreadDelegate.height
84+ ? spreadDelegate.width : spreadDelegate.height
85+ property string longestAxis: spreadDelegate.width > spreadDelegate.height ? "x" : "y"
86+
87+ property QtObject chosenAnimation
88+
89+ function setup90Animation() {
90+ background.visible = true;
91+
92+ screenshot.width = window.width;
93+ screenshot.height = window.height;
94+ screenshot.window.anchors.topMargin = window.window.anchors.topMargin;
95+ screenshot.take();
96+ screenshot.transformOriginX = root.shortestDimension / 2;
97+ screenshot.transformOriginY = root.shortestDimension / 2;
98+ screenshot.visible = true;
99+
100+ window.rotation = 0;
101+ window.width = spreadDelegate.width;
102+ window.height = spreadDelegate.height;
103+ window.transformOriginX = root.shortestDimension / 2;
104+ window.transformOriginY = root.shortestDimension / 2;
105+ }
106+
107+ function tearDown90Animation() {
108+ window.orientationAngle = spreadDelegate.shellOrientationAngle;
109+ screenshot.discard();
110+ screenshot.visible = false;
111+ background.visible = false;
112+ }
113+
114+ property QtObject simple90Animation: SequentialAnimation {
115+ id: simple90Animation
116+
117+ ScriptAction { script: setup90Animation() }
118+ ParallelAnimation {
119+ RotationAnimation {
120+ target: root.window
121+ duration: root.duration
122+ easing.type: root.easingType
123+ from: window.orientationAngle - spreadDelegate.shellOrientationAngle
124+ to: 0
125+ property: "transformRotationAngle"
126+ }
127+ RotationAnimation {
128+ target: root.screenshot
129+ duration: root.duration
130+ easing.type: root.easingType
131+ from: window.orientationAngle - spreadDelegate.shellOrientationAngle
132+ to: 0
133+ property: "transformRotationAngle"
134+ }
135+ NumberAnimation {
136+ target: root.screenshot
137+ duration: root.duration
138+ easing.type: root.easingType
139+ property: "opacity"
140+ from: 1.0
141+ to: 0.0
142+ }
143+ NumberAnimation {
144+ target: root.window
145+ duration: root.duration
146+ easing.type: root.easingType
147+ property: "opacity"
148+ from: 0.0
149+ to: 1.0
150+ }
151+ }
152+ ScriptAction { script: tearDown90Animation() }
153+ }
154+
155+ property QtObject moving90Animation: SequentialAnimation {
156+ id: moving90Animation
157+
158+ ScriptAction { script: setup90Animation() }
159+ ParallelAnimation {
160+ RotationAnimation {
161+ target: root.window
162+ duration: root.duration
163+ easing.type: root.easingType
164+ direction: RotationAnimation.Shortest
165+ from: window.orientationAngle - spreadDelegate.shellOrientationAngle
166+ to: 0
167+ property: "transformRotationAngle"
168+ }
169+ RotationAnimation {
170+ target: root.screenshot
171+ duration: root.duration
172+ easing.type: root.easingType
173+ direction: RotationAnimation.Shortest
174+ from: window.orientationAngle - spreadDelegate.shellOrientationAngle
175+ to: 0
176+ property: "transformRotationAngle"
177+ }
178+ NumberAnimation {
179+ target: root.screenshot
180+ duration: root.duration
181+ easing.type: root.easingType
182+ property: "opacity"
183+ from: 1.0
184+ to: 0.0
185+ }
186+ NumberAnimation {
187+ target: root.window
188+ duration: root.duration
189+ easing.type: root.easingType
190+ property: "opacity"
191+ from: 0.0
192+ to: 1.0
193+ }
194+ NumberAnimation {
195+ target: root.window
196+ duration: root.duration
197+ easing.type: root.easingType
198+ property: root.longestAxis
199+ from: root.longestDimension - root.shortestDimension
200+ to: 0
201+ }
202+ NumberAnimation {
203+ target: root.screenshot
204+ duration: root.duration
205+ easing.type: root.easingType
206+ property: root.longestAxis
207+ from: root.longestDimension - root.shortestDimension
208+ to: 0
209+ }
210+ }
211+ ScriptAction { script: tearDown90Animation() }
212+ }
213+
214+ property QtObject halfLoopAnimation: SequentialAnimation {
215+ id: halfLoopAnimation
216+
217+ ScriptAction { script: {
218+ background.visible = true;
219+
220+ window.rotation = 0;
221+ window.width = spreadDelegate.width;
222+ window.height = spreadDelegate.height;
223+ window.transformOriginX = window.width / 2
224+ window.transformOriginY = window.height / 2
225+ } }
226+ ParallelAnimation {
227+ RotationAnimation {
228+ target: root.window
229+ duration: root.duration
230+ easing.type: root.easingType
231+ from: window.orientationAngle - spreadDelegate.shellOrientationAngle
232+ to: 0
233+ property: "transformRotationAngle"
234+ }
235+ }
236+ ScriptAction { script: {
237+ window.orientationAngle = spreadDelegate.shellOrientationAngle;
238+ background.visible = false;
239+ } }
240+ }
241+}
qml/Stages/PhoneStage.qml+137−39
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014-2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -31,12 +31,64 @@ Rectangle {
31 property bool interactive
31 property bool interactive
32 property bool spreadEnabled: true // If false, animations and right edge will be disabled
32 property bool spreadEnabled: true // If false, animations and right edge will be disabled
33 property real inverseProgress: 0 // This is the progress for left edge drags, in pixels.
33 property real inverseProgress: 0 // This is the progress for left edge drags, in pixels.
34− property int orientation: Qt.PortraitOrientation
35 property QtObject applicationManager: ApplicationManager
34 property QtObject applicationManager: ApplicationManager
36 property bool focusFirstApp: true // If false, focused app will appear on right edge like other apps
35 property bool focusFirstApp: true // If false, focused app will appear on right edge like other apps
37 property bool altTabEnabled: true
36 property bool altTabEnabled: true
38 property real startScale: 1.1
37 property real startScale: 1.1
39 property real endScale: 0.7
38 property real endScale: 0.7
39+ property int shellOrientationAngle: 0
40+ property int shellOrientation
41+ property int shellPrimaryOrientation
42+ property int nativeOrientation
43+ property real nativeWidth
44+ property real nativeHeight
45+ property bool beingResized: false
46+ onBeingResizedChanged: {
47+ if (beingResized) {
48+ // Brace yourselves for impact!
49+ spreadView.selectedIndex = -1;
50+ spreadView.phase = 0;
51+ spreadView.contentX = -spreadView.shift;
52+ }
53+ }
54+ function updateFocusedAppOrientation() {
55+ if (spreadRepeater.count > 0) {
56+ spreadRepeater.itemAt(0).matchShellOrientation();
57+ }
58+
59+ for (var i = 1; i < spreadRepeater.count; ++i) {
60+
61+ var spreadDelegate = spreadRepeater.itemAt(i);
62+
63+ var delta = spreadDelegate.appWindowOrientationAngle - root.shellOrientationAngle;
64+ if (delta < 0) { delta += 360; }
65+ delta = delta % 360;
66+
67+ var supportedOrientations = spreadDelegate.application.supportedOrientations;
68+ if (supportedOrientations === Qt.PrimaryOrientation) {
69+ supportedOrientations = spreadDelegate.shellPrimaryOrientation;
70+ }
71+
72+ if (delta === 180 && (supportedOrientations & spreadDelegate.shellOrientation)) {
73+ spreadDelegate.matchShellOrientation();
74+ }
75+ }
76+ }
77+ function updateFocusedAppOrientationAnimated() {
78+ if (spreadRepeater.count > 0) {
79+ spreadRepeater.itemAt(0).animateToShellOrientation();
80+ }
81+ }
82+
83+ // To be read from outside
84+ readonly property var mainApp: applicationManager.focusedApplicationId
85+ ? applicationManager.findApplication(applicationManager.focusedApplicationId)
86+ : null
87+ property int mainAppWindowOrientationAngle: 0
88+ readonly property bool orientationChangesEnabled: priv.focusedAppOrientationChangesEnabled
89+ && !priv.focusedAppDelegateIsDislocated
90+ && !(priv.focusedAppDelegate && priv.focusedAppDelegate.xBehavior.running)
91+ && spreadView.phase === 0
40
92
41 // How far left the stage has been dragged
93 // How far left the stage has been dragged
42 readonly property real dragProgress: spreadRepeater.count > 0 ? -spreadRepeater.itemAt(0).xTranslate : 0
94 readonly property real dragProgress: spreadRepeater.count > 0 ? -spreadRepeater.itemAt(0).xTranslate : 0
@@ -54,12 +106,6 @@ Rectangle {
54 spreadView.snapTo(priv.indexOf(appId));
106 spreadView.snapTo(priv.indexOf(appId));
55 }
107 }
56
108
57− onWidthChanged: {
58− spreadView.selectedIndex = -1;
59− spreadView.phase = 0;
60− spreadView.contentX = -spreadView.shift;
61− }
62−
63 onInverseProgressChanged: {
109 onInverseProgressChanged: {
64 // This can't be a simple binding because that would be triggered after this handler
110 // This can't be a simple binding because that would be triggered after this handler
65 // while we need it active before doing the anition left/right
111 // while we need it active before doing the anition left/right
@@ -73,6 +119,20 @@ Rectangle {
73 priv.oldInverseProgress = inverseProgress;
119 priv.oldInverseProgress = inverseProgress;
74 }
120 }
75
121
122+ // <FIXME-contentX> See rationale in the next comment with this tag
123+ onWidthChanged: {
124+ if (!root.beingResized) {
125+ // we're being resized without a warning (ie, the corresponding property wasn't set
126+ root.beingResized = true;
127+ beingResizedTimer.start();
128+ }
129+ }
130+ Timer {
131+ id: beingResizedTimer
132+ interval: 100
133+ onTriggered: { root.beingResized = false; }
134+ }
135+
76 Connections {
136 Connections {
77 target: applicationManager
137 target: applicationManager
78
138
@@ -115,10 +175,10 @@ Rectangle {
115 QtObject {
175 QtObject {
116 id: priv
176 id: priv
117
177
118− readonly property int firstSpreadIndex: root.focusFirstApp ? 1 : 0
119− property string focusedAppId: applicationManager.focusedApplicationId
178+ property string focusedAppId: root.applicationManager.focusedApplicationId
120− property var focusedApplication: applicationManager.findApplication(focusedAppId)
179+ property var focusedApplication: root.applicationManager.findApplication(focusedAppId)
121 property var focusedAppDelegate: null
180 property var focusedAppDelegate: null
181+ property bool focusedAppOrientationChangesEnabled: false
122
182
123 property real oldInverseProgress: 0
183 property real oldInverseProgress: 0
124 property bool animateX: false
184 property bool animateX: false
@@ -131,15 +191,27 @@ Rectangle {
131 }
191 }
132 }
192 }
133
193
194+ property bool focusedAppDelegateIsDislocated: focusedAppDelegate && focusedAppDelegate.x !== 0
195+
134 function indexOf(appId) {
196 function indexOf(appId) {
135− for (var i = 0; i < applicationManager.count; i++) {
197+ for (var i = 0; i < root.applicationManager.count; i++) {
136− if (applicationManager.get(i).appId == appId) {
198+ if (root.applicationManager.get(i).appId == appId) {
137 return i;
199 return i;
138 }
200 }
139 }
201 }
140 return -1;
202 return -1;
141 }
203 }
142
204
205+ // Is more stable than "spreadView.shiftedContentX === 0" as it filters out noise caused by
206+ // Flickable.contentX changing due to resizes.
207+ property bool fullyShowingFocusedApp: true
208+ }
209+ Timer {
210+ id: fullyShowingFocusedAppUpdateTimer
211+ interval: 100
212+ onTriggered: {
213+ priv.fullyShowingFocusedApp = spreadView.shiftedContentX === 0;
214+ }
143 }
215 }
144
216
145 Flickable {
217 Flickable {
@@ -187,9 +259,25 @@ Rectangle {
187 property int draggedDelegateCount: 0
259 property int draggedDelegateCount: 0
188 property int closingIndex: -1
260 property int closingIndex: -1
189
261
190− property bool focusChanging: false
262+ // <FIXME-contentX> Workaround Flickable's behavior of bringing contentX back between valid boundaries
263+ // when resized. The proper way to fix this is refactoring PhoneStage so that it doesn't
264+ // rely on having Flickable.contentX keeping an out-of-bounds value when it's set programatically
265+ // (as opposed to having contentX reaching an out-of-bounds value through dragging, which will trigger
266+ // the Flickable.boundsBehavior upon release).
267+ onContentXChanged: { forceItToRemainStillIfBeingResized(); }
268+ onShiftChanged: { forceItToRemainStillIfBeingResized(); }
269+ function forceItToRemainStillIfBeingResized() {
270+ if (root.beingResized && contentX != -spreadView.shift) {
271+ contentX = -spreadView.shift;
272+ }
273+ }
191
274
192 onShiftedContentXChanged: {
275 onShiftedContentXChanged: {
276+ if (root.beingResized) {
277+ // Flickabe.contentX wiggles during resizes. Don't react to it.
278+ return;
279+ }
280+
193 switch (phase) {
281 switch (phase) {
194 case 0:
282 case 0:
195 if (shiftedContentX > width * positionMarker2) {
283 if (shiftedContentX > width * positionMarker2) {
@@ -204,6 +292,7 @@ Rectangle {
204 }
292 }
205 break;
293 break;
206 }
294 }
295+ fullyShowingFocusedAppUpdateTimer.restart();
207 }
296 }
208
297
209 function snap() {
298 function snap() {
@@ -228,7 +317,7 @@ Rectangle {
228 snapAnimation.start();
317 snapAnimation.start();
229 return;
318 return;
230 }
319 }
231− if (applicationManager.count <= index) {
320+ if (root.applicationManager.count <= index) {
232 // In case we're trying to snap to some non existing app, lets snap back to the first one
321 // In case we're trying to snap to some non existing app, lets snap back to the first one
233 index = 0;
322 index = 0;
234 }
323 }
@@ -265,7 +354,7 @@ Rectangle {
265 ScriptAction {
354 ScriptAction {
266 script: {
355 script: {
267 if (spreadView.selectedIndex >= 0) {
356 if (spreadView.selectedIndex >= 0) {
268− applicationManager.focusApplication(applicationManager.get(spreadView.selectedIndex).appId);
357+ root.applicationManager.focusApplication(root.applicationManager.get(spreadView.selectedIndex).appId);
269
358
270 spreadView.selectedIndex = -1;
359 spreadView.selectedIndex = -1;
271 spreadView.phase = 0;
360 spreadView.phase = 0;
@@ -280,7 +369,7 @@ Rectangle {
280 // This width controls how much the spread can be flicked left/right. It's composed of:
369 // This width controls how much the spread can be flicked left/right. It's composed of:
281 // tileDistance * app count (with a minimum of 3 apps, in order to also allow moving 1 and 2 apps a bit)
370 // tileDistance * app count (with a minimum of 3 apps, in order to also allow moving 1 and 2 apps a bit)
282 // + some constant value (still scales with the screen width) which looks good and somewhat fills the screen
371 // + some constant value (still scales with the screen width) which looks good and somewhat fills the screen
283− width: Math.max(3, applicationManager.count) * spreadView.tileDistance + (spreadView.width - spreadView.tileDistance) * 1.5
372+ width: Math.max(3, root.applicationManager.count) * spreadView.tileDistance + (spreadView.width - spreadView.tileDistance) * 1.5
284 height: parent.height
373 height: parent.height
285 Behavior on width {
374 Behavior on width {
286 enabled: spreadView.closingIndex >= 0
375 enabled: spreadView.closingIndex >= 0
@@ -303,7 +392,7 @@ Rectangle {
303 Repeater {
392 Repeater {
304 id: spreadRepeater
393 id: spreadRepeater
305 objectName: "spreadRepeater"
394 objectName: "spreadRepeater"
306− model: applicationManager
395+ model: root.applicationManager
307 delegate: TransformedSpreadDelegate {
396 delegate: TransformedSpreadDelegate {
308 id: appDelegate
397 id: appDelegate
309 objectName: "appDelegate" + index
398 objectName: "appDelegate" + index
@@ -318,11 +407,10 @@ Rectangle {
318 selected: spreadView.selectedIndex == index
407 selected: spreadView.selectedIndex == index
319 otherSelected: spreadView.selectedIndex >= 0 && !selected
408 otherSelected: spreadView.selectedIndex >= 0 && !selected
320 interactive: !spreadView.interactive && spreadView.phase === 0
409 interactive: !spreadView.interactive && spreadView.phase === 0
321− && spreadView.shiftedContentX === 0 && root.interactive && isFocused
410+ && priv.fullyShowingFocusedApp && root.interactive && isFocused
322 swipeToCloseEnabled: spreadView.interactive && root.interactive && !snapAnimation.running
411 swipeToCloseEnabled: spreadView.interactive && root.interactive && !snapAnimation.running
323 maximizedAppTopMargin: root.maximizedAppTopMargin
412 maximizedAppTopMargin: root.maximizedAppTopMargin
324− dropShadow: spreadView.active ||
413+ dropShadow: spreadView.active || priv.focusedAppDelegateIsDislocated
325− (priv.focusedAppDelegate && priv.focusedAppDelegate.x !== 0)
326 focusFirstApp: root.focusFirstApp
414 focusFirstApp: root.focusFirstApp
327
415
328 readonly property bool isDash: model.appId == "unity8-dash"
416 readonly property bool isDash: model.appId == "unity8-dash"
@@ -345,7 +433,7 @@ Rectangle {
345 return spreadView.width + spreadIndex * spreadView.tileDistance;
433 return spreadView.width + spreadIndex * spreadView.tileDistance;
346 }
434 }
347
435
348− application: applicationManager.get(index)
436+ application: root.applicationManager.get(index)
349 closeable: !isDash
437 closeable: !isDash
350
438
351 property real behavioredIndex: index
439 property real behavioredIndex: index
@@ -361,18 +449,16 @@ Rectangle {
361 }
449 }
362 }
450 }
363
451
452+ property var xBehavior: xBehavior
364 Behavior on x {
453 Behavior on x {
454+ id: xBehavior
365 enabled: root.spreadEnabled &&
455 enabled: root.spreadEnabled &&
366 !spreadView.active &&
456 !spreadView.active &&
367 !snapAnimation.running &&
457 !snapAnimation.running &&
368− priv.animateX
458+ priv.animateX &&
459+ !root.beingResized
369 UbuntuNumberAnimation {
460 UbuntuNumberAnimation {
370 duration: UbuntuAnimation.BriskDuration
461 duration: UbuntuAnimation.BriskDuration
371− onRunningChanged: {
372− if (!running && root.inverseProgress == 0) {
373− spreadView.focusChanging = false;
374− }
375− }
376 }
462 }
377 }
463 }
378
464
@@ -412,22 +498,21 @@ Rectangle {
412 }
498 }
413
499
414 // Hiding tiles when their progress is negative or reached the maximum
500 // Hiding tiles when their progress is negative or reached the maximum
415− visible: (progress >= 0 && progress < 1.7) ||
501+ visible: (progress >= 0 && progress < 1.7)
416− (isDash && priv.focusedAppDelegate.x !== 0)
502+ || (isDash && priv.focusedAppDelegateIsDislocated)
417
503
418− Binding {
504+
419− target: appDelegate
505+ shellOrientationAngle: root.shellOrientationAngle
420− property: "orientation"
506+ shellOrientation: root.shellOrientation
421− when: appDelegate.interactive
507+ shellPrimaryOrientation: root.shellPrimaryOrientation
422− value: root.orientation
508+ nativeOrientation: root.nativeOrientation
423− }
424
509
425 onClicked: {
510 onClicked: {
426 if (root.altTabEnabled && spreadView.phase == 2) {
511 if (root.altTabEnabled && spreadView.phase == 2) {
427− if (applicationManager.focusedApplicationId == applicationManager.get(index).appId) {
512+ if (root.applicationManager.focusedApplicationId == root.applicationManager.get(index).appId) {
428 spreadView.snapTo(index);
513 spreadView.snapTo(index);
429 } else {
514 } else {
430− applicationManager.requestFocusApplication(applicationManager.get(index).appId);
515+ root.applicationManager.requestFocusApplication(root.applicationManager.get(index).appId);
431 }
516 }
432 }
517 }
433 }
518 }
@@ -442,7 +527,20 @@ Rectangle {
442
527
443 onClosed: {
528 onClosed: {
444 spreadView.closingIndex = index;
529 spreadView.closingIndex = index;
445− applicationManager.stopApplication(applicationManager.get(index).appId);
530+ root.applicationManager.stopApplication(root.applicationManager.get(index).appId);
531+ }
532+
533+ Binding {
534+ target: root
535+ when: index == 0
536+ property: "mainAppWindowOrientationAngle"
537+ value: appWindowOrientationAngle
538+ }
539+ Binding {
540+ target: priv
541+ when: index == 0
542+ property: "focusedAppOrientationChangesEnabled"
543+ value: orientationChangesEnabled
446 }
544 }
447 }
545 }
448 }
546 }
qml/Stages/SessionContainer.qml+2−8
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2014 Canonical Ltd.
2+ * Copyright 2014-2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -24,14 +24,13 @@ FocusScope {
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 alias interactive: _surfaceContainer.interactive
26 property alias interactive: _surfaceContainer.interactive
27− property int orientation
27+ property alias surfaceOrientationAngle: _surfaceContainer.surfaceOrientationAngle
28
28
29 readonly property alias surfaceContainer: _surfaceContainer
29 readonly property alias surfaceContainer: _surfaceContainer
30 SurfaceContainer {
30 SurfaceContainer {
31 id: _surfaceContainer
31 id: _surfaceContainer
32 anchors.fill: parent
32 anchors.fill: parent
33 surface: session ? session.surface : null
33 surface: session ? session.surface : null
34− orientation: root.orientation
35 }
34 }
36
35
37 Repeater {
36 Repeater {
@@ -72,11 +71,6 @@ FocusScope {
72 target: item; when: item
71 target: item; when: item
73 property: "height"; value: root.height
72 property: "height"; value: root.height
74 }
73 }
75−
76− Binding {
77− target: item; when: item
78− property: "orientation"; value: root.orientation
79− }
80 }
74 }
81 }
75 }
82
76
qml/Stages/SpreadDelegate.qml+261−20
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2014 Canonical Ltd.
2+ * Copyright 2014-2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -18,6 +18,7 @@
18 */
18 */
19
19
20import QtQuick 2.0
20import QtQuick 2.0
21+import QtQuick.Window 2.0
21import Ubuntu.Components 1.1
22import Ubuntu.Components 1.1
22import "../Components"
23import "../Components"
23
24
@@ -28,6 +29,9 @@ FocusScope {
28 readonly property bool dragged: dragArea.moving
29 readonly property bool dragged: dragArea.moving
29 signal clicked()
30 signal clicked()
30 signal closed()
31 signal closed()
32+ readonly property alias appWindowOrientationAngle: appWindowWithShadow.orientationAngle
33+ readonly property alias appWindowRotation: appWindowWithShadow.rotation
34+ readonly property alias orientationChangesEnabled: appWindow.orientationChangesEnabled
31
35
32 // to be set from outside
36 // to be set from outside
33 property bool interactive: true
37 property bool interactive: true
@@ -36,10 +40,54 @@ FocusScope {
36 property alias swipeToCloseEnabled: dragArea.enabled
40 property alias swipeToCloseEnabled: dragArea.enabled
37 property bool closeable
41 property bool closeable
38 property alias application: appWindow.application
42 property alias application: appWindow.application
39− property int orientation
43+ property int shellOrientationAngle
44+ property int shellOrientation
45+ property int shellPrimaryOrientation
46+ property int nativeOrientation
47+
48+ function matchShellOrientation() {
49+ if (!root.application)
50+ return;
51+ appWindowWithShadow.orientationAngle = root.shellOrientationAngle;
52+ }
53+
54+ function animateToShellOrientation() {
55+ if (!root.application)
56+ return;
57+
58+ if (root.application.rotatesWindowContents) {
59+ appWindowWithShadow.orientationAngle = root.shellOrientationAngle;
60+ } else {
61+ orientationChangeAnimation.start();
62+ }
63+ }
64+
65+ OrientationChangeAnimation {
66+ id: orientationChangeAnimation
67+ objectName: "orientationChangeAnimation"
68+ spreadDelegate: root
69+ background: background
70+ window: appWindowWithShadow
71+ screenshot: appWindowScreenshotWithShadow
72+ }
73+
74+ QtObject {
75+ id: priv
76+ property bool startingUp: true
77+ }
78+
79+ Component.onCompleted: { finishStartUpTimer.start(); }
80+ Timer { id: finishStartUpTimer; interval: 400; onTriggered: priv.startingUp = false }
81+
82+ Rectangle {
83+ id: background
84+ color: "black"
85+ anchors.fill: parent
86+ visible: false
87+ }
40
88
41 Item {
89 Item {
42− objectName: "appWindowWithShadow"
90+ objectName: "displacedAppWindowWithShadow"
43
91
44 readonly property real limit: root.height / 4
92 readonly property real limit: root.height / 4
45
93
@@ -52,27 +100,220 @@ FocusScope {
52 return k * (1 - Math.pow((k - 1) / k, distance))
100 return k * (1 - Math.pow((k - 1) / k, distance))
53 }
101 }
54
102
55− BorderImage {
103+ Item {
56− anchors {
104+ id: appWindowWithShadow
105+ objectName: "appWindowWithShadow"
106+
107+ property int orientationAngle
108+
109+ property real transformRotationAngle: 0
110+ property real transformOriginX
111+ property real transformOriginY
112+
57− fill: appWindow
113+ property var window: appWindow
58− margins: -units.gu(2)
114+
115+ transform: Rotation {
116+ origin.x: appWindowWithShadow.transformOriginX
117+ origin.y: appWindowWithShadow.transformOriginY
118+ axis { x: 0; y: 0; z: 1 }
119+ angle: appWindowWithShadow.transformRotationAngle
120+ }
121+
122+ state: {
123+ if (priv.startingUp) {
124+ return "startingUp";
125+ } else if (root.application && root.application.rotatesWindowContents) {
126+ return "counterRotate";
127+ } else if (orientationChangeAnimation.running) {
128+ return "animatingRotation";
129+ } else {
130+ return "keepSceneRotation";
131+ }
59 }
132 }
60− source: "graphics/dropshadow2gu.sci"
61− opacity: root.dropShadow ? .3 : 0
62− Behavior on opacity { UbuntuNumberAnimation {} }
63− }
64
133
65− ApplicationWindow {
134+ // Ensures the given angle is in the form (0,90,180,270)
66− id: appWindow
135+ function normalizeAngle(angle) {
67− objectName: application ? "appWindow_" + application.appId : "appWindow_null"
136+ while (angle < 0) {
68− focus: true
137+ angle += 360;
69− anchors {
138+ }
70− fill: parent
139+ return angle % 360;
71− topMargin: appWindow.fullscreen ? 0 : maximizedAppTopMargin
72 }
140 }
73
141
142+ states: [
143+ // Sets the initial orientationAngle of the window, when it first slides into view
144+ // (with the splash screen likely being displayed). At that point we just try to
145+ // match shell's current orientation. We need a bit of time in this state as the
146+ // information we need to decide orientationAngle may take a few cycles to
147+ // be set.
148+ State {
149+ name: "startingUp"
150+ PropertyChanges {
151+ target: appWindowWithShadow
152+ restoreEntryValues: false
153+ orientationAngle: {
154+ if (!root.application || root.application.rotatesWindowContents) {
155+ return 0;
156+ }
157+ var supportedOrientations = root.application.supportedOrientations;
158+
159+ if (supportedOrientations === Qt.PrimaryOrientation) {
160+ supportedOrientations = root.shellPrimaryOrientation;
161+ }
162+
163+ // If it doesn't support shell's current orientation
164+ // then simply pick some arbitraty one that it does support
165+ var chosenOrientation = 0;
166+ if (supportedOrientations & root.shellOrientation) {
167+ chosenOrientation = root.shellOrientation;
168+ } else if (supportedOrientations & Qt.PortraitOrientation) {
169+ chosenOrientation = Qt.PortraitOrientation;
170+ } else if (supportedOrientations & Qt.LandscapeOrientation) {
171+ chosenOrientation = Qt.LandscapeOrientation;
172+ } else if (supportedOrientations & Qt.InvertedPortraitOrientation) {
173+ chosenOrientation = Qt.InvertedPortraitOrientation;
174+ } else if (supportedOrientations & Qt.InvertedLandscapeOrientation) {
175+ chosenOrientation = Qt.InvertedLandscapeOrientation;
176+ } else {
177+ chosenOrientation = root.shellPrimaryOrientation;
178+ }
179+
180+ return Screen.angleBetween(root.nativeOrientation, chosenOrientation);
181+ }
182+
183+ rotation: normalizeAngle(appWindowWithShadow.orientationAngle - root.shellOrientationAngle)
184+ width: {
185+ if (rotation == 0 || rotation == 180) {
186+ return root.width;
187+ } else {
188+ return root.height;
189+ }
190+ }
191+ height: {
192+ if (rotation == 0 || rotation == 180)
193+ return root.height;
194+ else
195+ return root.width;
196+ }
197+ }
198+ },
199+ // In this state we stick to our currently set orientationAngle, which may change only due
200+ // to calls made to matchShellOrientation() or animateToShellOrientation()
201+ State {
202+ id: keepSceneRotationState
203+ name: "keepSceneRotation"
204+
205+ StateChangeScript { script: {
206+ // break binding
207+ appWindowWithShadow.orientationAngle = appWindowWithShadow.orientationAngle;
208+ } }
209+ PropertyChanges {
210+ target: appWindowWithShadow
211+ restoreEntryValues: false
212+ rotation: normalizeAngle(appWindowWithShadow.orientationAngle - root.shellOrientationAngle)
213+ width: {
214+ if (rotation == 0 || rotation == 180) {
215+ return root.width;
216+ } else {
217+ return root.height;
218+ }
219+ }
220+ height: {
221+ if (rotation == 0 || rotation == 180)
222+ return root.height;
223+ else
224+ return root.width;
225+ }
226+ }
227+ },
228+ // In this state we counteract any shell rotation so that the window, in scene coordinates,
229+ // remains unrotated.
230+ State {
231+ name: "counterRotate"
232+ StateChangeScript { script: {
233+ // break binding
234+ appWindowWithShadow.orientationAngle = appWindowWithShadow.orientationAngle;
235+ } }
236+ PropertyChanges {
237+ target: appWindowWithShadow
238+ width: root.shellOrientationAngle == 0 || root.shellOrientationAngle == 180 ? root.width : root.height
239+ height: root.shellOrientationAngle == 0 || root.shellOrientationAngle == 180 ? root.height : root.width
240+ rotation: normalizeAngle(-root.shellOrientationAngle)
241+ }
242+ PropertyChanges {
243+ target: appWindow
244+ surfaceOrientationAngle: orientationAngle
245+ }
246+ },
247+ State {
248+ name: "animatingRotation"
249+ }
250+ ]
251+
252+ x: (parent.width - width) / 2
253+ y: (parent.height - height) / 2
254+
255+ BorderImage {
256+ anchors {
257+ fill: appWindow
258+ margins: -units.gu(2)
259+ }
260+ source: "graphics/dropshadow2gu.sci"
261+ opacity: root.dropShadow ? .3 : 0
262+ Behavior on opacity { UbuntuNumberAnimation {} }
263+ }
264+
265+ ApplicationWindow {
266+ id: appWindow
267+ objectName: application ? "appWindow_" + application.appId : "appWindow_null"
268+ focus: true
269+ anchors {
270+ fill: parent
271+ topMargin: appWindow.fullscreen || application.rotatesWindowContents
272+ ? 0 : maximizedAppTopMargin
273+ }
274+
74− interactive: root.interactive
275+ interactive: root.interactive
75− orientation: root.orientation
276+ }
277+ }
278+ }
279+
280+ Item {
281+ // mimics appWindowWithShadow. Do the positioning of screenshots of non-fullscreen
282+ // app windows
283+ id: appWindowScreenshotWithShadow
284+ visible: false
285+
286+ property real transformRotationAngle: 0
287+ property real transformOriginX
288+ property real transformOriginY
289+
290+ transform: Rotation {
291+ origin.x: appWindowScreenshotWithShadow.transformOriginX
292+ origin.y: appWindowScreenshotWithShadow.transformOriginY
293+ axis { x: 0; y: 0; z: 1 }
294+ angle: appWindowScreenshotWithShadow.transformRotationAngle
295+ }
296+
297+ property var window: appWindowScreenshot
298+
299+ function take() {
300+ // Format: "image://application/$APP_ID/$CURRENT_TIME_MS"
301+ // eg: "image://application/calculator-app/123456"
302+ var timeMs = new Date().getTime();
303+ appWindowScreenshot.source = "image://application/" + root.application.appId + "/" + timeMs;
304+ }
305+ function discard() {
306+ appWindowScreenshot.source = "";
307+ }
308+
309+ Image {
310+ id: appWindowScreenshot
311+ source: ""
312+
313+ anchors.fill: parent
314+
315+ sourceSize.width: width
316+ sourceSize.height: height
76 }
317 }
77 }
318 }
78
319
qml/Stages/SurfaceContainer.qml+2−2
@@ -24,8 +24,8 @@ FocusScope {
24 objectName: "surfaceContainer"
24 objectName: "surfaceContainer"
25 property Item surface: null
25 property Item surface: null
26 property bool hadSurface: false
26 property bool hadSurface: false
27− property int orientation
28 property bool interactive
27 property bool interactive
28+ property int surfaceOrientationAngle: 0
29
29
30 onSurfaceChanged: {
30 onSurfaceChanged: {
31 if (surface) {
31 if (surface) {
@@ -39,10 +39,10 @@ FocusScope {
39 }
39 }
40 }
40 }
41 Binding { target: surface; property: "anchors.fill"; value: root }
41 Binding { target: surface; property: "anchors.fill"; value: root }
42− Binding { target: surface; property: "orientation"; value: root.orientation }
43 Binding { target: surface; property: "z"; value: 1 }
42 Binding { target: surface; property: "z"; value: 1 }
44 Binding { target: surface; property: "enabled"; value: root.interactive; when: surface }
43 Binding { target: surface; property: "enabled"; value: root.interactive; when: surface }
45 Binding { target: surface; property: "antialiasing"; value: !root.interactive; when: surface }
44 Binding { target: surface; property: "antialiasing"; value: !root.interactive; when: surface }
45+ Binding { target: surface; property: "orientationAngle"; value: root.surfaceOrientationAngle; when: surface }
46
46
47 InputWatcher {
47 InputWatcher {
48 target: root.surface
48 target: root.surface
qml/Stages/TabletStage.qml+150−19
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014-2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -28,13 +28,79 @@ Rectangle {
28 color: "#111111"
28 color: "#111111"
29
29
30 // Controls to be set from outside
30 // Controls to be set from outside
31− property bool shown: false
32− property bool moving: false
33 property int dragAreaWidth
31 property int dragAreaWidth
34 property real maximizedAppTopMargin
32 property real maximizedAppTopMargin
35 property bool interactive
33 property bool interactive
34+ property alias beingResized: spreadView.beingResized
35+
36+ property bool spreadEnabled: true // If false, animations and right edge will be disabled
37+
36 property real inverseProgress: 0 // This is the progress for left edge drags, in pixels.
38 property real inverseProgress: 0 // This is the progress for left edge drags, in pixels.
37− property int orientation: Qt.PortraitOrientation
39+ property int shellOrientationAngle: 0
40+ property int shellOrientation
41+ property int shellPrimaryOrientation
42+ property int nativeOrientation
43+ property real nativeWidth
44+ property real nativeHeight
45+ function updateFocusedAppOrientation() {
46+ var mainStageAppIndex = priv.indexOf(priv.mainStageAppId);
47+ if (mainStageAppIndex >= 0 && mainStageAppIndex < spreadRepeater.count) {
48+ spreadRepeater.itemAt(mainStageAppIndex).matchShellOrientation();
49+ }
50+
51+ for (var i = 0; i < spreadRepeater.count; ++i) {
52+
53+ if (i === mainStageAppIndex) {
54+ continue;
55+ }
56+
57+ var spreadDelegate = spreadRepeater.itemAt(i);
58+
59+ var delta = spreadDelegate.appWindowOrientationAngle - root.shellOrientationAngle;
60+ if (delta < 0) { delta += 360; }
61+ delta = delta % 360;
62+
63+ var supportedOrientations = spreadDelegate.application.supportedOrientations;
64+ if (supportedOrientations === Qt.PrimaryOrientation) {
65+ supportedOrientations = spreadDelegate.shellPrimaryOrientation;
66+ }
67+
68+ if (delta === 180 && (supportedOrientations & spreadDelegate.shellOrientation)) {
69+ spreadDelegate.matchShellOrientation();
70+ }
71+ }
72+ }
73+ function updateFocusedAppOrientationAnimated() {
74+ var mainStageAppIndex = priv.indexOf(priv.mainStageAppId);
75+ if (mainStageAppIndex >= 0 && mainStageAppIndex < spreadRepeater.count) {
76+ spreadRepeater.itemAt(mainStageAppIndex).animateToShellOrientation();
77+ }
78+
79+ if (priv.sideStageAppId) {
80+ var sideStageAppIndex = priv.indexOf(priv.sideStageAppId);
81+ if (sideStageAppIndex >= 0 && sideStageAppIndex < spreadRepeater.count) {
82+ spreadRepeater.itemAt(sideStageAppIndex).matchShellOrientation();
83+ }
84+ }
85+ }
86+
87+ // To be read from outside
88+ property var mainApp: null
89+ property int mainAppWindowOrientationAngle: 0
90+ readonly property bool orientationChangesEnabled: priv.mainAppOrientationChangesEnabled
91+
92+ onWidthChanged: {
93+ spreadView.selectedIndex = -1;
94+ spreadView.phase = 0;
95+ spreadView.contentX = -spreadView.shift;
96+ }
97+
98+ onShellOrientationChanged: {
99+ if (shellOrientation == Qt.PortraitOrientation || shellOrientation == Qt.InvertedPortraitOrientation) {
100+ ApplicationManager.focusApplication(priv.mainStageAppId);
101+ priv.sideStageAppId = "";
102+ }
103+ }
38
104
39 onInverseProgressChanged: {
105 onInverseProgressChanged: {
40 // This can't be a simple binding because that would be triggered after this handler
106 // This can't be a simple binding because that would be triggered after this handler
@@ -54,6 +120,13 @@ Rectangle {
54
120
55 property string focusedAppId: ApplicationManager.focusedApplicationId
121 property string focusedAppId: ApplicationManager.focusedApplicationId
56 property string oldFocusedAppId: ""
122 property string oldFocusedAppId: ""
123+ property bool mainAppOrientationChangesEnabled: false
124+
125+ property real landscapeHeight: root.nativeOrientation == Qt.LandscapeOrientation ?
126+ root.nativeHeight : root.nativeWidth
127+
128+ property bool shellIsLandscape: root.shellOrientation === Qt.LandscapeOrientation
129+ || root.shellOrientation === Qt.InvertedLandscapeOrientation
57
130
58 property string mainStageAppId
131 property string mainStageAppId
59 property string sideStageAppId
132 property string sideStageAppId
@@ -71,6 +144,7 @@ Rectangle {
71 priv.sideStageAppId = focusedAppId;
144 priv.sideStageAppId = focusedAppId;
72 } else {
145 } else {
73 priv.mainStageAppId = focusedAppId;
146 priv.mainStageAppId = focusedAppId;
147+ root.mainApp = focusedApp;
74 }
148 }
75 }
149 }
76
150
@@ -169,6 +243,7 @@ Rectangle {
169
243
170 Flickable {
244 Flickable {
171 id: spreadView
245 id: spreadView
246+ objectName: "spreadView"
172 anchors.fill: parent
247 anchors.fill: parent
173 interactive: (spreadDragArea.dragging || phase > 1) && draggedDelegateCount === 0
248 interactive: (spreadDragArea.dragging || phase > 1) && draggedDelegateCount === 0
174 contentWidth: spreadRow.width - shift
249 contentWidth: spreadRow.width - shift
@@ -217,7 +292,25 @@ Rectangle {
217 property int draggedDelegateCount: 0
292 property int draggedDelegateCount: 0
218 property int closingIndex: -1
293 property int closingIndex: -1
219
294
295+ // FIXME: Workaround Flickable's not keepping its contentX still when resized
296+ onContentXChanged: { forceItToRemainStillIfBeingResized(); }
297+ onShiftChanged: { forceItToRemainStillIfBeingResized(); }
298+ function forceItToRemainStillIfBeingResized() {
299+ if (root.beingResized && contentX != -shift) {
300+ contentX = -shift;
301+ }
302+ }
303+
220 property bool animateX: true
304 property bool animateX: true
305+ property bool beingResized: false
306+ onBeingResizedChanged: {
307+ if (beingResized) {
308+ // Brace yourselves for impact!
309+ selectedIndex = -1;
310+ phase = 0;
311+ contentX = -shift;
312+ }
313+ }
221
314
222 property bool sideStageDragging: sideStageDragHandle.dragging
315 property bool sideStageDragging: sideStageDragHandle.dragging
223 property real sideStageDragProgress: sideStageDragHandle.progress
316 property real sideStageDragProgress: sideStageDragHandle.progress
@@ -256,7 +349,6 @@ Rectangle {
256 case "overlay":
349 case "overlay":
257 return 1;
350 return 1;
258 }
351 }
259− print("Unhandled nextInStack case! This shouldn't happen any more when the Dash is an app!");
260 return -1;
352 return -1;
261 }
353 }
262 property int nextZInStack: indexToZIndex(nextInStack)
354 property int nextZInStack: indexToZIndex(nextInStack)
@@ -292,6 +384,10 @@ Rectangle {
292 }
384 }
293
385
294 onShiftedContentXChanged: {
386 onShiftedContentXChanged: {
387+ if (root.beingResized) {
388+ // Flickabe.contentX wiggles during resizes. Don't react to it.
389+ return;
390+ }
295 if (spreadView.phase == 0 && spreadView.shiftedContentX > spreadView.width * spreadView.positionMarker2) {
391 if (spreadView.phase == 0 && spreadView.shiftedContentX > spreadView.width * spreadView.positionMarker2) {
296 spreadView.phase = 1;
392 spreadView.phase = 1;
297 } else if (spreadView.phase == 1 && spreadView.shiftedContentX > spreadView.width * spreadView.positionMarker4) {
393 } else if (spreadView.phase == 1 && spreadView.shiftedContentX > spreadView.width * spreadView.positionMarker4) {
@@ -401,8 +497,8 @@ Rectangle {
401 MouseArea {
497 MouseArea {
402 id: spreadRow
498 id: spreadRow
403 x: spreadView.contentX
499 x: spreadView.contentX
404− height: root.height
405 width: spreadView.width + Math.max(spreadView.width, ApplicationManager.count * spreadView.tileDistance)
500 width: spreadView.width + Math.max(spreadView.width, ApplicationManager.count * spreadView.tileDistance)
501+ height: root.height
406
502
407 onClicked: {
503 onClicked: {
408 spreadView.snapTo(0);
504 spreadView.snapTo(0);
@@ -411,8 +507,9 @@ Rectangle {
411 Rectangle {
507 Rectangle {
412 id: sideStageBackground
508 id: sideStageBackground
413 color: "black"
509 color: "black"
414− anchors.fill: parent
415− anchors.leftMargin: spreadView.width - (1 - sideStageDragHandle.progress) * spreadView.sideStageWidth
510+ width: spreadView.sideStageWidth * (1 - sideStageDragHandle.progress)
511+ height: priv.landscapeHeight
512+ x: spreadView.width - width
416 z: spreadView.indexToZIndex(priv.indexOf(priv.sideStageAppId))
513 z: spreadView.indexToZIndex(priv.indexOf(priv.sideStageAppId))
417 opacity: spreadView.phase == 0 ? 1 : 0
514 opacity: spreadView.phase == 0 ? 1 : 0
418 Behavior on opacity { UbuntuNumberAnimation {} }
515 Behavior on opacity { UbuntuNumberAnimation {} }
@@ -420,8 +517,10 @@ Rectangle {
420
517
421 Item {
518 Item {
422 id: sideStageDragHandle
519 id: sideStageDragHandle
423− anchors { top: parent.top; bottom: parent.bottom; left: parent.left; leftMargin: spreadView.width - spreadView.sideStageWidth - width }
520+ anchors.right: sideStageBackground.left
521+ anchors.top: sideStageBackground.top
424 width: units.gu(2)
522 width: units.gu(2)
523+ height: priv.landscapeHeight
425 z: sideStageBackground.z
524 z: sideStageBackground.z
426 opacity: spreadView.phase <= 0 && spreadView.sideStageVisible ? 1 : 0
525 opacity: spreadView.phase <= 0 && spreadView.sideStageVisible ? 1 : 0
427 property real progress: 0
526 property real progress: 0
@@ -440,7 +539,6 @@ Rectangle {
440
539
441 Image {
540 Image {
442 anchors.centerIn: parent
541 anchors.centerIn: parent
443− anchors.horizontalCenterOffset: parent.progress * spreadView.sideStageWidth - (width - parent.width) / 2
444 width: sideStageDragHandleMouseArea.pressed ? parent.width * 2 : parent.width
542 width: sideStageDragHandleMouseArea.pressed ? parent.width * 2 : parent.width
445 height: parent.height
543 height: parent.height
446 source: "graphics/sidestage_handle@20.png"
544 source: "graphics/sidestage_handle@20.png"
@@ -453,16 +551,19 @@ Rectangle {
453 enabled: spreadView.shiftedContentX == 0
551 enabled: spreadView.shiftedContentX == 0
454 property int startX
552 property int startX
455 property var gesturePoints: new Array()
553 property var gesturePoints: new Array()
554+ property real totalDiff
456
555
457 onPressed: {
556 onPressed: {
458 gesturePoints = [];
557 gesturePoints = [];
459 startX = mouseX;
558 startX = mouseX;
559+ totalDiff = 0.0;
460 sideStageDragHandle.progress = 0;
560 sideStageDragHandle.progress = 0;
461 sideStageDragHandle.dragging = true;
561 sideStageDragHandle.dragging = true;
462 }
562 }
463 onMouseXChanged: {
563 onMouseXChanged: {
564+ totalDiff += mouseX - startX;
464 if (priv.mainStageAppId) {
565 if (priv.mainStageAppId) {
465− sideStageDragHandle.progress = Math.max(0, (-startX + mouseX) / spreadView.sideStageWidth);
566+ sideStageDragHandle.progress = Math.max(0, totalDiff / spreadView.sideStageWidth);
466 }
567 }
467 gesturePoints.push(mouseX);
568 gesturePoints.push(mouseX);
468 }
569 }
@@ -491,12 +592,26 @@ Rectangle {
491
592
492 Repeater {
593 Repeater {
493 id: spreadRepeater
594 id: spreadRepeater
595+ objectName: "spreadRepeater"
494 model: ApplicationManager
596 model: ApplicationManager
495
597
496 delegate: TransformedTabletSpreadDelegate {
598 delegate: TransformedTabletSpreadDelegate {
497 id: spreadTile
599 id: spreadTile
498− height: spreadView.height
600+ objectName: "spreadDelegate_" + model.appId
601+ width: {
602+ if (wantsMainStage) {
603+ return spreadView.width;
604+ } else {
499− width: model.stage == ApplicationInfoInterface.MainStage ? spreadView.width : spreadView.sideStageWidth
605+ return spreadView.sideStageWidth;
606+ }
607+ }
608+ height: {
609+ if (wantsMainStage) {
610+ return spreadView.height;
611+ } else {
612+ return priv.landscapeHeight;
613+ }
614+ }
500 active: model.appId == priv.mainStageAppId || model.appId == priv.sideStageAppId
615 active: model.appId == priv.mainStageAppId || model.appId == priv.sideStageAppId
501 zIndex: spreadView.indexToZIndex(index)
616 zIndex: spreadView.indexToZIndex(index)
502 selected: spreadView.selectedIndex == index
617 selected: spreadView.selectedIndex == index
@@ -509,6 +624,8 @@ Rectangle {
509 application: ApplicationManager.get(index)
624 application: ApplicationManager.get(index)
510 closeable: !isDash
625 closeable: !isDash
511
626
627+ readonly property bool wantsMainStage: model.stage == ApplicationInfoInterface.MainStage
628+
512 readonly property bool isDash: model.appId == "unity8-dash"
629 readonly property bool isDash: model.appId == "unity8-dash"
513
630
514 // FIXME: A regular binding doesn't update any more after closing an app.
631 // FIXME: A regular binding doesn't update any more after closing an app.
@@ -560,12 +677,11 @@ Rectangle {
560 return progress;
677 return progress;
561 }
678 }
562
679
563− Binding {
680+ shellOrientationAngle: wantsMainStage ? root.shellOrientationAngle : 0
564− target: spreadTile
681+ shellOrientation: wantsMainStage ? root.shellOrientation : Qt.PortraitOrientation
565− property: "orientation"
682+ shellPrimaryOrientation: wantsMainStage ? root.shellPrimaryOrientation : Qt.PortraitOrientation
566− when: spreadTile.interactive
683+ nativeOrientation: wantsMainStage ? root.nativeOrientation : Qt.PortraitOrientation
567− value: root.orientation
684+
568− }
569
685
570 onClicked: {
686 onClicked: {
571 if (spreadView.phase == 2) {
687 if (spreadView.phase == 2) {
@@ -586,6 +702,19 @@ Rectangle {
586 ApplicationManager.stopApplication(ApplicationManager.get(index).appId);
702 ApplicationManager.stopApplication(ApplicationManager.get(index).appId);
587 }
703 }
588
704
705+ Binding {
706+ target: root
707+ when: model.appId == priv.mainStageAppId
708+ property: "mainAppWindowOrientationAngle"
709+ value: appWindowOrientationAngle
710+ }
711+ Binding {
712+ target: priv
713+ when: model.appId == priv.mainStageAppId
714+ property: "mainAppOrientationChangesEnabled"
715+ value: orientationChangesEnabled
716+ }
717+
589 EasingCurve {
718 EasingCurve {
590 id: snappingCurve
719 id: snappingCurve
591 type: EasingCurve.Linear
720 type: EasingCurve.Linear
@@ -599,9 +728,11 @@ Rectangle {
599
728
600 DirectionalDragArea {
729 DirectionalDragArea {
601 id: spreadDragArea
730 id: spreadDragArea
731+ objectName: "spreadDragArea"
602 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
732 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
603 width: root.dragAreaWidth
733 width: root.dragAreaWidth
604 direction: Direction.Leftwards
734 direction: Direction.Leftwards
735+ enabled: (spreadView.phase != 2 && root.spreadEnabled) || dragging
605
736
606 property var gesturePoints: new Array()
737 property var gesturePoints: new Array()
607
738
qml/Stages/TransformedSpreadDelegate.qml+50−6
@@ -298,7 +298,6 @@ SpreadDelegate {
298
298
299 return easingCurve.value;
299 return easingCurve.value;
300 }
300 }
301−
302 }
301 }
303
302
304 transform: [
303 transform: [
@@ -307,16 +306,61 @@ SpreadDelegate {
307 axis { x: 0; y: 1; z: 0 }
306 axis { x: 0; y: 1; z: 0 }
308 angle: priv.angle
307 angle: priv.angle
309 },
308 },
309+
310+ // The next two transformations are to ensure that fullscreen and rotated
311+ // windows all have the same size and position as an unrotated (0 degrees)
312+ // non-fullscreen window when they're stacked on top of each other on the
313+ // far left of the spread.
314+ Translate {
315+ y: !fullscreen && appWindowRotation === 180
316+ ? priv.topMarginProgress * maximizedAppTopMargin
317+ : 0
318+ },
319+ Scale {
320+ origin {
321+ x: appWindowRotation === 270 ? spreadView.width : 0
322+ y: spreadView.height
323+ }
324+
325+ xScale: {
326+ switch (appWindowRotation) {
327+ case 90:
328+ case 270:
329+ if (fullscreen) {
330+ return 1;
331+ } else {
332+ return 1 + priv.topMarginProgress * maximizedAppTopMargin / spreadView.width;
333+ }
334+ break;
335+ default:
336+ return 1;
337+ }
338+ }
339+
340+ yScale: {
341+ switch (appWindowRotation) {
342+ case 0:
343+ if (fullscreen) {
344+ return 1 - priv.topMarginProgress * maximizedAppTopMargin / spreadView.height;
345+ } else {
346+ return 1;
347+ }
348+ break;
349+ case 90:
350+ case 270:
351+ return 1 - priv.topMarginProgress * maximizedAppTopMargin / spreadView.height;
352+ break;
353+ default:
354+ return 1;
355+ }
356+ }
357+ },
358+
310 Scale {
359 Scale {
311 origin { x: 0; y: spreadView.height / 2 }
360 origin { x: 0; y: spreadView.height / 2 }
312 xScale: priv.scale
361 xScale: priv.scale
313 yScale: xScale
362 yScale: xScale
314 },
363 },
315− Scale {
316− origin { x: 0; y: (spreadView.height * priv.scale) + maximizedAppTopMargin * 3 }
317− xScale: 1
318− yScale: fullscreen ? 1 - priv.topMarginProgress * maximizedAppTopMargin / spreadView.height : 1
319− },
320 Translate {
364 Translate {
321 x: priv.xTranslate
365 x: priv.xTranslate
322 }
366 }
qml/Stages/TransformedTabletSpreadDelegate.qml+5−2
@@ -50,7 +50,9 @@ SpreadDelegate {
50 property int dragOffset: 0
50 property int dragOffset: 0
51
51
52 dropShadow: spreadView.active ||
52 dropShadow: spreadView.active ||
53+ (active
53− (active && model.stage == ApplicationInfoInterface.MainStage && priv.xTranslate != 0)
54+ && (model.stage == ApplicationInfoInterface.MainStage || !priv.shellIsLandscape)
55+ && priv.xTranslate != 0)
54
56
55 onSelectedChanged: {
57 onSelectedChanged: {
56 if (selected) {
58 if (selected) {
@@ -139,7 +141,8 @@ SpreadDelegate {
139 !snapAnimation.running &&
141 !snapAnimation.running &&
140 model.appId !== "unity8-dash" &&
142 model.appId !== "unity8-dash" &&
141 !spreadView.sideStageDragging &&
143 !spreadView.sideStageDragging &&
142− spreadView.animateX
144+ spreadView.animateX &&
145+ !spreadView.beingResized
143 UbuntuNumberAnimation {
146 UbuntuNumberAnimation {
144 duration: UbuntuAnimation.FastDuration
147 duration: UbuntuAnimation.FastDuration
145 }
148 }
run.sh+1−1
@@ -44,7 +44,7 @@ else
44 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/builddir/plugins/LightDM/liblightdm
44 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/builddir/plugins/LightDM/liblightdm
45fi
45fi
46
46
47−QML_PHONE_SHELL_ARGS=""
47+QML_PHONE_SHELL_ARGS="-windowgeometry=40gux68gu -devicename=mako"
48if $MOUSE_TOUCH; then
48if $MOUSE_TOUCH; then
49 QML_PHONE_SHELL_ARGS="$QML_PHONE_SHELL_ARGS -mousetouch"
49 QML_PHONE_SHELL_ARGS="$QML_PHONE_SHELL_ARGS -mousetouch"
50fi
50fi
src/ApplicationArguments.cppnew file+22
@@ -0,0 +1,22 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+#include "ApplicationArguments.h"
18+
19+ApplicationArguments::ApplicationArguments(QObject *parent)
20+ : QObject(parent)
21+{
22+}
src/ApplicationArguments.h+7−11
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013,2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -13,7 +13,6 @@
13 * You should have received a copy of the GNU General Public License
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/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
15 *
16− * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
17 */
16 */
18
17
19
18
@@ -22,23 +21,20 @@
22
21
23#include <QObject>
22#include <QObject>
24#include <QSize>
23#include <QSize>
25−#include <QStringList>
24+#include <QString>
26
25
27class ApplicationArguments : public QObject
26class ApplicationArguments : public QObject
28{
27{
29 Q_OBJECT
28 Q_OBJECT
29+ Q_PROPERTY(QString deviceName READ deviceName CONSTANT)
30public:
30public:
31− // Not exposed to the app as setSize isn't invokable
31+ ApplicationArguments(QObject *parent = nullptr);
32− void setSize(const QSize &size) {
33− m_size = size;
34− }
35
32
36− Q_INVOKABLE bool hasGeometry() const { return m_size.isValid(); }
33+ void setDeviceName(QString deviceName) { m_deviceName = deviceName; }
37− Q_INVOKABLE int width() const { return m_size.width(); }
34+ QString deviceName() const { return m_deviceName; }
38− Q_INVOKABLE int height() const { return m_size.height(); }
39
35
40private:
36private:
41− QSize m_size;
37+ QString m_deviceName;
42};
38};
43
39
44#endif // APPLICATION_ARGUMENTS_H
40#endif // APPLICATION_ARGUMENTS_H
src/CMakeLists.txt+5−6
@@ -17,7 +17,7 @@ file(GLOB_RECURSE QML_FILES
17)
17)
18
18
19add_executable(${SHELL_APP}
19add_executable(${SHELL_APP}
20− ApplicationArguments.h
20+ ApplicationArguments.cpp
21 main.cpp
21 main.cpp
22 MouseTouchAdaptor.cpp
22 MouseTouchAdaptor.cpp
23 CachingNetworkManagerFactory.cpp
23 CachingNetworkManagerFactory.cpp
@@ -26,13 +26,12 @@ add_executable(${SHELL_APP}
26)
26)
27
27
28qt5_use_modules(${SHELL_APP} Gui Qml Quick Test)
28qt5_use_modules(${SHELL_APP} Gui Qml Quick Test)
29−pkg_check_modules(XCB REQUIRED xcb)
30
29
31−if (NOT "${XCB_INCLUDE_DIRS}" STREQUAL "")
30+pkg_check_modules(NEEDED_LIBS REQUIRED xcb libandroid-properties)
31+if (NOT "${NEEDED_LIBS_INCLUDE_DIRS}" STREQUAL "")
32− set_target_properties(${SHELL_APP} PROPERTIES INCLUDE_DIRECTORIES ${XCB_INCLUDE_DIRS})
32+ set_target_properties(${SHELL_APP} PROPERTIES INCLUDE_DIRECTORIES ${NEEDED_LIBS_INCLUDE_DIRS})
33−
34− target_link_libraries(${SHELL_APP} ${XCB_LDFLAGS})
35endif()
33endif()
34+target_link_libraries(${SHELL_APP} ${NEEDED_LIBS_LDFLAGS})
36
35
37target_link_libraries(${SHELL_APP} UbuntuGestures connectivity-qt1)
36target_link_libraries(${SHELL_APP} UbuntuGestures connectivity-qt1)
38
37
src/Dash/CMakeLists.txt+7−1
@@ -1,6 +1,6 @@
1set(DASH_SRCS
1set(DASH_SRCS
2 main.cpp
2 main.cpp
3− ../ApplicationArguments.h
3+ ../ApplicationArguments.cpp
4 ../MouseTouchAdaptor.cpp
4 ../MouseTouchAdaptor.cpp
5 ../CachingNetworkManagerFactory.cpp
5 ../CachingNetworkManagerFactory.cpp
6)
6)
@@ -9,6 +9,12 @@ add_executable(unity8-dash ${DASH_SRCS})
9
9
10qt5_use_modules(unity8-dash Gui Qml Quick Test)
10qt5_use_modules(unity8-dash Gui Qml Quick Test)
11
11
12+pkg_check_modules(NEEDED_LIBS REQUIRED xcb libandroid-properties)
13+if (NOT "${NEEDED_LIBS_INCLUDE_DIRS}" STREQUAL "")
14+ set_target_properties(unity8-dash PROPERTIES INCLUDE_DIRECTORIES ${NEEDED_LIBS_INCLUDE_DIRS})
15+endif()
16+target_link_libraries(unity8-dash ${NEEDED_LIBS_LDFLAGS})
17+
12# For it to find libUbuntuGestures.so, needed by Ubuntu.Gestures QML module.
18# For it to find libUbuntuGestures.so, needed by Ubuntu.Gestures QML module.
13set_target_properties(unity8-dash PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${SHELL_PRIVATE_LIBDIR}")
19set_target_properties(unity8-dash PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${SHELL_PRIVATE_LIBDIR}")
14
20
src/Dash/main.cpp+12−6
@@ -61,12 +61,6 @@ int main(int argc, const char *argv[])
61 parser.process(*application);
61 parser.process(*application);
62
62
63 ApplicationArguments qmlArgs;
63 ApplicationArguments qmlArgs;
64− if (parser.isSet(windowGeometryOption) &&
65− parser.value(windowGeometryOption).split('x').size() == 2)
66− {
67− QStringList geom = parser.value(windowGeometryOption).split('x');
68− qmlArgs.setSize(QSize(geom.at(0).toInt(), geom.at(1).toInt()));
69− }
70
64
71 if (getenv("QT_LOAD_TESTABILITY")) {
65 if (getenv("QT_LOAD_TESTABILITY")) {
72 QLibrary testLib(QLatin1String("qttestability"));
66 QLibrary testLib(QLatin1String("qttestability"));
@@ -88,6 +82,18 @@ int main(int argc, const char *argv[])
88
82
89 QQuickView* view = new QQuickView();
83 QQuickView* view = new QQuickView();
90 view->setResizeMode(QQuickView::SizeRootObjectToView);
84 view->setResizeMode(QQuickView::SizeRootObjectToView);
85+
86+ if (parser.isSet(windowGeometryOption) &&
87+ parser.value(windowGeometryOption).split('x').size() == 2)
88+ {
89+ QStringList geom = parser.value(windowGeometryOption).split('x');
90+ QSize windowSize(geom.at(0).toInt(), geom.at(1).toInt());
91+ if (windowSize.isValid()) {
92+ view->setWidth(windowSize.width());
93+ view->setHeight(windowSize.height());
94+ }
95+ }
96+
91 view->setTitle("Scopes");
97 view->setTitle("Scopes");
92 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
98 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
93
99
src/UnityCommandLineParser.cpp+5
@@ -49,6 +49,10 @@ UnityCommandLineParser::UnityCommandLineParser(const QCoreApplication &app)
49 "DISCOURAGED: Please set QT_LOAD_TESTABILITY instead.\nLoad the testability driver");
49 "DISCOURAGED: Please set QT_LOAD_TESTABILITY instead.\nLoad the testability driver");
50 parser.addOption(testabilityOption);
50 parser.addOption(testabilityOption);
51
51
52+ QCommandLineOption devicenameOption(QStringList() << "devicename",
53+ "Specify the device name instead of letting Unity 8 find it out", "devicename", "");
54+ parser.addOption(devicenameOption);
55+
52 QCommandLineOption modeOption("mode",
56 QCommandLineOption modeOption("mode",
53 "Whether to run greeter and/or shell [full-greeter, full-shell, greeter, shell]",
57 "Whether to run greeter and/or shell [full-greeter, full-shell, greeter, shell]",
54 "mode", "full-greeter");
58 "mode", "full-greeter");
@@ -73,6 +77,7 @@ UnityCommandLineParser::UnityCommandLineParser(const QCoreApplication &app)
73 m_hasFrameless = parser.isSet(framelessOption);
77 m_hasFrameless = parser.isSet(framelessOption);
74 m_hasMouseToTouch = parser.isSet(mousetouchOption);
78 m_hasMouseToTouch = parser.isSet(mousetouchOption);
75 m_hasFullscreen = parser.isSet(fullscreenOption);
79 m_hasFullscreen = parser.isSet(fullscreenOption);
80+ m_deviceName = parser.value(devicenameOption);
76 resolveMode(parser, modeOption);
81 resolveMode(parser, modeOption);
77}
82}
78
83
src/UnityCommandLineParser.h+2
@@ -30,6 +30,7 @@ public:
30 bool hasFrameless() const { return m_hasFrameless; }
30 bool hasFrameless() const { return m_hasFrameless; }
31 bool hasMouseToTouch() const { return m_hasMouseToTouch; }
31 bool hasMouseToTouch() const { return m_hasMouseToTouch; }
32 bool hasFullscreen() const { return m_hasFullscreen; }
32 bool hasFullscreen() const { return m_hasFullscreen; }
33+ QString deviceName() const { return m_deviceName; }
33 QString mode() const { return m_mode; }
34 QString mode() const { return m_mode; }
34private:
35private:
35
36
@@ -44,6 +45,7 @@ private:
44 bool m_hasFrameless;
45 bool m_hasFrameless;
45 bool m_hasMouseToTouch;
46 bool m_hasMouseToTouch;
46 bool m_hasFullscreen;
47 bool m_hasFullscreen;
48+ QString m_deviceName;
47 QString m_mode;
49 QString m_mode;
48};
50};
49
51
src/main.cpp+18−8
@@ -25,6 +25,9 @@
25#include <csignal>
25#include <csignal>
26#include <libintl.h>
26#include <libintl.h>
27
27
28+// libandroid-properties
29+#include <hybris/properties/properties.h>
30+
28// local
31// local
29#include <paths.h>
32#include <paths.h>
30#include "MouseTouchAdaptor.h"
33#include "MouseTouchAdaptor.h"
@@ -50,13 +53,15 @@ int main(int argc, const char *argv[])
50
53
51 UnityCommandLineParser parser(*application);
54 UnityCommandLineParser parser(*application);
52
55
53− QString indicatorProfile = qgetenv("UNITY_INDICATOR_PROFILE");
54− if (indicatorProfile.isEmpty()) {
55− indicatorProfile = "phone";
56− }
57−
58 ApplicationArguments qmlArgs;
56 ApplicationArguments qmlArgs;
59− qmlArgs.setSize(parser.windowGeometry());
57+
58+ if (!parser.deviceName().isEmpty()) {
59+ qmlArgs.setDeviceName(parser.deviceName());
60+ } else {
61+ char buffer[200];
62+ property_get("ro.product.device", buffer /* value */, "desktop" /* default_value*/);
63+ qmlArgs.setDeviceName(QString(buffer));
64+ }
60
65
61 // The testability driver is only loaded by QApplication but not by QGuiApplication.
66 // The testability driver is only loaded by QApplication but not by QGuiApplication.
62 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
67 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
@@ -82,9 +87,14 @@ int main(int argc, const char *argv[])
82 view->setResizeMode(QQuickView::SizeRootObjectToView);
87 view->setResizeMode(QQuickView::SizeRootObjectToView);
83 view->setColor("black");
88 view->setColor("black");
84 view->setTitle("Unity8 Shell");
89 view->setTitle("Unity8 Shell");
90+
91+ if (parser.windowGeometry().isValid()) {
92+ view->setWidth(parser.windowGeometry().width());
93+ view->setHeight(parser.windowGeometry().height());
94+ }
95+
85 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
96 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
86 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
97 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
87− view->rootContext()->setContextProperty("indicatorProfile", indicatorProfile);
88 view->rootContext()->setContextProperty("shellMode", parser.mode());
98 view->rootContext()->setContextProperty("shellMode", parser.mode());
89 if (parser.hasFrameless()) {
99 if (parser.hasFrameless()) {
90 view->setFlags(Qt::FramelessWindowHint);
100 view->setFlags(Qt::FramelessWindowHint);
@@ -99,7 +109,7 @@ int main(int argc, const char *argv[])
99 mouseTouchAdaptor = MouseTouchAdaptor::instance();
109 mouseTouchAdaptor = MouseTouchAdaptor::instance();
100 }
110 }
101
111
102− QUrl source(::qmlDirectory()+"Shell.qml");
112+ QUrl source(::qmlDirectory()+"OrientedShell.qml");
103 prependImportPaths(view->engine(), ::overrideImportPaths());
113 prependImportPaths(view->engine(), ::overrideImportPaths());
104 if (!isMirServer) {
114 if (!isMirServer) {
105 prependImportPaths(view->engine(), ::nonMirImportPaths());
115 prependImportPaths(view->engine(), ::nonMirImportPaths());
tests/mocks/Unity/Application/ApplicationInfo.cpp+43−2
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013-2014 Canonical, Ltd.
2+ * Copyright (C) 2013-2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -34,6 +34,11 @@ ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
34 , m_focused(false)
34 , m_focused(false)
35 , m_fullscreen(false)
35 , m_fullscreen(false)
36 , m_session(0)
36 , m_session(0)
37+ , m_supportedOrientations(Qt::PortraitOrientation |
38+ Qt::LandscapeOrientation |
39+ Qt::InvertedPortraitOrientation |
40+ Qt::InvertedLandscapeOrientation)
41+ , m_rotatesWindowContents(false)
37 , m_manualSurfaceCreation(false)
42 , m_manualSurfaceCreation(false)
38{
43{
39}
44}
@@ -45,6 +50,11 @@ ApplicationInfo::ApplicationInfo(QObject *parent)
45 , m_focused(false)
50 , m_focused(false)
46 , m_fullscreen(false)
51 , m_fullscreen(false)
47 , m_session(0)
52 , m_session(0)
53+ , m_supportedOrientations(Qt::PortraitOrientation |
54+ Qt::LandscapeOrientation |
55+ Qt::InvertedPortraitOrientation |
56+ Qt::InvertedLandscapeOrientation)
57+ , m_rotatesWindowContents(false)
48 , m_manualSurfaceCreation(false)
58 , m_manualSurfaceCreation(false)
49{
59{
50}
60}
@@ -99,9 +109,17 @@ void ApplicationInfo::setIconId(const QString &iconId)
99
109
100void ApplicationInfo::setScreenshotId(const QString &screenshotId)
110void ApplicationInfo::setScreenshotId(const QString &screenshotId)
101{
111{
112+ QString screenshotFileName;
113+
114+ if (screenshotId.endsWith(".svg")) {
115+ screenshotFileName = QString("%1/Dash/graphics/phone/screenshots/%2")
116+ .arg(qmlDirectory())
117+ .arg(screenshotId);
118+ } else {
102− QString screenshotFileName = QString("%1/Dash/graphics/phone/screenshots/%2@12.png")
119+ screenshotFileName = QString("%1/Dash/graphics/phone/screenshots/%2@12.png")
103 .arg(qmlDirectory())
120 .arg(qmlDirectory())
104 .arg(screenshotId);
121 .arg(screenshotId);
122+ }
105
123
106 if (screenshotFileName != m_screenshotFileName) {
124 if (screenshotFileName != m_screenshotFileName) {
107 m_screenshotFileName = screenshotFileName;
125 m_screenshotFileName = screenshotFileName;
@@ -145,6 +163,9 @@ void ApplicationInfo::setState(State value)
145
163
146 if (!m_manualSurfaceCreation && m_state == ApplicationInfo::Running) {
164 if (!m_manualSurfaceCreation && m_state == ApplicationInfo::Running) {
147 QTimer::singleShot(500, this, SLOT(createSession()));
165 QTimer::singleShot(500, this, SLOT(createSession()));
166+ } else if (m_state == ApplicationInfo::Stopped) {
167+ delete m_session;
168+ m_session = nullptr;
148 }
169 }
149 }
170 }
150}
171}
@@ -172,3 +193,23 @@ void ApplicationInfo::setManualSurfaceCreation(bool value)
172 Q_EMIT manualSurfaceCreationChanged(value);
193 Q_EMIT manualSurfaceCreationChanged(value);
173 }
194 }
174}
195}
196+
197+Qt::ScreenOrientations ApplicationInfo::supportedOrientations() const
198+{
199+ return m_supportedOrientations;
200+}
201+
202+void ApplicationInfo::setSupportedOrientations(Qt::ScreenOrientations orientations)
203+{
204+ m_supportedOrientations = orientations;
205+}
206+
207+bool ApplicationInfo::rotatesWindowContents() const
208+{
209+ return m_rotatesWindowContents;
210+}
211+
212+void ApplicationInfo::setRotatesWindowContents(bool value)
213+{
214+ m_rotatesWindowContents = value;
215+}
tests/mocks/Unity/Application/ApplicationInfo.h+9−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013-2014 Canonical, Ltd.
2+ * Copyright (C) 2013-2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -80,6 +80,12 @@ public:
80 void setFullscreen(bool value);
80 void setFullscreen(bool value);
81 bool fullscreen() const { return m_fullscreen; }
81 bool fullscreen() const { return m_fullscreen; }
82
82
83+ Qt::ScreenOrientations supportedOrientations() const override;
84+ void setSupportedOrientations(Qt::ScreenOrientations orientations);
85+
86+ bool rotatesWindowContents() const override;
87+ void setRotatesWindowContents(bool value);
88+
83 bool manualSurfaceCreation() const { return m_manualSurfaceCreation; }
89 bool manualSurfaceCreation() const { return m_manualSurfaceCreation; }
84 void setManualSurfaceCreation(bool value);
90 void setManualSurfaceCreation(bool value);
85
91
@@ -108,6 +114,8 @@ private:
108 bool m_focused;
114 bool m_focused;
109 bool m_fullscreen;
115 bool m_fullscreen;
110 Session* m_session;
116 Session* m_session;
117+ Qt::ScreenOrientations m_supportedOrientations;
118+ bool m_rotatesWindowContents;
111
119
112 bool m_manualSurfaceCreation;
120 bool m_manualSurfaceCreation;
113};
121};
tests/mocks/Unity/Application/ApplicationManager.cpp+39−2
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013-2014 Canonical, Ltd.
2+ * Copyright (C) 2013-2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -348,6 +348,13 @@ void ApplicationManager::unfocusCurrentApplication()
348
348
349void ApplicationManager::buildListOfAvailableApplications()
349void ApplicationManager::buildListOfAvailableApplications()
350{
350{
351+ /*
352+ ATTENTION!
353+ Be careful when changing application properties here as some qmltests
354+ rely on them being the way it's specified here (e.g. that camera-app
355+ is fullscreen, that twitter-webapp can rotate in all directions, etc)
356+ */
357+
351 ApplicationInfo *application;
358 ApplicationInfo *application;
352
359
353 application = new ApplicationInfo(this);
360 application = new ApplicationInfo(this);
@@ -355,6 +362,7 @@ void ApplicationManager::buildListOfAvailableApplications()
355 application->setName("Unity 8 Mock Dash");
362 application->setName("Unity 8 Mock Dash");
356 application->setScreenshotId("unity8-dash");
363 application->setScreenshotId("unity8-dash");
357 application->setStage(ApplicationInfo::MainStage);
364 application->setStage(ApplicationInfo::MainStage);
365+ application->setSupportedOrientations(Qt::PrimaryOrientation);
358 m_availableApplications.append(application);
366 m_availableApplications.append(application);
359
367
360 application = new ApplicationInfo(this);
368 application = new ApplicationInfo(this);
@@ -363,6 +371,8 @@ void ApplicationManager::buildListOfAvailableApplications()
363 application->setScreenshotId("dialer");
371 application->setScreenshotId("dialer");
364 application->setIconId("dialer-app");
372 application->setIconId("dialer-app");
365 application->setStage(ApplicationInfo::SideStage);
373 application->setStage(ApplicationInfo::SideStage);
374+ application->setSupportedOrientations(Qt::PortraitOrientation
375+ | Qt::InvertedPortraitOrientation);
366 m_availableApplications.append(application);
376 m_availableApplications.append(application);
367
377
368 application = new ApplicationInfo(this);
378 application = new ApplicationInfo(this);
@@ -371,6 +381,11 @@ void ApplicationManager::buildListOfAvailableApplications()
371 application->setScreenshotId("camera");
381 application->setScreenshotId("camera");
372 application->setIconId("camera");
382 application->setIconId("camera");
373 application->setFullscreen(true);
383 application->setFullscreen(true);
384+ application->setSupportedOrientations(Qt::PortraitOrientation
385+ | Qt::LandscapeOrientation
386+ | Qt::InvertedPortraitOrientation
387+ | Qt::InvertedLandscapeOrientation);
388+ application->setRotatesWindowContents(true);
374 m_availableApplications.append(application);
389 m_availableApplications.append(application);
375
390
376 application = new ApplicationInfo(this);
391 application = new ApplicationInfo(this);
@@ -416,13 +431,35 @@ void ApplicationManager::buildListOfAvailableApplications()
416 application->setAppId("gmail-webapp");
431 application->setAppId("gmail-webapp");
417 application->setName("GMail");
432 application->setName("GMail");
418 application->setIconId("gmail");
433 application->setIconId("gmail");
434+ application->setScreenshotId("gmail-webapp.svg");
435+ application->setFullscreen(false);
436+ application->setStage(ApplicationInfo::MainStage);
437+ application->setSupportedOrientations(Qt::PortraitOrientation
438+ | Qt::LandscapeOrientation
439+ | Qt::InvertedPortraitOrientation
440+ | Qt::InvertedLandscapeOrientation);
441+ m_availableApplications.append(application);
442+
443+ application = new ApplicationInfo(this);
444+ application->setAppId("music-app");
445+ application->setName("Music");
446+ application->setIconId("soundcloud");
447+ application->setScreenshotId("music");
448+ application->setFullscreen(false);
449+ application->setStage(ApplicationInfo::MainStage);
450+ application->setSupportedOrientations(Qt::PortraitOrientation
451+ | Qt::LandscapeOrientation
452+ | Qt::InvertedPortraitOrientation
453+ | Qt::InvertedLandscapeOrientation);
419 m_availableApplications.append(application);
454 m_availableApplications.append(application);
420
455
421 application = new ApplicationInfo(this);
456 application = new ApplicationInfo(this);
422 application->setAppId("ubuntu-weather-app");
457 application->setAppId("ubuntu-weather-app");
423 application->setName("Weather");
458 application->setName("Weather");
424 application->setIconId("weather");
459 application->setIconId("weather");
425− application->setStage(ApplicationInfo::SideStage);
460+ application->setScreenshotId("ubuntu-weather-app.svg");
461+ application->setSupportedOrientations(Qt::LandscapeOrientation
462+ | Qt::InvertedLandscapeOrientation);
426 m_availableApplications.append(application);
463 m_availableApplications.append(application);
427
464
428 application = new ApplicationInfo(this);
465 application = new ApplicationInfo(this);
tests/mocks/Unity/Application/CMakeLists.txt+4−1
@@ -1,4 +1,6 @@
1−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=5)
1+include_directories(
2+ ${APPLICATION_API_INCLUDE_DIRS}
3+)
2
4
3set(FakeUnityApplicationQml_SOURCES
5set(FakeUnityApplicationQml_SOURCES
4 plugin.cpp
6 plugin.cpp
@@ -14,6 +16,7 @@ set(FakeUnityApplicationQml_SOURCES
14 SurfaceManager.cpp
16 SurfaceManager.cpp
15 SessionModel.h
17 SessionModel.h
16 UbuntuKeyboardInfo.cpp
18 UbuntuKeyboardInfo.cpp
19+ VirtualKeyboard.cpp
17 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
20 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
18 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
21 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
19)
22)
tests/mocks/Unity/Application/MirSurfaceItem.cpp+10−27
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014-2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -39,14 +39,12 @@ MirSurfaceItem::MirSurfaceItem(const QString& name,
39 , m_type(type)
39 , m_type(type)
40 , m_state(state)
40 , m_state(state)
41 , m_live(true)
41 , m_live(true)
42− , m_orientation(Qt::PortraitOrientation)
42+ , m_orientationAngle(Angle0)
43− , m_touchPressCount(0)
44− , m_touchReleaseCount(0)
45 , m_qmlItem(nullptr)
43 , m_qmlItem(nullptr)
46 , m_screenshotUrl(screenshot)
44 , m_screenshotUrl(screenshot)
45+ , m_touchPressCount(0)
46+ , m_touchReleaseCount(0)
47{
47{
48− qDebug() << "MirSurfaceItem::MirSurfaceItem() " << this->name();
49−
50 setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton |
48 setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton |
51 Qt::ExtraButton1 | Qt::ExtraButton2 | Qt::ExtraButton3 | Qt::ExtraButton4 |
49 Qt::ExtraButton1 | Qt::ExtraButton2 | Qt::ExtraButton3 | Qt::ExtraButton4 |
52 Qt::ExtraButton5 | Qt::ExtraButton6 | Qt::ExtraButton7 | Qt::ExtraButton8 |
50 Qt::ExtraButton5 | Qt::ExtraButton6 | Qt::ExtraButton7 | Qt::ExtraButton8 |
@@ -55,9 +53,6 @@ MirSurfaceItem::MirSurfaceItem(const QString& name,
55
53
56 QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
54 QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
57
55
58− connect(this, &QQuickItem::focusChanged,
59− this, &MirSurfaceItem::onFocusChanged);
60−
61 // The assumptions I make here really should hold.
56 // The assumptions I make here really should hold.
62 QQuickView *quickView =
57 QQuickView *quickView =
63 qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
58 qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
@@ -117,17 +112,17 @@ void MirSurfaceItem::release()
117 }
112 }
118}
113}
119
114
120−void MirSurfaceItem::setOrientation(const Qt::ScreenOrientation orientation)
115+void MirSurfaceItem::setOrientationAngle(OrientationAngle angle)
121{
116{
122− if (m_orientation == orientation)
117+ if (m_orientationAngle == angle)
123 return;
118 return;
124
119
125− m_orientation = orientation;
120+ m_orientationAngle = angle;
126
121
127− QQmlProperty orientationProp(m_qmlItem, "orientation");
122+ QQmlProperty orientationProp(m_qmlItem, "orientationAngle");
128− orientationProp.write(QVariant::fromValue(orientation));
123+ orientationProp.write(QVariant::fromValue(m_orientationAngle));
129
124
130− Q_EMIT orientationChanged();
125+ Q_EMIT orientationAngleChanged(m_orientationAngle);
131}
126}
132
127
133void MirSurfaceItem::setSession(Session* session)
128void MirSurfaceItem::setSession(Session* session)
@@ -152,15 +147,6 @@ void MirSurfaceItem::setLive(bool live)
152 }
147 }
153}
148}
154
149
155−void MirSurfaceItem::onFocusChanged()
156−{
157− if (!hasFocus()) {
158− // Causes a crash in tst_Shell.qml, inside the mock Unity.Application itself.
159− // Didn't have time to debug yet.
160− //Q_EMIT inputMethodDismissed();
161− }
162−}
163−
164void MirSurfaceItem::setState(MirSurfaceItem::State newState)
150void MirSurfaceItem::setState(MirSurfaceItem::State newState)
165{
151{
166 if (newState != m_state) {
152 if (newState != m_state) {
@@ -197,9 +183,6 @@ void MirSurfaceItem::touchEvent(QTouchEvent * event)
197 if (event->touchPointStates() & Qt::TouchPointPressed) {
183 if (event->touchPointStates() & Qt::TouchPointPressed) {
198 ++m_touchPressCount;
184 ++m_touchPressCount;
199 Q_EMIT touchPressCountChanged(m_touchPressCount);
185 Q_EMIT touchPressCountChanged(m_touchPressCount);
200− // Causes a crash in tst_Shell.qml, inside the mock Unity.Application itself.
201− // Didn't have time to debug yet.
202− // Q_EMIT inputMethodRequested();
203 } else if (event->touchPointStates() & Qt::TouchPointReleased) {
186 } else if (event->touchPointStates() & Qt::TouchPointReleased) {
204 ++m_touchReleaseCount;
187 ++m_touchReleaseCount;
205 Q_EMIT touchReleaseCountChanged(m_touchReleaseCount);
188 Q_EMIT touchReleaseCountChanged(m_touchReleaseCount);
tests/mocks/Unity/Application/MirSurfaceItem.h+29−29
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014-2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -29,17 +29,18 @@ class MirSurfaceItem : public QQuickItem
29 Q_OBJECT
29 Q_OBJECT
30 Q_ENUMS(Type)
30 Q_ENUMS(Type)
31 Q_ENUMS(State)
31 Q_ENUMS(State)
32+ Q_ENUMS(OrientationAngle)
32
33
33 Q_PROPERTY(Type type READ type NOTIFY typeChanged)
34 Q_PROPERTY(Type type READ type NOTIFY typeChanged)
34 Q_PROPERTY(State state READ state NOTIFY stateChanged)
35 Q_PROPERTY(State state READ state NOTIFY stateChanged)
35 Q_PROPERTY(QString name READ name CONSTANT)
36 Q_PROPERTY(QString name READ name CONSTANT)
36 Q_PROPERTY(bool live READ live NOTIFY liveChanged)
37 Q_PROPERTY(bool live READ live NOTIFY liveChanged)
37− Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged DESIGNABLE false)
38+ Q_PROPERTY(OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle
38−
39+ NOTIFY orientationAngleChanged DESIGNABLE false)
39− Q_PROPERTY(int touchPressCount READ touchPressCount WRITE setTouchPressCount NOTIFY touchPressCountChanged
40+ Q_PROPERTY(int touchPressCount READ touchPressCount WRITE setTouchPressCount
40− DESIGNABLE false)
41+ NOTIFY touchPressCountChanged DESIGNABLE false)
41− Q_PROPERTY(int touchReleaseCount READ touchReleaseCount WRITE setTouchReleaseCount NOTIFY touchReleaseCountChanged
42+ Q_PROPERTY(int touchReleaseCount READ touchReleaseCount WRITE setTouchReleaseCount
42− DESIGNABLE false)
43+ NOTIFY touchReleaseCountChanged DESIGNABLE false)
43
44
44public:
45public:
45 enum Type {
46 enum Type {
@@ -62,6 +63,13 @@ public:
62 Fullscreen,
63 Fullscreen,
63 };
64 };
64
65
66+ enum OrientationAngle {
67+ Angle0 = 0,
68+ Angle90 = 90,
69+ Angle180 = 180,
70+ Angle270 = 270
71+ };
72+
65 ~MirSurfaceItem();
73 ~MirSurfaceItem();
66
74
67 //getters
75 //getters
@@ -70,9 +78,9 @@ public:
70 State state() const { return m_state; }
78 State state() const { return m_state; }
71 QString name() const { return m_name; }
79 QString name() const { return m_name; }
72 bool live() const { return m_live; }
80 bool live() const { return m_live; }
73− Qt::ScreenOrientation orientation() const { return m_orientation; }
81+ OrientationAngle orientationAngle() const { return m_orientationAngle; }
74
82
75− void setOrientation(const Qt::ScreenOrientation orientation);
83+ void setOrientationAngle(OrientationAngle angle);
76
84
77 void setSession(Session* item);
85 void setSession(Session* item);
78 void setScreenshot(const QUrl& screenshot);
86 void setScreenshot(const QUrl& screenshot);
@@ -91,29 +99,14 @@ Q_SIGNALS:
91 void typeChanged(Type);
99 void typeChanged(Type);
92 void stateChanged(State);
100 void stateChanged(State);
93 void liveChanged(bool live);
101 void liveChanged(bool live);
94− void orientationChanged();
102+ void orientationAngleChanged(OrientationAngle angle);
95 void touchPressCountChanged(int count);
103 void touchPressCountChanged(int count);
96 void touchReleaseCountChanged(int count);
104 void touchReleaseCountChanged(int count);
97
105
98− void inputMethodRequested();
99− void inputMethodDismissed();
100−
101 // internal mock use
106 // internal mock use
102 void deregister();
107 void deregister();
103
108
104protected:
109protected:
105− void touchEvent(QTouchEvent * event) override;
106−
107− // becaue the default implementation ignores the events
108− void mousePressEvent(QMouseEvent *) override {}
109− void mouseMoveEvent(QMouseEvent *) override {}
110− void mouseReleaseEvent(QMouseEvent *) override {}
111−
112−private Q_SLOTS:
113− void onFocusChanged();
114− void onComponentStatusChanged(QQmlComponent::Status status);
115−
116−private:
117 explicit MirSurfaceItem(const QString& name,
110 explicit MirSurfaceItem(const QString& name,
118 Type type,
111 Type type,
119 State state,
112 State state,
@@ -121,6 +114,12 @@ private:
121 const QString &qmlFilePath = QString(),
114 const QString &qmlFilePath = QString(),
122 QQuickItem *parent = 0);
115 QQuickItem *parent = 0);
123
116
117+ void touchEvent(QTouchEvent * event) override;
118+
119+private Q_SLOTS:
120+ void onComponentStatusChanged(QQmlComponent::Status status);
121+
122+private:
124 void createQmlContentItem();
123 void createQmlContentItem();
125 void printComponentErrors();
124 void printComponentErrors();
126
125
@@ -129,19 +128,20 @@ private:
129 const Type m_type;
128 const Type m_type;
130 State m_state;
129 State m_state;
131 bool m_live;
130 bool m_live;
132− Qt::ScreenOrientation m_orientation;
131+ OrientationAngle m_orientationAngle;
133− int m_touchPressCount;
134− int m_touchReleaseCount;
135
132
136 QQmlComponent *m_qmlContentComponent;
133 QQmlComponent *m_qmlContentComponent;
137 QQuickItem *m_qmlItem;
134 QQuickItem *m_qmlItem;
138 QUrl m_screenshotUrl;
135 QUrl m_screenshotUrl;
139
136
137+ int m_touchPressCount;
138+ int m_touchReleaseCount;
139+
140 friend class SurfaceManager;
140 friend class SurfaceManager;
141};
141};
142
142
143Q_DECLARE_METATYPE(MirSurfaceItem*)
143Q_DECLARE_METATYPE(MirSurfaceItem*)
144Q_DECLARE_METATYPE(QList<MirSurfaceItem*>)
144Q_DECLARE_METATYPE(QList<MirSurfaceItem*>)
145−Q_DECLARE_METATYPE(Qt::ScreenOrientation)
145+Q_DECLARE_METATYPE(MirSurfaceItem::OrientationAngle)
146
146
147#endif // MIRSURFACEITEM_H
147#endif // MIRSURFACEITEM_H
tests/mocks/Unity/Application/MirSurfaceItem.qml+12−14
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2014 Canonical Ltd.
2+ * Copyright 2014-2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -23,19 +23,11 @@ Rectangle {
23 implicitWidth: units.gu(40)
23 implicitWidth: units.gu(40)
24 implicitHeight: units.gu(70)
24 implicitHeight: units.gu(70)
25
25
26− rotation: {
26+ width: parent ? parent.width : implicitWidth
27− if (orientation == Qt.PortraitOrientation) return 0;
28− else if (orientation == Qt.LandscapeOrientation) return 90;
29− else if (orientation == Qt.InvertedPortraitOrientation) return 180;
30− else return 270;
31− }
32− x: parent ? (parent.width - width) / 2 : 0
33− y: parent ? (parent.height - height) / 2 : 0
34− width: parent ? (rotation == 0 || rotation == 180 ? parent.width : parent.height) : implicitWidth
35− height: parent ? (rotation == 0 || rotation == 180 ? parent.height : parent.width) : implicitHeight
27+ height: parent ? parent.height : implicitHeight
36
28
37 property alias screenshotSource: screenshotImage.source
29 property alias screenshotSource: screenshotImage.source
38− property int orientation: Qt.PortraitOrientation
30+ property int orientationAngle
39
31
40 Image {
32 Image {
41 id: screenshotImage
33 id: screenshotImage
@@ -50,6 +42,7 @@ Rectangle {
50 fontSizeMode: Text.Fit
42 fontSizeMode: Text.Fit
51 minimumPixelSize: 10
43 minimumPixelSize: 10
52 verticalAlignment: Text.AlignVCenter
44 verticalAlignment: Text.AlignVCenter
45+ rotation: surfaceText.rotation
53 x: surfaceText.x
46 x: surfaceText.x
54 y: surfaceText.y
47 y: surfaceText.y
55 width: surfaceText.width
48 width: surfaceText.width
@@ -59,12 +52,17 @@ Rectangle {
59 }
52 }
60 Text {
53 Text {
61 id: surfaceText
54 id: surfaceText
62− anchors.fill: parent
63− text: "SURFACE"
55+ text: "SURFACE " + root.width + "," + root.height
64 color: root.parent && root.parent.activeFocus ? "yellow" : "blue"
56 color: root.parent && root.parent.activeFocus ? "yellow" : "blue"
65 font.bold: true
57 font.bold: true
66 fontSizeMode: Text.Fit
58 fontSizeMode: Text.Fit
67 minimumPixelSize: 10; font.pixelSize: 200
59 minimumPixelSize: 10; font.pixelSize: 200
68 verticalAlignment: Text.AlignVCenter
60 verticalAlignment: Text.AlignVCenter
61+
62+ rotation: root.orientationAngle
63+ x: (parent.width - width) / 2
64+ y: (parent.height - height) / 2
65+ width: (rotation == 0 || rotation == 180 ? parent.width : parent.height)
66+ height:(rotation == 0 || rotation == 180 ? parent.height : parent.width)
69 }
67 }
70}
68}
tests/mocks/Unity/Application/SurfaceManager.cpp+4−34
@@ -16,8 +16,9 @@
16
16
17#include "SurfaceManager.h"
17#include "SurfaceManager.h"
18
18
19+#include "VirtualKeyboard.h"
20+
19#include <paths.h>
21#include <paths.h>
20−#include "MirSurfaceItem.h"
21
22
22SurfaceManager *SurfaceManager::the_surface_manager = nullptr;
23SurfaceManager *SurfaceManager::the_surface_manager = nullptr;
23
24
@@ -40,10 +41,7 @@ MirSurfaceItem *SurfaceManager::createSurface(const QString& name,
40 MirSurfaceItem::State state,
41 MirSurfaceItem::State state,
41 const QUrl& screenshot)
42 const QUrl& screenshot)
42{
43{
43− MirSurfaceItem* surface = new MirSurfaceItem(name,
44+ MirSurfaceItem* surface = new MirSurfaceItem(name, type, state, screenshot);
44− type,
45− state,
46− screenshot);
47 Q_EMIT surfaceCreated(surface);
45 Q_EMIT surfaceCreated(surface);
48 return surface;
46 return surface;
49}
47}
@@ -57,40 +55,12 @@ void SurfaceManager::registerSurface(MirSurfaceItem *surface)
57 surface->setLive(false);
55 surface->setLive(false);
58 Q_EMIT surfaceDestroyed(surface);
56 Q_EMIT surfaceDestroyed(surface);
59 });
57 });
60− connect(surface, &MirSurfaceItem::inputMethodRequested,
61− this, &SurfaceManager::showInputMethod);
62− connect(surface, &MirSurfaceItem::inputMethodDismissed,
63− this, &SurfaceManager::hideInputMethod);
64−}
65−
66−void SurfaceManager::showInputMethod()
67−{
68− inputMethodSurface()->setState(MirSurfaceItem::Restored);
69−}
70−
71−void SurfaceManager::hideInputMethod()
72−{
73− if (m_virtualKeyboard) {
74− m_virtualKeyboard->setState(MirSurfaceItem::Minimized);
75− }
76}
58}
77
59
78MirSurfaceItem *SurfaceManager::inputMethodSurface()
60MirSurfaceItem *SurfaceManager::inputMethodSurface()
79{
61{
80 if (!m_virtualKeyboard) {
62 if (!m_virtualKeyboard) {
81−
82− QString screenshotPath = QString("file://%1/Dash/graphics/phone/screenshots/vkb_portrait.png")
83− .arg(qmlDirectory());
84−
85− QString qmlFilePath = QString("%1/Unity/Application/VirtualKeyboard.qml")
86− .arg(mockPluginsDir());
87−
88− m_virtualKeyboard = new MirSurfaceItem(
63+ m_virtualKeyboard = new VirtualKeyboard;
89− "input-method",
90− MirSurfaceItem::InputMethod,
91− MirSurfaceItem::Minimized,
92− screenshotPath,
93− qmlFilePath);
94 Q_EMIT surfaceCreated(m_virtualKeyboard);
64 Q_EMIT surfaceCreated(m_virtualKeyboard);
95 }
65 }
96 return m_virtualKeyboard;
66 return m_virtualKeyboard;
tests/mocks/Unity/Application/SurfaceManager.h+2−5
@@ -20,6 +20,7 @@
20#include <QObject>
20#include <QObject>
21
21
22#include "MirSurfaceItem.h"
22#include "MirSurfaceItem.h"
23+#include "VirtualKeyboard.h"
23
24
24class SurfaceManager : public QObject
25class SurfaceManager : public QObject
25{
26{
@@ -45,13 +46,9 @@ Q_SIGNALS:
45 void surfaceCreated(MirSurfaceItem *surface);
46 void surfaceCreated(MirSurfaceItem *surface);
46 void surfaceDestroyed(MirSurfaceItem *surface);
47 void surfaceDestroyed(MirSurfaceItem *surface);
47
48
48−private Q_SLOTS:
49− void showInputMethod();
50− void hideInputMethod();
51−
52private:
49private:
53 static SurfaceManager *the_surface_manager;
50 static SurfaceManager *the_surface_manager;
54− MirSurfaceItem *m_virtualKeyboard;
51+ VirtualKeyboard *m_virtualKeyboard;
55};
52};
56
53
57#endif // SURFACEMANAGER_H
54#endif // SURFACEMANAGER_H
tests/mocks/Unity/Application/UbuntuKeyboardInfo.cpp+33−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014-2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software: you can redistribute it and/or modify it under
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
5 * the terms of the GNU Lesser General Public License version 3, as published by
@@ -26,3 +26,35 @@ UbuntuKeyboardInfo::UbuntuKeyboardInfo(QObject *parent)
26 m_height(200)
26 m_height(200)
27{
27{
28}
28}
29+
30+void UbuntuKeyboardInfo::setX(qreal value)
31+{
32+ if (value != m_x) {
33+ m_x = value;
34+ Q_EMIT xChanged(m_x);
35+ }
36+}
37+
38+void UbuntuKeyboardInfo::setY(qreal value)
39+{
40+ if (value != m_y) {
41+ m_y = value;
42+ Q_EMIT yChanged(m_y);
43+ }
44+}
45+
46+void UbuntuKeyboardInfo::setWidth(qreal value)
47+{
48+ if (value != m_width) {
49+ m_width = value;
50+ Q_EMIT widthChanged(m_width);
51+ }
52+}
53+
54+void UbuntuKeyboardInfo::setHeight(qreal value)
55+{
56+ if (value != m_height) {
57+ m_height = value;
58+ Q_EMIT heightChanged(m_height);
59+ }
60+}
tests/mocks/Unity/Application/UbuntuKeyboardInfo.h+11−5
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014-2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software: you can redistribute it and/or modify it under
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
5 * the terms of the GNU Lesser General Public License version 3, as published by
@@ -22,10 +22,10 @@
22
22
23class UbuntuKeyboardInfo : public QObject {
23class UbuntuKeyboardInfo : public QObject {
24 Q_OBJECT
24 Q_OBJECT
25− Q_PROPERTY(qreal x READ x NOTIFY xChanged)
25+ Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
26− Q_PROPERTY(qreal y READ y NOTIFY yChanged)
26+ Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
27− Q_PROPERTY(qreal width READ width NOTIFY widthChanged)
27+ Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged)
28− Q_PROPERTY(qreal height READ height NOTIFY heightChanged)
28+ Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged)
29public:
29public:
30 UbuntuKeyboardInfo(QObject *parent = 0);
30 UbuntuKeyboardInfo(QObject *parent = 0);
31 virtual ~UbuntuKeyboardInfo() {}
31 virtual ~UbuntuKeyboardInfo() {}
@@ -34,6 +34,12 @@ public:
34 qreal width() const { return m_width; }
34 qreal width() const { return m_width; }
35 qreal height() const { return m_height; }
35 qreal height() const { return m_height; }
36
36
37+ // Just in the fake implementation
38+ void setX(qreal value);
39+ void setY(qreal value);
40+ void setWidth(qreal value);
41+ void setHeight(qreal value);
42+
37 static UbuntuKeyboardInfo *singleton() {
43 static UbuntuKeyboardInfo *singleton() {
38 if (!m_instance) {
44 if (!m_instance) {
39 m_instance = new UbuntuKeyboardInfo;
45 m_instance = new UbuntuKeyboardInfo;
tests/mocks/Unity/Application/VirtualKeyboard.cppnew file+44
@@ -0,0 +1,44 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+#include "VirtualKeyboard.h"
18+
19+#include <paths.h>
20+
21+#include <QString>
22+
23+#include <QDebug>
24+
25+VirtualKeyboard::VirtualKeyboard(QQuickItem *parent)
26+ : MirSurfaceItem("input-method",
27+ MirSurfaceItem::InputMethod,
28+ MirSurfaceItem::Minimized,
29+ QString("file://%1/Dash/graphics/phone/screenshots/vkb_portrait.png")
30+ .arg(qmlDirectory()),
31+ QString("%1/Unity/Application/VirtualKeyboard.qml")
32+ .arg(mockPluginsDir()),
33+ parent)
34+{
35+}
36+
37+VirtualKeyboard::~VirtualKeyboard()
38+{
39+}
40+
41+void VirtualKeyboard::touchEvent(QTouchEvent *event)
42+{
43+ event->setAccepted(false);
44+}
tests/mocks/Unity/Application/VirtualKeyboard.hnew file+42
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+#ifndef VIRTUALKEYBOARD_H
18+#define VIRTUALKEYBOARD_H
19+
20+#include "MirSurfaceItem.h"
21+#include "MirSurfaceItemModel.h"
22+
23+#include <QQuickItem>
24+#include <QUrl>
25+
26+class Session;
27+
28+class VirtualKeyboard : public MirSurfaceItem
29+{
30+ Q_OBJECT
31+public:
32+ explicit VirtualKeyboard(QQuickItem *parent = 0);
33+ ~VirtualKeyboard();
34+
35+protected:
36+ void touchEvent(QTouchEvent * event) override;
37+};
38+
39+Q_DECLARE_METATYPE(VirtualKeyboard*)
40+Q_DECLARE_METATYPE(QList<VirtualKeyboard*>)
41+
42+#endif // VIRTUALKEYBOARD_H
tests/mocks/Unity/Application/VirtualKeyboard.qml+7−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2014 Canonical Ltd.
2+ * Copyright 2014-2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -15,6 +15,7 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import Unity.Application 0.1
18
19
19Item {
20Item {
20 implicitWidth: units.gu(40)
21 implicitWidth: units.gu(40)
@@ -37,4 +38,9 @@ Item {
37 anchors.fill: parent
38 anchors.fill: parent
38 }
39 }
39 }
40 }
41+
42+ Binding { target: UbuntuKeyboardInfo; property: "x"; value: screenshotImage.x}
43+ Binding { target: UbuntuKeyboardInfo; property: "y"; value: screenshotImage.y}
44+ Binding { target: UbuntuKeyboardInfo; property: "width"; value: screenshotImage.width}
45+ Binding { target: UbuntuKeyboardInfo; property: "height"; value: screenshotImage.height}
40}
46}
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+3−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013,2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -35,6 +35,8 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
35 item->setProgress(50);
35 item->setProgress(50);
36 item->setCountVisible(true);
36 item->setCountVisible(true);
37 m_list.append(item);
37 m_list.append(item);
38+ item = new MockLauncherItem("music-app", "/usr/share/applications/music-app.desktop", "Music", "soundcloud", this);
39+ m_list.append(item);
38 item = new MockLauncherItem("facebook-webapp", "/usr/share/applications/facebook-webapp.desktop", "Facebook", "facebook", this);
40 item = new MockLauncherItem("facebook-webapp", "/usr/share/applications/facebook-webapp.desktop", "Facebook", "facebook", this);
39 item->setProgress(150);
41 item->setProgress(150);
40 m_list.append(item);
42 m_list.append(item);
tests/plugins/Greeter/Unity/Launcher/CMakeLists.txt+1−1
@@ -1,5 +1,5 @@
1pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=6)
1pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=6)
2−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=5)
2+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=6)
3
3
4include_directories(
4include_directories(
5 ${CMAKE_CURRENT_SOURCE_DIR}
5 ${CMAKE_CURRENT_SOURCE_DIR}
tests/plugins/Unity/Launcher/CMakeLists.txt+1−1
@@ -1,8 +1,8 @@
1pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
1pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
2pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=6)
2pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=6)
3−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=5)
4
3
5include_directories(
4include_directories(
5+ ${APPLICATION_API_INCLUDE_DIRS}
6 ${CMAKE_CURRENT_SOURCE_DIR}
6 ${CMAKE_CURRENT_SOURCE_DIR}
7 ${CMAKE_CURRENT_BINARY_DIR}
7 ${CMAKE_CURRENT_BINARY_DIR}
8 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher
8 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher
tests/plugins/Unity/Launcher/launchermodeltest.cpp+3−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013-2014 Canonical Ltd.
2+ * Copyright 2013-2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -52,6 +52,8 @@ public:
52 QColor splashColor() const override { return QColor(0,0,0,0); }
52 QColor splashColor() const override { return QColor(0,0,0,0); }
53 QColor splashColorHeader() const override { return QColor(0,0,0,0); }
53 QColor splashColorHeader() const override { return QColor(0,0,0,0); }
54 QColor splashColorFooter() const override { return QColor(0,0,0,0); }
54 QColor splashColorFooter() const override { return QColor(0,0,0,0); }
55+ Qt::ScreenOrientations supportedOrientations() const override { return Qt::PortraitOrientation; }
56+ bool rotatesWindowContents() const override { return false; }
55
57
56 // Methods used for mocking (not in the interface)
58 // Methods used for mocking (not in the interface)
57 void setFocused(bool focused) { m_focused = focused; Q_EMIT focusedChanged(focused); }
59 void setFocused(bool focused) { m_focused = focused; Q_EMIT focusedChanged(focused); }
tests/qmltests/CMakeLists.txt+1
@@ -19,6 +19,7 @@ set(qmltest_DEFAULT_TARGETS qmluitests)
19set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
19set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
20set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
20set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
21
21
22+add_qml_test(. OrientedShell)
22add_qml_test(. Shell)
23add_qml_test(. Shell)
23add_qml_test(. ShellWithPin)
24add_qml_test(. ShellWithPin)
24add_qml_test(Components Background)
25add_qml_test(Components Background)
tests/qmltests/Panel/tst_IndicatorsMenu.qml−2
@@ -28,8 +28,6 @@ IndicatorTest {
28 height: units.gu(71)
28 height: units.gu(71)
29 color: "white"
29 color: "white"
30
30
31− property string indicatorProfile: "phone"
32−
33 RowLayout {
31 RowLayout {
34 anchors.fill: parent
32 anchors.fill: parent
35 anchors.margins: units.gu(1)
33 anchors.margins: units.gu(1)
tests/qmltests/Panel/tst_Panel.qml−2
@@ -29,8 +29,6 @@ IndicatorTest {
29 height: units.gu(71)
29 height: units.gu(71)
30 color: "white"
30 color: "white"
31
31
32− property string indicatorProfile: "phone"
33−
34 RowLayout {
32 RowLayout {
35 anchors.fill: parent
33 anchors.fill: parent
36 anchors.margins: units.gu(1)
34 anchors.margins: units.gu(1)
tests/qmltests/Stages/tst_ApplicationWindow.qml+14−23
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2014 Canonical Ltd.
2+ * Copyright 2014-2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -50,7 +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+ surfaceOrientationAngle: 0
54 interactive: true
54 interactive: true
55 focus: true
55 focus: true
56 }
56 }
@@ -210,15 +210,6 @@ Rectangle {
210 stateGroup = null;
210 stateGroup = null;
211 }
211 }
212
212
213− // wait until any transition animation has finished
214− function waitUntilTransitionsEnd() {
215− var transitions = stateGroup.transitions;
216− for (var i = 0; i < transitions.length; ++i) {
217− var transition = transitions[i];
218− tryCompare(transition, "running", false, 2000);
219− }
220− }
221−
222 function init() {
213 function init() {
223 findInterestingApplicationWindowChildren();
214 findInterestingApplicationWindowChildren();
224 }
215 }
@@ -280,12 +271,12 @@ Rectangle {
280
271
281 tryCompare(stateGroup, "state", "surface");
272 tryCompare(stateGroup, "state", "surface");
282
273
283− waitUntilTransitionsEnd();
274+ waitUntilTransitionsEnd(stateGroup);
284
275
285 setApplicationState(appSuspended);
276 setApplicationState(appSuspended);
286
277
287 verify(stateGroup.state === "surface");
278 verify(stateGroup.state === "surface");
288− waitUntilTransitionsEnd();
279+ waitUntilTransitionsEnd(stateGroup);
289 }
280 }
290
281
291 function test_killedAppShowsScreenshot() {
282 function test_killedAppShowsScreenshot() {
@@ -311,7 +302,7 @@ Rectangle {
311 initSession();
302 initSession();
312 setApplicationState(appRunning);
303 setApplicationState(appRunning);
313 tryCompare(stateGroup, "state", "surface");
304 tryCompare(stateGroup, "state", "surface");
314− waitUntilTransitionsEnd();
305+ waitUntilTransitionsEnd(stateGroup);
315
306
316 setApplicationState(appSuspended);
307 setApplicationState(appSuspended);
317
308
@@ -319,19 +310,19 @@ Rectangle {
319 setApplicationState(appStopped);
310 setApplicationState(appStopped);
320
311
321 tryCompare(stateGroup, "state", "screenshot");
312 tryCompare(stateGroup, "state", "screenshot");
322− waitUntilTransitionsEnd();
313+ waitUntilTransitionsEnd(stateGroup);
323 tryCompare(fakeApplication, "session", null);
314 tryCompare(fakeApplication, "session", null);
324
315
325 // and restart it
316 // and restart it
326 setApplicationState(appStarting);
317 setApplicationState(appStarting);
327
318
328− waitUntilTransitionsEnd();
319+ waitUntilTransitionsEnd(stateGroup);
329 verify(stateGroup.state === "screenshot");
320 verify(stateGroup.state === "screenshot");
330 verify(fakeSession === null);
321 verify(fakeSession === null);
331
322
332 setApplicationState(appRunning);
323 setApplicationState(appRunning);
333
324
334− waitUntilTransitionsEnd();
325+ waitUntilTransitionsEnd(stateGroup);
335 verify(stateGroup.state === "screenshot");
326 verify(stateGroup.state === "screenshot");
336
327
337 initSession();
328 initSession();
@@ -344,7 +335,7 @@ Rectangle {
344 initSession();
335 initSession();
345 setApplicationState(appRunning);
336 setApplicationState(appRunning);
346 tryCompare(stateGroup, "state", "surface");
337 tryCompare(stateGroup, "state", "surface");
347− waitUntilTransitionsEnd();
338+ waitUntilTransitionsEnd(stateGroup);
348
339
349 // oh, it crashed...
340 // oh, it crashed...
350 setApplicationState(appStopped);
341 setApplicationState(appStopped);
@@ -357,18 +348,18 @@ Rectangle {
357 initSession();
348 initSession();
358 setApplicationState(appRunning);
349 setApplicationState(appRunning);
359 tryCompare(stateGroup, "state", "surface");
350 tryCompare(stateGroup, "state", "surface");
360− waitUntilTransitionsEnd();
351+ waitUntilTransitionsEnd(stateGroup);
361 verify(fakeSession.surface !== null);
352 verify(fakeSession.surface !== null);
362
353
363 applicationWindowLoader.item.visible = false;
354 applicationWindowLoader.item.visible = false;
364
355
365− waitUntilTransitionsEnd();
356+ waitUntilTransitionsEnd(stateGroup);
366 verify(stateGroup.state === "surface");
357 verify(stateGroup.state === "surface");
367 verify(fakeSession.surface !== null);
358 verify(fakeSession.surface !== null);
368
359
369 applicationWindowLoader.item.visible = true;
360 applicationWindowLoader.item.visible = true;
370
361
371− waitUntilTransitionsEnd();
362+ waitUntilTransitionsEnd(stateGroup);
372 verify(stateGroup.state === "surface");
363 verify(stateGroup.state === "surface");
373 verify(fakeSession.surface !== null);
364 verify(fakeSession.surface !== null);
374 }
365 }
@@ -379,7 +370,7 @@ Rectangle {
379
370
380 tryCompare(stateGroup, "state", "surface");
371 tryCompare(stateGroup, "state", "surface");
381
372
382− waitUntilTransitionsEnd();
373+ waitUntilTransitionsEnd(stateGroup);
383
374
384 var fakeSurface = fakeSession.surface;
375 var fakeSurface = fakeSession.surface;
385 fakeSurface.touchPressCount = 0;
376 fakeSurface.touchPressCount = 0;
@@ -396,7 +387,7 @@ Rectangle {
396 initSession();
387 initSession();
397 setApplicationState(appRunning);
388 setApplicationState(appRunning);
398 tryCompare(stateGroup, "state", "surface");
389 tryCompare(stateGroup, "state", "surface");
399− waitUntilTransitionsEnd();
390+ waitUntilTransitionsEnd(stateGroup);
400
391
401 cleanupSession();
392 cleanupSession();
402
393
tests/qmltests/Stages/tst_PhoneStage.qml+5−58
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2014 Canonical Ltd.
2+ * Copyright 2014-2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -33,7 +33,9 @@ Item {
33 dragAreaWidth: units.gu(2)
33 dragAreaWidth: units.gu(2)
34 maximizedAppTopMargin: units.gu(3) + units.dp(2)
34 maximizedAppTopMargin: units.gu(3) + units.dp(2)
35 interactive: true
35 interactive: true
36+ shellOrientation: Qt.PortraitOrientation
37+ shellPrimaryOrientation: Qt.PortraitOrientation
36− orientation: Qt.PortraitOrientation
38+ nativeOrientation: Qt.PortraitOrientation
37 }
39 }
38
40
39 Binding {
41 Binding {
@@ -73,21 +75,6 @@ Item {
73 ApplicationManager.get(appList.selectedAppIndex).setState(ApplicationInfoInterface.Stopped);
75 ApplicationManager.get(appList.selectedAppIndex).setState(ApplicationInfoInterface.Stopped);
74 }
76 }
75 }
77 }
76− Button {
77− anchors { left: parent.left; right: parent.right }
78− text: "Rotate device \u27F3"
79− onClicked: {
80− if (phoneStage.orientation == Qt.PortraitOrientation) {
81− phoneStage.orientation = Qt.LandscapeOrientation;
82− } else if (phoneStage.orientation == Qt.LandscapeOrientation) {
83− phoneStage.orientation = Qt.InvertedPortraitOrientation;
84− } else if (phoneStage.orientation == Qt.InvertedPortraitOrientation) {
85− phoneStage.orientation = Qt.InvertedLandscapeOrientation;
86− } else {
87− phoneStage.orientation = Qt.PortraitOrientation;
88− }
89− }
90− }
91 }
78 }
92 ListView {
79 ListView {
93 id: appList
80 id: appList
@@ -283,46 +270,6 @@ Item {
283 compare(ApplicationManager.focusedApplicationId, selectedApp.appId);
270 compare(ApplicationManager.focusedApplicationId, selectedApp.appId);
284 }
271 }
285
272
286− function test_orientationChangeSentToFocusedApp() {
287− phoneStage.orientation = Qt.PortraitOrientation;
288− addApps(1);
289−
290− var spreadView = findChild(phoneStage, "spreadView");
291− var app = findChild(spreadView, "appDelegate0");
292− tryCompare(app, "orientation", Qt.PortraitOrientation);
293−
294− phoneStage.orientation = Qt.LandscapeOrientation;
295− tryCompare(app, "orientation", Qt.LandscapeOrientation);
296− }
297−
298− function test_orientationChangeNotSentToAppsWhileSpreadOpen() {
299− phoneStage.orientation = Qt.PortraitOrientation;
300− addApps(1);
301−
302− var spreadView = findChild(phoneStage, "spreadView");
303− var app = findChild(spreadView, "appDelegate0");
304− tryCompare(app, "orientation", Qt.PortraitOrientation);
305−
306− goToSpread();
307− phoneStage.orientation = Qt.LandscapeOrientation;
308− tryCompare(app, "orientation", Qt.PortraitOrientation);
309− }
310−
311− function test_orientationChangeNotSentToUnfocusedAppUntilItFocused() {
312− phoneStage.orientation = Qt.PortraitOrientation;
313− addApps(1);
314−
315− var spreadView = findChild(phoneStage, "spreadView");
316− var app = findChild(spreadView, "appDelegate0");
317−
318− goToSpread();
319− phoneStage.orientation = Qt.LandscapeOrientation;
320− tryCompare(app, "orientation", Qt.PortraitOrientation);
321−
322− phoneStage.select(app.application.appId);
323− tryCompare(app, "orientation", Qt.LandscapeOrientation);
324− }
325−
326 function test_backgroundClickCancelsSpread() {
273 function test_backgroundClickCancelsSpread() {
327 addApps(3);
274 addApps(3);
328
275
@@ -347,7 +294,7 @@ Item {
347 ApplicationManager.stopApplication(ApplicationManager.get(closingIndex).appId)
294 ApplicationManager.stopApplication(ApplicationManager.get(closingIndex).appId)
348 tryCompare(ApplicationManager, "count", oldCount - 1)
295 tryCompare(ApplicationManager, "count", oldCount - 1)
349 }
296 }
350− phoneStage.orientation = Qt.PortraitOrientation;
297+ phoneStage.shellOrientationAngle = 0;
351 }
298 }
352
299
353 function test_focusNewTopMostAppAfterFocusedOneClosesItself() {
300 function test_focusNewTopMostAppAfterFocusedOneClosesItself() {
tests/qmltests/Stages/tst_SessionContainer.qml+1−64
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2014 Canonical Ltd.
2+ * Copyright 2014-2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -41,7 +41,6 @@ Rectangle {
41 SessionContainer {
41 SessionContainer {
42 id: sessionContainer
42 id: sessionContainer
43 anchors.fill: parent
43 anchors.fill: parent
44− orientation: Qt.PortraitOrientation
45 focus: true
44 focus: true
46 interactive: true
45 interactive: true
47 }
46 }
@@ -117,24 +116,6 @@ Rectangle {
117 session: sessionContainerLoader.item ? sessionContainerLoader.item.session : null
116 session: sessionContainerLoader.item ? sessionContainerLoader.item.session : null
118 }
117 }
119 }
118 }
120−
121− Button {
122− anchors { left: parent.left; right: parent.right }
123− text: "Rotate device \u27F3"
124− onClicked: {
125− var orientation = sessionContainerLoader.item.orientation
126− if (orientation == Qt.PortraitOrientation) {
127− orientation = Qt.LandscapeOrientation;
128− } else if (orientation == Qt.LandscapeOrientation) {
129− orientation = Qt.InvertedPortraitOrientation;
130− } else if (orientation == Qt.InvertedPortraitOrientation) {
131− orientation = Qt.InvertedLandscapeOrientation;
132− } else {
133− orientation = Qt.PortraitOrientation;
134− }
135− sessionContainerLoader.item.orientation = orientation;
136− }
137− }
138 }
119 }
139 }
120 }
140
121
@@ -324,49 +305,5 @@ Rectangle {
324 // wait for animation to end
305 // wait for animation to end
325 tryCompareFunction(function() { return isContainerAnimating(childContainer); }, false);
306 tryCompareFunction(function() { return isContainerAnimating(childContainer); }, false);
326 }
307 }
327−
328− function test_orientationPropagatedToChildren_data() {
329− return [ { tag: "count=1", count: 1 },
330− { tag: "count=4", count: 4 } ];
331− }
332−
333− /* Test orientation changes are propagated to all children immediately */
334− function test_orientationPropagatedToChildren(data) {
335− sessionCheckbox.checked = true;
336− var rootSessionContainer = sessionContainerLoader.item;
337− compare(rootSessionContainer.childSessions.count(), 0);
338−
339− var i;
340− var sessions = [];
341− for (i = 0; i < data.count; i++) {
342− var session = ApplicationTest.addChildSession(rootSessionContainer.session,
343− "gallery");
344− session.createSurface();
345− rootSessionContainer.session.addChildSession(session);
346−
347− // Check child SessionContainer has orientation matching the parent
348− var delegate = findChild(rootSessionContainer, "childDelegate" + i);
349− var childSessionContainer = findChild(delegate, "sessionContainer");
350−
351− tryCompare(rootSessionContainer, "orientation", childSessionContainer.orientation);
352−
353− sessions.push(session);
354− }
355−
356− // Change orientation and verify all children updated
357− rootSessionContainer.orientation = Qt.LandscapeOrientation;
358−
359− for (i = 0; i < data.count; i++) {
360− var delegate = findChild(rootSessionContainer, "childDelegate" + i);
361− var childSessionContainer = findChild(delegate, "sessionContainer");
362−
363− tryCompare(rootSessionContainer, "orientation", childSessionContainer.orientation);
364− }
365−
366− // Clean up
367− for (i = data.count-1; i >= 0; i--) {
368− ApplicationTest.removeSession(sessions[i]);
369− }
370− }
371 }
308 }
372}
309}
tests/qmltests/Stages/tst_SpreadDelegate.qml+172−37
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2014 Canonical Ltd.
2+ * Copyright 2014-2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -26,46 +26,89 @@ import Unity.Application 0.1
26Rectangle {
26Rectangle {
27 color: "red"
27 color: "red"
28 id: root
28 id: root
29− width: units.gu(70)
29+ width: fakeShell.shortestDimension + controls.width
30− height: units.gu(70)
30+ height: fakeShell.longestDimension
31
31
32− Component.onCompleted: {
33− root.fakeApplication = ApplicationManager.startApplication("gallery-app");
34− }
35 property QtObject fakeApplication: null
32 property QtObject fakeApplication: null
36
33
37− Component {
34+ Item {
38− id: spreadDelegateComponent
35+ id: fakeShell
36+
37+ readonly property real shortestDimension: units.gu(40)
38+ readonly property real longestDimension: units.gu(70)
39+
40+ width: landscape ? longestDimension : shortestDimension
41+ height: landscape ? shortestDimension : longestDimension
42+
43+ x: landscape ? (height - width) / 2 : 0
44+ y: landscape ? (width - height) / 2 : 0
45+
46+ property bool landscape: orientationAngle == 90 || orientationAngle == 270
47+ property int orientationAngle: shellOrientationAngleSelector.value
48+
49+ rotation: orientationAngle
50+
51+ Loader {
52+ id: spreadDelegateLoader
53+ width: parent.width
54+ height: parent.height
55+
56+ active: false
57+ property bool itemDestroyed: false
39− SpreadDelegate {
58+ sourceComponent: SpreadDelegate {
40− anchors.fill: parent
59+ anchors.fill: parent
41− swipeToCloseEnabled: swipeToCloseCheckbox.checked
60+ swipeToCloseEnabled: swipeToCloseCheckbox.checked
42− closeable: closeableCheckbox.checked
61+ closeable: closeableCheckbox.checked
43− application: fakeApplication
62+ application: fakeApplication
44− }
63+ shellOrientationAngle: shellOrientationAngleSelector.value
45− }
64+ shellOrientation: {
46− Loader {
65+ switch (shellOrientationAngleSelector.value) {
47− id: spreadDelegateLoader
66+ case 0:
48− anchors {
67+ return Qt.PortraitOrientation;
49− top: parent.top
68+ case 90:
50− bottom: parent.bottom
69+ return Qt.InvertedLandscapeOrientation;
51− left: parent.left
70+ case 180:
71+ return Qt.InvertedPortraitOrientation;
72+ default: // 270
73+ return Qt.LandscapeOrientation;
74+ }
75+ }
76+ shellPrimaryOrientation: Qt.PortraitOrientation
77+ nativeOrientation: Qt.PortraitOrientation
78+ maximizedAppTopMargin: units.gu(3)
79+ Component.onDestruction: {
80+ spreadDelegateLoader.itemDestroyed = true;
81+ }
82+ Component.onCompleted: {
83+ spreadDelegateLoader.itemDestroyed = false;
84+ }
85+ }
52 }
86 }
53− width: units.gu(40)
54− sourceComponent: spreadDelegateComponent
55 }
87 }
56
88
57 Rectangle {
89 Rectangle {
90+ id: controls
58 color: "white"
91 color: "white"
92+ x: fakeShell.shortestDimension
93+ width: units.gu(30)
59 anchors {
94 anchors {
60 top: parent.top
95 top: parent.top
61 bottom: parent.bottom
96 bottom: parent.bottom
62− left: spreadDelegateLoader.right
63− right: parent.right
64 }
97 }
65
98
66 Column {
99 Column {
67 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
100 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
68 spacing: units.gu(1)
101 spacing: units.gu(1)
102+ Button {
103+ id: loadWithWeatherApp
104+ text: "Load with ubuntu-weather-app"
105+ onClicked: { testCase.restartWithApp("ubuntu-weather-app"); }
106+ }
107+ Button {
108+ id: loadWithGalleryApp
109+ text: "Load with gallery-app"
110+ onClicked: { testCase.restartWithApp("gallery-app"); }
111+ }
69 Row {
112 Row {
70 anchors { left: parent.left; right: parent.right }
113 anchors { left: parent.left; right: parent.right }
71 CheckBox { id: swipeToCloseCheckbox; checked: false; }
114 CheckBox { id: swipeToCloseCheckbox; checked: false; }
@@ -76,6 +119,21 @@ Rectangle {
76 CheckBox { id: closeableCheckbox; checked: false }
119 CheckBox { id: closeableCheckbox; checked: false }
77 Label { text: "closeable" }
120 Label { text: "closeable" }
78 }
121 }
122+ ListItem.ItemSelector {
123+ id: shellOrientationAngleSelector
124+ anchors { left: parent.left; right: parent.right }
125+ text: "shellOrientationAngle"
126+ model: ["0", "90", "180", "270"]
127+ property int value: selectedIndex * 90
128+ }
129+ Button {
130+ text: "matchShellOrientation()"
131+ onClicked: { spreadDelegateLoader.item.matchShellOrientation(); }
132+ }
133+ Button {
134+ text: "animateToShellOrientation()"
135+ onClicked: { spreadDelegateLoader.item.animateToShellOrientation(); }
136+ }
79 }
137 }
80 }
138 }
81
139
@@ -91,18 +149,47 @@ Rectangle {
91 }
149 }
92
150
93 property var dragArea
151 property var dragArea
152+ property Item spreadDelegate: spreadDelegateLoader.item
94
153
95 function init() {
154 function init() {
96− dragArea = findInvisibleChild(spreadDelegateLoader.item, "dragArea");
97− dragArea.__dateTime = fakeDateTime;
98 }
155 }
99
156
100 function cleanup() {
157 function cleanup() {
101− // reload our test subject to get it in a fresh state once again
158+ unloadSpreadDelegate();
159+ spyClosedSignal.clear();
160+ shellOrientationAngleSelector.selectedIndex = 0;
161+ ApplicationManager.stopApplication(root.fakeApplication.appId);
162+ root.fakeApplication = null;
163+ }
164+
165+ function restartWithApp(appId) {
102− spreadDelegateLoader.active = false;
166+ if (spreadDelegateLoader.active) {
167+ unloadSpreadDelegate();
168+ }
169+ if (root.fakeApplication) {
170+ ApplicationManager.stopApplication(root.fakeApplication.appId);
171+ }
172+
173+ root.fakeApplication = ApplicationManager.startApplication(appId);
103 spreadDelegateLoader.active = true;
174 spreadDelegateLoader.active = true;
175+ tryCompare(spreadDelegateLoader, "status", Loader.Ready);
176+
177+ dragArea = findInvisibleChild(spreadDelegate, "dragArea");
178+ dragArea.__dateTime = fakeDateTime;
179+ }
180+
181+ function unloadSpreadDelegate() {
182+ spreadDelegateLoader.active = false;
183+ tryCompare(spreadDelegateLoader, "status", Loader.Null);
184+ tryCompare(spreadDelegateLoader, "item", null);
185+ // Loader.status might be Loader.Null and Loader.item might be null but the Loader
186+ // item might still be alive. So if we set Loader.active back to true
187+ // again right now we will get the very same Shell instance back. So no reload
188+ // actually took place. Likely because Loader waits until the next event loop
189+ // iteration to do its work. So to ensure the reload, we will wait until the
190+ // Shell instance gets destroyed.
191+ tryCompare(spreadDelegateLoader, "itemDestroyed", true);
104
192
105− spyClosedSignal.clear();
106 }
193 }
107
194
108 function test_swipeToClose_data() {
195 function test_swipeToClose_data() {
@@ -119,9 +206,10 @@ Rectangle {
119 }
206 }
120
207
121 function test_swipeToClose(data) {
208 function test_swipeToClose(data) {
209+ loadWithGalleryApp.clicked();
122− var appWindowWithShadow = findChild(spreadDelegateLoader.item, "appWindowWithShadow");
210+ var displacedAppWindowWithShadow = findChild(spreadDelegateLoader.item, "displacedAppWindowWithShadow");
123
211
124− verify(appWindowWithShadow.y === 0);
212+ verify(displacedAppWindowWithShadow.y === 0);
125
213
126 swipeToCloseCheckbox.checked = data.swipeToClose;
214 swipeToCloseCheckbox.checked = data.swipeToClose;
127 closeableCheckbox.checked = data.closeable;
215 closeableCheckbox.checked = data.closeable;
@@ -135,14 +223,14 @@ Rectangle {
135 true /* beginTouch */, false /* endTouch */, dragArea.minSpeedToClose * 1.1 /* speed */);
223 true /* beginTouch */, false /* endTouch */, dragArea.minSpeedToClose * 1.1 /* speed */);
136
224
137 if (data.swipeToClose) {
225 if (data.swipeToClose) {
138− verify(appWindowWithShadow.y < 0);
226+ verify(displacedAppWindowWithShadow.y < 0);
139 var threshold = findChild(spreadDelegateLoader.item, "dragArea").threshold
227 var threshold = findChild(spreadDelegateLoader.item, "dragArea").threshold
140 if (data.closeable) {
228 if (data.closeable) {
141 // Verify that the delegate started moving exactly "threshold" after the finger movement
229 // Verify that the delegate started moving exactly "threshold" after the finger movement
142 // and did not jump up to the finger, but lags the threshold behind
230 // and did not jump up to the finger, but lags the threshold behind
143− compare(Math.abs(Math.abs(appWindowWithShadow.y) - dragDistance), threshold);
231+ compare(Math.abs(Math.abs(displacedAppWindowWithShadow.y) - dragDistance), threshold);
144 } else {
232 } else {
145− verify(Math.abs(Math.abs(appWindowWithShadow.y) - dragDistance) > threshold);
233+ verify(Math.abs(Math.abs(displacedAppWindowWithShadow.y) - dragDistance) > threshold);
146 }
234 }
147
235
148 touchRelease(spreadDelegateLoader.item, touchX, toY - units.gu(1));
236 touchRelease(spreadDelegateLoader.item, touchX, toY - units.gu(1));
@@ -153,16 +241,63 @@ Rectangle {
153 verify(spyClosedSignal.count === 1);
241 verify(spyClosedSignal.count === 1);
154 } else {
242 } else {
155 verify(spyClosedSignal.count === 0);
243 verify(spyClosedSignal.count === 0);
156− tryCompare(appWindowWithShadow, "y", 0);
244+ tryCompare(displacedAppWindowWithShadow, "y", 0);
157 }
245 }
158
246
159 } else {
247 } else {
160− verify(appWindowWithShadow.y === 0);
248+ verify(displacedAppWindowWithShadow.y === 0);
161
249
162 touchRelease(spreadDelegateLoader.item, touchX, toY);
250 touchRelease(spreadDelegateLoader.item, touchX, toY);
163 }
251 }
164 }
252 }
165
253
254+ function test_loadingLandscapeOnlyAppWhenShellInPortrait() {
255+ loadWithWeatherApp.clicked();
256+
257+ var appWindow = findChild(spreadDelegate, "appWindow_ubuntu-weather-app");
258+ verify(appWindow);
259+
260+ // It must have landscape dimensions as it does not support portrait
261+ tryCompare(appWindow, "width", fakeShell.height);
262+ tryCompare(appWindow, "height", fakeShell.width - spreadDelegate.maximizedAppTopMargin);
263+ }
264+
265+ function test_keepsSceneTransformationWhenShellRotates_data() {
266+ return [
267+ {tag: "0", selectedIndex: 0},
268+ {tag: "90", selectedIndex: 1},
269+ {tag: "180", selectedIndex: 2},
270+ {tag: "270", selectedIndex: 3}
271+ ];
272+ }
273+ function test_keepsSceneTransformationWhenShellRotates(data) {
274+ loadWithGalleryApp.clicked();
275+
276+ var appWindowWithShadow = findChild(spreadDelegate, "appWindowWithShadow");
277+ verify(appWindowWithShadow);
278+
279+ // Wait until it reaches the state we are interested on.
280+ // It begins with "startingUp"
281+ tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
282+
283+ shellOrientationAngleSelector.selectedIndex = data.selectedIndex;
284+
285+ // must keep same aspect ratio
286+ compare(appWindowWithShadow.width, fakeShell.shortestDimension);
287+ compare(appWindowWithShadow.height, fakeShell.longestDimension);
288+
289+
290+ // and scene transformation must be the identity (ie, no rotation or translation)
291+ var pointInDelegateCoords = appWindowWithShadow.mapToItem(root, 0, 0);
292+ compare(pointInDelegateCoords.x, 0);
293+ compare(pointInDelegateCoords.y, 0);
294+
295+ pointInDelegateCoords = appWindowWithShadow.mapToItem(root,
296+ fakeShell.shortestDimension, fakeShell.longestDimension);
297+ compare(pointInDelegateCoords.x, fakeShell.shortestDimension);
298+ compare(pointInDelegateCoords.y, fakeShell.longestDimension);
299+ }
300+
166 function waitForCloseAnimationToFinish() {
301 function waitForCloseAnimationToFinish() {
167 var closeAnimation = findInvisibleChild(spreadDelegateLoader.item, "closeAnimation");
302 var closeAnimation = findInvisibleChild(spreadDelegateLoader.item, "closeAnimation");
168 wait(closeAnimation.duration * 1.5);
303 wait(closeAnimation.duration * 1.5);
tests/qmltests/Stages/tst_TabletStage.qml+51
@@ -49,6 +49,11 @@ Rectangle {
49 dragAreaWidth: units.gu(2)
49 dragAreaWidth: units.gu(2)
50 maximizedAppTopMargin: units.gu(3) + units.dp(2)
50 maximizedAppTopMargin: units.gu(3) + units.dp(2)
51 interactive: true
51 interactive: true
52+ shellOrientation: Qt.LandscapeOrientation
53+ shellPrimaryOrientation: Qt.LandscapeOrientation
54+ nativeOrientation: Qt.LandscapeOrientation
55+ nativeWidth: width
56+ nativeHeight: height
52 focus: true
57 focus: true
53 }
58 }
54 }
59 }
@@ -149,6 +154,52 @@ Rectangle {
149 tryCompare(dialerApp.session.surface, "activeFocus", true);
154 tryCompare(dialerApp.session.surface, "activeFocus", true);
150 tryCompare(webbrowserApp.session.surface, "activeFocus", false);
155 tryCompare(webbrowserApp.session.surface, "activeFocus", false);
151 }
156 }
157+
158+
159+ function test_closeAppInSideStage() {
160+ dialerCheckBox.checked = true;
161+ waitUntilAppSurfaceShowsUp(dialerCheckBox.appId);
162+
163+ performEdgeSwipeToShowAppSpread();
164+
165+ var appDelegate = findChild(tabletStage, "spreadDelegate_" + dialerCheckBox.appId);
166+ verify(appDelegate);
167+ tryCompare(appDelegate, "swipeToCloseEnabled", true);
168+
169+ swipeAppUpwards(dialerCheckBox.appId);
170+
171+ // Check that dialer-app has been closed
172+
173+ tryCompareFunction(function() {
174+ return findChild(tabletStage, "appWindow_" + dialerCheckBox.appId);
175+ }, null);
176+
177+ tryCompareFunction(function() {
178+ return ApplicationManager.findApplication(dialerCheckBox.appId);
179+ }, null);
180+ }
181+
182+ function performEdgeSwipeToShowAppSpread() {
183+ var touchStartY = tabletStage.height / 2;
184+ touchFlick(tabletStage,
185+ tabletStage.width - 1, touchStartY,
186+ 0, touchStartY);
187+
188+ var spreadView = findChild(tabletStage, "spreadView");
189+ verify(spreadView);
190+ tryCompare(spreadView, "phase", 2);
191+ tryCompare(spreadView, "flicking", false);
192+ tryCompare(spreadView, "moving", false);
193+ }
194+
195+ function swipeAppUpwards(appId) {
196+ var appWindow = findChild(tabletStage, "appWindow_" + appId);
197+ verify(appWindow);
198+
199+ touchFlick(appWindow,
200+ appWindow.width / 2, appWindow.height / 2,
201+ appWindow.width / 2, -appWindow.height / 2);
202+ }
152 }
203 }
153
204
154}
205}
tests/qmltests/tst_OrientedShell.qmlnew file+1151
@@ -0,0 +1,1151 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+import QtQuick 2.0
18+import QtQuick.Layouts 1.1
19+import QtTest 1.0
20+import Ubuntu.Components 1.1
21+import Ubuntu.Components.ListItems 1.0 as ListItem
22+import Unity.Application 0.1
23+import Unity.Test 0.1
24+import LightDM 0.1 as LightDM
25+import Powerd 0.1
26+
27+import "../../qml"
28+
29+Rectangle {
30+ id: root
31+ color: "grey"
32+ width: units.gu(160) + controls.width
33+ height: units.gu(100)
34+
35+ QtObject {
36+ id: applicationArguments
37+
38+ function hasGeometry() {
39+ return false;
40+ }
41+
42+ function width() {
43+ return 0;
44+ }
45+
46+ function height() {
47+ return 0;
48+ }
49+ property string deviceName: "mako"
50+ }
51+
52+ QtObject {
53+ id: mockOrientationLock
54+ property int savedOrientation
55+ }
56+
57+ QtObject {
58+ id: mockUsageModeSettings
59+ property string usageMode: usageModeSelector.model[usageModeSelector.selectedIndex]
60+ }
61+
62+ property int physicalOrientation0
63+ property int physicalOrientation90
64+ property int physicalOrientation180
65+ property int physicalOrientation270
66+ property real primaryOrientationAngle
67+
68+ state: applicationArguments.deviceName
69+ states: [
70+ State {
71+ name: "mako"
72+ PropertyChanges {
73+ target: orientedShellLoader
74+ width: units.gu(40)
75+ height: units.gu(71)
76+ }
77+ PropertyChanges {
78+ target: root
79+ physicalOrientation0: Qt.PortraitOrientation
80+ physicalOrientation90: Qt.InvertedLandscapeOrientation
81+ physicalOrientation180: Qt.InvertedPortraitOrientation
82+ physicalOrientation270: Qt.LandscapeOrientation
83+ primaryOrientationAngle: 0
84+ }
85+ },
86+ State {
87+ name: "manta"
88+ PropertyChanges {
89+ target: orientedShellLoader
90+ width: units.gu(160)
91+ height: units.gu(100)
92+ }
93+ PropertyChanges {
94+ target: root
95+ physicalOrientation90: Qt.PortraitOrientation
96+ physicalOrientation180: Qt.InvertedLandscapeOrientation
97+ physicalOrientation270: Qt.InvertedPortraitOrientation
98+ physicalOrientation0: Qt.LandscapeOrientation
99+ primaryOrientationAngle: 0
100+ }
101+ },
102+ State {
103+ name: "flo"
104+ PropertyChanges {
105+ target: orientedShellLoader
106+ width: units.gu(62)
107+ height: units.gu(100)
108+ }
109+ PropertyChanges {
110+ target: root
111+ physicalOrientation270: Qt.PortraitOrientation
112+ physicalOrientation0: Qt.InvertedLandscapeOrientation
113+ physicalOrientation90: Qt.InvertedPortraitOrientation
114+ physicalOrientation180: Qt.LandscapeOrientation
115+ primaryOrientationAngle: 90
116+ }
117+ }
118+ ]
119+
120+ Loader {
121+ id: orientedShellLoader
122+
123+ x: ((root.width - controls.width) - width) / 2
124+ y: (root.height - height) / 2
125+
126+ focus: true
127+
128+ property bool itemDestroyed: false
129+ sourceComponent: Component {
130+ OrientedShell {
131+ anchors.fill: parent
132+ usageModeSettings: mockUsageModeSettings
133+ physicalOrientation: root.physicalOrientation0
134+ orientationLocked: orientationLockedCheckBox.checked
135+ orientationLock: mockOrientationLock
136+ Component.onDestruction: {
137+ orientedShellLoader.itemDestroyed = true;
138+ }
139+ }
140+ }
141+ }
142+
143+ function orientationsToStr(orientations) {
144+ if (orientations === Qt.PrimaryOrientation) {
145+ return "Primary";
146+ } else {
147+ var str = "";
148+ if (orientations & Qt.PortraitOrientation) {
149+ str += " Portrait";
150+ }
151+ if (orientations & Qt.InvertedPortraitOrientation) {
152+ str += " InvertedPortrait";
153+ }
154+ if (orientations & Qt.LandscapeOrientation) {
155+ str += " Landscape";
156+ }
157+ if (orientations & Qt.InvertedLandscapeOrientation) {
158+ str += " InvertedLandscape";
159+ }
160+ return str;
161+ }
162+ }
163+
164+ Rectangle {
165+ width: controls.width
166+ anchors {
167+ top: parent.top
168+ bottom: parent.bottom
169+ right: parent.right
170+ }
171+ color: "darkgrey"
172+ }
173+ Flickable {
174+ id: controls
175+ width: units.gu(30)
176+ anchors {
177+ top: parent.top
178+ bottom: parent.bottom
179+ right: parent.right
180+ }
181+
182+ boundsBehavior: Flickable.StopAtBounds
183+ contentHeight: controlsColumn.height
184+
185+ Column {
186+ id: controlsColumn
187+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
188+ spacing: units.gu(1)
189+ Button {
190+ text: "Show Greeter"
191+ activeFocusOnPress: false
192+ onClicked: {
193+ if (orientedShellLoader.status !== Loader.Ready)
194+ return;
195+
196+ LightDM.Greeter.showGreeter();
197+ }
198+ }
199+ Label {
200+ text: "Physical Orientation:"
201+ }
202+ Button {
203+ id: rotate0Button
204+ text: root.orientationsToStr(root.physicalOrientation0) + " (0)"
205+ activeFocusOnPress: false
206+ onClicked: {
207+ orientedShellLoader.item.physicalOrientation = root.physicalOrientation0;
208+ }
209+ }
210+ Button {
211+ id: rotate90Button
212+ text: root.orientationsToStr(root.physicalOrientation90) + " (90)"
213+ activeFocusOnPress: false
214+ onClicked: {
215+ orientedShellLoader.item.physicalOrientation = root.physicalOrientation90;
216+ }
217+ }
218+ Button {
219+ id: rotate180Button
220+ text: root.orientationsToStr(root.physicalOrientation180) + " (180)"
221+ activeFocusOnPress: false
222+ onClicked: {
223+ orientedShellLoader.item.physicalOrientation = root.physicalOrientation180;
224+ }
225+ }
226+ Button {
227+ id: rotate270Button
228+ text: root.orientationsToStr(root.physicalOrientation270) + " (270)"
229+ activeFocusOnPress: false
230+ onClicked: {
231+ orientedShellLoader.item.physicalOrientation = root.physicalOrientation270;
232+ }
233+ }
234+ RowLayout {
235+ Layout.fillWidth: true
236+ CheckBox {
237+ id: orientationLockedCheckBox
238+ checked: false
239+ activeFocusOnPress: false
240+ }
241+ Label {
242+ text: "Orientation Locked"
243+ anchors.verticalCenter: parent.verticalCenter
244+ }
245+ }
246+ Button {
247+ text: "Power dialog"
248+ activeFocusOnPress: false
249+ onClicked: { testCase.showPowerDialog(); }
250+ }
251+ ListItem.ItemSelector {
252+ id: deviceNameSelector
253+ anchors { left: parent.left; right: parent.right }
254+ activeFocusOnPress: false
255+ text: "Device Name"
256+ model: ["mako", "manta", "flo"]
257+ onSelectedIndexChanged: {
258+ testCase.tearDown();
259+ applicationArguments.deviceName = model[selectedIndex];
260+ orientedShellLoader.active = true;
261+ }
262+ }
263+ ListItem.ItemSelector {
264+ id: usageModeSelector
265+ anchors { left: parent.left; right: parent.right }
266+ activeFocusOnPress: false
267+ text: "Usage Mode"
268+ model: ["Staged", "Windowed", "Automatic"]
269+ }
270+ Button {
271+ text: "Switch fullscreen"
272+ activeFocusOnPress: false
273+ onClicked: {
274+ var app = ApplicationManager.findApplication(ApplicationManager.focusedApplicationId);
275+ app.fullscreen = !app.fullscreen;
276+ }
277+ }
278+ RowLayout {
279+ Layout.fillWidth: true
280+ CheckBox {
281+ checked: false
282+ activeFocusOnPress: false
283+ onCheckedChanged: {
284+ var surface = SurfaceManager.inputMethodSurface();
285+ if (checked) {
286+ surface.setState(MirSurfaceItem.Restored);
287+ } else {
288+ surface.setState(MirSurfaceItem.Minimized);
289+ }
290+ }
291+ }
292+ Label {
293+ text: "Input Method"
294+ anchors.verticalCenter: parent.verticalCenter
295+ }
296+ }
297+ Button {
298+ text: Powerd.status === Powerd.On ? "Display ON" : "Display OFF"
299+ activeFocusOnPress: false
300+ onClicked: {
301+ if (Powerd.status === Powerd.On) {
302+ Powerd.status = Powerd.Off;
303+ } else {
304+ Powerd.status = Powerd.On;
305+ }
306+ }
307+ }
308+ }
309+ }
310+
311+ UnityTestCase {
312+ id: testCase
313+ name: "OrientedShell"
314+ when: windowShown
315+
316+ property Item orientedShell: orientedShellLoader.status === Loader.Ready ? orientedShellLoader.item : null
317+ property Item shell
318+
319+ SignalSpy { id: signalSpy }
320+ SignalSpy { id: signalSpy2 }
321+
322+ Connections {
323+ id: spreadRepeaterConnections
324+ ignoreUnknownSignals : true
325+ property var itemAddedCallback: null
326+ onItemAdded: {
327+ if (itemAddedCallback) {
328+ itemAddedCallback(item);
329+ }
330+ }
331+ }
332+
333+ function init() {
334+ if (orientedShellLoader.active) {
335+ // happens for the very first test function as shell
336+ // is loaded by default
337+ tearDown();
338+ }
339+ }
340+
341+ function tearDown() {
342+ orientedShellLoader.itemDestroyed = false;
343+ orientedShellLoader.active = false;
344+
345+ tryCompare(orientedShellLoader, "status", Loader.Null);
346+ tryCompare(orientedShellLoader, "item", null);
347+ // Loader.status might be Loader.Null and Loader.item might be null but the Loader
348+ // actually took place. Likely because Loader waits until the next event loop
349+ // iteration to do its work. So to ensure the reload, we will wait until the
350+ // Shell instance gets destroyed.
351+ tryCompare(orientedShellLoader, "itemDestroyed", true);
352+
353+ // kill all (fake) running apps
354+ killApps();
355+
356+ spreadRepeaterConnections.target = null;
357+ spreadRepeaterConnections.itemAddedCallback = null;
358+ signalSpy.target = null;
359+ signalSpy.signalName = "";
360+
361+ LightDM.Greeter.authenticate(""); // reset greeter
362+ }
363+
364+ function cleanup() {
365+ tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
366+ shell = null;
367+
368+ tearDown();
369+ }
370+
371+ function test_appSupportingOnlyPrimaryOrientationMakesShellStayPut_data() {
372+ return [
373+ {tag: "mako", deviceName: "mako"},
374+ {tag: "manta", deviceName: "manta"},
375+ {tag: "flo", deviceName: "flo"}
376+ ];
377+ }
378+ function test_appSupportingOnlyPrimaryOrientationMakesShellStayPut(data) {
379+ loadShell(data.deviceName);
380+
381+ // unity8-dash supports only primary orientation and should be already running
382+ var dashAppWindow = findChild(shell, "appWindow_unity8-dash");
383+ verify(dashAppWindow);
384+ compare(ApplicationManager.focusedApplicationId, "unity8-dash");
385+ var dashApp = dashAppWindow.application
386+ verify(dashApp);
387+ compare(dashApp.rotatesWindowContents, false);
388+ compare(dashApp.supportedOrientations, Qt.PrimaryOrientation);
389+ compare(dashApp.stage, ApplicationInfoInterface.MainStage);
390+
391+ tryCompareFunction(function(){return dashApp.session.surface != null;}, true);
392+ verify(checkAppSurfaceOrientation(dashApp, root.primaryOrientationAngle));
393+
394+ compare(shell.transformRotationAngle, root.primaryOrientationAngle);
395+ rotateTo(90);
396+
397+ verify(checkAppSurfaceOrientation(dashApp, root.primaryOrientationAngle));
398+ compare(shell.transformRotationAngle, root.primaryOrientationAngle);
399+
400+ rotateTo(180);
401+
402+ verify(checkAppSurfaceOrientation(dashApp, root.primaryOrientationAngle));
403+ compare(shell.transformRotationAngle, root.primaryOrientationAngle);
404+
405+ rotateTo(270);
406+
407+ verify(checkAppSurfaceOrientation(dashApp, root.primaryOrientationAngle));
408+ compare(shell.transformRotationAngle, root.primaryOrientationAngle);
409+ }
410+
411+ function test_greeterRemainsInPrimaryOrientation_data() {
412+ return [
413+ {tag: "mako", deviceName: "mako"},
414+ {tag: "manta", deviceName: "manta"},
415+ {tag: "flo", deviceName: "flo"}
416+ ];
417+ }
418+ function test_greeterRemainsInPrimaryOrientation(data) {
419+ loadShell(data.deviceName);
420+
421+ var gmailApp = ApplicationManager.startApplication("gmail-webapp");
422+ verify(gmailApp);
423+
424+ // ensure the mock gmail-webapp is as we expect
425+ compare(gmailApp.rotatesWindowContents, false);
426+ compare(gmailApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
427+ | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
428+ compare(gmailApp.stage, ApplicationInfoInterface.MainStage);
429+
430+ // wait until it's able to rotate
431+ tryCompare(shell, "orientationChangesEnabled", true);
432+
433+ compare(shell.transformRotationAngle, root.primaryOrientationAngle);
434+ rotateTo(90);
435+ tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle + 90);
436+
437+ showGreeter();
438+
439+ tryCompare(shell, "transformRotationAngle", root.primaryOrientationAngle);
440+ rotateTo(180);
441+ compare(shell.transformRotationAngle, root.primaryOrientationAngle);
442+ rotateTo(270);
443+ compare(shell.transformRotationAngle, root.primaryOrientationAngle);
444+ rotateTo(0);
445+ compare(shell.transformRotationAngle, root.primaryOrientationAngle);
446+ }
447+
448+ function test_appRotatesWindowContents_data() {
449+ return [
450+ {tag: "mako", deviceName: "mako", orientationAngleAfterRotation: 90},
451+ {tag: "manta", deviceName: "manta", orientationAngleAfterRotation: 90},
452+ {tag: "flo", deviceName: "flo", orientationAngleAfterRotation: 180}
453+ ];
454+ }
455+ function test_appRotatesWindowContents(data) {
456+ loadShell(data.deviceName);
457+ var cameraApp = ApplicationManager.startApplication("camera-app");
458+ verify(cameraApp);
459+
460+ // ensure the mock camera-app is as we expect
461+ compare(cameraApp.fullscreen, true);
462+ compare(cameraApp.rotatesWindowContents, true);
463+ compare(cameraApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
464+ | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
465+
466+ waitUntilAppSurfaceShowsUp("camera-app")
467+
468+ var cameraSurface = cameraApp.session.surface;
469+ verify(cameraSurface);
470+
471+ var focusChangedSpy = signalSpy;
472+ focusChangedSpy.clear();
473+ focusChangedSpy.target = cameraSurface;
474+ focusChangedSpy.signalName = "activeFocusChanged";
475+ verify(focusChangedSpy.valid);
476+
477+ verify(cameraSurface.activeFocus);
478+
479+ tryCompare(shell, "orientationChangesEnabled", true);
480+
481+ var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
482+ verify(rotationStates);
483+ var immediateTransition = null
484+ for (var i = 0; i < rotationStates.transitions.length && !immediateTransition; ++i) {
485+ var transition = rotationStates.transitions[i];
486+ if (transition.objectName == "immediateTransition") {
487+ immediateTransition = transition;
488+ }
489+ }
490+ verify(immediateTransition);
491+ var transitionSpy = signalSpy2;
492+ transitionSpy.clear();
493+ transitionSpy.target = immediateTransition;
494+ transitionSpy.signalName = "runningChanged";
495+ verify(transitionSpy.valid);
496+
497+ rotateTo(90);
498+
499+ tryCompare(cameraSurface, "orientationAngle", data.orientationAngleAfterRotation);
500+
501+ // the rotation should have been immediate
502+ // false -> true -> false
503+ compare(transitionSpy.count, 2);
504+
505+ // It should retain native dimensions regardless of its rotation/orientation
506+ compare(cameraSurface.width, orientedShell.width);
507+ compare(cameraSurface.height, orientedShell.height);
508+
509+ // Surface focus shouldn't have been touched because of the rotation
510+ compare(focusChangedSpy.count, 0);
511+ }
512+
513+ /*
514+ Preconditions:
515+ Shell orientation angle matches the screen one.
516+
517+ Use case:
518+ User switches to an app that has an orientation angle different from the
519+ shell one but that also happens to support the current shell orientation
520+ angle.
521+
522+ Expected outcome:
523+ The app should get rotated to match shell's orientation angle
524+ */
525+ function test_switchingToAppWithDifferentRotation_data() {
526+ return [
527+ {tag: "mako", deviceName: "mako", shellAngleAfterRotation: 90},
528+ {tag: "manta", deviceName: "manta", shellAngleAfterRotation: 90},
529+ {tag: "flo", deviceName: "flo", shellAngleAfterRotation: 180}
530+ ];
531+ }
532+ function test_switchingToAppWithDifferentRotation(data) {
533+ loadShell(data.deviceName);
534+ var gmailApp = ApplicationManager.startApplication("gmail-webapp");
535+ verify(gmailApp);
536+
537+ // ensure the mock gmail-webapp is as we expect
538+ compare(gmailApp.rotatesWindowContents, false);
539+ compare(gmailApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
540+ | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
541+ compare(gmailApp.stage, ApplicationInfoInterface.MainStage);
542+
543+ waitUntilAppSurfaceShowsUp("gmail-webapp")
544+
545+ var musicApp = ApplicationManager.startApplication("music-app");
546+ verify(musicApp);
547+
548+ // ensure the mock music-app is as we expect
549+ compare(musicApp.rotatesWindowContents, false);
550+ compare(musicApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
551+ | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
552+ compare(musicApp.stage, ApplicationInfoInterface.MainStage);
553+
554+ waitUntilAppSurfaceShowsUp("music-app")
555+ tryCompare(shell, "orientationChangesEnabled", true);
556+
557+ rotateTo(90);
558+ tryCompare(shell, "transformRotationAngle", data.shellAngleAfterRotation);
559+
560+ performEdgeSwipeToSwitchToPreviousApp();
561+
562+ tryCompare(shell, "mainAppWindowOrientationAngle", data.shellAngleAfterRotation);
563+ compare(shell.transformRotationAngle, data.shellAngleAfterRotation);
564+ }
565+
566+ /*
567+ Preconditions:
568+ - Device supports portrait, landscape and inverted-landscape
569+
570+ Steps:
571+ 1 - Launch app that supports all orientations
572+ 2 - Rotate device to inverted-landscape
573+ 3 - See that shell gets rotated to inverted-landscape accordingly
574+ 4 - Rotate device to inverted-portrait
575+
576+ Expected outcome:
577+ Shell stays at inverted-landscape
578+
579+ Actual outcome:
580+ Shell rotates to landscape
581+
582+ Comments:
583+ Rationale being that shell should be rotated to the closest supported orientation.
584+ In that case, landscape and inverted-landscape are both 90 degrees away from the physical
585+ orientation (Screen.orientation), so they are both equally good alternatives
586+ */
587+ function test_rotateToUnsupportedDeviceOrientation(data) {
588+ loadShell("mako");
589+ var twitterApp = ApplicationManager.startApplication("twitter-webapp");
590+ verify(twitterApp);
591+
592+ // ensure the mock twitter-webapp is as we expect
593+ compare(twitterApp.rotatesWindowContents, false);
594+ compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
595+ | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
596+
597+ waitUntilAppSurfaceShowsUp("twitter-webapp")
598+
599+ rotateTo(data.rotationAngle);
600+ tryCompare(shell, "transformRotationAngle", data.rotationAngle);
601+
602+ rotateTo(180);
603+ tryCompare(shell, "transformRotationAngle", data.rotationAngle);
604+ }
605+ function test_rotateToUnsupportedDeviceOrientation_data() {
606+ return [
607+ {tag: "90", rotationAngle: 90},
608+ {tag: "270", rotationAngle: 270}
609+ ];
610+ }
611+
612+ function test_launchLandscapeOnlyAppFromPortrait() {
613+ loadShell("mako");
614+ var weatherApp = ApplicationManager.startApplication("ubuntu-weather-app");
615+ verify(weatherApp);
616+
617+ // ensure the mock app is as we expect
618+ compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
619+
620+ waitUntilAppSurfaceShowsUp("ubuntu-weather-app");
621+
622+ var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
623+ waitUntilTransitionsEnd(rotationStates);
624+
625+ tryCompareFunction(function (){return shell.transformRotationAngle === 90
626+ || shell.transformRotationAngle === 270;}, true);
627+ }
628+
629+ /*
630+ - launch an app that supports all orientations, such as twitter-webapp
631+ - wait a bit until that app is considered to have finished initializing and is thus
632+ ready to get resized/rotated
633+ - switch back to dash
634+ - rotate device to 90 degrees
635+ - Physical orientation is 90 but Shell orientation is kept at 0 because unity8-dash
636+ doesn't support such orientation
637+ - do a long right-edge drag to show the apps spread
638+ - tap on twitter-webapp
639+
640+ Shell will rotate to match the physical orientation.
641+
642+ This is a kind of tricky case as there are a few things happening at the same time:
643+ 1 - Stage switching from apps spread (phase 2) to showing the focused app (phase 0)
644+ 2 - orientation and aspect ratio (ie size) changes
645+
646+ This may trigger some corner case bugs. such as one were
647+ the greeter is not kept completely outside the shell, causing the black rect in Shell.qml
648+ have an opacity > 0.
649+ */
650+ function test_greeterStaysAwayAfterRotation() {
651+ loadShell("mako");
652+ var twitterApp = ApplicationManager.startApplication("twitter-webapp");
653+ verify(twitterApp);
654+
655+ // ensure the mock twitter-webapp is as we expect
656+ compare(twitterApp.rotatesWindowContents, false);
657+ compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
658+ | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
659+
660+ waitUntilAppSurfaceShowsUp("twitter-webapp");
661+ waitUntilAppWindowCanRotate("twitter-webapp");
662+
663+ // go back to unity8-dash
664+ performEdgeSwipeToSwitchToPreviousApp();
665+
666+ rotateTo(90);
667+ wait(1); // spin the event loop to let all bindings do their thing
668+ // should not rotat as unity8-dash doesn't support it
669+ tryCompare(shell, "transformRotationAngle", 0);
670+
671+ performEdgeSwipeToShowAppSpread();
672+
673+ // wait until things have settled
674+ var greeter = findChild(shell, "greeter");
675+ tryCompare(greeter, "animating", false);
676+
677+ var twitterDelegate = findChild(shell, "appDelegate1");
678+ compare(twitterDelegate.application.appId, "twitter-webapp");
679+ twitterDelegate.clicked();
680+
681+ // now it should finally follow the physical orientation
682+ tryCompare(shell, "transformRotationAngle", 90);
683+
684+ // greeter should remaing completely hidden
685+ tryCompare(greeter, "shown", false);
686+ }
687+
688+ function test_appInSideStageDoesntRotateOnStartUp_data() {
689+ return [
690+ {tag: "manta", deviceName: "manta"},
691+ {tag: "flo", deviceName: "flo"}
692+ ];
693+ }
694+ function test_appInSideStageDoesntRotateOnStartUp(data) {
695+ loadShell(data.deviceName);
696+
697+ var twitterDelegate = null;
698+
699+ verify(spreadRepeaterConnections.target);
700+ spreadRepeaterConnections.itemAddedCallback = function(item) {
701+ verify(item.application.appId, "twitter-webapp");
702+ twitterDelegate = item;
703+ signalSpy.target = findInvisibleChild(item, "orientationChangeAnimation");
704+ verify(signalSpy.valid);
705+ }
706+
707+ signalSpy.clear();
708+ signalSpy.target = null;
709+ signalSpy.signalName = "runningChanged";
710+
711+ var twitterApp = ApplicationManager.startApplication("twitter-webapp");
712+ verify(twitterApp);
713+
714+ // ensure the mock twitter-webapp is as we expect
715+ compare(twitterApp.rotatesWindowContents, false);
716+ compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
717+ | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
718+ compare(twitterApp.stage, ApplicationInfoInterface.SideStage);
719+
720+ // Wait until spreadRepeaterConnections hs caught the new SpreadDelegate and
721+ // set up the signalSpy target accordingly.
722+ tryCompareFunction(function(){ return signalSpy.target != null && signalSpy.valid; }, true);
723+
724+ tryCompare(twitterDelegate, "orientationChangesEnabled", true);
725+
726+ var appWindowWithShadow = findChild(twitterDelegate, "appWindowWithShadow");
727+ verify(appWindowWithShadow);
728+ tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
729+
730+ // no reason for any rotation animation to have taken place
731+ compare(signalSpy.count, 0);
732+ }
733+
734+ function test_portraitOnlyAppInSideStage_data() {
735+ return [
736+ {tag: "manta", deviceName: "manta"},
737+ {tag: "flo", deviceName: "flo"}
738+ ];
739+ }
740+ function test_portraitOnlyAppInSideStage(data) {
741+ loadShell(data.deviceName);
742+
743+ var dialerDelegate = null;
744+ verify(spreadRepeaterConnections.target);
745+ spreadRepeaterConnections.itemAddedCallback = function(item) {
746+ dialerDelegate = item;
747+ verify(item.application.appId, "dialer-app");
748+ }
749+
750+ var dialerApp = ApplicationManager.startApplication("dialer-app");
751+ verify(dialerApp);
752+
753+ // ensure the mock dialer-app is as we expect
754+ compare(dialerApp.rotatesWindowContents, false);
755+ compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
756+ compare(dialerApp.stage, ApplicationInfoInterface.SideStage);
757+
758+ tryCompareFunction(function(){ return dialerDelegate != null; }, true);
759+ tryCompare(dialerDelegate, "orientationChangesEnabled", true);
760+
761+ var appWindowWithShadow = findChild(dialerDelegate, "appWindowWithShadow");
762+ verify(appWindowWithShadow);
763+ tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
764+
765+ // app must have portrait aspect ratio
766+ verify(appWindowWithShadow.width < appWindowWithShadow.height);
767+
768+ compare(appWindowWithShadow.rotation, 0);
769+
770+ verifyAppWindowWithinSpreadDelegateBoundaries(dialerDelegate);
771+
772+ // shell should remain in its primery orientation as the app in the main stage
773+ // is the one that dictates its orientation. In this case it's unity8-dash
774+ // which supports only primary orientation
775+ compare(shell.orientation, orientedShell.primaryOrientation);
776+ }
777+
778+ function test_sideStageAppsRemainPortraitInSpread_data() {
779+ return [
780+ {tag: "manta", deviceName: "manta"},
781+ {tag: "flo", deviceName: "flo"}
782+ ];
783+ }
784+ function test_sideStageAppsRemainPortraitInSpread(data) {
785+ loadShell(data.deviceName);
786+
787+
788+ ////
789+ // Launch dialer
790+ var dialerDelegate = null;
791+ verify(spreadRepeaterConnections.target);
792+ spreadRepeaterConnections.itemAddedCallback = function(item) {
793+ dialerDelegate = item;
794+ verify(item.application.appId, "dialer-app");
795+ }
796+
797+ var dialerApp = ApplicationManager.startApplication("dialer-app");
798+ verify(dialerApp);
799+
800+ // ensure the mock dialer-app is as we expect
801+ compare(dialerApp.rotatesWindowContents, false);
802+ compare(dialerApp.supportedOrientations, Qt.PortraitOrientation | Qt.InvertedPortraitOrientation);
803+ compare(dialerApp.stage, ApplicationInfoInterface.SideStage);
804+
805+ tryCompareFunction(function(){ return dialerDelegate != null; }, true);
806+ waitUntilAppDelegateIsFullyInit(dialerDelegate);
807+
808+
809+ ////
810+ // Launch twitter
811+ var twitterDelegate = null;
812+ spreadRepeaterConnections.itemAddedCallback = function(item) {
813+ twitterDelegate = item;
814+ verify(item.application.appId, "twitter-webapp");
815+ }
816+
817+ var twitterApp = ApplicationManager.startApplication("twitter-webapp");
818+ verify(twitterApp);
819+
820+ // ensure the mock twitter-webapp is as we expect
821+ compare(twitterApp.rotatesWindowContents, false);
822+ compare(twitterApp.supportedOrientations, Qt.PortraitOrientation | Qt.LandscapeOrientation
823+ | Qt.InvertedPortraitOrientation | Qt.InvertedLandscapeOrientation);
824+ compare(twitterApp.stage, ApplicationInfoInterface.SideStage);
825+
826+ tryCompareFunction(function(){ return twitterDelegate != null; }, true);
827+ waitUntilAppDelegateIsFullyInit(twitterDelegate);
828+
829+ ////
830+ // Edge swipe to show spread and check orientations
831+
832+ performEdgeSwipeToShowAppSpread();
833+
834+ {
835+ var appWindowWithShadow = findChild(dialerDelegate, "appWindowWithShadow");
836+ verify(appWindowWithShadow);
837+ tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
838+ compare(appWindowWithShadow.width, dialerDelegate.width);
839+ compare(appWindowWithShadow.height, dialerDelegate.height);
840+ compare(appWindowWithShadow.rotation, 0);
841+ }
842+ {
843+ var appWindowWithShadow = findChild(twitterDelegate, "appWindowWithShadow");
844+ verify(appWindowWithShadow);
845+ tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
846+ compare(appWindowWithShadow.width, twitterDelegate.width);
847+ compare(appWindowWithShadow.height, twitterDelegate.height);
848+ compare(appWindowWithShadow.rotation, 0);
849+ }
850+
851+ verifyAppWindowWithinSpreadDelegateBoundaries(dialerDelegate);
852+ verifyAppWindowWithinSpreadDelegateBoundaries(twitterDelegate);
853+ }
854+
855+ function test_launchedAppHasActiveFocus_data() {
856+ return [
857+ {tag: "mako", deviceName: "mako"},
858+ {tag: "manta", deviceName: "manta"},
859+ {tag: "flo", deviceName: "flo"}
860+ ];
861+ }
862+ function test_launchedAppHasActiveFocus(data) {
863+ loadShell(data.deviceName);
864+
865+ var gmailApp = ApplicationManager.startApplication("gmail-webapp");
866+ verify(gmailApp);
867+ waitUntilAppSurfaceShowsUp("gmail-webapp")
868+
869+ verify(gmailApp.session.surface);
870+
871+ tryCompare(gmailApp.session.surface, "activeFocus", true);
872+ }
873+
874+ function test_launchLandscapeOnlyAppOverPortraitOnlyDashThenSwitchToDash() {
875+ loadShell("mako");
876+
877+ // starts as portrait, as unity8-dash is portrait only
878+ tryCompare(shell, "transformRotationAngle", 0);
879+
880+ var weatherApp = ApplicationManager.startApplication("ubuntu-weather-app");
881+ verify(weatherApp);
882+
883+ // ensure the mock app is as we expect
884+ compare(weatherApp.supportedOrientations, Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation);
885+
886+ waitUntilAppSurfaceShowsUp("ubuntu-weather-app");
887+
888+ // should have rotated to landscape
889+ tryCompareFunction(function () { return shell.transformRotationAngle == 270
890+ || shell.transformRotationAngle == 90; }, true);
891+
892+ var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
893+ waitUntilTransitionsEnd(rotationStates);
894+
895+ performLeftEdgeSwipeToSwitchToDash();
896+
897+ // Should be back to portrait
898+ tryCompare(shell, "transformRotationAngle", 0);
899+ }
900+
901+ // angle - rotation angle in degrees clockwise, relative to the primary orientation.
902+ function rotateTo(angle) {
903+ switch (angle) {
904+ case 0:
905+ rotate0Button.clicked();
906+ break;
907+ case 90:
908+ rotate90Button.clicked();
909+ break;
910+ case 180:
911+ rotate180Button.clicked();
912+ break;
913+ case 270:
914+ rotate270Button.clicked();
915+ break;
916+ default:
917+ verify(false);
918+ }
919+
920+ var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
921+ waitUntilTransitionsEnd(rotationStates);
922+ }
923+
924+ function waitUntilAppDelegateIsFullyInit(spreadDelegate) {
925+ tryCompare(spreadDelegate, "orientationChangesEnabled", true);
926+
927+ var appWindowWithShadow = findChild(spreadDelegate, "appWindowWithShadow");
928+ verify(appWindowWithShadow);
929+ tryCompare(appWindowWithShadow, "state", "keepSceneRotation");
930+
931+ var appWindowStates = findInvisibleChild(appWindowWithShadow, "applicationWindowStateGroup");
932+ verify(appWindowStates);
933+ tryCompare(appWindowStates, "state", "surface");
934+ }
935+
936+ function waitUntilAppSurfaceShowsUp(appId) {
937+ var appWindow = findChild(shell, "appWindow_" + appId);
938+ verify(appWindow);
939+ var appWindowStates = findInvisibleChild(appWindow, "applicationWindowStateGroup");
940+ verify(appWindowStates);
941+ tryCompare(appWindowStates, "state", "surface");
942+ }
943+
944+ function waitUntilAppWindowCanRotate(appId) {
945+ var appWindow = findChild(shell, "appWindow_" + appId);
946+ verify(appWindow);
947+ tryCompare(appWindow, "orientationChangesEnabled", true);
948+ }
949+
950+ function waitUntilShellIsInOrientation(orientation) {
951+ tryCompare(shell, "orientation", orientation);
952+ var rotationStates = findInvisibleChild(orientedShell, "rotationStates");
953+ waitUntilTransitionsEnd(rotationStates);
954+ }
955+
956+ function performLeftEdgeSwipeToSwitchToDash() {
957+ var spreadView = findChild(shell, "spreadView");
958+ var swipeLength = spreadView.width * 0.7;
959+
960+ var touchStartX = 1;
961+ var touchStartY = shell.height / 2;
962+ touchFlick(shell,
963+ touchStartX, touchStartY,
964+ touchStartX + swipeLength, touchStartY);
965+
966+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
967+ }
968+
969+ function performEdgeSwipeToSwitchToPreviousApp() {
970+ // swipe just enough to ensure an app switch action.
971+ // If we swipe too much we will trigger the spread mode
972+ // and we don't want that.
973+ var spreadView = findChild(shell, "spreadView");
974+ verify(spreadView);
975+
976+ verify(ApplicationManager.count >= 2);
977+ var previousApp = ApplicationManager.get(1);
978+
979+ var touchStartX = shell.width - 1;
980+ var touchStartY = shell.height / 2;
981+
982+ var condition;
983+ if (applicationArguments.deviceName === "phone") {
984+ condition = function() {
985+ return spreadView.shiftedContentX > units.gu(2) &&
986+ spreadView.shiftedContentX < spreadView.positionMarker1 * spreadView.width;
987+ };
988+ } else {
989+ condition = function() {
990+ return spreadView.shiftedContentX > spreadView.width * spreadView.positionMarker1
991+ && spreadView.shiftedContentX < spreadView.width * spreadView.positionMarker2;
992+ };
993+ }
994+
995+ touchDragUntil(shell,
996+ touchStartX, touchStartY,
997+ -units.gu(1), 0,
998+ condition);
999+
1000+ // ensure the app switch animation has ended
1001+ tryCompare(spreadView, "shiftedContentX", 0);
1002+
1003+ compare(ApplicationManager.get(0).appId, previousApp.appId);
1004+ }
1005+
1006+ function performEdgeSwipeToShowAppSpread() {
1007+ var touchStartY = shell.height / 2;
1008+ touchFlick(shell,
1009+ shell.width - 1, touchStartY,
1010+ 0, touchStartY);
1011+
1012+ var spreadView = findChild(shell, "spreadView");
1013+ verify(spreadView);
1014+ tryCompare(spreadView, "phase", 2);
1015+ tryCompare(spreadView, "flicking", false);
1016+ tryCompare(spreadView, "moving", false);
1017+ }
1018+
1019+ function showPowerDialog() {
1020+ var dialogs = findChild(orientedShell, "dialogs");
1021+ var dialogsPrivate = findInvisibleChild(dialogs, "dialogsPrivate");
1022+ dialogsPrivate.showPowerDialog();
1023+ }
1024+
1025+ function verifyAppWindowWithinSpreadDelegateBoundaries(spreadDelegate) {
1026+ var appWindowWithShadow = findChild(spreadDelegate, "appWindowWithShadow");
1027+ verify(appWindowWithShadow);
1028+
1029+ var windowInDelegateCoords = appWindowWithShadow.mapToItem(spreadDelegate, 0, 0,
1030+ appWindowWithShadow.width, appWindowWithShadow.height);
1031+
1032+ compare(windowInDelegateCoords.x, 0);
1033+ compare(windowInDelegateCoords.y, 0);
1034+ compare(windowInDelegateCoords.width, spreadDelegate.width);
1035+ compare(windowInDelegateCoords.height, spreadDelegate.height);
1036+ }
1037+
1038+ function swipeAwayGreeter() {
1039+ var greeter = findChild(shell, "greeter");
1040+ tryCompare(greeter, "fullyShown", true);
1041+
1042+ var touchX = shell.width - (shell.edgeSize / 2);
1043+ var touchY = shell.height / 2;
1044+ touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY);
1045+
1046+ // wait until the animation has finished
1047+ tryCompare(greeter, "shown", false);
1048+ waitForRendering(greeter);
1049+ }
1050+
1051+ function showGreeter() {
1052+ LightDM.Greeter.showGreeter();
1053+ // wait until the animation has finished
1054+ var greeter = findChild(shell, "greeter");
1055+ tryCompare(greeter, "fullyShown", true);
1056+ }
1057+
1058+ function killApps() {
1059+ while (ApplicationManager.count > 1) {
1060+ var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
1061+ ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
1062+ }
1063+ compare(ApplicationManager.count, 1)
1064+ }
1065+
1066+ function loadShell(deviceName) {
1067+ applicationArguments.deviceName = deviceName;
1068+
1069+ // reload our test subject to get it in a fresh state once again
1070+ orientedShellLoader.active = true;
1071+
1072+ tryCompare(orientedShellLoader, "status", Loader.Ready);
1073+ removeTimeConstraintsFromDirectionalDragAreas(orientedShellLoader.item);
1074+
1075+ shell = findChild(orientedShell, "shell");
1076+
1077+ tryCompare(shell, "enabled", true); // enabled by greeter when ready
1078+
1079+ waitUntilShellIsInOrientation(root.physicalOrientation0);
1080+
1081+ waitForGreeterToStabilize();
1082+
1083+ swipeAwayGreeter();
1084+
1085+ var spreadRepeater = findChild(shell, "spreadRepeater");
1086+ if (spreadRepeater) {
1087+ spreadRepeaterConnections.target = spreadRepeater;
1088+ }
1089+ }
1090+
1091+ function waitForGreeterToStabilize() {
1092+ var greeter = findChild(shell, "greeter");
1093+ verify(greeter);
1094+
1095+ var loginList = findChild(greeter, "loginList");
1096+ // Only present in WideView
1097+ if (loginList) {
1098+ var userList = findChild(loginList, "userList");
1099+ verify(userList);
1100+ tryCompare(userList, "movingInternally", false);
1101+ }
1102+ }
1103+
1104+ // expectedAngle is in orientedShell's coordinate system
1105+ function checkAppSurfaceOrientation(app, expectedAngle) {
1106+ var surface = app.session.surface;
1107+ if (!surface) {
1108+ console.warn("no surface");
1109+ return false;
1110+ }
1111+
1112+ if (!itemIsChildOfOrientedShell(surface)) {
1113+ console.warn("surface not a child of OrientedShell");
1114+ return false;
1115+ }
1116+
1117+ var topMargin = 0.;
1118+ if (!app.fullscreen) {
1119+ var appsDisplayLoader = findChild(shell, "applicationsDisplayLoader");
1120+ verify(appsDisplayLoader);
1121+ verify(appsDisplayLoader.item);
1122+ verify(appsDisplayLoader.item.maximizedAppTopMargin !== undefined);
1123+ topMargin = appsDisplayLoader.item.maximizedAppTopMargin;
1124+ }
1125+
1126+ var point = surface.mapToItem(orientedShell, 0, 0);
1127+
1128+ switch (expectedAngle) {
1129+ case 0:
1130+ return point.x === 0. && point.y === topMargin;
1131+ case 90:
1132+ return point.x === orientedShell.width - topMargin && point.y === 0;
1133+ case 180:
1134+ return point.x === orientedShell.width && point.y === orientedShell.height - topMargin;
1135+ default: // 270
1136+ return point.x === topMargin && point.y === orientedShell.height;
1137+ }
1138+ }
1139+
1140+ function itemIsChildOfOrientedShell(item) {
1141+ var parent = item.parent;
1142+ var found = false;
1143+ while (parent && !found) {
1144+ found = parent === orientedShell;
1145+ parent = parent.parent;
1146+ }
1147+ return found;
1148+ }
1149+ }
1150+
1151+}
tests/qmltests/tst_Shell.qml+15−69
@@ -1,9 +1,6 @@
1/*
1/*
2 * Copyright (C) 2013-2015 Canonical, Ltd.
2 * Copyright (C) 2013-2015 Canonical, Ltd.
3 *
3 *
4− * Authors:
5− * Daniel d'Andrada <daniel.dandrada@canonical.com>
6− *
7 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
6 * the Free Software Foundation; version 3.
@@ -48,22 +45,6 @@ Rectangle {
48 shellLoader.active = true;
45 shellLoader.active = true;
49 }
46 }
50
47
51− QtObject {
52− id: applicationArguments
53−
54− function hasGeometry() {
55− return false;
56− }
57−
58− function width() {
59− return 0;
60− }
61−
62− function height() {
63− return 0;
64− }
65− }
66−
67 Item {
48 Item {
68 anchors.left: root.left
49 anchors.left: root.left
69 anchors.right: controls.left
50 anchors.right: controls.left
@@ -99,8 +80,10 @@ Rectangle {
99 property bool itemDestroyed: false
80 property bool itemDestroyed: false
100 sourceComponent: Component {
81 sourceComponent: Component {
101 Shell {
82 Shell {
102− property string indicatorProfile: "phone"
83+ usageScenario: "phone"
103−
84+ orientation: Qt.PortraitOrientation
85+ primaryOrientation: Qt.PortraitOrientation
86+ nativeOrientation: Qt.PortraitOrientation
104 Component.onDestruction: {
87 Component.onDestruction: {
105 shellLoader.itemDestroyed = true;
88 shellLoader.itemDestroyed = true;
106 }
89 }
@@ -632,15 +615,6 @@ Rectangle {
632 tryCompare(item, "visible", false);
615 tryCompare(item, "visible", false);
633 }
616 }
634
617
635− // wait until any transition animation has finished
636− function waitUntilTransitionsEnd(stateGroup) {
637− var transitions = stateGroup.transitions;
638− for (var i = 0; i < transitions.length; ++i) {
639− var transition = transitions[i];
640− tryCompare(transition, "running", false, 2000);
641− }
642− }
643−
644 // Wait until the ApplicationWindow for the given Application object is fully loaded
618 // Wait until the ApplicationWindow for the given Application object is fully loaded
645 // (ie, the real surface has replaced the splash screen)
619 // (ie, the real surface has replaced the splash screen)
646 function waitUntilAppWindowIsFullyLoaded(app) {
620 function waitUntilAppWindowIsFullyLoaded(app) {
@@ -798,37 +772,6 @@ Rectangle {
798 removeTimeConstraintsFromDirectionalDragAreas(greeter);
772 removeTimeConstraintsFromDirectionalDragAreas(greeter);
799 }
773 }
800
774
801− function test_greeterDoesNotChangeIndicatorProfile() {
802− loadShell("phone");
803− swipeAwayGreeter();
804− var panel = findChild(shell, "panel");
805− tryCompare(panel.indicators.indicatorsModel, "profile", shell.indicatorProfile);
806−
807− showGreeter();
808− tryCompare(panel.indicators.indicatorsModel, "profile", shell.indicatorProfile);
809−
810− LightDM.Greeter.hideGreeter();
811− tryCompare(panel.indicators.indicatorsModel, "profile", shell.indicatorProfile);
812− }
813−
814− function test_shellProfileChangesReachIndicators() {
815− loadShell("phone");
816− swipeAwayGreeter();
817− var panel = findChild(shell, "panel");
818−
819− shell.indicatorProfile = "test1";
820− for (var i = 0; i < panel.indicators.indicatorsModel.count; ++i) {
821− var properties = panel.indicators.indicatorsModel.data(i, IndicatorsModelRole.IndicatorProperties);
822− verify(properties["menuObjectPath"].substr(-5), "test1");
823− }
824−
825− shell.indicatorProfile = "test2";
826− for (var i = 0; i < panel.indicators.indicatorsModel.count; ++i) {
827− var properties = panel.indicators.indicatorsModel.data(i, IndicatorsModelRole.IndicatorProperties);
828− verify(properties["menuObjectPath"].substr(-5), "test2");
829− }
830− }
831−
832 function test_focusRequestedHidesGreeter() {
775 function test_focusRequestedHidesGreeter() {
833 loadShell("phone");
776 loadShell("phone");
834 swipeAwayGreeter();
777 swipeAwayGreeter();
@@ -1003,9 +946,14 @@ Rectangle {
1003 loadShell("phone");
946 loadShell("phone");
1004 swipeAwayGreeter();
947 swipeAwayGreeter();
1005 var topmostSpreadDelegate = findChild(shell, "appDelegate0");
948 var topmostSpreadDelegate = findChild(shell, "appDelegate0");
949+ verify(topmostSpreadDelegate);
950+
951+ waitUntilFocusedApplicationIsShowingItsSurface();
952+
1006 var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
953 var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
1007− var rightEdgeDragArea = findChild(shell, "spreadDragArea");
954+ verify(topmostSurface);
1008
955
956+ var rightEdgeDragArea = findChild(shell, "spreadDragArea");
1009 topmostSurface.touchPressCount = 0;
957 topmostSurface.touchPressCount = 0;
1010 topmostSurface.touchReleaseCount = 0;
958 topmostSurface.touchReleaseCount = 0;
1011
959
@@ -1092,13 +1040,11 @@ Rectangle {
1092 // left edge drag area.
1040 // left edge drag area.
1093 {
1041 {
1094 var buttonShowDashHome = findChild(launcher, "buttonShowDashHome");
1042 var buttonShowDashHome = findChild(launcher, "buttonShowDashHome");
1095− var startPos = buttonShowDashHome.mapToItem(shell,
1043+ touchFlick(buttonShowDashHome,
1096− buttonShowDashHome.width * 0.2,
1044+ buttonShowDashHome.width * 0.2, /* startPos.x */
1097− buttonShowDashHome.height * 0.8);
1045+ buttonShowDashHome.height * 0.8, /* startPos.y */
1098− var endPos = buttonShowDashHome.mapToItem(shell,
1046+ buttonShowDashHome.width * 0.8, /* endPos.x */
1099− buttonShowDashHome.width * 0.8,
1047+ buttonShowDashHome.height * 0.2 /* endPos.y */);
1100− buttonShowDashHome.height * 0.2);
1101− touchFlick(shell, startPos.x, startPos.y, endPos.x, endPos.y);
1102 }
1048 }
1103
1049
1104 compare(launcherShowDashHomeSpy.count, 1);
1050 compare(launcherShowDashHomeSpy.count, 1);
tests/qmltests/tst_ShellWithPin.qml+6−10
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014-2015 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -69,8 +69,6 @@ Item {
69 property bool itemDestroyed: false
69 property bool itemDestroyed: false
70 sourceComponent: Component {
70 sourceComponent: Component {
71 Shell {
71 Shell {
72− property string indicatorProfile: "phone"
73−
74 Component.onDestruction: {
72 Component.onDestruction: {
75 shellLoader.itemDestroyed = true
73 shellLoader.itemDestroyed = true
76 }
74 }
@@ -397,24 +395,22 @@ Item {
397 var applicationsDisplayLoader = findChild(shell, "applicationsDisplayLoader")
395 var applicationsDisplayLoader = findChild(shell, "applicationsDisplayLoader")
398
396
399 // We start in phone mode
397 // We start in phone mode
400− tryCompare(shell, "sideStageEnabled", false)
398+ compare(shell.usageScenario, "phone");
401− tryCompare(applicationsDisplayLoader, "tabletMode", false)
399+ compare(applicationsDisplayLoader.usageScenario, "phone");
402
400
403 var lockscreen = findChild(shell, "lockscreen")
401 var lockscreen = findChild(shell, "lockscreen")
404 lockscreen.emergencyCall()
402 lockscreen.emergencyCall()
405 confirmLockedApp("dialer-app")
403 confirmLockedApp("dialer-app")
406
404
407 // OK, we're in. Now try (but fail) to switch to tablet mode
405 // OK, we're in. Now try (but fail) to switch to tablet mode
408− shell.tablet = true
406+ shell.usageScenario = "tablet";
409− tryCompare(shell, "sideStageEnabled", true)
410− tryCompare(applicationsDisplayLoader, "tabletMode", false)
407+ compare(applicationsDisplayLoader.usageScenario, "phone");
411
408
412 // And when we kill the app, we go back to locked tablet mode
409 // And when we kill the app, we go back to locked tablet mode
413 killApps()
410 killApps()
414 var greeter = findChild(shell, "greeter")
411 var greeter = findChild(shell, "greeter")
415 tryCompare(greeter, "fullyShown", true)
412 tryCompare(greeter, "fullyShown", true)
416− tryCompare(shell, "sideStageEnabled", true)
417− tryCompare(applicationsDisplayLoader, "tabletMode", true)
413+ compare(applicationsDisplayLoader.usageScenario, "tablet");
418 }
414 }
419
415
420 function test_emergencyDialerIncoming() {
416 function test_emergencyDialerIncoming() {
tests/utils/modules/Unity/Test/UnityTestCase.qml+53−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013-2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -308,6 +308,48 @@ TestCase {
308 }
308 }
309 }
309 }
310
310
311+ // perform a drag in the given direction until the given condition is true
312+ // The condition is a function to be evaluated after every step
313+ function touchDragUntil(item, startX, startY, stepX, stepY, condition) {
314+
315+ var root = fetchRootItem(item);
316+ var pos = item.mapToItem(root, startX, startY);
317+
318+ // convert step to scene coords
319+ {
320+ var stepStart = item.mapToItem(root, 0, 0);
321+ var stepEnd = item.mapToItem(root, stepX, stepY);
322+ }
323+ stepX = stepEnd.x - stepStart.x;
324+ stepY = stepEnd.y - stepStart.y;
325+
326+ var event = touchEvent(item)
327+ event.press(0 /* touchId */, pos.x, pos.y)
328+ event.commit()
329+
330+ // we have to stop at some point
331+ var maxSteps = 100;
332+ var stepsDone = 0;
333+
334+ while (!condition() && stepsDone < maxSteps) {
335+ wait(25);
336+ fakeDateTime.currentTimeMs += 25;
337+
338+ pos.x += stepX;
339+ pos.y += stepY;
340+
341+ event = touchEvent(item);
342+ event.move(0 /* touchId */, pos.x, pos.y);
343+ event.commit();
344+
345+ stepsDone += 1;
346+ }
347+
348+ event = touchEvent(item)
349+ event.release(0 /* touchId */, pos.x, pos.y)
350+ event.commit()
351+ }
352+
311 function touchPinch(item, x1Start, y1Start, x1End, y1End, x2Start, y2Start, x2End, y2End) {
353 function touchPinch(item, x1Start, y1Start, x1End, y1End, x2Start, y2Start, x2End, y2End) {
312 // Make sure the item is rendered
354 // Make sure the item is rendered
313 waitForRendering(item);
355 waitForRendering(item);
@@ -421,4 +463,14 @@ TestCase {
421 return qtest_results.waitForRendering(item, timeout);
463 return qtest_results.waitForRendering(item, timeout);
422 }
464 }
423
465
466+ /*
467+ Wait until any transition animation has finished for the given StateGroup or Item
468+ */
469+ function waitUntilTransitionsEnd(stateGroup) {
470+ var transitions = stateGroup.transitions;
471+ for (var i = 0; i < transitions.length; ++i) {
472+ var transition = transitions[i];
473+ tryCompare(transition, "running", false, 2000);
474+ }
475+ }
424}
476}