on xenial help sign in
Merge trunk.
commitecc17793f17793fbe01d1df6bd0721bcb3c8d13b authorMichał Sawicz <michal.sawicz@canonical.com> dateFri 28 Feb 2014, 11:45 (13 years ago) parente634da8b792470
11 files changed+157−44
debian/changelog+12 plugins/Utils/CMakeLists.txt+1−1 plugins/Utils/albumartprovider.cpp+23−21 po/ar.po+6−6 po/fi.po+4−4 po/sl.po+10−8 qml/Dash/Card.qml+40−2 qml/Greeter/Greeter.qml+1−1 qml/Shell.qml+1−1 tests/qmltests/Dash/artwork/checkers.png tests/qmltests/Dash/tst_Card.qml+59
debian/changelog+12
@@ -1,3 +1,15 @@
1+unity8 (7.84+14.04.20140221-0ubuntu1) trusty; urgency=low
2+
3+ [ Michał Sawicz ]
4+ * Add card background support.
5+ * Increase the sidestage threshold.
6+
7+ [ Jussi Pakkanen ]
8+ * Move downloads to their own threads so they don't muck about with
9+ the parent thread's event loop. (LP: #1240408)
10+
11+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Fri, 21 Feb 2014 09:06:04 +0000
12+
113unity8 (7.84+14.04.20140218-0ubuntu1) trusty; urgency=low
214
315 [ Michał Sawicz ]
plugins/Utils/CMakeLists.txt+1−1
@@ -33,7 +33,7 @@ target_link_libraries(Utils-qml ${GIO_LDFLAGS})
3333# files directly in targets.
3434set_target_properties(Utils-qml PROPERTIES COMPILE_FLAGS -fvisibility=default)
3535
36−qt5_use_modules(Utils-qml Qml Quick DBus Network XmlPatterns)
36+qt5_use_modules(Utils-qml Qml Quick DBus Network XmlPatterns Concurrent)
3737
3838# export the qmldir qmltypes and plugin files
3939export_qmlfiles(Utils Utils)
plugins/Utils/albumartprovider.cpp+23−21
@@ -33,12 +33,27 @@
3333#include <QImage>
3434#include <QUrl>
3535#include <QUrlQuery>
36+#include <QtConcurrent>
3637
3738using namespace std;
3839
3940const std::string AlbumArtProvider::DEFAULT_ALBUM_ART = "/usr/share/unity/icons/album_missing.png";
4041const std::string AlbumArtProvider::UNITY_LENS_SCHEMA = "com.canonical.Unity.Lenses";
4142
43+static QByteArray download(QString url) {
44+ QScopedPointer<QNetworkAccessManager> am(new QNetworkAccessManager);
45+ QNetworkReply *reply = am->get(QNetworkRequest(QUrl(url)));
46+ QEventLoop loop;
47+ QObject::connect(am.data(), &QNetworkAccessManager::finished, &loop, &QEventLoop::quit);
48+ loop.exec();
49+
50+ if (reply->error() != QNetworkReply::NoError) {
51+ qWarning() << "Error downloading from the network:" << reply->errorString();
52+ return QByteArray();
53+ }
54+ return reply->readAll();
55+}
56+
4257AlbumArtProvider::AlbumArtProvider()
4358 : QQuickImageProvider(QQmlImageProviderBase::Image, QQmlImageProviderBase::ForceAsynchronousImageLoading),
4459 m_settings(nullptr)
@@ -76,20 +91,14 @@ std::string AlbumArtProvider::get_lastfm_url(const albuminfo &ai) {
7691 QString request = QString("http://ws.audioscrobbler.com/1.0/album/%1/%2/info.xml").arg(artist)
7792 .arg(album)
7893 .toHtmlEscaped();
79− QScopedPointer<QNetworkAccessManager> am(new QNetworkAccessManager);
80− QNetworkReply *reply = am->get(QNetworkRequest(QUrl(request)));
81− QEventLoop loop;
82− QObject::connect(am.data(), &QNetworkAccessManager::finished, &loop, &QEventLoop::quit);
83− loop.exec();
84−
85− if (reply->error() != QNetworkReply::NoError) {
86− qWarning() << "Error getting the XML:" << reply->errorString();
94+ QFuture<QByteArray> future = QtConcurrent::run(download, request);
95+ QByteArray arr = future.result();
96+ if(arr.size() == 0) {
8797 return "";
8898 }
89−
9099 QXmlQuery query;
91100 QBuffer tmp;
92− tmp.setData(reply->readAll());
101+ tmp.setData(arr);
93102 tmp.open(QIODevice::ReadOnly);
94103 query.bindVariable("reply", &tmp);
95104 query.setQuery("doc($reply)/album/coverart/large[1]/text()");
@@ -109,24 +118,17 @@ std::string AlbumArtProvider::get_lastfm_url(const albuminfo &ai) {
109118bool AlbumArtProvider::download_and_store(const std::string &image_url, const std::string &output_file) {
110119 QString url = QString::fromStdString(image_url);
111120 QString fileName = QString::fromStdString(output_file);
112−
113− QScopedPointer<QNetworkAccessManager> am(new QNetworkAccessManager);
114− QNetworkReply *reply = am->get(QNetworkRequest(QUrl(url)));
115− QEventLoop loop;
116− QObject::connect(am.data(), &QNetworkAccessManager::finished, &loop, &QEventLoop::quit);
117− loop.exec();
118−
119− if (reply->error() != QNetworkReply::NoError) {
120− qWarning() << "Error getting the image:" << reply->errorString();
121+ QFuture<QByteArray> future = QtConcurrent::run(download, url);
122+ QByteArray arr = future.result();
123+ if (arr.size() == 0) {
121124 return false;
122125 }
123−
124126 QFile file(fileName);
125127 if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
126128 qWarning() << "Could not open file for writing:" << file.errorString();
127129 return false;
128130 }
129− if (file.write(reply->readAll()) == -1){
131+ if (file.write(arr) == -1){
130132 qWarning() << "Could not write the image:" << file.error();
131133 return false;
132134 }
po/ar.po+6−6
@@ -8,7 +8,7 @@ msgstr ""
88"Project-Id-Version: unity\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2014-02-13 18:37+0000\n"
11−"PO-Revision-Date: 2014-02-16 09:56+0000\n"
11+"PO-Revision-Date: 2014-02-21 11:19+0000\n"
1212"Last-Translator: Ibrahim Saed <ibraheem5000@gmail.com>\n"
1313"Language-Team: Arabic <ar@li.org>\n"
1414"MIME-Version: 1.0\n"
@@ -16,8 +16,8 @@ msgstr ""
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n % 100 >= "
1818"3 && n % 100 <= 10 ? 3 : n % 100 >= 11 && n % 100 <= 99 ? 4 : 5;\n"
19−"X-Launchpad-Export-Date: 2014-02-19 05:44+0000\n"
20−"X-Generator: Launchpad (build 16916)\n"
19+"X-Launchpad-Export-Date: 2014-02-22 07:40+0000\n"
20+"X-Generator: Launchpad (build 16926)\n"
2121
2222#: plugins/Unity/Launcher/launcheritem.cpp:43
2323#: plugins/Unity/Launcher/launcheritem.cpp:73
@@ -113,11 +113,11 @@ msgstr[5] "%1 تعليق"
113113
114114#: qml/Dash/Previews/PreviewActionCombo.qml:34
115115msgid "More..."
116−msgstr ""
116+msgstr "المزيد..."
117117
118118#: qml/Dash/Previews/PreviewActionCombo.qml:34
119119msgid "Less..."
120−msgstr ""
120+msgstr "أقل..."
121121
122122#: qml/Dash/Previews/PreviewRating.qml:114 qml/Dash/Previews/Reviews.qml:74
123123msgid "Add a review"
@@ -174,7 +174,7 @@ msgstr "عرض كلمة السر"
174174
175175#: qml/Notifications/NotificationMenuItemFactory.qml:103
176176msgid "Please enter SIM PIN"
177−msgstr ""
177+msgstr "من فضلك أدخِل رقم التعريف الشخصي لبطاقة SIM"
178178
179179#: qml/Panel/SearchIndicator.qml:27
180180msgid "Search"
po/fi.po+4−4
@@ -8,15 +8,15 @@ msgstr ""
88"Project-Id-Version: unity\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2014-02-13 18:37+0000\n"
11−"PO-Revision-Date: 2014-02-14 13:28+0000\n"
11+"PO-Revision-Date: 2014-02-21 19:36+0000\n"
1212"Last-Translator: Jiri Grönroos <Unknown>\n"
1313"Language-Team: Finnish <fi@li.org>\n"
1414"MIME-Version: 1.0\n"
1515"Content-Type: text/plain; charset=UTF-8\n"
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=2; plural=n != 1;\n"
18−"X-Launchpad-Export-Date: 2014-02-19 05:44+0000\n"
19−"X-Generator: Launchpad (build 16916)\n"
18+"X-Launchpad-Export-Date: 2014-02-22 07:40+0000\n"
19+"X-Generator: Launchpad (build 16926)\n"
2020
2121#: plugins/Unity/Launcher/launcheritem.cpp:43
2222#: plugins/Unity/Launcher/launcheritem.cpp:73
@@ -105,7 +105,7 @@ msgstr[1] "%1 arvostelua"
105105
106106#: qml/Dash/Previews/PreviewActionCombo.qml:34
107107msgid "More..."
108−msgstr ""
108+msgstr "Lisää..."
109109
110110#: qml/Dash/Previews/PreviewActionCombo.qml:34
111111msgid "Less..."
po/sl.po+10−8
@@ -8,7 +8,7 @@ msgstr ""
88"Project-Id-Version: unity\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2014-02-13 18:37+0000\n"
11−"PO-Revision-Date: 2013-11-30 08:20+0000\n"
11+"PO-Revision-Date: 2014-02-21 16:38+0000\n"
1212"Last-Translator: Damir Jerovšek <Unknown>\n"
1313"Language-Team: Slovenian <sl@li.org>\n"
1414"MIME-Version: 1.0\n"
@@ -16,8 +16,8 @@ msgstr ""
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=4; plural=(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || "
1818"n%100==4 ? 3 : 0);\n"
19−"X-Launchpad-Export-Date: 2014-02-19 05:44+0000\n"
20−"X-Generator: Launchpad (build 16916)\n"
19+"X-Launchpad-Export-Date: 2014-02-22 07:40+0000\n"
20+"X-Generator: Launchpad (build 16926)\n"
2121
2222#: plugins/Unity/Launcher/launcheritem.cpp:43
2323#: plugins/Unity/Launcher/launcheritem.cpp:73
@@ -75,6 +75,8 @@ msgid ""
7575"You have now mastered the edge gestures and can start using the "
7676"phone<br><br>Tap on the screen to start"
7777msgstr ""
78+"Sedaj, ko ste osvojili poteze robov, lahko začnete uporabljati "
79+"telefon<br><br>Tapnite na zaslon za začetek"
7880
7981#: qml/Components/PageHeader.qml:340
8082msgid "Recent searches"
@@ -82,11 +84,11 @@ msgstr "Nedavna iskanja"
8284
8385#: qml/Components/SeeMore.qml:35
8486msgid "See more"
85−msgstr ""
87+msgstr "Pokaži več"
8688
8789#: qml/Components/SeeMore.qml:57
8890msgid "See less"
89−msgstr ""
91+msgstr "Pokaži manj"
9092
9193#: qml/Dash/Apps/AppPreview.qml:136 qml/Dash/Previews/PreviewRating.qml:70
9294msgid "Rate this"
@@ -110,11 +112,11 @@ msgstr[3] "%1 ocene"
110112
111113#: qml/Dash/Previews/PreviewActionCombo.qml:34
112114msgid "More..."
113−msgstr ""
115+msgstr "Več ..."
114116
115117#: qml/Dash/Previews/PreviewActionCombo.qml:34
116118msgid "Less..."
117−msgstr ""
119+msgstr "Manj ..."
118120
119121#: qml/Dash/Previews/PreviewRating.qml:114 qml/Dash/Previews/Reviews.qml:74
120122msgid "Add a review"
@@ -171,7 +173,7 @@ msgstr "Pokaži geslo"
171173
172174#: qml/Notifications/NotificationMenuItemFactory.qml:103
173175msgid "Please enter SIM PIN"
174−msgstr ""
176+msgstr "Vnesite PIN kartice SIM"
175177
176178#: qml/Panel/SearchIndicator.qml:27
177179msgid "Search"
qml/Dash/Card.qml+40−2
@@ -30,7 +30,39 @@ Item {
3030 property bool showHeader: true
3131
3232 implicitWidth: childrenRect.width
33− implicitHeight: summary.y + summary.height
33+ implicitHeight: summary.y + summary.height + (summary.text && background.visible ? units.gu(1) : 0)
34+
35+ UbuntuShape {
36+ id: background
37+ objectName: "background"
38+ radius: "medium"
39+ visible: template["card-layout"] !== "horizontal" && (template["card-background"] || components["background"]
40+ || artAndSummary)
41+ property bool artAndSummary: components["art"]["field"] && components["summary"] || false
42+ color: getColor(0) || "white"
43+ gradientColor: getColor(1) || color
44+ anchors.fill: parent
45+ image: backgroundImage.source ? backgroundImage : null
46+
47+ property Image backgroundImage: Image {
48+ objectName: "backgroundImage"
49+ source: {
50+ if (cardData && typeof cardData["background"] === "string") return cardData["background"]
51+ else if (template && typeof template["card-background"] === "string") return template["card-background"]
52+ else return ""
53+ }
54+ }
55+
56+ function getColor(index) {
57+ if (cardData && typeof cardData["background"] === "object"
58+ && (cardData["background"]["type"] === "color" || cardData["background"]["type"] === "gradient")) {
59+ return cardData["background"]["elements"][index];
60+ } else if (template && typeof template["card-background"] === "object"
61+ && (template["card-background"]["type"] === "color" || template["card-background"]["type"] === "gradient")) {
62+ return template["card-background"]["elements"][index];
63+ } else return undefined;
64+ }
65+ }
3466
3567 UbuntuShape {
3668 id: artShape
@@ -138,7 +170,13 @@ Item {
138170 Label {
139171 id: summary
140172 objectName: "summaryLabel"
141− anchors { top: header.visible ? header.bottom : artShape.bottom; left: parent.left; right: parent.right }
173+ anchors {
174+ top: header.visible ? header.bottom : artShape.bottom
175+ left: parent.left
176+ right: parent.right
177+ margins: background.visible ? units.gu(1) : 0
178+ topMargin: 0
179+ }
142180 wrapMode: Text.Wrap
143181 maximumLineCount: 5
144182 elide: Text.ElideRight
qml/Greeter/Greeter.qml+1−1
@@ -37,7 +37,7 @@ Showable {
3737 property alias model: greeterContentLoader.model
3838 property bool locked: shown && !LightDM.Greeter.promptless
3939
40− readonly property bool narrowMode: !multiUser && width <= units.gu(60)
40+ readonly property bool narrowMode: !multiUser && height > width
4141 readonly property bool multiUser: LightDM.Users.count > 1
4242
4343 readonly property bool leftTeaserPressed: greeterContentLoader.status == Loader.Ready &&
qml/Shell.qml+1−1
@@ -340,7 +340,7 @@ FocusScope {
340340 }
341341 }
342342
343− enabled: shell.width >= units.gu(60)
343+ enabled: shell.width >= units.gu(100)
344344 visible: enabled
345345 fullyShown: stages.fullyShown && shown
346346 && sideStage[sideStageRevealer.boundProperty] == sideStageRevealer.openedValue
tests/qmltests/Dash/artwork/checkers.pngnew file

Binary file not shown.

tests/qmltests/Dash/tst_Card.qml+59
@@ -79,6 +79,21 @@ Rectangle {
7979 "layout": { "template": { "overlay": true },
8080 "components": JSON.parse(Helpers.fullMapping) }
8181 },
82+ {
83+ "name": "Art, header - grey background",
84+ "layout": { "template": { "card-background": { "type": "color", "elements": ["grey"] } },
85+ "components": JSON.parse(Helpers.fullMapping) }
86+ },
87+ {
88+ "name": "Art, header - gradient background",
89+ "layout": { "template": { "card-background": { "type": "gradient", "elements": ["grey", "white"] } },
90+ "components": JSON.parse(Helpers.fullMapping) }
91+ },
92+ {
93+ "name": "Art, header - image background",
94+ "layout": { "template": { "card-background": Qt.resolvedUrl("artwork/checkers.png") },
95+ "components": JSON.parse(Helpers.fullMapping) }
96+ },
8297 ]
8398
8499 CardTool {
@@ -171,12 +186,16 @@ Rectangle {
171186 property Item art: findChild(card, "artShape")
172187 property Item artImage: findChild(card, "artImage")
173188 property Item summary: findChild(card, "summaryLabel")
189+ property Item background: findChild(card, "background")
190+ property Item backgroundImage: findChild(card, "backgroundImage")
174191
175192 function initTestCase() {
176193 verify(typeof testCase.header === "object", "Couldn't find header object.");
177194 verify(typeof testCase.art === "object", "Couldn't find art object.");
178195 verify(typeof testCase.artImage === "object", "Couldn't find artImage object.");
179196 verify(typeof testCase.summary === "object", "Couldn't find summary object.");
197+ verify(typeof testCase.artImage === "object", "Couldn't find background object.");
198+ verify(typeof testCase.summary === "object", "Couldn't find backgroundImage object.");
180199 }
181200
182201 function cleanup() {
@@ -356,6 +375,46 @@ Rectangle {
356375 compare(testCase.art.width, 0);
357376 }
358377
378+ function test_background_data() {
379+ return [
380+ { tag: "Art and summary", visible: true, color: "#ffffff", index: 0 },
381+ { tag: "No Summary", visible: false, index: 6 },
382+ { tag: "Horizontal", visible: false, index: 5 },
383+ { tag: "Grey background", visible: true, color: "#808080", index: 10 },
384+ { tag: "Overriden Gradient background", visible: true, color: "#808080", gradientColor: "#ffffff",
385+ background: {type: "color", elements: ["grey", "white"]}, index: 10 },
386+ { tag: "Overriden Image background", visible: true, image: Qt.resolvedUrl("artwork/checkers.png"),
387+ background: Qt.resolvedUrl("artwork/checkers.png"), index: 10 },
388+ { tag: "Gradient background", visible: true, color: "#808080", gradientColor: "#ffffff", index: 11 },
389+ { tag: "Image background", visible: true, image: Qt.resolvedUrl("artwork/checkers.png"), index: 12 },
390+ ];
391+ }
392+
393+ function test_background(data) {
394+ selector.selectedIndex = data.index;
395+
396+ if (data.hasOwnProperty("background")) {
397+ card.cardData["background"] = data.background;
398+ card.cardDataChanged();
399+ }
400+
401+ waitForRendering(card);
402+
403+ tryCompare(background, "visible", data.visible);
404+
405+ if (data.hasOwnProperty("color")) {
406+ tryCompare(background, "color", data.color);
407+ }
408+
409+ if (data.hasOwnProperty("gradientColor")) {
410+ tryCompare(background, "gradientColor", data.gradientColor);
411+ }
412+
413+ if (data.hasOwnProperty("image")) {
414+ tryCompare(backgroundImage, "source", data.image);
415+ }
416+ }
417+
359418 function test_font_weights_data() {
360419 return [
361420 { tag: "Title only", index: 8, weight: Font.Normal },