Merge lp:~dandrader/unity8/cursorGridUnit into lp:unity8

Proposed by Daniel d'Andrada on 2016-07-14
Status: Merged
Approved by: Albert Astals Cid on 2016-07-15
Approved revision: 2544
Merged at revision: 2568
Proposed branch: lp:~dandrader/unity8/cursorGridUnit
Merge into: lp:unity8
Diff against target: 401 lines (+88/-31)
7 files modified
plugins/Cursor/Cursor.qml (+5/-2)
plugins/Cursor/CursorImageInfo.cpp (+21/-1)
plugins/Cursor/CursorImageInfo.h (+10/-0)
plugins/Cursor/CursorImageProvider.cpp (+33/-21)
plugins/Cursor/CursorImageProvider.h (+9/-6)
qml/Shell.qml (+2/-0)
tests/plugins/Cursor/tst_Cursor.qml (+8/-1)
To merge this branch: bzr merge lp:~dandrader/unity8/cursorGridUnit
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Approve on 2016-07-15
Albert Astals Cid (community) 2016-07-14 Approve on 2016-07-15
Review via email: mp+300130@code.launchpad.net

Commit Message

Cursor: make its size grid unit based

So that it scales along with the rest of the UI

Description of the Change

* Are there any related MPs required for this MP to build/function as expected? Please list.
No

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes.

To test apply this patch http://pastebin.ubuntu.com/19413075/
Then use Alt+A and Alt+S to decrease and increase the requested cursor size respectively. You should see 3 different cursor sizes, as DMZ theme (the default ubuntu one) provides only 3 different resolutions of its cursor images.

Applying scaling on top of the bitmap based cursor to get a exact match of the requested size would cause blurriness and other artifacts.

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

* If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2543
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1747/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/2297
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/1225
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/1225
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=qmluitests.sh/1225
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/2325
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2225
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2225
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2225
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2218
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2218/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2218
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2218/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2218
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2218/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2218
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2218/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2218
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2218/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2218
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2218/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2218
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2218/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2218
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2218/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2218
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2218/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1747/rebuild

review: Approve (continuous-integration)
lp:~dandrader/unity8/cursorGridUnit updated on 2016-07-15
2544. By Daniel d'Andrada on 2016-07-15

move imageSource to CursorImageInfo

Albert Astals Cid (aacid) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

 * Did CI run pass?
Yes

