forked from andreagen0r/ColorPicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolorpickerpreview.h
37 lines (28 loc) · 1001 Bytes
/
colorpickerpreview.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once
#include <QQuickPaintedItem>
#include <QQmlEngine>
#include <QPointF>
class ColorPickerPreview : public QQuickPaintedItem {
Q_OBJECT
QML_ELEMENT
Q_PROPERTY( qreal previewSize READ previewSize WRITE setPreviewSize NOTIFY previewSizeChanged )
Q_PROPERTY( qreal size READ size WRITE setSize NOTIFY sizeChanged )
Q_PROPERTY( QPointF mousePosition READ mousePosition WRITE setMousePosition NOTIFY mousePositionChanged )
public:
ColorPickerPreview();
void paint( QPainter* painter ) override;
[[nodiscard]] qreal previewSize() const;
void setPreviewSize( qreal newPreviewSize );
[[nodiscard]] qreal size() const;
void setSize( qreal newSize );
[[nodiscard]] QPointF mousePosition() const;
Q_INVOKABLE void setMousePosition( QPointF newMousePosition );
signals:
void previewSizeChanged();
void sizeChanged();
void mousePositionChanged();
private:
qreal m_previewSize;
qreal m_size;
QPointF m_mousePosition;
};