on xenial help sign in
First pass at making wizard a plugin
commit6f03af2f057731fed71abe0d86d4d5d7c6284a9a authorMichael Terry <michael.terry@canonical.com> dateFri 14 Nov 2014, 12:47 (12 years ago) parent23a2ae1
72 files changed+887−540
CMakeLists.txt+5−1 build.sh+1 debian/control+1−1 include/paths.h.in+2 plugins/AccountsService/AccountsService.cpp+45−1 plugins/AccountsService/AccountsService.h+16 plugins/CMakeLists.txt+1 wizard/50-com.ubuntu.system-settings.wizard.pkla → plugins/Wizard/50-com.canonical.unity.wizard.pkla plugins/Wizard/CMakeLists.txt+11 wizard/PageList.cpp → plugins/Wizard/PageList.cpp+10−9 wizard/PageList.h → plugins/Wizard/PageList.h+3−5 plugins/Wizard/System.cpp+87 plugins/Wizard/System.h+50 wizard/Unity/Application/CMakeLists.txt → plugins/Wizard/Unity/Application/CMakeLists.txt wizard/Unity/Application/OSKController.qml → plugins/Wizard/Unity/Application/OSKController.qml wizard/Unity/Application/qmldir → plugins/Wizard/Unity/Application/qmldir wizard/Unity/CMakeLists.txt → plugins/Wizard/Unity/CMakeLists.txt wizard/Utils/CMakeLists.txt → plugins/Wizard/Utils/CMakeLists.txt wizard/Utils/plugin.cpp → plugins/Wizard/Utils/plugin.cpp wizard/Utils/plugin.h → plugins/Wizard/Utils/plugin.h wizard/Utils/qmldir → plugins/Wizard/Utils/qmldir wizard/Utils/qsortfilterproxymodelqml.cpp → plugins/Wizard/Utils/qsortfilterproxymodelqml.cpp wizard/Utils/qsortfilterproxymodelqml.h → plugins/Wizard/Utils/qsortfilterproxymodelqml.h plugins/Wizard/Wizard.qmltypes+36 wizard/main.cpp → plugins/Wizard/main.cpp plugins/Wizard/plugin.cpp+42 plugins/Wizard/plugin.h+34 plugins/Wizard/qmldir+3 wizard/test.sh → plugins/Wizard/test.sh wizard/ubuntu-system-settings-wizard-cleanup.conf → plugins/Wizard/ubuntu-system-settings-wizard-cleanup.conf wizard/ubuntu-system-settings-wizard-set-lang.conf → plugins/Wizard/ubuntu-system-settings-wizard-set-lang.conf wizard/ubuntu-system-settings-wizard.conf → plugins/Wizard/ubuntu-system-settings-wizard.conf qml/Shell.qml+7 wizard/qml/Components/CheckableSetting.qml → qml/Wizard/CheckableSetting.qml−1 wizard/qml/Components/InputMethod.qml → qml/Wizard/Components/InputMethod.qml wizard/qml/Components/Page.qml → qml/Wizard/Page.qml+1−2 qml/Wizard/Pages.qml+132 wizard/qml/Pages/10-welcome.qml → qml/Wizard/Pages/10-welcome.qml+3−3 wizard/qml/Pages/20-sim.qml → qml/Wizard/Pages/20-sim.qml+1−1 wizard/qml/Pages/30-passwd-type.qml → qml/Wizard/Pages/30-passwd-type.qml+13−1 wizard/qml/Pages/40-wifi.qml → qml/Wizard/Pages/40-wifi.qml+1−2 wizard/qml/Pages/50-location.qml → qml/Wizard/Pages/50-location.qml+12−7 wizard/qml/Pages/60-reporting.qml → qml/Wizard/Pages/60-reporting.qml+1−1 wizard/qml/Pages/80-finished.qml → qml/Wizard/Pages/80-finished.qml+1−1 wizard/qml/Pages/data/meet_ubuntu_simcard@30.png → qml/Wizard/Pages/data/meet_ubuntu_simcard@30.png wizard/qml/Pages/here-terms.qml → qml/Wizard/Pages/here-terms.qml+4−4 wizard/qml/Pages/passwd-confirm.qml → qml/Wizard/Pages/passwd-confirm.qml+2−2 wizard/qml/Pages/passwd-set.qml → qml/Wizard/Pages/passwd-set.qml+2−2 wizard/qml/Components/StackButton.qml → qml/Wizard/StackButton.qml qml/Wizard/Wizard.qml+40 tests/CMakeLists.txt−1 tests/mocks/AccountsService/AccountsService.cpp+25−1 tests/mocks/AccountsService/AccountsService.h+16 tests/mocks/CMakeLists.txt+1 tests/mocks/QMenuModel/CMakeLists.txt+1 tests/mocks/QMenuModel/dbus-enums.h+52 tests/mocks/QMenuModel/plugin.cpp+3 tests/mocks/Wizard/CMakeLists.txt+12 tests/mocks/Wizard/MockSystem.cpp+38 tests/mocks/Wizard/MockSystem.h+46 tests/mocks/Wizard/Wizard.qmltypes+36 tests/mocks/Wizard/mockplugin.cpp+42 tests/mocks/Wizard/mockplugin.h+32 tests/mocks/Wizard/qmldir+3 tests/plugins/CMakeLists.txt+1 tests/plugins/Wizard/CMakeLists.txt+11 tests/wizard/tst_pagelist.cpp → tests/plugins/Wizard/tst_pagelist.cpp+1−3 tests/wizard/CMakeLists.txt−5 wizard/CMakeLists.txt−65 wizard/Utils/system.cpp−118 wizard/Utils/system.h−57 wizard/qml/main.qml−246
CMakeLists.txt+5−1
@@ -60,6 +60,11 @@ include(GNUInstallDirs)
6060set(SHELL_APP_DIR ${CMAKE_INSTALL_DATADIR}/unity8)
6161set(SHELL_PRIVATE_LIBDIR ${CMAKE_INSTALL_LIBDIR}/unity8)
6262
63+execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugin_private_module_dir SystemSettings OUTPUT_VARIABLE USS_PRIVATE_PLUGINDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
64+if(USS_PRIVATE_PLUGINDIR STREQUAL "")
65+ message(FATAL_ERROR "Could not determine USS private plugin installation dir.")
66+endif()
67+
6368execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugindir_suffix unity-shell-api OUTPUT_VARIABLE SHELL_INSTALL_QML OUTPUT_STRIP_TRAILING_WHITESPACE)
6469if(SHELL_INSTALL_QML STREQUAL "")
6570 message(FATAL_ERROR "Could not determine plugin installation dir.")
@@ -116,7 +121,6 @@ add_subdirectory(tools)
116121add_subdirectory(qml)
117122add_subdirectory(tests)
118123add_subdirectory(plugins)
119−add_subdirectory(wizard)
120124
121125#
122126# Data files
build.sh+1
@@ -54,6 +54,7 @@ install_dependencies() {
5454 qtdeclarative5-unity-notifications-plugin \
5555 qml-module-ubuntu-connectivity \
5656 ubuntu-mobile-icons \
57+ ubuntu-system-settings \
5758 unity-plugin-scopes \
5859 xvfb \
5960 || exit 5
debian/control+1−1
@@ -23,7 +23,6 @@ Build-Depends: cmake,
2323 libpulse-dev,
2424 libqmenumodel-dev (>= 0.2.8),
2525 libqt5xmlpatterns5-dev,
26− libsystemsettings-dev,
2726 libunity-api-dev (>= 7.93),
2827 libusermetricsoutput1-dev,
2928 libxcb1-dev,
@@ -47,6 +46,7 @@ Build-Depends: cmake,
4746 qtdeclarative5-ubuntu-settings-components (>= 0.4),
4847 qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 0.1.49) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles (>= 0.1.49),
4948 ttf-ubuntu-font-family,
49+ ubuntu-system-settings,
5050Standards-Version: 3.9.4
5151Homepage: http://launchpad.net/unity
5252# If you aren't a member of ~unity-team but need to upload
include/paths.h.in+2
@@ -71,9 +71,11 @@ inline QStringList fallbackImportPaths() {
7171 QStringList paths;
7272 if (isRunningInstalled()) {
7373 paths << QString("@CMAKE_INSTALL_PREFIX@/@SHELL_INSTALL_QML@");
74+ paths << QString("@USS_PRIVATE_PLUGINDIR@");
7475 paths << QString("@SHELL_PLUGINDIR@");
7576 paths << QString("@CMAKE_INSTALL_PREFIX@/@SHELL_INSTALL_QML@/mocks");
7677 } else {
78+ paths << QString("@USS_PRIVATE_PLUGINDIR@");
7779 paths << QString("@SHELL_PLUGINDIR@");
7880 paths << QString("@CMAKE_BINARY_DIR@/tests/mocks");
7981 }
plugins/AccountsService/AccountsService.cpp+45−1
@@ -30,7 +30,9 @@ AccountsService::AccountsService(QObject* parent)
3030 m_enableIndicatorsWhileLocked(false),
3131 m_statsWelcomeScreen(false),
3232 m_passwordDisplayHint(Keyboard),
33− m_failedLogins(0)
33+ m_failedLogins(0),
34+ m_hereEnabled(false),
35+ m_hereLicensePath(" ") // blank space means not set yet
3436{
3537 connect(m_service, SIGNAL(propertiesChanged(const QString &, const QString &, const QStringList &)),
3638 this, SLOT(propertiesChanged(const QString &, const QString &, const QStringList &)));
@@ -55,6 +57,8 @@ void AccountsService::setUser(const QString &user)
5557 updateStatsWelcomeScreen();
5658 updatePasswordDisplayHint();
5759 updateFailedLogins();
60+ updateHereEnabled();
61+ updateHereLicensePath();
5862}
5963
6064bool AccountsService::demoEdges() const
@@ -93,6 +97,21 @@ AccountsService::PasswordDisplayHint AccountsService::passwordDisplayHint() cons
9397 return m_passwordDisplayHint;
9498}
9599
100+bool AccountsService::hereEnabled() const
101+{
102+ return m_hereEnabled;
103+}
104+
105+void AccountsService::setHereEnabled(bool enabled)
106+{
107+ m_service->setUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseAccepted", enabled);
108+}
109+
110+QString AccountsService::hereLicensePath() const
111+{
112+ return m_hereLicensePath;
113+}
114+
96115void AccountsService::updateDemoEdges()
97116{
98117 auto demoEdges = m_service->getUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges").toBool();
@@ -156,6 +175,24 @@ void AccountsService::updateFailedLogins()
156175 }
157176}
158177
178+void AccountsService::updateHereEnabled()
179+{
180+ bool hereEnabled = m_service->getUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseAccepted").toBool();
181+ if (m_hereEnabled != hereEnabled) {
182+ m_hereEnabled = hereEnabled;
183+ Q_EMIT hereEnabledChanged();
184+ }
185+}
186+
187+void AccountsService::updateHereLicensePath()
188+{
189+ QString hereLicensePath = m_service->getUserProperty(m_user, "com.ubuntu.location.providers.here.AccountsService", "LicenseBasePath").toString();
190+ if (m_hereLicensePath != hereLicensePath) {
191+ m_hereLicensePath = hereLicensePath;
192+ Q_EMIT hereLicensePathChanged();
193+ }
194+}
195+
159196uint AccountsService::failedLogins() const
160197{
161198 return m_failedLogins;
@@ -195,6 +232,13 @@ void AccountsService::propertiesChanged(const QString &user, const QString &inte
195232 if (changed.contains("EnableIndicatorsWhileLocked")) {
196233 updateEnableIndicatorsWhileLocked();
197234 }
235+ } else if (interface == "com.ubuntu.location.providers.here.AccountsService") {
236+ if (changed.contains("LicenseAccepted")) {
237+ updateHereEnabled();
238+ }
239+ if (changed.contains("LicenseBasePath")) {
240+ updateHereLicensePath();
241+ }
198242 }
199243}
200244
plugins/AccountsService/AccountsService.h+16
@@ -55,6 +55,13 @@ class AccountsService: public QObject
5555 READ failedLogins
5656 WRITE setFailedLogins
5757 NOTIFY failedLoginsChanged)
58+ Q_PROPERTY(bool hereEnabled
59+ READ hereEnabled
60+ WRITE setHereEnabled
61+ NOTIFY hereEnabledChanged)
62+ Q_PROPERTY(QString hereLicensePath
63+ READ hereLicensePath
64+ NOTIFY hereLicensePathChanged)
5865
5966public:
6067 enum PasswordDisplayHint {
@@ -75,6 +82,9 @@ public:
7582 PasswordDisplayHint passwordDisplayHint() const;
7683 uint failedLogins() const;
7784 void setFailedLogins(uint failedLogins);
85+ bool hereEnabled() const;
86+ void setHereEnabled(bool enabled);
87+ QString hereLicensePath() const;
7888
7989Q_SIGNALS:
8090 void userChanged();
@@ -85,6 +95,8 @@ Q_SIGNALS:
8595 void statsWelcomeScreenChanged();
8696 void passwordDisplayHintChanged();
8797 void failedLoginsChanged();
98+ void hereEnabledChanged();
99+ void hereLicensePathChanged();
88100
89101private Q_SLOTS:
90102 void propertiesChanged(const QString &user, const QString &interface, const QStringList &changed);
@@ -98,6 +110,8 @@ private:
98110 void updateStatsWelcomeScreen();
99111 void updatePasswordDisplayHint();
100112 void updateFailedLogins();
113+ void updateHereEnabled();
114+ void updateHereLicensePath();
101115
102116 AccountsServiceDBusAdaptor *m_service;
103117 QString m_user;
@@ -108,6 +122,8 @@ private:
108122 bool m_statsWelcomeScreen;
109123 PasswordDisplayHint m_passwordDisplayHint;
110124 uint m_failedLogins;
125+ bool m_hereEnabled;
126+ QString m_hereLicensePath;
111127};
112128
113129#endif
plugins/CMakeLists.txt+1
@@ -21,3 +21,4 @@ add_subdirectory(ScreenGrabber)
2121add_subdirectory(Ubuntu)
2222add_subdirectory(Unity)
2323add_subdirectory(Utils)
24+add_subdirectory(Wizard)
wizard/50-com.ubuntu.system-settings.wizard.pkla → plugins/Wizard/50-com.canonical.unity.wizard.pklarenamed

