-
Notifications
You must be signed in to change notification settings - Fork 12
/
ColorChooserButton.h
66 lines (50 loc) · 1.05 KB
/
ColorChooserButton.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef COLORCHOOSERBUTTON_H
#define COLORCHOOSERBUTTON_H
#include <QWidget>
#include <QColor>
#define COLOR_CHOOSER_BUTTON_PREVIEW_WIDTH 48
#define COLOR_CHOOSER_BUTTON_PREVIEW_HEIGHT 16
namespace Ui {
class ColorChooserButton;
}
class ColorChooserButton : public QWidget
{
Q_OBJECT
Q_PROPERTY(
QColor color
READ getColor
WRITE setColor
NOTIFY colorChanged)
QColor current;
QPixmap preview;
void resetPixmap(void);
public:
explicit ColorChooserButton(QWidget *parent = nullptr);
~ColorChooserButton();
QColor
getColor(void)
{
return this->current;
}
void
getColor(QColor &color)
{
color = this->current;
}
void
setColor(QColor color)
{
if (this->current != color) {
this->current = color;
emit colorChanged(color);
}
this->resetPixmap();
}
private:
Ui::ColorChooserButton *ui;
public slots:
void onClicked(void);
signals:
void colorChanged(QColor);
};
#endif // COLORCHOOSERBUTTON_H