on xenial help sign in
Implement the right edge app switching with an App Spread.

* Reworks interaction with ApplicationManager (This will end SurfaceFlinger support) * Reworks Stage and SideStage * Implements the App Spread for the Phone form factor right edge * Reimplements the overlay mode side stage for the tablet form factor Fixes: 1297239

commit091e176683c0904e70267ce0ff3e7ccff7370cec authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 1 Apr 2014, 22:55 (13 years ago) parent39654125c0b84f
46 files changed+2385−864
debian/changelog+7 debian/control+7−4 debian/unity8.install+1−1 plugins/Utils/CMakeLists.txt+2−1 plugins/Utils/easingcurve.cpp+67 plugins/Utils/easingcurve.h+70 plugins/Utils/plugin.cpp+2 qml/CMakeLists.txt+1−1 qml/Components/ApplicationManagerWrapper.qml−169 qml/Components/ApplicationScreenshot.qml−61 qml/Components/ApplicationsModelStageFiltered.qml−49 qml/Components/ResponsiveFlowView.qml+3−10 qml/Dash/Apps/RunningApplicationTile.qml+14−24 qml/Dash/Apps/RunningApplicationsGrid.qml+5−20 qml/Dash/DashApps.qml+4−5 qml/Dash/GenericScopeView.qml+2−2 qml/Launcher/Launcher.qml+2−1 qml/Panel/Panel.qml+1−1 qml/Shell.qml+201−303 qml/SideStage/SideStage.qml−73 qml/Stages/PhoneStage.qml+499 qml/SideStage/SidestageHandle.qml → qml/Stages/SidestageHandle.qml qml/Stages/SpreadDelegate.qml+55 qml/Stages/StageWithSideStage.qml+407 qml/Stages/SwitchingApplicationImage.qml+81 qml/Stages/TransformedSpreadDelegate.qml+327 qml/Stages/graphics/dropshadow.png qml/SideStage/graphics/sidestage_handle@20.png → qml/Stages/graphics/sidestage_handle@20.png qml/SideStage/graphics/sidestage_handle@20.sci → qml/Stages/graphics/sidestage_handle@20.sci tests/autopilot/unity8/shell/emulators/dash.py+1−4 tests/autopilot/unity8/shell/emulators/main_window.py+1−1 tests/mocks/Unity/Application/ApplicationInfo.cpp+9 tests/mocks/Unity/Application/ApplicationInfo.h+2 tests/mocks/Unity/Application/ApplicationManager.cpp+109−3 tests/mocks/Unity/Application/ApplicationManager.h+16 tests/mocks/Unity/Application/ApplicationScreenshotProvider.cpp+74 tests/mocks/Unity/Application/ApplicationScreenshotProvider.h+34 tests/mocks/Unity/Application/CMakeLists.txt+1 tests/mocks/Unity/Application/plugin.cpp+18−3 tests/mocks/Unity/Application/plugin.h+1 tests/plugins/Unity/Launcher/launchermodeltest.cpp+5 tests/qmltests/CMakeLists.txt+1−1 tests/qmltests/Components/tst_ResponsiveFlowView.qml+1−2 tests/qmltests/Dash/Apps/tst_RunningApplicationsGrid.qml+50−117 tests/qmltests/Stages/tst_PhoneStage.qml+288 tests/qmltests/tst_Shell.qml+16−8
debian/changelog+7
@@ -1,3 +1,10 @@
1+unity8 (7.85-0ubuntu1) UNRELEASED; urgency=medium
2+
3+ * Bump version to ensure incompatibility with previous Unity.Application
4+ implementations.
5+
6+ -- Michał Sawicz <michal.sawicz@canonical.com> Mon, 31 Mar 2014 14:44:30 +0100
7+
18unity8 (7.84+14.04.20140327.1-0ubuntu2) trusty; urgency=medium
29
310 * For now, have libunity-private depending on libunity-core-6.0-9 as the
debian/control+7−4
@@ -17,7 +17,7 @@ Build-Depends: cmake,
1717 libnih-dev,
1818 libpulse-dev,
1919 libqmenumodel-dev (>= 0.2.7),
20− libunity-api-dev (>= 7.80.4),
20+ libunity-api-dev (>= 7.80.6),
2121 libunity-mir-dev,
2222 libupstart-dev,
2323 libusermetricsoutput1-dev,
@@ -83,9 +83,10 @@ Depends: gsettings-desktop-schemas,
8383 qtdeclarative5-ubuntu-ui-toolkit-plugin,
8484 qtdeclarative5-unity-notifications-plugin | unity-notifications-impl,
8585 qtdeclarative5-xmllistmodel-plugin,
86+ unity-application-impl-2,
8687 unity-launcher-impl-3,
8788 unity-notifications-impl-2,
88− unity8-fake-env | qtubuntu-shell,
89+ unity8-fake-env | unity-application-impl,
8990 unity8-private (= ${binary:Version}),
9091 unity8-private | unity-launcher-impl,
9192 unity-plugin-scopes | unity-scopes-impl,
@@ -97,7 +98,8 @@ Depends: gsettings-desktop-schemas,
9798Recommends: unity-scope-click,
9899 unity-scope-mediascanner2,
99100 unity-scope-scopes,
100−Breaks: indicator-network (<< 0.5.1)
101+Breaks: indicator-network (<< 0.5.1),
102+ ubuntu-touch-session (<< 0.107),
101103Replaces: ubuntu-touch-session (<< 0.82~)
102104Description: Unity 8 shell
103105 The Unity 8 shell is the primary user interface for Ubuntu devices.
@@ -134,7 +136,8 @@ Multi-Arch: same
134136Pre-Depends: ${misc:Pre-Depends},
135137Depends: ${misc:Depends},
136138 ${shlibs:Depends},
137−Provides: qtubuntu-shell,
139+Provides: unity-application-impl,
140+ unity-application-impl-2,
138141Description: Fake environment for running Unity 8 shell
139142 Provides fake implementations of some QML modules used by Unity 8 shell
140143 (e.g Ubuntu.Application) so that you can run it in a sandboxed environment.
debian/unity8.install+1−1
@@ -10,6 +10,6 @@ usr/share/unity8/Launcher
1010usr/share/unity8/Notifications
1111usr/share/unity8/Panel
1212usr/share/unity8/Shell.qml
13−usr/share/unity8/SideStage
13+usr/share/unity8/Stages
1414usr/share/unity8/graphics
1515data/unity8.conf usr/share/upstart/sessions/
plugins/Utils/CMakeLists.txt+2−1
@@ -18,6 +18,7 @@ set(QMLPLUGIN_SRC
1818 qsortfilterproxymodelqml.cpp
1919 timeformatter.cpp
2020 unitymenumodelpaths.cpp
21+ easingcurve.cpp
2122 plugin.cpp
2223 )
2324
@@ -33,7 +34,7 @@ target_link_libraries(Utils-qml ${GIO_LDFLAGS})
3334# files directly in targets.
3435set_target_properties(Utils-qml PROPERTIES COMPILE_FLAGS -fvisibility=default)
3536
36−qt5_use_modules(Utils-qml Qml Quick DBus Network XmlPatterns Concurrent)
37+qt5_use_modules(Utils-qml Qml Quick DBus Network XmlPatterns Gui Concurrent)
3738
3839# export the qmldir qmltypes and plugin files
3940export_qmlfiles(Utils Utils)
plugins/Utils/easingcurve.cppnew file+67
@@ -0,0 +1,67 @@
1+/*
2+ * Copyright 2014 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+ * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17+*/
18+
19+#include "easingcurve.h"
20+
21+
22+EasingCurve::EasingCurve(QObject *parent):
23+ QObject(parent)
24+{
25+
26+}
27+
28+QEasingCurve::Type EasingCurve::type() const
29+{
30+ return m_easingCurve.type();
31+}
32+
33+void EasingCurve::setType(const QEasingCurve::Type &type)
34+{
35+ m_easingCurve.setType(type);
36+ Q_EMIT typeChanged();
37+}
38+
39+qreal EasingCurve::period() const
40+{
41+ return m_easingCurve.period();
42+}
43+
44+void EasingCurve::setPeriod(qreal period)
45+{
46+ m_easingCurve.setPeriod(period);
47+ Q_EMIT periodChanged();
48+}
49+
50+qreal EasingCurve::progress() const
51+{
52+ return m_progress;
53+}
54+
55+void EasingCurve::setProgress(qreal progress)
56+{
57+ if (m_progress != progress) {
58+ m_progress = progress;
59+ m_value = m_easingCurve.valueForProgress(m_progress);
60+ Q_EMIT progressChanged();
61+ }
62+}
63+
64+qreal EasingCurve::value() const
65+{
66+ return m_value;
67+}
plugins/Utils/easingcurve.hnew file+70
@@ -0,0 +1,70 @@
1+/*
2+ * Copyright 2014 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+ * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17+*/
18+
19+#ifndef EASINGCURVE_H
20+#define EASINGCURVE_H
21+
22+#include <QObject>
23+#include <QEasingCurve>
24+
25+/**
26+ * @brief The EasingCurve class
27+ *
28+ * This class exposes the QEasingCurve C++ API to QML.
29+ * This is useful for user interactive animations. While the QML Animation types
30+ * all require a "from", "to" and "duration", this one is based on "period" and
31+ * "progress". So you can control the position of the aimation by changing the
32+ * progress, also going back and forward in the animation. Depending on the type
33+ * of the easing curve, value will return the transformed progress.
34+ */
35+
36+class EasingCurve: public QObject
37+{
38+ Q_OBJECT
39+ Q_ENUMS(QEasingCurve::Type)
40+ Q_PROPERTY(QEasingCurve::Type type READ type WRITE setType NOTIFY typeChanged)
41+ Q_PROPERTY(qreal period READ period WRITE setPeriod NOTIFY periodChanged)
42+ Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged)
43+ Q_PROPERTY(qreal value READ value NOTIFY progressChanged)
44+
45+public:
46+ EasingCurve(QObject *parent = 0);
47+
48+ QEasingCurve::Type type() const;
49+ void setType(const QEasingCurve::Type &type);
50+
51+ qreal period() const;
52+ void setPeriod(qreal period);
53+
54+ qreal progress() const;
55+ void setProgress(qreal progress);
56+
57+ qreal value() const;
58+
59+Q_SIGNALS:
60+ void typeChanged();
61+ void periodChanged();
62+ void progressChanged();
63+
64+private:
65+ QEasingCurve m_easingCurve;
66+ qreal m_progress;
67+ qreal m_value;
68+};
69+
70+#endif
plugins/Utils/plugin.cpp+2
@@ -32,6 +32,7 @@
3232#include "qsortfilterproxymodelqml.h"
3333#include "timeformatter.h"
3434#include "unitymenumodelpaths.h"
35+#include "easingcurve.h"
3536
3637static const char* BOTTOM_BAR_VISIBILITY_COMMUNICATOR_DBUS_PATH = "/BottomBarVisibilityCommunicator";
3738static const char* DBUS_SERVICE = "com.canonical.Shell.BottomBarVisibilityCommunicator";
@@ -46,6 +47,7 @@ void UtilsPlugin::registerTypes(const char *uri)
4647 qmlRegisterType<TimeFormatter>(uri, 0, 1, "TimeFormatter");
4748 qmlRegisterType<GDateTimeFormatter>(uri, 0, 1, "GDateTimeFormatter");
4849 qmlRegisterUncreatableType<BottomBarVisibilityCommunicatorShell>(uri, 0, 1, "BottomBarVisibilityCommunicatorShell", "Can't create BottomBarVisibilityCommunicatorShell");
50+ qmlRegisterType<EasingCurve>(uri, 0, 1, "EasingCurve");
4951}
5052
5153void UtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
qml/CMakeLists.txt+1−1
@@ -13,7 +13,7 @@ set(QML_DIRS
1313 Hud
1414 Panel
1515 Launcher
16− SideStage
16+ Stages
1717 Notifications
1818 )
1919
qml/Components/ApplicationManagerWrapper.qmldeleted−169
@@ -1,169 +0,0 @@
1−/*
2− * Copyright (C) 2013 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 Unity.Application 0.1
19−
20−Item {
21− id: root
22−
23− property alias mainStageApplications: mainStageModel
24− property alias sideStageApplications: sideStageModel
25− property variant mainStageFocusedApplication: null
26− property variant sideStageFocusedApplication: null
27− property bool sideStageEnabled: true
28− property bool keyboardVisible: ApplicationManager.keyboardVisible
29− property int keyboardHeight: ApplicationManager.keyboardHeight
30−
31− property bool fake: ApplicationManager.fake ? ApplicationManager.fake : false
32−
33− signal focusRequested(string appId)
34−
35− ApplicationsModelStageFiltered {
36− id: mainStageModel
37− stage: ApplicationInfo.MainStage
38− }
39−
40− ApplicationsModelStageFiltered {
41− id: sideStageModel
42− stage: ApplicationInfo.SideStage
43− }
44−
45− Connections {
46− target: ApplicationManager
47− onFocusedApplicationIdChanged: {
48− var app = ApplicationManager.findApplication(ApplicationManager.focusedApplicationId)
49− if (!app) { //nothing at all focused, so clear all
50− mainStageFocusedApplication = null;
51− sideStageFocusedApplication = null;
52− } else {
53− if (app.stage == ApplicationInfo.MainStage) {
54− mainStageFocusedApplication = app;
55− // possible the side stage app being unfocused fired this signal, so check for it
56− if (sideStageFocusedApplication && !sideStageFocusedApplication.focused)
57− sideStageFocusedApplication = null;
58− } else {
59− sideStageFocusedApplication = app;
60− // possible the main stage app being unfocused fired this signal, so check for it
61− if (mainStageFocusedApplication && !mainStageFocusedApplication.focused)
62− mainStageFocusedApplication = null;
63− }
64− }
65− }
66−
67− onFocusRequested: {
68− // if no side stage enabled, override application's stage parameter
69− var app = ApplicationManager.findApplication(appId);
70− if (app && app.stage === ApplicationInfo.SideStage && !sideStageEnabled) {
71− app.stage = ApplicationInfo.MainStage;
72− }
73−
74− root.focusRequested(appId);
75− }
76− }
77−
78− function activateApplication(desktopFile, argument) {
79− var appId;
80−
81− // HACK: Applications identified sometimes with with appId, but mostly with desktopFile.
82− // TODO: convert entire shell to use appId only.
83− if (desktopFile.indexOf(".desktop") >= 0) {
84− appId = desktopFileToAppId(desktopFile);
85− } else {
86− appId = desktopFile;
87− }
88−
89− var application = ApplicationManager.findApplication(appId);
90− if (application !== null) {
91− return application;
92− }
93−
94− var execFlags = sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
95−
96− if (argument) {
97− return ApplicationManager.startApplication(appId, execFlags, [argument]);
98− } else {
99− return ApplicationManager.startApplication(appId, execFlags);
100− }
101− }
102−
103− function stopApplication(application) {
104− var appId;
105−
106− // HACK: Applications identified sometimes with with appId, but mostly with desktopFile.
107− // TODO: convert entire shell to use appId only.
108− if (typeof application == "string") {
109− appId = application;
110− } else {
111− appId = desktopFileToAppId(application.desktopFile);
112− }
113−
114− ApplicationManager.stopApplication(appId);
115− }
116−
117− function focusApplication(application) {
118− if (application == null || application == undefined) {
119− return;
120− }
121−
122− ApplicationManager.focusApplication(application.appId);
123− }
124−
125− function unfocusCurrentApplication() {
126− ApplicationManager.unfocusCurrentApplication();
127− }
128−
129− function moveRunningApplicationStackPosition(from, to, stage) {
130− if (from == to || from < 0 || to < 0) return;
131−
132− if (stage == ApplicationInfo.SideStage) {
133− sideStageModel.move(from, to);
134− } else {
135− mainStageModel.move(from, to);
136− }
137− }
138−
139− function getApplicationFromDesktopFile(desktopFile, stage) {
140− var appId;
141−
142− // HACK: Applications identified sometimes with with appId, but mostly with desktopFile.
143− // TODO: convert entire shell to use appId only.
144− if (desktopFile.indexOf(".desktop") >= 0) {
145− appId = desktopFileToAppId(desktopFile);
146− } else {
147− appId = desktopFile;
148− }
149−
150− for (var i = 0, len = ApplicationManager.count; i < len; i++ ) {
151− var app = ApplicationManager.get(i);
152−
153− // if stage not specified, return whichever app running on either stage
154− if (app.appId == appId && (stage == undefined || app.stage == stage)) {
155− return app;
156− }
157− }
158− }
159−
160− function desktopFileToAppId(desktopFile) {
161− var right = desktopFile.lastIndexOf(".desktop");
162− var left = desktopFile.lastIndexOf("/");
163− if (left == -1 || right == -1 || left == right) {
164− console.log("ApplicationManagerWrapper: unable to extract appId from '" + desktopFile + "'");
165− return "";
166− }
167− return desktopFile.substring(left+1, right);
168− }
169−}
qml/Components/ApplicationScreenshot.qmldeleted−61
@@ -1,61 +0,0 @@
1−/*
2− * Copyright (C) 2013 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 0.1
19−import Unity.Application 0.1
20−
21−Item {
22− id: applicationScreenshot
23−
24− property var application: null
25− property bool withBackground: false
26− property bool ready: applicationImage.ready || withBackground
27−
28− function setApplication(application) {
29− applicationScreenshot.application = application
30− }
31−
32− function clearApplication() {
33− applicationScreenshot.withBackground = false;
34− applicationScreenshot.application = null
35− applicationScreenshot.scheduleUpdate();
36− }
37−
38− function scheduleUpdate() {
39− applicationImage.scheduleUpdate()
40− }
41−
42− function updateFromCache() {
43− applicationImage.updateFromCache()
44− }
45−
46− Rectangle {
47− id: background
48− anchors.fill: parent
49− color: "white" // FIXME should use normal background color of Suru theme
50− visible: applicationScreenshot.withBackground
51− }
52−
53− ApplicationImage {
54− id: applicationImage
55− objectName: "screenshot image"
56− width: applicationScreenshot.application ? parent.width : 0
57− height: applicationScreenshot.application ? parent.height : 0
58− visible: applicationScreenshot.application != null && ready
59− source: ApplicationManager.findApplication((application) ? application.appId : "")
60− }
61−}
qml/Components/ApplicationsModelStageFiltered.qmldeleted−49
@@ -1,49 +0,0 @@
1−/*
2− * Copyright (C) 2013 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 Utils 0.1
19−import Unity.Application 0.1
20−
21−SortFilterProxyModel {
22− id: root
23− property int stage
24−
25− function get(index) {
26− return model.get(mapRowToSource(index));
27− }
28−
29− function move(from, to) {
30− var realFrom = mapRowToSource(from);
31− if (realFrom == -1) {
32− console.log("ERROR; invalid from=" + from + " index in move operation");
33− return;
34− }
35− var realTo = mapRowToSource(to);
36− if (realTo == -1) {
37− // assuming wanting to move to end of list
38− realTo = model.count - 1;
39− }
40−
41− if (realFrom == realTo) return;
42− model.move(realFrom, realTo);
43− }
44−
45− model: ApplicationManager
46− dynamicSortFilter: true
47− filterRole: ApplicationManager.RoleStage
48− filterRegExp: RegExp(stage)
49−}
qml/Components/ResponsiveFlowView.qml+3−10
@@ -27,9 +27,8 @@ Item {
2727 property alias verticalSpacing: flow.verticalSpacing
2828 property alias horizontalSpacing: flow.horizontalSpacing
2929 property int referenceDelegateWidth
30− property alias firstModel: repeater1.model
31− property alias secondModel: repeater2.model
32− property alias delegate: repeater1.delegate
30+ property alias model: repeater.model
31+ property alias delegate: repeater.delegate
3332 readonly property int cellWidth: referenceDelegateWidth + horizontalSpacing
3433 readonly property int cellHeight: referenceDelegateWidth + verticalSpacing
3534 property alias move: flow.move
@@ -69,13 +68,7 @@ Item {
6968 property int margin: allocatableVerticalSpace - columns * horizontalSpacing
7069
7170 Repeater {
72− id: repeater1
73− model: (root.model) ? root.model[0] : null
74− }
75− Repeater {
76− id: repeater2
77− model: (root.model) ? root.model[1] : null
78− delegate: repeater1.delegate
71+ id: repeater
7972 }
8073 }
8174}
qml/Dash/Apps/RunningApplicationTile.qml+14−24
@@ -23,7 +23,6 @@ import "../../Components/ListItems"
2323AbstractButton {
2424 id: root
2525 property var application
26− property bool __sideStageEnabled: shell.applicationManager.sideStageEnabled
2726
2827 signal requestedApplicationActivation(var application)
2928 signal requestedApplicationTermination(var application)
@@ -34,7 +33,7 @@ AbstractButton {
3433 // To avoid "binding loop" warning
3534 height: shapedApplicationImage.height + labelContainer.height
3635
37− width: shapedApplicationImage.width
36+ width: shapedApplicationImage.width <= units.gu(11) ? units.gu(11) : height
3837
3938 property bool terminationModeEnabled: false
4039
@@ -51,32 +50,23 @@ AbstractButton {
5150 }
5251 }
5352
54− function updateScreenshotFromCache() {
55− applicationImage.updateFromCache();
56− }
57−
58− // FIXME: should use UbuntuShape from SDK
59− UbuntuShapeForItem {
53+ UbuntuShape {
6054 id: shapedApplicationImage
61− anchors {
62− top: parent.top
63− horizontalCenter: parent.horizontalCenter
64− }
55+ anchors { top: parent.top; horizontalCenter: parent.horizontalCenter }
6556
66− // FIXME: width and height should be defined according to the
67− // application window's aspect ratio.
68− width: (application.stage === ApplicationInfo.MainStage && __sideStageEnabled) ?
69− units.gu(22) : units.gu(11)
70− height: (__sideStageEnabled) ? units.gu(22) : units.gu(19)
57+ height: units.gu(17)
58+ width: applicationImage.width
7159 radius: "medium"
72− image: applicationImage
73− }
7460
75− ApplicationImage {
76− id: applicationImage
77− source: ApplicationManager.findApplication((application) ? application.appId : "")
78− width: shapedApplicationImage.width
79− height: shapedApplicationImage.height
61+ image: Image {
62+ id: applicationImage
63+ source: application.screenshot
64+ // height : width = ss.height : ss.width
65+ height: shapedApplicationImage.height
66+ fillMode: Image.PreserveAspectCrop
67+ width: Math.min(height, height * sourceSize.width / sourceSize.height)
68+ }
69+
8070 }
8171
8272 UbuntuShape {
qml/Dash/Apps/RunningApplicationsGrid.qml+5−20
@@ -18,6 +18,7 @@ import QtQuick 2.0
1818import "../../Components"
1919
2020import Ubuntu.Gestures 0.1
21+import Unity.Application 0.1
2122
2223ResponsiveFlowView {
2324 id: root
@@ -25,13 +26,7 @@ ResponsiveFlowView {
2526
2627 signal updateScreenshots
2728 property alias enableHeightBehavior: heightBehaviour.enabled
28− property bool enableHeightBehaviorOnNextCreation: firstModel.count + secondModel.count == 0
29−
30− Connections {
31− target: shell
32− onDashShownChanged: if (shell.dashShown && shell.stageScreenshotsReady) updateScreenshots();
33− onStageScreenshotsReadyChanged: if (shell.dashShown && shell.stageScreenshotsReady) updateScreenshots();
34− }
29+ property bool enableHeightBehaviorOnNextCreation: model.count === 0
3530
3631 Behavior on height {
3732 id: heightBehaviour
@@ -40,13 +35,7 @@ ResponsiveFlowView {
4035 }
4136
4237 Connections {
43− target: root.firstModel
44− onCountChanged: {
45− heightBehaviour.enabled = true;
46− }
47− }
48− Connections {
49− target: root.secondModel
38+ target: root.model
5039 onCountChanged: {
5140 heightBehaviour.enabled = true;
5241 }
@@ -85,17 +74,13 @@ ResponsiveFlowView {
8574 root.terminationModeEnabled = true
8675 }
8776 onRequestedApplicationTermination: {
88− shell.applicationManager.stopApplication(model.appId)
77+ ApplicationManager.stopApplication(model.appId)
8978 }
9079 onRequestedApplicationActivation: {
91− shell.activateApplication(model.appId)
80+ ApplicationManager.requestFocusApplication(model.appId)
9281 }
9382
9483 terminationModeEnabled: root.terminationModeEnabled
95−
96− Component.onCompleted: {
97− root.updateScreenshots.connect(updateScreenshotFromCache);
98− }
9984 }
10085 }
10186
qml/Dash/DashApps.qml+4−5
@@ -17,6 +17,7 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import Utils 0.1
20+import Unity.Application 0.1
2021import "../Components"
2122import "../Components/ListItems"
2223import "Apps"
@@ -25,17 +26,15 @@ GenericScopeView {
2526 id: scopeView
2627 objectName: "DashApps"
2728
28− // FIXME: a way to aggregate these models would be ideal
29− property var mainStageApplicationsModel: shell.applicationManager.mainStageApplications
30− property var sideStageApplicationModel: shell.applicationManager.sideStageApplications
29+ property var runningApps: ApplicationManager
3130
3231 QtObject {
3332 id: countObject
34− property int count: scopeView.scope.searchQuery.length == 0 ? (mainStageApplicationsModel.count + sideStageApplicationModel.count) : 0
33+ property int count: scopeView.scope.searchQuery.length == 0 ? scopeView.runningApps.count : 0
3534 }
3635
3736 onScopeChanged: {
3837 scopeView.scope.categories.addSpecialCategory("running.apps.category", i18n.tr("Recent"), "", "{ \"template\": { \"category-layout\": \"running-apps\" } }", countObject);
39− enableHeightBehaviorOnNextCreation = (mainStageApplicationsModel.count + sideStageApplicationModel.count == 0)
38+ enableHeightBehaviorOnNextCreation = scopeView.runningApps.count === 0
4039 }
4140}
qml/Dash/GenericScopeView.qml+2−2
@@ -18,6 +18,7 @@ import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import Utils 0.1
2020import Unity 0.2
21+import Unity.Application 0.1
2122import "../Components"
2223import "../Components/ListItems" as ListItems
2324
@@ -167,8 +168,7 @@ FocusScope {
167168 if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
168169 // TODO: this is still a kludge :D Ideally add some kind of hook so that we
169170 // can do this from DashApps.qml or think a better way that needs no special casing
170− item.firstModel = Qt.binding(function() { return mainStageApplicationsModel })
171− item.secondModel = Qt.binding(function() { return sideStageApplicationModel })
171+ item.model = Qt.binding(function() { return runningApps; })
172172 item.canEnableTerminationMode = Qt.binding(function() { return scopeView.isCurrent })
173173 } else {
174174 item.model = Qt.binding(function() { return results })
qml/Launcher/Launcher.qml+2−1
@@ -29,7 +29,8 @@ Item {
2929 property int dragAreaWidth: units.gu(1)
3030 property int minimizeDistance: units.gu(26)
3131 property real progress: dragArea.dragging && dragArea.touchX > panelWidth ?
32− (width * (dragArea.touchX-panelWidth) / (width - panelWidth)) : 0
32+ (width * (dragArea.touchX-panelWidth) / (width - panelWidth)) :
33+ (dragArea.dragging ? 0.001 : 0)
3334
3435 readonly property bool shown: panel.x > -panel.width
3536
qml/Panel/Panel.qml+1−1
@@ -62,7 +62,7 @@ Item {
6262 height: __panelMinusSeparatorLineHeight
6363 y: 0
6464
65− Behavior on y { StandardAnimation {} }
65+ Behavior on y { StandardAnimation { duration: UbuntuAnimation.FastDuration } }
6666 }
6767
6868 PanelSeparatorLine {
qml/Shell.qml+201−303
@@ -31,7 +31,6 @@ import "Panel"
3131import "Hud"
3232import "Components"
3333import "Bottombar"
34−import "SideStage"
3534import "Notifications"
3635import Unity.Notifications 1.0 as NotificationBackend
3736
@@ -49,20 +48,24 @@ FocusScope {
4948 readonly property real panelHeight: panel.panelHeight
5049
5150 property bool dashShown: dash.shown
52− property bool stageScreenshotsReady: {
53− if (sideStage.shown) {
54− if (mainStage.applications.count > 0) {
55− return mainStage.usingScreenshots && sideStage.usingScreenshots;
56− } else {
57− return sideStage.usingScreenshots;
51+
52+ property bool sideStageEnabled: shell.width >= units.gu(100)
53+ readonly property string focusedApplicationId: ApplicationManager.focusedApplicationId
54+
55+ function activateApplication(appId) {
56+ if (ApplicationManager.findApplication(appId)) {
57+ ApplicationManager.requestFocusApplication(appId);
58+ stages.show(true);
59+ if (stages.locked && ApplicationManager.focusedApplicationId == appId) {
60+ applicationsDisplayLoader.item.select(appId);
5861 }
5962 } else {
60− return mainStage.usingScreenshots;
63+ var execFlags = shell.sideStageEnabled ? ApplicationManager.NoFlag : ApplicationManager.ForceMainStage;
64+ ApplicationManager.startApplication(appId, execFlags);
65+ stages.show(false);
6166 }
6267 }
6368
64− property var applicationManager: ApplicationManagerWrapper {}
65−
6669 Binding {
6770 target: LauncherModel
6871 property: "applicationManager"
@@ -71,49 +74,6 @@ FocusScope {
7174
7275 Component.onCompleted: {
7376 Theme.name = "Ubuntu.Components.Themes.SuruGradient"
74−
75− applicationManager.sideStageEnabled = Qt.binding(function() { return sideStage.enabled })
76−
77− // FIXME: if application focused before shell starts, shell draws on top of it only.
78− // We should detect already running applications on shell start and bring them to the front.
79− applicationManager.unfocusCurrentApplication();
80− }
81−
82− readonly property bool applicationFocused: !!applicationManager.mainStageFocusedApplication
83− || !!applicationManager.sideStageFocusedApplication
84− // Used for autopilot testing.
85− readonly property string currentFocusedAppId: ApplicationManager.focusedApplicationId
86−
87− readonly property bool fullscreenMode: {
88− if (greeter.shown || lockscreen.shown) {
89− return false;
90− } else if (mainStage.usingScreenshots) { // Window Manager animating so want to re-evaluate fullscreen mode
91− return mainStage.switchingFromFullscreenToFullscreen;
92− } else if (applicationManager.mainStageFocusedApplication) {
93− return applicationManager.mainStageFocusedApplication.fullscreen;
94− } else {
95− return false;
96− }
97− }
98−
99− function activateApplication(appId, argument) {
100− if (applicationManager) {
101− // For newly started applications, as it takes them time to draw their first frame
102− // we add a delay before we hide the animation screenshots to compensate.
103− var addDelay = !applicationManager.getApplicationFromDesktopFile(appId);
104−
105− var application;
106− application = applicationManager.activateApplication(appId, argument);
107− if (application == null) {
108− return;
109− }
110− if (application.stage == ApplicationInfo.MainStage || !sideStage.enabled) {
111− mainStage.activateApplication(appId, addDelay);
112− } else {
113− sideStage.activateApplication(appId, addDelay);
114− }
115− stages.show();
116− }
11777 }
11878
11979 GSettings {
@@ -133,244 +93,219 @@ FocusScope {
13393 Keys.onVolumeDownPressed: volumeControl.volumeDown()
13494
13595 Item {
136− id: underlay
137− objectName: "underlay"
96+ id: underlayClipper
13897 anchors.fill: parent
98+ anchors.rightMargin: stages.overlayWidth
99+ clip: stages.overlayMode && !stages.painting
139100
140− // Whether the underlay is fully covered by opaque UI elements.
141− property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
101+ InputFilterArea {
102+ anchors.fill: parent
103+ blockInput: parent.clip
104+ }
142105
143− readonly property bool applicationRunning: ((mainStage.applications && mainStage.applications.count > 0)
144− || (sideStage.applications && sideStage.applications.count > 0))
106+ Item {
107+ id: underlay
108+ objectName: "underlay"
109+ anchors.fill: parent
110+ anchors.rightMargin: -parent.anchors.rightMargin
145111
146− // Whether the user should see the topmost application surface (if there's one at all).
147− readonly property bool applicationSurfaceShouldBeSeen: applicationRunning && !stages.fullyHidden
148− && !mainStage.usingScreenshots // but want sideStage animating over app surface
112+ // Whether the underlay is fully covered by opaque UI elements.
113+ property bool fullyCovered: panel.indicators.fullyOpened && shell.width <= panel.indicatorsMenuWidth
149114
115+ // Whether the user should see the topmost application surface (if there's one at all).
116+ readonly property bool applicationSurfaceShouldBeSeen: stages.shown && !stages.painting && !stages.overlayMode
150117
118+ // NB! Application surfaces are stacked behind the shell one. So they can only be seen by the user
119+ // through the translucent parts of the shell surface.
120+ visible: !fullyCovered && !applicationSurfaceShouldBeSeen
151121
152− // NB! Application surfaces are stacked behing the shell one. So they can only be seen by the user
153− // through the translucent parts of the shell surface.
154− visible: !fullyCovered && !applicationSurfaceShouldBeSeen
122+ CrossFadeImage {
123+ id: backgroundImage
124+ objectName: "backgroundImage"
155125
156− Rectangle {
157− anchors.fill: parent
158− color: "black"
159− opacity: dash.disappearingAnimationProgress
160− }
126+ anchors.fill: parent
127+ source: shell.background
128+ fillMode: Image.PreserveAspectCrop
129+ }
161130
162− Image {
163− anchors.fill: dash
164− source: shell.width > shell.height ? "Dash/graphics/paper_landscape.png" : "Dash/graphics/paper_portrait.png"
165− fillMode: Image.PreserveAspectCrop
166− horizontalAlignment: Image.AlignRight
167− verticalAlignment: Image.AlignTop
168− }
131+ Rectangle {
132+ anchors.fill: parent
133+ color: "black"
134+ opacity: dash.disappearingAnimationProgress
135+ }
169136
170− Dash {
171− id: dash
172− objectName: "dash"
173−
174− available: !greeter.shown && !lockscreen.shown
175− hides: [stages, launcher, panel.indicators]
176− shown: disappearingAnimationProgress !== 1.0
177− enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
178− // FIXME: unfocus all applications when going back to the dash
179− onEnabledChanged: {
180− if (enabled) {
181− shell.applicationManager.unfocusCurrentApplication()
182− }
137+ Image {
138+ anchors.fill: dash
139+ source: shell.width > shell.height ? "Dash/graphics/paper_landscape.png" : "Dash/graphics/paper_portrait.png"
140+ fillMode: Image.PreserveAspectCrop
141+ horizontalAlignment: Image.AlignRight
142+ verticalAlignment: Image.AlignTop
183143 }
184144
185− anchors {
186− fill: parent
187− topMargin: panel.panelHeight
145+ Dash {
146+ id: dash
147+ objectName: "dash"
148+
149+ available: !greeter.shown && !lockscreen.shown
150+ hides: [stages, launcher, panel.indicators]
151+ shown: disappearingAnimationProgress !== 1.0
152+ enabled: disappearingAnimationProgress === 0.0 && edgeDemo.dashEnabled
153+
154+ anchors {
155+ fill: parent
156+ topMargin: panel.panelHeight
157+ }
158+
159+ contentScale: 1.0 - 0.2 * disappearingAnimationProgress
160+ opacity: 1.0 - disappearingAnimationProgress
161+ property real disappearingAnimationProgress: {
162+ if (greeter.shown) {
163+ return greeter.showProgress;
164+ } else {
165+ if (stages.overlayMode) {
166+ return 0;
167+ }
168+ return stages.showProgress
169+ }
170+ }
171+
172+ // FIXME: only necessary because stages.showProgress and
173+ // greeterRevealer.animatedProgress are not animated
174+ Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
188175 }
176+ }
177+ }
178+
179+ EdgeDragArea {
180+ id: stagesDragHandle
181+ direction: Direction.Leftwards
182+
183+ anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
184+ width: shell.edgeSize
189185
190− contentScale: 1.0 - 0.2 * disappearingAnimationProgress
191− opacity: 1.0 - disappearingAnimationProgress
192− property real disappearingAnimationProgress: {
193− if (greeter.shown) {
194− return greeter.showProgress;
186+ property real progress: stages.width
187+
188+ onTouchXChanged: {
189+ if (status == DirectionalDragArea.Recognized) {
190+ if (ApplicationManager.count == 0) {
191+ progress = Math.max(stages.width - stagesDragHandle.width + touchX, stages.width * .3)
195192 } else {
196− return stagesOuterContainer.showProgress;
193+ progress = stages.width - stagesDragHandle.width + touchX
197194 }
198195 }
196+ }
199197
200− // FIXME: only necessary because stagesOuterContainer.showProgress and
201− // greeterRevealer.animatedProgress are not animated
202− Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
198+ onDraggingChanged: {
199+ if (!dragging) {
200+ if (ApplicationManager.count > 0 && progress < stages.width - units.gu(10)) {
201+ stages.show(true)
202+ }
203+ stagesDragHandle.progress = stages.width;
204+ }
203205 }
204206 }
205207
206208 Item {
207− id: stagesOuterContainer
208−
209+ id: stages
210+ objectName: "stages"
209211 width: parent.width
210212 height: parent.height
211− x: launcher.progress
212− Behavior on x {SmoothedAnimation{velocity: 600}}
213213
214− property real showProgress:
215− MathUtils.clamp(1 - (x + stages.x) / shell.width, 0, 1)
214+ x: {
215+ if (shown) {
216+ if (overlayMode || locked) {
217+ return 0;
218+ }
219+ return launcher.progress
220+ } else {
221+ return stagesDragHandle.progress
222+ }
223+ }
224+
225+ Behavior on x { SmoothedAnimation { velocity: 600; duration: UbuntuAnimation.FastDuration } }
216226
217− Showable {
218− id: stages
219− objectName: "stages"
227+ property bool shown: false
220228
221− x: width
229+ property real showProgress: overlayMode ? 0 : MathUtils.clamp(1 - x / shell.width, 0, 1)
222230
223− property bool fullyShown: shown && x == 0 && parent.x == 0
224− property bool fullyHidden: !shown && x == width
225− available: !greeter.shown
226− hides: [panel.indicators]
227− shown: false
228− opacity: 1.0
229− showAnimation: StandardAnimation { property: "x"; duration: 350; to: 0; easing.type: Easing.OutCubic }
230− hideAnimation: StandardAnimation { property: "x"; duration: 350; to: width; easing.type: Easing.OutCubic }
231+ property bool fullyShown: x == 0
232+ property bool fullyHidden: x == width
231233
232− width: parent.width
233− height: parent.height
234+ property bool painting: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.painting : false
235+ property bool fullscreen: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.fullscreen : false
236+ property bool overlayMode: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.overlayMode : false
237+ property int overlayWidth: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.overlayWidth : false
238+ property bool locked: applicationsDisplayLoader.item ? applicationsDisplayLoader.item.locked : false
234239
235− // close the stages when no focused application remains
236− Connections {
237− target: shell.applicationManager
238− onMainStageFocusedApplicationChanged: stages.closeIfNoApplications()
239− onSideStageFocusedApplicationChanged: stages.closeIfNoApplications()
240− ignoreUnknownSignals: true
240+ function show(focusApp) {
241+ shown = true;
242+ panel.indicators.hide();
243+ if (!ApplicationManager.focusedApplicationId && ApplicationManager.count > 0 && focusApp) {
244+ ApplicationManager.focusApplication(ApplicationManager.get(0).appId);
241245 }
246+ }
242247
243− function closeIfNoApplications() {
244− if (!shell.applicationManager.mainStageFocusedApplication
245− && !shell.applicationManager.sideStageFocusedApplication
246− && shell.applicationManager.mainStageApplications.count == 0
247− && shell.applicationManager.sideStageApplications.count == 0) {
248− stages.hide();
249− }
248+ function hide() {
249+ shown = false;
250+ if (ApplicationManager.focusedApplicationId) {
251+ ApplicationManager.unfocusCurrentApplication();
250252 }
253+ }
251254
252− // show the stages when an application gets the focus
253− Connections {
254− target: shell.applicationManager
255− onMainStageFocusedApplicationChanged: {
256− if (shell.applicationManager.mainStageFocusedApplication) {
257− mainStage.show();
258− stages.show();
259− }
260− }
261− onSideStageFocusedApplicationChanged: {
262− if (shell.applicationManager.sideStageFocusedApplication) {
263− sideStage.show();
264− stages.show();
255+ Connections {
256+ target: ApplicationManager
257+
258+ onFocusRequested: {
259+ stages.show(true);
260+ }
261+
262+ onFocusedApplicationIdChanged: {
263+ if (ApplicationManager.focusedApplicationId.length > 0) {
264+ stages.show(false);
265+ } else {
266+ if (!stages.overlayMode) {
267+ stages.hide();
265268 }
266269 }
267− ignoreUnknownSignals: true
268− }
269270
270− Stage {
271− id: mainStage
271+ // If any app is focused when greeter is open, it's due to a user action
272+ // like a snap decision (say, an incoming call).
273+ // TODO: these should be protected to only unlock for certain applications / certain usecases
274+ // potentially only in connection with a notification.
275+ greeter.hide()
276+ }
272277
273− anchors.fill: parent
274− fullyShown: stages.fullyShown
275− fullyHidden: stages.fullyHidden
276− shouldUseScreenshots: !fullyShown
277− rightEdgeEnabled: !sideStage.enabled
278−
279− applicationManager: shell.applicationManager
280− rightEdgeDraggingAreaWidth: shell.edgeSize
281− normalApplicationY: shell.panelHeight
282−
283− shown: true
284− function show() {
285− stages.show();
286− }
287− function hide() {
288− }
278+ onApplicationAdded: {
279+ stages.show(false);
280+ }
289281
290− // FIXME: workaround the fact that focusing a main stage application
291− // raises its surface on top of all other surfaces including the ones
292− // that belong to side stage applications.
293− onFocusedApplicationChanged: {
294− if (focusedApplication && sideStage.focusedApplication && sideStage.fullyShown) {
295− shell.applicationManager.focusApplication(sideStage.focusedApplication);
296− }
282+ onApplicationRemoved: {
283+ if (ApplicationManager.focusedApplicationId.length == 0) {
284+ stages.hide();
297285 }
298286 }
287+ }
299288
300− SideStage {
301− id: sideStage
302−
303− applicationManager: shell.applicationManager
304− rightEdgeDraggingAreaWidth: shell.edgeSize
305− normalApplicationY: shell.panelHeight
289+ Loader {
290+ id: applicationsDisplayLoader
291+ anchors.fill: parent
306292
307− onShownChanged: {
308− if (!shown && mainStage.applications.count == 0) {
309− stages.hide();
310− }
311− }
312− // FIXME: when hiding the side stage, refocus the main stage
313− // application so that it goes in front of the side stage
314− // application and hides it
315− onFullyShownChanged: {
316− if (!fullyShown && stages.fullyShown && sideStage.focusedApplication != null) {
317− shell.applicationManager.focusApplication(mainStage.focusedApplication);
318− }
319− }
293+ source: shell.sideStageEnabled ? "Stages/StageWithSideStage.qml" : "Stages/PhoneStage.qml"
320294
321− enabled: shell.width >= units.gu(100)
322− visible: enabled
323− fullyShown: stages.fullyShown && shown
324− && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
325− shouldUseScreenshots: !fullyShown || mainStage.usingScreenshots || sideStageRevealer.pressed
326−
327− available: !greeter.shown && !lockscreen.shown && enabled
328− hides: [launcher, panel.indicators]
329− shown: false
330− showAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.openedValue; easing.type: Easing.OutQuint }
331− hideAnimation: StandardAnimation { property: "x"; duration: 350; to: sideStageRevealer.closedValue; easing.type: Easing.OutQuint }
332−
333− width: units.gu(40)
334− height: stages.height
335− handleExpanded: sideStageRevealer.pressed
336− }
337−
338− Revealer {
339− id: sideStageRevealer
340−
341− enabled: mainStage.applications.count > 0 && sideStage.applications.count > 0
342− && sideStage.available
343− direction: Qt.RightToLeft
344− openedValue: parent.width - sideStage.width
345− hintDisplacement: units.gu(3)
346− /* The size of the sidestage handle needs to be bigger than the
347− typical size used for edge detection otherwise it is really
348− hard to grab.
349− */
350− handleSize: sideStage.shown ? units.gu(4) : shell.edgeSize
351− closedValue: parent.width + sideStage.handleSizeCollapsed
352− target: sideStage
353− x: parent.width - width
354− width: sideStage.width + handleSize * 0.7
355− height: sideStage.height
356− orientation: Qt.Horizontal
357− }
358−
359− DragHandle {
360− id: stagesDragHandle
361−
362− anchors.top: parent.top
363− anchors.bottom: parent.bottom
364− anchors.right: parent.left
365−
366− width: shell.edgeSize
367− direction: Direction.Leftwards
368− enabled: greeter.showProgress == 0 && edgeDemo.dashEnabled
369− property bool haveApps: mainStage.applications.count > 0 || sideStage.applications.count > 0
370−
371− maxTotalDragDistance: haveApps ? parent.width : parent.width * 0.7
372− // Make autocompletion impossible when !haveApps
373− edgeDragEvaluator.minDragDistance: haveApps ? maxTotalDragDistance * 0.1 : Number.MAX_VALUE
295+ Binding {
296+ target: applicationsDisplayLoader.item
297+ property: "moving"
298+ value: !stages.fullyShown
299+ }
300+ Binding {
301+ target: applicationsDisplayLoader.item
302+ property: "shown"
303+ value: stages.shown
304+ }
305+ Binding {
306+ target: applicationsDisplayLoader.item
307+ property: "dragAreaWidth"
308+ value: shell.edgeSize
374309 }
375310 }
376311 }
@@ -447,26 +382,6 @@ FocusScope {
447382
448383 dragHandleWidth: shell.edgeSize
449384
450− property var previousMainApp: null
451− property var previousSideApp: null
452−
453− function removeApplicationFocus() {
454− greeter.previousMainApp = applicationManager.mainStageFocusedApplication;
455− greeter.previousSideApp = applicationManager.sideStageFocusedApplication;
456− applicationManager.unfocusCurrentApplication();
457− }
458−
459− function restoreApplicationFocus() {
460− if (greeter.previousMainApp) {
461− applicationManager.focusApplication(greeter.previousMainApp);
462− greeter.previousMainApp = null;
463− }
464− if (greeter.previousSideApp) {
465− applicationManager.focusApplication(greeter.previousSideApp);
466− greeter.previousSideApp = null;
467− }
468− }
469−
470385 onShownChanged: {
471386 if (shown) {
472387 lockscreen.reset();
@@ -476,9 +391,6 @@ FocusScope {
476391 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
477392 }
478393 greeter.forceActiveFocus();
479− removeApplicationFocus();
480− } else {
481− restoreApplicationFocus();
482394 }
483395 }
484396
@@ -496,33 +408,16 @@ FocusScope {
496408 }
497409 }
498410
499− Connections {
500− target: applicationManager
501− ignoreUnknownSignals: true
502− // If any app is focused when greeter is open, it's due to a user action
503− // like a snap decision (say, an incoming call).
504− // TODO: these should be protected to only unlock for certain applications / certain usecases
505− // potentially only in connection with a notification.
506− onMainStageFocusedApplicationChanged: {
507− if (greeter.shown && applicationManager.mainStageFocusedApplication) {
508− greeter.previousMainApp = null // make way for new focused app
509− greeter.previousSideApp = null
510− greeter.hide()
511− }
512− }
513− onSideStageFocusedApplicationChanged: {
514− if (greeter.shown && applicationManager.sideStageFocusedApplication) {
515− greeter.previousMainApp = null // make way for new focused app
516− greeter.previousSideApp = null
517− greeter.hide()
518− }
519− }
411+ Binding {
412+ target: ApplicationManager
413+ property: "suspended"
414+ value: greeter.shown && greeter.showProgress == 1
520415 }
521416 }
522417
523418 InputFilterArea {
524419 anchors.fill: parent
525− blockInput: !applicationFocused || greeter.shown || lockscreen.shown || launcher.shown
420+ blockInput: ApplicationManager.focusedApplicationId.length === 0 || greeter.shown || lockscreen.shown || launcher.shown
526421 || panel.indicators.shown || hud.shown
527422 }
528423
@@ -571,7 +466,9 @@ FocusScope {
571466 available: edgeDemo.panelEnabled
572467 contentEnabled: edgeDemo.panelContentEnabled
573468 }
574− fullscreenMode: shell.fullscreenMode
469+ property string focusedAppId: ApplicationManager.focusedApplicationId
470+ property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
471+ fullscreenMode: focusedApplication && stages.fullscreen && !greeter.shown && !lockscreen.shown
575472 searchVisible: !greeter.shown && !lockscreen.shown && dash.shown && dash.searchable
576473
577474 InputFilterArea {
@@ -597,9 +494,8 @@ FocusScope {
597494 hideAnimation: StandardAnimation { property: "y"; duration: hud.showableAnimationDuration; to: hudRevealer.closedValue; easing.type: Easing.Linear }
598495
599496 Connections {
600− target: shell.applicationManager
601− onMainStageFocusedApplicationChanged: hud.hide()
602− onSideStageFocusedApplicationChanged: hud.hide()
497+ target: ApplicationManager
498+ onFocusedApplicationIdChanged: hud.hide()
603499 }
604500 }
605501
@@ -624,7 +520,7 @@ FocusScope {
624520 theHud: hud
625521 anchors.fill: parent
626522 enabled: hud.available
627− applicationIsOnForeground: applicationFocused
523+ applicationIsOnForeground: ApplicationManager.focusedApplicationId
628524 }
629525
630526 InputFilterArea {
@@ -655,9 +551,11 @@ FocusScope {
655551 showHome()
656552 }
657553 onDash: {
658− if (stages.shown) {
659− stages.hide();
660− launcher.hide();
554+ if (stages.shown && !stages.overlayMode) {
555+ if (!stages.locked) {
556+ stages.hide();
557+ launcher.hide();
558+ }
661559 }
662560 }
663561 onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
@@ -750,14 +648,14 @@ FocusScope {
750648 anchors.bottom: parent.bottom
751649 anchors.left: parent.left
752650 anchors.right: parent.right
753− height: shell.applicationManager ? shell.applicationManager.keyboardHeight : 0
651+ height: ApplicationManager.keyboardVisible ? ApplicationManager.keyboardHeight : 0
754652
755− enabled: shell.applicationManager && shell.applicationManager.keyboardVisible
653+ enabled: ApplicationManager.keyboardVisible
756654 }
757655
758656 Label {
759657 anchors.centerIn: parent
760− visible: applicationManager.fake
658+ visible: ApplicationManager.fake ? ApplicationManager.fake : false
761659 text: "EARLY ALPHA\nNOT READY FOR USE"
762660 color: "lightgrey"
763661 opacity: 0.2
qml/SideStage/SideStage.qmldeleted−73
@@ -1,73 +0,0 @@
1−/*
2− * Copyright (C) 2013 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 Unity.Application 0.1
19−import Ubuntu.Components 0.1
20−import "../Components"
21−
22−Stage {
23− id: stage
24−
25− type: ApplicationInfo.SideStage
26− property real handleSizeCollapsed: units.gu(2.5)
27− property real handleSizeExpanded: units.gu(4)
28− property bool handleExpanded
29−
30− /* FIXME: workaround so that when a main stage app goes fullscreen
31− the sidestage's top is not transparent. Proper fix would be to
32− resize the side stage app.
33− */
34− Rectangle {
35− id: backgroundBeneathPanel
36− anchors {
37− top: parent.top
38− left: parent.left
39− right: parent.right
40− }
41− height: shell.panelHeight
42− color: background.color
43− z: -1
44− }
45−
46− Rectangle {
47− id: background
48− anchors.fill: parent
49− color: "#2c2924"
50− z: -1
51− visible: stage.usingScreenshots
52− }
53−
54− SidestageHandle {
55− id: handle
56− objectName: "sideStageHandle"
57−
58− anchors {
59− top: parent.top
60− bottom: parent.bottom
61− left: parent.left
62− leftMargin: -width
63− }
64− width: handleExpanded ? handleSizeExpanded : handleSizeCollapsed
65− Behavior on width { NumberAnimation { easing.type: Easing.OutQuart} }
66− z: -1
67− }
68−
69− InputFilterArea {
70− anchors.fill: handle
71− blockInput: visible
72− }
73−}
qml/Stages/PhoneStage.qmlnew file+499
@@ -0,0 +1,499 @@
1+/*
2+ * Copyright (C) 2014 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 0.1
19+import Ubuntu.Gestures 0.1
20+import Unity.Application 0.1
21+import Utils 0.1
22+import "../Components"
23+
24+Item {
25+ id: root
26+
27+ // Controls to be set from outside
28+ property bool shown: false
29+ property bool moving: false
30+ property int dragAreaWidth
31+
32+ // State information propagated to the outside
33+ readonly property bool painting: mainScreenshotImage.visible || fadeInScreenshotImage.visible || appSplash.visible || spreadView.visible
34+ property bool fullscreen: priv.focusedApplication ? priv.focusedApplication.fullscreen : false
35+ property bool locked: spreadView.visible
36+
37+ // Not used for PhoneStage, only useful for SideStage and similar
38+ property bool overlayMode: false
39+ property int overlayWidth: 0
40+
41+ function select(appId) {
42+ spreadView.snapTo(priv.indexOf(appId))
43+ }
44+
45+ onMovingChanged: {
46+ if (moving) {
47+ if (ApplicationManager.focusedApplicationId) {
48+ priv.requestNewScreenshot();
49+ } else {
50+ mainScreenshotImage.anchors.leftMargin = 0;
51+ mainScreenshotImage.source = ApplicationManager.get(0).screenshot;
52+ mainScreenshotImage.visible = true;
53+ }
54+ } else {
55+ mainScreenshotImage.visible = false;
56+ }
57+ }
58+
59+ Connections {
60+ target: ApplicationManager
61+
62+ onFocusRequested: {
63+ if (spreadView.visible) {
64+ spreadView.snapTo(priv.indexOf(appId));
65+ } else {
66+ priv.switchToApp(appId);
67+ }
68+ }
69+
70+ onFocusedApplicationIdChanged: {
71+ if (ApplicationManager.focusedApplicationId.length > 0) {
72+ if (priv.secondApplicationStarting || priv.applicationStarting) {
73+ appSplashTimer.restart();
74+ } else {
75+ var application = priv.focusedApplication;
76+ root.fullscreen = application.fullscreen;
77+ mainScreenshotImage.source = application.screenshot;
78+ }
79+ } else {
80+ spreadView.selectedIndex = -1;
81+ spreadView.phase = 0;
82+ spreadView.contentX = -spreadView.shift;
83+ }
84+ }
85+
86+ onApplicationAdded: {
87+ if (!priv.focusedApplication) {
88+ mainScreenshotImage.source = "";
89+ mainScreenshotImage.visible = false;
90+ priv.applicationStarting = true;
91+ } else {
92+ mainScreenshotImage.source = "";
93+ priv.newFocusedAppId = appId;
94+ priv.secondApplicationStarting = true;
95+ priv.requestNewScreenshot();
96+ }
97+
98+ if (spreadView.visible) {
99+ spreadView.snapTo(0);
100+ }
101+ }
102+
103+ onApplicationRemoved: {
104+ if (ApplicationManager.count == 0) {
105+ mainScreenshotImage.source = ""
106+ mainScreenshotImage.visible = false;
107+ } else {
108+ mainScreenshotImage.source = ApplicationManager.get(0).screenshot;
109+ }
110+ }
111+ }
112+
113+ QtObject {
114+ id: priv
115+
116+ property string focusedAppId: ApplicationManager.focusedApplicationId
117+ property var focusedApplication: ApplicationManager.findApplication(focusedAppId)
118+ property url focusedScreenshot: focusedApplication ? focusedApplication.screenshot : ""
119+
120+ property bool waitingForScreenshot: false
121+
122+ property bool applicationStarting: false
123+ property bool secondApplicationStarting: false
124+
125+ property string newFocusedAppId
126+
127+ onFocusedScreenshotChanged: {
128+ if (root.moving && priv.waitingForScreenshot) {
129+ mainScreenshotImage.anchors.leftMargin = 0;
130+ mainScreenshotImage.source = priv.focusedScreenshot
131+ mainScreenshotImage.visible = true;
132+ } else if (priv.secondApplicationStarting && priv.waitingForScreenshot) {
133+ applicationSwitchingAnimation.start();
134+ }
135+ waitingForScreenshot = false;
136+ }
137+
138+ function requestNewScreenshot() {
139+ waitingForScreenshot = true;
140+ ApplicationManager.updateScreenshot(focusedAppId);
141+ }
142+
143+ function switchToApp(appId) {
144+ if (priv.focusedAppId) {
145+ priv.newFocusedAppId = appId;
146+ root.fullscreen = ApplicationManager.findApplication(appId).fullscreen;
147+ applicationSwitchingAnimation.start();
148+ } else {
149+ ApplicationManager.focusApplication(appId);
150+ }
151+ }
152+
153+ function indexOf(appId) {
154+ for (var i = 0; i < ApplicationManager.count; i++) {
155+ if (ApplicationManager.get(i).appId == appId) {
156+ return i;
157+ }
158+ }
159+ return -1;
160+ }
161+
162+ }
163+
164+ // FIXME: the signal connections seems to get lost.
165+ Connections {
166+ target: priv.focusedApplication
167+ onScreenshotChanged: priv.focusedScreenshot = priv.focusedApplication.screenshot
168+ }
169+ Binding {
170+ target: root
171+ property: "fullscreen"
172+ value: priv.focusedApplication ? priv.focusedApplication.fullscreen : false
173+ }
174+
175+ Timer {
176+ id: appSplashTimer
177+ // FIXME: We really need to show something meaningful in the app surface instead of guessing
178+ // when it might be ready
179+ interval: 500
180+ repeat: false
181+ onTriggered: {
182+ priv.applicationStarting = false;
183+ priv.secondApplicationStarting = false;
184+ }
185+ }
186+
187+ SequentialAnimation {
188+ id: applicationSwitchingAnimation
189+ // setup
190+ PropertyAction { target: mainScreenshotImage; property: "anchors.leftMargin"; value: 0 }
191+ PropertyAction { target: mainScreenshotImage; property: "source"; value: priv.focusedScreenshot }
192+ PropertyAction { targets: [mainScreenshotImage, fadeInScreenshotImage]; property: "visible"; value: true }
193+ PropertyAction { target: fadeInScreenshotImage; property: "source"; value: {
194+ var newFocusedApp = ApplicationManager.findApplication(priv.newFocusedAppId);
195+ return newFocusedApp ? newFocusedApp.screenshot : "" }
196+ }
197+ PropertyAction { target: fadeInScreenshotImage; property: "opacity"; value: 0 }
198+ PropertyAction { target: fadeInScreenshotImage; property: "scale"; value: .8 }
199+
200+
201+ // The actual animation
202+ ParallelAnimation {
203+ UbuntuNumberAnimation { target: mainScreenshotImage; property: "anchors.leftMargin"; to: root.width; duration: UbuntuAnimation.SlowDuration }
204+ UbuntuNumberAnimation { target: fadeInScreenshotImage; properties: "opacity,scale"; to: 1; duration: UbuntuAnimation.SlowDuration }
205+ }
206+
207+ // restore stuff
208+ ScriptAction { script: ApplicationManager.focusApplication(priv.newFocusedAppId); }
209+ PropertyAction { target: fadeInScreenshotImage; property: "visible"; value: false }
210+ PropertyAction { target: mainScreenshotImage; property: "visible"; value: false }
211+ }
212+
213+ // FIXME: Drop this and make the imageprovider show a splashscreen instead
214+ Rectangle {
215+ id: appSplash2
216+ anchors.fill: parent
217+ color: "white"
218+ visible: priv.secondApplicationStarting
219+ }
220+ Image {
221+ id: fadeInScreenshotImage
222+ anchors { left: parent.left; bottom: parent.bottom }
223+ width: parent.width
224+ scale: .7
225+ visible: false
226+ }
227+
228+ Rectangle {
229+ id: appSplash
230+ anchors.fill: parent
231+ color: "white"
232+ visible: priv.applicationStarting
233+ }
234+ Image {
235+ id: mainScreenshotImage
236+ anchors { left: parent.left; bottom: parent.bottom }
237+ width: parent.width
238+ visible: false
239+ }
240+
241+ EdgeDragArea {
242+ id: spreadDragArea
243+ direction: Direction.Leftwards
244+ enabled: ApplicationManager.count > 1 && spreadView.phase != 2
245+
246+ anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
247+ width: root.dragAreaWidth
248+
249+ // Sitting at the right edge of the screen, this EdgeDragArea directly controls the spreadView when
250+ // attachedToView is true. When the finger movement passes positionMarker3 we detach it from the
251+ // spreadView and make the spreadView snap to positionMarker4.
252+ property bool attachedToView: true
253+
254+ property var gesturePoints: new Array()
255+
256+ onTouchXChanged: {
257+ if (!dragging && !priv.waitingForScreenshot) {
258+ // Initial touch. Let's update the screenshot and reset the spreadView to the starting position.
259+ priv.requestNewScreenshot();
260+ spreadView.phase = 0;
261+ spreadView.contentX = -spreadView.shift;
262+ }
263+ if (dragging && attachedToView) {
264+ // Gesture recognized. Let's move the spreadView with the finger
265+ spreadView.contentX = -touchX - spreadView.shift;
266+ }
267+ if (attachedToView && spreadView.shiftedContentX >= spreadView.width * spreadView.positionMarker3) {
268+ // We passed positionMarker3. Detach from spreadView and snap it.
269+ attachedToView = false;
270+ spreadView.snap();
271+ }
272+ gesturePoints.push(touchX);
273+ }
274+
275+ onStatusChanged: {
276+ if (status == DirectionalDragArea.Recognized) {
277+ attachedToView = true;
278+ }
279+ }
280+
281+ onDraggingChanged: {
282+ if (dragging) {
283+ // Gesture recognized. Start recording this gesture
284+ gesturePoints = [];
285+ return;
286+ }
287+
288+ // Ok. The user released. Find out if it was a one-way movement.
289+ var oneWayFlick = true;
290+ var smallestX = spreadDragArea.width;
291+ for (var i = 0; i < gesturePoints.length; i++) {
292+ if (gesturePoints[i] >= smallestX) {
293+ oneWayFlick = false;
294+ break;
295+ }
296+ smallestX = gesturePoints[i];
297+ }
298+ gesturePoints = [];
299+
300+ if (oneWayFlick && spreadView.shiftedContentX > units.gu(2) &&
301+ spreadView.shiftedContentX < spreadView.positionMarker1 * spreadView.width) {
302+ // If it was a short one-way movement, do the Alt+Tab switch
303+ // no matter if we didn't cross positionMarker1 yet.
304+ spreadView.snapTo(1);
305+ } else if (!dragging && attachedToView) {
306+ // otherwise snap to the closest snap position we can find
307+ // (might be back to start, to app 1 or to spread)
308+ spreadView.snap();
309+ }
310+ }
311+ }
312+
313+ Rectangle {
314+ id: coverFlipBackground
315+ anchors.fill: parent
316+ color: "black"
317+ visible: spreadView.visible
318+ }
319+
320+ InputFilterArea {
321+ anchors.fill: root
322+ blockInput: spreadView.visible
323+ }
324+
325+ Flickable {
326+ id: spreadView
327+ objectName: "spreadView"
328+ anchors.fill: parent
329+ visible: spreadDragArea.status == DirectionalDragArea.Recognized || phase > 1 || snapAnimation.running
330+ contentWidth: spreadRow.width - shift
331+ contentX: -shift
332+
333+ // The flickable needs to fill the screen in order to get touch events all over.
334+ // However, we don't want to the user to be able to scroll back all the way. For
335+ // that, the beginning of the gesture starts with a negative value for contentX
336+ // so the flickable wants to pull it into the view already. "shift" tunes the
337+ // distance where to "lock" the content.
338+ property real shift: width / 2
339+ property real shiftedContentX: contentX + shift
340+
341+ property int tileDistance: width / 4
342+
343+ // Those markers mark the various positions in the spread (ratio to screen width from right to left):
344+ // 0 - 1: following finger, snap back to the beginning on release
345+ property real positionMarker1: 0.3
346+ // 1 - 2: curved snapping movement, snap to app 1 on release
347+ property real positionMarker2: 0.45
348+ // 2 - 3: movement follows finger, snaps back to app 1 on release
349+ property real positionMarker3: 0.6
350+ // passing 3, we detach movement from the finger and snap to 4
351+ property real positionMarker4: 0.9
352+
353+ // This is where the first app snaps to when bringing it in from the right edge.
354+ property real snapPosition: 0.75
355+
356+ // Phase of the animation:
357+ // 0: Starting from right edge, a new app (index 1) comes in from the right
358+ // 1: The app has reached the first snap position.
359+ // 2: The list is dragged further and snaps into the spread view when entering phase 2
360+ property int phase: 0
361+
362+ property int selectedIndex: -1
363+
364+ onShiftedContentXChanged: {
365+ switch (phase) {
366+ case 0:
367+ if (shiftedContentX > width * positionMarker2) {
368+ phase = 1;
369+ }
370+ break;
371+ case 1:
372+ if (shiftedContentX < width * positionMarker2) {
373+ phase = 0;
374+ } else if (shiftedContentX >= width * positionMarker4) {
375+ phase = 2;
376+ }
377+ break;
378+ }
379+ }
380+
381+ function snap() {
382+ if (shiftedContentX < positionMarker1 * width) {
383+ snapAnimation.targetContentX = -shift;
384+ snapAnimation.start();
385+ } else if (shiftedContentX < positionMarker2 * width) {
386+ snapTo(1)
387+ } else if (shiftedContentX < positionMarker3 * width) {
388+ snapTo(1)
389+ } else if (phase < 2){
390+ // Add 1 pixel to make sure we definitely hit positionMarker4 even with rounding errors of the animation.
391+ snapAnimation.targetContentX = width * positionMarker4 + 1 - shift;
392+ snapAnimation.start();
393+ }
394+ }
395+ function snapTo(index) {
396+ spreadView.selectedIndex = index;
397+ root.fullscreen = ApplicationManager.get(index).fullscreen;
398+ snapAnimation.targetContentX = -shift;
399+ snapAnimation.start();
400+ }
401+
402+ SequentialAnimation {
403+ id: snapAnimation
404+ property int targetContentX: -spreadView.shift
405+
406+ UbuntuNumberAnimation {
407+ target: spreadView
408+ property: "contentX"
409+ to: snapAnimation.targetContentX
410+ duration: UbuntuAnimation.FastDuration
411+ }
412+
413+ ScriptAction {
414+ script: {
415+ if (spreadView.selectedIndex >= 0) {
416+ ApplicationManager.focusApplication(ApplicationManager.get(spreadView.selectedIndex).appId);
417+ spreadView.selectedIndex = -1
418+ spreadView.phase = 0;
419+ spreadView.contentX = -spreadView.shift;
420+ }
421+ }
422+ }
423+ }
424+
425+ Item {
426+ id: spreadRow
427+ // This width controls how much the spread can be flicked left/right. It's composed of:
428+ // tileDistance * app count (with a minimum of 3 apps, in order to also allow moving 1 and 2 apps a bit)
429+ // + some constant value (still scales with the screen width) which looks good and somewhat fills the screen
430+ width: Math.max(3, ApplicationManager.count) * spreadView.tileDistance + (spreadView.width - spreadView.tileDistance) * 1.5
431+
432+ x: spreadView.contentX
433+
434+ Repeater {
435+ id: spreadRepeater
436+ model: ApplicationManager
437+ delegate: TransformedSpreadDelegate {
438+ id: appDelegate
439+ objectName: "appDelegate" + index
440+ startAngle: 45
441+ endAngle: 5
442+ startScale: 1.1
443+ endScale: 0.7
444+ startDistance: spreadView.tileDistance
445+ endDistance: units.gu(.5)
446+ width: spreadView.width
447+ height: spreadView.height
448+ selected: spreadView.selectedIndex == index
449+ otherSelected: spreadView.selectedIndex >= 0 && !selected
450+
451+ z: index
452+ x: index == 0 ? 0 : spreadView.width + (index - 1) * spreadView.tileDistance
453+
454+ // Each tile has a different progress value running from 0 to 1.
455+ // A progress value of 0 means the tile is at the right edge. 1 means the tile has reched the left edge.
456+ progress: {
457+ var tileProgress = (spreadView.shiftedContentX - index * spreadView.tileDistance) / spreadView.width;
458+ // Tile 1 needs to move directly from the beginning...
459+ if (index == 1 && spreadView.phase < 2) {
460+ tileProgress += spreadView.tileDistance / spreadView.width;
461+ }
462+ return tileProgress;
463+ }
464+
465+ // This mostly is the same as progress, just adds the snapping to phase 1 for tiles 0 and 1
466+ animatedProgress: {
467+ if (spreadView.phase == 0 && index < 2) {
468+ if (progress < spreadView.positionMarker1) {
469+ return progress;
470+ } else if (progress < spreadView.positionMarker1 + snappingCurve.period){
471+ return spreadView.positionMarker1 + snappingCurve.value * 3;
472+ } else {
473+ return spreadView.positionMarker2;
474+ }
475+ }
476+ return progress;
477+ }
478+
479+ EasingCurve {
480+ id: snappingCurve
481+ type: EasingCurve.OutQuad
482+ period: 0.05
483+ progress: appDelegate.progress - spreadView.positionMarker1
484+ }
485+
486+ onClicked: {
487+ if (spreadView.phase == 2) {
488+ if (ApplicationManager.focusedApplicationId == ApplicationManager.get(index).appId) {
489+ spreadView.snapTo(index);
490+ } else {
491+ ApplicationManager.requestFocusApplication(ApplicationManager.get(index).appId);
492+ }
493+ }
494+ }
495+ }
496+ }
497+ }
498+ }
499+}
qml/SideStage/SidestageHandle.qml → qml/Stages/SidestageHandle.qmlrenamed

The content is the same.

qml/Stages/SpreadDelegate.qmlnew file+55
@@ -0,0 +1,55 @@
1+/*
2+ * Copyright 2014 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+ * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17+*/
18+
19+import QtQuick 2.0
20+
21+Item {
22+ id: root
23+
24+ signal clicked()
25+
26+ property real topMarginProgress
27+
28+ QtObject {
29+ id: priv
30+ property real heightDifference: root.height - appImage.implicitHeight
31+ }
32+
33+ Image {
34+ id: dropShadow
35+ anchors.fill: appImage
36+ anchors.margins: -units.gu(2)
37+ source: "graphics/dropshadow.png"
38+ opacity: .4
39+ }
40+ Image {
41+ id: appImage
42+ anchors {
43+ left: parent.left;
44+ bottom: parent.bottom;
45+ top: parent.top;
46+ topMargin: priv.heightDifference * Math.max(0, 1 - root.topMarginProgress)
47+ }
48+ source: model.screenshot
49+ antialiasing: true
50+ }
51+ MouseArea {
52+ anchors.fill: appImage
53+ onClicked: root.clicked()
54+ }
55+}
qml/Stages/StageWithSideStage.qmlnew file+407
@@ -0,0 +1,407 @@
1+/*
2+ * Copyright (C) 2014 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 0.1
19+import "../Components"
20+import Unity.Application 0.1
21+import Ubuntu.Gestures 0.1
22+
23+Item {
24+ id: root
25+ objectName: "stages"
26+ anchors.fill: parent
27+
28+ // Controls to be set from outside
29+ property bool shown: false
30+ property bool moving: false
31+ property int dragAreaWidth
32+
33+ // State information propagated to the outside
34+ readonly property bool painting: mainStageImage.visible || sideStageImage.visible || sideStageSnapAnimation.running
35+ property bool fullscreen: priv.focusedApplication ? priv.focusedApplication.fullscreen : false
36+ property bool overlayMode: (sideStageImage.shown && priv.mainStageAppId.length == 0) || priv.overlayOverride
37+ || (priv.mainStageAppId.length == 0 && sideStageSnapAnimation.running)
38+
39+ readonly property int overlayWidth: priv.overlayOverride ? 0 : priv.sideStageWidth
40+
41+ onShownChanged: {
42+ if (!shown) {
43+ priv.mainStageAppId = "";
44+ }
45+ }
46+
47+ onMovingChanged: {
48+ if (moving) {
49+ if (!priv.mainStageAppId && !priv.sideStageAppId) {
50+ // Pulling in from the right, make the last used (topmost) app visible
51+ var application = ApplicationManager.get(0);
52+ if (application.stage == ApplicationInfoInterface.SideStage) {
53+ sideStageImage.application = application;
54+ sideStageImage.x = root.width - sideStageImage.width
55+ sideStageImage.visible = true;
56+ } else {
57+ mainStageImage.application = application;
58+ mainStageImage.visible = true;
59+ }
60+ } else {
61+ priv.requestNewScreenshot(ApplicationInfoInterface.MainStage)
62+ if (priv.focusedApplicationId == priv.sideStageAppId) {
63+ priv.requestNewScreenshot(ApplicationInfoInterface.SideStage)
64+ }
65+ }
66+ } else {
67+ mainStageImage.visible = false;
68+ sideStageImage.visible = false;
69+ }
70+ }
71+
72+ QtObject {
73+ id: priv
74+
75+ property int sideStageWidth: units.gu(40)
76+
77+
78+ property string sideStageAppId
79+ property string mainStageAppId
80+
81+
82+ property var sideStageApp: ApplicationManager.findApplication(sideStageAppId)
83+ property var mainStageApp: ApplicationManager.findApplication(mainStageAppId)
84+
85+ property string sideStageScreenshot: sideStageApp ? sideStageApp.screenshot : ""
86+ property string mainStageScreenshot: mainStageApp ? mainStageApp.screenshot : ""
87+
88+ property string focusedApplicationId: ApplicationManager.focusedApplicationId
89+ property var focusedApplication: ApplicationManager.findApplication(focusedApplicationId)
90+ property url focusedScreenshot: focusedApplication ? focusedApplication.screenshot : ""
91+
92+ property bool waitingForMainScreenshot: false
93+ property bool waitingForSideScreenshot: false
94+ property bool waitingForScreenshots: waitingForMainScreenshot || waitingForSideScreenshot
95+
96+ property string startingAppId: ""
97+
98+ // Keep overlayMode even if there is no focused app (to allow pulling in the sidestage from the right)
99+ property bool overlayOverride: false
100+
101+ onFocusedApplicationChanged: {
102+ if (focusedApplication) {
103+ if (focusedApplication.stage == ApplicationInfoInterface.MainStage) {
104+ mainStageAppId = focusedApplicationId;
105+ priv.overlayOverride = false;
106+ if (priv.startingAppId == focusedApplicationId && sideStageImage.shown) {
107+ // There was already a sidestage app on top. bring it back!
108+ ApplicationManager.focusApplication(priv.sideStageAppId)
109+ priv.startingAppId = "";
110+ }
111+ } else if (focusedApplication.stage == ApplicationInfoInterface.SideStage) {
112+ sideStageAppId = focusedApplicationId;
113+ if (priv.startingAppId == focusedApplicationId && !sideStageImage.shown) {
114+ sideStageImage.snapToApp(focusedApplication);
115+ priv.startingAppId = "";
116+ }
117+ }
118+ } else if (root.overlayMode){
119+ sideStageImage.snapTo(root.width)
120+ }
121+ }
122+
123+ onMainStageScreenshotChanged: {
124+ waitingForMainScreenshot = false;
125+ }
126+
127+ onSideStageScreenshotChanged: {
128+ waitingForSideScreenshot = false;
129+ }
130+
131+ onFocusedScreenshotChanged: {
132+ waitingForSideScreenshot = false;
133+ }
134+
135+ onWaitingForScreenshotsChanged: {
136+ if (waitingForScreenshots) {
137+ return;
138+ }
139+
140+ if (root.moving) {
141+ if (mainStageAppId) {
142+ mainStageImage.application = mainStageApp
143+ mainStageImage.visible = true;
144+ }
145+ if (sideStageAppId && focusedApplicationId == sideStageAppId) {
146+ sideStageImage.application = sideStageApp;
147+ sideStageImage.x = root.width - sideStageImage.width
148+ sideStageImage.visible = true;
149+ }
150+ }
151+ if (sideStageHandleMouseArea.pressed) {
152+ if (sideStageAppId) {
153+ sideStageImage.application = sideStageApp;
154+ sideStageImage.x = root.width - sideStageImage.width
155+ sideStageImage.visible = true;
156+ }
157+ if (mainStageAppId) {
158+ mainStageImage.application = mainStageApp
159+ mainStageImage.visible = true;
160+ }
161+ }
162+ }
163+
164+ function requestNewScreenshot(stage) {
165+ if (stage == ApplicationInfoInterface.MainStage && mainStageAppId) {
166+ waitingForMainScreenshot = true;
167+ ApplicationManager.updateScreenshot(mainStageAppId);
168+ } else if (stage == ApplicationInfoInterface.SideStage && sideStageAppId) {
169+ waitingForSideScreenshot = true;
170+ ApplicationManager.updateScreenshot(sideStageAppId);
171+ }
172+ }
173+
174+ }
175+ // FIXME: the signal connection seems to get lost with the fake application manager.
176+ Connections {
177+ target: priv.sideStageApp
178+ onScreenshotChanged: priv.sideStageScreenshot = priv.sideStageApp.screenshot
179+ }
180+ Connections {
181+ target: priv.mainStageApp
182+ onScreenshotChanged: priv.mainStageScreenshot = priv.mainStageApp.screenshot
183+ }
184+
185+ Connections {
186+ target: ApplicationManager
187+
188+ onApplicationAdded: {
189+ priv.startingAppId = appId;
190+ splashScreenTimer.start();
191+ var application = ApplicationManager.findApplication(appId)
192+ if (application.stage == ApplicationInfoInterface.SideStage) {
193+ sideStageSplash.visible = true;
194+ } else if (application.stage == ApplicationInfoInterface.MainStage) {
195+ mainStageSplash.visible = true;
196+ }
197+ }
198+
199+ onFocusRequested: {
200+ var application = ApplicationManager.findApplication(appId)
201+ if (application.stage == ApplicationInfoInterface.SideStage) {
202+ if (!root.shown) {
203+ priv.mainStageAppId = "";
204+ mainStageImage.application = null
205+ }
206+ if (sideStageImage.shown) {
207+ sideStageImage.switchTo(application);
208+ if (priv.mainStageAppId) {
209+ mainStageImage.application = priv.mainStageApp;
210+ mainStageImage.visible = true;
211+ }
212+ } else {
213+ sideStageImage.application = application;
214+ sideStageImage.snapToApp(application);
215+ }
216+ } else if (application.stage == ApplicationInfoInterface.MainStage) {
217+ if (root.shown) {
218+ if (sideStageImage.shown) {
219+ sideStageImage.application = priv.sideStageApp;
220+ sideStageImage.visible = true;
221+ }
222+ priv.mainStageAppId = application.appId;
223+ mainStageImage.switchTo(application)
224+ ApplicationManager.focusApplication(appId)
225+ if (sideStageImage.shown) {
226+ // There was already a focused SS app. Bring it back
227+ ApplicationManager.focusApplication(priv.sideStageAppId)
228+ }
229+ } else {
230+ if (sideStageImage.shown) {
231+ sideStageImage.visible = false;
232+ sideStageImage.x = root.width;
233+ }
234+
235+ mainStageImage.application = application;
236+ ApplicationManager.focusApplication(appId)
237+ }
238+ }
239+ }
240+
241+ onApplicationRemoved: {
242+ if (priv.mainStageAppId == appId) {
243+ priv.mainStageAppId = "";
244+ }
245+ if (priv.sideStageAppId == appId) {
246+ priv.sideStageAppId = "";
247+ }
248+ if (priv.sideStageAppId.length == 0) {
249+ sideStageImage.shown = false;
250+ priv.overlayOverride = false;
251+ }
252+ }
253+
254+ }
255+
256+ Timer {
257+ id: splashScreenTimer
258+ // FIXME: apart from removing this completely in the future and make the app surface paint
259+ // meaningful stuff, also check for colin's stuff to land so we can shape 1.4 secs away from here
260+ // https://code.launchpad.net/~cjwatson/upstart-app-launch/libclick-manifest/+merge/210520
261+ // https://code.launchpad.net/~cjwatson/upstart-app-launch/libclick-pkgdir/+merge/209909
262+ interval: 1700
263+ repeat: false
264+ onTriggered: {
265+ mainStageSplash.visible = false;
266+ sideStageSplash.visible = false;
267+ }
268+ }
269+
270+ SwitchingApplicationImage {
271+ id: mainStageImage
272+ anchors.bottom: parent.bottom
273+ width: parent.width
274+ visible: false
275+
276+ onSwitched: {
277+ sideStageImage.visible = false;
278+ }
279+ }
280+
281+ Rectangle {
282+ id: mainStageSplash
283+ anchors.fill: root
284+ anchors.rightMargin: root.width - sideStageImage.x
285+ color: "white"
286+ }
287+
288+ SidestageHandle {
289+ id: sideStageHandle
290+ anchors { top: parent.top; right: sideStageImage.left; bottom: parent.bottom }
291+ width: root.dragAreaWidth
292+ visible: root.shown && priv.sideStageAppId && sideStageImage.x < root.width
293+
294+ }
295+ MouseArea {
296+ id: sideStageHandleMouseArea
297+ anchors { top: parent.top; right: parent.right; bottom: parent.bottom; rightMargin: sideStageImage.shown ? sideStageImage.width : 0}
298+ width: root.dragAreaWidth
299+ visible: priv.sideStageAppId
300+
301+ property var dragPoints: new Array()
302+
303+ onPressed: {
304+ priv.requestNewScreenshot(ApplicationInfoInterface.SideStage)
305+ if (priv.mainStageAppId) {
306+ priv.requestNewScreenshot(ApplicationInfoInterface.MainStage)
307+ }
308+ }
309+
310+ onMouseXChanged: {
311+ dragPoints.push(mouseX)
312+
313+ var dragPoint = root.width + mouseX;
314+ if (sideStageImage.shown) {
315+ dragPoint -= sideStageImage.width
316+ }
317+ sideStageImage.x = Math.max(root.width - sideStageImage.width, dragPoint)
318+ }
319+
320+ onReleased: {
321+ var distance = 0;
322+ var lastX = dragPoints[0];
323+ var oneWayFlick = true;
324+ for (var i = 0; i < dragPoints.length; ++i) {
325+ if (dragPoints[i] < lastX) {
326+ oneWayFlick = false;
327+ }
328+ distance += dragPoints[i] - lastX;
329+ lastX = dragPoints[i];
330+ }
331+ dragPoints = [];
332+
333+ if (oneWayFlick || distance > sideStageImage.width / 2) {
334+ sideStageImage.snapTo(root.width)
335+ } else {
336+ sideStageImage.snapToApp(priv.sideStageApp)
337+ }
338+ }
339+ }
340+
341+ SwitchingApplicationImage {
342+ id: sideStageImage
343+ width: priv.sideStageWidth
344+ height: root.height
345+ x: root.width
346+ anchors.bottom: parent.bottom
347+ visible: true
348+ property bool shown: false
349+
350+ onSwitched: {
351+ mainStageImage.visible = false;
352+ ApplicationManager.focusApplication(application.appId)
353+ }
354+
355+ function snapTo(targetX) {
356+ sideStageSnapAnimation.targetX = targetX
357+ sideStageImage.visible = true;
358+ if (priv.mainStageAppId) {
359+ mainStageImage.application = priv.mainStageApp
360+ mainStageImage.visible = true;
361+ }
362+ sideStageSnapAnimation.start();
363+ }
364+
365+ function snapToApp(application) {
366+ sideStageImage.application = application
367+ sideStageSnapAnimation.snapToId = application.appId;
368+ snapTo(root.width - sideStageImage.width);
369+ }
370+
371+ SequentialAnimation {
372+ id: sideStageSnapAnimation
373+ property int targetX: root.width
374+ property string snapToId
375+
376+ UbuntuNumberAnimation { target: sideStageImage; property: "x"; to: sideStageSnapAnimation.targetX; duration: UbuntuAnimation.SlowDuration }
377+ ScriptAction {
378+ script: {
379+ if (sideStageSnapAnimation.targetX == root.width) {
380+ if (priv.mainStageAppId) {
381+ ApplicationManager.focusApplication(priv.mainStageAppId)
382+ } else {
383+ priv.overlayOverride = true;
384+ ApplicationManager.unfocusCurrentApplication();
385+ }
386+ sideStageImage.shown = false;
387+ }
388+ if (sideStageSnapAnimation.snapToId) {
389+ ApplicationManager.focusApplication(sideStageSnapAnimation.snapToId)
390+ sideStageSnapAnimation.snapToId = "";
391+ sideStageImage.shown = true;
392+ priv.overlayOverride = false;
393+ }
394+ sideStageImage.visible = false;
395+ mainStageImage.visible = false;
396+ }
397+ }
398+ }
399+ }
400+
401+ Rectangle {
402+ id: sideStageSplash
403+ anchors.fill: parent
404+ anchors.leftMargin: sideStageImage.x
405+ color: "white"
406+ }
407+}
qml/Stages/SwitchingApplicationImage.qmlnew file+81
@@ -0,0 +1,81 @@
1+/*
2+ * Copyright 2014 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+ * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17+*/
18+
19+import QtQuick 2.0
20+import Ubuntu.Components 0.1
21+
22+Rectangle {
23+ id: root
24+ implicitHeight: image.implicitHeight
25+ implicitWidth: image.implicitWidth
26+ color: "black"
27+
28+ property var application
29+
30+ signal switched()
31+
32+ function switchTo(application) {
33+ if (root.application == application) {
34+ root.switched();
35+ return;
36+ }
37+
38+ priv.newApplication = application
39+ root.visible = true;
40+ switchToAnimation.start()
41+ }
42+
43+ QtObject {
44+ id: priv
45+ property var newApplication
46+ }
47+
48+ Image {
49+ id: newImage
50+ anchors.bottom: parent.bottom
51+ width: root.width
52+ source: priv.newApplication ? priv.newApplication.screenshot : ""
53+ }
54+
55+ Image {
56+ id: image
57+ visible: true
58+ source: root.application ? root.application.screenshot : ""
59+ width: root.width
60+ height: sourceSize.height
61+ anchors.bottom: parent.bottom
62+
63+ }
64+
65+ SequentialAnimation {
66+ id: switchToAnimation
67+ ParallelAnimation {
68+ UbuntuNumberAnimation { target: image; property: "x"; from: 0; to: root.width; duration: UbuntuAnimation.SlowDuration }
69+ UbuntuNumberAnimation { target: newImage; property: "scale"; from: 0.7; to: 1; duration: UbuntuAnimation.SlowDuration }
70+ }
71+ ScriptAction {
72+ script: {
73+ image.x = 0
74+ root.application = priv.newApplication
75+ root.visible = false;
76+ priv.newApplication = null
77+ root.switched();
78+ }
79+ }
80+ }
81+}
qml/Stages/TransformedSpreadDelegate.qmlnew file+327
@@ -0,0 +1,327 @@
1+/*
2+ * Copyright 2014 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+ * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17+*/
18+
19+import QtQuick 2.0
20+import Utils 0.1
21+import Ubuntu.Components 0.1
22+
23+SpreadDelegate {
24+ id: root
25+
26+ property bool selected: false
27+ property bool otherSelected: false
28+
29+ // The progress animates the tiles. A value > 0 makes it appear from the right edge. At 1 it reaches the end position.
30+ property real progress: 0
31+ // This is required to snap tile 1 during phase 1 and 2.
32+ property real animatedProgress: 0
33+
34+ property real startAngle: 0
35+ property real endAngle: 0
36+
37+ property real startScale: 1
38+ property real endScale: 1
39+
40+ // Specific to just one tile
41+ property real tile1StartScale: startScale + .4
42+ property real tile0SnapAngle: 10
43+
44+ property real startDistance: units.gu(5)
45+ property real endDistance: units.gu(.5)
46+
47+ onSelectedChanged: {
48+ if (selected) {
49+ priv.snapshot();
50+ }
51+ priv.isSelected = selected;
52+ }
53+
54+ onOtherSelectedChanged: {
55+ if (otherSelected) {
56+ priv.snapshot();
57+ }
58+ priv.otherSelected = otherSelected;
59+ }
60+
61+ Connections {
62+ target: spreadView
63+ onPhaseChanged: {
64+ if (spreadView.phase == 1) {
65+ if (index == 0) {
66+ priv.phase2startTranslate = priv.easingAnimation(0, spreadView.positionMarker4, 0, -spreadView.width, spreadView.positionMarker4) + spreadView.width;
67+ priv.phase2startAngle = priv.easingAnimation(0, spreadView.positionMarker4, root.startAngle, root.endAngle, spreadView.positionMarker4);
68+ priv.phase2startScale = priv.easingAnimation(0, spreadView.positionMarker4, root.startScale, root.endScale, spreadView.positionMarker4);
69+ priv.phase2startTopMarginProgress = priv.easingAnimation(0, 1, 0, 1, spreadView.positionMarker4);
70+ } else if (index == 1) {
71+ // find where the main easing for Tile 1 would be when reaching phase 2
72+ var phase2Progress = spreadView.positionMarker4 - spreadView.tileDistance / spreadView.width;
73+ priv.phase2startTranslate = priv.easingAnimation(0, phase2Progress, 0, -spreadView.width + root.endDistance, phase2Progress);
74+ priv.phase2startAngle = priv.easingAnimation(0, phase2Progress, root.startAngle, root.endAngle, phase2Progress);
75+ priv.phase2startScale = priv.easingAnimation(0, phase2Progress, root.startScale, root.endScale, phase2Progress);
76+ priv.phase2startTopMarginProgress = priv.easingAnimation(0, 1, 0, spreadView.positionMarker4, phase2Progress);
77+ }
78+ }
79+ }
80+ }
81+
82+ QtObject {
83+ id: priv
84+ property bool isSelected: false
85+ property bool otherSelected: false
86+ property real selectedProgress
87+ property real selectedXTranslate
88+ property real selectedAngle
89+ property real selectedScale
90+ property real selectedOpacity
91+ property real selectedTopMarginProgress
92+
93+ // Those values are needed as target values for the end of phase 1.
94+ // As they are static values, lets calculate them once when entering phase 1 instead of calculating them in each animation pass.
95+ property real phase2startTranslate
96+ property real phase2startAngle
97+ property real phase2startScale
98+ property real phase2startTopMarginProgress
99+
100+ function snapshot() {
101+ selectedProgress = root.progress;
102+ selectedXTranslate = xTranslate;
103+ selectedAngle = angle;
104+ selectedScale = scale;
105+ selectedOpacity = opacity;
106+ selectedTopMarginProgress = topMarginProgress;
107+ }
108+
109+ // This calculates how much negative progress there can be if unwinding the spread completely
110+ // the progress for each tile starts at 0 when it crosses the right edge, so the later a tile comes in,
111+ // the bigger its negativeProgress can be.
112+ property real negativeProgress: {
113+ if (index == 1 && spreadView.phase < 2) {
114+ return 0;
115+ }
116+ return -index * spreadView.tileDistance / spreadView.width;
117+ }
118+
119+ function linearAnimation(startProgress, endProgress, startValue, endValue, progress) {
120+ // progress : progressDiff = value : valueDiff => value = progress * valueDiff / progressDiff
121+ return (progress - startProgress) * (endValue - startValue) / (endProgress - startProgress) + startValue;
122+ }
123+
124+ function easingAnimation(startProgress, endProgress, startValue, endValue, progress) {
125+ helperEasingCurve.progress = progress - startProgress;
126+ helperEasingCurve.period = endProgress - startProgress;
127+ return helperEasingCurve.value * (endValue - startValue) + startValue;
128+ }
129+
130+ property real animatedEndDistance: linearAnimation(0, 2, root.endDistance, 0, root.progress)
131+
132+ // The following blocks handle the animation of the tile in the spread.
133+ // At the beginning, each tile is attached at the right edge, outside the screen.
134+ // The progress for each tile starts at 0 and it reaches its end position at a progress of 1.
135+ // The first phases are handled special for the first 2 tiles. as we do the alt-tab and snapping in there
136+ // Once we reached phase 3, the animation is the same for all tiles.
137+ // When a tile is selected, the animation state is snapshotted, and the spreadView is unwound (progress animates
138+ // back to negativeProgress). All tiles are kept in place and faded out to 0 opacity except
139+ // the selected tile, which is animated from the snapshotted position to be fullscreen.
140+
141+ property real xTranslate: {
142+ if (otherSelected) {
143+ if (spreadView.phase < 2 && index == 0) {
144+ return linearAnimation(selectedProgress, negativeProgress,
145+ selectedXTranslate, selectedXTranslate - spreadView.tileDistance, root.progress);
146+ }
147+
148+ return selectedXTranslate;
149+ }
150+
151+ switch (index) {
152+ case 0:
153+ if (spreadView.phase == 0) {
154+ return Math.min(0, linearAnimation(0, spreadView.positionMarker2,
155+ 0, -spreadView.width * .25, root.animatedProgress));
156+ } else if (spreadView.phase == 1){
157+ return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
158+ -spreadView.width * .25, priv.phase2startTranslate, root.progress);
159+ } else if (!priv.isSelected){ // phase 2
160+ // Apply the same animation as with the rest but add spreadView.width to align it with the others.
161+ return -easingCurve.value * spreadView.width + spreadView.width;
162+ } else if (priv.isSelected) {
163+ return linearAnimation(selectedProgress, negativeProgress, selectedXTranslate, 0, root.progress);
164+ }
165+
166+ case 1:
167+ if (spreadView.phase == 0 && !priv.isSelected) {
168+ return linearAnimation(0, spreadView.positionMarker2,
169+ 0, -spreadView.width * spreadView.snapPosition, root.animatedProgress);
170+ } else if (spreadView.phase == 1 && !priv.isSelected) {
171+ return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
172+ -spreadView.width * spreadView.snapPosition, priv.phase2startTranslate,
173+ root.progress);
174+ }
175+ }
176+
177+ if (priv.isSelected) {
178+ // Distance to left edge
179+ var targetTranslate = -spreadView.width - ((index - 1) * root.startDistance);
180+ return linearAnimation(selectedProgress, negativeProgress,
181+ selectedXTranslate, targetTranslate, root.progress);
182+ }
183+
184+ // Fix it at the right edge...
185+ var rightEdgeOffset = -((index - 1) * root.startDistance);
186+ // ...and use our easing to move them to the left. Stop a bit earlier for each tile
187+ return -easingCurve.value * spreadView.width + (index * animatedEndDistance) + rightEdgeOffset;
188+
189+ }
190+
191+ property real angle: {
192+ if (priv.otherSelected) {
193+ return priv.selectedAngle;
194+ }
195+ if (priv.isSelected) {
196+ return linearAnimation(selectedProgress, negativeProgress, selectedAngle, 0, root.progress);
197+ }
198+ switch (index) {
199+ case 0:
200+ if (spreadView.phase == 0) {
201+ return Math.max(0, linearAnimation(0, spreadView.positionMarker2,
202+ 0, root.tile0SnapAngle, root.animatedProgress));
203+ } else if (spreadView.phase == 1) {
204+ return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
205+ root.tile0SnapAngle, phase2startAngle, root.progress);
206+ }
207+ case 1:
208+ if (spreadView.phase == 0) {
209+ return linearAnimation(0, spreadView.positionMarker2, root.startAngle,
210+ root.startAngle * (1-spreadView.snapPosition), root.animatedProgress);
211+ } else if (spreadView.phase == 1) {
212+ return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
213+ root.startAngle * (1-spreadView.snapPosition), priv.phase2startAngle,
214+ root.progress);
215+ }
216+ }
217+ return root.startAngle - easingCurve.value * (root.startAngle - root.endAngle);
218+ }
219+
220+ property real scale: {
221+ if (priv.otherSelected) {
222+ return priv.selectedScale;
223+ }
224+ if (priv.isSelected) {
225+ return linearAnimation(selectedProgress, negativeProgress, selectedScale, 1, root.progress);
226+ }
227+
228+ switch (index) {
229+ case 0:
230+ if (spreadView.phase == 0) {
231+ return 1;
232+ } else if (spreadView.phase == 1) {
233+ return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
234+ 1, phase2startScale, root.progress);
235+ }
236+ case 1:
237+ if (spreadView.phase == 0) {
238+ var targetScale = tile1StartScale - ((tile1StartScale - 1) * spreadView.snapPosition);
239+ return linearAnimation(0, spreadView.positionMarker2,
240+ root.tile1StartScale, targetScale, root.animatedProgress);
241+ } else if (spreadView.phase == 1) {
242+ var startScale = tile1StartScale - ((tile1StartScale - 1) * spreadView.snapPosition);
243+ return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
244+ startScale, priv.phase2startScale, root.progress);
245+ }
246+ }
247+ return root.startScale - easingCurve.value * (root.startScale - root.endScale);
248+ }
249+
250+ property real opacity: {
251+ if (priv.otherSelected) {
252+ return linearAnimation (selectedProgress, Math.max(0, selectedProgress - .5),
253+ selectedOpacity, 0, root.progress);
254+ }
255+ if (index == 0) {
256+ switch (spreadView.phase) {
257+ case 0:
258+ return linearAnimation(0, spreadView.positionMarker2, 1, .3, root.animatedProgress);
259+ case 1:
260+ return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
261+ .3, 1, root.animatedProgress);
262+ }
263+ }
264+
265+ return 1;
266+ }
267+
268+ property real topMarginProgress: {
269+ if (priv.isSelected) {
270+ return linearAnimation(selectedProgress, negativeProgress, selectedTopMarginProgress, 0, root.progress);
271+ }
272+
273+ switch (index) {
274+ case 0:
275+ if (spreadView.phase == 0) {
276+ return 0;
277+ } else if (spreadView.phase == 1) {
278+ return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
279+ 0, priv.phase2startTopMarginProgress, root.progress);
280+ }
281+ break;
282+ case 1:
283+ if (spreadView.phase == 0) {
284+ return 0;
285+ } else if (spreadView.phase == 1) {
286+ return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4,
287+ 0, priv.phase2startTopMarginProgress, root.progress);
288+ }
289+ }
290+
291+ return easingCurve.value;
292+ }
293+ }
294+
295+ transform: [
296+ Rotation {
297+ origin { x: 0; y: spreadView.height / 2 }
298+ axis { x: 0; y: 1; z: 0 }
299+ angle: priv.angle
300+ },
301+ Scale {
302+ origin { x: 0; y: spreadView.height / 2 }
303+ xScale: priv.scale
304+ yScale: xScale
305+ },
306+ Translate {
307+ x: priv.xTranslate
308+ }
309+ ]
310+ opacity: priv.opacity
311+ topMarginProgress: priv.topMarginProgress
312+
313+ EasingCurve {
314+ id: easingCurve
315+ type: EasingCurve.OutSine
316+ period: 1 - spreadView.positionMarker2
317+ progress: root.animatedProgress
318+ }
319+
320+ // This is used as a calculation helper to figure values for progress other than the current one
321+ // Do not bind anything to this...
322+ EasingCurve {
323+ id: helperEasingCurve
324+ type: easingCurve.type
325+ period: easingCurve.period
326+ }
327+}
qml/Stages/graphics/dropshadow.pngnew file

