Merge lp:~fboucault/ubuntu-ui-toolkit/dpr_rebase_qt_5.1 into lp:ubuntu-ui-toolkit
- dpr_rebase_qt_5.1
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | Tim Peeters |
Proposed branch: | lp:~fboucault/ubuntu-ui-toolkit/dpr_rebase_qt_5.1 |
Merge into: | lp:ubuntu-ui-toolkit |
Diff against target: |
525 lines (+219/-61) 11 files modified
modules/Ubuntu/Components/Themes/Ambiance/HeaderStyle.qml (+1/-0) modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml (+2/-2) modules/Ubuntu/Components/plugin/shapeitem.cpp (+20/-5) modules/Ubuntu/Components/plugin/ucqquickimageextension.cpp (+42/-4) modules/Ubuntu/Components/plugin/ucscalingimageprovider.cpp (+6/-0) modules/Ubuntu/Components/plugin/ucunits.cpp (+30/-7) modules/Ubuntu/Components/plugin/ucunits.h (+4/-0) modules/Ubuntu/Components/plugin/unitythemeiconprovider.cpp (+5/-2) tests/unit/tst_qquick_image_extension/tst_qquick_image_extension.cpp (+7/-1) tests/unit/tst_scaling_image_provider/tst_scaling_image_provider.cpp (+12/-4) tests/unit/tst_units/tst_units.cpp (+90/-36) |
To merge this branch: | bzr merge lp:~fboucault/ubuntu-ui-toolkit/dpr_rebase_qt_5.1 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Peeters | Needs Resubmitting | ||
PS Jenkins bot | continuous-integration | Approve | |
Zsombor Egri | Pending | ||
Review via email: mp+183762@code.launchpad.net |
Commit message
Change is only enabled for the webbrowser app.
Rebase resolution independence on Qt's infrastructure:
- QPlatformScreen
- QPlatformWindow
Change is only enabled for Qt version >= 5.1 and when qtubuntu is in use.
A 'dp' is now exactly one Qt pixel and a 'gu' is 8 Qt pixels.
devicePixelRatio is set to be GRID_UNIT_PX / 8.
Description of the change
Dmitry Shachnev (mitya57) wrote : | # |
Albert Astals Cid (aacid) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:750
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://
- 751. By Florian Boucault
-
Merged from trunk.
- 752. By Florian Boucault
-
Removed duplicated constant.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:751
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://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:752
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://
- 753. By Florian Boucault
-
Removed useless include.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:753
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://
- 754. By Florian Boucault
-
Do not avoid upscaling.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:754
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://
- 755. By Florian Boucault
-
Icon image provider: convert from device independent pixels to real pixels
- 756. By Florian Boucault
-
Fix BorderImage scaling with a workaround.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:756
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://
- 757. By Florian Boucault
-
Merged from trunk.
- 758. By Florian Boucault
-
Only activate new code path when Qt is at least version 5.1 and we are using qtubuntu.
- 759. By Florian Boucault
-
Removed stray debug.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:757
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://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:759
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://
- 760. By Florian Boucault
-
Merged from trunk
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:760
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://
- 761. By Florian Boucault
-
Also activate useDevicePixelRatio for MIR's qtubuntu.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:761
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://
- 762. By Florian Boucault
-
Removed stray debug.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:762
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://
- 763. By Florian Boucault
-
TabBar: do not rely on sourceSize that uses real pixels.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:763
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://
Zsombor Egri (zsombi) wrote : | # |
25 - height: 0.82*sourceSize
26 + height: units.dp(25)
This may cause the chevron issues on Mir, however we need to check whether it appears on SurfaceFlinger. If it does, the image scaling needs to be revisited.
- 764. By Florian Boucault
-
Made tab bar chevron a bit smaller and prettier.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:764
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://
- 765. By Florian Boucault
-
Only activate devicePixelRatio based scaling for webbrowser-app.
- 766. By Florian Boucault
-
Reverted unwanted change from previous commit.
- 767. By Florian Boucault
-
Also activate devicePixelRatio based scaling for webapps.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:766
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://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:767
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://
Tim Peeters (tpeeters) wrote : | # |
If this MR is still valid, please resubmit it to staging
Unmerged revisions
- 767. By Florian Boucault
-
Also activate devicePixelRatio based scaling for webapps.
- 766. By Florian Boucault
-
Reverted unwanted change from previous commit.
- 765. By Florian Boucault
-
Only activate devicePixelRatio based scaling for webbrowser-app.
- 764. By Florian Boucault
-
Made tab bar chevron a bit smaller and prettier.
- 763. By Florian Boucault
-
TabBar: do not rely on sourceSize that uses real pixels.
- 762. By Florian Boucault
-
Removed stray debug.
- 761. By Florian Boucault
-
Also activate useDevicePixelRatio for MIR's qtubuntu.
- 760. By Florian Boucault
-
Merged from trunk
- 759. By Florian Boucault
-
Removed stray debug.
- 758. By Florian Boucault
-
Only activate new code path when Qt is at least version 5.1 and we are using qtubuntu.
Preview Diff
1 | === modified file 'modules/Ubuntu/Components/Themes/Ambiance/HeaderStyle.qml' | |||
2 | --- modules/Ubuntu/Components/Themes/Ambiance/HeaderStyle.qml 2014-01-08 16:32:38 +0000 | |||
3 | +++ modules/Ubuntu/Components/Themes/Ambiance/HeaderStyle.qml 2014-03-10 17:18:58 +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/Themes/Ambiance/TabBarStyle.qml' | |||
14 | --- modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml 2014-02-26 18:29:40 +0000 | |||
15 | +++ modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml 2014-03-10 17:18:58 +0000 | |||
16 | @@ -162,11 +162,11 @@ | |||
17 | 162 | source: indicatorImageSource | 162 | source: indicatorImageSource |
18 | 163 | anchors { | 163 | anchors { |
19 | 164 | bottom: parent.bottom | 164 | bottom: parent.bottom |
21 | 165 | bottomMargin: headerTextBottomMargin | 165 | bottomMargin: headerTextBottomMargin - units.dp(3) |
22 | 166 | } | 166 | } |
23 | 167 | x: button.width - width | 167 | x: button.width - width |
24 | 168 | // FIXME: temporary hack for the chevron's height to match the font size | 168 | // FIXME: temporary hack for the chevron's height to match the font size |
26 | 169 | height: 0.82*sourceSize.height | 169 | height: units.dp(20) |
27 | 170 | 170 | ||
28 | 171 | // The indicator image must be visible after the selected tab button, when the | 171 | // The indicator image must be visible after the selected tab button, when the |
29 | 172 | // tab bar is not in selection mode, or after the "last" button (starting with | 172 | // tab bar is not in selection mode, or after the "last" button (starting with |
30 | 173 | 173 | ||
31 | === modified file 'modules/Ubuntu/Components/plugin/shapeitem.cpp' | |||
32 | --- modules/Ubuntu/Components/plugin/shapeitem.cpp 2013-11-22 19:21:34 +0000 | |||
33 | +++ modules/Ubuntu/Components/plugin/shapeitem.cpp 2014-03-10 17:18:58 +0000 | |||
34 | @@ -146,8 +146,13 @@ | |||
35 | 146 | setFlag(ItemHasContents); | 146 | setFlag(ItemHasContents); |
36 | 147 | QObject::connect(&UCUnits::instance(), SIGNAL(gridUnitChanged()), this, | 147 | QObject::connect(&UCUnits::instance(), SIGNAL(gridUnitChanged()), this, |
37 | 148 | SLOT(gridUnitChanged())); | 148 | SLOT(gridUnitChanged())); |
40 | 149 | setImplicitWidth(8 * gridUnit_); | 149 | if (UCUnits::useDevicePixelRatio) { |
41 | 150 | setImplicitHeight(8 * gridUnit_); | 150 | setImplicitWidth(8 * DEFAULT_GRID_UNIT_PX); |
42 | 151 | setImplicitHeight(8 * DEFAULT_GRID_UNIT_PX); | ||
43 | 152 | } else { | ||
44 | 153 | setImplicitWidth(8 * gridUnit_); | ||
45 | 154 | setImplicitHeight(8 * gridUnit_); | ||
46 | 155 | } | ||
47 | 151 | update(); | 156 | update(); |
48 | 152 | } | 157 | } |
49 | 153 | 158 | ||
50 | @@ -324,8 +329,13 @@ | |||
51 | 324 | void ShapeItem::gridUnitChanged() | 329 | void ShapeItem::gridUnitChanged() |
52 | 325 | { | 330 | { |
53 | 326 | gridUnit_ = UCUnits::instance().gridUnit(); | 331 | gridUnit_ = UCUnits::instance().gridUnit(); |
56 | 327 | setImplicitWidth(8 * gridUnit_); | 332 | if (UCUnits::useDevicePixelRatio) { |
57 | 328 | setImplicitHeight(8 * gridUnit_); | 333 | setImplicitWidth(8 * DEFAULT_GRID_UNIT_PX); |
58 | 334 | setImplicitHeight(8 * DEFAULT_GRID_UNIT_PX); | ||
59 | 335 | } else { | ||
60 | 336 | setImplicitWidth(8 * gridUnit_); | ||
61 | 337 | setImplicitHeight(8 * gridUnit_); | ||
62 | 338 | } | ||
63 | 329 | dirtyFlags_ |= ShapeItem::DirtyGridUnit; | 339 | dirtyFlags_ |= ShapeItem::DirtyGridUnit; |
64 | 330 | update(); | 340 | update(); |
65 | 331 | } | 341 | } |
66 | @@ -390,7 +400,12 @@ | |||
67 | 390 | // is less than 2 radii, the radius is scaled down anyhow. | 400 | // is less than 2 radii, the radius is scaled down anyhow. |
68 | 391 | float radius = (radius_ == ShapeItem::SmallRadius) ? | 401 | float radius = (radius_ == ShapeItem::SmallRadius) ? |
69 | 392 | textureData->smallRadius : textureData->mediumRadius; | 402 | textureData->smallRadius : textureData->mediumRadius; |
71 | 393 | const float scaleFactor = gridUnit_ / textureData->gridUnit; | 403 | float scaleFactor; |
72 | 404 | if (UCUnits::useDevicePixelRatio) { | ||
73 | 405 | scaleFactor = DEFAULT_GRID_UNIT_PX / textureData->gridUnit; | ||
74 | 406 | } else { | ||
75 | 407 | scaleFactor = gridUnit_ / textureData->gridUnit; | ||
76 | 408 | } | ||
77 | 394 | radius *= scaleFactor; | 409 | radius *= scaleFactor; |
78 | 395 | int scaledDown = 0; | 410 | int scaledDown = 0; |
79 | 396 | if (scaleFactor != 1.0f) { | 411 | if (scaleFactor != 1.0f) { |
80 | 397 | 412 | ||
81 | === modified file 'modules/Ubuntu/Components/plugin/ucqquickimageextension.cpp' | |||
82 | --- modules/Ubuntu/Components/plugin/ucqquickimageextension.cpp 2013-10-18 08:56:39 +0000 | |||
83 | +++ modules/Ubuntu/Components/plugin/ucqquickimageextension.cpp 2014-03-10 17:18:58 +0000 | |||
84 | @@ -75,15 +75,16 @@ | |||
85 | 75 | QString scaleFactor = resolved.left(separatorPosition); | 75 | QString scaleFactor = resolved.left(separatorPosition); |
86 | 76 | QString selectedFilePath = resolved.mid(separatorPosition+1); | 76 | QString selectedFilePath = resolved.mid(separatorPosition+1); |
87 | 77 | 77 | ||
92 | 78 | if (scaleFactor == "1") { | 78 | if (UCUnits::useDevicePixelRatio) { |
89 | 79 | // No scaling. Just pass the file as is. | ||
90 | 80 | m_image->setSource(QUrl::fromLocalFile(selectedFilePath)); | ||
91 | 81 | } else { | ||
93 | 82 | // Prepend "image://scaling" for the image to be loaded by UCScalingImageProvider. | 79 | // Prepend "image://scaling" for the image to be loaded by UCScalingImageProvider. |
94 | 83 | if (!m_source.path().endsWith(".sci")) { | 80 | if (!m_source.path().endsWith(".sci")) { |
95 | 84 | // Regular image file | 81 | // Regular image file |
96 | 85 | m_image->setSource(QUrl("image://scaling/" + resolved)); | 82 | m_image->setSource(QUrl("image://scaling/" + resolved)); |
97 | 86 | } else { | 83 | } else { |
98 | 84 | /* FIXME: workaround for https://bugreports.qt-project.org/browse/QTBUG-37206 */ | ||
99 | 85 | float windowPixelRatio = UCUnits::instance().gridUnit() / DEFAULT_GRID_UNIT_PX; | ||
100 | 86 | scaleFactor = QString::number(scaleFactor.toFloat() / windowPixelRatio); | ||
101 | 87 | |||
102 | 87 | // .sci image file. Rewrite the .sci file into a temporary file. | 88 | // .sci image file. Rewrite the .sci file into a temporary file. |
103 | 88 | bool rewritten = true; | 89 | bool rewritten = true; |
104 | 89 | QTemporaryFile* rewrittenSciFile; | 90 | QTemporaryFile* rewrittenSciFile; |
105 | @@ -110,6 +111,43 @@ | |||
106 | 110 | m_image->setSource(m_source); | 111 | m_image->setSource(m_source); |
107 | 111 | } | 112 | } |
108 | 112 | } | 113 | } |
109 | 114 | } else { | ||
110 | 115 | if (scaleFactor == "1") { | ||
111 | 116 | // No scaling. Just pass the file as is. | ||
112 | 117 | m_image->setSource(QUrl::fromLocalFile(selectedFilePath)); | ||
113 | 118 | } else { | ||
114 | 119 | // Prepend "image://scaling" for the image to be loaded by UCScalingImageProvider. | ||
115 | 120 | if (!m_source.path().endsWith(".sci")) { | ||
116 | 121 | // Regular image file | ||
117 | 122 | m_image->setSource(QUrl("image://scaling/" + resolved)); | ||
118 | 123 | } else { | ||
119 | 124 | // .sci image file. Rewrite the .sci file into a temporary file. | ||
120 | 125 | bool rewritten = true; | ||
121 | 126 | QTemporaryFile* rewrittenSciFile; | ||
122 | 127 | |||
123 | 128 | /* Ensure that only one temporary rewritten .sci file is created | ||
124 | 129 | for each source .sci file by storing the path to the temporary | ||
125 | 130 | file in a global hash. | ||
126 | 131 | */ | ||
127 | 132 | rewrittenSciFile = UCQQuickImageExtension::s_rewrittenSciFiles.value(m_source).data(); | ||
128 | 133 | if (rewrittenSciFile == NULL) { | ||
129 | 134 | rewrittenSciFile = new QTemporaryFile; | ||
130 | 135 | rewrittenSciFile->setFileTemplate(QDir::tempPath() + QDir::separator() + "XXXXXX.sci"); | ||
131 | 136 | rewrittenSciFile->open(); | ||
132 | 137 | QTextStream output(rewrittenSciFile); | ||
133 | 138 | rewritten = rewriteSciFile(selectedFilePath, scaleFactor, output); | ||
134 | 139 | rewrittenSciFile->close(); | ||
135 | 140 | |||
136 | 141 | s_rewrittenSciFiles.insert(m_source, QSharedPointer<QTemporaryFile>(rewrittenSciFile)); | ||
137 | 142 | } | ||
138 | 143 | |||
139 | 144 | if (rewritten) { | ||
140 | 145 | m_image->setSource(QUrl::fromLocalFile(rewrittenSciFile->fileName())); | ||
141 | 146 | } else { | ||
142 | 147 | m_image->setSource(m_source); | ||
143 | 148 | } | ||
144 | 149 | } | ||
145 | 150 | } | ||
146 | 113 | } | 151 | } |
147 | 114 | } | 152 | } |
148 | 115 | 153 | ||
149 | 116 | 154 | ||
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 2014-03-10 17:18:58 +0000 | |||
153 | @@ -17,6 +17,7 @@ | |||
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 | @@ -65,6 +66,11 @@ | |||
162 | 65 | 66 | ||
163 | 66 | imageReader.read(&image); | 67 | imageReader.read(&image); |
164 | 67 | *size = scaledSize; | 68 | *size = scaledSize; |
165 | 69 | |||
166 | 70 | if (UCUnits::useDevicePixelRatio) { | ||
167 | 71 | float windowPixelRatio = UCUnits::instance().gridUnit() / DEFAULT_GRID_UNIT_PX; | ||
168 | 72 | image.setDevicePixelRatio(windowPixelRatio); | ||
169 | 73 | } | ||
170 | 68 | return image; | 74 | return image; |
171 | 69 | } else { | 75 | } else { |
172 | 70 | return QImage(); | 76 | return QImage(); |
173 | 71 | 77 | ||
174 | === modified file 'modules/Ubuntu/Components/plugin/ucunits.cpp' | |||
175 | --- modules/Ubuntu/Components/plugin/ucunits.cpp 2013-10-18 08:56:39 +0000 | |||
176 | +++ modules/Ubuntu/Components/plugin/ucunits.cpp 2014-03-10 17:18:58 +0000 | |||
177 | @@ -24,9 +24,11 @@ | |||
178 | 24 | #include <QtCore/QDir> | 24 | #include <QtCore/QDir> |
179 | 25 | #include <QtCore/QRegularExpression> | 25 | #include <QtCore/QRegularExpression> |
180 | 26 | #include <QtCore/qmath.h> | 26 | #include <QtCore/qmath.h> |
181 | 27 | #include <QtCore/QDebug> | ||
182 | 28 | #include <QtGui/QGuiApplication> | ||
183 | 29 | #include <QtCore/QCoreApplication> | ||
184 | 27 | 30 | ||
185 | 28 | #define ENV_GRID_UNIT_PX "GRID_UNIT_PX" | 31 | #define ENV_GRID_UNIT_PX "GRID_UNIT_PX" |
186 | 29 | #define DEFAULT_GRID_UNIT_PX 8 | ||
187 | 30 | 32 | ||
188 | 31 | static float getenvFloat(const char* name, float defaultValue) | 33 | static float getenvFloat(const char* name, float defaultValue) |
189 | 32 | { | 34 | { |
190 | @@ -36,6 +38,12 @@ | |||
191 | 36 | return ok ? value : defaultValue; | 38 | return ok ? value : defaultValue; |
192 | 37 | } | 39 | } |
193 | 38 | 40 | ||
194 | 41 | bool UCUnits::useDevicePixelRatio = (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) && | ||
195 | 42 | (QGuiApplication::platformName() == "ubuntu" || | ||
196 | 43 | QGuiApplication::platformName() == "ubuntumirserver" || | ||
197 | 44 | QGuiApplication::platformName() == "ubuntumirclient") && | ||
198 | 45 | (QCoreApplication::applicationName() == "webbrowser-app" || | ||
199 | 46 | QCoreApplication::applicationName() == "webapp-container"); | ||
200 | 39 | 47 | ||
201 | 40 | /*! | 48 | /*! |
202 | 41 | \qmltype Units | 49 | \qmltype Units |
203 | @@ -80,6 +88,13 @@ | |||
204 | 80 | 88 | ||
205 | 81 | void UCUnits::setGridUnit(float gridUnit) | 89 | void UCUnits::setGridUnit(float gridUnit) |
206 | 82 | { | 90 | { |
207 | 91 | /* Implementation of resolution independence is spread accross | ||
208 | 92 | the toolkit and qtubuntu. The number of pixels for a grid unit | ||
209 | 93 | is read by both from the environment variable GRID_UNIT_PX. | ||
210 | 94 | Setting the 'gridUnit' property here has no effect. | ||
211 | 95 | */ | ||
212 | 96 | qWarning() << "UCUnits::setGridUnit is deprecated."; | ||
213 | 97 | |||
214 | 83 | m_gridUnit = gridUnit; | 98 | m_gridUnit = gridUnit; |
215 | 84 | Q_EMIT gridUnitChanged(); | 99 | Q_EMIT gridUnitChanged(); |
216 | 85 | } | 100 | } |
217 | @@ -91,12 +106,16 @@ | |||
218 | 91 | */ | 106 | */ |
219 | 92 | float UCUnits::dp(float value) | 107 | float UCUnits::dp(float value) |
220 | 93 | { | 108 | { |
225 | 94 | const float ratio = m_gridUnit / DEFAULT_GRID_UNIT_PX; | 109 | if (UCUnits::useDevicePixelRatio) { |
226 | 95 | if (value <= 2.0) { | 110 | return qRound(value); |
223 | 96 | // for values under 2dp, return only multiples of the value | ||
224 | 97 | return qRound(value * qFloor(ratio)); | ||
227 | 98 | } else { | 111 | } else { |
229 | 99 | return qRound(value * ratio); | 112 | const float ratio = m_gridUnit / DEFAULT_GRID_UNIT_PX; |
230 | 113 | if (value <= 2.0) { | ||
231 | 114 | // for values under 2dp, return only multiples of the value | ||
232 | 115 | return qRound(value * qFloor(ratio)); | ||
233 | 116 | } else { | ||
234 | 117 | return qRound(value * ratio); | ||
235 | 118 | } | ||
236 | 100 | } | 119 | } |
237 | 101 | } | 120 | } |
238 | 102 | 121 | ||
239 | @@ -107,7 +126,11 @@ | |||
240 | 107 | */ | 126 | */ |
241 | 108 | float UCUnits::gu(float value) | 127 | float UCUnits::gu(float value) |
242 | 109 | { | 128 | { |
244 | 110 | return qRound(value * m_gridUnit); | 129 | if (UCUnits::useDevicePixelRatio) { |
245 | 130 | return qRound(value * DEFAULT_GRID_UNIT_PX); | ||
246 | 131 | } else { | ||
247 | 132 | return qRound(value * m_gridUnit); | ||
248 | 133 | } | ||
249 | 111 | } | 134 | } |
250 | 112 | 135 | ||
251 | 113 | QString UCUnits::resolveResource(const QUrl& url) | 136 | QString UCUnits::resolveResource(const QUrl& url) |
252 | 114 | 137 | ||
253 | === modified file 'modules/Ubuntu/Components/plugin/ucunits.h' | |||
254 | --- modules/Ubuntu/Components/plugin/ucunits.h 2013-10-18 08:56:39 +0000 | |||
255 | +++ modules/Ubuntu/Components/plugin/ucunits.h 2014-03-10 17:18:58 +0000 | |||
256 | @@ -23,6 +23,8 @@ | |||
257 | 23 | #include <QtCore/QHash> | 23 | #include <QtCore/QHash> |
258 | 24 | #include <QtCore/QUrl> | 24 | #include <QtCore/QUrl> |
259 | 25 | 25 | ||
260 | 26 | #define DEFAULT_GRID_UNIT_PX 8 | ||
261 | 27 | |||
262 | 26 | class UCUnits : public QObject | 28 | class UCUnits : public QObject |
263 | 27 | { | 29 | { |
264 | 28 | Q_OBJECT | 30 | Q_OBJECT |
265 | @@ -45,6 +47,8 @@ | |||
266 | 45 | // setters | 47 | // setters |
267 | 46 | void setGridUnit(float gridUnit); | 48 | void setGridUnit(float gridUnit); |
268 | 47 | 49 | ||
269 | 50 | static bool useDevicePixelRatio; | ||
270 | 51 | |||
271 | 48 | Q_SIGNALS: | 52 | Q_SIGNALS: |
272 | 49 | void gridUnitChanged(); | 53 | void gridUnitChanged(); |
273 | 50 | 54 | ||
274 | 51 | 55 | ||
275 | === modified file 'modules/Ubuntu/Components/plugin/unitythemeiconprovider.cpp' | |||
276 | --- modules/Ubuntu/Components/plugin/unitythemeiconprovider.cpp 2014-02-24 18:20:43 +0000 | |||
277 | +++ modules/Ubuntu/Components/plugin/unitythemeiconprovider.cpp 2014-03-10 17:18:58 +0000 | |||
278 | @@ -17,6 +17,7 @@ | |||
279 | 17 | */ | 17 | */ |
280 | 18 | 18 | ||
281 | 19 | #include "unitythemeiconprovider.h" | 19 | #include "unitythemeiconprovider.h" |
282 | 20 | #include "ucunits.h" | ||
283 | 20 | 21 | ||
284 | 21 | #include <QIcon> | 22 | #include <QIcon> |
285 | 22 | 23 | ||
286 | @@ -34,8 +35,10 @@ | |||
287 | 34 | icon = QIcon::fromTheme(name); | 35 | icon = QIcon::fromTheme(name); |
288 | 35 | if (!icon.isNull()) { | 36 | if (!icon.isNull()) { |
289 | 36 | if (requestedSize.isValid()) { | 37 | if (requestedSize.isValid()) { |
292 | 37 | *realSize =requestedSize; | 38 | /* Convert from device independent pixels to pixels into actual pixels */ |
293 | 38 | return icon.pixmap(requestedSize); | 39 | float windowPixelRatio = UCUnits::instance().gridUnit() / DEFAULT_GRID_UNIT_PX; |
294 | 40 | *realSize = requestedSize * windowPixelRatio; | ||
295 | 41 | return icon.pixmap(*realSize); | ||
296 | 39 | } else { | 42 | } else { |
297 | 40 | QList<QSize> sizes = icon.availableSizes(); | 43 | QList<QSize> sizes = icon.availableSizes(); |
298 | 41 | if (sizes.count() > 0 && sizes.last().isValid()) { | 44 | if (sizes.count() > 0 && sizes.last().isValid()) { |
299 | 42 | 45 | ||
300 | === modified file 'tests/unit/tst_qquick_image_extension/tst_qquick_image_extension.cpp' | |||
301 | --- tests/unit/tst_qquick_image_extension/tst_qquick_image_extension.cpp 2013-05-06 16:33:54 +0000 | |||
302 | +++ tests/unit/tst_qquick_image_extension/tst_qquick_image_extension.cpp 2014-03-10 17:18:58 +0000 | |||
303 | @@ -18,6 +18,7 @@ | |||
304 | 18 | 18 | ||
305 | 19 | #include <QtTest/QtTest> | 19 | #include <QtTest/QtTest> |
306 | 20 | #include <QtQuick/private/qquickimagebase_p.h> | 20 | #include <QtQuick/private/qquickimagebase_p.h> |
307 | 21 | #include "ucunits.h" | ||
308 | 21 | 22 | ||
309 | 22 | // Make protected methods of QQuickImageExtension public in order to test them | 23 | // Make protected methods of QQuickImageExtension public in order to test them |
310 | 23 | #define protected public | 24 | #define protected public |
311 | @@ -55,7 +56,12 @@ | |||
312 | 55 | void scaledBorderDouble() { | 56 | void scaledBorderDouble() { |
313 | 56 | UCQQuickImageExtension image; | 57 | UCQQuickImageExtension image; |
314 | 57 | QString border = "border: 13"; | 58 | QString border = "border: 13"; |
316 | 58 | QString expected = "border: 26"; | 59 | QString expected; |
317 | 60 | if (UCUnits::useDevicePixelRatio) { | ||
318 | 61 | expected = "border: 13"; | ||
319 | 62 | } else { | ||
320 | 63 | expected = "border: 26"; | ||
321 | 64 | } | ||
322 | 59 | QString result = image.scaledBorder(border, "2"); | 65 | QString result = image.scaledBorder(border, "2"); |
323 | 60 | QCOMPARE(result, expected); | 66 | QCOMPARE(result, expected); |
324 | 61 | } | 67 | } |
325 | 62 | 68 | ||
326 | === modified file 'tests/unit/tst_scaling_image_provider/tst_scaling_image_provider.cpp' | |||
327 | --- tests/unit/tst_scaling_image_provider/tst_scaling_image_provider.cpp 2013-04-20 00:39:40 +0000 | |||
328 | +++ tests/unit/tst_scaling_image_provider/tst_scaling_image_provider.cpp 2014-03-10 17:18:58 +0000 | |||
329 | @@ -18,6 +18,7 @@ | |||
330 | 18 | 18 | ||
331 | 19 | #include <QtTest/QtTest> | 19 | #include <QtTest/QtTest> |
332 | 20 | #include "ucscalingimageprovider.h" | 20 | #include "ucscalingimageprovider.h" |
333 | 21 | #include "ucunits.h" | ||
334 | 21 | 22 | ||
335 | 22 | class tst_UCScalingImageProvider: public QObject | 23 | class tst_UCScalingImageProvider: public QObject |
336 | 23 | { | 24 | { |
337 | @@ -67,10 +68,17 @@ | |||
338 | 67 | QTest::newRow("downscaling, smaller width") << inputFile << "0.5" << QSize(50, 1000) << QSize(64, 128) << QSize(50, 100); | 68 | QTest::newRow("downscaling, smaller width") << inputFile << "0.5" << QSize(50, 1000) << QSize(64, 128) << QSize(50, 100); |
339 | 68 | QTest::newRow("downscaling, smaller height") << inputFile << "0.5" << QSize(1000, 50) << QSize(64, 128) << QSize(25, 50); | 69 | QTest::newRow("downscaling, smaller height") << inputFile << "0.5" << QSize(1000, 50) << QSize(64, 128) << QSize(25, 50); |
340 | 69 | QTest::newRow("downscaling, smaller width and height")<< inputFile << "0.5" << QSize(50, 50) << QSize(64, 128) << QSize(25, 50); | 70 | QTest::newRow("downscaling, smaller width and height")<< inputFile << "0.5" << QSize(50, 50) << QSize(64, 128) << QSize(25, 50); |
345 | 70 | QTest::newRow("upscaling, bigger width and height") << inputFile << "2.0" << QSize(1000, 1000) << QSize(256, 512) << QSize(256, 512); | 71 | if (UCUnits::useDevicePixelRatio) { |
346 | 71 | QTest::newRow("upscaling, smaller width") << inputFile << "2.0" << QSize(50, 1000) << QSize(256, 512) << QSize(50, 100); | 72 | QTest::newRow("upscaling, bigger width and height") << inputFile << "2.0" << QSize(1000, 1000) << QSize(128, 256) << QSize(128, 256); |
347 | 72 | QTest::newRow("upscaling, smaller height") << inputFile << "2.0" << QSize(1000, 50) << QSize(256, 512) << QSize(25, 50); | 73 | QTest::newRow("upscaling, smaller width") << inputFile << "2.0" << QSize(50, 1000) << QSize(128, 256) << QSize(50, 100); |
348 | 73 | QTest::newRow("upscaling, smaller width and height") << inputFile << "2.0" << QSize(50, 50) << QSize(256, 512) << QSize(25, 50); | 74 | QTest::newRow("upscaling, smaller height") << inputFile << "2.0" << QSize(1000, 50) << QSize(128, 256) << QSize(25, 50); |
349 | 75 | QTest::newRow("upscaling, smaller width and height") << inputFile << "2.0" << QSize(50, 50) << QSize(128, 256) << QSize(25, 50); | ||
350 | 76 | } else { | ||
351 | 77 | QTest::newRow("upscaling, bigger width and height") << inputFile << "2.0" << QSize(1000, 1000) << QSize(256, 512) << QSize(256, 512); | ||
352 | 78 | QTest::newRow("upscaling, smaller width") << inputFile << "2.0" << QSize(50, 1000) << QSize(256, 512) << QSize(50, 100); | ||
353 | 79 | QTest::newRow("upscaling, smaller height") << inputFile << "2.0" << QSize(1000, 50) << QSize(256, 512) << QSize(25, 50); | ||
354 | 80 | QTest::newRow("upscaling, smaller width and height") << inputFile << "2.0" << QSize(50, 50) << QSize(256, 512) << QSize(25, 50); | ||
355 | 81 | } | ||
356 | 74 | } | 82 | } |
357 | 75 | 83 | ||
358 | 76 | void respectRequestedSize() { | 84 | void respectRequestedSize() { |
359 | 77 | 85 | ||
360 | === modified file 'tests/unit/tst_units/tst_units.cpp' | |||
361 | --- tests/unit/tst_units/tst_units.cpp 2013-02-05 17:10:20 +0000 | |||
362 | +++ tests/unit/tst_units/tst_units.cpp 2014-03-10 17:18:58 +0000 | |||
363 | @@ -85,72 +85,126 @@ | |||
364 | 85 | QCOMPARE(units.dp(0.23), 0.0f); | 85 | QCOMPARE(units.dp(0.23), 0.0f); |
365 | 86 | QCOMPARE(units.dp(0.51), 1.0f); | 86 | QCOMPARE(units.dp(0.51), 1.0f); |
366 | 87 | QCOMPARE(units.dp(0.9999), 1.0f); | 87 | QCOMPARE(units.dp(0.9999), 1.0f); |
368 | 88 | QCOMPARE(units.dp(1000.01), 1250.0f); | 88 | if (UCUnits::useDevicePixelRatio) { |
369 | 89 | QCOMPARE(units.dp(1000.01), 1000.0f); | ||
370 | 90 | } else { | ||
371 | 91 | QCOMPARE(units.dp(1000.01), 1250.0f); | ||
372 | 92 | } | ||
373 | 89 | } | 93 | } |
374 | 90 | 94 | ||
375 | 91 | void guGridUnitTen() { | 95 | void guGridUnitTen() { |
376 | 92 | UCUnits units; | 96 | UCUnits units; |
377 | 93 | units.setGridUnit(10); | 97 | units.setGridUnit(10); |
378 | 94 | 98 | ||
386 | 95 | QCOMPARE(units.gu(0.5), 5.0f); | 99 | if (UCUnits::useDevicePixelRatio) { |
387 | 96 | QCOMPARE(units.gu(1), 10.0f); | 100 | QCOMPARE(units.gu(0.5), 4.0f); |
388 | 97 | QCOMPARE(units.gu(1.5), 15.0f); | 101 | QCOMPARE(units.gu(1), 8.0f); |
389 | 98 | QCOMPARE(units.gu(2), 20.0f); | 102 | QCOMPARE(units.gu(1.5), 12.0f); |
390 | 99 | QCOMPARE(units.gu(4), 40.0f); | 103 | QCOMPARE(units.gu(2), 16.0f); |
391 | 100 | QCOMPARE(units.gu(100000), 1000000.0f); | 104 | QCOMPARE(units.gu(4), 32.0f); |
392 | 101 | QCOMPARE(units.gu(150.51983), 1505.0f); | 105 | QCOMPARE(units.gu(100000), 800000.0f); |
393 | 106 | QCOMPARE(units.gu(150.51983), 1204.0f); | ||
394 | 107 | } else { | ||
395 | 108 | QCOMPARE(units.gu(0.5), 5.0f); | ||
396 | 109 | QCOMPARE(units.gu(1), 10.0f); | ||
397 | 110 | QCOMPARE(units.gu(1.5), 15.0f); | ||
398 | 111 | QCOMPARE(units.gu(2), 20.0f); | ||
399 | 112 | QCOMPARE(units.gu(4), 40.0f); | ||
400 | 113 | QCOMPARE(units.gu(100000), 1000000.0f); | ||
401 | 114 | QCOMPARE(units.gu(150.51983), 1505.0f); | ||
402 | 115 | } | ||
403 | 102 | } | 116 | } |
404 | 103 | 117 | ||
405 | 104 | void dpGridUnitSixteen() { | 118 | void dpGridUnitSixteen() { |
406 | 105 | UCUnits units; | 119 | UCUnits units; |
407 | 106 | units.setGridUnit(16); | 120 | units.setGridUnit(16); |
408 | 107 | 121 | ||
416 | 108 | QCOMPARE(units.dp(1.0), 2.0f); | 122 | if (UCUnits::useDevicePixelRatio) { |
417 | 109 | QCOMPARE(units.dp(1.32), 3.0f); | 123 | QCOMPARE(units.dp(1.0), 1.0f); |
418 | 110 | QCOMPARE(units.dp(1.72), 3.0f); | 124 | QCOMPARE(units.dp(1.32), 1.0f); |
419 | 111 | QCOMPARE(units.dp(0.23), 0.0f); | 125 | QCOMPARE(units.dp(1.72), 2.0f); |
420 | 112 | QCOMPARE(units.dp(0.51), 1.0f); | 126 | QCOMPARE(units.dp(0.23), 0.0f); |
421 | 113 | QCOMPARE(units.dp(0.9999), 2.0f); | 127 | QCOMPARE(units.dp(0.51), 1.0f); |
422 | 114 | QCOMPARE(units.dp(1000.01), 2000.0f); | 128 | QCOMPARE(units.dp(0.9999), 1.0f); |
423 | 129 | QCOMPARE(units.dp(1000.01), 1000.0f); | ||
424 | 130 | } else { | ||
425 | 131 | QCOMPARE(units.dp(1.0), 2.0f); | ||
426 | 132 | QCOMPARE(units.dp(1.32), 3.0f); | ||
427 | 133 | QCOMPARE(units.dp(1.72), 3.0f); | ||
428 | 134 | QCOMPARE(units.dp(0.23), 0.0f); | ||
429 | 135 | QCOMPARE(units.dp(0.51), 1.0f); | ||
430 | 136 | QCOMPARE(units.dp(0.9999), 2.0f); | ||
431 | 137 | QCOMPARE(units.dp(1000.01), 2000.0f); | ||
432 | 138 | } | ||
433 | 115 | } | 139 | } |
434 | 116 | 140 | ||
435 | 117 | void guGridUnitSixteen() { | 141 | void guGridUnitSixteen() { |
436 | 118 | UCUnits units; | 142 | UCUnits units; |
437 | 119 | units.setGridUnit(16); | 143 | units.setGridUnit(16); |
438 | 120 | 144 | ||
446 | 121 | QCOMPARE(units.gu(0.5), 8.0f); | 145 | if (UCUnits::useDevicePixelRatio) { |
447 | 122 | QCOMPARE(units.gu(1), 16.0f); | 146 | QCOMPARE(units.gu(0.5), 4.0f); |
448 | 123 | QCOMPARE(units.gu(1.5), 24.0f); | 147 | QCOMPARE(units.gu(1), 8.0f); |
449 | 124 | QCOMPARE(units.gu(2), 32.0f); | 148 | QCOMPARE(units.gu(1.5), 12.0f); |
450 | 125 | QCOMPARE(units.gu(4), 64.0f); | 149 | QCOMPARE(units.gu(2), 16.0f); |
451 | 126 | QCOMPARE(units.gu(100000), 1600000.0f); | 150 | QCOMPARE(units.gu(4), 32.0f); |
452 | 127 | QCOMPARE(units.gu(150.51983), 2408.0f); | 151 | QCOMPARE(units.gu(100000), 800000.0f); |
453 | 152 | QCOMPARE(units.gu(150.51983), 1204.0f); | ||
454 | 153 | } else { | ||
455 | 154 | QCOMPARE(units.gu(0.5), 8.0f); | ||
456 | 155 | QCOMPARE(units.gu(1), 16.0f); | ||
457 | 156 | QCOMPARE(units.gu(1.5), 24.0f); | ||
458 | 157 | QCOMPARE(units.gu(2), 32.0f); | ||
459 | 158 | QCOMPARE(units.gu(4), 64.0f); | ||
460 | 159 | QCOMPARE(units.gu(100000), 1600000.0f); | ||
461 | 160 | QCOMPARE(units.gu(150.51983), 2408.0f); | ||
462 | 161 | } | ||
463 | 128 | } | 162 | } |
464 | 129 | 163 | ||
465 | 130 | void dpGridUnitEighteen() { | 164 | void dpGridUnitEighteen() { |
466 | 131 | UCUnits units; | 165 | UCUnits units; |
467 | 132 | units.setGridUnit(18); | 166 | units.setGridUnit(18); |
468 | 133 | 167 | ||
476 | 134 | QCOMPARE(units.dp(1.0), 2.0f); | 168 | if (UCUnits::useDevicePixelRatio) { |
477 | 135 | QCOMPARE(units.dp(1.32), 3.0f); | 169 | QCOMPARE(units.dp(1.0), 1.0f); |
478 | 136 | QCOMPARE(units.dp(1.72), 3.0f); | 170 | QCOMPARE(units.dp(1.32), 1.0f); |
479 | 137 | QCOMPARE(units.dp(0.23), 0.0f); | 171 | QCOMPARE(units.dp(1.72), 2.0f); |
480 | 138 | QCOMPARE(units.dp(0.51), 1.0f); | 172 | QCOMPARE(units.dp(0.23), 0.0f); |
481 | 139 | QCOMPARE(units.dp(0.9999), 2.0f); | 173 | QCOMPARE(units.dp(0.51), 1.0f); |
482 | 140 | QCOMPARE(units.dp(1000.01), 2250.0f); | 174 | QCOMPARE(units.dp(0.9999), 1.0f); |
483 | 175 | QCOMPARE(units.dp(1000.01), 1000.0f); | ||
484 | 176 | } else { | ||
485 | 177 | QCOMPARE(units.dp(1.0), 2.0f); | ||
486 | 178 | QCOMPARE(units.dp(1.32), 3.0f); | ||
487 | 179 | QCOMPARE(units.dp(1.72), 3.0f); | ||
488 | 180 | QCOMPARE(units.dp(0.23), 0.0f); | ||
489 | 181 | QCOMPARE(units.dp(0.51), 1.0f); | ||
490 | 182 | QCOMPARE(units.dp(0.9999), 2.0f); | ||
491 | 183 | QCOMPARE(units.dp(1000.01), 2250.0f); | ||
492 | 184 | } | ||
493 | 141 | } | 185 | } |
494 | 142 | 186 | ||
495 | 143 | void dpGridUnitTwenty() { | 187 | void dpGridUnitTwenty() { |
496 | 144 | UCUnits units; | 188 | UCUnits units; |
497 | 145 | units.setGridUnit(20); | 189 | units.setGridUnit(20); |
498 | 146 | 190 | ||
506 | 147 | QCOMPARE(units.dp(1.0), 2.0f); | 191 | if (UCUnits::useDevicePixelRatio) { |
507 | 148 | QCOMPARE(units.dp(1.32), 3.0f); | 192 | QCOMPARE(units.dp(1.0), 1.0f); |
508 | 149 | QCOMPARE(units.dp(1.72), 3.0f); | 193 | QCOMPARE(units.dp(1.32), 1.0f); |
509 | 150 | QCOMPARE(units.dp(0.23), 0.0f); | 194 | QCOMPARE(units.dp(1.72), 2.0f); |
510 | 151 | QCOMPARE(units.dp(0.51), 1.0f); | 195 | QCOMPARE(units.dp(0.23), 0.0f); |
511 | 152 | QCOMPARE(units.dp(0.9999), 2.0f); | 196 | QCOMPARE(units.dp(0.51), 1.0f); |
512 | 153 | QCOMPARE(units.dp(1000.01), 2500.0f); | 197 | QCOMPARE(units.dp(0.9999), 1.0f); |
513 | 198 | QCOMPARE(units.dp(1000.01), 1000.0f); | ||
514 | 199 | } else { | ||
515 | 200 | QCOMPARE(units.dp(1.0), 2.0f); | ||
516 | 201 | QCOMPARE(units.dp(1.32), 3.0f); | ||
517 | 202 | QCOMPARE(units.dp(1.72), 3.0f); | ||
518 | 203 | QCOMPARE(units.dp(0.23), 0.0f); | ||
519 | 204 | QCOMPARE(units.dp(0.51), 1.0f); | ||
520 | 205 | QCOMPARE(units.dp(0.9999), 2.0f); | ||
521 | 206 | QCOMPARE(units.dp(1000.01), 2500.0f); | ||
522 | 207 | } | ||
523 | 154 | } | 208 | } |
524 | 155 | 209 | ||
525 | 156 | void resolveEmpty() { | 210 | void resolveEmpty() { |
The tests currently fail here:
FAIL! : qmltestrunner: :UCUnitsAPI: :test_gu( ) can use units.gu dmitry/ tests/ubuntu- ui-toolkit/ tests/unit/ tst_components/ tst_plugin_ ucunits. qml(40) ]
Actual (): 8
Expected (): 9
Loc: [/home/