review: Approve
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2544
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1752/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/2302
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/1228
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/1228
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=qmluitests.sh/1228
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/2330
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2230
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2230
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2230
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2223
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2223/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2223
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2223/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2223
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2223/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2223
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2223/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2223
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2223/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2223
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2223/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2223
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2223/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2223
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2223/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2223
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2223/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1752/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Cursor/Cursor.qml'
2--- plugins/Cursor/Cursor.qml 2016-06-27 18:42:16 +0000
3+++ plugins/Cursor/Cursor.qml 2016-07-15 14:37:35 +0000
4@@ -25,6 +25,7 @@
5 id: imageInfo
6 themeName: mousePointer.themeName
7 cursorName: mousePointer.cursorName
8+ cursorHeight: mousePointer.height
9 }
10
11 Loader {
12@@ -32,7 +33,7 @@
13 sourceComponent: AnimatedSprite {
14 x: -imageInfo.hotspot.x
15 y: -imageInfo.hotspot.y
16- source: "image://cursor/" + mousePointer.themeName + "/" + mousePointer.cursorName
17+ source: imageInfo.imageSource
18
19 interpolate: false
20
21@@ -53,7 +54,9 @@
22 sourceComponent: Image {
23 x: -imageInfo.hotspot.x
24 y: -imageInfo.hotspot.y
25- source: "image://cursor/" + mousePointer.themeName + "/" + mousePointer.cursorName
26+ source: imageInfo.imageSource
27+ width: sourceSize.width
28+ height: sourceSize.height
29 }
30 }
31 }
32
33=== modified file 'plugins/Cursor/CursorImageInfo.cpp'
34--- plugins/Cursor/CursorImageInfo.cpp 2016-06-09 10:54:24 +0000
35+++ plugins/Cursor/CursorImageInfo.cpp 2016-07-15 14:37:35 +0000
36@@ -28,6 +28,15 @@
37 update();
38 Q_EMIT cursorNameChanged();
39 }
40+
41+}
42+void CursorImageInfo::setCursorHeight(qreal cursorHeight)
43+{
44+ if (cursorHeight != m_cursorHeight) {
45+ m_cursorHeight = cursorHeight;
46+ update();
47+ Q_EMIT cursorHeightChanged();
48+ }
49 }
50
51 void CursorImageInfo::setThemeName(const QString &themeName)
52@@ -41,13 +50,14 @@
53
54 void CursorImageInfo::update()
55 {
56- m_cursorImage = CursorImageProvider::instance()->fetchCursor(m_themeName, m_cursorName);
57+ m_cursorImage = CursorImageProvider::instance()->fetchCursor(m_themeName, m_cursorName, (int) m_cursorHeight);
58
59 Q_EMIT hotspotChanged();
60 Q_EMIT frameWidthChanged();
61 Q_EMIT frameHeightChanged();
62 Q_EMIT frameCountChanged();
63 Q_EMIT frameDurationChanged();
64+ Q_EMIT imageSourceChanged();
65 }
66
67 QPoint CursorImageInfo::hotspot() const
68@@ -94,3 +104,13 @@
69 return 0;
70 }
71 }
72+
73+QUrl CursorImageInfo::imageSource() const
74+{
75+ auto urlString = QString("image://cursor/%1/%2/%3")
76+ .arg(m_themeName)
77+ .arg(m_cursorName)
78+ .arg(m_cursorHeight);
79+
80+ return QUrl(urlString);
81+}
82
83=== modified file 'plugins/Cursor/CursorImageInfo.h'
84--- plugins/Cursor/CursorImageInfo.h 2016-06-09 10:54:24 +0000
85+++ plugins/Cursor/CursorImageInfo.h 2016-07-15 14:37:35 +0000
86@@ -21,6 +21,7 @@
87
88 #include <QObject>
89 #include <QString>
90+#include <QUrl>
91
92 class CursorImageInfo : public QObject
93 {
94@@ -28,12 +29,14 @@
95
96 Q_PROPERTY(QString themeName READ themeName WRITE setThemeName NOTIFY themeNameChanged)
97 Q_PROPERTY(QString cursorName READ cursorName WRITE setCursorName NOTIFY cursorNameChanged)
98+ Q_PROPERTY(qreal cursorHeight READ cursorHeight WRITE setCursorHeight NOTIFY cursorHeightChanged)
99
100 Q_PROPERTY(QPoint hotspot READ hotspot NOTIFY hotspotChanged)
101 Q_PROPERTY(qreal frameWidth READ frameWidth NOTIFY frameWidthChanged)
102 Q_PROPERTY(qreal frameHeight READ frameHeight NOTIFY frameHeightChanged)
103 Q_PROPERTY(int frameCount READ frameCount NOTIFY frameCountChanged)
104 Q_PROPERTY(int frameDuration READ frameDuration NOTIFY frameDurationChanged)
105+ Q_PROPERTY(QUrl imageSource READ imageSource NOTIFY imageSourceChanged)
106
107 public:
108 CursorImageInfo(QObject *parent = nullptr);
109@@ -44,20 +47,26 @@
110 QString cursorName() const { return m_cursorName; }
111 void setCursorName(const QString &);
112
113+ qreal cursorHeight() const { return m_cursorHeight; }
114+ void setCursorHeight(qreal);
115+
116 QPoint hotspot() const;
117 qreal frameWidth() const;
118 qreal frameHeight() const;
119 int frameCount() const;
120 int frameDuration() const;
121+ QUrl imageSource() const;
122
123 Q_SIGNALS:
124 void themeNameChanged();
125 void cursorNameChanged();
126+ void cursorHeightChanged();
127 void hotspotChanged();
128 void frameWidthChanged();
129 void frameHeightChanged();
130 void frameCountChanged();
131 void frameDurationChanged();
132+ void imageSourceChanged();
133
134 private Q_SLOTS:
135 void update();
136@@ -65,6 +74,7 @@
137 private:
138 QString m_themeName;
139 QString m_cursorName;
140+ qreal m_cursorHeight{0};
141
142 CursorImage *m_cursorImage{nullptr};
143 };
144
145=== modified file 'plugins/Cursor/CursorImageProvider.cpp'
146--- plugins/Cursor/CursorImageProvider.cpp 2016-06-06 20:35:02 +0000
147+++ plugins/Cursor/CursorImageProvider.cpp 2016-07-15 14:37:35 +0000
148@@ -27,7 +27,7 @@
149 /////
150 // BuiltInCursorImage
151
152-BuiltInCursorImage::BuiltInCursorImage()
153+BuiltInCursorImage::BuiltInCursorImage(int cursorHeight)
154 {
155 const char *svgString =
156 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"
157@@ -42,12 +42,14 @@
158 " d=\"M 20.504,50.94931 460.42533,518.14486 266.47603,515.61948 366.48114,719.16522 274.05218,770.68296 172.53185,559.56112 20.504,716.13476 Z\" />"
159 "</svg>";
160
161- qimage = QImage(20, 32, QImage::Format_ARGB32);
162+ // NB: Original image dimension is 20x32. Ensure aspect ratio is kept
163+ qimage = QImage((20./32.)*cursorHeight, cursorHeight, QImage::Format_ARGB32);
164 qimage.fill(Qt::transparent);
165 QPainter imagePainter(&qimage);
166
167 frameWidth = qimage.width();
168 frameHeight = qimage.height();
169+ requestedHeight = cursorHeight;
170
171 QSvgRenderer *svgRenderer = new QSvgRenderer(QByteArray(svgString));
172 svgRenderer->render(&imagePainter);
173@@ -81,11 +83,9 @@
174 /////
175 // XCursorImage
176
177-XCursorImage::XCursorImage(const QString &theme, const QString &file)
178+XCursorImage::XCursorImage(const QString &theme, const QString &file, int preferredCursorHeightPx)
179 {
180- // TODO: Consider grid unit value
181- // Hardcoding to a medium size for now
182- int preferredCursorHeightPx = 32;
183+ requestedHeight = preferredCursorHeightPx;
184
185 XcursorImages *xcursorImages = XcursorLibraryLoadImages(QFile::encodeName(file), QFile::encodeName(theme),
186 preferredCursorHeightPx);
187@@ -96,7 +96,7 @@
188 frameCount = xcursorImages->nimage;
189
190 for (int i = 0; i < xcursorImages->nimage; ++i) {
191- XcursorImage *xcursorImage = xcursorImages->images[0];
192+ XcursorImage *xcursorImage = xcursorImages->images[i];
193 if (frameWidth < (int)xcursorImage->width) {
194 frameWidth = xcursorImage->width;
195 }
196@@ -235,34 +235,43 @@
197 m_instance = nullptr;
198 }
199
200-QImage CursorImageProvider::requestImage(const QString &cursorThemeAndName, QSize *size, const QSize & /*requestedSize*/)
201+QImage CursorImageProvider::requestImage(const QString &cursorThemeAndNameAndHeight, QSize *size, const QSize & /*requestedSize*/)
202 {
203- CursorImage *cursorImage = fetchCursor(cursorThemeAndName);
204+ CursorImage *cursorImage = fetchCursor(cursorThemeAndNameAndHeight);
205 size->setWidth(cursorImage->qimage.width());
206 size->setHeight(cursorImage->qimage.height());
207
208 return cursorImage->qimage;
209 }
210
211-CursorImage *CursorImageProvider::fetchCursor(const QString &cursorThemeAndName)
212+CursorImage *CursorImageProvider::fetchCursor(const QString &cursorThemeAndNameAndHeight)
213 {
214 QString themeName;
215 QString cursorName;
216+ int cursorHeight;
217 {
218- QStringList themeAndNameList = cursorThemeAndName.split('/');
219- if (themeAndNameList.size() != 2) {
220+ QStringList themeAndNameList = cursorThemeAndNameAndHeight.split('/');
221+ if (themeAndNameList.size() != 3) {
222 return nullptr;
223 }
224 themeName = themeAndNameList[0];
225 cursorName = themeAndNameList[1];
226+
227+ bool ok;
228+ cursorHeight = themeAndNameList[2].toInt(&ok);
229+ if (!ok) {
230+ cursorHeight = 32;
231+ qWarning().nospace() << "CursorImageProvider: invalid cursor height ("<<themeAndNameList[2]<<")."
232+ " Falling back to "<<cursorHeight<<" pixels";
233+ }
234 }
235
236- return fetchCursor(themeName, cursorName);
237+ return fetchCursor(themeName, cursorName, cursorHeight);
238 }
239
240-CursorImage *CursorImageProvider::fetchCursor(const QString &themeName, const QString &cursorName)
241+CursorImage *CursorImageProvider::fetchCursor(const QString &themeName, const QString &cursorName, int cursorHeight)
242 {
243- CursorImage *cursorImage = fetchCursorHelper(themeName, cursorName);
244+ CursorImage *cursorImage = fetchCursorHelper(themeName, cursorName, cursorHeight);
245
246 // Try some fallbacks
247 if (cursorImage->qimage.isNull()) {
248@@ -271,7 +280,7 @@
249 int i = 0;
250 while (cursorImage->qimage.isNull() && i < fallbackNames.count()) {
251 qDebug().nospace() << "CursorImageProvider: "<< cursorName <<" not found, trying " << fallbackNames.at(i);
252- cursorImage = fetchCursorHelper(themeName, fallbackNames.at(i));
253+ cursorImage = fetchCursorHelper(themeName, fallbackNames.at(i), cursorHeight);
254 ++i;
255 }
256 }
257@@ -281,14 +290,14 @@
258 if (cursorImage->qimage.isNull() && cursorName != QLatin1String("left_ptr")) {
259 qDebug() << "CursorImageProvider:" << cursorName
260 << "not found (nor its fallbacks, if any). Going for \"left_ptr\" as a last resort.";
261- cursorImage = fetchCursorHelper(themeName, QStringLiteral("left_ptr"));
262+ cursorImage = fetchCursorHelper(themeName, QStringLiteral("left_ptr"), cursorHeight);
263 }
264
265 if (cursorImage->qimage.isNull()) {
266 // finally, go for the built-in cursor
267 qWarning() << "CursorImageProvider: couldn't find any cursors. Using the built-in one";
268- if (!m_builtInCursorImage) {
269- m_builtInCursorImage.reset(new BuiltInCursorImage);
270+ if (!m_builtInCursorImage || m_builtInCursorImage->requestedHeight != cursorHeight) {
271+ m_builtInCursorImage.reset(new BuiltInCursorImage(cursorHeight));
272 }
273 cursorImage = m_builtInCursorImage.data();
274 }
275@@ -296,7 +305,7 @@
276 return cursorImage;
277 }
278
279-CursorImage *CursorImageProvider::fetchCursorHelper(const QString &themeName, const QString &cursorName)
280+CursorImage *CursorImageProvider::fetchCursorHelper(const QString &themeName, const QString &cursorName, int cursorHeight)
281 {
282 if (cursorName == QLatin1String("blank")) {
283 return &m_blankCursorImage;
284@@ -306,7 +315,10 @@
285 QMap<QString, CursorImage*> &themeCursors = m_cursors[themeName];
286
287 if (!themeCursors.contains(cursorName)) {
288- themeCursors[cursorName] = new XCursorImage(themeName, cursorName);
289+ themeCursors[cursorName] = new XCursorImage(themeName, cursorName, cursorHeight);
290+ } else if (themeCursors[cursorName]->requestedHeight != cursorHeight) {
291+ delete themeCursors.take(cursorName);
292+ themeCursors[cursorName] = new XCursorImage(themeName, cursorName, cursorHeight);
293 }
294
295 return themeCursors[cursorName];
296
297=== modified file 'plugins/Cursor/CursorImageProvider.h'
298--- plugins/Cursor/CursorImageProvider.h 2016-05-19 19:44:37 +0000
299+++ plugins/Cursor/CursorImageProvider.h 2016-07-15 14:37:35 +0000
300@@ -42,17 +42,20 @@
301 int frameHeight{0};
302 int frameCount{1};
303 int frameDuration{40};
304+
305+ // Requested height when creating this cursor.
306+ int requestedHeight{0};
307 };
308
309 class XCursorImage : public CursorImage {
310 public:
311- XCursorImage(const QString &theme, const QString &file);
312+ XCursorImage(const QString &theme, const QString &file, int preferredCursorHeightPx);
313 virtual ~XCursorImage();
314 };
315
316 class BuiltInCursorImage : public CursorImage {
317 public:
318- BuiltInCursorImage();
319+ BuiltInCursorImage(int cursorHeight);
320 };
321
322 class BlankCursorImage : public CursorImage {
323@@ -74,15 +77,15 @@
324 static CursorImageProvider *instance() { return m_instance; }
325
326
327- QImage requestImage(const QString &cursorName, QSize *size, const QSize &requestedSize) override;
328+ QImage requestImage(const QString &cursorThemeAndNameAndHeight, QSize *size, const QSize &requestedSize) override;
329
330- CursorImage *fetchCursor(const QString &themeName, const QString &cursorName);
331+ CursorImage *fetchCursor(const QString &themeName, const QString &cursorName, int cursorHeight);
332
333 void setCustomCursor(const QCursor &customCursor);
334
335 private:
336- CursorImage *fetchCursor(const QString &cursorThemeAndName);
337- CursorImage *fetchCursorHelper(const QString &themeName, const QString &cursorName);
338+ CursorImage *fetchCursor(const QString &cursorThemeAndNameAndHeight);
339+ CursorImage *fetchCursorHelper(const QString &themeName, const QString &cursorName, int cursorHeight);
340
341 // themeName -> (cursorName -> cursorImage)
342 // TODO: discard old, unused, cursors
343
344=== modified file 'qml/Shell.qml'
345--- qml/Shell.qml 2016-07-11 17:23:38 +0000
346+++ qml/Shell.qml 2016-07-15 14:37:35 +0000
347@@ -775,6 +775,8 @@
348 when: cursor.mouseNeverMoved && cursor.visible
349 }
350
351+ height: units.gu(3)
352+
353 onPushedLeftBoundary: {
354 if (buttons === Qt.NoButton) {
355 launcher.pushEdge(amount);
356
357=== modified file 'tests/plugins/Cursor/tst_Cursor.qml'
358--- tests/plugins/Cursor/tst_Cursor.qml 2016-05-19 19:44:37 +0000
359+++ tests/plugins/Cursor/tst_Cursor.qml 2016-07-15 14:37:35 +0000
360@@ -26,11 +26,13 @@
361
362 property string themeName: "default"
363 property string cursorName: "left_ptr"
364+ property string cursorHeight: "32"
365
366 CursorImageInfo {
367 id: imageInfo
368 themeName: root.themeName
369 cursorName: root.cursorName
370+ cursorHeight: root.cursorHeight
371 }
372
373 Item {
374@@ -43,7 +45,7 @@
375
376 x: -imageInfo.hotspot.x
377 y: -imageInfo.hotspot.y
378- source: "image://cursor/" + root.themeName + "/" + root.cursorName
379+ source: "image://cursor/" + root.themeName + "/" + root.cursorName + "/" + root.cursorHeight
380
381 interpolate: false
382
383@@ -110,6 +112,10 @@
384
385 Item {width: 10; height: 40}
386
387+ TextEntry { id: cursorHeightEntry; name: "cursorHeight"; value: "32" }
388+
389+ Item {width: 10; height: 40}
390+
391 Rectangle {
392 color: applyMouseArea.pressed ? "green" : "lightslategray"
393 width: parent.width - 20
394@@ -121,6 +127,7 @@
395 onClicked: {
396 root.themeName = themeNameEntry.value;
397 root.cursorName = cursorNameEntry.value;
398+ root.cursorHeight = cursorHeightEntry.value;
399 }
400 }
401 }

Subscribers

People subscribed via source and target branches