Binary file not shown.

qml/SideStage/graphics/sidestage_handle@20.png → qml/Stages/graphics/sidestage_handle@20.pngrenamed

Binary file not shown.

qml/SideStage/graphics/sidestage_handle@20.sci → qml/Stages/graphics/sidestage_handle@20.scirenamed

The content is the same.

tests/autopilot/unity8/shell/emulators/dash.py+1−4
@@ -80,10 +80,7 @@ class Dash(emulators.UnityEmulatorBase):
8080 'No scope found with id {0}'.format(scope_id))
8181
8282 def _get_scope_from_loader(self, loader):
83− if loader.scopeId == 'clickscope':
84− return loader.select_single(DashApps)
85− else:
86− return loader.select_single(GenericScopeView)
83+ return loader.get_children()[0]
8784
8885 def _open_scope_scrolling(self, scope_loader):
8986 scroll = self._get_scroll_direction(scope_loader)
tests/autopilot/unity8/shell/emulators/main_window.py+1−1
@@ -112,4 +112,4 @@ class QQuickView(emulators.UnityEmulatorBase):
112112
113113 def get_current_focused_app_id(self):
114114 """Return the id of the focused application."""
115− return self.select_single('Shell').currentFocusedAppId
115+ return self.select_single('Shell').focusedApplicationId
tests/mocks/Unity/Application/ApplicationInfo.cpp+9
@@ -20,6 +20,7 @@
2020#include <QQuickItem>
2121#include <QQuickView>
2222#include <QQmlComponent>
23+#include <QTimer>
2324
2425ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
2526 : ApplicationInfoInterface(appId, parent)
@@ -32,6 +33,7 @@ ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
3233 ,m_windowComponent(0)
3334 ,m_parentItem(0)
3435{
36+ QTimer::singleShot(300, this, SLOT(setRunning()));
3537}
3638
3739ApplicationInfo::ApplicationInfo(QObject *parent)
@@ -44,6 +46,7 @@ ApplicationInfo::ApplicationInfo(QObject *parent)
4446 ,m_windowComponent(0)
4547 ,m_parentItem(0)
4648{
49+ QTimer::singleShot(300, this, SLOT(setRunning()));
4750}
4851
4952void ApplicationInfo::onWindowComponentStatusChanged(QQmlComponent::Status status)
@@ -52,6 +55,12 @@ void ApplicationInfo::onWindowComponentStatusChanged(QQmlComponent::Status statu
5255 doCreateWindowItem();
5356}
5457
58+void ApplicationInfo::setRunning()
59+{
60+ m_state = Running;
61+ Q_EMIT stateChanged();
62+}
63+
5564void ApplicationInfo::createWindowComponent()
5665{
5766 // The assumptions I make here really should hold.
tests/mocks/Unity/Application/ApplicationInfo.h+2
@@ -74,6 +74,7 @@ class ApplicationInfo : public ApplicationInfoInterface {
7474 IMPLEMENT_PROPERTY(fullscreen, Fullscreen, bool)
7575 IMPLEMENT_PROPERTY(imageQml, ImageQml, QString)
7676 IMPLEMENT_PROPERTY(windowQml, WindowQml, QString)
77+ IMPLEMENT_PROPERTY(screenshot, Screenshot, QUrl)
7778
7879 #undef IMPLEMENT_PROPERTY
7980
@@ -83,6 +84,7 @@ class ApplicationInfo : public ApplicationInfoInterface {
8384
8485 private Q_SLOTS:
8586 void onWindowComponentStatusChanged(QQmlComponent::Status status);
87+ void setRunning();
8688
8789 private:
8890 void createWindowItem();
tests/mocks/Unity/Application/ApplicationManager.cpp+109−3
@@ -24,13 +24,17 @@
2424#include <QQuickItem>
2525#include <QQuickView>
2626#include <QQmlComponent>
27+#include <QTimer>
28+#include <QDateTime>
2729
2830ApplicationManager::ApplicationManager(QObject *parent)
2931 : ApplicationManagerInterface(parent)
32+ , m_suspended(false)
3033 , m_mainStageComponent(0)
3134 , m_mainStage(0)
3235 , m_sideStageComponent(0)
3336 , m_sideStage(0)
37+ , m_rightMargin(0)
3438{
3539 buildListOfAvailableApplications();
3640}
@@ -63,6 +67,8 @@ QVariant ApplicationManager::data(const QModelIndex& index, int role) const {
6367 return app->state();
6468 case RoleFocused:
6569 return app->focused();
70+ case RoleScreenshot:
71+ return app->screenshot();
6672 default:
6773 return QVariant();
6874 }
@@ -84,13 +90,16 @@ ApplicationInfo *ApplicationManager::findApplication(const QString &appId) const
8490}
8591
8692void ApplicationManager::add(ApplicationInfo *application) {
87− if (!application)
93+ if (!application) {
8894 return;
95+ }
8996
9097 beginInsertRows(QModelIndex(), m_runningApplications.size(), m_runningApplications.size());
9198 m_runningApplications.append(application);
9299 endInsertRows();
100+ Q_EMIT applicationAdded(application->appId());
93101 Q_EMIT countChanged();
102+ Q_EMIT focusRequested(application->appId());
94103}
95104
96105void ApplicationManager::remove(ApplicationInfo *application) {
@@ -99,6 +108,7 @@ void ApplicationManager::remove(ApplicationInfo *application) {
99108 beginRemoveRows(QModelIndex(), i, i);
100109 m_runningApplications.removeAt(i);
101110 endRemoveRows();
111+ Q_EMIT applicationRemoved(application->appId());
102112 Q_EMIT countChanged();
103113 }
104114}
@@ -171,6 +181,8 @@ ApplicationInfo* ApplicationManager::startApplication(const QString &appId,
171181 }
172182 add(application);
173183
184+ QMetaObject::invokeMethod(this, "focusApplication", Qt::QueuedConnection, Q_ARG(QString, appId));
185+
174186 return application;
175187}
176188
@@ -180,8 +192,32 @@ bool ApplicationManager::stopApplication(const QString &appId)
180192 if (application == nullptr)
181193 return false;
182194
195+ if (application->appId() == focusedApplicationId()) {
196+ unfocusCurrentApplication();
197+ }
183198 remove(application);
184− Q_EMIT focusedApplicationIdChanged();
199+ return true;
200+}
201+
202+bool ApplicationManager::updateScreenshot(const QString &appId)
203+{
204+ int idx = -1;
205+ ApplicationInfo *application = nullptr;
206+ for (int i = 0; i < m_availableApplications.count(); ++i) {
207+ application = m_availableApplications.at(i);
208+ if (application->appId() == appId) {
209+ idx = i;
210+ break;
211+ }
212+ }
213+
214+ if (idx == -1) {
215+ return false;
216+ }
217+
218+ application->setScreenshot(QString("image://application/%1/%2").arg(appId).arg(QDateTime::currentMSecsSinceEpoch()));
219+ QModelIndex appIndex = index(idx);
220+ Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << RoleScreenshot);
185221 return true;
186222}
187223
@@ -194,6 +230,25 @@ QString ApplicationManager::focusedApplicationId() const {
194230 return QString();
195231}
196232
233+bool ApplicationManager::suspended() const
234+{
235+ return m_suspended;
236+}
237+
238+void ApplicationManager::setSuspended(bool suspended)
239+{
240+ ApplicationInfo *focusedApp = findApplication(focusedApplicationId());
241+ if (focusedApp) {
242+ if (suspended) {
243+ focusedApp->setState(ApplicationInfo::Suspended);
244+ } else {
245+ focusedApp->setState(ApplicationInfo::Running);
246+ }
247+ }
248+ m_suspended = suspended;
249+ Q_EMIT suspendedChanged();
250+}
251+
197252bool ApplicationManager::focusApplication(const QString &appId)
198253{
199254 ApplicationInfo *application = findApplication(appId);
@@ -242,6 +297,15 @@ bool ApplicationManager::focusApplication(const QString &appId)
242297 return true;
243298}
244299
300+bool ApplicationManager::requestFocusApplication(const QString &appId)
301+{
302+ if (appId != focusedApplicationId()) {
303+ QMetaObject::invokeMethod(this, "focusRequested", Qt::QueuedConnection, Q_ARG(QString, appId));
304+ return true;
305+ }
306+ return false;
307+}
308+
245309void ApplicationManager::unfocusCurrentApplication()
246310{
247311 for (ApplicationInfo *app : m_runningApplications) {
@@ -270,10 +334,12 @@ void ApplicationManager::generateQmlStrings(ApplicationInfo *application)
270334 "Image {\n"
271335 " anchors.fill: parent\n"
272336 " anchors.topMargin: %1\n"
273− " source: \"file://%2/Dash/graphics/phone/screenshots/%3.png\"\n"
337+ " anchors.rightMargin: %2\n"
338+ " source: \"file://%3/Dash/graphics/phone/screenshots/%4.png\"\n"
274339 " smooth: true\n"
275340 " fillMode: Image.PreserveAspectCrop\n"
276341 "}").arg(topMargin)
342+ .arg(m_rightMargin)
277343 .arg(qmlDirectory())
278344 .arg(application->icon().toString());
279345 application->setWindowQml(windowQml);
@@ -299,6 +365,7 @@ void ApplicationManager::buildListOfAvailableApplications()
299365 application->setName("Phone");
300366 application->setIcon(QUrl("phone"));
301367 application->setStage(ApplicationInfo::SideStage);
368+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
302369 generateQmlStrings(application);
303370 m_availableApplications.append(application);
304371
@@ -307,6 +374,7 @@ void ApplicationManager::buildListOfAvailableApplications()
307374 application->setName("Camera");
308375 application->setIcon(QUrl("camera"));
309376 application->setFullscreen(true);
377+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
310378 generateQmlStrings(application);
311379 m_availableApplications.append(application);
312380
@@ -314,6 +382,7 @@ void ApplicationManager::buildListOfAvailableApplications()
314382 application->setAppId("gallery-app");
315383 application->setName("Gallery");
316384 application->setIcon(QUrl("gallery"));
385+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
317386 generateQmlStrings(application);
318387 m_availableApplications.append(application);
319388
@@ -322,13 +391,16 @@ void ApplicationManager::buildListOfAvailableApplications()
322391 application->setName("Facebook");
323392 application->setIcon(QUrl("facebook"));
324393 application->setStage(ApplicationInfo::SideStage);
394+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
325395 generateQmlStrings(application);
326396 m_availableApplications.append(application);
327397
328398 application = new ApplicationInfo(this);
329399 application->setAppId("webbrowser-app");
400+ application->setFullscreen(true);
330401 application->setName("Browser");
331402 application->setIcon(QUrl("browser"));
403+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
332404 generateQmlStrings(application);
333405 m_availableApplications.append(application);
334406
@@ -337,6 +409,7 @@ void ApplicationManager::buildListOfAvailableApplications()
337409 application->setName("Twitter");
338410 application->setIcon(QUrl("twitter"));
339411 application->setStage(ApplicationInfo::SideStage);
412+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
340413 generateQmlStrings(application);
341414 m_availableApplications.append(application);
342415
@@ -344,6 +417,7 @@ void ApplicationManager::buildListOfAvailableApplications()
344417 application->setAppId("gmail-webapp");
345418 application->setName("GMail");
346419 application->setIcon(QUrl("gmail"));
420+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
347421 m_availableApplications.append(application);
348422
349423 application = new ApplicationInfo(this);
@@ -351,6 +425,7 @@ void ApplicationManager::buildListOfAvailableApplications()
351425 application->setName("Weather");
352426 application->setIcon(QUrl("weather"));
353427 application->setStage(ApplicationInfo::SideStage);
428+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
354429 generateQmlStrings(application);
355430 m_availableApplications.append(application);
356431
@@ -359,6 +434,7 @@ void ApplicationManager::buildListOfAvailableApplications()
359434 application->setName("Notepad");
360435 application->setIcon(QUrl("notepad"));
361436 application->setStage(ApplicationInfo::SideStage);
437+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
362438 m_availableApplications.append(application);
363439
364440 application = new ApplicationInfo(this);
@@ -366,6 +442,7 @@ void ApplicationManager::buildListOfAvailableApplications()
366442 application->setName("Calendar");
367443 application->setIcon(QUrl("calendar"));
368444 application->setStage(ApplicationInfo::SideStage);
445+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
369446 m_availableApplications.append(application);
370447
371448 application = new ApplicationInfo(this);
@@ -373,18 +450,21 @@ void ApplicationManager::buildListOfAvailableApplications()
373450 application->setName("Media Player");
374451 application->setIcon(QUrl("mediaplayer-app"));
375452 application->setFullscreen(true);
453+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
376454 m_availableApplications.append(application);
377455
378456 application = new ApplicationInfo(this);
379457 application->setAppId("evernote");
380458 application->setName("Evernote");
381459 application->setIcon(QUrl("evernote"));
460+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
382461 m_availableApplications.append(application);
383462
384463 application = new ApplicationInfo(this);
385464 application->setAppId("map");
386465 application->setName("Map");
387466 application->setIcon(QUrl("map"));
467+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
388468 generateQmlStrings(application);
389469 m_availableApplications.append(application);
390470
@@ -392,24 +472,28 @@ void ApplicationManager::buildListOfAvailableApplications()
392472 application->setAppId("pinterest");
393473 application->setName("Pinterest");
394474 application->setIcon(QUrl("pinterest"));
475+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
395476 m_availableApplications.append(application);
396477
397478 application = new ApplicationInfo(this);
398479 application->setAppId("soundcloud");
399480 application->setName("SoundCloud");
400481 application->setIcon(QUrl("soundcloud"));
482+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
401483 m_availableApplications.append(application);
402484
403485 application = new ApplicationInfo(this);
404486 application->setAppId("wikipedia");
405487 application->setName("Wikipedia");
406488 application->setIcon(QUrl("wikipedia"));
489+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
407490 m_availableApplications.append(application);
408491
409492 application = new ApplicationInfo(this);
410493 application->setAppId("youtube");
411494 application->setName("YouTube");
412495 application->setIcon(QUrl("youtube"));
496+ application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
413497 m_availableApplications.append(application);
414498}
415499
@@ -484,3 +568,25 @@ void ApplicationManager::createSideStage()
484568 m_sideStage->setParentItem(shell);
485569 m_sideStage->setFlag(QQuickItem::ItemHasContents, false);
486570}
571+
572+QStringList ApplicationManager::availableApplications()
573+{
574+ QStringList appIds;
575+ Q_FOREACH(ApplicationInfo *app, m_availableApplications) {
576+ appIds << app->appId();
577+ }
578+ return appIds;
579+}
580+
581+int ApplicationManager::rightMargin() const
582+{
583+ return m_rightMargin;
584+}
585+
586+void ApplicationManager::setRightMargin(int rightMargin)
587+{
588+ m_rightMargin = rightMargin;
589+ Q_FOREACH(ApplicationInfo *app, m_availableApplications) {
590+ generateQmlStrings(app);
591+ }
592+}
tests/mocks/Unity/Application/ApplicationManager.h+16
@@ -45,6 +45,10 @@ class ApplicationManager : public ApplicationManagerInterface {
4545
4646 Q_PROPERTY(bool fake READ fake CONSTANT)
4747
48+ // Only for testing
49+ // This can be used to place some controls to right, like make tryPhoneStage for example
50+ Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin)
51+
4852 public:
4953 ApplicationManager(QObject *parent = NULL);
5054 virtual ~ApplicationManager();
@@ -87,13 +91,22 @@ class ApplicationManager : public ApplicationManagerInterface {
8791 Q_INVOKABLE void move(int from, int to);
8892
8993 // Application control methods
94+ Q_INVOKABLE bool requestFocusApplication(const QString &appId) override;
9095 Q_INVOKABLE bool focusApplication(const QString &appId) override;
9196 Q_INVOKABLE void unfocusCurrentApplication() override;
9297 Q_INVOKABLE ApplicationInfo *startApplication(const QString &appId, const QStringList &arguments = QStringList()) override;
9398 Q_INVOKABLE ApplicationInfo *startApplication(const QString &appId, ExecFlags flags, const QStringList &arguments = QStringList());
9499 Q_INVOKABLE bool stopApplication(const QString &appId) override;
100+ Q_INVOKABLE bool updateScreenshot(const QString &appId) override;
95101
96102 QString focusedApplicationId() const override;
103+ bool suspended() const;
104+ void setSuspended(bool suspended);
105+
106+ // Only for testing
107+ Q_INVOKABLE QStringList availableApplications();
108+ int rightMargin() const;
109+ void setRightMargin(int rightMargin);
97110
98111 Q_SIGNALS:
99112 void keyboardHeightChanged();
@@ -113,12 +126,15 @@ class ApplicationManager : public ApplicationManagerInterface {
113126 void createSideStage();
114127 int m_keyboardHeight;
115128 bool m_keyboardVisible;
129+ bool m_suspended;
116130 QList<ApplicationInfo*> m_runningApplications;
117131 QList<ApplicationInfo*> m_availableApplications;
118132 QQmlComponent *m_mainStageComponent;
119133 QQuickItem *m_mainStage;
120134 QQmlComponent *m_sideStageComponent;
121135 QQuickItem *m_sideStage;
136+
137+ int m_rightMargin;
122138};
123139
124140Q_DECLARE_OPERATORS_FOR_FLAGS(ApplicationManager::ExecFlags)
tests/mocks/Unity/Application/ApplicationScreenshotProvider.cppnew file+74
@@ -0,0 +1,74 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
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
6+ * the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but WITHOUT
9+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+ * 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+#include "ApplicationScreenshotProvider.h"
18+#include "ApplicationManager.h"
19+#include "ApplicationInfo.h"
20+
21+#include "paths.h"
22+
23+#include <QDebug>
24+#include <QGuiApplication>
25+#include <QWindow>
26+#include <QQuickWindow>
27+
28+ApplicationScreenshotProvider::ApplicationScreenshotProvider(ApplicationManager *appManager)
29+ : QQuickImageProvider(QQuickImageProvider::Image)
30+ , m_appManager(appManager)
31+{
32+}
33+
34+QImage ApplicationScreenshotProvider::requestImage(const QString &imageId, QSize * size,
35+ const QSize &requestedSize)
36+{
37+ // We ignore requestedSize here intentionally to avoid keeping scaled copies around
38+ Q_UNUSED(requestedSize)
39+
40+ QString appId = imageId.split('/').first();
41+
42+ ApplicationInfo* app = static_cast<ApplicationInfo*>(m_appManager->findApplication(appId));
43+ if (app == nullptr) {
44+ return QImage();
45+ }
46+
47+ QString filePath = QString("%1/Dash/graphics/phone/screenshots/%2@12.png").arg(qmlDirectory()).arg(app->icon().toString());
48+
49+ QImage image;
50+ if (!image.load(filePath)) {
51+ qWarning() << "failed loading app image" << filePath;
52+ }
53+
54+
55+ if (app->stage() == ApplicationInfo::SideStage) {
56+ QByteArray gus = qgetenv("GRID_UNIT_PX");
57+ image = image.scaledToWidth(gus.toInt() * 48);
58+ } else {
59+ // Lets scale main stage applications to be the size of the screen/window.
60+ QGuiApplication *unity = qobject_cast<QGuiApplication*>(qApp);
61+ Q_FOREACH (QWindow *win, unity->allWindows()) {
62+ QQuickWindow *quickWin = qobject_cast<QQuickWindow*>(win);
63+ if (quickWin) {
64+ image = image.scaledToWidth(quickWin->width() - m_appManager->rightMargin());
65+ break;
66+ }
67+ }
68+ }
69+
70+ size->setWidth(image.width());
71+ size->setHeight(image.height());
72+
73+ return image;
74+}
tests/mocks/Unity/Application/ApplicationScreenshotProvider.hnew file+34
@@ -0,0 +1,34 @@
1+/*
2+ * Copyright (C) 201 Canonical, Ltd.
3+ *
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
6+ * the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but WITHOUT
9+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+ * 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+#ifndef APPLICATIONSCREENSHOTPROVIDER_H
18+#define APPLICATIONSCREENSHOTPROVIDER_H
19+
20+#include <QQuickImageProvider>
21+
22+class ApplicationManager;
23+class ApplicationScreenshotProvider : public QQuickImageProvider
24+{
25+public:
26+ explicit ApplicationScreenshotProvider(ApplicationManager *appManager);
27+
28+ QImage requestImage(const QString &appId, QSize *size, const QSize &requestedSize) override;
29+
30+private:
31+ ApplicationManager* m_appManager;
32+};
33+
34+#endif // APPLICATIONSCREENSHOTPROVIDER_H
tests/mocks/Unity/Application/CMakeLists.txt+1
@@ -5,6 +5,7 @@ set(FakeUnityApplicationQml_SOURCES
55 ApplicationInfo.cpp
66 ApplicationImage.cpp
77 ApplicationManager.cpp
8+ ApplicationScreenshotProvider.cpp
89 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
910 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
1011)
tests/mocks/Unity/Application/plugin.cpp+18−3
@@ -18,13 +18,20 @@
1818#include "ApplicationInfo.h"
1919#include "ApplicationImage.h"
2020#include "ApplicationManager.h"
21+#include "ApplicationScreenshotProvider.h"
2122
2223#include <qqml.h>
24+#include <QQmlEngine>
25+
26+ApplicationManager *s_appManager = 0;
2327
2428static QObject* applicationManagerSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
25− Q_UNUSED(engine);
26− Q_UNUSED(scriptEngine);
27− return new ApplicationManager();
29+ Q_UNUSED(engine);
30+ Q_UNUSED(scriptEngine);
31+ if (!s_appManager) {
32+ s_appManager = new ApplicationManager();
33+ }
34+ return s_appManager;
2835}
2936
3037void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
@@ -37,3 +44,11 @@ void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
3744
3845 qmlRegisterType<ApplicationImage>(uri, 0, 1, "ApplicationImage");
3946}
47+
48+void FakeUnityApplicationQmlPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
49+{
50+ QQmlExtensionPlugin::initializeEngine(engine, uri);
51+
52+ ApplicationManager* appManager = static_cast<ApplicationManager*>(applicationManagerSingleton(engine, NULL));
53+ engine->addImageProvider(QLatin1String("application"), new ApplicationScreenshotProvider(appManager));
54+}
tests/mocks/Unity/Application/plugin.h+1
@@ -25,6 +25,7 @@ class FakeUnityApplicationQmlPlugin : public QQmlExtensionPlugin
2525 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
2626public:
2727 void registerTypes(const char *uri);
28+ void initializeEngine(QQmlEngine *engine, const char *uri);
2829};
2930
3031#endif
tests/plugins/Unity/Launcher/launchermodeltest.cpp+5
@@ -39,6 +39,7 @@ public:
3939 ApplicationInfoInterface::Stage stage() const { return ApplicationInfoInterface::MainStage; }
4040 ApplicationInfoInterface::State state() const { return ApplicationInfoInterface::Running; }
4141 bool focused() const { return m_focused; }
42+ QUrl screenshot() const { return QUrl(); }
4243
4344 // Methods used for mocking (not in the interface)
4445 void setFocused(bool focused) { m_focused = focused; Q_EMIT focusedChanged(focused); }
@@ -92,6 +93,10 @@ public:
9293 m_list.takeAt(index)->deleteLater();
9394 endRemoveRows();
9495 }
96+ bool updateScreenshot(const QString &appId) { Q_UNUSED(appId); return true; }
97+ bool requestFocusApplication(const QString &appId) { Q_UNUSED(appId); return true; }
98+ bool suspended() const { return false; }
99+ void setSuspended(bool) {}
95100
96101private:
97102 QList<MockApp*> m_list;
tests/qmltests/CMakeLists.txt+1−1
@@ -84,6 +84,6 @@ add_qml_test(Panel/Indicators DefaultIndicatorPage IMPORT_PATHS ${CMAKE_BINARY_D
8484 ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
8585add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
8686add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
87−add_qml_test(SideStage SideStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
87+add_qml_test(Stages PhoneStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
8888 ${CMAKE_BINARY_DIR}/tests/mocks
8989 ${CMAKE_BINARY_DIR}/plugins)
tests/qmltests/Components/tst_ResponsiveFlowView.qml+1−2
@@ -82,8 +82,7 @@ Item {
8282 ResponsiveFlowView {
8383 id: flow
8484 anchors.fill: parent
85− firstModel: fakeModel
86− secondModel: fakeModel
85+ model: fakeModel
8786 minimumHorizontalSpacing:
8887 minHSpacingSelector.values[minHSpacingSelector.selectedIndex]
8988 verticalSpacing: units.gu(2)
tests/qmltests/Dash/Apps/tst_RunningApplicationsGrid.qml+50−117
@@ -18,87 +18,20 @@ import QtQuick 2.0
1818import QtTest 1.0
1919import "../../../../qml/Dash/Apps"
2020import Unity.Test 0.1 as UT
21+import Unity.Application 0.1
2122
22−Item {
23+// Using Rectangle to have an opaque surface because AppManager paints app surfaces behind it.
24+Rectangle {
2325 width: units.gu(50)
2426 height: units.gu(40)
2527
26− QtObject {
27− id: fakeApplicationManager
28−
29− property bool sideStageEnabled: false
30−
31− function stopApplication(appId) {
32− for (var i=0, len=fakeRunningAppsModel.count; i<len; i++) {
33− if (appId == fakeRunningAppsModel.get(i).appId) {
34− fakeRunningAppsModel.remove(i)
35− }
36− }
37− }
38− }
39−
40− QtObject {
41− id: shell
42− property bool dashShown: true
43− property bool stageScreenshotsReady: false
44− property var applicationManager: fakeApplicationManager
45−
46− function activateApplication(appId) {
47− }
48− }
49−
50− ListModel {
51− id: fakeRunningAppsModel
52−
53− function contains(appId) {
54− for (var i=0, len=fakeRunningAppsModel.count; i<len; i++) {
55− if (appId == fakeRunningAppsModel.get(i).appId) {
56− return true;
57− }
58− }
59− return false;
60− }
61−
62− function rePopulate() {
63− for (var i=0, len=availableAppsModel.count; i<len; i++) {
64− fakeRunningAppsModel.append(availableAppsModel.get(i));
65− }
66− }
67− }
68−
69− ListModel {
70− id: availableAppsModel
71− ListElement {
72− name: "Phone"
73− icon: "phone-app"
74− exec: "/usr/bin/phone-app"
75− appId: "phone"
76− imageQml: "import QtQuick 2.0\n \
77− Rectangle { \n \
78− anchors.fill:parent \n \
79− color:'darkgreen' \n \
80− Text { anchors.centerIn: parent; text: 'PHONE' } \n \
81− }"
28+ function resetRunningApplications() {
29+ while (ApplicationManager.count > 0) {
30+ ApplicationManager.stopApplication(ApplicationManager.get(0).appId)
8231 }
8332
84− ListElement {
85− name: "Calendar"
86− icon: "calendar-app"
87− exec: "/usr/bin/calendar-app"
88− appId: "calendar"
89− imageQml: "import QtQuick 2.0\n \
90− Rectangle { \n \
91− anchors.fill:parent \n \
92− color:'darkblue' \n \
93− Text { anchors.centerIn: parent; text: 'CALENDAR'\n \
94− color:'white'} \n \
95− }"
96− }
97− }
98−
99− function resetRunningApplications() {
100− fakeRunningAppsModel.clear()
101− fakeRunningAppsModel.rePopulate()
33+ ApplicationManager.startApplication("phone-app");
34+ ApplicationManager.startApplication("webbrowser-app");
10235 }
10336
10437 Component.onCompleted: {
@@ -109,7 +42,7 @@ Item {
10942 RunningApplicationsGrid {
11043 id: runningApplicationsGrid
11144 anchors.fill: parent
112− firstModel: fakeRunningAppsModel
45+ model: ApplicationManager
11346 }
11447
11548 UT.UnityTestCase {
@@ -121,11 +54,11 @@ Item {
12154 resetRunningApplications()
12255 }
12356
124− property var calendarTile
57+ property var browserTile
12558 property var phoneTile
12659
127− property var isCalendarLongPressed: false
128− function onCalendarLongPressed() {isCalendarLongPressed = true}
60+ property var isBrowserLongPressed: false
61+ function onBrowserLongPressed() {isBrowserLongPressed = true}
12962
13063 property var isPhoneLongPressed: false
13164 function onPhoneLongPressed() {isPhoneLongPressed = true}
@@ -133,25 +66,25 @@ Item {
13366 // Tiles should go to termination mode when any one of them is long-pressed.
13467 // Long-pressing when they're in termination mode brings them back to activation mode
13568 function test_enterTerminationMode() {
136− calendarTile = findChild(runningApplicationsGrid, "runningAppTile Calendar")
137− verify(calendarTile != undefined)
138− calendarTile.onPressAndHold.connect(onCalendarLongPressed)
69+ browserTile = findChild(runningApplicationsGrid, "runningAppTile Browser")
70+ verify(browserTile != undefined)
71+ browserTile.onPressAndHold.connect(onBrowserLongPressed)
13972
14073 phoneTile = findChild(runningApplicationsGrid, "runningAppTile Phone")
14174 verify(phoneTile != undefined)
14275 phoneTile.onPressAndHold.connect(onPhoneLongPressed)
14376
144− compare(calendarTile.terminationModeEnabled, false)
77+ compare(browserTile.terminationModeEnabled, false)
14578 compare(phoneTile.terminationModeEnabled, false)
14679 compare(runningApplicationsGrid.terminationModeEnabled, false)
14780
148− isCalendarLongPressed = false
149− mousePress(calendarTile, calendarTile.width/2, calendarTile.height/2)
81+ isBrowserLongPressed = false
82+ mousePress(browserTile, browserTile.width/2, browserTile.height/2)
15083 tryCompareFunction(checkSwitchToTerminationModeAfterLongPress, true)
15184
152− mouseRelease(calendarTile, calendarTile.width/2, calendarTile.height/2)
85+ mouseRelease(browserTile, browserTile.width/2, browserTile.height/2)
15386
154− compare(calendarTile.terminationModeEnabled, true)
87+ compare(browserTile.terminationModeEnabled, true)
15588 compare(phoneTile.terminationModeEnabled, true)
15689 compare(runningApplicationsGrid.terminationModeEnabled, true)
15790
@@ -161,23 +94,23 @@ Item {
16194
16295 mouseRelease(phoneTile, phoneTile.width/2, phoneTile.height/2)
16396
164− compare(calendarTile.terminationModeEnabled, false)
97+ compare(browserTile.terminationModeEnabled, false)
16598 compare(phoneTile.terminationModeEnabled, false)
16699 compare(runningApplicationsGrid.terminationModeEnabled, false)
167100
168− calendarTile.onPressAndHold.disconnect(onCalendarLongPressed)
101+ browserTile.onPressAndHold.disconnect(onBrowserLongPressed)
169102 phoneTile.onPressAndHold.disconnect(onPhoneLongPressed)
170103 }
171104
172105 // Checks that components swicth to termination mode after (and only after) a long
173− // press happens on Calendar tile.
106+ // press happens on Browser tile.
174107 function checkSwitchToTerminationModeAfterLongPress() {
175− compare(calendarTile.terminationModeEnabled, isCalendarLongPressed)
176− compare(phoneTile.terminationModeEnabled, isCalendarLongPressed)
177− compare(runningApplicationsGrid.terminationModeEnabled, isCalendarLongPressed)
108+ compare(browserTile.terminationModeEnabled, isBrowserLongPressed)
109+ compare(phoneTile.terminationModeEnabled, isBrowserLongPressed)
110+ compare(runningApplicationsGrid.terminationModeEnabled, isBrowserLongPressed)
178111
179− return isCalendarLongPressed &&
180− calendarTile.terminationModeEnabled &&
112+ return isBrowserLongPressed &&
113+ browserTile.terminationModeEnabled &&
181114 phoneTile.terminationModeEnabled &&
182115 runningApplicationsGrid.terminationModeEnabled
183116 }
@@ -185,12 +118,12 @@ Item {
185118 // Checks that components swicth to activation mode after (and only after) a long
186119 // press happens on Phone tile.
187120 function checkSwitchToActivationModeAfterLongPress() {
188− compare(calendarTile.terminationModeEnabled, !isPhoneLongPressed)
121+ compare(browserTile.terminationModeEnabled, !isPhoneLongPressed)
189122 compare(phoneTile.terminationModeEnabled, !isPhoneLongPressed)
190123 compare(runningApplicationsGrid.terminationModeEnabled, !isPhoneLongPressed)
191124
192125 return isPhoneLongPressed &&
193− !calendarTile.terminationModeEnabled &&
126+ !browserTile.terminationModeEnabled &&
194127 !phoneTile.terminationModeEnabled &&
195128 !runningApplicationsGrid.terminationModeEnabled
196129 }
@@ -200,17 +133,17 @@ Item {
200133 function test_clickTileNotClose() {
201134 runningApplicationsGrid.terminationModeEnabled = true
202135
203− var calendarTile = findChild(runningApplicationsGrid, "runningAppTile Calendar")
204− verify(calendarTile != undefined)
136+ var browserTile = findChild(runningApplicationsGrid, "runningAppTile Browser")
137+ verify(browserTile != undefined)
205138
206− verify(fakeRunningAppsModel.contains("calendar"))
139+ verify(ApplicationManager.findApplication("webbrowser-app") !== null)
207140
208− mouseClick(calendarTile, calendarTile.width/2, calendarTile.height/2)
141+ mouseClick(browserTile, browserTile.width/2, browserTile.height/2)
209142
210− verify(fakeRunningAppsModel.contains("calendar"))
143+ verify(ApplicationManager.findApplication("webbrowser-app") !== null)
211144
212− // The tile for the Calendar app should stay there
213− tryCompareFunction(checkCalendarTileExists, true)
145+ // The tile for the Browser app should stay there
146+ tryCompareFunction(checkBrowserTileExists, true)
214147 }
215148
216149 // While in termination mode, clicking on a running application tile's close icon
@@ -218,25 +151,25 @@ Item {
218151 function test_clickCloseIconToTerminateApp() {
219152 runningApplicationsGrid.terminationModeEnabled = true
220153
221− var calendarTile = findChild(runningApplicationsGrid, "runningAppTile Calendar")
222− var calendarTileCloseButton = findChild(runningApplicationsGrid, "closeIcon Calendar")
154+ var browserTile = findChild(runningApplicationsGrid, "runningAppTile Browser")
155+ var browserTileCloseButton = findChild(runningApplicationsGrid, "closeIcon Browser")
223156
224− verify(calendarTile != undefined)
225− verify(calendarTileCloseButton != undefined)
226− verify(fakeRunningAppsModel.contains("calendar"))
157+ verify(browserTile != undefined)
158+ verify(browserTileCloseButton != undefined)
159+ verify(ApplicationManager.findApplication("webbrowser-app") !== 0)
227160
228− mouseClick(calendarTileCloseButton, calendarTileCloseButton.width/2, calendarTileCloseButton.height/2)
161+ mouseClick(browserTileCloseButton, browserTileCloseButton.width/2, browserTileCloseButton.height/2)
229162 wait(0) // spin event loop to start any pending animation
230163
231− verify(!fakeRunningAppsModel.contains("calendar"))
164+ verify(ApplicationManager.findApplication("webbrowser-app") === null)
232165
233− // The tile for the Calendar app should eventually vanish since the
166+ // The tile for the Browser app should eventually vanish since the
234167 // application has been terminated.
235− tryCompareFunction(checkCalendarTileExists, false)
168+ tryCompareFunction(checkBrowserTileExists, false)
236169 }
237170
238− function checkCalendarTileExists() {
239− return findChild(runningApplicationsGrid, "runningAppTile Calendar")
171+ function checkBrowserTileExists() {
172+ return findChild(runningApplicationsGrid, "runningAppTile Browser")
240173 != undefined
241174 }
242175
@@ -245,8 +178,8 @@ Item {
245178 function test_clickOutsideTilesDisablesTerminationMode() {
246179 runningApplicationsGrid.terminationModeEnabled = true
247180
248− var calendarTile = findChild(runningApplicationsGrid, "runningAppTile Calendar")
249− verify(calendarTile != undefined)
181+ var browserTile = findChild(runningApplicationsGrid, "runningAppTile Browser")
182+ verify(browserTile != undefined)
250183
251184 verify(runningApplicationsGrid.terminationModeEnabled);
252185
tests/qmltests/Stages/tst_PhoneStage.qmlnew file+288
@@ -0,0 +1,288 @@
1+/*
2+ * Copyright 2014 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 QtTest 1.0
19+import Unity.Test 0.1 as UT
20+import ".."
21+import "../../../qml/Stages"
22+import Ubuntu.Components 0.1
23+import Unity.Application 0.1
24+
25+Item {
26+ width: units.gu(70)
27+ height: units.gu(70)
28+
29+ Rectangle {
30+
31+ }
32+
33+ PhoneStage {
34+ id: phoneStage
35+ anchors { fill: parent; rightMargin: units.gu(30) }
36+ shown: true
37+ dragAreaWidth: units.gu(2)
38+ }
39+
40+ Binding {
41+ target: ApplicationManager
42+ property: "rightMargin"
43+ value: phoneStage.anchors.rightMargin
44+ }
45+
46+ Rectangle {
47+ anchors { fill: parent; leftMargin: phoneStage.width }
48+// color: "blue"
49+
50+ Column {
51+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
52+ spacing: units.gu(1)
53+ Button {
54+ anchors { left: parent.left; right: parent.right }
55+ text: "Add App"
56+ onClicked: {
57+ testCase.addApps();
58+ }
59+ }
60+ Button {
61+ anchors { left: parent.left; right: parent.right }
62+ text: "Add App"
63+ }
64+ }
65+ }
66+
67+ UT.UnityTestCase {
68+ id: testCase
69+ name: "PhoneStage"
70+ when: windowShown
71+
72+ function addApps(count) {
73+ if (count == undefined) count = 1;
74+ for (var i = 0; i < count; i++) {
75+ var app = ApplicationManager.startApplication(ApplicationManager.availableApplications()[ApplicationManager.count])
76+ tryCompare(app, "state", ApplicationInfoInterface.Running)
77+ // Fixme: Right now there is a timeout in the PhoneStage that displays a white splash
78+ // screen rectangle when an app starts. This is because we don't yet have a way of
79+ // knowing when an app has finished launching. That workaround and this wait() should
80+ // go away at some point and the app's state only changing to Running when ready for real.
81+// wait(1000)
82+ waitForRendering(phoneStage)
83+ }
84+ }
85+
86+ function goToSpread() {
87+ var spreadView = findChild(phoneStage, "spreadView");
88+
89+ var startX = phoneStage.width;
90+ var startY = phoneStage.height / 2;
91+ var endY = startY;
92+ var endX = units.gu(2);
93+
94+ touchFlick(phoneStage, startX, startY, endX, endY,
95+ true /* beginTouch */, true /* endTouch */, units.gu(10), 50);
96+ }
97+
98+ function test_shortFlick() {
99+ addApps(2)
100+ var startX = phoneStage.width - units.gu(1);
101+ var startY = phoneStage.height / 2;
102+ var endX = phoneStage.width / 2;
103+ var endY = startY;
104+
105+ var activeApp = ApplicationManager.get(0);
106+ var inactiveApp = ApplicationManager.get(1);
107+
108+ touchFlick(phoneStage, startX, startY, endX, endY,
109+ true /* beginTouch */, true /* endTouch */, units.gu(10), 50);
110+
111+ tryCompare(ApplicationManager, "focusedApplicationId", inactiveApp.appId)
112+
113+ touchFlick(phoneStage, startX, startY, endX, endY,
114+ true /* beginTouch */, true /* endTouch */, units.gu(10), 50);
115+
116+ tryCompare(ApplicationManager, "focusedApplicationId", activeApp.appId)
117+
118+ tryCompare(phoneStage, "painting", false);
119+ }
120+
121+ function test_enterSpread_data() {
122+ return [
123+ {tag: "<position1 (linear movement)", positionMarker: "positionMarker1", linear: true, offset: -1, endPhase: 0, targetPhase: 0, newFocusedIndex: 1 },
124+ {tag: "<position1 (non-linear movement)", positionMarker: "positionMarker1", linear: false, offset: -1, endPhase: 0, targetPhase: 0, newFocusedIndex: 0 },
125+ {tag: ">position1", positionMarker: "positionMarker1", linear: true, offset: +1, endPhase: 0, targetPhase: 0, newFocusedIndex: 1 },
126+ {tag: "<position2 (linear)", positionMarker: "positionMarker2", linear: true, offset: -1, endPhase: 0, targetPhase: 0, newFocusedIndex: 1 },
127+ {tag: "<position2 (non-linear)", positionMarker: "positionMarker2", linear: false, offset: -1, endPhase: 0, targetPhase: 0, newFocusedIndex: 1 },
128+ {tag: ">position2", positionMarker: "positionMarker2", linear: true, offset: +1, endPhase: 1, targetPhase: 0, newFocusedIndex: 1 },
129+ {tag: "<position3", positionMarker: "positionMarker3", linear: true, offset: -1, endPhase: 1, targetPhase: 0, newFocusedIndex: 1 },
130+ {tag: ">position3", positionMarker: "positionMarker3", linear: true, offset: +1, endPhase: 2, targetPhase: 2, newFocusedIndex: 2 },
131+ ];
132+ }
133+
134+ function test_enterSpread(data) {
135+ addApps(5)
136+
137+ var spreadView = findChild(phoneStage, "spreadView");
138+
139+ var startX = phoneStage.width;
140+ var startY = phoneStage.height / 2;
141+ var endY = startY;
142+ var endX = spreadView.width - (spreadView.width * spreadView[data.positionMarker]) - data.offset - phoneStage.dragAreaWidth;
143+
144+ var oldFocusedApp = ApplicationManager.get(0);
145+ var newFocusedApp = ApplicationManager.get(data.newFocusedIndex);
146+
147+ touchFlick(phoneStage, startX, startY, endX, endY,
148+ true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
149+
150+ tryCompare(spreadView, "phase", data.endPhase)
151+
152+ if (!data.linear) {
153+ touchFlick(phoneStage, endX, endY, endX + units.gu(.5), endY,
154+ false /* beginTouch */, false /* endTouch */, units.gu(10), 50);
155+ touchFlick(phoneStage, endY + units.gu(.5), endY, endX, endY,
156+ false /* beginTouch */, false /* endTouch */, units.gu(10), 50);
157+ }
158+
159+ touchRelease(phoneStage, endX, endY);
160+
161+ tryCompare(spreadView, "phase", data.targetPhase)
162+
163+ if (data.targetPhase == 2) {
164+ var app2 = findChild(spreadView, "appDelegate2");
165+ mouseClick(app2, units.gu(1), units.gu(1));
166+ }
167+
168+ tryCompare(phoneStage, "painting", false);
169+ tryCompare(ApplicationManager, "focusedApplicationId", newFocusedApp.appId);
170+ }
171+
172+ function test_selectAppFromSpread_data() {
173+ var appsToTest = 6;
174+ var apps = new Array();
175+ for (var i = 0; i < appsToTest; i++) {
176+ var item = new Object();
177+ item.tag = "App " + i;
178+ item.index = i;
179+ item.total = appsToTest;
180+ apps.push(item)
181+ }
182+ return apps;
183+ }
184+
185+ function test_selectAppFromSpread(data) {
186+ addApps(data.total)
187+
188+ var spreadView = findChild(phoneStage, "spreadView");
189+
190+ goToSpread();
191+
192+ tryCompare(spreadView, "phase", 2);
193+
194+ var tile = findChild(spreadView, "appDelegate" + data.index);
195+ var appId = ApplicationManager.get(data.index).appId;
196+
197+ if (tile.mapToItem(spreadView).x > spreadView.width) {
198+ // Item is not visible... Need to flick the spread
199+ var startX = phoneStage.width - units.gu(1);
200+ var startY = phoneStage.height / 2;
201+ var endY = startY;
202+ var endX = units.gu(2);
203+ touchFlick(phoneStage, startX, startY, endX, endY, true, true, units.gu(10), 50)
204+ tryCompare(spreadView, "flicking", false);
205+ tryCompare(spreadView, "moving", false);
206+// waitForRendering(phoneStage);
207+ }
208+
209+ console.log("clicking app", data.index, "(", appId, ")")
210+ mouseClick(spreadView, tile.mapToItem(spreadView).x + units.gu(1), spreadView.height / 2)
211+ tryCompare(ApplicationManager, "focusedApplicationId", appId);
212+ tryCompare(spreadView, "phase", 0);
213+ }
214+
215+ function test_animateAppStartup() {
216+ compare(phoneStage.painting, false);
217+ addApps(2);
218+ tryCompare(phoneStage, "painting", true);
219+ tryCompare(phoneStage, "painting", false);
220+ addApps(1);
221+ tryCompare(phoneStage, "painting", true);
222+ tryCompare(phoneStage, "painting", false);
223+ }
224+
225+ function test_select_data() {
226+ return [
227+ { tag: "0", index: 0 },
228+ { tag: "2", index: 2 },
229+ { tag: "4", index: 4 },
230+ ]
231+ }
232+
233+ function test_select(data) {
234+ addApps(5);
235+
236+ var spreadView = findChild(phoneStage, "spreadView");
237+ var selectedApp = ApplicationManager.get(data.index);
238+
239+ goToSpread();
240+
241+ phoneStage.select(selectedApp.appId);
242+
243+ tryCompare(phoneStage, "painting", false);
244+ compare(ApplicationManager.focusedApplicationId, selectedApp.appId);
245+ }
246+
247+ function test_fullscreenMode() {
248+ var fullscreenApp = null;
249+ var normalApp = null;
250+
251+ for (var i = 0; i < 5; i++) {
252+ addApps(1);
253+ var newApp = ApplicationManager.get(0);
254+ tryCompare(phoneStage, "fullscreen", newApp.fullscreen);
255+ if (newApp.fullscreen && fullscreenApp == null) {
256+ fullscreenApp = newApp;
257+ } else if (!newApp.fullscreen && normalApp == null){
258+ normalApp = newApp;
259+ }
260+ }
261+ verify(fullscreenApp != null); // Can't continue the test without having a fullscreen app
262+ verify(normalApp != null); // Can't continue the test without having a non-fullscreen app
263+
264+ // Select a normal app
265+ goToSpread();
266+ phoneStage.select(normalApp.appId);
267+ tryCompare(phoneStage, "fullscreen", false);
268+
269+ // Select a fullscreen app
270+ goToSpread();
271+ phoneStage.select(fullscreenApp.appId);
272+ tryCompare(phoneStage, "fullscreen", true);
273+
274+ // Select a normal app
275+ goToSpread();
276+ phoneStage.select(normalApp.appId);
277+ tryCompare(phoneStage, "fullscreen", false);
278+ }
279+
280+ function cleanup() {
281+ while (ApplicationManager.count > 0) {
282+ var oldCount = ApplicationManager.count;
283+ ApplicationManager.stopApplication(ApplicationManager.get(0).appId)
284+ tryCompare(ApplicationManager, "count", oldCount - 1)
285+ }
286+ }
287+ }
288+}
tests/qmltests/tst_Shell.qml+16−8
@@ -117,6 +117,7 @@ Item {
117117 while (apps.count > 0) {
118118 ApplicationManager.stopApplication(apps.get(0).appId);
119119 }
120+ compare(ApplicationManager.count, 0)
120121 }
121122
122123 /*
@@ -187,26 +188,34 @@ Item {
187188 tapOnAppIconInLauncher();
188189 waitUntilApplicationWindowIsFullyVisible();
189190
190− var mainApp = ApplicationManager.focusedApplicationId;
191− verify(mainApp != "");
191+ var mainAppId = ApplicationManager.focusedApplicationId;
192+ verify(mainAppId != "");
193+ var mainApp = ApplicationManager.findApplication(mainAppId);
194+ verify(mainApp);
195+ tryCompare(mainApp.state, ApplicationInfo.Running);
192196
193197 // Try to suspend while proximity is engaged...
194198 Powerd.displayPowerStateChange(Powerd.Off, Powerd.UseProximity);
195199 tryCompare(greeter, "showProgress", 0);
196200
197201 // Now really suspend
202+ print("suspending")
198203 Powerd.displayPowerStateChange(Powerd.Off, 0);
204+ print("done suspending")
199205 tryCompare(greeter, "showProgress", 1);
200− tryCompare(ApplicationManager, "focusedApplicationId", "");
206+
207+ tryCompare(ApplicationManager, "suspended", true);
208+ compare(mainApp.state, ApplicationInfo.Suspended);
201209
202210 // And wake up
203211 Powerd.displayPowerStateChange(Powerd.On, 0);
204− tryCompare(ApplicationManager, "focusedApplicationId", "");
205212 tryCompare(greeter, "showProgress", 1);
206213
207214 // Swipe away greeter to focus app
208215 swipeAwayGreeter();
209− tryCompare(ApplicationManager, "focusedApplicationId", mainApp);
216+ tryCompare(ApplicationManager, "suspended", false);
217+ compare(mainApp.state, ApplicationInfo.Running);
218+ tryCompare(ApplicationManager, "focusedApplicationId", mainAppId);
210219 }
211220
212221 function swipeAwayGreeter() {
@@ -239,7 +248,7 @@ Item {
239248 tryCompare(dash, "opacity", 1.0);
240249
241250 touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
242− true /* beginTouch */, false /* endTouch */);
251+ true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
243252
244253 // check that Dash has been scaled down and had its opacity reduced
245254 tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
@@ -270,7 +279,7 @@ Item {
270279 tryCompare(dash, "opacity", 1.0);
271280
272281 touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
273− true /* beginTouch */, false /* endTouch */);
282+ true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
274283
275284 // check that Dash has been scaled down and had its opacity reduced
276285 tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
@@ -486,7 +495,6 @@ Item {
486495 }
487496
488497 function test_DashShown(data) {
489−
490498 if (data.greeter) {
491499 // Swipe the greeter in
492500 var greeter = findChild(shell, "greeter");