Merge lp:~sil2100/unity-2d/trunk.lp855508 into lp:unity-2d

Proposed by Łukasz Zemczak on 2011-09-21
Status: Merged
Approved by: Alberto Mardegan on 2011-09-23
Approved revision: 732
Merged at revision: 734
Proposed branch: lp:~sil2100/unity-2d/trunk.lp855508
Merge into: lp:unity-2d
Diff against target: 173 lines (+116/-1)
5 files modified
libunity-2d-private/Unity2d/GnomeBackground.qml (+6/-1)
libunity-2d-private/Unity2d/plugin.cpp (+4/-0)
libunity-2d-private/src/CMakeLists.txt (+1/-0)
libunity-2d-private/src/percentcoder.cpp (+57/-0)
libunity-2d-private/src/percentcoder.h (+48/-0)
To merge this branch: bzr merge lp:~sil2100/unity-2d/trunk.lp855508
Reviewer Review Type Date Requested Status
Alberto Mardegan (community) 2011-09-21 Approve on 2011-09-23
Review via email: mp+76406@code.launchpad.net

Commit message

[lib][spread] URL-decode the background image path before fetching the image.

Added a PercentCoder element that enables encoding/decoding URL encoded strings.
Fixes https://bugs.launchpad.net/unity-2d/+bug/855508

Description of the change

It's a small proposed fix for bug number 855508. I have added a PercentCoder element to libunity-2d-private which allows conversions from URL Encoded strings to Unicode and vice versa. I used it in the GnomeBackground.qml module to fix the wrongly read path when there are non-ASCII characters in the pathname to the background images. After this fix, the background is read by Unity-2D correctly in all cases. I am proposing a merge for such a small fix now because I'm trying to learn how Launchpad branch merging and bug handling looks like ;)

To post a comment you must log in.
Alberto Mardegan (mardy) wrote :

Thanks Łukasz! I tested the code and it works perfectly.

Just a minor issues: in Unity 2D, alas :-), the coding style seems to prefer having the "*" and "&" character next to the type, and not to the variable.

review: Needs Fixing
lp:~sil2100/unity-2d/trunk.lp855508 updated on 2011-09-23
732. By Łukasz Zemczak on 2011-09-23

Minor coding style fixes.

Łukasz Zemczak (sil2100) wrote :

Ooops, sorry for that - eh, those habits. Fixed (I hope)! ;) Thanks!

Alberto Mardegan (mardy) wrote :

