on xenial help sign in
move imageSource to CursorImageInfo
commitf5cb9e20ee3565d3c11ffb3f8826d1ee42dfd3ac authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateFri 15 Jul 2016, 11:36 (10 years ago) parentef73617
3 files changed+17−8
plugins/Cursor/Cursor.qml+2−8 plugins/Cursor/CursorImageInfo.cpp+11 plugins/Cursor/CursorImageInfo.h+4
plugins/Cursor/Cursor.qml+2−8
@@ -28,18 +28,12 @@ MousePointer {
2828 cursorHeight: mousePointer.height
2929 }
3030
31− QtObject {
32− id: d
33− readonly property url imageSource: "image://cursor/" + mousePointer.themeName + "/" + mousePointer.cursorName
34− + "/" + mousePointer.height
35− }
36−
3731 Loader {
3832 active: mousePointer.visible && imageInfo.frameCount > 1
3933 sourceComponent: AnimatedSprite {
4034 x: -imageInfo.hotspot.x
4135 y: -imageInfo.hotspot.y
42− source: d.imageSource
36+ source: imageInfo.imageSource
4337
4438 interpolate: false
4539
@@ -60,7 +54,7 @@ MousePointer {
6054 sourceComponent: Image {
6155 x: -imageInfo.hotspot.x
6256 y: -imageInfo.hotspot.y
63− source: d.imageSource
57+ source: imageInfo.imageSource
6458 width: sourceSize.width
6559 height: sourceSize.height
6660 }
plugins/Cursor/CursorImageInfo.cpp+11
@@ -57,6 +57,7 @@ void CursorImageInfo::update()
5757 Q_EMIT frameHeightChanged();
5858 Q_EMIT frameCountChanged();
5959 Q_EMIT frameDurationChanged();
60+ Q_EMIT imageSourceChanged();
6061}
6162
6263QPoint CursorImageInfo::hotspot() const
@@ -103,3 +104,13 @@ int CursorImageInfo::frameDuration() const
103104 return 0;
104105 }
105106}
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 @@
2121
2222#include <QObject>
2323#include <QString>
24+#include <QUrl>
2425
2526class CursorImageInfo : public QObject
2627{
@@ -35,6 +36,7 @@ class CursorImageInfo : public QObject
3536 Q_PROPERTY(qreal frameHeight READ frameHeight NOTIFY frameHeightChanged)
3637 Q_PROPERTY(int frameCount READ frameCount NOTIFY frameCountChanged)
3738 Q_PROPERTY(int frameDuration READ frameDuration NOTIFY frameDurationChanged)
39+ Q_PROPERTY(QUrl imageSource READ imageSource NOTIFY imageSourceChanged)
3840
3941public:
4042 CursorImageInfo(QObject *parent = nullptr);
@@ -53,6 +55,7 @@ public:
5355 qreal frameHeight() const;
5456 int frameCount() const;
5557 int frameDuration() const;
58+ QUrl imageSource() const;
5659
5760Q_SIGNALS:
5861 void themeNameChanged();
@@ -63,6 +66,7 @@ Q_SIGNALS:
6366 void frameHeightChanged();
6467 void frameCountChanged();
6568 void frameDurationChanged();
69+ void imageSourceChanged();
6670
6771private Q_SLOTS:
6872 void update();