Merge lp:~jonas-drange/ubuntu-system-settings/appearance-launcher into lp:ubuntu-system-settings
- appearance-launcher
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ken VanDine | ||||
Approved revision: | 1745 | ||||
Merged at revision: | 1742 | ||||
Proposed branch: | lp:~jonas-drange/ubuntu-system-settings/appearance-launcher | ||||
Merge into: | lp:ubuntu-system-settings | ||||
Diff against target: |
1631 lines (+1383/-24) 35 files modified
debian/control (+1/-0) plugins/CMakeLists.txt (+1/-0) plugins/launcher/CMakeLists.txt (+20/-0) plugins/launcher/PageComponent.qml (+113/-0) plugins/launcher/launcher.h (+42/-0) plugins/launcher/launcher.settings (+14/-0) plugins/launcher/launcher_impl.cpp (+52/-0) plugins/launcher/launcher_impl.h (+40/-0) plugins/launcher/plugin.cpp (+39/-0) plugins/launcher/plugin.h (+33/-0) plugins/launcher/plugin/CMakeLists.txt (+8/-0) plugins/launcher/plugin/GuAccessor.qml (+6/-0) plugins/launcher/plugin/launcher-plugin.cpp (+86/-0) plugins/launcher/plugin/launcher-plugin.h (+37/-0) plugins/launcher/qmldir.in (+2/-0) plugins/launcher/settings-launcher.svg (+179/-0) src/CMakeLists.txt (+1/-1) src/main.cpp (+2/-23) tests/mocks/CMakeLists.txt (+1/-0) tests/mocks/GSettings.1.0/CMakeLists.txt (+19/-0) tests/mocks/GSettings.1.0/fake_gsettings.cpp (+193/-0) tests/mocks/GSettings.1.0/fake_gsettings.h (+118/-0) tests/mocks/GSettings.1.0/plugin.cpp (+35/-0) tests/mocks/GSettings.1.0/plugin.h (+33/-0) tests/mocks/GSettings.1.0/qmldir (+2/-0) tests/mocks/Ubuntu/SystemSettings/CMakeLists.txt (+1/-0) tests/mocks/Ubuntu/SystemSettings/Launcher/CMakeLists.txt (+20/-0) tests/mocks/Ubuntu/SystemSettings/Launcher/MockLauncherPanelPlugin.cpp (+57/-0) tests/mocks/Ubuntu/SystemSettings/Launcher/MockLauncherPanelPlugin.h (+49/-0) tests/mocks/Ubuntu/SystemSettings/Launcher/plugin.cpp (+37/-0) tests/mocks/Ubuntu/SystemSettings/Launcher/plugin.h (+32/-0) tests/mocks/Ubuntu/SystemSettings/Launcher/qmldir (+2/-0) tests/plugins/CMakeLists.txt (+8/-0) tests/plugins/launcher/Source/qmldir (+2/-0) tests/plugins/launcher/tst_LauncherPageComponent.qml (+98/-0) |
||||
To merge this branch: | bzr merge lp:~jonas-drange/ubuntu-system-settings/appearance-launcher | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ken VanDine | Approve | ||
system-apps-ci-bot | continuous-integration | Needs Fixing | |
Review via email: mp+310657@code.launchpad.net |
Commit message
* Packaging change: depend on USC for testing
* Adds Launcher settings panel to System Settings
* Makes USS a gapplication as a requirement for the use of the qtdesktopwidget
* Adds gsetting qml mock
Description of the change
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
- 1738. By Jonas G. Drange
-
clean up screens, add working launcher panel pluguin based on qdesktopwidget
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1738
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
- 1739. By Jonas G. Drange
-
merge trunk
- 1740. By Jonas G. Drange
-
finishes qml testing of launcher
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1740
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
- 1741. By Jonas G. Drange
-
adds test dep, drops unecessary import in EntryComponent
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1741
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Ken VanDine (ken-vandine) wrote : | # |
The grid isn't handling the visibility change, I'm just getting an empty item in the grid.
Also line 45 of EntryComponent.qml is spewing an error about pageStack.
- 1742. By Jonas G. Drange
-
obtain gus in c++ using qml file
- 1743. By Jonas G. Drange
-
changes confusing guard name
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1742
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1743
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
- 1744. By Jonas G. Drange
-
drops entrycomponent from makelist
- 1745. By Jonas G. Drange
-
uses RAII instead of a broken delete (there was a possible early return)
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1744
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1745
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Ken VanDine (ken-vandine) wrote : | # |
This looks good now. I tested for regressions on a vivid device, the launcher icon is not shown as expected.
Preview Diff
1 | === modified file 'debian/control' |
2 | --- debian/control 2016-11-09 15:25:45 +0000 |
3 | +++ debian/control 2016-11-21 14:26:16 +0000 |
4 | @@ -46,6 +46,7 @@ |
5 | qml-module-qttest, |
6 | qml-module-qtquick2, |
7 | qml-module-ubuntu-components | qml-module-ubuntu-components-gles, |
8 | + qtdeclarative5-ubuntu-settings-components (>= 0.8), |
9 | libubuntuoneauth-2.0-dev, |
10 | libqtdbusmock1-dev (>= 0.2+14.04.20140724), |
11 | libqtdbustest1-dev, |
12 | |
13 | === modified file 'plugins/CMakeLists.txt' |
14 | --- plugins/CMakeLists.txt 2016-04-25 15:38:51 +0000 |
15 | +++ plugins/CMakeLists.txt 2016-11-21 14:26:16 +0000 |
16 | @@ -11,6 +11,7 @@ |
17 | add_subdirectory(flight-mode) |
18 | add_subdirectory(hotspot) |
19 | add_subdirectory(language) |
20 | +add_subdirectory(launcher) |
21 | add_subdirectory(mouse) |
22 | add_subdirectory(notifications) |
23 | add_subdirectory(orientation-lock) |
24 | |
25 | === added directory 'plugins/launcher' |
26 | === added file 'plugins/launcher/CMakeLists.txt' |
27 | --- plugins/launcher/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
28 | +++ plugins/launcher/CMakeLists.txt 2016-11-21 14:26:16 +0000 |
29 | @@ -0,0 +1,20 @@ |
30 | +add_subdirectory(plugin) |
31 | + |
32 | +set(QML_SOURCES PageComponent.qml) |
33 | +set(PANEL_SOURCES |
34 | + launcher.h |
35 | + launcher_impl.cpp |
36 | + plugin.cpp |
37 | + plugin.h |
38 | + ${QML_SOURCES} |
39 | +) |
40 | + |
41 | +add_library(UbuntuLauncherPanel MODULE ${PANEL_SOURCES} ${QML_SOURCES}) |
42 | +qt5_use_modules(UbuntuLauncherPanel Qml Widgets) |
43 | + |
44 | +set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/Launcher) |
45 | +install(TARGETS UbuntuLauncherPanel DESTINATION ${PLUG_DIR}) |
46 | +install(FILES qmldir.in DESTINATION ${PLUG_DIR} RENAME qmldir) |
47 | + |
48 | +install(FILES launcher.settings DESTINATION ${PLUGIN_MANIFEST_DIR}) |
49 | +install(FILES ${QML_SOURCES} DESTINATION ${PLUGIN_QML_DIR}/launcher) |
50 | |
51 | === added file 'plugins/launcher/PageComponent.qml' |
52 | --- plugins/launcher/PageComponent.qml 1970-01-01 00:00:00 +0000 |
53 | +++ plugins/launcher/PageComponent.qml 2016-11-21 14:26:16 +0000 |
54 | @@ -0,0 +1,113 @@ |
55 | +/* |
56 | + * This file is part of system-settings |
57 | + * |
58 | + * Copyright (C) 2016 Canonical Ltd. |
59 | + * |
60 | + * This program is free software: you can redistribute it and/or modify it |
61 | + * under the terms of the GNU General Public License version 3, as published |
62 | + * by the Free Software Foundation. |
63 | + * |
64 | + * This program is distributed in the hope that it will be useful, but |
65 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
66 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
67 | + * PURPOSE. See the GNU General Public License for more details. |
68 | + * |
69 | + * You should have received a copy of the GNU General Public License along |
70 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
71 | + */ |
72 | + |
73 | +import GSettings 1.0 |
74 | +import QtQuick 2.4 |
75 | +import SystemSettings 1.0 |
76 | +import SystemSettings.ListItems 1.0 as SettingsListItems |
77 | +import Ubuntu.Components 1.3 |
78 | +import Ubuntu.Settings.Components 0.1 as USC |
79 | +import Ubuntu.Settings.Menus 0.1 as Menus |
80 | +import Ubuntu.SystemSettings.Launcher 1.0 |
81 | + |
82 | +ItemPage { |
83 | + id: root |
84 | + objectName: "launcherPage" |
85 | + title: i18n.tr("Launcher") |
86 | + |
87 | + /* The introductory label “On large displays:” should be present if the |
88 | + current display does not fall into <the large screen> category (to explain |
89 | + why the settings aren’t applying to the display that you’re looking at). */ |
90 | + property bool largeScreenAvailable: { |
91 | + var currentScreen = LauncherPanelPlugin.getCurrentScreenNumber(); |
92 | + for (var i=0; i < LauncherPanelPlugin.screens; i++) { |
93 | + if (LauncherPanelPlugin.screenGeometry(i).width > units.gu(90)) { |
94 | + if (currentScreen === i) { |
95 | + return false; |
96 | + } |
97 | + } |
98 | + } |
99 | + return true; // No large screens were the current one. |
100 | + } |
101 | + |
102 | + Flickable { |
103 | + id: flick |
104 | + anchors.fill: parent |
105 | + contentWidth: parent.width |
106 | + contentHeight: contentItem.childrenRect.height |
107 | + boundsBehavior: (contentHeight > root.height) ? |
108 | + Flickable.DragAndOvershootBounds : Flickable.StopAtBounds |
109 | + |
110 | + Column { |
111 | + anchors { |
112 | + left: parent.left |
113 | + right: parent.right |
114 | + } |
115 | + spacing: units.gu(1) |
116 | + |
117 | + SettingsItemTitle { |
118 | + text: i18n.tr("On large screens:") |
119 | + objectName: "largeScreenLabel" |
120 | + visible: largeScreenAvailable |
121 | + } |
122 | + |
123 | + SettingsListItems.Standard { |
124 | + id: alwaysShowLauncher |
125 | + objectName: "alwaysShowLauncher" |
126 | + text: i18n.tr("Always show the launcher") |
127 | + layout.subtitle.text: i18n.tr("Videos and full-screen games may hide it temporarily.") |
128 | + |
129 | + Switch { |
130 | + id: alwaysShowLauncherSwitch |
131 | + objectName: "alwaysShowLauncherSwitch" |
132 | + checked: !unity8Settings.autohideLauncher |
133 | + onTriggered: unity8Settings.autohideLauncher = !checked |
134 | + } |
135 | + } |
136 | + |
137 | + Menus.SliderMenu { |
138 | + text: i18n.tr("Icon size:") |
139 | + |
140 | + id: iconWidth |
141 | + objectName: "iconWidth" |
142 | + function formatValue(v) { return v.toFixed(2) } |
143 | + minimumValue: 6 |
144 | + maximumValue: 12 |
145 | + value: unity8Settings.launcherWidth |
146 | + live: true |
147 | + |
148 | + property real serverValue: unity8Settings.launcherWidth |
149 | + USC.ServerPropertySynchroniser { |
150 | + userTarget: iconWidth |
151 | + userProperty: "value" |
152 | + serverTarget: iconWidth |
153 | + serverProperty: "serverValue" |
154 | + maximumWaitBufferInterval: 16 |
155 | + |
156 | + onSyncTriggered: unity8Settings.launcherWidth = value |
157 | + } |
158 | + } |
159 | + } |
160 | + } |
161 | + |
162 | + GSettings { |
163 | + id: unity8Settings |
164 | + objectName: "unity8Settings" |
165 | + schema.id: "com.canonical.Unity8" |
166 | + } |
167 | +} |
168 | |
169 | === added file 'plugins/launcher/launcher.h' |
170 | --- plugins/launcher/launcher.h 1970-01-01 00:00:00 +0000 |
171 | +++ plugins/launcher/launcher.h 2016-11-21 14:26:16 +0000 |
172 | @@ -0,0 +1,42 @@ |
173 | +/* |
174 | + * This file is part of system-settings |
175 | + * |
176 | + * Copyright (C) 2016 Canonical Ltd. |
177 | + * |
178 | + * This program is free software: you can redistribute it and/or modify it |
179 | + * under the terms of the GNU General Public License version 3, as published |
180 | + * by the Free Software Foundation. |
181 | + * |
182 | + * This program is distributed in the hope that it will be useful, but |
183 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
184 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
185 | + * PURPOSE. See the GNU General Public License for more details. |
186 | + * |
187 | + * You should have received a copy of the GNU General Public License along |
188 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
189 | + */ |
190 | + |
191 | +#ifndef LAUNCHER_H |
192 | +#define LAUNCHER_H |
193 | + |
194 | +#include <QObject> |
195 | +#include <QRect> |
196 | + |
197 | +class LauncherPanelPlugin : public QObject |
198 | +{ |
199 | + Q_OBJECT |
200 | + Q_PROPERTY(int screens READ screens NOTIFY screensChanged) |
201 | +public: |
202 | + explicit LauncherPanelPlugin(QObject *parent = nullptr) |
203 | + : QObject(parent) {}; |
204 | + virtual ~LauncherPanelPlugin() {}; |
205 | + // Return index of screen at which USS is currently rendered. |
206 | + virtual int screens() const = 0; |
207 | +public slots: |
208 | + virtual QRect screenGeometry(const int &screen = -1) const = 0; |
209 | + virtual int getCurrentScreenNumber() const = 0; |
210 | +Q_SIGNALS: |
211 | + void screensChanged(int newCount); |
212 | +}; |
213 | + |
214 | +#endif // LAUNCHER_H |
215 | |
216 | === added file 'plugins/launcher/launcher.settings' |
217 | --- plugins/launcher/launcher.settings 1970-01-01 00:00:00 +0000 |
218 | +++ plugins/launcher/launcher.settings 2016-11-21 14:26:16 +0000 |
219 | @@ -0,0 +1,14 @@ |
220 | +{ |
221 | + "name": "Launcher", |
222 | + "icon": "preferences-desktop-launcher-symbolic", |
223 | + "plugin": "launcher-plugin", |
224 | + "translations": "ubuntu-system-settings", |
225 | + "category": "personal", |
226 | + "keywords": [ |
227 | + "launcher", |
228 | + "appearance" |
229 | + ], |
230 | + "page-component": "PageComponent.qml", |
231 | + "has-dynamic-keywords": false, |
232 | + "has-dynamic-visibility": true |
233 | +} |
234 | |
235 | === added file 'plugins/launcher/launcher_impl.cpp' |
236 | --- plugins/launcher/launcher_impl.cpp 1970-01-01 00:00:00 +0000 |
237 | +++ plugins/launcher/launcher_impl.cpp 2016-11-21 14:26:16 +0000 |
238 | @@ -0,0 +1,52 @@ |
239 | +/* |
240 | + * This file is part of system-settings |
241 | + * |
242 | + * Copyright (C) 2016 Canonical Ltd. |
243 | + * |
244 | + * This program is free software: you can redistribute it and/or modify it |
245 | + * under the terms of the GNU General Public License version 3, as published |
246 | + * by the Free Software Foundation. |
247 | + * |
248 | + * This program is distributed in the hope that it will be useful, but |
249 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
250 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
251 | + * PURPOSE. See the GNU General Public License for more details. |
252 | + * |
253 | + * You should have received a copy of the GNU General Public License along |
254 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
255 | + */ |
256 | + |
257 | +#include "launcher_impl.h" |
258 | + |
259 | +#include <QApplication> |
260 | +#include <QGuiApplication> |
261 | + |
262 | +LauncherPanelPluginImpl::LauncherPanelPluginImpl(QObject *parent) |
263 | + : LauncherPanelPlugin(parent) |
264 | +{ |
265 | + auto app = (QApplication*) QGuiApplication::instance(); |
266 | + m_desktopWidget = app->desktop(); |
267 | + connect(m_desktopWidget, SIGNAL(screenCountChanged(int)), |
268 | + this, SIGNAL(screensChanged(int))); |
269 | +} |
270 | + |
271 | +LauncherPanelPluginImpl::~LauncherPanelPluginImpl() |
272 | +{ |
273 | + disconnect(m_desktopWidget, SIGNAL(screenCountChanged(int)), |
274 | + this, SIGNAL(screensChanged(int))); |
275 | +} |
276 | + |
277 | +QRect LauncherPanelPluginImpl::screenGeometry(const int &screen) const |
278 | +{ |
279 | + return m_desktopWidget->screenGeometry(screen); |
280 | +} |
281 | + |
282 | +int LauncherPanelPluginImpl::getCurrentScreenNumber() const |
283 | +{ |
284 | + return m_desktopWidget->screenNumber(m_desktopWidget); |
285 | +} |
286 | + |
287 | +int LauncherPanelPluginImpl::screens() const |
288 | +{ |
289 | + return m_desktopWidget->screenCount(); |
290 | +} |
291 | |
292 | === added file 'plugins/launcher/launcher_impl.h' |
293 | --- plugins/launcher/launcher_impl.h 1970-01-01 00:00:00 +0000 |
294 | +++ plugins/launcher/launcher_impl.h 2016-11-21 14:26:16 +0000 |
295 | @@ -0,0 +1,40 @@ |
296 | +/* |
297 | + * This file is part of system-settings |
298 | + * |
299 | + * Copyright (C) 2016 Canonical Ltd. |
300 | + * |
301 | + * This program is free software: you can redistribute it and/or modify it |
302 | + * under the terms of the GNU General Public License version 3, as published |
303 | + * by the Free Software Foundation. |
304 | + * |
305 | + * This program is distributed in the hope that it will be useful, but |
306 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
307 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
308 | + * PURPOSE. See the GNU General Public License for more details. |
309 | + * |
310 | + * You should have received a copy of the GNU General Public License along |
311 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
312 | + */ |
313 | + |
314 | +#ifndef LAUNCHER_IMPL_H |
315 | +#define LAUNCHER_IMPL_H |
316 | + |
317 | +#include "launcher.h" |
318 | + |
319 | +#include <QDesktopWidget> |
320 | + |
321 | +class LauncherPanelPluginImpl : public LauncherPanelPlugin |
322 | +{ |
323 | + Q_OBJECT |
324 | +public: |
325 | + explicit LauncherPanelPluginImpl(QObject *parent = nullptr); |
326 | + ~LauncherPanelPluginImpl(); |
327 | + virtual int screens() const override; |
328 | +public slots: |
329 | + virtual QRect screenGeometry(const int &screen = -1) const override; |
330 | + virtual int getCurrentScreenNumber() const override; |
331 | +private: |
332 | + QDesktopWidget *m_desktopWidget = nullptr; |
333 | +}; |
334 | + |
335 | +#endif // LAUNCHER_IMPL_H |
336 | |
337 | === added directory 'plugins/launcher/plugin' |
338 | === added file 'plugins/launcher/plugin.cpp' |
339 | --- plugins/launcher/plugin.cpp 1970-01-01 00:00:00 +0000 |
340 | +++ plugins/launcher/plugin.cpp 2016-11-21 14:26:16 +0000 |
341 | @@ -0,0 +1,39 @@ |
342 | +/* |
343 | + * This file is part of system-settings |
344 | + * |
345 | + * Copyright (C) 2016 Canonical Ltd. |
346 | + * |
347 | + * This program is free software: you can redistribute it and/or modify it |
348 | + * under the terms of the GNU General Public License version 3, as published |
349 | + * by the Free Software Foundation. |
350 | + * |
351 | + * This program is distributed in the hope that it will be useful, but |
352 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
353 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
354 | + * PURPOSE. See the GNU General Public License for more details. |
355 | + * |
356 | + * You should have received a copy of the GNU General Public License along |
357 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
358 | + */ |
359 | + |
360 | +#include "plugin.h" |
361 | +#include "launcher_impl.h" |
362 | + |
363 | +#include <QtQml/QtQml> |
364 | + |
365 | +#define MAKE_SINGLETON_FACTORY(type) \ |
366 | + static QObject* type##_singleton_factory(QQmlEngine* engine, QJSEngine* scriptEngine) { \ |
367 | + Q_UNUSED(engine); \ |
368 | + Q_UNUSED(scriptEngine); \ |
369 | + return new type(); \ |
370 | + } |
371 | + |
372 | +MAKE_SINGLETON_FACTORY(LauncherPanelPluginImpl) |
373 | + |
374 | +void BackendPlugin::registerTypes(const char *uri) |
375 | +{ |
376 | + Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.Launcher")); |
377 | + qmlRegisterSingletonType<LauncherPanelPluginImpl>( |
378 | + uri, 1, 0, "LauncherPanelPlugin", LauncherPanelPluginImpl_singleton_factory |
379 | + ); |
380 | +} |
381 | |
382 | === added file 'plugins/launcher/plugin.h' |
383 | --- plugins/launcher/plugin.h 1970-01-01 00:00:00 +0000 |
384 | +++ plugins/launcher/plugin.h 2016-11-21 14:26:16 +0000 |
385 | @@ -0,0 +1,33 @@ |
386 | +/* |
387 | + * This file is part of system-settings |
388 | + * |
389 | + * Copyright (C) 2016 Canonical Ltd. |
390 | + * |
391 | + * This program is free software: you can redistribute it and/or modify it |
392 | + * under the terms of the GNU General Public License version 3, as published |
393 | + * by the Free Software Foundation. |
394 | + * |
395 | + * This program is distributed in the hope that it will be useful, but |
396 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
397 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
398 | + * PURPOSE. See the GNU General Public License for more details. |
399 | + * |
400 | + * You should have received a copy of the GNU General Public License along |
401 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
402 | + */ |
403 | + |
404 | +#ifndef LAUNCHER_PLUGIN_H |
405 | +#define LAUNCHER_PLUGIN_H |
406 | + |
407 | +#include <QtQml/QQmlEngine> |
408 | +#include <QtQml/QQmlExtensionPlugin> |
409 | + |
410 | +class BackendPlugin : public QQmlExtensionPlugin |
411 | +{ |
412 | + Q_OBJECT |
413 | + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") |
414 | + |
415 | +public: |
416 | + void registerTypes(const char *uri); |
417 | +}; |
418 | +#endif // LAUNCHER_PLUGIN_H |
419 | |
420 | === added file 'plugins/launcher/plugin/CMakeLists.txt' |
421 | --- plugins/launcher/plugin/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
422 | +++ plugins/launcher/plugin/CMakeLists.txt 2016-11-21 14:26:16 +0000 |
423 | @@ -0,0 +1,8 @@ |
424 | +include_directories(${CMAKE_CURRENT_BINARY_DIR} ../) |
425 | + |
426 | +add_definitions(-DLAUNCHER_PLUGIN_QML_DIR="${PLUGIN_QML_DIR}/launcher") |
427 | +add_library(launcher-plugin SHARED launcher-plugin.h launcher-plugin.cpp ../launcher.h ../launcher_impl.cpp) |
428 | +qt5_use_modules(launcher-plugin Core Qml Widgets) |
429 | +target_link_libraries(launcher-plugin SystemSettings) |
430 | +install(TARGETS launcher-plugin DESTINATION ${PLUGIN_MODULE_DIR}) |
431 | +install(FILES GuAccessor.qml DESTINATION ${PLUGIN_QML_DIR}/launcher) |
432 | |
433 | === added file 'plugins/launcher/plugin/GuAccessor.qml' |
434 | --- plugins/launcher/plugin/GuAccessor.qml 1970-01-01 00:00:00 +0000 |
435 | +++ plugins/launcher/plugin/GuAccessor.qml 2016-11-21 14:26:16 +0000 |
436 | @@ -0,0 +1,6 @@ |
437 | +import QtQml 2.2 |
438 | +import Ubuntu.Components 1.3 |
439 | + |
440 | +QtObject { |
441 | + property int largeScreenThreshold: units.gu(90) |
442 | +} |
443 | |
444 | === added file 'plugins/launcher/plugin/launcher-plugin.cpp' |
445 | --- plugins/launcher/plugin/launcher-plugin.cpp 1970-01-01 00:00:00 +0000 |
446 | +++ plugins/launcher/plugin/launcher-plugin.cpp 2016-11-21 14:26:16 +0000 |
447 | @@ -0,0 +1,86 @@ |
448 | +/* |
449 | + * This file is part of system-settings |
450 | + * |
451 | + * Copyright (C) 2016 Canonical Ltd. |
452 | + * |
453 | + * This program is free software: you can redistribute it and/or modify it |
454 | + * under the terms of the GNU General Public License version 3, as published |
455 | + * by the Free Software Foundation. |
456 | + * |
457 | + * This program is distributed in the hope that it will be useful, but |
458 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
459 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
460 | + * PURPOSE. See the GNU General Public License for more details. |
461 | + * |
462 | + * You should have received a copy of the GNU General Public License along |
463 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
464 | + * |
465 | + */ |
466 | + |
467 | +#include "launcher_impl.h" |
468 | +#include "launcher-plugin.h" |
469 | + |
470 | +#include <SystemSettings/ItemBase> |
471 | +#include <QObject> |
472 | +#include <QProcessEnvironment> |
473 | +#include <QQmlComponent> |
474 | +#include <QQmlEngine> |
475 | +#include <QScopedPointer> |
476 | +#include <QUrl> |
477 | + |
478 | +using namespace SystemSettings; |
479 | + |
480 | +class LauncherItem: public ItemBase |
481 | +{ |
482 | + Q_OBJECT |
483 | + |
484 | +public: |
485 | + explicit LauncherItem(const QVariantMap &staticData, QObject *parent = 0); |
486 | + void setVisibility(bool visible); |
487 | +}; |
488 | + |
489 | +LauncherItem::LauncherItem(const QVariantMap &staticData, QObject *parent): |
490 | + ItemBase(staticData, parent) |
491 | +{ |
492 | + // Unconditionally show if USS_SHOW_ALL_UI is set. |
493 | + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); |
494 | + if (env.contains(QLatin1String("USS_SHOW_ALL_UI"))) { |
495 | + QString showAllS = env.value("USS_SHOW_ALL_UI", QString()); |
496 | + |
497 | + if(!showAllS.isEmpty()) { |
498 | + setVisibility(true); |
499 | + return; |
500 | + } |
501 | + } |
502 | + |
503 | + // Show only if some screen is larger than the threshold. |
504 | + QQmlEngine engine; |
505 | + LauncherPanelPluginImpl panel; |
506 | + QString folder(env.value("SNAP", QString()) + LAUNCHER_PLUGIN_QML_DIR); |
507 | + QQmlComponent guAccessorComponent( |
508 | + &engine, QUrl::fromLocalFile(folder + "/GuAccessor.qml") |
509 | + ); |
510 | + QScopedPointer<QObject> guAccessor(guAccessorComponent.create()); |
511 | + int largeScreenThreshold = guAccessor->property("largeScreenThreshold").toInt(); |
512 | + for (int i = 0; i < panel.screens(); i++) { |
513 | + if (panel.screenGeometry(i).width() > largeScreenThreshold) { |
514 | + setVisibility(true); |
515 | + return; |
516 | + } |
517 | + } |
518 | + |
519 | + setVisibility(false); |
520 | +} |
521 | + |
522 | +void LauncherItem::setVisibility(bool visible) |
523 | +{ |
524 | + setVisible(visible); |
525 | +} |
526 | + |
527 | +ItemBase *LauncherPlugin::createItem(const QVariantMap &staticData, |
528 | + QObject *parent) |
529 | +{ |
530 | + return new LauncherItem(staticData, parent); |
531 | +} |
532 | + |
533 | +#include "launcher-plugin.moc" |
534 | |
535 | === added file 'plugins/launcher/plugin/launcher-plugin.h' |
536 | --- plugins/launcher/plugin/launcher-plugin.h 1970-01-01 00:00:00 +0000 |
537 | +++ plugins/launcher/plugin/launcher-plugin.h 2016-11-21 14:26:16 +0000 |
538 | @@ -0,0 +1,37 @@ |
539 | +/* |
540 | + * This file is part of system-settings |
541 | + * |
542 | + * Copyright (C) 2016 Canonical Ltd. |
543 | + * |
544 | + * This program is free software: you can redistribute it and/or modify it |
545 | + * under the terms of the GNU General Public License version 3, as published |
546 | + * by the Free Software Foundation. |
547 | + * |
548 | + * This program is distributed in the hope that it will be useful, but |
549 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
550 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
551 | + * PURPOSE. See the GNU General Public License for more details. |
552 | + * |
553 | + * You should have received a copy of the GNU General Public License along |
554 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
555 | + * |
556 | + */ |
557 | + |
558 | +#ifndef SYSTEM_SETTINGS_LAUNCHER_PLUGIN_H |
559 | +#define SYSTEM_SETTINGS_LAUNCHER_PLUGIN_H |
560 | + |
561 | +#include <QObject> |
562 | +#include <SystemSettings/PluginInterface> |
563 | + |
564 | +class LauncherPlugin: public QObject, public SystemSettings::PluginInterface2 |
565 | +{ |
566 | + Q_OBJECT |
567 | + Q_PLUGIN_METADATA(IID "com.ubuntu.SystemSettings.PluginInterface/2.0") |
568 | + Q_INTERFACES(SystemSettings::PluginInterface2) |
569 | + |
570 | +public: |
571 | + SystemSettings::ItemBase *createItem(const QVariantMap &staticData, |
572 | + QObject *parent = 0); |
573 | +}; |
574 | + |
575 | +#endif // SYSTEM_SETTINGS_LAUNCHER_PLUGIN_H |
576 | |
577 | === added file 'plugins/launcher/qmldir.in' |
578 | --- plugins/launcher/qmldir.in 1970-01-01 00:00:00 +0000 |
579 | +++ plugins/launcher/qmldir.in 2016-11-21 14:26:16 +0000 |
580 | @@ -0,0 +1,2 @@ |
581 | +module Ubuntu.SystemSettings.Launcher |
582 | +plugin UbuntuLauncherPanel |
583 | |
584 | === added file 'plugins/launcher/settings-launcher.svg' |
585 | --- plugins/launcher/settings-launcher.svg 1970-01-01 00:00:00 +0000 |
586 | +++ plugins/launcher/settings-launcher.svg 2016-11-21 14:26:16 +0000 |
587 | @@ -0,0 +1,179 @@ |
588 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
589 | +<!-- Created with Inkscape (http://www.inkscape.org/) --> |
590 | + |
591 | +<svg |
592 | + xmlns:dc="http://purl.org/dc/elements/1.1/" |
593 | + xmlns:cc="http://creativecommons.org/ns#" |
594 | + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
595 | + xmlns:svg="http://www.w3.org/2000/svg" |
596 | + xmlns="http://www.w3.org/2000/svg" |
597 | + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" |
598 | + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" |
599 | + width="96" |
600 | + height="96" |
601 | + id="svg4874" |
602 | + version="1.1" |
603 | + inkscape:version="0.91 r13725" |
604 | + viewBox="0 0 96 96.000001" |
605 | + sodipodi:docname="preferences-desktop-launcher-symbolic.svg"> |
606 | + <defs |
607 | + id="defs4876" /> |
608 | + <sodipodi:namedview |
609 | + id="base" |
610 | + pagecolor="#ffffff" |
611 | + bordercolor="#666666" |
612 | + borderopacity="1.0" |
613 | + inkscape:pageopacity="0.0" |
614 | + inkscape:pageshadow="2" |
615 | + inkscape:zoom="8.7812488" |
616 | + inkscape:cx="-27.450542" |
617 | + inkscape:cy="71.470458" |
618 | + inkscape:document-units="px" |
619 | + inkscape:current-layer="g4780" |
620 | + showgrid="true" |
621 | + showborder="true" |
622 | + fit-margin-top="0" |
623 | + fit-margin-left="0" |
624 | + fit-margin-right="0" |
625 | + fit-margin-bottom="0" |
626 | + inkscape:snap-bbox="true" |
627 | + inkscape:bbox-paths="true" |
628 | + inkscape:bbox-nodes="true" |
629 | + inkscape:snap-bbox-edge-midpoints="true" |
630 | + inkscape:snap-bbox-midpoints="true" |
631 | + inkscape:object-paths="true" |
632 | + inkscape:snap-intersection-paths="true" |
633 | + inkscape:object-nodes="true" |
634 | + inkscape:snap-smooth-nodes="true" |
635 | + inkscape:snap-midpoints="true" |
636 | + inkscape:snap-object-midpoints="true" |
637 | + inkscape:snap-center="true" |
638 | + showguides="true" |
639 | + inkscape:guide-bbox="true" |
640 | + inkscape:snap-global="true" |
641 | + inkscape:locked="false"> |
642 | + <inkscape:grid |
643 | + type="xygrid" |
644 | + id="grid5451" |
645 | + empspacing="8" /> |
646 | + <sodipodi:guide |
647 | + orientation="1,0" |
648 | + position="8,-8.0000001" |
649 | + id="guide4063" |
650 | + inkscape:locked="false" /> |
651 | + <sodipodi:guide |
652 | + orientation="1,0" |
653 | + position="4,-8.0000001" |
654 | + id="guide4065" |
655 | + inkscape:locked="false" /> |
656 | + <sodipodi:guide |
657 | + orientation="0,1" |
658 | + position="-8,88.000001" |
659 | + id="guide4067" |
660 | + inkscape:locked="false" /> |
661 | + <sodipodi:guide |
662 | + orientation="0,1" |
663 | + position="-8,92.000001" |
664 | + id="guide4069" |
665 | + inkscape:locked="false" /> |
666 | + <sodipodi:guide |
667 | + orientation="0,1" |
668 | + position="104,4" |
669 | + id="guide4071" |
670 | + inkscape:locked="false" /> |
671 | + <sodipodi:guide |
672 | + orientation="0,1" |
673 | + position="-5,8.0000001" |
674 | + id="guide4073" |
675 | + inkscape:locked="false" /> |
676 | + <sodipodi:guide |
677 | + orientation="1,0" |
678 | + position="88,-8.0000001" |
679 | + id="guide4077" |
680 | + inkscape:locked="false" /> |
681 | + <sodipodi:guide |
682 | + orientation="0,1" |
683 | + position="-8,84.000001" |
684 | + id="guide4074" |
685 | + inkscape:locked="false" /> |
686 | + <sodipodi:guide |
687 | + orientation="1,0" |
688 | + position="12,-8.0000001" |
689 | + id="guide4076" |
690 | + inkscape:locked="false" /> |
691 | + <sodipodi:guide |
692 | + orientation="1,0" |
693 | + position="84,-8.0000001" |
694 | + id="guide4080" |
695 | + inkscape:locked="false" /> |
696 | + <sodipodi:guide |
697 | + position="48,-8.0000001" |
698 | + orientation="1,0" |
699 | + id="guide4170" |
700 | + inkscape:locked="false" /> |
701 | + <sodipodi:guide |
702 | + position="-8,48" |
703 | + orientation="0,1" |
704 | + id="guide4172" |
705 | + inkscape:locked="false" /> |
706 | + <sodipodi:guide |
707 | + position="92,-8.0000001" |
708 | + orientation="1,0" |
709 | + id="guide4760" |
710 | + inkscape:locked="false" /> |
711 | + <sodipodi:guide |
712 | + position="115,12" |
713 | + orientation="0,1" |
714 | + id="guide4269" |
715 | + inkscape:locked="false" /> |
716 | + </sodipodi:namedview> |
717 | + <metadata |
718 | + id="metadata4879"> |
719 | + <rdf:RDF> |
720 | + <cc:Work |
721 | + rdf:about=""> |
722 | + <dc:format>image/svg+xml</dc:format> |
723 | + <dc:type |
724 | + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> |
725 | + <dc:title /> |
726 | + </cc:Work> |
727 | + </rdf:RDF> |
728 | + </metadata> |
729 | + <g |
730 | + inkscape:label="Layer 1" |
731 | + inkscape:groupmode="layer" |
732 | + id="layer1" |
733 | + transform="translate(67.857146,-78.50504)"> |
734 | + <g |
735 | + transform="matrix(0,-1,-1,0,373.50506,516.50504)" |
736 | + id="g4845" |
737 | + style="display:inline"> |
738 | + <g |
739 | + inkscape:export-ydpi="90" |
740 | + inkscape:export-xdpi="90" |
741 | + inkscape:export-filename="next01.png" |
742 | + transform="matrix(-0.9996045,0,0,1,575.94296,-611.00001)" |
743 | + id="g4778" |
744 | + inkscape:label="Layer 1"> |
745 | + <g |
746 | + transform="matrix(-1,0,0,1,575.99999,611)" |
747 | + id="g4780" |
748 | + style="display:inline"> |
749 | + <rect |
750 | + style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:none;stroke:none;stroke-width:4;marker:none;enable-background:accumulate" |
751 | + id="rect4782" |
752 | + width="96.037987" |
753 | + height="96" |
754 | + x="-438.00244" |
755 | + y="345.36221" |
756 | + transform="scale(-1,1)" /> |
757 | + <path |
758 | + style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:4.00079155;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" |
759 | + d="M 15.976562 14 C 10.943804 14.058177 7.26124 13.881536 4.25 15.542969 C 2.74438 16.37368 1.5531413 17.776754 0.89453125 19.53125 C 0.23593125 21.285746 -0.001953125 23.369641 -0.001953125 26 L -0.001953125 70 C -0.001953125 72.630359 0.23593125 74.714254 0.89453125 76.46875 C 1.5531413 78.223246 2.74438 79.62632 4.25 80.457031 C 7.26124 82.118454 10.943804 81.941823 15.976562 82 L 15.988281 82 L 80.009766 82 L 80.021484 82 C 85.054244 81.941813 88.736807 82.118454 91.748047 80.457031 C 93.253667 79.62632 94.444916 78.223246 95.103516 76.46875 C 95.762116 74.714254 96 72.630359 96 70 L 96 26 C 96 23.369641 95.762116 21.285746 95.103516 19.53125 C 94.444916 17.776754 93.253667 16.37368 91.748047 15.542969 C 88.736807 13.881536 85.054244 14.058177 80.021484 14 L 80.009766 14 L 15.988281 14 L 15.976562 14 z M 20 18 L 79.998047 18 C 85.036307 18.058767 88.350163 18.235058 89.814453 19.042969 C 90.547973 19.447679 90.967112 19.897711 91.357422 20.9375 C 91.747742 21.977279 91.998047 23.630358 91.998047 26 L 91.998047 70 C 91.998047 72.369642 91.747742 74.022721 91.357422 75.0625 C 90.967112 76.102289 90.547973 76.552311 89.814453 76.957031 C 88.350163 77.764942 85.036307 77.941223 79.998047 78 L 79.974609 78 L 20 78 L 20 18 z M 9.0019531 22 L 10.998047 22 C 15.000037 22 16 23.000013 16 27 C 16 30.999987 15.000037 32 10.998047 32 L 9.0019531 32 C 4.9999631 32 4.00001 30.999987 4 27 C 3.99999 23.000013 4.9999631 22 9.0019531 22 z M 9.0019531 36 L 10.998047 36 C 15.000037 36 16 36.999983 16 41 C 16 45.000017 15.000037 46 10.998047 46 L 9.0019531 46 C 4.9999631 46 4.00001 45.000017 4 41 C 3.99999 36.999983 4.9999631 36 9.0019531 36 z M 9.0019531 50 L 10.998047 50 C 15.000037 50 16 50.999983 16 55 C 16 59.000017 15.000037 60 10.998047 60 L 9.0019531 60 C 4.9999631 60 4.00001 59.000017 4 55 C 3.99999 50.999983 4.9999631 50 9.0019531 50 z M 9.0019531 64 L 10.998047 64 C 15.000037 64 16 64.999983 16 69 C 16 73.000017 15.000037 74 10.998047 74 L 9.0019531 74 C 4.9999631 74 4.00001 73.000017 4 69 C 3.99999 64.999983 4.9999631 64 9.0019531 64 z " |
760 | + transform="matrix(0,-1,-1.0003957,0,438.00245,441.36222)" |
761 | + id="path4297" /> |
762 | + </g> |
763 | + </g> |
764 | + </g> |
765 | + </g> |
766 | +</svg> |
767 | |
768 | === modified file 'src/CMakeLists.txt' |
769 | --- src/CMakeLists.txt 2016-09-22 14:21:55 +0000 |
770 | +++ src/CMakeLists.txt 2016-11-21 14:26:16 +0000 |
771 | @@ -35,7 +35,7 @@ |
772 | QT5_ADD_RESOURCES(system-settings-resources ui.qrc) |
773 | |
774 | add_executable(system-settings ${USS_SOURCES} ${QML_SOURCES} ${system-settings-resources}) |
775 | -qt5_use_modules(system-settings Core Gui Quick Qml DBus) |
776 | +qt5_use_modules(system-settings Core Gui Quick Qml DBus Widgets) |
777 | target_link_libraries(system-settings SystemSettings ${GLIB_LDFLAGS}) |
778 | install(TARGETS system-settings RUNTIME DESTINATION bin) |
779 | |
780 | |
781 | === modified file 'src/main.cpp' |
782 | --- src/main.cpp 2016-09-23 13:07:28 +0000 |
783 | +++ src/main.cpp 2016-11-21 14:26:16 +0000 |
784 | @@ -24,7 +24,7 @@ |
785 | #include "utils.h" |
786 | |
787 | #include <QByteArray> |
788 | -#include <QGuiApplication> |
789 | +#include <QApplication> |
790 | #include <QProcessEnvironment> |
791 | #include <QQmlContext> |
792 | #include <QUrl> |
793 | @@ -38,30 +38,9 @@ |
794 | |
795 | int main(int argc, char **argv) |
796 | { |
797 | - QGuiApplication app(argc, argv); |
798 | + QApplication app(argc, argv); |
799 | QByteArray mountPoint = qEnvironmentVariableIsSet("SNAP") ? qgetenv("SNAP") : ""; |
800 | |
801 | - /* The testability driver is only loaded by QApplication but not by |
802 | - * QGuiApplication. However, QApplication depends on QWidget which would |
803 | - * add some unneeded overhead => Let's load the testability driver on our |
804 | - * own. |
805 | - */ |
806 | - if (app.arguments().contains(QStringLiteral("-testability"))) { |
807 | - QLibrary testLib(QStringLiteral("qttestability")); |
808 | - if (testLib.load()) { |
809 | - typedef void (*TasInitialize)(void); |
810 | - TasInitialize initFunction = |
811 | - (TasInitialize)testLib.resolve("qt_testability_init"); |
812 | - if (initFunction) { |
813 | - initFunction(); |
814 | - } else { |
815 | - qCritical("Library qttestability resolve failed!"); |
816 | - } |
817 | - } else { |
818 | - qCritical("Library qttestability load failed!"); |
819 | - } |
820 | - } |
821 | - |
822 | /* read environment variables */ |
823 | QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); |
824 | if (environment.contains(QLatin1String("SS_LOGGING_LEVEL"))) { |
825 | |
826 | === modified file 'tests/mocks/CMakeLists.txt' |
827 | --- tests/mocks/CMakeLists.txt 2016-07-25 13:54:08 +0000 |
828 | +++ tests/mocks/CMakeLists.txt 2016-11-21 14:26:16 +0000 |
829 | @@ -31,5 +31,6 @@ |
830 | ) |
831 | endmacro() |
832 | |
833 | +add_subdirectory(GSettings.1.0) |
834 | add_subdirectory(QMenuModel) |
835 | add_subdirectory(Ubuntu) |
836 | |
837 | === added directory 'tests/mocks/GSettings.1.0' |
838 | === added file 'tests/mocks/GSettings.1.0/CMakeLists.txt' |
839 | --- tests/mocks/GSettings.1.0/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
840 | +++ tests/mocks/GSettings.1.0/CMakeLists.txt 2016-11-21 14:26:16 +0000 |
841 | @@ -0,0 +1,19 @@ |
842 | +include_directories( |
843 | + ${CMAKE_CURRENT_BINARY_DIR} |
844 | + ${Qt5Core_INCLUDE_DIRS} |
845 | + ${Qt5Quick_INCLUDE_DIRS} |
846 | +) |
847 | + |
848 | +set(GSettingsQML_SOURCES |
849 | + fake_gsettings.cpp |
850 | + plugin.cpp |
851 | +) |
852 | + |
853 | +add_library(FakeGSettingsQml MODULE ${GSettingsQML_SOURCES}) |
854 | +target_link_libraries(FakeGSettingsQml |
855 | + ${Qt5Core_LIBRARIES} |
856 | + ${Qt5Quick_LIBRARIES} |
857 | +) |
858 | + |
859 | +qt5_use_modules(FakeGSettingsQml Qml) |
860 | +add_uss_mock(GSettings 1.0 GSettings.1.0 TARGETS FakeGSettingsQml) |
861 | |
862 | === added file 'tests/mocks/GSettings.1.0/fake_gsettings.cpp' |
863 | --- tests/mocks/GSettings.1.0/fake_gsettings.cpp 1970-01-01 00:00:00 +0000 |
864 | +++ tests/mocks/GSettings.1.0/fake_gsettings.cpp 2016-11-21 14:26:16 +0000 |
865 | @@ -0,0 +1,193 @@ |
866 | +/* |
867 | + * This file is part of system-settings |
868 | + * |
869 | + * Copyright (C) 2016 Canonical Ltd. |
870 | + * |
871 | + * This program is free software: you can redistribute it and/or modify it |
872 | + * under the terms of the GNU General Public License version 3, as published |
873 | + * by the Free Software Foundation. |
874 | + * |
875 | + * This program is distributed in the hope that it will be useful, but |
876 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
877 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
878 | + * PURPOSE. See the GNU General Public License for more details. |
879 | + * |
880 | + * You should have received a copy of the GNU General Public License along |
881 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
882 | + */ |
883 | + |
884 | +#include "fake_gsettings.h" |
885 | + |
886 | +#include <QDebug> |
887 | +#include <QList> |
888 | + |
889 | +GSettingsControllerQml* GSettingsControllerQml::s_controllerInstance = 0; |
890 | + |
891 | +GSettingsControllerQml::GSettingsControllerQml() |
892 | + : m_autoBrightness(false) |
893 | +{ |
894 | +} |
895 | + |
896 | +GSettingsControllerQml::~GSettingsControllerQml() { |
897 | + s_controllerInstance = 0; |
898 | +} |
899 | + |
900 | +GSettingsControllerQml* GSettingsControllerQml::instance() { |
901 | + if (!s_controllerInstance) { |
902 | + s_controllerInstance = new GSettingsControllerQml(); |
903 | + } |
904 | + return s_controllerInstance; |
905 | +} |
906 | + |
907 | +bool GSettingsControllerQml::autoBrightness() const |
908 | +{ |
909 | + return m_autoBrightness; |
910 | +} |
911 | + |
912 | +void GSettingsControllerQml::setAutoBrightness(bool val) |
913 | +{ |
914 | + if (val != m_autoBrightness) { |
915 | + m_autoBrightness = val; |
916 | + Q_EMIT autoBrightnessChanged(); |
917 | + } |
918 | +} |
919 | + |
920 | +uint GSettingsControllerQml::launcherWidth() const |
921 | +{ |
922 | + return m_launcherWidth; |
923 | +} |
924 | + |
925 | +bool GSettingsControllerQml::autohideLauncher() const |
926 | +{ |
927 | + return m_autohideLauncher; |
928 | +} |
929 | + |
930 | +void GSettingsControllerQml::setLauncherWidth(uint val) |
931 | +{ |
932 | + if (val != m_launcherWidth) { |
933 | + m_launcherWidth = val; |
934 | + Q_EMIT launcherWidthChanged(); |
935 | + } |
936 | +} |
937 | + |
938 | +void GSettingsControllerQml::setAutohideLauncher(bool val) |
939 | +{ |
940 | + if (val != m_autohideLauncher) { |
941 | + m_autohideLauncher = val; |
942 | + Q_EMIT autohideLauncherChanged(); |
943 | + } |
944 | +} |
945 | + |
946 | +GSettingsSchemaQml::GSettingsSchemaQml(QObject *parent): QObject(parent) { |
947 | +} |
948 | + |
949 | +QByteArray GSettingsSchemaQml::id() const { |
950 | + return m_id; |
951 | +} |
952 | + |
953 | +void GSettingsSchemaQml::setId(const QByteArray &id) { |
954 | + if (!m_id.isEmpty()) { |
955 | + qWarning("GSettings.schema.id may only be set on construction"); |
956 | + return; |
957 | + } |
958 | + |
959 | + m_id = id; |
960 | +} |
961 | + |
962 | +QByteArray GSettingsSchemaQml::path() const { |
963 | + return m_path; |
964 | +} |
965 | + |
966 | +void GSettingsSchemaQml::setPath(const QByteArray &path) { |
967 | + if (!m_path.isEmpty()) { |
968 | + qWarning("GSettings.schema.path may only be set on construction"); |
969 | + return; |
970 | + } |
971 | + |
972 | + m_path = path; |
973 | +} |
974 | + |
975 | +GSettingsQml::GSettingsQml(QObject *parent) |
976 | + : QObject(parent), |
977 | + m_valid(false) |
978 | +{ |
979 | + m_schema = new GSettingsSchemaQml(this); |
980 | +} |
981 | + |
982 | +void GSettingsQml::classBegin() |
983 | +{ |
984 | +} |
985 | + |
986 | +void GSettingsQml::componentComplete() |
987 | +{ |
988 | + // Emulate what the real GSettings module does, and only return undefined |
989 | + // values until we are completed loading. |
990 | + m_valid = true; |
991 | + |
992 | + // FIXME: We should make this dynamic, instead of hard-coding all possible |
993 | + // properties in one object. We should create properties based on the schema. |
994 | + connect(GSettingsControllerQml::instance(), &GSettingsControllerQml::autoBrightnessChanged, |
995 | + this, &GSettingsQml::autoBrightnessChanged); |
996 | + connect(GSettingsControllerQml::instance(), &GSettingsControllerQml::autohideLauncherChanged, |
997 | + this, &GSettingsQml::autohideLauncherChanged); |
998 | + connect(GSettingsControllerQml::instance(), &GSettingsControllerQml::launcherWidthChanged, |
999 | + this, &GSettingsQml::launcherWidthChanged); |
1000 | + |
1001 | + Q_EMIT autoBrightnessChanged(); |
1002 | + Q_EMIT autohideLauncherChanged(); |
1003 | + Q_EMIT launcherWidthChanged(); |
1004 | +} |
1005 | + |
1006 | +GSettingsSchemaQml * GSettingsQml::schema() const { |
1007 | + return m_schema; |
1008 | +} |
1009 | + |
1010 | +QVariant GSettingsQml::autoBrightness() const |
1011 | +{ |
1012 | + if (m_valid && m_schema->id() == "com.ubuntu.touch.system") { |
1013 | + return GSettingsControllerQml::instance()->autoBrightness(); |
1014 | + } else { |
1015 | + return QVariant(); |
1016 | + } |
1017 | +} |
1018 | + |
1019 | +void GSettingsQml::setAutoBrightness(const QVariant &val) |
1020 | +{ |
1021 | + if (m_valid && m_schema->id() == "com.ubuntu.touch.system") { |
1022 | + GSettingsControllerQml::instance()->setAutoBrightness(val.toBool()); |
1023 | + } |
1024 | +} |
1025 | + |
1026 | + |
1027 | +QVariant GSettingsQml::launcherWidth() const |
1028 | +{ |
1029 | + if (m_valid && m_schema->id() == "com.canonical.Unity8") { |
1030 | + return GSettingsControllerQml::instance()->launcherWidth(); |
1031 | + } else { |
1032 | + return QVariant(); |
1033 | + } |
1034 | +} |
1035 | + |
1036 | +QVariant GSettingsQml::autohideLauncher() const |
1037 | +{ |
1038 | + if (m_valid && m_schema->id() == "com.canonical.Unity8") { |
1039 | + return GSettingsControllerQml::instance()->autohideLauncher(); |
1040 | + } else { |
1041 | + return QVariant(); |
1042 | + } |
1043 | +} |
1044 | + |
1045 | + |
1046 | +void GSettingsQml::setLauncherWidth(const QVariant &val) |
1047 | +{ |
1048 | + if (m_valid && m_schema->id() == "com.canonical.Unity8") { |
1049 | + GSettingsControllerQml::instance()->setLauncherWidth(val.toUInt()); |
1050 | + } |
1051 | +} |
1052 | + |
1053 | +void GSettingsQml::setAutohideLauncher(const QVariant &val) |
1054 | +{ |
1055 | + if (m_valid && m_schema->id() == "com.canonical.Unity8") { |
1056 | + GSettingsControllerQml::instance()->setAutohideLauncher(val.toBool()); |
1057 | + } |
1058 | +} |
1059 | |
1060 | === added file 'tests/mocks/GSettings.1.0/fake_gsettings.h' |
1061 | --- tests/mocks/GSettings.1.0/fake_gsettings.h 1970-01-01 00:00:00 +0000 |
1062 | +++ tests/mocks/GSettings.1.0/fake_gsettings.h 2016-11-21 14:26:16 +0000 |
1063 | @@ -0,0 +1,118 @@ |
1064 | +/* |
1065 | + * This file is part of system-settings |
1066 | + * |
1067 | + * Copyright (C) 2016 Canonical Ltd. |
1068 | + * |
1069 | + * This program is free software: you can redistribute it and/or modify it |
1070 | + * under the terms of the GNU General Public License version 3, as published |
1071 | + * by the Free Software Foundation. |
1072 | + * |
1073 | + * This program is distributed in the hope that it will be useful, but |
1074 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
1075 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1076 | + * PURPOSE. See the GNU General Public License for more details. |
1077 | + * |
1078 | + * You should have received a copy of the GNU General Public License along |
1079 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
1080 | + */ |
1081 | + |
1082 | +#ifndef FAKE_GSETTINGS_H |
1083 | +#define FAKE_GSETTINGS_H |
1084 | + |
1085 | +#include <QList> |
1086 | +#include <QObject> |
1087 | +#include <QQmlParserStatus> |
1088 | +#include <QStringList> |
1089 | +#include <QVariant> |
1090 | + |
1091 | +class GSettingsSchemaQml: public QObject |
1092 | +{ |
1093 | + Q_OBJECT |
1094 | + |
1095 | + Q_PROPERTY(QByteArray id READ id WRITE setId) |
1096 | + |
1097 | +public: |
1098 | + GSettingsSchemaQml(QObject *parent = nullptr); |
1099 | + |
1100 | + QByteArray id() const; |
1101 | + void setId(const QByteArray &id); |
1102 | + |
1103 | + QByteArray path() const; |
1104 | + void setPath(const QByteArray &path); |
1105 | + |
1106 | +private: |
1107 | + QByteArray m_id; |
1108 | + QByteArray m_path; |
1109 | +}; |
1110 | + |
1111 | +class GSettingsQml: public QObject, public QQmlParserStatus |
1112 | +{ |
1113 | + Q_OBJECT |
1114 | + Q_INTERFACES(QQmlParserStatus) |
1115 | + |
1116 | + Q_PROPERTY(GSettingsSchemaQml* schema READ schema NOTIFY schemaChanged) |
1117 | + Q_PROPERTY(QVariant autoBrightness READ autoBrightness WRITE setAutoBrightness NOTIFY autoBrightnessChanged) |
1118 | + Q_PROPERTY(QVariant launcherWidth READ launcherWidth WRITE setLauncherWidth NOTIFY launcherWidthChanged) |
1119 | + Q_PROPERTY(QVariant autohideLauncher READ autohideLauncher WRITE setAutohideLauncher NOTIFY autohideLauncherChanged) |
1120 | + |
1121 | +public: |
1122 | + GSettingsQml(QObject *parent = nullptr); |
1123 | + |
1124 | + void classBegin() override; |
1125 | + void componentComplete() override; |
1126 | + |
1127 | + GSettingsSchemaQml * schema() const; |
1128 | + QVariant autoBrightness() const; |
1129 | + QVariant launcherWidth() const; |
1130 | + QVariant autohideLauncher() const; |
1131 | + |
1132 | + void setAutoBrightness(const QVariant &val); |
1133 | + void setLauncherWidth(const QVariant &val); |
1134 | + void setAutohideLauncher(const QVariant &val); |
1135 | + |
1136 | +Q_SIGNALS: |
1137 | + void autoBrightnessChanged(); |
1138 | + void launcherWidthChanged(); |
1139 | + void autohideLauncherChanged(); |
1140 | + void schemaChanged(); |
1141 | + |
1142 | +private: |
1143 | + GSettingsSchemaQml* m_schema; |
1144 | + bool m_valid; |
1145 | + |
1146 | + friend class GSettingsSchemaQml; |
1147 | +}; |
1148 | + |
1149 | +class GSettingsControllerQml: public QObject |
1150 | +{ |
1151 | + Q_OBJECT |
1152 | + |
1153 | +public: |
1154 | + static GSettingsControllerQml* instance(); |
1155 | + ~GSettingsControllerQml(); |
1156 | + |
1157 | + bool autoBrightness() const; |
1158 | + uint launcherWidth() const; |
1159 | + bool autohideLauncher() const; |
1160 | + |
1161 | + Q_INVOKABLE void setAutoBrightness(bool val); |
1162 | + Q_INVOKABLE void setLauncherWidth(uint val); |
1163 | + Q_INVOKABLE void setAutohideLauncher(bool val); |
1164 | + |
1165 | +Q_SIGNALS: |
1166 | + void autoBrightnessChanged(); |
1167 | + void launcherWidthChanged(); |
1168 | + void autohideLauncherChanged(); |
1169 | + |
1170 | +private: |
1171 | + GSettingsControllerQml(); |
1172 | + |
1173 | + bool m_autoBrightness; |
1174 | + uint m_launcherWidth = 8; |
1175 | + bool m_autohideLauncher = true; |
1176 | + |
1177 | + static GSettingsControllerQml* s_controllerInstance; |
1178 | + QList<GSettingsQml *> m_registeredGSettings; |
1179 | +}; |
1180 | + |
1181 | +#endif // FAKE_GSETTINGS_H |
1182 | |
1183 | === added file 'tests/mocks/GSettings.1.0/plugin.cpp' |
1184 | --- tests/mocks/GSettings.1.0/plugin.cpp 1970-01-01 00:00:00 +0000 |
1185 | +++ tests/mocks/GSettings.1.0/plugin.cpp 2016-11-21 14:26:16 +0000 |
1186 | @@ -0,0 +1,35 @@ |
1187 | +/* |
1188 | + * This file is part of system-settings |
1189 | + * |
1190 | + * Copyright (C) 2016 Canonical Ltd. |
1191 | + * |
1192 | + * This program is free software: you can redistribute it and/or modify it |
1193 | + * under the terms of the GNU General Public License version 3, as published |
1194 | + * by the Free Software Foundation. |
1195 | + * |
1196 | + * This program is distributed in the hope that it will be useful, but |
1197 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
1198 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1199 | + * PURPOSE. See the GNU General Public License for more details. |
1200 | + * |
1201 | + * You should have received a copy of the GNU General Public License along |
1202 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
1203 | + */ |
1204 | + |
1205 | +#include "plugin.h" |
1206 | +#include "fake_gsettings.h" |
1207 | + |
1208 | +#include <QtQml/qqml.h> |
1209 | + |
1210 | +static QObject* controllerProvider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */) |
1211 | +{ |
1212 | + return GSettingsControllerQml::instance(); |
1213 | +} |
1214 | + |
1215 | +void FakeGSettingsQmlPlugin::registerTypes(const char *uri) |
1216 | +{ |
1217 | + qmlRegisterSingletonType<GSettingsControllerQml>(uri, 1, 0, "GSettingsController", controllerProvider); |
1218 | + qmlRegisterType<GSettingsQml>(uri, 1, 0, "GSettings"); |
1219 | + qmlRegisterUncreatableType<GSettingsSchemaQml>(uri, 1, 0, "GSettingsSchema", |
1220 | + "GSettingsSchema can only be used inside of a GSettings component"); |
1221 | +} |
1222 | |
1223 | === added file 'tests/mocks/GSettings.1.0/plugin.h' |
1224 | --- tests/mocks/GSettings.1.0/plugin.h 1970-01-01 00:00:00 +0000 |
1225 | +++ tests/mocks/GSettings.1.0/plugin.h 2016-11-21 14:26:16 +0000 |
1226 | @@ -0,0 +1,33 @@ |
1227 | +/* |
1228 | + * This file is part of system-settings |
1229 | + * |
1230 | + * Copyright (C) 2016 Canonical Ltd. |
1231 | + * |
1232 | + * This program is free software: you can redistribute it and/or modify it |
1233 | + * under the terms of the GNU General Public License version 3, as published |
1234 | + * by the Free Software Foundation. |
1235 | + * |
1236 | + * This program is distributed in the hope that it will be useful, but |
1237 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
1238 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1239 | + * PURPOSE. See the GNU General Public License for more details. |
1240 | + * |
1241 | + * You should have received a copy of the GNU General Public License along |
1242 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
1243 | + */ |
1244 | + |
1245 | +#ifndef FAKE_GSETTINGS_PLUGIN_H |
1246 | +#define FAKE_GSETTINGS_PLUGIN_H |
1247 | + |
1248 | +#include <QtQml/QQmlExtensionPlugin> |
1249 | + |
1250 | +class FakeGSettingsQmlPlugin : public QQmlExtensionPlugin |
1251 | +{ |
1252 | + Q_OBJECT |
1253 | + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") |
1254 | + |
1255 | +public: |
1256 | + void registerTypes(const char *uri) override; |
1257 | +}; |
1258 | + |
1259 | +#endif // FAKE_GSETTINGS_PLUGIN_H |
1260 | |
1261 | === added file 'tests/mocks/GSettings.1.0/qmldir' |
1262 | --- tests/mocks/GSettings.1.0/qmldir 1970-01-01 00:00:00 +0000 |
1263 | +++ tests/mocks/GSettings.1.0/qmldir 2016-11-21 14:26:16 +0000 |
1264 | @@ -0,0 +1,2 @@ |
1265 | +module GSettings |
1266 | +plugin FakeGSettingsQml |
1267 | |
1268 | === modified file 'tests/mocks/Ubuntu/SystemSettings/CMakeLists.txt' |
1269 | --- tests/mocks/Ubuntu/SystemSettings/CMakeLists.txt 2016-08-19 12:30:40 +0000 |
1270 | +++ tests/mocks/Ubuntu/SystemSettings/CMakeLists.txt 2016-11-21 14:26:16 +0000 |
1271 | @@ -1,3 +1,4 @@ |
1272 | +add_subdirectory(Launcher) |
1273 | add_subdirectory(Notifications) |
1274 | add_subdirectory(Update) |
1275 | add_subdirectory(Wifi) |
1276 | |
1277 | === added directory 'tests/mocks/Ubuntu/SystemSettings/Launcher' |
1278 | === added file 'tests/mocks/Ubuntu/SystemSettings/Launcher/CMakeLists.txt' |
1279 | --- tests/mocks/Ubuntu/SystemSettings/Launcher/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1280 | +++ tests/mocks/Ubuntu/SystemSettings/Launcher/CMakeLists.txt 2016-11-21 14:26:16 +0000 |
1281 | @@ -0,0 +1,20 @@ |
1282 | +find_package(Qt5Qml REQUIRED) |
1283 | + |
1284 | +include_directories( |
1285 | + ${CMAKE_CURRENT_BINARY_DIR} |
1286 | + ${CMAKE_SOURCE_DIR}/plugins/launcher |
1287 | + ${Qt5Qml_INCLUDE_DIRS} |
1288 | +) |
1289 | + |
1290 | +set(MOCK_LAUNCHER_SRCS |
1291 | + ${CMAKE_SOURCE_DIR}/plugins/launcher/launcher.h |
1292 | + MockLauncherPanelPlugin.cpp |
1293 | + plugin.cpp |
1294 | +) |
1295 | + |
1296 | +add_library(MockLauncherPanelPlugin SHARED ${MOCK_LAUNCHER_SRCS}) |
1297 | + |
1298 | +target_link_libraries(MockLauncherPanelPlugin Qt5::Qml) |
1299 | + |
1300 | +add_uss_mock(Ubuntu.SystemSettings.Launcher 1.0 Ubuntu/SystemSettings/Launcher |
1301 | + TARGETS MockLauncherPanelPlugin) |
1302 | |
1303 | === added file 'tests/mocks/Ubuntu/SystemSettings/Launcher/MockLauncherPanelPlugin.cpp' |
1304 | --- tests/mocks/Ubuntu/SystemSettings/Launcher/MockLauncherPanelPlugin.cpp 1970-01-01 00:00:00 +0000 |
1305 | +++ tests/mocks/Ubuntu/SystemSettings/Launcher/MockLauncherPanelPlugin.cpp 2016-11-21 14:26:16 +0000 |
1306 | @@ -0,0 +1,57 @@ |
1307 | +/* |
1308 | + * This file is part of system-settings |
1309 | + * |
1310 | + * Copyright (C) 2016 Canonical Ltd. |
1311 | + * |
1312 | + * This program is free software: you can redistribute it and/or modify it |
1313 | + * under the terms of the GNU General Public License version 3, as published |
1314 | + * by the Free Software Foundation. |
1315 | + * |
1316 | + * This program is distributed in the hope that it will be useful, but |
1317 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
1318 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1319 | + * PURPOSE. See the GNU General Public License for more details. |
1320 | + * |
1321 | + * You should have received a copy of the GNU General Public License along |
1322 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
1323 | + */ |
1324 | + |
1325 | +#include "MockLauncherPanelPlugin.h" |
1326 | + |
1327 | +#include <QDebug> |
1328 | + |
1329 | +QRect MockLauncherPanelPlugin::screenGeometry(const int &screen) const |
1330 | +{ |
1331 | + return m_geometries.value(screen); |
1332 | +} |
1333 | + |
1334 | +int MockLauncherPanelPlugin::getCurrentScreenNumber() const |
1335 | +{ |
1336 | + return m_currentScreenNumber; |
1337 | +} |
1338 | + |
1339 | +int MockLauncherPanelPlugin::screens() const |
1340 | +{ |
1341 | + return m_screens; |
1342 | +} |
1343 | + |
1344 | +void MockLauncherPanelPlugin::setScreens(const int &screens) |
1345 | +{ |
1346 | + m_screens = screens; |
1347 | + Q_EMIT screensChanged(m_screens); |
1348 | +} |
1349 | + |
1350 | +void MockLauncherPanelPlugin::setCurrentScreenNumber(const int ¤tScreenNumber) |
1351 | +{ |
1352 | + m_currentScreenNumber = currentScreenNumber; |
1353 | +} |
1354 | + |
1355 | +void MockLauncherPanelPlugin::setScreenGeometry( |
1356 | + const int &screen, const int &x, const int &y, const int &width, |
1357 | + const int &height) |
1358 | + |
1359 | +{ |
1360 | + QRect rect(x, y, width, height); |
1361 | + m_geometries.insert(screen, rect); |
1362 | + Q_EMIT screensChanged(m_screens); |
1363 | +} |
1364 | |
1365 | === added file 'tests/mocks/Ubuntu/SystemSettings/Launcher/MockLauncherPanelPlugin.h' |
1366 | --- tests/mocks/Ubuntu/SystemSettings/Launcher/MockLauncherPanelPlugin.h 1970-01-01 00:00:00 +0000 |
1367 | +++ tests/mocks/Ubuntu/SystemSettings/Launcher/MockLauncherPanelPlugin.h 2016-11-21 14:26:16 +0000 |
1368 | @@ -0,0 +1,49 @@ |
1369 | +/* |
1370 | + * This file is part of system-settings |
1371 | + * |
1372 | + * Copyright (C) 2016 Canonical Ltd. |
1373 | + * |
1374 | + * This program is free software: you can redistribute it and/or modify it |
1375 | + * under the terms of the GNU General Public License version 3, as published |
1376 | + * by the Free Software Foundation. |
1377 | + * |
1378 | + * This program is distributed in the hope that it will be useful, but |
1379 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
1380 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1381 | + * PURPOSE. See the GNU General Public License for more details. |
1382 | + * |
1383 | + * You should have received a copy of the GNU General Public License along |
1384 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
1385 | + */ |
1386 | + |
1387 | +#ifndef MOCK_LAUNCHER_PANEL_PLUGIN_H |
1388 | +#define MOCK_LAUNCHER_PANEL_PLUGIN_H |
1389 | + |
1390 | +#include "launcher.h" |
1391 | + |
1392 | +#include <QMap> |
1393 | + |
1394 | +class MockLauncherPanelPlugin : public LauncherPanelPlugin |
1395 | +{ |
1396 | + Q_OBJECT |
1397 | +public: |
1398 | + explicit MockLauncherPanelPlugin(QObject *parent = nullptr) |
1399 | + : LauncherPanelPlugin(parent) {}; |
1400 | + virtual ~MockLauncherPanelPlugin() {}; |
1401 | + virtual int screens() const override; |
1402 | +public slots: |
1403 | + virtual QRect screenGeometry(const int &screen = -1) const override; |
1404 | + virtual int getCurrentScreenNumber() const override; |
1405 | + void setScreens(const int &screens); // mock only |
1406 | + void setCurrentScreenNumber(const int ¤tScreenNumber); // mock only |
1407 | + void setScreenGeometry(const int &screen, const int &x, const int &y, |
1408 | + const int &width, const int &height); // mock only |
1409 | +private: |
1410 | + int m_currentScreenNumber = 0; |
1411 | + int m_screens = 0; |
1412 | + QMap<int, QRect> m_geometries; |
1413 | + |
1414 | +}; |
1415 | + |
1416 | + |
1417 | +#endif // MOCK_LAUNCHER_PANEL_PLUGIN_H |
1418 | |
1419 | === added file 'tests/mocks/Ubuntu/SystemSettings/Launcher/plugin.cpp' |
1420 | --- tests/mocks/Ubuntu/SystemSettings/Launcher/plugin.cpp 1970-01-01 00:00:00 +0000 |
1421 | +++ tests/mocks/Ubuntu/SystemSettings/Launcher/plugin.cpp 2016-11-21 14:26:16 +0000 |
1422 | @@ -0,0 +1,37 @@ |
1423 | +/* |
1424 | + * This file is part of system-settings |
1425 | + * |
1426 | + * Copyright (C) 2016 Canonical Ltd. |
1427 | + * |
1428 | + * This program is free software: you can redistribute it and/or modify it |
1429 | + * under the terms of the GNU General Public License version 3, as published |
1430 | + * by the Free Software Foundation. |
1431 | + * |
1432 | + * This program is distributed in the hope that it will be useful, but |
1433 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
1434 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1435 | + * PURPOSE. See the GNU General Public License for more details. |
1436 | + * |
1437 | + * You should have received a copy of the GNU General Public License along |
1438 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
1439 | + */ |
1440 | + |
1441 | +#include "plugin.h" |
1442 | +#include "MockLauncherPanelPlugin.h" |
1443 | + |
1444 | +#include <QtQml> |
1445 | + |
1446 | +#define MAKE_SINGLETON_FACTORY(type) \ |
1447 | + static QObject* type##_singleton_factory(QQmlEngine* engine, QJSEngine* scriptEngine) { \ |
1448 | + Q_UNUSED(engine); \ |
1449 | + Q_UNUSED(scriptEngine); \ |
1450 | + return new type(); \ |
1451 | + } |
1452 | + |
1453 | +MAKE_SINGLETON_FACTORY(MockLauncherPanelPlugin) |
1454 | + |
1455 | +void BackendPlugin::registerTypes(const char *uri) |
1456 | +{ |
1457 | + Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.Launcher")); |
1458 | + qmlRegisterSingletonType<MockLauncherPanelPlugin>(uri, 1, 0, "LauncherPanelPlugin", MockLauncherPanelPlugin_singleton_factory); |
1459 | +} |
1460 | |
1461 | === added file 'tests/mocks/Ubuntu/SystemSettings/Launcher/plugin.h' |
1462 | --- tests/mocks/Ubuntu/SystemSettings/Launcher/plugin.h 1970-01-01 00:00:00 +0000 |
1463 | +++ tests/mocks/Ubuntu/SystemSettings/Launcher/plugin.h 2016-11-21 14:26:16 +0000 |
1464 | @@ -0,0 +1,32 @@ |
1465 | +/* |
1466 | + * This file is part of system-settings |
1467 | + * |
1468 | + * Copyright (C) 2016 Canonical Ltd. |
1469 | + * |
1470 | + * This program is free software: you can redistribute it and/or modify it |
1471 | + * under the terms of the GNU General Public License version 3, as published |
1472 | + * by the Free Software Foundation. |
1473 | + * |
1474 | + * This program is distributed in the hope that it will be useful, but |
1475 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
1476 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1477 | + * PURPOSE. See the GNU General Public License for more details. |
1478 | + * |
1479 | + * You should have received a copy of the GNU General Public License along |
1480 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
1481 | + */ |
1482 | + |
1483 | +#ifndef MOCK_SYSTEMSETTINGS_LAUNCHER_PLUGIN_H |
1484 | +#define MOCK_SYSTEMSETTINGS_LAUNCHER_PLUGIN_H |
1485 | + |
1486 | +#include <QQmlExtensionPlugin> |
1487 | + |
1488 | +class BackendPlugin : public QQmlExtensionPlugin |
1489 | +{ |
1490 | + Q_OBJECT |
1491 | + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") |
1492 | +public: |
1493 | + void registerTypes(const char *uri) override; |
1494 | +}; |
1495 | + |
1496 | +#endif // MOCK_SYSTEMSETTINGS_LAUNCHER_PLUGIN_H |
1497 | |
1498 | === added file 'tests/mocks/Ubuntu/SystemSettings/Launcher/qmldir' |
1499 | --- tests/mocks/Ubuntu/SystemSettings/Launcher/qmldir 1970-01-01 00:00:00 +0000 |
1500 | +++ tests/mocks/Ubuntu/SystemSettings/Launcher/qmldir 2016-11-21 14:26:16 +0000 |
1501 | @@ -0,0 +1,2 @@ |
1502 | +module Ubuntu.SystemSettings.Launcher |
1503 | +plugin MockLauncherPanelPlugin |
1504 | |
1505 | === modified file 'tests/plugins/CMakeLists.txt' |
1506 | --- tests/plugins/CMakeLists.txt 2016-08-19 12:30:40 +0000 |
1507 | +++ tests/plugins/CMakeLists.txt 2016-11-21 14:26:16 +0000 |
1508 | @@ -55,3 +55,11 @@ |
1509 | add_qml_test(system-update systemupdate_download_handler |
1510 | IMPORT_PATHS ${SYSTEMUPDATE_IMPORT_PATHS} |
1511 | ) |
1512 | + |
1513 | +set(LAUNCHER_IMPORT_PATHS |
1514 | + ${CMAKE_SOURCE_DIR}/src |
1515 | + ${CMAKE_BINARY_DIR}/tests/utils/modules |
1516 | + ${CMAKE_BINARY_DIR}/tests/mocks/ |
1517 | + ${CMAKE_SOURCE_DIR}/tests/plugins/launcher |
1518 | +) |
1519 | +add_qml_test(launcher LauncherPageComponent IMPORT_PATHS ${LAUNCHER_IMPORT_PATHS}) |
1520 | |
1521 | === added directory 'tests/plugins/launcher' |
1522 | === added directory 'tests/plugins/launcher/Source' |
1523 | === added file 'tests/plugins/launcher/Source/qmldir' |
1524 | --- tests/plugins/launcher/Source/qmldir 1970-01-01 00:00:00 +0000 |
1525 | +++ tests/plugins/launcher/Source/qmldir 2016-11-21 14:26:16 +0000 |
1526 | @@ -0,0 +1,2 @@ |
1527 | +module Source |
1528 | +PageComponent 1.0 ../../../../plugins/launcher/PageComponent.qml |
1529 | |
1530 | === added file 'tests/plugins/launcher/tst_LauncherPageComponent.qml' |
1531 | --- tests/plugins/launcher/tst_LauncherPageComponent.qml 1970-01-01 00:00:00 +0000 |
1532 | +++ tests/plugins/launcher/tst_LauncherPageComponent.qml 2016-11-21 14:26:16 +0000 |
1533 | @@ -0,0 +1,98 @@ |
1534 | +/* |
1535 | + * This file is part of system-settings |
1536 | + * |
1537 | + * Copyright (C) 2016 Canonical Ltd. |
1538 | + * |
1539 | + * This program is free software: you can redistribute it and/or modify it |
1540 | + * under the terms of the GNU General Public License version 3, as published |
1541 | + * by the Free Software Foundation. |
1542 | + * |
1543 | + * This program is distributed in the hope that it will be useful, but |
1544 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
1545 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1546 | + * PURPOSE. See the GNU General Public License for more details. |
1547 | + * |
1548 | + * You should have received a copy of the GNU General Public License along |
1549 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
1550 | + */ |
1551 | + |
1552 | +import QtQuick 2.4 |
1553 | +import QtTest 1.0 |
1554 | +import Ubuntu.Test 0.1 |
1555 | + |
1556 | +import Source 1.0 |
1557 | +import Ubuntu.SystemSettings.Launcher 1.0 |
1558 | + |
1559 | +Item { |
1560 | + id: testRoot |
1561 | + width: 300 |
1562 | + height: 500 |
1563 | + |
1564 | + property int largeScreen: units.gu(91) |
1565 | + |
1566 | + Component { |
1567 | + id: pageComponent |
1568 | + PageComponent { |
1569 | + anchors.fill: parent |
1570 | + } |
1571 | + } |
1572 | + |
1573 | + UbuntuTestCase { |
1574 | + name: "LauncherPageComponent" |
1575 | + when: windowShown |
1576 | + |
1577 | + property var instance: null |
1578 | + |
1579 | + function init() { |
1580 | + instance = pageComponent.createObject(testRoot, {}); |
1581 | + } |
1582 | + |
1583 | + function cleanup() { |
1584 | + instance.destroy(); |
1585 | + } |
1586 | + |
1587 | + function get_gsettings_plugin() { |
1588 | + return findInvisibleChild(instance, "unity8Settings"); |
1589 | + } |
1590 | + |
1591 | + function test_no_large_screen_label_necessary() { |
1592 | + /* I.e. you're on a large screen, and the screen USS is rendered on |
1593 | + is that screen. Assumes currentScreenNumber is 0. */ |
1594 | + var label = findChild(instance, "largeScreenLabel"); |
1595 | + LauncherPanelPlugin.setScreenGeometry(0, 0, 0, largeScreen, 100); |
1596 | + LauncherPanelPlugin.setScreens(1); |
1597 | + verify(!label.visible); |
1598 | + } |
1599 | + |
1600 | + function test_large_screen_label_should_show() { |
1601 | + /* I.e. you're on a small screen, but there's a large screen |
1602 | + somewhere and USS is rendered onto that screen. */ |
1603 | + var label = findChild(instance, "largeScreenLabel"); |
1604 | + LauncherPanelPlugin.setScreenGeometry(0, 0, 0, 100, 100); // small |
1605 | + LauncherPanelPlugin.setScreenGeometry(1, 0, 0, largeScreen, 100); |
1606 | + LauncherPanelPlugin.setScreens(2); |
1607 | + verify(label.visible); |
1608 | + } |
1609 | + |
1610 | + function test_always_show_launcher_switch() { |
1611 | + var gsettings = get_gsettings_plugin(); |
1612 | + var control = findChild(instance, 'alwaysShowLauncherSwitch'); |
1613 | + compare(control.checked, !gsettings.autohideLauncher); |
1614 | + |
1615 | + gsettings.autohideLauncher = !gsettings.autohideLauncher; |
1616 | + compare(control.checked, !gsettings.autohideLauncher); |
1617 | + |
1618 | + control.trigger(); |
1619 | + compare(control.checked, !gsettings.autohideLauncher); |
1620 | + } |
1621 | + |
1622 | + function test_icon_width_slider() { |
1623 | + var gsettings = get_gsettings_plugin(); |
1624 | + var slider = findChild(instance, "iconWidth"); |
1625 | + compare(slider.value, gsettings.launcherWidth); |
1626 | + |
1627 | + gsettings.launcherWidth = 10; |
1628 | + tryCompare(slider, "value", gsettings.launcherWidth); |
1629 | + } |
1630 | + } |
1631 | +} |
FAILED: Continuous integration, rev:1737 /jenkins. canonical. com/system- apps/job/ lp-ubuntu- system- settings- ci/232/ /jenkins. canonical. com/system- apps/job/ build/1970/ console /jenkins. canonical. com/system- apps/job/ build-0- fetch/1971 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 1806/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1806/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= zesty/1806/ console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 1806/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1806/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= zesty/1806/ console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 1806/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1806/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= zesty/1806/ console
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/system- apps/job/ lp-ubuntu- system- settings- ci/232/ rebuild
https:/