1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the QtWidgets module of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 #ifndef QCOLORDIALOG_H 41 #define QCOLORDIALOG_H 42 43 #include <QtWidgets/qtwidgetsglobal.h> 44 45 #include <QtWidgets/qdialog.h> 46 47 QT_REQUIRE_CONFIG(colordialog); 48 49 QT_BEGIN_NAMESPACE 50 51 class QColorDialogPrivate; 52 53 class Q_WIDGETS_EXPORT QColorDialog : public QDialog 54 { 55 Q_OBJECT 56 Q_DECLARE_PRIVATE(QColorDialog) 57 Q_PROPERTY(QColor currentColor READ currentColor WRITE setCurrentColor 58 NOTIFY currentColorChanged) 59 Q_PROPERTY(ColorDialogOptions options READ options WRITE setOptions) 60 61 public: 62 enum ColorDialogOption { 63 ShowAlphaChannel = 0x00000001, 64 NoButtons = 0x00000002, 65 DontUseNativeDialog = 0x00000004 66 }; 67 Q_ENUM(ColorDialogOption) 68 69 Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption) 70 71 explicit QColorDialog(QWidget *parent = nullptr); 72 explicit QColorDialog(const QColor &initial, QWidget *parent = nullptr); 73 ~QColorDialog(); 74 75 void setCurrentColor(const QColor &color); 76 QColor currentColor() const; 77 78 QColor selectedColor() const; 79 80 void setOption(ColorDialogOption option, bool on = true); 81 bool testOption(ColorDialogOption option) const; 82 void setOptions(ColorDialogOptions options); 83 ColorDialogOptions options() const; 84 85 using QDialog::open; 86 void open(QObject *receiver, const char *member); 87 88 void setVisible(bool visible) override; 89 90 static QColor getColor(const QColor &initial = Qt::white, 91 QWidget *parent = nullptr, 92 const QString &title = QString(), 93 ColorDialogOptions options = ColorDialogOptions()); 94 95 #if QT_DEPRECATED_SINCE(5, 12) 96 QT_DEPRECATED_X("Use getColor()") static QRgb getRgba(QRgb rgba = 0xffffffff, bool *ok = nullptr, QWidget *parent = nullptr); 97 #endif 98 99 static int customCount(); 100 static QColor customColor(int index); 101 static void setCustomColor(int index, QColor color); 102 static QColor standardColor(int index); 103 static void setStandardColor(int index, QColor color); 104 105 Q_SIGNALS: 106 void currentColorChanged(const QColor &color); 107 void colorSelected(const QColor &color); 108 109 protected: 110 void changeEvent(QEvent *event) override; 111 void done(int result) override; 112 113 private: 114 Q_DISABLE_COPY(QColorDialog) 115 116 Q_PRIVATE_SLOT(d_func(), void _q_addCustom()) 117 Q_PRIVATE_SLOT(d_func(), void _q_newHsv(int h, int s, int v)) 118 Q_PRIVATE_SLOT(d_func(), void _q_newColorTypedIn(QRgb rgb)) 119 Q_PRIVATE_SLOT(d_func(), void _q_nextCustom(int, int)) 120 Q_PRIVATE_SLOT(d_func(), void _q_newCustom(int, int)) 121 Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int)) 122 Q_PRIVATE_SLOT(d_func(), void _q_pickScreenColor()) 123 Q_PRIVATE_SLOT(d_func(), void _q_updateColorPicking()) 124 }; 125 126 Q_DECLARE_OPERATORS_FOR_FLAGS(QColorDialog::ColorDialogOptions) 127 128 QT_END_NAMESPACE 129 130 #endif // QCOLORDIALOG_H 131