Super, thanks! :-)

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/GnomeBackground.qml'
2--- libunity-2d-private/Unity2d/GnomeBackground.qml 2011-08-09 17:06:35 +0000
3+++ libunity-2d-private/Unity2d/GnomeBackground.qml 2011-09-23 10:40:30 +0000
4@@ -37,6 +37,11 @@
5 schema: "org.gnome.desktop.background"
6 }
7
8+ PercentCoder {
9+ id: backgroundFilename
10+ encoded: desktopBackground.pictureUri
11+ }
12+
13 Rectangle {
14 Rectangle {
15 anchors.fill: parent
16@@ -64,7 +69,7 @@
17 https://bugs.launchpad.net/ubuntu/+source/ubuntu-wallpapers/+bug/296538
18 http://bugreports.qt.nokia.com/browse/QTBUG-7276
19 */
20- var filename = desktopBackground.pictureUri
21+ var filename = backgroundFilename.unencoded /* path is urlencoded */
22 if(filename == "file:///usr/share/backgrounds/warty-final-ubuntu.png")
23 filename = "/usr/share/unity-2d/warty-final-ubuntu.jpg"
24
25
26=== modified file 'libunity-2d-private/Unity2d/plugin.cpp'
27--- libunity-2d-private/Unity2d/plugin.cpp 2011-09-07 14:24:28 +0000
28+++ libunity-2d-private/Unity2d/plugin.cpp 2011-09-23 10:40:30 +0000
29@@ -61,6 +61,8 @@
30 #include "lenses.h"
31 #include "lens.h"
32
33+#include "percentcoder.h"
34+
35 #include "filter.h"
36 #include "filters.h"
37 #include "ratingsfilter.h"
38@@ -148,6 +150,8 @@
39 qmlRegisterType<Lenses>(uri, 1, 0, "Lenses");
40 qmlRegisterType<Lens>(uri, 1, 0, "Lens");
41
42+ qmlRegisterType<PercentCoder>(uri, 0, 1, "PercentCoder");
43+
44 qmlRegisterType<Filter>();
45 qmlRegisterType<Filters>();
46 qmlRegisterType<RatingsFilter>();
47
48=== modified file 'libunity-2d-private/src/CMakeLists.txt'
49--- libunity-2d-private/src/CMakeLists.txt 2011-09-19 17:11:45 +0000
50+++ libunity-2d-private/src/CMakeLists.txt 2011-09-23 10:40:30 +0000
51@@ -73,6 +73,7 @@
52 indicatorswidget.cpp
53 panelapplet.cpp
54 panelstyle.cpp
55+ percentcoder.cpp
56 )
57
58 # Build
59
60=== added file 'libunity-2d-private/src/percentcoder.cpp'
61--- libunity-2d-private/src/percentcoder.cpp 1970-01-01 00:00:00 +0000
62+++ libunity-2d-private/src/percentcoder.cpp 2011-09-23 10:40:30 +0000
63@@ -0,0 +1,57 @@
64+/*
65+ * Copyright (C) 2011 Canonical, Ltd.
66+ *
67+ * Authors:
68+ * Lukasz 'sil2100' Zemczak <lukasz.zemczak@canonical.com>
69+ *
70+ * This program is free software; you can redistribute it and/or modify
71+ * it under the terms of the GNU General Public License as published by
72+ * the Free Software Foundation; version 3.
73+ *
74+ * This program is distributed in the hope that it will be useful,
75+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
76+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
77+ * GNU General Public License for more details.
78+ *
79+ * You should have received a copy of the GNU General Public License
80+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
81+ */
82+
83+#include <QUrl>
84+
85+#include "percentcoder.h"
86+
87+PercentCoder::PercentCoder(QObject* parent) :
88+ QObject(parent)
89+{
90+}
91+
92+QString PercentCoder::encoded() const
93+{
94+ QString string(QUrl::toPercentEncoding(m_string));
95+ return string;
96+}
97+
98+QString PercentCoder::unencoded() const
99+{
100+ return m_string;
101+}
102+
103+void PercentCoder::setEncoded(const QString &string)
104+{
105+ QString str = QUrl::fromPercentEncoding(string.toAscii());
106+ if (str != m_string) {
107+ m_string = str;
108+ Q_EMIT stringChanged();
109+ }
110+}
111+
112+void PercentCoder::setUnencoded(const QString& string)
113+{
114+ if (string != m_string) {
115+ m_string = string;
116+ Q_EMIT stringChanged();
117+ }
118+}
119+
120+#include "percentcoder.moc"
121
122=== added file 'libunity-2d-private/src/percentcoder.h'
123--- libunity-2d-private/src/percentcoder.h 1970-01-01 00:00:00 +0000
124+++ libunity-2d-private/src/percentcoder.h 2011-09-23 10:40:30 +0000
125@@ -0,0 +1,48 @@
126+/*
127+ * Copyright (C) 2011 Canonical, Ltd.
128+ *
129+ * Authors:
130+ * Lukasz 'sil2100' Zemczak <lukasz.zemczak@canonical.com>
131+ *
132+ * This program is free software; you can redistribute it and/or modify
133+ * it under the terms of the GNU General Public License as published by
134+ * the Free Software Foundation; version 3.
135+ *
136+ * This program is distributed in the hope that it will be useful,
137+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
138+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
139+ * GNU General Public License for more details.
140+ *
141+ * You should have received a copy of the GNU General Public License
142+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
143+ */
144+
145+#ifndef PERCENTCODER_H
146+#define PERCENTCODER_H
147+
148+#include <QObject>
149+
150+/* This element type can be used to covert URL Encoded strings to Unicode
151+ QStrings and vice versa */
152+class PercentCoder : public QObject {
153+ Q_OBJECT
154+
155+ Q_PROPERTY(QString encoded READ encoded WRITE setEncoded NOTIFY stringChanged)
156+ Q_PROPERTY(QString unencoded READ unencoded WRITE setUnencoded NOTIFY stringChanged)
157+
158+public:
159+ PercentCoder(QObject* parent = 0);
160+
161+ QString encoded() const;
162+ QString unencoded() const;
163+ void setEncoded(const QString&);
164+ void setUnencoded(const QString&);
165+
166+Q_SIGNALS:
167+ void stringChanged();
168+
169+private:
170+ QString m_string;
171+};
172+
173+#endif

Subscribers

People subscribed via source and target branches