The content is the same.

plugins/Wizard/CMakeLists.txtnew file+11
@@ -0,0 +1,11 @@
1+add_library(Wizard-qml MODULE
2+ plugin.cpp
3+ PageList.cpp
4+ System.cpp
5+)
6+
7+qt5_use_modules(Wizard-qml DBus Qml)
8+add_unity8_plugin(Wizard 0.1 Wizard TARGETS Wizard-qml)
9+
10+set(POLKIT_LIB_DIR "${CMAKE_INSTALL_LOCALSTATEDIR}/lib/polkit-1")
11+install(FILES 50-com.canonical.unity.wizard.pkla DESTINATION ${POLKIT_LIB_DIR}/localauthority/10-vendor.d)
wizard/PageList.cpp → plugins/Wizard/PageList.cpprenamed+10−9
@@ -1,6 +1,4 @@
11/*
2− * This file is part of system-settings
3− *
42 * Copyright (C) 2014 Canonical Ltd.
53 *
64 * This program is free software: you can redistribute it and/or modify it
@@ -19,7 +17,7 @@
1917/**
2018 * This class lets the list of wizard pages be dynamic.
2119 * - To add new ones, drop them into
22− * $XDG_DATA_DIRS/ubuntu/settings/wizard/qml/Pages with a numbered prefix,
20+ * $XDG_DATA_DIRS/Wizard/Pages with a numbered prefix,
2321 * like "21-custom-page.qml". The number determines the order in the page
2422 * sequence that your page will appear.
2523 * - To disable an existing page, add a file like "21-custom-page.qml.disabled"
@@ -32,10 +30,11 @@
3230 */
3331
3432#include "PageList.h"
33+#include <paths.h>
3534#include <QDir>
35+#include <QSet>
3636#include <QStandardPaths>
3737
38−#include <QDebug>
3938PageList::PageList(QObject *parent)
4039 : QObject(parent),
4140 m_index(-1),
@@ -44,14 +43,16 @@ PageList::PageList(QObject *parent)
4443 QString qmlSuffix = ".qml";
4544 QString disabledSuffix = ".disabled";
4645 QSet<QString> disabledPages;
47− QStringList dataDirs = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
46+ QStringList dataDirs;
4847
49− QString rootDir = qgetenv("UBUNTU_SYSTEM_SETTINGS_WIZARD_ROOT"); // for testing
50− if (!rootDir.isEmpty())
51− dataDirs = QStringList() << rootDir;
48+ if (isRunningInstalled()) {
49+ dataDirs = shellDataDirs();
50+ } else {
51+ dataDirs = QStringList() << qmlDirectory();
52+ }
5253
5354 Q_FOREACH(const QString &dataDir, dataDirs) {
54− QDir dir(dataDir + "/ubuntu/settings/wizard/qml/Pages");
55+ QDir dir(dataDir + "/Wizard/Pages");
5556 QStringList entries = dir.entryList(QStringList("[0-9]*"), QDir::Files | QDir::Readable);
5657 Q_FOREACH(const QString &entry, entries) {
5758 if (!m_pages.contains(entry) && entry.endsWith(qmlSuffix))
wizard/PageList.h → plugins/Wizard/PageList.hrenamed+3−5
@@ -1,6 +1,4 @@
11/*
2− * This file is part of system-settings
3− *
42 * Copyright (C) 2014 Canonical Ltd.
53 *
64 * This program is free software: you can redistribute it and/or modify it
@@ -16,8 +14,8 @@
1614 * with this program. If not, see <http://www.gnu.org/licenses/>.
1715 */
1816
19−#ifndef PAGELIST_H
20−#define PAGEList_H
17+#ifndef WIZARD_PAGELIST_H
18+#define WIZARD_PAGELIST_H
2119
2220#include <QMap>
2321#include <QObject>
@@ -52,4 +50,4 @@ private:
5250 QMap<QString, QString> m_pages;
5351};
5452
55−#endif // PAGELIST_H
53+#endif // WIZARD_PAGELIST_H
plugins/Wizard/System.cppnew file+87
@@ -0,0 +1,87 @@
1+/*
2+ * Copyright (C) 2014 Canonical Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it
5+ * under the terms of the GNU General Public License version 3, as published
6+ * by the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but
9+ * WITHOUT ANY WARRANTY; without even the implied warranties of
10+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11+ * PURPOSE. See the GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License along
14+ * with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "System.h"
18+
19+#include <QDBusInterface>
20+#include <QDBusMetaType>
21+#include <QDir>
22+#include <QFile>
23+#include <QMap>
24+#include <QProcess>
25+
26+System::System()
27+ : QObject(),
28+ m_fsWatcher()
29+{
30+ // Register the argument needed for UpdateActivationEnvironment below
31+ qDBusRegisterMetaType<QMap<QString,QString>>();
32+
33+ m_fsWatcher.addPath(wizardEnabledPath());
34+ connect(&m_fsWatcher, SIGNAL(fileChanged(const QString &)),
35+ this, SIGNAL(wizardEnabledChanged()));
36+}
37+
38+QString System::wizardEnabledPath()
39+{
40+ // Uses ubuntu-system-settings namespace for historic compatibility reasons
41+ return QDir::home().filePath(".config/ubuntu-system-settings/wizard-has-run");
42+}
43+
44+bool System::wizardEnabled() const
45+{
46+ return !QFile::exists(wizardEnabledPath());
47+}
48+
49+void System::setWizardEnabled(bool enabled)
50+{
51+ if (enabled) {
52+ QFile::remove(wizardEnabledPath());
53+ } else {
54+ QDir(wizardEnabledPath()).mkpath("..");
55+ QFile(wizardEnabledPath()).open(QIODevice::WriteOnly);
56+ }
57+}
58+
59+void System::setSessionVariable(const QString &variable, const QString &value)
60+{
61+ // We need to update both upstart's and DBus's environment
62+ QProcess::execute(QString("initctl set-env --global %1=%2").arg(variable, value));
63+
64+ QDBusInterface iface("org.freedesktop.DBus",
65+ "/org/freedesktop/DBus",
66+ "org.freedesktop.DBus",
67+ QDBusConnection::sessionBus());
68+
69+ QMap<QString,QString> valueMap;
70+ valueMap.insert(variable, value);
71+ iface.call("UpdateActivationEnvironment", QVariant::fromValue(valueMap));
72+}
73+
74+void System::updateSessionLanguage(const QString &locale)
75+{
76+ QString language = locale.split(".")[0];
77+
78+ setSessionVariable("LANGUAGE", language);
79+ setSessionVariable("LANG", locale);
80+ setSessionVariable("LC_ALL", locale);
81+
82+ // Indicators and OSK need to pick up new language
83+ QProcess::startDetached("sh -c \"initctl emit indicator-services-end; \
84+ stop maliit-server; \
85+ initctl emit --no-wait indicator-services-start; \
86+ initctl start --no-wait maliit-server\"");
87+}
plugins/Wizard/System.hnew file+50
@@ -0,0 +1,50 @@
1+/*
2+ * Copyright (C) 2014 Canonical Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it
5+ * under the terms of the GNU General Public License version 3, as published
6+ * by the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but
9+ * WITHOUT ANY WARRANTY; without even the implied warranties of
10+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11+ * PURPOSE. See the GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License along
14+ * with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef WIZARD_SYSTEM_H
18+#define WIZARD_SYSTEM_H
19+
20+#include <QFileSystemWatcher>
21+#include <QObject>
22+#include <QString>
23+
24+class System : public QObject
25+{
26+ Q_OBJECT
27+ Q_PROPERTY(bool wizardEnabled READ wizardEnabled WRITE setWizardEnabled NOTIFY wizardEnabledChanged)
28+
29+public:
30+ System();
31+
32+ bool wizardEnabled() const;
33+ void setWizardEnabled(bool enabled);
34+
35+public Q_SLOTS:
36+ void updateSessionLanguage(const QString &locale);
37+
38+Q_SIGNALS:
39+ void wizardEnabledChanged();
40+
41+private:
42+ Q_DISABLE_COPY(System)
43+
44+ static QString wizardEnabledPath();
45+ static void setSessionVariable(const QString &variable, const QString &value);
46+
47+ QFileSystemWatcher m_fsWatcher;
48+};
49+
50+#endif
wizard/Unity/Application/CMakeLists.txt → plugins/Wizard/Unity/Application/CMakeLists.txtrenamed

The content is the same.

wizard/Unity/Application/OSKController.qml → plugins/Wizard/Unity/Application/OSKController.qmlrenamed

The content is the same.

wizard/Unity/Application/qmldir → plugins/Wizard/Unity/Application/qmldirrenamed

The content is the same.

wizard/Unity/CMakeLists.txt → plugins/Wizard/Unity/CMakeLists.txtrenamed

The content is the same.

wizard/Utils/CMakeLists.txt → plugins/Wizard/Utils/CMakeLists.txtrenamed

The content is the same.

wizard/Utils/plugin.cpp → plugins/Wizard/Utils/plugin.cpprenamed

The content is the same.

wizard/Utils/plugin.h → plugins/Wizard/Utils/plugin.hrenamed

The content is the same.

wizard/Utils/qmldir → plugins/Wizard/Utils/qmldirrenamed

The content is the same.

wizard/Utils/qsortfilterproxymodelqml.cpp → plugins/Wizard/Utils/qsortfilterproxymodelqml.cpprenamed

The content is the same.

wizard/Utils/qsortfilterproxymodelqml.h → plugins/Wizard/Utils/qsortfilterproxymodelqml.hrenamed

The content is the same.

plugins/Wizard/Wizard.qmltypesnew file+36
@@ -0,0 +1,36 @@
1+import QtQuick.tooling 1.1
2+
3+// This file describes the plugin-supplied types contained in the library.
4+// It is used for QML tooling purposes only.
5+//
6+// This file was auto-generated by:
7+// 'qmlplugindump -notrelocatable Wizard 0.1 plugins'
8+
9+Module {
10+ Component {
11+ name: "PageList"
12+ prototype: "QObject"
13+ exports: ["Wizard/PageList 0.1"]
14+ isCreatable: false
15+ isSingleton: true
16+ exportMetaObjectRevisions: [0]
17+ Property { name: "index"; type: "int"; isReadonly: true }
18+ Property { name: "numPages"; type: "int"; isReadonly: true }
19+ Method { name: "prev"; type: "string" }
20+ Method { name: "next"; type: "string" }
21+ }
22+ Component {
23+ name: "System"
24+ prototype: "QObject"
25+ exports: ["Wizard/System 0.1"]
26+ isCreatable: false
27+ isSingleton: true
28+ exportMetaObjectRevisions: [0]
29+ Property { name: "wizardEnabled"; type: "bool" }
30+ Method {
31+ name: "updateSessionLanguage"
32+ Parameter { name: "locale"; type: "string" }
33+ }
34+ }
35+}
36+
wizard/main.cpp → plugins/Wizard/main.cpprenamed

The content is the same.

plugins/Wizard/plugin.cppnew file+42
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (C) 2014 Canonical Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it
5+ * under the terms of the GNU General Public License version 3, as published
6+ * by the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but
9+ * WITHOUT ANY WARRANTY; without even the implied warranties of
10+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11+ * PURPOSE. See the GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License along
14+ * with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "plugin.h"
18+#include "PageList.h"
19+#include "System.h"
20+
21+#include <QtQml/qqml.h>
22+
23+static QObject *pagelist_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
24+{
25+ Q_UNUSED(engine)
26+ Q_UNUSED(scriptEngine)
27+ return new PageList();
28+}
29+
30+static QObject *system_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
31+{
32+ Q_UNUSED(engine)
33+ Q_UNUSED(scriptEngine)
34+ return new System();
35+}
36+
37+void WizardPlugin::registerTypes(const char *uri)
38+{
39+ Q_ASSERT(uri == QLatin1String("Wizard"));
40+ qmlRegisterSingletonType<PageList>(uri, 0, 1, "PageList", pagelist_provider);
41+ qmlRegisterSingletonType<System>(uri, 0, 1, "System", system_provider);
42+}
plugins/Wizard/plugin.hnew file+34
@@ -0,0 +1,34 @@
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+ * Author: Renato Araujo Oliveira Filho <renato.filho@canonical.com>
17+ */
18+
19+#ifndef WIZARD_PLUGIN_H
20+#define WIZARD_PLUGIN_H
21+
22+#include <QtQml/QQmlEngine>
23+#include <QtQml/QQmlExtensionPlugin>
24+
25+class WizardPlugin : public QQmlExtensionPlugin
26+{
27+ Q_OBJECT
28+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
29+
30+public:
31+ void registerTypes(const char *uri);
32+};
33+
34+#endif
plugins/Wizard/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module Wizard
2+plugin Wizard-qml
3+typeinfo Wizard.qmltypes
wizard/test.sh → plugins/Wizard/test.shrenamed

The content is the same.

wizard/ubuntu-system-settings-wizard-cleanup.conf → plugins/Wizard/ubuntu-system-settings-wizard-cleanup.confrenamed

The content is the same.

wizard/ubuntu-system-settings-wizard-set-lang.conf → plugins/Wizard/ubuntu-system-settings-wizard-set-lang.confrenamed

The content is the same.

wizard/ubuntu-system-settings-wizard.conf → plugins/Wizard/ubuntu-system-settings-wizard.confrenamed

The content is the same.

qml/Shell.qml+7
@@ -37,6 +37,7 @@ import "Components"
3737import "Notifications"
3838import "Stages"
3939import "Panel/Indicators"
40+import "Wizard"
4041import Unity.Notifications 1.0 as NotificationBackend
4142import Unity.Session 0.1
4243import Unity.DashCommunicator 0.1
@@ -726,6 +727,12 @@ Item {
726727 }
727728 }
728729
730+ Wizard {
731+ id: wizard
732+ anchors.fill: parent
733+ background: shell.background
734+ }
735+
729736 Rectangle {
730737 id: modalNotificationBackground
731738
wizard/qml/Components/CheckableSetting.qml → qml/Wizard/CheckableSetting.qmlrenamed−1
@@ -15,7 +15,6 @@
1515 */
1616
1717import QtQuick 2.3
18−import QMenuModel 0.1
1918import Ubuntu.Components 1.1
2019import Ubuntu.Components.ListItems 1.0 as ListItem
2120
wizard/qml/Components/InputMethod.qml → qml/Wizard/Components/InputMethod.qmlrenamed

The content is the same.

wizard/qml/Components/Page.qml → qml/Wizard/Page.qmlrenamed+1−2
@@ -16,7 +16,6 @@
1616
1717import QtQuick 2.3
1818import Ubuntu.Components 1.1
19−import "." as LocalComponents
2019
2120Item {
2221 readonly property real buttonMargin: units.gu(2)
@@ -76,7 +75,7 @@ Item {
7675 }
7776 }
7877
79− LocalComponents.StackButton {
78+ StackButton {
8079 id: backButton
8180 width: buttonWidth
8281 anchors {
qml/Wizard/Pages.qmlnew file+132
@@ -0,0 +1,132 @@
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.3
18+import Ubuntu.Components 1.1
19+import Ubuntu.SystemSettings.SecurityPrivacy 1.0
20+import Wizard 0.1
21+import "../Components"
22+
23+Showable {
24+ // The background wallpaper to use
25+ property string background
26+
27+ ////
28+
29+ id: root
30+ focus: true
31+
32+ // These should be set by a security page and we apply the settings when
33+ // the user exits the wizard.
34+ property int passwordMethod: UbuntuSecurityPrivacyPanel.Passcode
35+ property string password: ""
36+
37+ hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
38+
39+ UbuntuSecurityPrivacyPanel {
40+ id: securityPrivacy
41+ }
42+
43+ function quitWizard() {
44+ var errorMsg = "" //securityPrivacy.setSecurity("", password, passwordMethod)
45+ if (errorMsg !== "") {
46+ // Ignore (but log) any errors, since we're past where the user set
47+ // the method. Worst case, we just leave the user with a swipe
48+ // security method and they fix it in the system settings.
49+ console.log("Error setting security method:", errorMsg)
50+ }
51+
52+ System.wizardEnabled = false;
53+ hide();
54+ }
55+
56+ MouseArea { // eat anything that gets past widgets
57+ anchors.fill: parent
58+ }
59+
60+ Image {
61+ id: image
62+ // Use x/y/height/width instead of anchors so that we don't adjust
63+ // the image when the OSK appears.
64+ x: 0
65+ y: 0
66+ height: root.height
67+ width: root.width
68+ sourceSize.height: height
69+ sourceSize.width: width
70+ source: root.background
71+ fillMode: Image.PreserveAspectCrop
72+ visible: status === Image.Ready
73+ }
74+
75+ PageStack {
76+ id: pageStack
77+ anchors.fill: parent
78+
79+ function next() {
80+ // If we've opened any extra (non-main) pages, pop them before
81+ // continuing so back button returns to the previous main page.
82+ while (PageList.index < pageStack.depth - 1)
83+ pop()
84+ load(PageList.next())
85+ }
86+
87+ function prev() {
88+ if (PageList.index >= pageStack.depth - 1)
89+ PageList.prev() // update PageList.index, but not for extra pages
90+ pop()
91+ if (!currentPage || currentPage.opacity === 0) { // undo skipped pages
92+ prev()
93+ } else {
94+ currentPage.enabled = true
95+ }
96+ }
97+
98+ function load(path) {
99+ if (currentPage) {
100+ currentPage.enabled = false
101+ }
102+
103+ // First load it invisible, check that we should actually use
104+ // this page, and either skip it or continue.
105+ push(path, {"opacity": 0, "enabled": false})
106+
107+ // Check for immediate skip or not. We may have to wait for
108+ // skipValid to be assigned (see Connections object below)
109+ _checkSkip()
110+ }
111+
112+ function _checkSkip() {
113+ if (!currentPage) { // may have had a parse error
114+ next()
115+ } else if (currentPage.skipValid) {
116+ if (currentPage.skip) {
117+ next()
118+ } else {
119+ currentPage.opacity = 1
120+ currentPage.enabled = true
121+ }
122+ }
123+ }
124+
125+ Connections {
126+ target: pageStack.currentPage
127+ onSkipValidChanged: pageStack._checkSkip()
128+ }
129+
130+ Component.onCompleted: next()
131+ }
132+}
wizard/qml/Pages/10-welcome.qml → qml/Wizard/Pages/10-welcome.qmlrenamed+3−3
@@ -18,8 +18,8 @@ import QtQuick 2.3
1818import Ubuntu.Components 1.1
1919import Ubuntu.Components.ListItems 0.1
2020import Ubuntu.SystemSettings.LanguagePlugin 1.0
21−import Ubuntu.SystemSettings.Wizard.Utils 0.1
22−import "../Components" as LocalComponents
21+import Wizard 0.1
22+import ".." as LocalComponents
2323
2424LocalComponents.Page {
2525 title: i18n.tr("Hi!")
@@ -85,7 +85,7 @@ LocalComponents.Page {
8585 text: i18n.tr("Continue")
8686 onClicked: {
8787 plugin.currentLanguage = listview.currentIndex
88− System.updateSessionLanguage()
88+ System.updateSessionLanguage(plugin.languageCodes[listview.currentIndex]);
8989 pageStack.next()
9090 }
9191 }
wizard/qml/Pages/20-sim.qml → qml/Wizard/Pages/20-sim.qmlrenamed+1−1
@@ -17,7 +17,7 @@
1717import QtQuick 2.0
1818import MeeGo.QOfono 0.2
1919import Ubuntu.Components 0.1
20−import "../Components" as LocalComponents
20+import ".." as LocalComponents
2121
2222LocalComponents.Page {
2323 title: i18n.tr("Add a SIM card and restart your device")
wizard/qml/Pages/30-passwd-type.qml → qml/Wizard/Pages/30-passwd-type.qmlrenamed+13−1
@@ -18,7 +18,7 @@ import QtQuick 2.3
1818import Ubuntu.Components 1.1
1919import Ubuntu.Components.ListItems 1.0
2020import Ubuntu.SystemSettings.SecurityPrivacy 1.0
21−import "../Components" as LocalComponents
21+import ".." as LocalComponents
2222
2323/**
2424 * One quirk with this page: we don't actually set the password. We avoid
@@ -77,6 +77,7 @@ LocalComponents.Page {
7777 expanded: true
7878 anchors.left: parent.left
7979 anchors.right: parent.right
80+ property color originalBackground
8081
8182 model: ["", "", ""] // otherwise the delegate will show the text itself and we only want subText
8283
@@ -103,6 +104,17 @@ LocalComponents.Page {
103104 }
104105
105106 style: Item {}
107+
108+ Component.onCompleted: {
109+ // A visible selected background looks bad in ListItem widgets with our theme
110+ originalBackground = Theme.palette.selected.background
111+ Theme.palette.selected.background = "transparent"
112+ }
113+
114+ Component.onDestruction: {
115+ // Restore original theme background
116+ Theme.palette.selected.background = originalBackground
117+ }
106118 }
107119 }
108120
wizard/qml/Pages/40-wifi.qml → qml/Wizard/Pages/40-wifi.qmlrenamed+1−2
@@ -18,9 +18,8 @@ import QtQuick 2.0
1818import QMenuModel 0.1 as QMenuModel
1919import Ubuntu.Components 0.1
2020import Ubuntu.Components.ListItems 0.1 as ListItem
21−import Ubuntu.SystemSettings.Wizard.Utils 0.1
2221import Ubuntu.Settings.Menus 0.1 as Menus
23−import "../Components" as LocalComponents
22+import ".." as LocalComponents
2423
2524LocalComponents.Page {
2625 id: wifiPage
wizard/qml/Pages/50-location.qml → qml/Wizard/Pages/50-location.qmlrenamed+12−7
@@ -15,29 +15,34 @@
1515 */
1616
1717import QtQuick 2.3
18+import AccountsService 0.1
1819import QMenuModel 0.1 as QMenuModel
1920import Qt.labs.folderlistmodel 2.1
2021import Ubuntu.Components 1.1
21−import Ubuntu.SystemSettings.Wizard.Utils 0.1
22−import "../Components" as LocalComponents
22+import ".." as LocalComponents
2323
2424LocalComponents.Page {
2525 title: i18n.tr("Location")
2626 forwardButtonSourceComponent: forwardButton
2727
28− property bool pathSet: System.hereLicensePath !== " " // single space means it's unassigned
28+ property bool pathSet: AccountsService.hereLicensePath !== " " // single space means it's unassigned
2929 property bool countSet: false
30− skipValid: pathSet && (System.hereLicensePath === "" || countSet)
31− skip: skipValid && (System.hereLicensePath === "" || termsModel.count === 0)
30+ skipValid: pathSet && (AccountsService.hereLicensePath === "" || countSet)
31+ skip: skipValid && (AccountsService.hereLicensePath === "" || termsModel.count === 0)
3232
3333 Connections {
3434 target: termsModel
3535 onCountChanged: if (pathSet) countSet = true
3636 }
3737
38+ Connections {
39+ target: AccountsService
40+ onHereLicensePathChanged: console.log("MIKE path is", AccountsService.hereLicensePath)
41+ }
42+
3843 FolderListModel {
3944 id: termsModel
40− folder: System.hereLicensePath
45+ folder: AccountsService.hereLicensePath
4146 nameFilters: ["*.html"]
4247 showDirs: false
4348 showOnlyReadable: true
@@ -141,7 +146,7 @@ LocalComponents.Page {
141146 if (locationActionGroup.gps.state != gpsOn) {
142147 locationActionGroup.gps.activate();
143148 }
144− System.hereEnabled = hereOn;
149+ AccountsService.hereEnabled = hereOn;
145150 pageStack.next()
146151 }
147152 }
wizard/qml/Pages/60-reporting.qml → qml/Wizard/Pages/60-reporting.qmlrenamed+1−1
@@ -16,7 +16,7 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19−import "../Components" as LocalComponents
19+import ".." as LocalComponents
2020
2121LocalComponents.Page {
2222 title: i18n.tr("Improving your experience")
wizard/qml/Pages/80-finished.qml → qml/Wizard/Pages/80-finished.qmlrenamed+1−1
@@ -16,7 +16,7 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19−import "../Components" as LocalComponents
19+import ".." as LocalComponents
2020
2121LocalComponents.Page {
2222 title: i18n.tr("All done")
wizard/qml/Pages/data/meet_ubuntu_simcard@30.png → qml/Wizard/Pages/data/meet_ubuntu_simcard@30.pngrenamed

Binary file not shown.

wizard/qml/Pages/here-terms.qml → qml/Wizard/Pages/here-terms.qmlrenamed+4−4
@@ -15,11 +15,11 @@
1515 */
1616
1717import QtQuick 2.3
18+import AccountsService 0.1
1819import Qt.labs.folderlistmodel 2.1
1920import Ubuntu.Components 1.1
20−import Ubuntu.SystemSettings.Wizard.Utils 0.1
2121import Ubuntu.Web 0.2
22−import "../Components" as LocalComponents
22+import ".." as LocalComponents
2323
2424LocalComponents.Page {
2525 title: i18n.tr("Terms & Conditions")
@@ -27,7 +27,7 @@ LocalComponents.Page {
2727
2828 FolderListModel {
2929 id: termsModel
30− folder: System.hereLicensePath
30+ folder: AccountsService.hereLicensePath
3131 nameFilters: ["*.html"]
3232 showDirs: false
3333 showOnlyReadable: true
@@ -73,7 +73,7 @@ LocalComponents.Page {
7373
7474 function loadFileContent() {
7575 var xhr = new XMLHttpRequest
76− xhr.open("GET", System.hereLicensePath + "/" + determineFileName())
76+ xhr.open("GET", AccountsService.hereLicensePath + "/" + determineFileName())
7777 xhr.onreadystatechange = function() {
7878 if (xhr.readyState == XMLHttpRequest.DONE) {
7979 termsLabel.text = xhr.responseText
wizard/qml/Pages/passwd-confirm.qml → qml/Wizard/Pages/passwd-confirm.qmlrenamed+2−2
@@ -17,8 +17,8 @@
1717import QtQuick 2.3
1818import Ubuntu.Components 1.1
1919import Ubuntu.SystemSettings.SecurityPrivacy 1.0
20−import "../Components" as LocalComponents
21−import "file:///usr/share/unity8/Components" as UnityComponents
20+import ".." as LocalComponents
21+import "../../Components" as UnityComponents
2222
2323/**
2424 * See the main passwd-type page for an explanation of why we don't actually
wizard/qml/Pages/passwd-set.qml → qml/Wizard/Pages/passwd-set.qmlrenamed+2−2
@@ -17,8 +17,8 @@
1717import QtQuick 2.3
1818import Ubuntu.Components 1.1
1919import Ubuntu.SystemSettings.SecurityPrivacy 1.0
20−import "../Components" as LocalComponents
21−import "file:///usr/share/unity8/Components" as UnityComponents
20+import ".." as LocalComponents
21+import "../../Components" as UnityComponents
2222
2323/**
2424 * See the main passwd-type page for an explanation of why we don't actually
wizard/qml/Components/StackButton.qml → qml/Wizard/StackButton.qmlrenamed

The content is the same.

qml/Wizard/Wizard.qmlnew file+40
@@ -0,0 +1,40 @@
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.3
18+import Ubuntu.Components 1.1
19+import Wizard 0.1
20+
21+Item {
22+ // The background wallpaper to use
23+ property string background
24+
25+ ////
26+
27+ id: root
28+
29+ Loader {
30+ id: loader
31+ anchors.fill: parent
32+ property bool itemRequired // avoids a binding loop on item.required
33+ active: System.wizardEnabled || itemRequired
34+ sourceComponent: Pages {
35+ anchors.fill: parent
36+ background: root.background
37+ onRequiredChanged: loader.itemRequired = required
38+ }
39+ }
40+}
tests/CMakeLists.txt−1
@@ -14,4 +14,3 @@ add_subdirectory(whitespace)
1414add_subdirectory(plugins)
1515add_subdirectory(utils)
1616add_subdirectory(uqmlscene)
17−add_subdirectory(wizard)
tests/mocks/AccountsService/AccountsService.cpp+25−1
@@ -27,7 +27,9 @@ AccountsService::AccountsService(QObject* parent)
2727 m_backgroundFile(qmlDirectory() + "graphics/phone_background.jpg"),
2828 m_statsWelcomeScreen(true),
2929 m_failedLogins(0),
30− m_demoEdges(false)
30+ m_demoEdges(false),
31+ m_hereEnabled(false),
32+ m_hereLicensePath("")
3133{
3234}
3335
@@ -116,3 +118,25 @@ void AccountsService::setFailedLogins(uint failedLogins)
116118 m_failedLogins = failedLogins;
117119 failedLoginsChanged();
118120}
121+
122+bool AccountsService::hereEnabled() const
123+{
124+ return m_hereEnabled;
125+}
126+
127+void AccountsService::setHereEnabled(bool enabled)
128+{
129+ m_hereEnabled = enabled;
130+ hereEnabledChanged();
131+}
132+
133+QString AccountsService::hereLicensePath() const
134+{
135+ return m_hereLicensePath;
136+}
137+
138+void AccountsService::setHereLicensePath(const QString &path)
139+{
140+ m_hereLicensePath = path;
141+ hereLicensePathChanged();
142+}
tests/mocks/AccountsService/AccountsService.h+16
@@ -59,6 +59,14 @@ class AccountsService: public QObject
5959 READ failedLogins
6060 WRITE setFailedLogins
6161 NOTIFY failedLoginsChanged)
62+ Q_PROPERTY(bool hereEnabled
63+ READ hereEnabled
64+ WRITE setHereEnabled
65+ NOTIFY hereEnabledChanged)
66+ Q_PROPERTY(QString hereLicensePath
67+ READ hereLicensePath
68+ WRITE setHereLicensePath // only available in mock
69+ NOTIFY hereLicensePathChanged)
6270
6371public:
6472 enum PasswordDisplayHint {
@@ -83,6 +91,10 @@ public:
8391 PasswordDisplayHint passwordDisplayHint() const;
8492 uint failedLogins() const;
8593 void setFailedLogins(uint failedLogins);
94+ bool hereEnabled() const;
95+ void setHereEnabled(bool enabled);
96+ QString hereLicensePath() const;
97+ void setHereLicensePath(const QString &path);
8698
8799Q_SIGNALS:
88100 void userChanged();
@@ -93,6 +105,8 @@ Q_SIGNALS:
93105 void statsWelcomeScreenChanged();
94106 void passwordDisplayHintChanged();
95107 void failedLoginsChanged();
108+ void hereEnabledChanged();
109+ void hereLicensePathChanged();
96110
97111private:
98112 bool m_enableLauncherWhileLocked;
@@ -102,6 +116,8 @@ private:
102116 bool m_statsWelcomeScreen;
103117 uint m_failedLogins;
104118 bool m_demoEdges;
119+ bool m_hereEnabled;
120+ QString m_hereLicensePath;
105121};
106122
107123#endif
tests/mocks/CMakeLists.txt+1
@@ -37,6 +37,7 @@ add_subdirectory(QMenuModel)
3737add_subdirectory(Ubuntu)
3838add_subdirectory(Unity)
3939add_subdirectory(QtMultimedia)
40+add_subdirectory(Wizard)
4041
4142install(
4243 DIRECTORY data
tests/mocks/QMenuModel/CMakeLists.txt+1
@@ -5,6 +5,7 @@ include_directories(
55
66set(QMenuModelQml_SOURCES
77 actionstateparser.cpp
8+ dbus-enums.h
89 plugin.cpp
910 unitymenumodel.cpp
1011)
tests/mocks/QMenuModel/dbus-enums.hnew file+52
@@ -0,0 +1,52 @@
1+/*
2+ * Copyright 2012 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:
17+ * Olivier Tilloy <olivier.tilloy@canonical.com>
18+ */
19+
20+#ifndef __DBUS_ENUMS__
21+#define __DBUS_ENUMS__
22+
23+#include <QObject>
24+
25+// This class acts as a namespace only, with the addition that its enums
26+// are registered to be exposed on the QML side.
27+class DBusEnums : public QObject
28+{
29+ Q_OBJECT
30+
31+ Q_ENUMS(BusType)
32+ Q_ENUMS(ConnectionStatus)
33+
34+public:
35+ enum BusType {
36+ None = 0,
37+ SessionBus,
38+ SystemBus,
39+ LastBusType
40+ };
41+
42+ enum ConnectionStatus {
43+ Disconnected = 0,
44+ Connecting,
45+ Connected
46+ };
47+
48+private:
49+ DBusEnums() {}
50+};
51+
52+#endif // __DBUS_ENUMS__
tests/mocks/QMenuModel/plugin.cpp+3
@@ -19,12 +19,15 @@
1919#include "plugin.h"
2020#include "unitymenumodel.h"
2121#include "actionstateparser.h"
22+#include "dbus-enums.h"
2223
2324#include <QtQml/qqml.h>
2425
2526void QMenuModelPlugin::registerTypes(const char *uri)
2627{
2728 Q_ASSERT(uri == QLatin1String("QMenuModel"));
29+ qmlRegisterUncreatableType<DBusEnums>(uri, 0, 1, "DBus",
30+ "DBus is only a namespace");
2831 qmlRegisterType<UnityMenuModel>(uri, 0, 1, "UnityMenuModel");
2932 qmlRegisterType<ActionStateParser>(uri, 0, 1, "ActionStateParser");
3033}
tests/mocks/Wizard/CMakeLists.txtnew file+12
@@ -0,0 +1,12 @@
1+include_directories(
2+ ${CMAKE_SOURCE_DIR}/plugins/Wizard
3+)
4+
5+add_library(MockWizard-qml MODULE
6+ mockplugin.cpp
7+ MockSystem.cpp
8+ ${CMAKE_SOURCE_DIR}/plugins/Wizard/PageList.cpp
9+)
10+
11+qt5_use_modules(MockWizard-qml Qml)
12+add_unity8_mock(Wizard 0.1 Wizard TARGETS MockWizard-qml)
tests/mocks/Wizard/MockSystem.cppnew file+38
@@ -0,0 +1,38 @@
1+/*
2+ * Copyright (C) 2014 Canonical Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it
5+ * under the terms of the GNU General Public License version 3, as published
6+ * by the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but
9+ * WITHOUT ANY WARRANTY; without even the implied warranties of
10+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11+ * PURPOSE. See the GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License along
14+ * with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "MockSystem.h"
18+
19+MockSystem::MockSystem()
20+ : QObject(),
21+ m_wizardEnabled(false)
22+{
23+}
24+
25+bool MockSystem::wizardEnabled() const
26+{
27+ return m_wizardEnabled;
28+}
29+
30+void MockSystem::setWizardEnabled(bool enabled)
31+{
32+ m_wizardEnabled = enabled;
33+ Q_EMIT wizardEnabledChanged();
34+}
35+
36+void MockSystem::updateSessionLanguage(const QString &)
37+{
38+}
tests/mocks/Wizard/MockSystem.hnew file+46
@@ -0,0 +1,46 @@
1+/*
2+ * Copyright (C) 2014 Canonical Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it
5+ * under the terms of the GNU General Public License version 3, as published
6+ * by the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but
9+ * WITHOUT ANY WARRANTY; without even the implied warranties of
10+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11+ * PURPOSE. See the GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License along
14+ * with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef WIZARD_MOCK_SYSTEM_H
18+#define WIZARD_MOCK_SYSTEM_H
19+
20+#include <QObject>
21+#include <QString>
22+
23+class MockSystem : public QObject
24+{
25+ Q_OBJECT
26+ Q_PROPERTY(bool wizardEnabled READ wizardEnabled WRITE setWizardEnabled NOTIFY wizardEnabledChanged)
27+
28+public:
29+ MockSystem();
30+
31+ bool wizardEnabled() const;
32+ void setWizardEnabled(bool enabled);
33+
34+public Q_SLOTS:
35+ void updateSessionLanguage(const QString &locale);
36+
37+Q_SIGNALS:
38+ void wizardEnabledChanged();
39+
40+private:
41+ Q_DISABLE_COPY(MockSystem)
42+
43+ bool m_wizardEnabled;
44+};
45+
46+#endif
tests/mocks/Wizard/Wizard.qmltypesnew file+36
@@ -0,0 +1,36 @@
1+import QtQuick.tooling 1.1
2+
3+// This file describes the plugin-supplied types contained in the library.
4+// It is used for QML tooling purposes only.
5+//
6+// This file was auto-generated by:
7+// 'qmlplugindump -notrelocatable Wizard 0.1 tests/mocks'
8+
9+Module {
10+ Component {
11+ name: "MockSystem"
12+ prototype: "QObject"
13+ exports: ["Wizard/System 0.1"]
14+ isCreatable: false
15+ isSingleton: true
16+ exportMetaObjectRevisions: [0]
17+ Property { name: "wizardEnabled"; type: "bool" }
18+ Method {
19+ name: "updateSessionLanguage"
20+ Parameter { name: "locale"; type: "string" }
21+ }
22+ }
23+ Component {
24+ name: "PageList"
25+ prototype: "QObject"
26+ exports: ["Wizard/PageList 0.1"]
27+ isCreatable: false
28+ isSingleton: true
29+ exportMetaObjectRevisions: [0]
30+ Property { name: "index"; type: "int"; isReadonly: true }
31+ Property { name: "numPages"; type: "int"; isReadonly: true }
32+ Method { name: "prev"; type: "string" }
33+ Method { name: "next"; type: "string" }
34+ }
35+}
36+
tests/mocks/Wizard/mockplugin.cppnew file+42
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright (C) 2012,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+#include "mockplugin.h"
18+#include "MockSystem.h"
19+#include "PageList.h"
20+
21+#include <QtQml/qqml.h>
22+
23+static QObject *pagelist_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
24+{
25+ Q_UNUSED(engine)
26+ Q_UNUSED(scriptEngine)
27+ return new PageList();
28+}
29+
30+static QObject *system_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
31+{
32+ Q_UNUSED(engine)
33+ Q_UNUSED(scriptEngine)
34+ return new MockSystem();
35+}
36+
37+void MockWizardPlugin::registerTypes(const char *uri)
38+{
39+ Q_ASSERT(uri == QLatin1String("Wizard"));
40+ qmlRegisterSingletonType<PageList>(uri, 0, 1, "PageList", pagelist_provider);
41+ qmlRegisterSingletonType<MockSystem>(uri, 0, 1, "System", system_provider);
42+}
tests/mocks/Wizard/mockplugin.hnew file+32
@@ -0,0 +1,32 @@
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+#ifndef MOCK_WIZARD_PLUGIN_H
18+#define MOCK_WIZARD_PLUGIN_H
19+
20+#include <QtQml/QQmlEngine>
21+#include <QtQml/QQmlExtensionPlugin>
22+
23+class MockWizardPlugin : public QQmlExtensionPlugin
24+{
25+ Q_OBJECT
26+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
27+
28+public:
29+ void registerTypes(const char *uri);
30+};
31+
32+#endif
tests/mocks/Wizard/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module Wizard
2+plugin MockWizard-qml
3+typeinfo Wizard.qmltypes
tests/plugins/CMakeLists.txt+1
@@ -4,3 +4,4 @@ add_subdirectory(Dash)
44add_subdirectory(Ubuntu)
55add_subdirectory(Unity)
66add_subdirectory(Utils)
7+add_subdirectory(Wizard)
tests/plugins/Wizard/CMakeLists.txtnew file+11
@@ -0,0 +1,11 @@
1+include_directories(
2+ ${CMAKE_CURRENT_BINARY_DIR}
3+ ${CMAKE_SOURCE_DIR}/plugins/Wizard
4+)
5+
6+add_executable(tst-pagelist
7+ tst_pagelist.cpp
8+ ${CMAKE_SOURCE_DIR}/plugins/Wizard/PageList.cpp
9+)
10+qt5_use_modules(tst-pagelist Core Qml Test)
11+add_test(tst-pagelist tst-pagelist)
tests/wizard/tst_pagelist.cpp → tests/plugins/Wizard/tst_pagelist.cpprenamed+1−3
@@ -1,6 +1,4 @@
11/*
2− * This file is part of system-settings
3− *
42 * Copyright (C) 2014 Canonical Ltd.
53 *
64 * This program is free software: you can redistribute it and/or modify it
@@ -23,7 +21,7 @@
2321#include <QTemporaryDir>
2422#include <QTest>
2523
26−#define PAGES_PATH "ubuntu/settings/wizard/qml/Pages"
24+#define PAGES_PATH "Wizard/Pages"
2725
2826class PageListTest: public QObject
2927{
tests/wizard/CMakeLists.txtdeleted−5
@@ -1,5 +0,0 @@
1−add_executable(tst-pagelist tst_pagelist.cpp ${CMAKE_SOURCE_DIR}/wizard/PageList.cpp)
2−set_target_properties(tst-pagelist PROPERTIES
3− INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR};${CMAKE_SOURCE_DIR}/wizard")
4−qt5_use_modules(tst-pagelist Core Test)
5−add_test(tst-pagelist tst-pagelist)
wizard/CMakeLists.txtdeleted−65
@@ -1,65 +0,0 @@
1−# This file uses a lot of namespacing like "ubuntu-system-settings" instead of
2−# "unity8". This is because we have imported it from ubuntu-system-settings
3−# and haven't fully integrated it yet.
4−
5−include_directories(
6− ${CMAKE_CURRENT_BINARY_DIR}
7− ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
8−)
9−
10−set(PLUGIN_MANIFEST_DIR_BASE share/ubuntu/settings/system)
11−set(PLUGIN_MODULE_DIR_BASE ubuntu-system-settings)
12−set(PLUGIN_PRIVATE_MODULE_DIR_BASE "${PLUGIN_MODULE_DIR_BASE}/private")
13−set(PLUGIN_QML_DIR_BASE share/ubuntu/settings/system/qml-plugins)
14−
15−set(PLUGIN_MANIFEST_DIR "${CMAKE_INSTALL_PREFIX}/${PLUGIN_MANIFEST_DIR_BASE}")
16−set(PLUGIN_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${PLUGIN_MODULE_DIR_BASE}")
17−set(PLUGIN_PRIVATE_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${PLUGIN_PRIVATE_MODULE_DIR_BASE}")
18−set(PLUGIN_QML_DIR "${CMAKE_INSTALL_PREFIX}/${PLUGIN_QML_DIR_BASE}")
19−
20−add_definitions(-DI18N_DOMAIN="unity8")
21−add_definitions(-DPLUGIN_MANIFEST_DIR="${PLUGIN_MANIFEST_DIR}")
22−add_definitions(-DPLUGIN_MODULE_DIR="${PLUGIN_MODULE_DIR}")
23−add_definitions(-DPLUGIN_PRIVATE_MODULE_DIR="${PLUGIN_PRIVATE_MODULE_DIR}")
24−add_definitions(-DPLUGIN_QML_DIR="${PLUGIN_QML_DIR}")
25−
26−execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=plugindir unity-shell-api OUTPUT_VARIABLE SHELL_PLUGINDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
27−if(SHELL_PLUGINDIR STREQUAL "")
28− message(FATAL_ERROR "Could not determine plugin import dir.")
29−endif()
30−
31−add_definitions(-DSHELL_PLUGINDIR="${SHELL_PLUGINDIR}")
32−
33−set(WIZARD_ROOT "${CMAKE_INSTALL_PREFIX}/share")
34−add_definitions(-DWIZARD_ROOT="${WIZARD_ROOT}")
35−
36−file(GLOB_RECURSE QML_FILES
37− qml/*
38−)
39−
40−set(WIZARD_SOURCES
41− main.cpp
42− PageList.cpp
43−)
44−
45−add_executable(system-settings-wizard
46− ${WIZARD_SOURCES}
47− ${system-settings-wizard-resources}
48− ${QML_FILES} # This is to make qml and image files appear in the IDE's project tree
49−)
50−
51−qt5_use_modules(system-settings-wizard Core Gui Quick Qml)
52−
53−add_subdirectory(Unity)
54−add_subdirectory(Utils)
55−
56−install(TARGETS system-settings-wizard RUNTIME DESTINATION bin)
57−install(FILES ubuntu-system-settings-wizard.conf
58− ubuntu-system-settings-wizard-cleanup.conf
59− ubuntu-system-settings-wizard-set-lang.conf
60− DESTINATION share/upstart/sessions)
61−
62−set(POLKIT_LIB_DIR "${CMAKE_INSTALL_LOCALSTATEDIR}/lib/polkit-1")
63−install(FILES 50-com.ubuntu.system-settings.wizard.pkla DESTINATION ${POLKIT_LIB_DIR}/localauthority/10-vendor.d)
64−
65−install(DIRECTORY qml DESTINATION ${WIZARD_ROOT}/ubuntu/settings/wizard)
wizard/Utils/system.cppdeleted−118
@@ -1,118 +0,0 @@
1−/*
2− * This file is part of system-settings
3− *
4− * Copyright (C) 2014 Canonical Ltd.
5− *
6− * This program is free software: you can redistribute it and/or modify it
7− * under the terms of the GNU General Public License version 3, as published
8− * by the Free Software Foundation.
9− *
10− * This program is distributed in the hope that it will be useful, but
11− * WITHOUT ANY WARRANTY; without even the implied warranties of
12− * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13− * PURPOSE. See the GNU General Public License for more details.
14− *
15− * You should have received a copy of the GNU General Public License along
16− * with this program. If not, see <http://www.gnu.org/licenses/>.
17− */
18−
19−#include "system.h"
20−#include <QDBusInterface>
21−#include <QDBusPendingCall>
22−#include <QDBusPendingReply>
23−#include <QFile>
24−#include <QProcess>
25−#include <unistd.h>
26−
27−#define HERE_IFACE "com.ubuntu.location.providers.here.AccountsService"
28−#define ENABLED_PROP "LicenseAccepted"
29−#define PATH_PROP "LicenseBasePath"
30−
31−System::System()
32− : QObject(),
33− m_accounts(nullptr),
34− m_hereEnabled(false),
35− m_hereLicensePath(" ") // use a single space to indicate it is unasssigned
36−{
37− m_accounts = new QDBusInterface("org.freedesktop.Accounts",
38− "/org/freedesktop/Accounts/User" + QString::number(geteuid()),
39− "org.freedesktop.DBus.Properties",
40− QDBusConnection::systemBus(),
41− this);
42−
43− m_accounts->connection().connect(m_accounts->service(),
44− m_accounts->path(),
45− m_accounts->interface(),
46− "PropertiesChanged",
47− this,
48− SLOT(propertiesChanged(QString, QVariantMap, QStringList)));
49−
50− QDBusPendingCall call = m_accounts->asyncCall("Get", HERE_IFACE, PATH_PROP);
51− QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
52− QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)),
53− this, SLOT(getHereLicensePathFinished(QDBusPendingCallWatcher *)));
54−}
55−
56−void System::propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalid)
57−{
58− if (interface == HERE_IFACE) {
59− if (changed.contains(ENABLED_PROP)) {
60− m_hereEnabled = changed[ENABLED_PROP].toBool();
61− Q_EMIT hereEnabledChanged();
62− } else if (invalid.contains(ENABLED_PROP)) {
63− QDBusPendingCall call = m_accounts->asyncCall("Get", HERE_IFACE, ENABLED_PROP);
64− QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
65− QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher *)),
66− this, SLOT(getHereEnabledFinished(QDBusPendingCallWatcher *)));
67− }
68− }
69−}
70−
71−void System::getHereEnabledFinished(QDBusPendingCallWatcher *watcher)
72−{
73− QDBusPendingReply<QVariant> reply = *watcher;
74− if (!reply.isError()) {
75− QVariant value = reply.argumentAt<0>();
76− m_hereEnabled = value.toBool();
77− Q_EMIT hereEnabledChanged();
78− }
79− watcher->deleteLater();
80−}
81−
82−void System::getHereLicensePathFinished(QDBusPendingCallWatcher *watcher)
83−{
84− QDBusPendingReply<QVariant> reply = *watcher;
85−
86− m_hereLicensePath = "";
87−
88− if (!reply.isError()) {
89− QVariant value = reply.argumentAt<0>();
90− if (QFile::exists(value.toString())) {
91− m_hereLicensePath = value.toString();
92− }
93− }
94−
95− Q_EMIT hereLicensePathChanged();
96−
97− watcher->deleteLater();
98−}
99−
100−bool System::hereEnabled() const
101−{
102− return m_hereEnabled;
103−}
104−
105−void System::setHereEnabled(bool enabled)
106−{
107− m_accounts->asyncCall("Set", HERE_IFACE, ENABLED_PROP, QVariant::fromValue(QDBusVariant(enabled)));
108−}
109−
110−QString System::hereLicensePath() const
111−{
112− return m_hereLicensePath;
113−}
114−
115−void System::updateSessionLanguage()
116−{
117− QProcess::startDetached("sh -c \"initctl start ubuntu-system-settings-wizard-set-lang; initctl emit --no-wait indicator-services-start; initctl start --no-wait maliit-server\"");
118−}
wizard/Utils/system.hdeleted−57
@@ -1,57 +0,0 @@
1−/*
2− * This file is part of system-settings
3− *
4− * Copyright (C) 2014 Canonical Ltd.
5− *
6− * This program is free software: you can redistribute it and/or modify it
7− * under the terms of the GNU General Public License version 3, as published
8− * by the Free Software Foundation.
9− *
10− * This program is distributed in the hope that it will be useful, but
11− * WITHOUT ANY WARRANTY; without even the implied warranties of
12− * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13− * PURPOSE. See the GNU General Public License for more details.
14− *
15− * You should have received a copy of the GNU General Public License along
16− * with this program. If not, see <http://www.gnu.org/licenses/>.
17− */
18−
19−#include <QObject>
20−#include <QString>
21−
22−class QDBusInterface;
23−class QDBusPendingCallWatcher;
24−
25−class System : public QObject
26−{
27− Q_OBJECT
28− Q_PROPERTY(bool hereEnabled READ hereEnabled WRITE setHereEnabled NOTIFY hereEnabledChanged)
29− Q_PROPERTY(QString hereLicensePath READ hereLicensePath NOTIFY hereLicensePathChanged)
30−
31−public:
32− System();
33−
34− bool hereEnabled() const;
35− void setHereEnabled(bool enabled);
36−
37− QString hereLicensePath() const;
38−
39−public Q_SLOTS:
40− void updateSessionLanguage();
41−
42−Q_SIGNALS:
43− void hereEnabledChanged();
44− void hereLicensePathChanged();
45−
46−private Q_SLOTS:
47− void propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalid);
48− void getHereEnabledFinished(QDBusPendingCallWatcher *watcher);
49− void getHereLicensePathFinished(QDBusPendingCallWatcher *watcher);
50−
51−private:
52− Q_DISABLE_COPY(System)
53−
54− QDBusInterface *m_accounts;
55− bool m_hereEnabled;
56− QString m_hereLicensePath;
57−};
wizard/qml/main.qmldeleted−246
@@ -1,246 +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.3
18−import GSettings 1.0
19−import Ubuntu.Components 1.1
20−import Ubuntu.SystemSettings.SecurityPrivacy 1.0
21−import Unity.Application 0.1
22−import Unity.Notifications 1.0 as NotificationBackend
23−import Unity.Session 0.1
24−import "Components"
25−import "file:///usr/share/unity8/Notifications" as Notifications // FIXME This should become a module or go away
26−import "file:///usr/share/unity8/Components" as UnityComponents
27−
28−Item {
29− id: root
30− width: units.gu(40)
31− height: units.gu(71)
32− focus: true
33−
34− // These should be set by a security page and we apply the settings when
35− // the user exits the wizard.
36− property int passwordMethod: UbuntuSecurityPrivacyPanel.Passcode
37− property string password: ""
38−
39− Component.onCompleted: {
40− Theme.name = "Ubuntu.Components.Themes.SuruGradient"
41− // A visible selected background looks bad in ListItem widgets with our theme
42− Theme.palette.selected.background = "#00000000"
43− i18n.domain = "unity8"
44− }
45−
46− UbuntuSecurityPrivacyPanel {
47− id: securityPrivacy
48− }
49−
50− function quitWizard() {
51− // Immediately go to black to give quick feedback
52− blackCover.visible = true
53−
54− var errorMsg = securityPrivacy.setSecurity("", password, passwordMethod)
55− if (errorMsg !== "") {
56− // Ignore (but log) any errors, since we're past where the user set
57− // the method. Worst case, we just leave the user with a swipe
58− // security method and they fix it in the system settings.
59− console.log("Error setting security method:", errorMsg)
60− }
61−
62− Qt.quit()
63− }
64−
65− // This is just a little screen to immediately go to black once the wizard
66− // is done, to give quick feedback to the user.
67− Rectangle {
68− id: blackCover
69− color: "#000000"
70− anchors.fill: parent
71− z: 1
72− visible: false
73− }
74−
75− MainView {
76− anchors.fill: parent
77− headerColor: "#57365E"
78− backgroundColor: "#A55263"
79− footerColor: "#D75669"
80− anchorToKeyboard: true
81− useDeprecatedToolbar: false
82−
83− GSettings {
84− id: background
85− schema.id: "org.gnome.desktop.background"
86− }
87−
88− Image {
89− id: image
90− // Use x/y/height/width instead of anchors so that we don't adjust
91− // the image when the OSK appears.
92− x: 0
93− y: 0
94− height: root.height
95− width: root.width
96− source: background.pictureUri
97− fillMode: Image.PreserveAspectCrop
98− visible: status === Image.Ready
99− }
100−
101− PageStack {
102− id: pageStack
103−
104− function next() {
105− // If we've opened any extra (non-main) pages, pop them before
106− // continuing so back button returns to the previous main page.
107− while (pageList.index < pageStack.depth - 1)
108− pop()
109− load(pageList.next())
110− }
111−
112− function prev() {
113− if (pageList.index >= pageStack.depth - 1)
114− pageList.prev() // update pageList.index, but not for extra pages
115− pop()
116− if (!currentPage || currentPage.opacity === 0) { // undo skipped pages
117− prev()
118− } else {
119− currentPage.enabled = true
120− }
121− }
122−
123− function load(path) {
124− if (currentPage) {
125− currentPage.enabled = false
126− }
127−
128− // First load it invisible, check that we should actually use
129− // this page, and either skip it or continue.
130− push(path, {"opacity": 0, "enabled": false})
131−
132− // Check for immediate skip or not. We may have to wait for
133− // skipValid to be assigned (see Connections object below)
134− _checkSkip()
135− }
136−
137− function _checkSkip() {
138− if (!currentPage) { // may have had a parse error
139− next()
140− } else if (currentPage.skipValid) {
141− if (currentPage.skip) {
142− next()
143− } else {
144− currentPage.opacity = 1
145− currentPage.enabled = true
146− }
147− }
148− }
149−
150− Connections {
151− target: pageStack.currentPage
152− onSkipValidChanged: pageStack._checkSkip()
153− }
154−
155− Component.onCompleted: next()
156− }
157− }
158−
159− Rectangle {
160− id: modalNotificationBackground
161− visible: notifications.useModal && (notifications.state == "narrow")
162− anchors.fill: parent
163− color: "#80000000"
164−
165− MouseArea {
166− anchors.fill: parent
167− }
168− }
169−
170− InputMethod {
171− anchors.fill: parent
172− }
173−
174− Notifications.Notifications {
175− id: notifications
176− model: NotificationBackend.Model
177− margin: units.gu(1)
178− anchors {
179− top: parent.top
180− right: parent.right
181− bottom: parent.bottom
182− }
183− states: [
184− State {
185− name: "narrow"
186− when: parent.width <= units.gu(60)
187− AnchorChanges { target: notifications; anchors.left: parent.left }
188− },
189− State {
190− name: "wide"
191− when: parent.width > units.gu(60)
192− AnchorChanges { target: notifications; anchors.left: undefined }
193− PropertyChanges { target: notifications; width: units.gu(38) }
194− }
195− ]
196− }
197−
198− UnityComponents.Dialogs {
199− id: dialogs
200− anchors.fill: parent
201− z: 10
202− onPowerOffClicked: {
203− shutdownFadeOutRectangle.enabled = true;
204− shutdownFadeOutRectangle.visible = true;
205− shutdownFadeOut.start();
206− }
207− }
208−
209− Rectangle {
210− id: shutdownFadeOutRectangle
211− z: dialogs.z + 10
212− enabled: false
213− visible: false
214− color: "black"
215− anchors.fill: parent
216− opacity: 0.0
217− NumberAnimation on opacity {
218− id: shutdownFadeOut
219− from: 0.0
220− to: 1.0
221− onStopped: {
222− if (shutdownFadeOutRectangle.enabled && shutdownFadeOutRectangle.visible) {
223− DBusUnitySessionService.Shutdown();
224− }
225− }
226− }
227− }
228−
229− Keys.onPressed: {
230− if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
231− dialogs.onPowerKeyPressed();
232− event.accepted = true;
233− } else {
234− event.accepted = false;
235− }
236− }
237−
238− Keys.onReleased: {
239− if (event.key == Qt.Key_PowerOff || event.key == Qt.Key_PowerDown) {
240− dialogs.onPowerKeyReleased();
241− event.accepted = true;
242− } else {
243− event.accepted = false;
244− }
245− }
246−}