on xenial help sign in
Merge in lp:~mterry/unity8/skip-spread-tutorial-on-desktop
commitd85438aaa692d893842efbf071ae3f8c776438ec authorMichael Terry <michael.terry@canonical.com> dateFri 3 Apr 2015, 10:23 (12 years ago) parent197516541d4d9f
8 files changed+124−43
qml/Shell.qml+9 qml/Tutorial/Tutorial.qml+7 qml/Tutorial/TutorialContent.qml+9−1 tests/mocks/GSettings.1.0/fake_gsettings.cpp+58−22 tests/mocks/GSettings.1.0/fake_gsettings.h+16−6 tests/mocks/GSettings.1.0/plugin.cpp−6 tests/qmltests/Tutorial/tst_Tutorial.qml+22−5 tests/qmltests/tst_Shell.qml+3−3
qml/Shell.qml+9
@@ -294,6 +294,15 @@ Item {
294294 panel: panel
295295 edgeSize: shell.edgeSize
296296
297+ // EdgeDragAreas don't work with mice. So to avoid trapping the user,
298+ // we'll tell the tutorial to avoid using them on the Desktop. The
299+ // Desktop doesn't use the same spread design anyway. The tutorial is
300+ // all a bit of a placeholder on non-phone form factors right now.
301+ // When the design team gives us more guidance, we can do something
302+ // more clever here.
303+ // TODO: use DeviceConfiguration instead of checking source
304+ useEdgeDragArea: applicationsDisplayLoader.source != Qt.resolvedUrl("Stages/DesktopStage.qml")
305+
297306 onFinished: {
298307 AccountsService.demoEdges = false;
299308 active = false; // for immediate response / if AS is having problems
qml/Tutorial/Tutorial.qml+7
@@ -23,6 +23,7 @@ Item {
2323 property alias active: loader.active
2424 property bool paused
2525 property real edgeSize
26+ property bool useEdgeDragArea
2627
2728 property Item launcher
2829 property Item panel
@@ -58,6 +59,12 @@ Item {
5859 value: root.edgeSize
5960 }
6061
62+ Binding {
63+ target: loader.item
64+ property: "useEdgeDragArea"
65+ value: root.useEdgeDragArea
66+ }
67+
6168 Binding {
6269 target: loader.item
6370 property: "launcher"
qml/Tutorial/TutorialContent.qml+9−1
@@ -32,6 +32,7 @@ Item {
3232
3333 property bool paused: false
3434 property real edgeSize
35+ property bool useEdgeDragArea
3536
3637 signal finished()
3738
@@ -77,10 +78,17 @@ Item {
7778 anchors.fill: parent
7879 textXOffset: root.launcher.panelWidth
7980 paused: !shown || root.paused
81+ text: root.useEdgeDragArea ? i18n.tr("Tap here to continue.") : i18n.tr("Click here to finish.")
8082
8183 onFinished: {
8284 root.launcher.hide();
83− tutorialRight.show();
85+ if (root.useEdgeDragArea) {
86+ tutorialRight.show();
87+ } else {
88+ // Last two screens use EdgeDragArea (right edge spread and
89+ // bottom edge). So just end tutorial here.
90+ root.finish();
91+ }
8492 }
8593 }
8694
tests/mocks/GSettings.1.0/fake_gsettings.cpp+58−22
@@ -20,7 +20,9 @@
2020
2121GSettingsControllerQml* GSettingsControllerQml::s_controllerInstance = 0;
2222
23−GSettingsControllerQml::GSettingsControllerQml() {
23+GSettingsControllerQml::GSettingsControllerQml()
24+ : m_usageMode("Staged")
25+{
2426}
2527
2628GSettingsControllerQml::~GSettingsControllerQml() {
@@ -34,17 +36,29 @@ GSettingsControllerQml* GSettingsControllerQml::instance() {
3436 return s_controllerInstance;
3537}
3638
37−void GSettingsControllerQml::registerSettingsObject(GSettingsQml *obj) {
38− m_registeredGSettings.append(obj);
39+QString GSettingsControllerQml::pictureUri() const
40+{
41+ return m_pictureUri;
42+}
43+
44+void GSettingsControllerQml::setPictureUri(const QString &str)
45+{
46+ if (str != m_pictureUri) {
47+ m_pictureUri = str;
48+ Q_EMIT pictureUriChanged(m_pictureUri);
49+ }
3950}
4051
41−void GSettingsControllerQml::unRegisterSettingsObject(GSettingsQml *obj) {
42− m_registeredGSettings.removeOne(obj);
52+QString GSettingsControllerQml::usageMode() const
53+{
54+ return m_usageMode;
4355}
4456
45−void GSettingsControllerQml::setPictureUri(const QString &str) {
46− Q_FOREACH (GSettingsQml *obj, m_registeredGSettings) {
47− obj->setPictureUri(str);
57+void GSettingsControllerQml::setUsageMode(const QString &usageMode)
58+{
59+ if (usageMode != m_usageMode) {
60+ m_usageMode = usageMode;
61+ Q_EMIT usageModeChanged(m_usageMode);
4862 }
4963}
5064
@@ -56,7 +70,7 @@ QByteArray GSettingsSchemaQml::id() const {
5670}
5771
5872void GSettingsSchemaQml::setId(const QByteArray &id) {
59− if (m_id.isEmpty()) {
73+ if (!m_id.isEmpty()) {
6074 qWarning("GSettings.schema.id may only be set on construction");
6175 return;
6276 }
@@ -69,7 +83,7 @@ QByteArray GSettingsSchemaQml::path() const {
6983}
7084
7185void GSettingsSchemaQml::setPath(const QByteArray &path) {
72− if (m_path.isEmpty()) {
86+ if (!m_path.isEmpty()) {
7387 qWarning("GSettings.schema.path may only be set on construction");
7488 return;
7589 }
@@ -77,26 +91,48 @@ void GSettingsSchemaQml::setPath(const QByteArray &path) {
7791 m_path = path;
7892}
7993
80−GSettingsQml::GSettingsQml(QObject *parent): QObject(parent) {
94+GSettingsQml::GSettingsQml(QObject *parent)
95+ : QObject(parent)
96+{
8197 m_schema = new GSettingsSchemaQml(this);
82− GSettingsControllerQml::instance()->registerSettingsObject(this);
83−}
84−
85−GSettingsQml::~GSettingsQml() {
86− GSettingsControllerQml::instance()->unRegisterSettingsObject(this);
98+ connect(GSettingsControllerQml::instance(), SIGNAL(pictureUriChanged(const QString &)),
99+ this, SIGNAL(pictureUriChanged(const QString &)));
100+ connect(GSettingsControllerQml::instance(), SIGNAL(usageModeChanged(const QString &)),
101+ this, SIGNAL(usageModeChanged(const QString &)));
87102}
88103
89104GSettingsSchemaQml * GSettingsQml::schema() const {
90105 return m_schema;
91106}
92107
93−QString GSettingsQml::pictureUri() const {
94− return m_pictureUri;
108+QString GSettingsQml::pictureUri() const
109+{
110+ if (m_schema->id() == "org.gnome.desktop.background") {
111+ return GSettingsControllerQml::instance()->pictureUri();
112+ } else {
113+ return "";
114+ }
95115}
96116
97−void GSettingsQml::setPictureUri(const QString &str) {
98− if (str != m_pictureUri) {
99− m_pictureUri = str;
100− Q_EMIT pictureUriChanged(m_pictureUri);
117+void GSettingsQml::setPictureUri(const QString &str)
118+{
119+ if (m_schema->id() == "org.gnome.desktop.background") {
120+ GSettingsControllerQml::instance()->setPictureUri(str);
121+ }
122+}
123+
124+QString GSettingsQml::usageMode() const
125+{
126+ if (m_schema->id() == "com.canonical.Unity8") {
127+ return GSettingsControllerQml::instance()->usageMode();
128+ } else {
129+ return "";
130+ }
131+}
132+
133+void GSettingsQml::setUsageMode(const QString &usageMode)
134+{
135+ if (m_schema->id() == "com.canonical.Unity8") {
136+ GSettingsControllerQml::instance()->setUsageMode(usageMode);
101137 }
102138}
tests/mocks/GSettings.1.0/fake_gsettings.h+16−6
@@ -46,25 +46,26 @@ class GSettingsQml: public QObject
4646
4747 Q_PROPERTY(GSettingsSchemaQml* schema READ schema NOTIFY schemaChanged)
4848 Q_PROPERTY(QString pictureUri READ pictureUri WRITE setPictureUri NOTIFY pictureUriChanged)
49+ Q_PROPERTY(QString usageMode READ usageMode WRITE setUsageMode NOTIFY usageModeChanged)
4950
5051public:
5152 GSettingsQml(QObject *parent = nullptr);
52− ~GSettingsQml();
5353
5454 GSettingsSchemaQml * schema() const;
5555 QString pictureUri() const;
56+ QString usageMode() const;
5657
5758 void setPictureUri(const QString &str);
59+ void setUsageMode(const QString &usageMode);
5860
5961Q_SIGNALS:
6062 void schemaChanged();
6163 void pictureUriChanged(const QString&);
64+ void usageModeChanged(const QString&);
6265
6366private:
6467 GSettingsSchemaQml* m_schema;
6568
66− QString m_pictureUri;
67−
6869 friend class GSettingsSchemaQml;
6970};
7071
@@ -76,13 +77,22 @@ public:
7677 static GSettingsControllerQml* instance();
7778 ~GSettingsControllerQml();
7879
79− void registerSettingsObject(GSettingsQml *obj);
80− void unRegisterSettingsObject(GSettingsQml *obj);
81− Q_INVOKABLE void setPictureUri(const QString &str);
80+ QString pictureUri() const;
81+ void setPictureUri(const QString &str);
82+
83+ QString usageMode() const;
84+ void setUsageMode(const QString &usageMode);
85+
86+Q_SIGNALS:
87+ void pictureUriChanged(const QString&);
88+ void usageModeChanged(const QString&);
8289
8390private:
8491 GSettingsControllerQml();
8592
93+ QString m_pictureUri;
94+ QString m_usageMode;
95+
8696 static GSettingsControllerQml* s_controllerInstance;
8797 QList<GSettingsQml *> m_registeredGSettings;
8898};
tests/mocks/GSettings.1.0/plugin.cpp−6
@@ -19,14 +19,8 @@
1919
2020#include <QtQml/qqml.h>
2121
22−static QObject* controllerProvider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */)
23−{
24− return GSettingsControllerQml::instance();
25−}
26−
2722void FakeGSettingsQmlPlugin::registerTypes(const char *uri)
2823{
29− qmlRegisterSingletonType<GSettingsControllerQml>(uri, 1, 0, "GSettingsController", controllerProvider);
3024 qmlRegisterType<GSettingsQml>(uri, 1, 0, "GSettings");
3125 qmlRegisterUncreatableType<GSettingsSchemaQml>(uri, 1, 0, "GSettingsSchema",
3226 "GSettingsSchema can only be used inside of a GSettings component");
tests/qmltests/Tutorial/tst_Tutorial.qml+22−5
@@ -17,6 +17,7 @@
1717import QtQuick 2.0
1818import QtTest 1.0
1919import AccountsService 0.1
20+import GSettings 1.0
2021import LightDM 0.1 as LightDM
2122import Ubuntu.Components 1.1
2223import Unity.Application 0.1
@@ -45,6 +46,11 @@ Item {
4546 }
4647 }
4748
49+ GSettings {
50+ id: unity8Settings
51+ schema.id: "com.canonical.Unity8"
52+ }
53+
4854 Component.onCompleted: {
4955 // must set the mock mode before loading the Shell
5056 LightDM.Greeter.mockMode = "single-pin";
@@ -112,6 +118,7 @@ Item {
112118
113119 function init() {
114120 tryCompare(shell, "enabled", true); // enabled by greeter when ready
121+ unity8Settings.usageMode = "Staged";
115122 AccountsService.demoEdges = false;
116123 AccountsService.demoEdges = true;
117124 swipeAwayGreeter();
@@ -185,17 +192,19 @@ Item {
185192 }
186193
187194 function checkRightEdge() {
188− touchFlick(shell, shell.width, halfHeight, halfWidth, halfHeight);
195+ if (unity8Settings.usageMode === "Staged") {
196+ touchFlick(shell, shell.width, halfHeight, halfWidth, halfHeight);
189197
190− var stage = findChild(shell, "stage");
191− var spreadView = findChild(stage, "spreadView");
192− tryCompare(spreadView, "phase", 0);
198+ var stage = findChild(shell, "stage");
199+ var spreadView = findChild(stage, "spreadView");
200+ tryCompare(spreadView, "phase", 0);
201+ }
193202 }
194203
195204 function checkBottomEdge() {
196205 // Can't actually check effect of swipe, since dash isn't really loaded
197206 var applicationsDisplayLoader = findChild(shell, "applicationsDisplayLoader");
198− tryCompare(applicationsDisplayLoader.item, "interactive", false);
207+ tryCompare(applicationsDisplayLoader, "interactive", false);
199208 }
200209
201210 function checkFinished() {
@@ -256,6 +265,14 @@ Item {
256265 goToPage(null);
257266 }
258267
268+ function test_walkthroughOnDesktop() {
269+ unity8Settings.usageMode = "Windowed";
270+ var page = goToPage("tutorialLeftFinish");
271+ var tick = findChild(page, "tick");
272+ tap(tick);
273+ checkFinished();
274+ }
275+
259276 function test_launcherShortDrag() {
260277 // goToPage does a normal launcher pull. But here we want to test
261278 // just barely pulling the launcher out and letting go (i.e. not
tests/qmltests/tst_Shell.qml+3−3
@@ -1089,11 +1089,11 @@ Rectangle {
10891089 {
10901090 var buttonShowDashHome = findChild(launcher, "buttonShowDashHome");
10911091 var startPos = buttonShowDashHome.mapToItem(shell,
1092− buttonShowDashHome.width * 0.8,
1093− buttonShowDashHome.height * 0.2);
1094− var endPos = buttonShowDashHome.mapToItem(shell,
10951092 buttonShowDashHome.width * 0.2,
10961093 buttonShowDashHome.height * 0.8);
1094+ var endPos = buttonShowDashHome.mapToItem(shell,
1095+ buttonShowDashHome.width * 0.8,
1096+ buttonShowDashHome.height * 0.2);
10971097 touchFlick(shell, startPos.x, startPos.y, endPos.x, endPos.y);
10981098 }
10991099