Changeset View
Changeset View
Standalone View
Standalone View
kcms/cursortheme/xcursor/previewwidget.h
Show All 13 Lines | |||||
14 | * along with this program; see the file COPYING. If not, write to | 14 | * along with this program; see the file COPYING. If not, write to | ||
15 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 15 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
16 | * Boston, MA 02110-1301, USA. | 16 | * Boston, MA 02110-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #ifndef PREVIEWWIDGET_H | 19 | #ifndef PREVIEWWIDGET_H | ||
20 | #define PREVIEWWIDGET_H | 20 | #define PREVIEWWIDGET_H | ||
21 | 21 | | |||
22 | #include <QWidget> | 22 | #include <QQuickPaintedItem> | ||
23 | #include <QPointer> | ||||
24 | #include "sortproxymodel.h" | ||||
23 | 25 | | |||
24 | class CursorTheme; | 26 | class CursorTheme; | ||
25 | class PreviewCursor; | 27 | class PreviewCursor; | ||
26 | 28 | | |||
27 | class PreviewWidget : public QWidget | 29 | class PreviewWidget : public QQuickPaintedItem | ||
28 | { | 30 | { | ||
31 | Q_OBJECT | ||||
32 | Q_PROPERTY(SortProxyModel *themeModel READ themeModel WRITE setThemeModel NOTIFY themeModelChanged) | ||||
33 | Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) | ||||
34 | Q_PROPERTY(int currentSize READ currentSize WRITE setCurrentSize NOTIFY currentSizeChanged) | ||||
35 | | ||||
36 | | ||||
29 | public: | 37 | public: | ||
30 | PreviewWidget(QWidget *parent); | 38 | PreviewWidget(QQuickItem *parent = 0); | ||
31 | ~PreviewWidget(); | 39 | ~PreviewWidget(); | ||
32 | 40 | | |||
33 | void setTheme(const CursorTheme *theme, const int size); | 41 | void setTheme(const CursorTheme *theme, const int size); | ||
34 | void setUseLables(bool); | 42 | void setUseLables(bool); | ||
35 | QSize sizeHint() const Q_DECL_OVERRIDE; | 43 | void updateImplicitSize(); | ||
44 | | ||||
45 | void setThemeModel(SortProxyModel *themeModel); | ||||
46 | SortProxyModel *themeModel(); | ||||
47 | | ||||
48 | void setCurrentIndex(int idx); | ||||
49 | int currentIndex() const; | ||||
50 | | ||||
51 | void setCurrentSize(int size); | ||||
52 | int currentSize() const; | ||||
53 | | ||||
54 | Q_SIGNALS: | ||||
55 | void themeModelChanged(); | ||||
56 | void currentIndexChanged(); | ||||
57 | void currentSizeChanged(); | ||||
36 | 58 | | |||
37 | protected: | 59 | protected: | ||
38 | void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; | 60 | void paint(QPainter *); | ||
39 | void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; | 61 | void hoverMoveEvent(QHoverEvent *event); | ||
40 | void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; | 62 | void hoverLeaveEvent(QHoverEvent *e); | ||
63 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; | ||||
41 | 64 | | |||
42 | private: | 65 | private: | ||
43 | void layoutItems(); | 66 | void layoutItems(); | ||
44 | 67 | | |||
45 | QList<PreviewCursor*> list; | 68 | QList<PreviewCursor*> list; | ||
46 | const PreviewCursor *current; | 69 | const PreviewCursor *current; | ||
47 | bool needLayout:1; | 70 | bool needLayout:1; | ||
71 | QPointer<SortProxyModel> m_themeModel; | ||||
72 | int m_currentIndex; | ||||
73 | int m_currentSize; | ||||
48 | }; | 74 | }; | ||
49 | 75 | | |||
50 | #endif // PREVIEWWIDGET_H | 76 | #endif // PREVIEWWIDGET_H | ||
51 | 77 | |