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 QTCOLORBUTTON_H
5#define QTCOLORBUTTON_H
6
7#include <QtWidgets/QToolButton>
8
9QT_BEGIN_NAMESPACE
10
11class QtColorButton : public QToolButton
12{
13 Q_OBJECT
14 Q_PROPERTY(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered)
15public:
16 QtColorButton(QWidget *parent = 0);
17 ~QtColorButton();
18
19 bool isBackgroundCheckered() const;
20 void setBackgroundCheckered(bool checkered);
21
22 QColor color() const;
23
24public slots:
25 void setColor(const QColor &color);
26
27signals:
28 void colorChanged(const QColor &color);
29
30protected:
31 void paintEvent(QPaintEvent *event) override;
32 void mousePressEvent(QMouseEvent *event) override;
33 void mouseMoveEvent(QMouseEvent *event) override;
34#ifndef QT_NO_DRAGANDDROP
35 void dragEnterEvent(QDragEnterEvent *event) override;
36 void dragLeaveEvent(QDragLeaveEvent *event) override;
37 void dropEvent(QDropEvent *event) override;
38#endif
39
40private:
41 QScopedPointer<class QtColorButtonPrivate> d_ptr;
42 Q_DECLARE_PRIVATE(QtColorButton)
43 Q_DISABLE_COPY_MOVE(QtColorButton)
44};
45
46QT_END_NAMESPACE
47
48#endif
49

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