Merge lp:~gerboland/unity-2d/unit-test-print-error-output into lp:unity-2d
- unit-test-print-error-output
- Merge into trunk
Proposed by
Gerry Boland
Status: | Superseded |
---|---|
Proposed branch: | lp:~gerboland/unity-2d/unit-test-print-error-output |
Merge into: | lp:unity-2d |
Diff against target: |
803 lines (+541/-35) 17 files modified
CMakeLists.txt (+1/-1) libunity-2d-private/Unity2d/plugin.cpp (+7/-0) libunity-2d-private/src/CMakeLists.txt (+2/-0) libunity-2d-private/src/colorizeeffect.cpp (+92/-0) libunity-2d-private/src/colorizeeffect.h (+60/-0) libunity-2d-private/src/imageutilities.cpp (+93/-0) libunity-2d-private/src/imageutilities.h (+57/-0) libunity-2d-private/src/panelstyle.cpp (+12/-1) libunity-2d-private/src/panelstyle.h (+1/-0) libunity-2d-private/src/percentcoder.cpp (+1/-1) libunity-2d-private/tests/CMakeLists.txt (+1/-0) libunity-2d-private/tests/imageutilitiestest.cpp (+97/-0) shell/Shell.qml (+4/-0) shell/WallpaperColor.qml (+65/-0) shell/common/Background.qml (+45/-30) shell/dash/Dash.qml (+0/-1) shell/launcher/Launcher.qml (+3/-1) |
To merge this branch: | bzr merge lp:~gerboland/unity-2d/unit-test-print-error-output |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michał Sawicz | Pending | ||
Review via email: mp+95402@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-03-01.
Commit message
Description of the change
[test] Have Unit tests print error output if they fail
To post a comment you must log in.
- 932. By Gerry Boland
-
Merge trunk
Unmerged revisions
- 932. By Gerry Boland
-
Merge trunk
- 931. By Gerry Boland
-
[test] Have Unit tests print error output if they fail
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2012-01-18 09:01:50 +0000 |
3 | +++ CMakeLists.txt 2012-03-01 16:35:22 +0000 |
4 | @@ -88,7 +88,7 @@ |
5 | |
6 | # Tests |
7 | enable_testing() |
8 | -add_custom_target(check make test) |
9 | +add_custom_target(check make test CTEST_OUTPUT_ON_FAILURE=1) |
10 | configure_file(tests/misc/binary_dir.txt.in ${CMAKE_CURRENT_SOURCE_DIR}/tests/misc/binary_dir.txt @ONLY) |
11 | |
12 | # Source |
13 | |
14 | === modified file 'libunity-2d-private/Unity2d/plugin.cpp' |
15 | --- libunity-2d-private/Unity2d/plugin.cpp 2012-02-28 12:30:17 +0000 |
16 | +++ libunity-2d-private/Unity2d/plugin.cpp 2012-03-01 16:35:22 +0000 |
17 | @@ -40,6 +40,7 @@ |
18 | #include "desktopinfo.h" |
19 | #include "plugin.h" |
20 | #include "cacheeffect.h" |
21 | +#include "colorizeeffect.h" |
22 | #include "iconutilities.h" |
23 | #include "cursorshapearea.h" |
24 | #include "unity2dtr.h" |
25 | @@ -80,6 +81,8 @@ |
26 | #include "unity2dpanel.h" |
27 | #include "strutmanager.h" |
28 | |
29 | +#include "imageutilities.h" |
30 | + |
31 | #include <QtDeclarative/qdeclarative.h> |
32 | #include <QDeclarativeEngine> |
33 | #include <QDeclarativeContext> |
34 | @@ -118,6 +121,7 @@ |
35 | qmlRegisterType<WorkspacesInfo>(); // Register the type as non creatable |
36 | |
37 | qmlRegisterType<CacheEffect>(uri, 0, 1, "CacheEffect"); |
38 | + qmlRegisterType<ColorizeEffect>("Effects", 0, 1, "ColorizeEffect"); |
39 | qmlRegisterType<QGraphicsBlurEffect>("Effects", 1, 0, "Blur"); |
40 | qmlRegisterType<QGraphicsColorizeEffect>("Effects", 1, 0, "Colorize"); |
41 | qmlRegisterType<QGraphicsDropShadowEffect>("Effects", 1, 0, "DropShadow"); |
42 | @@ -183,6 +187,8 @@ |
43 | |
44 | qmlRegisterType<Unity2dPanel>(uri, 0, 1, "Unity2dPanel"); |
45 | qmlRegisterType<StrutManager>(uri, 0, 1, "StrutManager"); |
46 | + |
47 | + qmlRegisterType<ImageUtilities>(uri, 0, 1, "ImageUtilities"); |
48 | } |
49 | |
50 | void Unity2dPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) |
51 | @@ -202,6 +208,7 @@ |
52 | |
53 | /* Expose QConf objects as a context property not to initialize it multiple times */ |
54 | engine->rootContext()->setContextProperty("unity2dConfiguration", &unity2dConfiguration()); |
55 | + engine->rootContext()->setContextProperty("unityConfiguration", &unityConfiguration()); |
56 | engine->rootContext()->setContextProperty("launcher2dConfiguration", &launcher2dConfiguration()); |
57 | engine->rootContext()->setContextProperty("dash2dConfiguration", &dash2dConfiguration()); |
58 | |
59 | |
60 | === modified file 'libunity-2d-private/src/CMakeLists.txt' |
61 | --- libunity-2d-private/src/CMakeLists.txt 2012-02-28 12:30:17 +0000 |
62 | +++ libunity-2d-private/src/CMakeLists.txt 2012-03-01 16:35:22 +0000 |
63 | @@ -32,6 +32,7 @@ |
64 | screeninfo.cpp |
65 | desktopinfo.cpp |
66 | cacheeffect.cpp |
67 | + colorizeeffect.cpp |
68 | workspacesinfo.cpp |
69 | signalwaiter.cpp |
70 | dragitem.cpp |
71 | @@ -78,6 +79,7 @@ |
72 | inputshaperectangle.cpp |
73 | inputshapemask.cpp |
74 | strutmanager.cpp |
75 | + imageutilities.cpp |
76 | ) |
77 | |
78 | # Build |
79 | |
80 | === added file 'libunity-2d-private/src/colorizeeffect.cpp' |
81 | --- libunity-2d-private/src/colorizeeffect.cpp 1970-01-01 00:00:00 +0000 |
82 | +++ libunity-2d-private/src/colorizeeffect.cpp 2012-03-01 16:35:22 +0000 |
83 | @@ -0,0 +1,92 @@ |
84 | +/* |
85 | + * Copyright (C) 2012 Canonical, Ltd. |
86 | + * |
87 | + * Authors: |
88 | + * Florian Boucault <florian.boucault@canonical.com> |
89 | + * |
90 | + * This program is free software; you can redistribute it and/or modify |
91 | + * it under the terms of the GNU General Public License as published by |
92 | + * the Free Software Foundation; version 3. |
93 | + * |
94 | + * This program is distributed in the hope that it will be useful, |
95 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
96 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
97 | + * GNU General Public License for more details. |
98 | + * |
99 | + * You should have received a copy of the GNU General Public License |
100 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
101 | + */ |
102 | + |
103 | +#include "colorizeeffect.h" |
104 | + |
105 | +#include <QPainter> |
106 | + |
107 | +ColorizeEffect::ColorizeEffect(QObject *parent) : |
108 | + QGraphicsEffect(parent), |
109 | + m_color("black"), |
110 | + m_saturation(1.0) |
111 | +{ |
112 | +} |
113 | + |
114 | +QColor ColorizeEffect::color() const |
115 | +{ |
116 | + return m_color; |
117 | +} |
118 | + |
119 | +void ColorizeEffect::setColor(const QColor &color) |
120 | +{ |
121 | + if (color == m_color) return; |
122 | + |
123 | + m_color = color; |
124 | + m_tintedPixmap = QPixmap(); |
125 | + update(); |
126 | + Q_EMIT colorChanged(color); |
127 | +} |
128 | + |
129 | +qreal ColorizeEffect::saturation() const |
130 | +{ |
131 | + return m_saturation; |
132 | +} |
133 | + |
134 | +void ColorizeEffect::setSaturation(qreal saturation) |
135 | +{ |
136 | + if (saturation == m_saturation) return; |
137 | + |
138 | + m_saturation = saturation; |
139 | + m_tintedPixmap = QPixmap(); |
140 | + update(); |
141 | + Q_EMIT saturationChanged(saturation); |
142 | +} |
143 | + |
144 | +void ColorizeEffect::draw(QPainter *painter) |
145 | +{ |
146 | + QPoint offset; |
147 | + const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, QGraphicsEffect::NoPad); |
148 | + |
149 | + if (m_tintedPixmap.isNull()) { |
150 | + /* Compute the tinted pixmap by composing the source pixmap and a tinted rectangle */ |
151 | + m_tintedPixmap = pixmap.copy(); |
152 | + QPainter tintedPainter(&m_tintedPixmap); |
153 | + tintedPainter.setRenderHints(painter->renderHints()); |
154 | + tintedPainter.setCompositionMode(QPainter::CompositionMode_Overlay); |
155 | + QColor color = m_color; |
156 | + color.setAlphaF(m_saturation); |
157 | + tintedPainter.fillRect(m_tintedPixmap.rect(), color); |
158 | + /* Apply alpha channel of the source pixmap to the tinted pixmap */ |
159 | + tintedPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); |
160 | + tintedPainter.drawPixmap(0, 0, pixmap); |
161 | + tintedPainter.end(); |
162 | + } |
163 | + |
164 | + QTransform previousTransform = painter->worldTransform(); |
165 | + painter->setWorldTransform(QTransform()); |
166 | + painter->drawPixmap(offset, m_tintedPixmap); |
167 | + painter->setWorldTransform(previousTransform); |
168 | +} |
169 | + |
170 | +void ColorizeEffect::sourceChanged(ChangeFlags flags) |
171 | +{ |
172 | + m_tintedPixmap = QPixmap(); |
173 | +} |
174 | + |
175 | +#include "colorizeeffect.moc" |
176 | |
177 | === added file 'libunity-2d-private/src/colorizeeffect.h' |
178 | --- libunity-2d-private/src/colorizeeffect.h 1970-01-01 00:00:00 +0000 |
179 | +++ libunity-2d-private/src/colorizeeffect.h 2012-03-01 16:35:22 +0000 |
180 | @@ -0,0 +1,60 @@ |
181 | +/* |
182 | + * Copyright (C) 2012 Canonical, Ltd. |
183 | + * |
184 | + * Authors: |
185 | + * Florian Boucault <florian.boucault@canonical.com> |
186 | + * |
187 | + * This program is free software; you can redistribute it and/or modify |
188 | + * it under the terms of the GNU General Public License as published by |
189 | + * the Free Software Foundation; version 3. |
190 | + * |
191 | + * This program is distributed in the hope that it will be useful, |
192 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
193 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
194 | + * GNU General Public License for more details. |
195 | + * |
196 | + * You should have received a copy of the GNU General Public License |
197 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
198 | + */ |
199 | + |
200 | +#ifndef COLORIZEEFFECT_H |
201 | +#define COLORIZEEFFECT_H |
202 | + |
203 | +#include <QGraphicsEffect> |
204 | +#include <QColor> |
205 | + |
206 | +class ColorizeEffect : public QGraphicsEffect |
207 | +{ |
208 | + Q_OBJECT |
209 | + |
210 | + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
211 | + Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation NOTIFY saturationChanged) |
212 | + |
213 | +public: |
214 | + explicit ColorizeEffect(QObject *parent = 0); |
215 | + |
216 | + // getters |
217 | + QColor color() const; |
218 | + qreal saturation() const; |
219 | + |
220 | + // setters |
221 | + void setColor(const QColor &color); |
222 | + void setSaturation(qreal saturation); |
223 | + |
224 | +Q_SIGNALS: |
225 | + void colorChanged(const QColor &color); |
226 | + void saturationChanged(qreal saturation); |
227 | + |
228 | +protected: |
229 | + void draw(QPainter *painter); |
230 | + void sourceChanged(ChangeFlags flags); |
231 | + |
232 | +private: |
233 | + QColor m_color; |
234 | + qreal m_saturation; |
235 | + |
236 | + // caching of intermediary renderings |
237 | + QPixmap m_tintedPixmap; |
238 | +}; |
239 | + |
240 | +#endif // COLORIZEEFFECT_H |
241 | |
242 | === added file 'libunity-2d-private/src/imageutilities.cpp' |
243 | --- libunity-2d-private/src/imageutilities.cpp 1970-01-01 00:00:00 +0000 |
244 | +++ libunity-2d-private/src/imageutilities.cpp 2012-03-01 16:35:22 +0000 |
245 | @@ -0,0 +1,93 @@ |
246 | +/* |
247 | + * Copyright (C) 2012 Canonical, Ltd. |
248 | + * |
249 | + * Authors: |
250 | + * Florian Boucault <florian.boucault@canonical.com> |
251 | + * |
252 | + * This program is free software; you can redistribute it and/or modify |
253 | + * it under the terms of the GNU General Public License as published by |
254 | + * the Free Software Foundation; version 3. |
255 | + * |
256 | + * This program is distributed in the hope that it will be useful, |
257 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
258 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
259 | + * GNU General Public License for more details. |
260 | + * |
261 | + * You should have received a copy of the GNU General Public License |
262 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
263 | + */ |
264 | + |
265 | +#include "imageutilities.h" |
266 | + |
267 | +#include <QImage> |
268 | + |
269 | +ImageUtilities::ImageUtilities(QObject *parent) : |
270 | + QObject(parent) |
271 | +{ |
272 | +} |
273 | + |
274 | +QUrl ImageUtilities::source() const |
275 | +{ |
276 | + return m_source; |
277 | +} |
278 | + |
279 | +QColor ImageUtilities::averageColor() const |
280 | +{ |
281 | + return m_averageColor; |
282 | +} |
283 | + |
284 | +void ImageUtilities::setSource(const QUrl &source) |
285 | +{ |
286 | + /* FIXME: should monitor source file for changes */ |
287 | + if (source == m_source) return; |
288 | + m_source = source; |
289 | + Q_EMIT sourceChanged(); |
290 | + |
291 | + QImage image; |
292 | + image.load(source.toLocalFile()); |
293 | + |
294 | + if (image.isNull()) return; |
295 | + |
296 | + QColor averageColor = computeAverageColor(image); |
297 | + |
298 | + if (averageColor != m_averageColor) { |
299 | + m_averageColor = averageColor; |
300 | + Q_EMIT averageColorChanged(); |
301 | + } |
302 | +} |
303 | + |
304 | +QColor ImageUtilities::computeAverageColor(const QImage& image) |
305 | +{ |
306 | + long int rtotal = 0, gtotal = 0, btotal = 0; |
307 | + float total = 0.0f; |
308 | + // always sample 100x100 pixels |
309 | + int samplePoints = 100; |
310 | + int stepX = std::max(image.width() / samplePoints, 1); |
311 | + int stepY = std::max(image.height() / samplePoints, 1); |
312 | + |
313 | + for (int y = 0; y < image.height(); y += stepY) { |
314 | + for (int x = 0; x < image.width(); x += stepX) { |
315 | + QColor color = QColor::fromRgba(image.pixel(x, y)); |
316 | + |
317 | + float saturation = (qMax (color.red(), qMax (color.green(), color.blue())) - |
318 | + qMin (color.red(), qMin (color.green(), color.blue()))) / 255.0f; |
319 | + float relevance = .1 + .9 * (color.alpha() / 255.0f) * saturation; |
320 | + |
321 | + rtotal += (unsigned char) (color.red() * relevance); |
322 | + gtotal += (unsigned char) (color.green() * relevance); |
323 | + btotal += (unsigned char) (color.blue() * relevance); |
324 | + |
325 | + total += relevance * 255; |
326 | + } |
327 | + } |
328 | + |
329 | + QColor hsv = QColor::fromRgbF(rtotal / total, gtotal / total, btotal / total).toHsv(); |
330 | + |
331 | + /* Background color is the base color with 0.90f HSV value */ |
332 | + hsv.setHsvF(hsv.hueF(), |
333 | + (hsv.saturationF() > .15f) ? 0.65f : hsv.saturationF(), |
334 | + 0.90f); |
335 | + return hsv; |
336 | +} |
337 | + |
338 | +#include "imageutilities.moc" |
339 | |
340 | === added file 'libunity-2d-private/src/imageutilities.h' |
341 | --- libunity-2d-private/src/imageutilities.h 1970-01-01 00:00:00 +0000 |
342 | +++ libunity-2d-private/src/imageutilities.h 2012-03-01 16:35:22 +0000 |
343 | @@ -0,0 +1,57 @@ |
344 | +/* |
345 | + * Copyright (C) 2012 Canonical, Ltd. |
346 | + * |
347 | + * Authors: |
348 | + * Florian Boucault <florian.boucault@canonical.com> |
349 | + * |
350 | + * This program is free software; you can redistribute it and/or modify |
351 | + * it under the terms of the GNU General Public License as published by |
352 | + * the Free Software Foundation; version 3. |
353 | + * |
354 | + * This program is distributed in the hope that it will be useful, |
355 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
356 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
357 | + * GNU General Public License for more details. |
358 | + * |
359 | + * You should have received a copy of the GNU General Public License |
360 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
361 | + */ |
362 | + |
363 | +#ifndef IMAGEUTILITIES_H |
364 | +#define IMAGEUTILITIES_H |
365 | + |
366 | +#include <QObject> |
367 | +#include <QColor> |
368 | +#include <QUrl> |
369 | +#include <QImage> |
370 | + |
371 | +class ImageUtilities : public QObject |
372 | +{ |
373 | + Q_OBJECT |
374 | + |
375 | + Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) |
376 | + Q_PROPERTY(QColor averageColor READ averageColor NOTIFY averageColorChanged) |
377 | + |
378 | +public: |
379 | + explicit ImageUtilities(QObject *parent = 0); |
380 | + |
381 | + // getters |
382 | + QUrl source() const; |
383 | + QColor averageColor() const; |
384 | + |
385 | + // setters |
386 | + void setSource(const QUrl&); |
387 | + |
388 | +Q_SIGNALS: |
389 | + void sourceChanged(); |
390 | + void averageColorChanged(); |
391 | + |
392 | +protected: |
393 | + QColor computeAverageColor(const QImage&); |
394 | + |
395 | +private: |
396 | + QUrl m_source; |
397 | + QColor m_averageColor; |
398 | +}; |
399 | + |
400 | +#endif // IMAGEUTILITIES_H |
401 | |
402 | === modified file 'libunity-2d-private/src/panelstyle.cpp' |
403 | --- libunity-2d-private/src/panelstyle.cpp 2012-02-22 17:06:20 +0000 |
404 | +++ libunity-2d-private/src/panelstyle.cpp 2012-03-01 16:35:22 +0000 |
405 | @@ -27,6 +27,7 @@ |
406 | #include <gconnector.h> |
407 | #include <gscopedpointer.h> |
408 | #include <dashclient.h> |
409 | +#include <config.h> |
410 | |
411 | // Qt |
412 | #include <QApplication> |
413 | @@ -70,7 +71,11 @@ |
414 | |
415 | QPalette pal; |
416 | if (DashClient::instance()->active() || DashClient::instance()->hudActive()) { |
417 | - pal.setBrush(QPalette::Window, QColor(0, 0, 0, 168)); |
418 | + /* The background color is the same as in the launcher */ |
419 | + QColor wallpaperColor(unityConfiguration().property("averageBgColor").toString()); |
420 | + QColor backgroundColor(wallpaperColor.red(), wallpaperColor.green(), wallpaperColor.blue(), 168); |
421 | + backgroundColor = backgroundColor.darker(800); |
422 | + pal.setBrush(QPalette::Window, backgroundColor); |
423 | } else { |
424 | pal.setBrush(QPalette::Window, generateBackgroundBrush()); |
425 | } |
426 | @@ -181,6 +186,7 @@ |
427 | |
428 | QObject::connect(DashClient::instance(), SIGNAL(activeChanged(bool)), this, SLOT(onDashActiveChanged(bool))); |
429 | QObject::connect(DashClient::instance(), SIGNAL(hudActiveChanged(bool)), this, SLOT(onDashActiveChanged(bool))); |
430 | + QObject::connect(&unityConfiguration(), SIGNAL(averageBgColor(QVariant)), this, SLOT(onWallpaperColorChanged(QVariant))); |
431 | d->updatePalette(); |
432 | } |
433 | |
434 | @@ -217,4 +223,9 @@ |
435 | d->updatePalette(); |
436 | } |
437 | |
438 | +void PanelStyle::onWallpaperColorChanged(QVariant color) |
439 | +{ |
440 | + d->updatePalette(); |
441 | +} |
442 | + |
443 | #include "panelstyle.moc" |
444 | |
445 | === modified file 'libunity-2d-private/src/panelstyle.h' |
446 | --- libunity-2d-private/src/panelstyle.h 2012-02-12 15:12:46 +0000 |
447 | +++ libunity-2d-private/src/panelstyle.h 2012-03-01 16:35:22 +0000 |
448 | @@ -66,6 +66,7 @@ |
449 | |
450 | private Q_SLOTS: |
451 | void onDashActiveChanged(bool active); |
452 | + void onWallpaperColorChanged(QVariant color); |
453 | |
454 | private: |
455 | friend class PanelStylePrivate; |
456 | |
457 | === modified file 'libunity-2d-private/src/percentcoder.cpp' |
458 | --- libunity-2d-private/src/percentcoder.cpp 2011-09-23 10:35:54 +0000 |
459 | +++ libunity-2d-private/src/percentcoder.cpp 2012-03-01 16:35:22 +0000 |
460 | @@ -39,7 +39,7 @@ |
461 | |
462 | void PercentCoder::setEncoded(const QString &string) |
463 | { |
464 | - QString str = QUrl::fromPercentEncoding(string.toAscii()); |
465 | + QString str = QUrl::fromPercentEncoding(string.toUtf8()); |
466 | if (str != m_string) { |
467 | m_string = str; |
468 | Q_EMIT stringChanged(); |
469 | |
470 | === modified file 'libunity-2d-private/tests/CMakeLists.txt' |
471 | --- libunity-2d-private/tests/CMakeLists.txt 2012-01-24 08:38:24 +0000 |
472 | +++ libunity-2d-private/tests/CMakeLists.txt 2012-03-01 16:35:22 +0000 |
473 | @@ -37,6 +37,7 @@ |
474 | listaggregatormodeltest |
475 | qsortfilterproxymodeltest |
476 | focuspathtest |
477 | + imageutilitiestest |
478 | ) |
479 | |
480 | # unity2dtrtest - FIXME |
481 | |
482 | === added file 'libunity-2d-private/tests/imageutilitiestest.cpp' |
483 | --- libunity-2d-private/tests/imageutilitiestest.cpp 1970-01-01 00:00:00 +0000 |
484 | +++ libunity-2d-private/tests/imageutilitiestest.cpp 2012-03-01 16:35:22 +0000 |
485 | @@ -0,0 +1,97 @@ |
486 | +/* |
487 | + * This file is part of unity-2d |
488 | + * |
489 | + * Copyright 2012 Canonical Ltd. |
490 | + * |
491 | + * Authors: |
492 | + * - Gerry Boland <gerry.boland@canonical.com> |
493 | + * |
494 | + * This program is free software; you can redistribute it and/or modify |
495 | + * it under the terms of the GNU General Public License as published by |
496 | + * the Free Software Foundation; version 3. |
497 | + * |
498 | + * This program is distributed in the hope that it will be useful, |
499 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
500 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
501 | + * GNU General Public License for more details. |
502 | + * |
503 | + * You should have received a copy of the GNU General Public License |
504 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
505 | + */ |
506 | + |
507 | +// Local |
508 | +#include <unitytestmacro.h> |
509 | +#include <debug_p.h> |
510 | +#include <imageutilities.h> |
511 | + |
512 | +const int threshold = 0.001; |
513 | + |
514 | +class ImageUtilitiesTest : public QObject |
515 | +{ |
516 | + Q_OBJECT |
517 | +private Q_SLOTS: |
518 | + void initTestCase() |
519 | + { |
520 | + } |
521 | + |
522 | + void testAverageColorComputed0() |
523 | + { |
524 | + ImageUtilities imageUtil; |
525 | + QUrl image("file:./verification/JardinPolar_by_CarmenGloria_Gonzalez.jpg"); |
526 | + QColor color; |
527 | + |
528 | + imageUtil.setSource(image); |
529 | + color = imageUtil.averageColor(); |
530 | + |
531 | + QCOMPARE(color.red(), 80); |
532 | + QCOMPARE(color.green(), 194); |
533 | + QCOMPARE(color.blue(), 230); |
534 | + } |
535 | + |
536 | + void testAverageColorComputed1() |
537 | + { |
538 | + ImageUtilities imageUtil; |
539 | + QString imagePath = QString::fromUtf8("file:./verification/Langelinie_Allé_by_SirPecanGum.jpg"); |
540 | + QUrl image(imagePath); |
541 | + QColor color; |
542 | + |
543 | + imageUtil.setSource(image); |
544 | + color = imageUtil.averageColor(); |
545 | + QCOMPARE(color.red(), 230); |
546 | + QCOMPARE(color.green(), 126); |
547 | + QCOMPARE(color.blue(), 80); |
548 | + } |
549 | + |
550 | + void testAverageColorComputed2() |
551 | + { |
552 | + ImageUtilities imageUtil; |
553 | + QUrl image("file:./verification/The_Grass_aint_Greener_by_fix_pena.jpg"); |
554 | + QColor color; |
555 | + |
556 | + imageUtil.setSource(image); |
557 | + color = imageUtil.averageColor(); |
558 | + |
559 | + QCOMPARE(color.red(), 218); |
560 | + QCOMPARE(color.green(), 230); |
561 | + QCOMPARE(color.blue(), 80); |
562 | + } |
563 | + |
564 | + void testAverageColorComputed3() |
565 | + { |
566 | + ImageUtilities imageUtil; |
567 | + QUrl image("file:./verification/warty-final-ubuntu.png"); |
568 | + QColor color; |
569 | + |
570 | + imageUtil.setSource(image); |
571 | + color = imageUtil.averageColor(); |
572 | + |
573 | + QCOMPARE(color.red(), 230); |
574 | + QCOMPARE(color.green(), 80); |
575 | + QCOMPARE(color.blue(), 137); |
576 | + } |
577 | +}; |
578 | + |
579 | +UAPP_TEST_MAIN(ImageUtilitiesTest) |
580 | + |
581 | +#include "imageutilitiestest.moc" |
582 | + |
583 | |
584 | === added directory 'libunity-2d-private/tests/verification' |
585 | === added file 'libunity-2d-private/tests/verification/JardinPolar_by_CarmenGloria_Gonzalez.jpg' |
586 | Binary files libunity-2d-private/tests/verification/JardinPolar_by_CarmenGloria_Gonzalez.jpg 1970-01-01 00:00:00 +0000 and libunity-2d-private/tests/verification/JardinPolar_by_CarmenGloria_Gonzalez.jpg 2012-03-01 16:35:22 +0000 differ |
587 | === added file 'libunity-2d-private/tests/verification/Langelinie_Allé_by_SirPecanGum.jpg' |
588 | Binary files libunity-2d-private/tests/verification/Langelinie_Allé_by_SirPecanGum.jpg 1970-01-01 00:00:00 +0000 and libunity-2d-private/tests/verification/Langelinie_Allé_by_SirPecanGum.jpg 2012-03-01 16:35:22 +0000 differ |
589 | === added file 'libunity-2d-private/tests/verification/The_Grass_aint_Greener_by_fix_pena.jpg' |
590 | Binary files libunity-2d-private/tests/verification/The_Grass_aint_Greener_by_fix_pena.jpg 1970-01-01 00:00:00 +0000 and libunity-2d-private/tests/verification/The_Grass_aint_Greener_by_fix_pena.jpg 2012-03-01 16:35:22 +0000 differ |
591 | === added file 'libunity-2d-private/tests/verification/warty-final-ubuntu.png' |
592 | Binary files libunity-2d-private/tests/verification/warty-final-ubuntu.png 1970-01-01 00:00:00 +0000 and libunity-2d-private/tests/verification/warty-final-ubuntu.png 2012-03-01 16:35:22 +0000 differ |
593 | === modified file 'shell/Shell.qml' |
594 | --- shell/Shell.qml 2012-02-28 12:00:14 +0000 |
595 | +++ shell/Shell.qml 2012-03-01 16:35:22 +0000 |
596 | @@ -36,6 +36,10 @@ |
597 | |
598 | property alias hudActive: hudLoader.active |
599 | |
600 | + |
601 | + WallpaperColor { |
602 | + } |
603 | + |
604 | GestureHandler { |
605 | id: gestureHandler |
606 | } |
607 | |
608 | === added file 'shell/WallpaperColor.qml' |
609 | --- shell/WallpaperColor.qml 1970-01-01 00:00:00 +0000 |
610 | +++ shell/WallpaperColor.qml 2012-03-01 16:35:22 +0000 |
611 | @@ -0,0 +1,65 @@ |
612 | +/* |
613 | + * This file is part of unity-2d |
614 | + * |
615 | + * Copyright 2012 Canonical Ltd. |
616 | + * |
617 | + * This program is free software; you can redistribute it and/or modify |
618 | + * it under the terms of the GNU General Public License as published by |
619 | + * the Free Software Foundation; version 3. |
620 | + * |
621 | + * This program is distributed in the hope that it will be useful, |
622 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
623 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
624 | + * GNU General Public License for more details. |
625 | + * |
626 | + * You should have received a copy of the GNU General Public License |
627 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
628 | + */ |
629 | + |
630 | +import QtQuick 1.1 |
631 | +import QConf 1.0 |
632 | +import Unity2d 1.0 |
633 | + |
634 | +/* Save wallpaper average color in Unity's configuration key 'averageBgColor' |
635 | + FIXME: the case where the wallpaper is a slideshow is not yet supported |
636 | +*/ |
637 | +/* FIXME: change of wallpaper is not taken into account live because of a bug |
638 | + in dconf-dbus. Patch is available and needs to be pushed in Ubuntu. |
639 | + Ref.: https://bugzilla.gnome.org/show_bug.cgi?id=669915 |
640 | +*/ |
641 | +Item { |
642 | + QConf { |
643 | + id: desktopBackground |
644 | + schema: "org.gnome.desktop.background" |
645 | + } |
646 | + |
647 | + PercentCoder { |
648 | + id: backgroundFilename |
649 | + encoded: desktopBackground.pictureUri |
650 | + } |
651 | + |
652 | + ImageUtilities { |
653 | + id: imageUtilities |
654 | + source: { |
655 | + /* FIXME: Because /usr/share/backgrounds/warty-final-ubuntu.png is |
656 | + actually a jpeg and Qt relies by default on the extension |
657 | + that particular background fails to load. We workaround |
658 | + it by having our own symlink with a 'jpg' extension. |
659 | + |
660 | + References: |
661 | + https://bugs.launchpad.net/ubuntu/+source/ubuntu-wallpapers/+bug/296538 |
662 | + http://bugreports.qt.nokia.com/browse/QTBUG-7276 |
663 | + */ |
664 | + var filename = backgroundFilename.unencoded /* path is urlencoded */ |
665 | + if(filename == "file:///usr/share/backgrounds/warty-final-ubuntu.png") |
666 | + filename = "/usr/share/unity-2d/warty-final-ubuntu.jpg" |
667 | + return filename |
668 | + } |
669 | + } |
670 | + |
671 | + Binding { |
672 | + target: unityConfiguration |
673 | + property: "averageBgColor" |
674 | + value: desktopBackground.pictureUri != "" ? imageUtilities.averageColor : desktopBackground.primaryColor |
675 | + } |
676 | +} |
677 | |
678 | === modified file 'shell/common/Background.qml' |
679 | --- shell/common/Background.qml 2012-02-17 16:25:15 +0000 |
680 | +++ shell/common/Background.qml 2012-03-01 16:35:22 +0000 |
681 | @@ -33,39 +33,54 @@ |
682 | |
683 | Item { |
684 | anchors.fill: parent |
685 | - anchors.bottomMargin: bottomBorderThickness |
686 | - anchors.rightMargin: rightBorderThickness |
687 | - clip: true |
688 | - |
689 | - Image { |
690 | - id: blurredBackground |
691 | - |
692 | - effect: Blur {blurRadius: 12} |
693 | - |
694 | - /* 'source' needs to be set when this becomes visible, that is when active |
695 | - becomes true, so that a screenshot of the desktop is taken at that point. |
696 | - See http://doc.qt.nokia.com/4.7-snapshot/qml-image.html#cache-prop |
697 | - */ |
698 | - |
699 | - /* Use an image of the root window which essentially is a |
700 | - capture of the entire screen */ |
701 | - source: active ? "image://window/root" : "" |
702 | - cache: false |
703 | - |
704 | - fillMode: Image.PreserveAspectCrop |
705 | - |
706 | - /* Place the screenshot of the desktop background on top of the desktop background, |
707 | - no matter where the DeclarativeView or the parent object are placed. |
708 | - */ |
709 | - property variant origin: parent.mapFromItem(null, -declarativeView.globalPosition.x, -declarativeView.globalPosition.y) |
710 | - x: origin.x |
711 | - y: origin.y |
712 | + /* Extra Item seemingly unnecessary but actually useful to avoid a |
713 | + redrawing bug that happens when applying an effect on a clipped item. |
714 | + In this particular case, doing the Colorize on the clipped child item |
715 | + would prevent proper repainting when maximizing then unmaximizing the |
716 | + dash. |
717 | + */ |
718 | + effect: ColorizeEffect { |
719 | + color: unityConfiguration.averageBgColor |
720 | + saturation: 0.4 |
721 | } |
722 | |
723 | - Image { |
724 | + Item { |
725 | anchors.fill: parent |
726 | - fillMode: Image.PreserveAspectCrop |
727 | - source: "artwork/background_sheen.png" |
728 | + anchors.bottomMargin: bottomBorderThickness |
729 | + anchors.rightMargin: rightBorderThickness |
730 | + clip: true |
731 | + |
732 | + Image { |
733 | + id: blurredBackground |
734 | + |
735 | + effect: Blur {blurRadius: 12} |
736 | + |
737 | + /* 'source' needs to be set when this becomes visible, that is when active |
738 | + becomes true, so that a screenshot of the desktop is taken at that point. |
739 | + See http://doc.qt.nokia.com/4.7-snapshot/qml-image.html#cache-prop |
740 | + */ |
741 | + |
742 | + /* Use an image of the root window which essentially is a |
743 | + capture of the entire screen */ |
744 | + source: active ? "image://window/root" : "" |
745 | + cache: false |
746 | + |
747 | + fillMode: Image.PreserveAspectCrop |
748 | + |
749 | + /* Place the screenshot of the desktop background on top of the desktop background, |
750 | + no matter where the DeclarativeView or the parent object are placed. |
751 | + */ |
752 | + property variant origin: parent.mapFromItem(null, -declarativeView.globalPosition.x, -declarativeView.globalPosition.y) |
753 | + x: origin.x |
754 | + y: origin.y |
755 | + } |
756 | + |
757 | + Image { |
758 | + anchors.fill: parent |
759 | + fillMode: Image.PreserveAspectCrop |
760 | + source: "artwork/background_sheen.png" |
761 | + opacity: 0.8 |
762 | + } |
763 | } |
764 | } |
765 | |
766 | |
767 | === modified file 'shell/dash/Dash.qml' |
768 | --- shell/dash/Dash.qml 2012-02-27 10:47:50 +0000 |
769 | +++ shell/dash/Dash.qml 2012-03-01 16:35:22 +0000 |
770 | @@ -18,7 +18,6 @@ |
771 | |
772 | import QtQuick 1.1 |
773 | import Unity2d 1.0 |
774 | -import Effects 1.0 |
775 | import "../common" |
776 | import "../common/utils.js" as Utils |
777 | |
778 | |
779 | === modified file 'shell/launcher/Launcher.qml' |
780 | --- shell/launcher/Launcher.qml 2012-02-27 10:50:43 +0000 |
781 | +++ shell/launcher/Launcher.qml 2012-03-01 16:35:22 +0000 |
782 | @@ -62,11 +62,12 @@ |
783 | } |
784 | } |
785 | |
786 | + /* The background color is the same as in the panel */ |
787 | Rectangle { |
788 | Accessible.name: "background" |
789 | anchors.fill: parent |
790 | anchors.rightMargin: declarativeView.dashActive ? 0 : border.width |
791 | - color: "black" |
792 | + color: Qt.darker(unityConfiguration.averageBgColor, 8.0) |
793 | opacity: 0.66 |
794 | visible: desktop.isCompositingManagerRunning |
795 | } |
796 | @@ -79,6 +80,7 @@ |
797 | height: parent.height |
798 | anchors.right: Utils.isLeftToRight() ? parent.right : undefined |
799 | anchors.left: Utils.isLeftToRight() ? undefined : parent.left |
800 | + |
801 | visible: declarativeView.dashActive |
802 | source: "artwork/border.png" |
803 | fillMode: Image.Stretch |