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

Proposed by Albert Astals Cid
Status: Merged
Approved by: Cris Dywan
Approved revision: 1253
Merged at revision: 1256
Proposed branch: lp:~aacid/ubuntu-ui-toolkit/scaling_image_provider_respect_one_requested_size_zero
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 33 lines (+11/-1)
2 files modified
modules/Ubuntu/Components/plugin/ucscalingimageprovider.cpp (+9/-1)
tests/unit/tst_scaling_image_provider/tst_scaling_image_provider.cpp (+2/-0)
To merge this branch: bzr merge lp:~aacid/ubuntu-ui-toolkit/scaling_image_provider_respect_one_requested_size_zero
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Cris Dywan Approve
Review via email: mp+235098@code.launchpad.net

Commit message

Make the scaling provider respect requestedSizes with one of the values 0

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

Looks sensible.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
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/ucscalingimageprovider.cpp'
2--- modules/Ubuntu/Components/plugin/ucscalingimageprovider.cpp 2013-04-20 01:14:43 +0000
3+++ modules/Ubuntu/Components/plugin/ucscalingimageprovider.cpp 2014-09-18 09:35:38 +0000
4@@ -54,7 +54,15 @@
5 scaledSize = realSize * scaleFactor;
6 }
7 if (requestedSize.isValid() && (requestedSize.width() < realSize.width() || requestedSize.height() < realSize.height())) {
8- constrainedSize = scaledSize.scaled(requestedSize, Qt::KeepAspectRatio);
9+ if (requestedSize.width() > 0 && requestedSize.height() == 0 && scaledSize.width() > 0) {
10+ constrainedSize.setWidth(requestedSize.width());
11+ constrainedSize.setHeight(scaledSize.height() * requestedSize.width() / scaledSize.width());
12+ } else if (requestedSize.height() > 0 && requestedSize.width() == 0 && scaledSize.height() > 0) {
13+ constrainedSize.setHeight(requestedSize.height());
14+ constrainedSize.setWidth(scaledSize.width() * requestedSize.height() / scaledSize.height());
15+ } else {
16+ constrainedSize = scaledSize.scaled(requestedSize, Qt::KeepAspectRatio);
17+ }
18 }
19
20 if (constrainedSize.isValid()) {
21
22=== modified file 'tests/unit/tst_scaling_image_provider/tst_scaling_image_provider.cpp'
23--- tests/unit/tst_scaling_image_provider/tst_scaling_image_provider.cpp 2013-04-20 00:39:40 +0000
24+++ tests/unit/tst_scaling_image_provider/tst_scaling_image_provider.cpp 2014-09-18 09:35:38 +0000
25@@ -71,6 +71,8 @@
26 QTest::newRow("upscaling, smaller width") << inputFile << "2.0" << QSize(50, 1000) << QSize(256, 512) << QSize(50, 100);
27 QTest::newRow("upscaling, smaller height") << inputFile << "2.0" << QSize(1000, 50) << QSize(256, 512) << QSize(25, 50);
28 QTest::newRow("upscaling, smaller width and height") << inputFile << "2.0" << QSize(50, 50) << QSize(256, 512) << QSize(25, 50);
29+ QTest::newRow("upscaling, smaller width and no height") << inputFile << "2.0" << QSize(50, 0) << QSize(256, 512) << QSize(50, 100);
30+ QTest::newRow("upscaling, smaller height and no width") << inputFile << "2.0" << QSize(0, 50) << QSize(256, 512) << QSize(25, 50);
31 }
32
33 void respectRequestedSize() {

Subscribers

People subscribed via source and target branches