1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | // |
5 | // W A R N I N G |
6 | // ------------- |
7 | // |
8 | // This file is not part of the Qt API. It exists for the convenience |
9 | // of Qt Designer. This header file may change from version to version |
10 | // without notice, or even be removed. |
11 | // |
12 | // We mean it. |
13 | // |
14 | |
15 | #ifndef QTCOLORLINE_H |
16 | #define QTCOLORLINE_H |
17 | |
18 | #include <QtWidgets/QWidget> |
19 | |
20 | QT_BEGIN_NAMESPACE |
21 | |
22 | class QtColorLine : public QWidget |
23 | { |
24 | Q_OBJECT |
25 | Q_PROPERTY(QColor color READ color WRITE setColor) |
26 | Q_PROPERTY(int indicatorSpace READ indicatorSpace WRITE setIndicatorSpace) |
27 | Q_PROPERTY(int indicatorSize READ indicatorSize WRITE setIndicatorSize) |
28 | Q_PROPERTY(bool flip READ flip WRITE setFlip) |
29 | Q_PROPERTY(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered) |
30 | Q_PROPERTY(ColorComponent colorComponent READ colorComponent WRITE setColorComponent) |
31 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) |
32 | public: |
33 | |
34 | enum ColorComponent { |
35 | Red, |
36 | Green, |
37 | Blue, |
38 | Hue, |
39 | Saturation, |
40 | Value, |
41 | Alpha |
42 | }; |
43 | Q_ENUM(ColorComponent) |
44 | |
45 | QSize minimumSizeHint() const override; |
46 | QSize sizeHint() const override; |
47 | |
48 | QtColorLine(QWidget *parent = 0); |
49 | ~QtColorLine(); |
50 | |
51 | QColor color() const; |
52 | |
53 | void setIndicatorSize(int size); |
54 | int indicatorSize() const; |
55 | |
56 | void setIndicatorSpace(int space); |
57 | int indicatorSpace() const; |
58 | |
59 | void setFlip(bool flip); |
60 | bool flip() const; |
61 | |
62 | bool isBackgroundCheckered() const; |
63 | void setBackgroundCheckered(bool checkered); |
64 | |
65 | void setOrientation(Qt::Orientation orientation); |
66 | Qt::Orientation orientation() const; |
67 | |
68 | void setColorComponent(ColorComponent component); |
69 | ColorComponent colorComponent() const; |
70 | |
71 | public slots: |
72 | void setColor(QColor color); |
73 | |
74 | signals: |
75 | void colorChanged(QColor color); |
76 | |
77 | protected: |
78 | void resizeEvent(QResizeEvent *event) override; |
79 | void paintEvent(QPaintEvent *event) override; |
80 | void mousePressEvent(QMouseEvent *event) override; |
81 | void mouseMoveEvent(QMouseEvent *event) override; |
82 | void mouseReleaseEvent(QMouseEvent *event) override; |
83 | void mouseDoubleClickEvent(QMouseEvent *event) override; |
84 | |
85 | private: |
86 | QScopedPointer<class QtColorLinePrivate> d_ptr; |
87 | Q_DECLARE_PRIVATE(QtColorLine) |
88 | Q_DISABLE_COPY_MOVE(QtColorLine) |
89 | }; |
90 | |
91 | QT_END_NAMESPACE |
92 | |
93 | #endif |
94 | |