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 QCOLORDIALOG_H
5#define QCOLORDIALOG_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8
9#include <QtWidgets/qdialog.h>
10
11QT_REQUIRE_CONFIG(colordialog);
12
13QT_BEGIN_NAMESPACE
14
15class QColorDialogPrivate;
16
17class Q_WIDGETS_EXPORT QColorDialog : public QDialog
18{
19 Q_OBJECT
20 Q_DECLARE_PRIVATE(QColorDialog)
21 Q_PROPERTY(QColor currentColor READ currentColor WRITE setCurrentColor
22 NOTIFY currentColorChanged)
23 Q_PROPERTY(ColorDialogOptions options READ options WRITE setOptions)
24
25public:
26 enum ColorDialogOption {
27 ShowAlphaChannel = 0x00000001,
28 NoButtons = 0x00000002,
29 DontUseNativeDialog = 0x00000004
30 };
31 Q_ENUM(ColorDialogOption)
32
33 Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)
34
35 explicit QColorDialog(QWidget *parent = nullptr);
36 explicit QColorDialog(const QColor &initial, QWidget *parent = nullptr);
37 ~QColorDialog();
38
39 void setCurrentColor(const QColor &color);
40 QColor currentColor() const;
41
42 QColor selectedColor() const;
43
44 void setOption(ColorDialogOption option, bool on = true);
45 bool testOption(ColorDialogOption option) const;
46 void setOptions(ColorDialogOptions options);
47 ColorDialogOptions options() const;
48
49 using QDialog::open;
50 void open(QObject *receiver, const char *member);
51
52 void setVisible(bool visible) override;
53
54 static QColor getColor(const QColor &initial = Qt::white,
55 QWidget *parent = nullptr,
56 const QString &title = QString(),
57 ColorDialogOptions options = ColorDialogOptions());
58
59 static int customCount();
60 static QColor customColor(int index);
61 static void setCustomColor(int index, QColor color);
62 static QColor standardColor(int index);
63 static void setStandardColor(int index, QColor color);
64
65Q_SIGNALS:
66 void currentColorChanged(const QColor &color);
67 void colorSelected(const QColor &color);
68
69protected:
70 void changeEvent(QEvent *event) override;
71 void done(int result) override;
72
73private:
74 Q_DISABLE_COPY(QColorDialog)
75
76 Q_PRIVATE_SLOT(d_func(), void _q_addCustom())
77 Q_PRIVATE_SLOT(d_func(), void _q_newHsv(int h, int s, int v))
78 Q_PRIVATE_SLOT(d_func(), void _q_newColorTypedIn(QRgb rgb))
79 Q_PRIVATE_SLOT(d_func(), void _q_nextCustom(int, int))
80 Q_PRIVATE_SLOT(d_func(), void _q_newCustom(int, int))
81 Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int))
82 Q_PRIVATE_SLOT(d_func(), void _q_pickScreenColor())
83 Q_PRIVATE_SLOT(d_func(), void _q_updateColorPicking())
84};
85
86Q_DECLARE_OPERATORS_FOR_FLAGS(QColorDialog::ColorDialogOptions)
87
88QT_END_NAMESPACE
89
90#endif // QCOLORDIALOG_H
91

source code of qtbase/src/widgets/dialogs/qcolordialog.h