Merge lp:~aacid/ubuntu-ui-toolkit/dpr_rebase_qt_5.1_with_ifdefs into lp:ubuntu-ui-toolkit
- dpr_rebase_qt_5.1_with_ifdefs
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | Florian Boucault |
Proposed branch: | lp:~aacid/ubuntu-ui-toolkit/dpr_rebase_qt_5.1_with_ifdefs |
Merge into: | lp:ubuntu-ui-toolkit |
Diff against target: |
449 lines (+172/-7) 9 files modified
modules/Ubuntu/Components/Themes/Ambiance/HeaderStyle.qml (+1/-0) modules/Ubuntu/Components/plugin/shapeitem.cpp (+17/-0) modules/Ubuntu/Components/plugin/ucqquickimageextension.cpp (+47/-3) modules/Ubuntu/Components/plugin/ucscalingimageprovider.cpp (+20/-0) modules/Ubuntu/Components/plugin/ucunits.cpp (+17/-1) modules/Ubuntu/Components/plugin/ucunits.h (+2/-0) tests/unit/tst_qquick_image_extension/tst_qquick_image_extension.cpp (+4/-0) tests/unit/tst_scaling_image_provider/tst_scaling_image_provider.cpp (+10/-3) tests/unit/tst_units/tst_units.cpp (+54/-0) |
To merge this branch: | bzr merge lp:~aacid/ubuntu-ui-toolkit/dpr_rebase_qt_5.1_with_ifdefs |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Ubuntu SDK team | Pending | ||
Review via email: mp+196253@code.launchpad.net |
Commit message
Rebase resolution independence on Qt's infrastructure:
- QPlatformScreen
- QPlatformWindow
Description of the change
Albert Astals Cid (aacid) wrote : | # |
Albert Astals Cid (aacid) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:749
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Florian Boucault (fboucault) wrote : | # |
Unmerged revisions
- 749. By Albert Astals Cid
-
Forgot this ifdef
- 748. By Albert Astals Cid
-
Add ifdefs for simultaneous 5.0 and 5.1/2 compilation
- 747. By Albert Astals Cid
-
Merge
- 746. By Florian Boucault
-
Merged trunk
- 745. By Florian Boucault
-
Merged trunk
- 744. By Florian Boucault
-
Merged from trunk
- 743. By Florian Boucault
-
Rebase resolution independence on Qt's infrastructure:
- QPlatformScreen::devicePixelRa tio
- QPlatformWindow::devicePixelRa tio
Preview Diff
1 | === modified file 'modules/Ubuntu/Components/Themes/Ambiance/HeaderStyle.qml' | |||
2 | --- modules/Ubuntu/Components/Themes/Ambiance/HeaderStyle.qml 2013-11-12 06:41:24 +0000 | |||
3 | +++ modules/Ubuntu/Components/Themes/Ambiance/HeaderStyle.qml 2013-11-22 10:29:14 +0000 | |||
4 | @@ -50,6 +50,7 @@ | |||
5 | 50 | left: parent.left | 50 | left: parent.left |
6 | 51 | right: parent.right | 51 | right: parent.right |
7 | 52 | } | 52 | } |
8 | 53 | height: units.dp(15) | ||
9 | 53 | source: headerStyle.separatorSource | 54 | source: headerStyle.separatorSource |
10 | 54 | } | 55 | } |
11 | 55 | Image { | 56 | Image { |
12 | 56 | 57 | ||
13 | === modified file 'modules/Ubuntu/Components/plugin/shapeitem.cpp' | |||
14 | --- modules/Ubuntu/Components/plugin/shapeitem.cpp 2013-10-18 08:56:39 +0000 | |||
15 | +++ modules/Ubuntu/Components/plugin/shapeitem.cpp 2013-11-22 10:29:14 +0000 | |||
16 | @@ -31,6 +31,9 @@ | |||
17 | 31 | 31 | ||
18 | 32 | // Threshold in grid unit defining the texture quality to be used. | 32 | // Threshold in grid unit defining the texture quality to be used. |
19 | 33 | const float lowHighTextureThreshold = 11.0f; | 33 | const float lowHighTextureThreshold = 11.0f; |
20 | 34 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
21 | 35 | const float defaultGridUnit = 8.0f; | ||
22 | 36 | #endif | ||
23 | 34 | 37 | ||
24 | 35 | static const char* const shapeVertexShader = | 38 | static const char* const shapeVertexShader = |
25 | 36 | "uniform lowp mat4 matrix; \n" | 39 | "uniform lowp mat4 matrix; \n" |
26 | @@ -146,8 +149,13 @@ | |||
27 | 146 | setFlag(ItemHasContents); | 149 | setFlag(ItemHasContents); |
28 | 147 | QObject::connect(&UCUnits::instance(), SIGNAL(gridUnitChanged()), this, | 150 | QObject::connect(&UCUnits::instance(), SIGNAL(gridUnitChanged()), this, |
29 | 148 | SLOT(gridUnitChanged())); | 151 | SLOT(gridUnitChanged())); |
30 | 152 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
31 | 153 | setImplicitWidth(8 * defaultGridUnit); | ||
32 | 154 | setImplicitHeight(8 * defaultGridUnit); | ||
33 | 155 | #else | ||
34 | 149 | setImplicitWidth(8 * gridUnit_); | 156 | setImplicitWidth(8 * gridUnit_); |
35 | 150 | setImplicitHeight(8 * gridUnit_); | 157 | setImplicitHeight(8 * gridUnit_); |
36 | 158 | #endif | ||
37 | 151 | update(); | 159 | update(); |
38 | 152 | } | 160 | } |
39 | 153 | 161 | ||
40 | @@ -324,8 +332,13 @@ | |||
41 | 324 | void ShapeItem::gridUnitChanged() | 332 | void ShapeItem::gridUnitChanged() |
42 | 325 | { | 333 | { |
43 | 326 | gridUnit_ = UCUnits::instance().gridUnit(); | 334 | gridUnit_ = UCUnits::instance().gridUnit(); |
44 | 335 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
45 | 336 | setImplicitWidth(8 * defaultGridUnit); | ||
46 | 337 | setImplicitHeight(8 * defaultGridUnit); | ||
47 | 338 | #else | ||
48 | 327 | setImplicitWidth(8 * gridUnit_); | 339 | setImplicitWidth(8 * gridUnit_); |
49 | 328 | setImplicitHeight(8 * gridUnit_); | 340 | setImplicitHeight(8 * gridUnit_); |
50 | 341 | #endif | ||
51 | 329 | dirtyFlags_ |= ShapeItem::DirtyGridUnit; | 342 | dirtyFlags_ |= ShapeItem::DirtyGridUnit; |
52 | 330 | update(); | 343 | update(); |
53 | 331 | } | 344 | } |
54 | @@ -390,7 +403,11 @@ | |||
55 | 390 | // is less than 2 radii, the radius is scaled down anyhow. | 403 | // is less than 2 radii, the radius is scaled down anyhow. |
56 | 391 | float radius = (radius_ == ShapeItem::SmallRadius) ? | 404 | float radius = (radius_ == ShapeItem::SmallRadius) ? |
57 | 392 | textureData->smallRadius : textureData->mediumRadius; | 405 | textureData->smallRadius : textureData->mediumRadius; |
58 | 406 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
59 | 407 | const float scaleFactor = defaultGridUnit / textureData->gridUnit; | ||
60 | 408 | #else | ||
61 | 393 | const float scaleFactor = gridUnit_ / textureData->gridUnit; | 409 | const float scaleFactor = gridUnit_ / textureData->gridUnit; |
62 | 410 | #endif | ||
63 | 394 | radius *= scaleFactor; | 411 | radius *= scaleFactor; |
64 | 395 | int scaledDown = 0; | 412 | int scaledDown = 0; |
65 | 396 | if (scaleFactor != 1.0f) { | 413 | if (scaleFactor != 1.0f) { |
66 | 397 | 414 | ||
67 | === modified file 'modules/Ubuntu/Components/plugin/ucqquickimageextension.cpp' | |||
68 | --- modules/Ubuntu/Components/plugin/ucqquickimageextension.cpp 2013-10-18 08:56:39 +0000 | |||
69 | +++ modules/Ubuntu/Components/plugin/ucqquickimageextension.cpp 2013-11-22 10:29:14 +0000 | |||
70 | @@ -75,6 +75,39 @@ | |||
71 | 75 | QString scaleFactor = resolved.left(separatorPosition); | 75 | QString scaleFactor = resolved.left(separatorPosition); |
72 | 76 | QString selectedFilePath = resolved.mid(separatorPosition+1); | 76 | QString selectedFilePath = resolved.mid(separatorPosition+1); |
73 | 77 | 77 | ||
74 | 78 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
75 | 79 | // Prepend "image://scaling" for the image to be loaded by UCScalingImageProvider. | ||
76 | 80 | if (!m_source.path().endsWith(".sci")) { | ||
77 | 81 | // Regular image file | ||
78 | 82 | m_image->setSource(QUrl("image://scaling/" + resolved)); | ||
79 | 83 | } else { | ||
80 | 84 | // .sci image file. Rewrite the .sci file into a temporary file. | ||
81 | 85 | bool rewritten = true; | ||
82 | 86 | QTemporaryFile* rewrittenSciFile; | ||
83 | 87 | |||
84 | 88 | /* Ensure that only one temporary rewritten .sci file is created | ||
85 | 89 | for each source .sci file by storing the path to the temporary | ||
86 | 90 | file in a global hash. | ||
87 | 91 | */ | ||
88 | 92 | rewrittenSciFile = UCQQuickImageExtension::s_rewrittenSciFiles.value(m_source).data(); | ||
89 | 93 | if (rewrittenSciFile == NULL) { | ||
90 | 94 | rewrittenSciFile = new QTemporaryFile; | ||
91 | 95 | rewrittenSciFile->setFileTemplate(QDir::tempPath() + QDir::separator() + "XXXXXX.sci"); | ||
92 | 96 | rewrittenSciFile->open(); | ||
93 | 97 | QTextStream output(rewrittenSciFile); | ||
94 | 98 | rewritten = rewriteSciFile(selectedFilePath, scaleFactor, output); | ||
95 | 99 | rewrittenSciFile->close(); | ||
96 | 100 | |||
97 | 101 | s_rewrittenSciFiles.insert(m_source, QSharedPointer<QTemporaryFile>(rewrittenSciFile)); | ||
98 | 102 | } | ||
99 | 103 | |||
100 | 104 | if (rewritten) { | ||
101 | 105 | m_image->setSource(QUrl::fromLocalFile(rewrittenSciFile->fileName())); | ||
102 | 106 | } else { | ||
103 | 107 | m_image->setSource(m_source); | ||
104 | 108 | } | ||
105 | 109 | } | ||
106 | 110 | #else | ||
107 | 78 | if (scaleFactor == "1") { | 111 | if (scaleFactor == "1") { |
108 | 79 | // No scaling. Just pass the file as is. | 112 | // No scaling. Just pass the file as is. |
109 | 80 | m_image->setSource(QUrl::fromLocalFile(selectedFilePath)); | 113 | m_image->setSource(QUrl::fromLocalFile(selectedFilePath)); |
110 | @@ -89,8 +122,8 @@ | |||
111 | 89 | QTemporaryFile* rewrittenSciFile; | 122 | QTemporaryFile* rewrittenSciFile; |
112 | 90 | 123 | ||
113 | 91 | /* Ensure that only one temporary rewritten .sci file is created | 124 | /* Ensure that only one temporary rewritten .sci file is created |
116 | 92 | for each source .sci file by storing the path to the temporary | 125 | for each source .sci file by storing the path to the temporary |
117 | 93 | file in a global hash. | 126 | file in a global hash. |
118 | 94 | */ | 127 | */ |
119 | 95 | rewrittenSciFile = UCQQuickImageExtension::s_rewrittenSciFiles.value(m_source).data(); | 128 | rewrittenSciFile = UCQQuickImageExtension::s_rewrittenSciFiles.value(m_source).data(); |
120 | 96 | if (rewrittenSciFile == NULL) { | 129 | if (rewrittenSciFile == NULL) { |
121 | @@ -111,6 +144,7 @@ | |||
122 | 111 | } | 144 | } |
123 | 112 | } | 145 | } |
124 | 113 | } | 146 | } |
125 | 147 | #endif | ||
126 | 114 | } | 148 | } |
127 | 115 | 149 | ||
128 | 116 | bool UCQQuickImageExtension::rewriteSciFile(const QString &sciFilePath, const QString &scaleFactor, QTextStream& output) | 150 | bool UCQQuickImageExtension::rewriteSciFile(const QString &sciFilePath, const QString &scaleFactor, QTextStream& output) |
129 | @@ -137,8 +171,18 @@ | |||
130 | 137 | QString UCQQuickImageExtension::scaledBorder(const QString &border, const QString &scaleFactor) | 171 | QString UCQQuickImageExtension::scaledBorder(const QString &border, const QString &scaleFactor) |
131 | 138 | { | 172 | { |
132 | 139 | // Rewrite the border line with a scaled border value | 173 | // Rewrite the border line with a scaled border value |
133 | 174 | float scaledValue; | ||
134 | 140 | QStringList parts = border.split(":"); | 175 | QStringList parts = border.split(":"); |
136 | 141 | float scaledValue = parts[1].toFloat() * scaleFactor.toFloat(); | 176 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) |
137 | 177 | if (scaleFactor.toFloat() < 1.0) { | ||
138 | 178 | scaledValue = parts[1].toFloat() * scaleFactor.toFloat(); | ||
139 | 179 | } else { | ||
140 | 180 | // match the behaviour of UCScalingImageProvider and do not upscale | ||
141 | 181 | scaledValue = parts[1].toFloat(); | ||
142 | 182 | } | ||
143 | 183 | #else | ||
144 | 184 | scaledValue = parts[1].toFloat() * scaleFactor.toFloat(); | ||
145 | 185 | #endif | ||
146 | 142 | return parts[0] + ": " + QString::number(qRound(scaledValue)); | 186 | return parts[0] + ": " + QString::number(qRound(scaledValue)); |
147 | 143 | } | 187 | } |
148 | 144 | 188 | ||
149 | 145 | 189 | ||
150 | === modified file 'modules/Ubuntu/Components/plugin/ucscalingimageprovider.cpp' | |||
151 | --- modules/Ubuntu/Components/plugin/ucscalingimageprovider.cpp 2013-04-20 01:14:43 +0000 | |||
152 | +++ modules/Ubuntu/Components/plugin/ucscalingimageprovider.cpp 2013-11-22 10:29:14 +0000 | |||
153 | @@ -17,9 +17,11 @@ | |||
154 | 17 | */ | 17 | */ |
155 | 18 | 18 | ||
156 | 19 | #include "ucscalingimageprovider.h" | 19 | #include "ucscalingimageprovider.h" |
157 | 20 | #include "ucunits.h" | ||
158 | 20 | 21 | ||
159 | 21 | #include <QtCore/QFile> | 22 | #include <QtCore/QFile> |
160 | 22 | #include <QtGui/QImageReader> | 23 | #include <QtGui/QImageReader> |
161 | 24 | #include <QtCore/QDebug> | ||
162 | 23 | 25 | ||
163 | 24 | /*! | 26 | /*! |
164 | 25 | \internal | 27 | \internal |
165 | @@ -29,6 +31,10 @@ | |||
166 | 29 | - 'scale' is the scaling factor applied to the image | 31 | - 'scale' is the scaling factor applied to the image |
167 | 30 | - 'path' is the full path of the image on the filesystem | 32 | - 'path' is the full path of the image on the filesystem |
168 | 31 | 33 | ||
169 | 34 | If the scaling factor is bigger than 1.0 then do not scale: UCScalingImageProvider | ||
170 | 35 | never upscales but instead set the devicePixelRatio appropriately so that upscaling | ||
171 | 36 | is done in the GPU. | ||
172 | 37 | |||
173 | 32 | Example: | 38 | Example: |
174 | 33 | * image://scaling/0.5/arrow.png | 39 | * image://scaling/0.5/arrow.png |
175 | 34 | */ | 40 | */ |
176 | @@ -50,7 +56,11 @@ | |||
177 | 50 | QSize scaledSize = realSize; | 56 | QSize scaledSize = realSize; |
178 | 51 | QSize constrainedSize; | 57 | QSize constrainedSize; |
179 | 52 | 58 | ||
180 | 59 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
181 | 60 | if (!qFuzzyCompare(scaleFactor, (float)1.0) && scaleFactor < 1.0) { | ||
182 | 61 | #else | ||
183 | 53 | if (!qFuzzyCompare(scaleFactor, (float)1.0)) { | 62 | if (!qFuzzyCompare(scaleFactor, (float)1.0)) { |
184 | 63 | #endif | ||
185 | 54 | scaledSize = realSize * scaleFactor; | 64 | scaledSize = realSize * scaleFactor; |
186 | 55 | } | 65 | } |
187 | 56 | if (requestedSize.isValid() && (requestedSize.width() < realSize.width() || requestedSize.height() < realSize.height())) { | 66 | if (requestedSize.isValid() && (requestedSize.width() < realSize.width() || requestedSize.height() < realSize.height())) { |
188 | @@ -65,6 +75,16 @@ | |||
189 | 65 | 75 | ||
190 | 66 | imageReader.read(&image); | 76 | imageReader.read(&image); |
191 | 67 | *size = scaledSize; | 77 | *size = scaledSize; |
192 | 78 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
193 | 79 | float windowPixelRatio = UCUnits::instance().gridUnit() / DEFAULT_GRID_UNIT_PX; | ||
194 | 80 | if (scaleFactor < 1.0) { | ||
195 | 81 | image.setDevicePixelRatio(windowPixelRatio); | ||
196 | 82 | } else { | ||
197 | 83 | /* When image needs to be upscaled, do not upscale it here but set its | ||
198 | 84 | devicePixelRatio appropriately so that upscaling is done when rendering. */ | ||
199 | 85 | image.setDevicePixelRatio(windowPixelRatio / scaleFactor); | ||
200 | 86 | } | ||
201 | 87 | #endif | ||
202 | 68 | return image; | 88 | return image; |
203 | 69 | } else { | 89 | } else { |
204 | 70 | return QImage(); | 90 | return QImage(); |
205 | 71 | 91 | ||
206 | === modified file 'modules/Ubuntu/Components/plugin/ucunits.cpp' | |||
207 | --- modules/Ubuntu/Components/plugin/ucunits.cpp 2013-10-18 08:56:39 +0000 | |||
208 | +++ modules/Ubuntu/Components/plugin/ucunits.cpp 2013-11-22 10:29:14 +0000 | |||
209 | @@ -24,9 +24,9 @@ | |||
210 | 24 | #include <QtCore/QDir> | 24 | #include <QtCore/QDir> |
211 | 25 | #include <QtCore/QRegularExpression> | 25 | #include <QtCore/QRegularExpression> |
212 | 26 | #include <QtCore/qmath.h> | 26 | #include <QtCore/qmath.h> |
213 | 27 | #include <QtCore/QDebug> | ||
214 | 27 | 28 | ||
215 | 28 | #define ENV_GRID_UNIT_PX "GRID_UNIT_PX" | 29 | #define ENV_GRID_UNIT_PX "GRID_UNIT_PX" |
216 | 29 | #define DEFAULT_GRID_UNIT_PX 8 | ||
217 | 30 | 30 | ||
218 | 31 | static float getenvFloat(const char* name, float defaultValue) | 31 | static float getenvFloat(const char* name, float defaultValue) |
219 | 32 | { | 32 | { |
220 | @@ -80,6 +80,14 @@ | |||
221 | 80 | 80 | ||
222 | 81 | void UCUnits::setGridUnit(float gridUnit) | 81 | void UCUnits::setGridUnit(float gridUnit) |
223 | 82 | { | 82 | { |
224 | 83 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
225 | 84 | /* Implementation of resolution independence is spread accross | ||
226 | 85 | the toolkit and qtubuntu. The number of pixels for a grid unit | ||
227 | 86 | is read by both from the environment variable GRID_UNIT_PX. | ||
228 | 87 | Setting the 'gridUnit' property here has no effect. | ||
229 | 88 | */ | ||
230 | 89 | qWarning() << "UCUnits::setGridUnit is deprecated."; | ||
231 | 90 | #endif | ||
232 | 83 | m_gridUnit = gridUnit; | 91 | m_gridUnit = gridUnit; |
233 | 84 | Q_EMIT gridUnitChanged(); | 92 | Q_EMIT gridUnitChanged(); |
234 | 85 | } | 93 | } |
235 | @@ -91,6 +99,9 @@ | |||
236 | 91 | */ | 99 | */ |
237 | 92 | float UCUnits::dp(float value) | 100 | float UCUnits::dp(float value) |
238 | 93 | { | 101 | { |
239 | 102 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
240 | 103 | return qRound(value); | ||
241 | 104 | #else | ||
242 | 94 | const float ratio = m_gridUnit / DEFAULT_GRID_UNIT_PX; | 105 | const float ratio = m_gridUnit / DEFAULT_GRID_UNIT_PX; |
243 | 95 | if (value <= 2.0) { | 106 | if (value <= 2.0) { |
244 | 96 | // for values under 2dp, return only multiples of the value | 107 | // for values under 2dp, return only multiples of the value |
245 | @@ -98,6 +109,7 @@ | |||
246 | 98 | } else { | 109 | } else { |
247 | 99 | return qRound(value * ratio); | 110 | return qRound(value * ratio); |
248 | 100 | } | 111 | } |
249 | 112 | #endif | ||
250 | 101 | } | 113 | } |
251 | 102 | 114 | ||
252 | 103 | /*! | 115 | /*! |
253 | @@ -107,7 +119,11 @@ | |||
254 | 107 | */ | 119 | */ |
255 | 108 | float UCUnits::gu(float value) | 120 | float UCUnits::gu(float value) |
256 | 109 | { | 121 | { |
257 | 122 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
258 | 123 | return qRound(value * DEFAULT_GRID_UNIT_PX); | ||
259 | 124 | #else | ||
260 | 110 | return qRound(value * m_gridUnit); | 125 | return qRound(value * m_gridUnit); |
261 | 126 | #endif | ||
262 | 111 | } | 127 | } |
263 | 112 | 128 | ||
264 | 113 | QString UCUnits::resolveResource(const QUrl& url) | 129 | QString UCUnits::resolveResource(const QUrl& url) |
265 | 114 | 130 | ||
266 | === modified file 'modules/Ubuntu/Components/plugin/ucunits.h' | |||
267 | --- modules/Ubuntu/Components/plugin/ucunits.h 2013-10-18 08:56:39 +0000 | |||
268 | +++ modules/Ubuntu/Components/plugin/ucunits.h 2013-11-22 10:29:14 +0000 | |||
269 | @@ -23,6 +23,8 @@ | |||
270 | 23 | #include <QtCore/QHash> | 23 | #include <QtCore/QHash> |
271 | 24 | #include <QtCore/QUrl> | 24 | #include <QtCore/QUrl> |
272 | 25 | 25 | ||
273 | 26 | #define DEFAULT_GRID_UNIT_PX 8 | ||
274 | 27 | |||
275 | 26 | class UCUnits : public QObject | 28 | class UCUnits : public QObject |
276 | 27 | { | 29 | { |
277 | 28 | Q_OBJECT | 30 | Q_OBJECT |
278 | 29 | 31 | ||
279 | === modified file 'tests/unit/tst_qquick_image_extension/tst_qquick_image_extension.cpp' | |||
280 | --- tests/unit/tst_qquick_image_extension/tst_qquick_image_extension.cpp 2013-05-06 16:33:54 +0000 | |||
281 | +++ tests/unit/tst_qquick_image_extension/tst_qquick_image_extension.cpp 2013-11-22 10:29:14 +0000 | |||
282 | @@ -55,7 +55,11 @@ | |||
283 | 55 | void scaledBorderDouble() { | 55 | void scaledBorderDouble() { |
284 | 56 | UCQQuickImageExtension image; | 56 | UCQQuickImageExtension image; |
285 | 57 | QString border = "border: 13"; | 57 | QString border = "border: 13"; |
286 | 58 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
287 | 59 | QString expected = "border: 13"; | ||
288 | 60 | #else | ||
289 | 58 | QString expected = "border: 26"; | 61 | QString expected = "border: 26"; |
290 | 62 | #endif | ||
291 | 59 | QString result = image.scaledBorder(border, "2"); | 63 | QString result = image.scaledBorder(border, "2"); |
292 | 60 | QCOMPARE(result, expected); | 64 | QCOMPARE(result, expected); |
293 | 61 | } | 65 | } |
294 | 62 | 66 | ||
295 | === modified file 'tests/unit/tst_scaling_image_provider/tst_scaling_image_provider.cpp' | |||
296 | --- tests/unit/tst_scaling_image_provider/tst_scaling_image_provider.cpp 2013-04-20 00:39:40 +0000 | |||
297 | +++ tests/unit/tst_scaling_image_provider/tst_scaling_image_provider.cpp 2013-11-22 10:29:14 +0000 | |||
298 | @@ -67,10 +67,17 @@ | |||
299 | 67 | QTest::newRow("downscaling, smaller width") << inputFile << "0.5" << QSize(50, 1000) << QSize(64, 128) << QSize(50, 100); | 67 | QTest::newRow("downscaling, smaller width") << inputFile << "0.5" << QSize(50, 1000) << QSize(64, 128) << QSize(50, 100); |
300 | 68 | QTest::newRow("downscaling, smaller height") << inputFile << "0.5" << QSize(1000, 50) << QSize(64, 128) << QSize(25, 50); | 68 | QTest::newRow("downscaling, smaller height") << inputFile << "0.5" << QSize(1000, 50) << QSize(64, 128) << QSize(25, 50); |
301 | 69 | QTest::newRow("downscaling, smaller width and height")<< inputFile << "0.5" << QSize(50, 50) << QSize(64, 128) << QSize(25, 50); | 69 | QTest::newRow("downscaling, smaller width and height")<< inputFile << "0.5" << QSize(50, 50) << QSize(64, 128) << QSize(25, 50); |
305 | 70 | QTest::newRow("upscaling, bigger width and height") << inputFile << "2.0" << QSize(1000, 1000) << QSize(256, 512) << QSize(256, 512); | 70 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) |
306 | 71 | QTest::newRow("upscaling, smaller width") << inputFile << "2.0" << QSize(50, 1000) << QSize(256, 512) << QSize(50, 100); | 71 | QTest::newRow("upscaling, bigger width and height") << inputFile << "2.0" << QSize(1000, 1000) << QSize(128, 256) << QSize(128, 256); |
307 | 72 | QTest::newRow("upscaling, smaller height") << inputFile << "2.0" << QSize(1000, 50) << QSize(256, 512) << QSize(25, 50); | 72 | QTest::newRow("upscaling, smaller width") << inputFile << "2.0" << QSize(50, 1000) << QSize(128, 256) << QSize(50, 100); |
308 | 73 | QTest::newRow("upscaling, smaller height") << inputFile << "2.0" << QSize(1000, 50) << QSize(128, 256) << QSize(25, 50); | ||
309 | 74 | QTest::newRow("upscaling, smaller width and height") << inputFile << "2.0" << QSize(50, 50) << QSize(128, 256) << QSize(25, 50); | ||
310 | 75 | #else | ||
311 | 76 | QTest::newRow("upscaling, bigger width and height") << inputFile << "2.0" << QSize(1000, 1000) << QSize(256, 512) << QSize(256, 512); | ||
312 | 77 | QTest::newRow("upscaling, smaller width") << inputFile << "2.0" << QSize(50, 1000) << QSize(256, 512) << QSize(50, 100); | ||
313 | 78 | QTest::newRow("upscaling, smaller height") << inputFile << "2.0" << QSize(1000, 50) << QSize(256, 512) << QSize(25, 50); | ||
314 | 73 | QTest::newRow("upscaling, smaller width and height") << inputFile << "2.0" << QSize(50, 50) << QSize(256, 512) << QSize(25, 50); | 79 | QTest::newRow("upscaling, smaller width and height") << inputFile << "2.0" << QSize(50, 50) << QSize(256, 512) << QSize(25, 50); |
315 | 80 | #endif | ||
316 | 74 | } | 81 | } |
317 | 75 | 82 | ||
318 | 76 | void respectRequestedSize() { | 83 | void respectRequestedSize() { |
319 | 77 | 84 | ||
320 | === modified file 'tests/unit/tst_units/tst_units.cpp' | |||
321 | --- tests/unit/tst_units/tst_units.cpp 2013-02-05 17:10:20 +0000 | |||
322 | +++ tests/unit/tst_units/tst_units.cpp 2013-11-22 10:29:14 +0000 | |||
323 | @@ -85,13 +85,26 @@ | |||
324 | 85 | QCOMPARE(units.dp(0.23), 0.0f); | 85 | QCOMPARE(units.dp(0.23), 0.0f); |
325 | 86 | QCOMPARE(units.dp(0.51), 1.0f); | 86 | QCOMPARE(units.dp(0.51), 1.0f); |
326 | 87 | QCOMPARE(units.dp(0.9999), 1.0f); | 87 | QCOMPARE(units.dp(0.9999), 1.0f); |
327 | 88 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
328 | 89 | QCOMPARE(units.dp(1000.01), 1000.0f); | ||
329 | 90 | #else | ||
330 | 88 | QCOMPARE(units.dp(1000.01), 1250.0f); | 91 | QCOMPARE(units.dp(1000.01), 1250.0f); |
331 | 92 | #endif | ||
332 | 89 | } | 93 | } |
333 | 90 | 94 | ||
334 | 91 | void guGridUnitTen() { | 95 | void guGridUnitTen() { |
335 | 92 | UCUnits units; | 96 | UCUnits units; |
336 | 93 | units.setGridUnit(10); | 97 | units.setGridUnit(10); |
337 | 94 | 98 | ||
338 | 99 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
339 | 100 | QCOMPARE(units.gu(0.5), 4.0f); | ||
340 | 101 | QCOMPARE(units.gu(1), 8.0f); | ||
341 | 102 | QCOMPARE(units.gu(1.5), 12.0f); | ||
342 | 103 | QCOMPARE(units.gu(2), 16.0f); | ||
343 | 104 | QCOMPARE(units.gu(4), 32.0f); | ||
344 | 105 | QCOMPARE(units.gu(100000), 800000.0f); | ||
345 | 106 | QCOMPARE(units.gu(150.51983), 1204.0f); | ||
346 | 107 | #else | ||
347 | 95 | QCOMPARE(units.gu(0.5), 5.0f); | 108 | QCOMPARE(units.gu(0.5), 5.0f); |
348 | 96 | QCOMPARE(units.gu(1), 10.0f); | 109 | QCOMPARE(units.gu(1), 10.0f); |
349 | 97 | QCOMPARE(units.gu(1.5), 15.0f); | 110 | QCOMPARE(units.gu(1.5), 15.0f); |
350 | @@ -99,12 +112,22 @@ | |||
351 | 99 | QCOMPARE(units.gu(4), 40.0f); | 112 | QCOMPARE(units.gu(4), 40.0f); |
352 | 100 | QCOMPARE(units.gu(100000), 1000000.0f); | 113 | QCOMPARE(units.gu(100000), 1000000.0f); |
353 | 101 | QCOMPARE(units.gu(150.51983), 1505.0f); | 114 | QCOMPARE(units.gu(150.51983), 1505.0f); |
354 | 115 | #endif | ||
355 | 102 | } | 116 | } |
356 | 103 | 117 | ||
357 | 104 | void dpGridUnitSixteen() { | 118 | void dpGridUnitSixteen() { |
358 | 105 | UCUnits units; | 119 | UCUnits units; |
359 | 106 | units.setGridUnit(16); | 120 | units.setGridUnit(16); |
360 | 107 | 121 | ||
361 | 122 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
362 | 123 | QCOMPARE(units.dp(1.0), 1.0f); | ||
363 | 124 | QCOMPARE(units.dp(1.32), 1.0f); | ||
364 | 125 | QCOMPARE(units.dp(1.72), 2.0f); | ||
365 | 126 | QCOMPARE(units.dp(0.23), 0.0f); | ||
366 | 127 | QCOMPARE(units.dp(0.51), 1.0f); | ||
367 | 128 | QCOMPARE(units.dp(0.9999), 1.0f); | ||
368 | 129 | QCOMPARE(units.dp(1000.01), 1000.0f); | ||
369 | 130 | #else | ||
370 | 108 | QCOMPARE(units.dp(1.0), 2.0f); | 131 | QCOMPARE(units.dp(1.0), 2.0f); |
371 | 109 | QCOMPARE(units.dp(1.32), 3.0f); | 132 | QCOMPARE(units.dp(1.32), 3.0f); |
372 | 110 | QCOMPARE(units.dp(1.72), 3.0f); | 133 | QCOMPARE(units.dp(1.72), 3.0f); |
373 | @@ -112,12 +135,22 @@ | |||
374 | 112 | QCOMPARE(units.dp(0.51), 1.0f); | 135 | QCOMPARE(units.dp(0.51), 1.0f); |
375 | 113 | QCOMPARE(units.dp(0.9999), 2.0f); | 136 | QCOMPARE(units.dp(0.9999), 2.0f); |
376 | 114 | QCOMPARE(units.dp(1000.01), 2000.0f); | 137 | QCOMPARE(units.dp(1000.01), 2000.0f); |
377 | 138 | #endif | ||
378 | 115 | } | 139 | } |
379 | 116 | 140 | ||
380 | 117 | void guGridUnitSixteen() { | 141 | void guGridUnitSixteen() { |
381 | 118 | UCUnits units; | 142 | UCUnits units; |
382 | 119 | units.setGridUnit(16); | 143 | units.setGridUnit(16); |
383 | 120 | 144 | ||
384 | 145 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
385 | 146 | QCOMPARE(units.gu(0.5), 4.0f); | ||
386 | 147 | QCOMPARE(units.gu(1), 8.0f); | ||
387 | 148 | QCOMPARE(units.gu(1.5), 12.0f); | ||
388 | 149 | QCOMPARE(units.gu(2), 16.0f); | ||
389 | 150 | QCOMPARE(units.gu(4), 32.0f); | ||
390 | 151 | QCOMPARE(units.gu(100000), 800000.0f); | ||
391 | 152 | QCOMPARE(units.gu(150.51983), 1204.0f); | ||
392 | 153 | #else | ||
393 | 121 | QCOMPARE(units.gu(0.5), 8.0f); | 154 | QCOMPARE(units.gu(0.5), 8.0f); |
394 | 122 | QCOMPARE(units.gu(1), 16.0f); | 155 | QCOMPARE(units.gu(1), 16.0f); |
395 | 123 | QCOMPARE(units.gu(1.5), 24.0f); | 156 | QCOMPARE(units.gu(1.5), 24.0f); |
396 | @@ -125,12 +158,22 @@ | |||
397 | 125 | QCOMPARE(units.gu(4), 64.0f); | 158 | QCOMPARE(units.gu(4), 64.0f); |
398 | 126 | QCOMPARE(units.gu(100000), 1600000.0f); | 159 | QCOMPARE(units.gu(100000), 1600000.0f); |
399 | 127 | QCOMPARE(units.gu(150.51983), 2408.0f); | 160 | QCOMPARE(units.gu(150.51983), 2408.0f); |
400 | 161 | #endif | ||
401 | 128 | } | 162 | } |
402 | 129 | 163 | ||
403 | 130 | void dpGridUnitEighteen() { | 164 | void dpGridUnitEighteen() { |
404 | 131 | UCUnits units; | 165 | UCUnits units; |
405 | 132 | units.setGridUnit(18); | 166 | units.setGridUnit(18); |
406 | 133 | 167 | ||
407 | 168 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
408 | 169 | QCOMPARE(units.dp(1.0), 1.0f); | ||
409 | 170 | QCOMPARE(units.dp(1.32), 1.0f); | ||
410 | 171 | QCOMPARE(units.dp(1.72), 2.0f); | ||
411 | 172 | QCOMPARE(units.dp(0.23), 0.0f); | ||
412 | 173 | QCOMPARE(units.dp(0.51), 1.0f); | ||
413 | 174 | QCOMPARE(units.dp(0.9999), 1.0f); | ||
414 | 175 | QCOMPARE(units.dp(1000.01), 1000.0f); | ||
415 | 176 | #else | ||
416 | 134 | QCOMPARE(units.dp(1.0), 2.0f); | 177 | QCOMPARE(units.dp(1.0), 2.0f); |
417 | 135 | QCOMPARE(units.dp(1.32), 3.0f); | 178 | QCOMPARE(units.dp(1.32), 3.0f); |
418 | 136 | QCOMPARE(units.dp(1.72), 3.0f); | 179 | QCOMPARE(units.dp(1.72), 3.0f); |
419 | @@ -138,12 +181,22 @@ | |||
420 | 138 | QCOMPARE(units.dp(0.51), 1.0f); | 181 | QCOMPARE(units.dp(0.51), 1.0f); |
421 | 139 | QCOMPARE(units.dp(0.9999), 2.0f); | 182 | QCOMPARE(units.dp(0.9999), 2.0f); |
422 | 140 | QCOMPARE(units.dp(1000.01), 2250.0f); | 183 | QCOMPARE(units.dp(1000.01), 2250.0f); |
423 | 184 | #endif | ||
424 | 141 | } | 185 | } |
425 | 142 | 186 | ||
426 | 143 | void dpGridUnitTwenty() { | 187 | void dpGridUnitTwenty() { |
427 | 144 | UCUnits units; | 188 | UCUnits units; |
428 | 145 | units.setGridUnit(20); | 189 | units.setGridUnit(20); |
429 | 146 | 190 | ||
430 | 191 | #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) | ||
431 | 192 | QCOMPARE(units.dp(1.0), 1.0f); | ||
432 | 193 | QCOMPARE(units.dp(1.32), 1.0f); | ||
433 | 194 | QCOMPARE(units.dp(1.72), 2.0f); | ||
434 | 195 | QCOMPARE(units.dp(0.23), 0.0f); | ||
435 | 196 | QCOMPARE(units.dp(0.51), 1.0f); | ||
436 | 197 | QCOMPARE(units.dp(0.9999), 1.0f); | ||
437 | 198 | QCOMPARE(units.dp(1000.01), 1000.0f); | ||
438 | 199 | #else | ||
439 | 147 | QCOMPARE(units.dp(1.0), 2.0f); | 200 | QCOMPARE(units.dp(1.0), 2.0f); |
440 | 148 | QCOMPARE(units.dp(1.32), 3.0f); | 201 | QCOMPARE(units.dp(1.32), 3.0f); |
441 | 149 | QCOMPARE(units.dp(1.72), 3.0f); | 202 | QCOMPARE(units.dp(1.72), 3.0f); |
442 | @@ -151,6 +204,7 @@ | |||
443 | 151 | QCOMPARE(units.dp(0.51), 1.0f); | 204 | QCOMPARE(units.dp(0.51), 1.0f); |
444 | 152 | QCOMPARE(units.dp(0.9999), 2.0f); | 205 | QCOMPARE(units.dp(0.9999), 2.0f); |
445 | 153 | QCOMPARE(units.dp(1000.01), 2500.0f); | 206 | QCOMPARE(units.dp(1000.01), 2500.0f); |
446 | 207 | #endif | ||
447 | 154 | } | 208 | } |
448 | 155 | 209 | ||
449 | 156 | void resolveEmpty() { | 210 | void resolveEmpty() { |
Same as https:/ /code.launchpad .net/~fboucault /ubuntu- ui-toolkit/ dpr_rebase_ qt_5.1/ +merge/ 183762 with ifdefs