on xenial help sign in
move imageSource to CursorImageInfo
f5cb9e2Daniel d'Andrada
plugins/Cursor/Cursor.qml+2−8
@@ -28,18 +28,12 @@ MousePointer {
28 cursorHeight: mousePointer.height
28 cursorHeight: mousePointer.height
29 }
29 }
30
30
31− QtObject {
32− id: d
33− readonly property url imageSource: "image://cursor/" + mousePointer.themeName + "/" + mousePointer.cursorName
34− + "/" + mousePointer.height
35− }
36−
37 Loader {
31 Loader {
38 active: mousePointer.visible && imageInfo.frameCount > 1
32 active: mousePointer.visible && imageInfo.frameCount > 1
39 sourceComponent: AnimatedSprite {
33 sourceComponent: AnimatedSprite {
40 x: -imageInfo.hotspot.x
34 x: -imageInfo.hotspot.x
41 y: -imageInfo.hotspot.y
35 y: -imageInfo.hotspot.y
42− source: d.imageSource
36+ source: imageInfo.imageSource
43
37
44 interpolate: false
38 interpolate: false
45
39
@@ -60,7 +54,7 @@ MousePointer {
60 sourceComponent: Image {
54 sourceComponent: Image {
61 x: -imageInfo.hotspot.x
55 x: -imageInfo.hotspot.x
62 y: -imageInfo.hotspot.y
56 y: -imageInfo.hotspot.y
63− source: d.imageSource
57+ source: imageInfo.imageSource
64 width: sourceSize.width
58 width: sourceSize.width
65 height: sourceSize.height
59 height: sourceSize.height
66 }
60 }
plugins/Cursor/CursorImageInfo.cpp+11
@@ -57,6 +57,7 @@ void CursorImageInfo::update()
57 Q_EMIT frameHeightChanged();
57 Q_EMIT frameHeightChanged();
58 Q_EMIT frameCountChanged();
58 Q_EMIT frameCountChanged();
59 Q_EMIT frameDurationChanged();
59 Q_EMIT frameDurationChanged();
60+ Q_EMIT imageSourceChanged();
60}
61}
61
62
62QPoint CursorImageInfo::hotspot() const
63QPoint CursorImageInfo::hotspot() const
@@ -103,3 +104,13 @@ int CursorImageInfo::frameDuration() const
103 return 0;
104 return 0;
104 }
105 }
105}
106}
107+
108+QUrl CursorImageInfo::imageSource() const
109+{
110+ auto urlString = QString("image://cursor/%1/%2/%3")
111+ .arg(m_themeName)
112+ .arg(m_cursorName)
113+ .arg(m_cursorHeight);
114+
115+ return QUrl(urlString);
116+}
plugins/Cursor/CursorImageInfo.h+4
@@ -21,6 +21,7 @@
21
21
22#include <QObject>
22#include <QObject>
23#include <QString>
23#include <QString>
24+#include <QUrl>
24
25
25class CursorImageInfo : public QObject
26class CursorImageInfo : public QObject
26{
27{
@@ -35,6 +36,7 @@ class CursorImageInfo : public QObject
35 Q_PROPERTY(qreal frameHeight READ frameHeight NOTIFY frameHeightChanged)
36 Q_PROPERTY(qreal frameHeight READ frameHeight NOTIFY frameHeightChanged)
36 Q_PROPERTY(int frameCount READ frameCount NOTIFY frameCountChanged)
37 Q_PROPERTY(int frameCount READ frameCount NOTIFY frameCountChanged)
37 Q_PROPERTY(int frameDuration READ frameDuration NOTIFY frameDurationChanged)
38 Q_PROPERTY(int frameDuration READ frameDuration NOTIFY frameDurationChanged)
39+ Q_PROPERTY(QUrl imageSource READ imageSource NOTIFY imageSourceChanged)
38
40
39public:
41public:
40 CursorImageInfo(QObject *parent = nullptr);
42 CursorImageInfo(QObject *parent = nullptr);
@@ -53,6 +55,7 @@ public:
53 qreal frameHeight() const;
55 qreal frameHeight() const;
54 int frameCount() const;
56 int frameCount() const;
55 int frameDuration() const;
57 int frameDuration() const;
58+ QUrl imageSource() const;
56
59
57Q_SIGNALS:
60Q_SIGNALS:
58 void themeNameChanged();
61 void themeNameChanged();
@@ -63,6 +66,7 @@ Q_SIGNALS:
63 void frameHeightChanged();
66 void frameHeightChanged();
64 void frameCountChanged();
67 void frameCountChanged();
65 void frameDurationChanged();
68 void frameDurationChanged();
69+ void imageSourceChanged();
66
70
67private Q_SLOTS:
71private Q_SLOTS:
68 void update();
72 void update();