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#ifndef QTCOLORLINE_H
5#define QTCOLORLINE_H
6
7#include <QtWidgets/QWidget>
8
9QT_BEGIN_NAMESPACE
10
11class QtColorLine : public QWidget
12{
13 Q_OBJECT
14 Q_PROPERTY(QColor color READ color WRITE setColor)
15 Q_PROPERTY(int indicatorSpace READ indicatorSpace WRITE setIndicatorSpace)
16 Q_PROPERTY(int indicatorSize READ indicatorSize WRITE setIndicatorSize)
17 Q_PROPERTY(bool flip READ flip WRITE setFlip)
18 Q_PROPERTY(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered)
19 Q_PROPERTY(ColorComponent colorComponent READ colorComponent WRITE setColorComponent)
20 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
21public:
22
23 enum ColorComponent {
24 Red,
25 Green,
26 Blue,
27 Hue,
28 Saturation,
29 Value,
30 Alpha
31 };
32 Q_ENUM(ColorComponent)
33
34 QSize minimumSizeHint() const override;
35 QSize sizeHint() const override;
36
37 QtColorLine(QWidget *parent = 0);
38 ~QtColorLine();
39
40 QColor color() const;
41
42 void setIndicatorSize(int size);
43 int indicatorSize() const;
44
45 void setIndicatorSpace(int space);
46 int indicatorSpace() const;
47
48 void setFlip(bool flip);
49 bool flip() const;
50
51 bool isBackgroundCheckered() const;
52 void setBackgroundCheckered(bool checkered);
53
54 void setOrientation(Qt::Orientation orientation);
55 Qt::Orientation orientation() const;
56
57 void setColorComponent(ColorComponent component);
58 ColorComponent colorComponent() const;
59
60public slots:
61 void setColor(const QColor &color);
62
63signals:
64 void colorChanged(const QColor &color);
65
66protected:
67 void resizeEvent(QResizeEvent *event) override;
68 void paintEvent(QPaintEvent *event) override;
69 void mousePressEvent(QMouseEvent *event) override;
70 void mouseMoveEvent(QMouseEvent *event) override;
71 void mouseReleaseEvent(QMouseEvent *event) override;
72 void mouseDoubleClickEvent(QMouseEvent *event) override;
73
74private:
75 QScopedPointer<class QtColorLinePrivate> d_ptr;
76 Q_DECLARE_PRIVATE(QtColorLine)
77 Q_DISABLE_COPY_MOVE(QtColorLine)
78};
79
80QT_END_NAMESPACE
81
82#endif
83

source code of qttools/src/shared/qtgradienteditor/qtcolorline.h