Merge lp:~unity-2d-team/unity-2d/wallpaper-based-tinting into lp:unity-2d

Proposed by Gerry Boland
Status: Merged
Approved by: Gerry Boland
Approved revision: 1007
Merged at revision: 1007
Proposed branch: lp:~unity-2d-team/unity-2d/wallpaper-based-tinting
Merge into: lp:unity-2d
Diff against target: 704 lines (+498/-4)
15 files modified
libunity-2d-private/Unity2d/plugin.cpp (+6/-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/panelpalettemanager.cpp (+8/-1)
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 (+3/-0)
shell/WallpaperColor.qml (+65/-0)
shell/common/Background.qml (+11/-0)
shell/dash/Dash.qml (+0/-1)
shell/launcher/Launcher.qml (+2/-1)
To merge this branch: bzr merge lp:~unity-2d-team/unity-2d/wallpaper-based-tinting
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
Jason Smith Pending
John Lea design Pending
Review via email: mp+98458@code.launchpad.net

This proposal supersedes a proposal from 2012-03-20.

Commit message

Compute the wallpaper average color and use it to colorize the launcher's, panel's and dash's background. Thanks to Florian Boucault

Description of the change

Compute the wallpaper average color and use it to colorize the launcher's, panel's and dash's background.

To post a comment you must log in.
Revision history for this message
Florian Boucault (fboucault) wrote : Posted in a previous version of this proposal

The color computation needs to be refined and checked with the designers.

Interesting references:
http://www.hgrebdes.com/colour/spectrum/colourvisibility.html
http://www.w3.org/TR/AERT#color-contrast

Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

I don't know how common this is, but doing pixel for each of the pixels is ultra slow, you should use scanLine instead

Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

I don't have anything to add to Albert's comment.

review: Approve
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

> I don't have anything to add to Albert's comment.
I take that back, I can has tests for that?

review: Needs Fixing
Revision history for this message
Jason Smith (jassmith) wrote : Posted in a previous version of this proposal

This should have design signoff and screenshots so we can keep UnityQt and Unity in sync

Revision history for this message
Jason Smith (jassmith) wrote : Posted in a previous version of this proposal

Forgot to mark needs fixing

review: Needs Fixing
Revision history for this message
Florian Boucault (fboucault) wrote : Posted in a previous version of this proposal

> This should have design signoff and screenshots so we can keep UnityQt and
> Unity in sync

Don't worry, design is always involved.

Revision history for this message
Jason Smith (jassmith) wrote : Posted in a previous version of this proposal

Design needs to sign off on the review itself before its merged so we can know when to update.

Revision history for this message
Jason Smith (jassmith) wrote : Posted in a previous version of this proposal

And it still needs screenshots

Revision history for this message
Tim Penhey (thumper) wrote : Posted in a previous version of this proposal

Florian, please add a review request from the design team, and add before and after pictures so they can see what is going on.

Revision history for this message
Florian Boucault (fboucault) wrote : Posted in a previous version of this proposal

> Florian, please add a review request from the design team, and add before and
> after pictures so they can see what is going on.

Design has done a prereview of it already. Though the work is not finished on my side. Visual changes in Unity 2D are checked by design.

Do you always put screenshots for visual changes in Unity?

Revision history for this message
Jason Smith (jassmith) wrote : Posted in a previous version of this proposal

We try to put up screenshots for every design review we do. We are working on improving this across the board and here should be no different. The point of the screenshots is to show visual changes in merge reviews.

Revision history for this message
Florian Boucault (fboucault) wrote : Posted in a previous version of this proposal

After fiddling with lots of things we landed on the following solution that the design team is happy with.
One shortcoming is that it does not do so well if the windows below are dark (e.g. a terminal) but that's not worse than it was before.

http://people.canonical.com/~kaleo/colorize/before.png
http://people.canonical.com/~kaleo/colorize/after.png

Code wise, it is missing a couple of tests and the rest should be good to go.

Revision history for this message
Florian Boucault (fboucault) wrote : Posted in a previous version of this proposal

I forgot to mention that this MR depends on https://code.launchpad.net/~fboucault/unity-2d/transparent_panel_when_dash/+merge/92672 that was reviewed and 'approved' but not landed yet due to the freeze.

Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

This isn't so apparent with your packed launcher, but is that http://ubuntuone.com/4xOyGy4ZQVSxfHCvZdFeOS how the it is supposed to look? Looks too bright to me.

review: Needs Information
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

And here with the panel - same issue as with the launcher http://ubuntuone.com/2Y9Dgt1HZP3PDPo4mlGbAr

Revision history for this message
Unity Merger (unity-merger) wrote : Posted in a previous version of this proposal

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity-2d/150/console reported an error when processing this lp:~fboucault/unity-2d/wallpaper_average_color branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote : Posted in a previous version of this proposal

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity-2d/151/console reported an error when processing this lp:~fboucault/unity-2d/wallpaper_average_color branch.
Not merging it.

Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote : Posted in a previous version of this proposal

fails: LC_ALL=C ./imageutilitiestest
works: LC_ALL=C.UTF-8 ./imageutilitiestest

The file "Langelinie_Allé_by_SirPecanGum.jpg" can't be found when using non utf8 environment, even though LANG is en_US.UTF-8

Revision history for this message
Unity Merger (unity-merger) wrote : Posted in a previous version of this proposal

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity-2d/153/console reported an error when processing this lp:~fboucault/unity-2d/wallpaper_average_color branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote : Posted in a previous version of this proposal

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity-2d/156/console reported an error when processing this lp:~fboucault/unity-2d/wallpaper_average_color branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote : Posted in a previous version of this proposal

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity-2d/158/console reported an error when processing this lp:~fboucault/unity-2d/wallpaper_average_color branch.
Not merging it.

Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

Approving again to check if Didier's unity-merger tweak helps.

Revision history for this message
Unity Merger (unity-merger) wrote : Posted in a previous version of this proposal

Attempt to merge into lp:unity-2d failed due to conflicts:

text conflict in libunity-2d-private/Unity2d/plugin.cpp
text conflict in libunity-2d-private/src/CMakeLists.txt
text conflict in libunity-2d-private/src/panelstyle.cpp
text conflict in libunity-2d-private/src/panelstyle.h
text conflict in libunity-2d-private/tests/CMakeLists.txt
text conflict in shell/launcher/Launcher.qml

Revision history for this message
Michał Sawicz (saviq) wrote :

The issues have been resolved, approving.

review: Approve

Preview Diff

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

Subscribers

People subscribed via source and target branches