Lomiri
CursorImageInfo.h
1 /*
2  * Copyright (C) 2016 Canonical Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef CURSOR_IMAGE_INFO_H
18 #define CURSOR_IMAGE_INFO_H
19 
20 #include "CursorImageProvider.h"
21 
22 #include <QObject>
23 #include <QString>
24 #include <QUrl>
25 
26 class CursorImageInfo : public QObject
27 {
28  Q_OBJECT
29 
30  Q_PROPERTY(QString themeName READ themeName WRITE setThemeName NOTIFY themeNameChanged)
31  Q_PROPERTY(QString cursorName READ cursorName WRITE setCursorName NOTIFY cursorNameChanged)
32  Q_PROPERTY(qreal cursorHeight READ cursorHeight WRITE setCursorHeight NOTIFY cursorHeightChanged)
33 
34  Q_PROPERTY(QPoint hotspot READ hotspot NOTIFY hotspotChanged)
35  Q_PROPERTY(qreal frameWidth READ frameWidth NOTIFY frameWidthChanged)
36  Q_PROPERTY(qreal frameHeight READ frameHeight NOTIFY frameHeightChanged)
37  Q_PROPERTY(int frameCount READ frameCount NOTIFY frameCountChanged)
38  Q_PROPERTY(int frameDuration READ frameDuration NOTIFY frameDurationChanged)
39  Q_PROPERTY(QUrl imageSource READ imageSource NOTIFY imageSourceChanged)
40 
41 public:
42  CursorImageInfo(QObject *parent = nullptr);
43 
44  QString themeName() const { return m_themeName; }
45  void setThemeName(const QString &);
46 
47  QString cursorName() const { return m_cursorName; }
48  void setCursorName(const QString &);
49 
50  qreal cursorHeight() const { return m_cursorHeight; }
51  void setCursorHeight(qreal);
52 
53  QPoint hotspot() const;
54  qreal frameWidth() const;
55  qreal frameHeight() const;
56  int frameCount() const;
57  int frameDuration() const;
58  QUrl imageSource() const;
59 
60 Q_SIGNALS:
61  void themeNameChanged();
62  void cursorNameChanged();
63  void cursorHeightChanged();
64  void hotspotChanged();
65  void frameWidthChanged();
66  void frameHeightChanged();
67  void frameCountChanged();
68  void frameDurationChanged();
69  void imageSourceChanged();
70 
71 private Q_SLOTS:
72  void update();
73 
74 private:
75  QString m_themeName;
76  QString m_cursorName;
77  qreal m_cursorHeight{0};
78 
79  CursorImage *m_cursorImage{nullptr};
80 };
81 
82 #endif // CURSOR_IMAGE_INFO_H