Merge lp:~aacid/ubuntu-ui-toolkit/noBiggerIcons into lp:ubuntu-ui-toolkit/staging

Proposed by Albert Astals Cid on 2015-02-19
Status: Merged
Approved by: Zsombor Egri on 2015-02-20
Approved revision: 1415
Merged at revision: 1415
Proposed branch: lp:~aacid/ubuntu-ui-toolkit/noBiggerIcons
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 53 lines (+8/-5)
2 files modified
modules/Ubuntu/Components/plugin/unitythemeiconprovider.cpp (+5/-2)
tests/unit_x11/tst_iconprovider/tst_iconprovider.cpp (+3/-3)
To merge this branch: bzr merge lp:~aacid/ubuntu-ui-toolkit/noBiggerIcons
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-02-20
Zsombor Egri (community) 2015-02-19 Approve on 2015-02-20
Review via email: mp+250320@code.launchpad.net

Commit Message

IconProvider: Make sure icons fit in the given size

Unless one of the sizes is <= 0 which means "give me the size you want"

To post a comment you must log in.
Zsombor Egri (zsombi) wrote :

Good stuff, thanks!

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/plugin/unitythemeiconprovider.cpp'
2--- modules/Ubuntu/Components/plugin/unitythemeiconprovider.cpp 2015-02-18 12:18:02 +0000
3+++ modules/Ubuntu/Components/plugin/unitythemeiconprovider.cpp 2015-02-19 14:58:52 +0000
4@@ -125,16 +125,19 @@
5 {
6 QPixmap pixmap;
7
8+ const bool anyZero = size.width() <= 0 || size.height() <= 0;
9+ const Qt::AspectRatioMode scaleMode = anyZero ? Qt::KeepAspectRatioByExpanding : Qt::KeepAspectRatio;
10+
11 if (filename.endsWith(".png")) {
12 pixmap = QPixmap(filename);
13 if (!pixmap.isNull() && !size.isNull() && (pixmap.width() != size.width() || pixmap.height() != size.height())) {
14- const QSize newSize = pixmap.size().scaled(size.width(), size.height(), Qt::KeepAspectRatioByExpanding);
15+ const QSize newSize = pixmap.size().scaled(size.width(), size.height(), scaleMode);
16 pixmap = pixmap.scaled(newSize);
17 }
18 }
19 else if (filename.endsWith(".svg")) {
20 QSvgRenderer renderer(filename);
21- pixmap = QPixmap(renderer.defaultSize().scaled(size.width(), size.height(), Qt::KeepAspectRatioByExpanding));
22+ pixmap = QPixmap(renderer.defaultSize().scaled(size.width(), size.height(), scaleMode));
23 pixmap.fill(Qt::transparent);
24 QPainter painter(&pixmap);
25 renderer.render(&painter);
26
27=== modified file 'tests/unit_x11/tst_iconprovider/tst_iconprovider.cpp'
28--- tests/unit_x11/tst_iconprovider/tst_iconprovider.cpp 2015-02-18 12:14:47 +0000
29+++ tests/unit_x11/tst_iconprovider/tst_iconprovider.cpp 2015-02-19 14:58:52 +0000
30@@ -39,13 +39,13 @@
31 QTest::addColumn<QSize>("requestSize");
32 QTest::addColumn<QSize>("resultSize");
33
34- QTest::newRow("battery0") << "battery-100-charging" << QSize(-1, -1) << QSize(395, 256);
35+ QTest::newRow("battery0") << "battery-100-charging" << QSize(-1, -1) << QSize(256, 165);
36 QTest::newRow("battery1") << "battery-100-charging" << QSize(-1, 16) << QSize(24, 16);
37 QTest::newRow("battery2") << "battery-100-charging" << QSize(16, -1) << QSize(16, 10);
38 QTest::newRow("battery3") << "battery-100-charging" << QSize(0, 16) << QSize(24, 16);
39 QTest::newRow("battery4") << "battery-100-charging" << QSize(16, 0) << QSize(16, 10);
40 QTest::newRow("battery5") << "battery-100-charging" << QSize(24, 16) << QSize(24, 16);
41- QTest::newRow("battery6") << "battery-100-charging" << QSize(24, 24) << QSize(37, 24);
42+ QTest::newRow("battery6") << "battery-100-charging" << QSize(24, 24) << QSize(24, 15);
43 QTest::newRow("battery7") << "battery-100-charging" << QSize(37, 24) << QSize(37, 24);
44
45 QTest::newRow("gallery0") << "gallery-app" << QSize(-1, -1) << QSize(512, 512);
46@@ -53,7 +53,7 @@
47 QTest::newRow("gallery2") << "gallery-app" << QSize(16, -1) << QSize(16, 16);
48 QTest::newRow("gallery3") << "gallery-app" << QSize(0, 16) << QSize(16, 16);
49 QTest::newRow("gallery4") << "gallery-app" << QSize(16, 0) << QSize(16, 16);
50- QTest::newRow("gallery5") << "gallery-app" << QSize(24, 16) << QSize(24, 24);
51+ QTest::newRow("gallery5") << "gallery-app" << QSize(24, 16) << QSize(16, 16);
52 QTest::newRow("gallery6") << "gallery-app" << QSize(24, 24) << QSize(24, 24);
53 }
54

Subscribers

People subscribed via source and target branches