File indexing completed on 2024-05-19 05:47:32

0001 /****************************************************************************
0002 ** Copied from Qt 5.6.3 sources, module qttools, directory src/shared/qtgradienteditor
0003 ** with small modifications to match more modern C++ standards and for no alpha-channel
0004 **
0005 ** Copyright (C) 2015 The Qt Company Ltd.
0006 ** Contact: http://www.qt.io/licensing/
0007 **
0008 ** This file is part of the tools applications of the Qt Toolkit.
0009 **
0010 ** $QT_BEGIN_LICENSE:LGPL21$
0011 ** Commercial License Usage
0012 ** Licensees holding valid commercial Qt licenses may use this file in
0013 ** accordance with the commercial license agreement provided with the
0014 ** Software or, alternatively, in accordance with the terms contained in
0015 ** a written agreement between you and The Qt Company. For licensing terms
0016 ** and conditions see http://www.qt.io/terms-conditions. For further
0017 ** information use the contact form at http://www.qt.io/contact-us.
0018 **
0019 ** GNU Lesser General Public License Usage
0020 ** Alternatively, this file may be used under the terms of the GNU Lesser
0021 ** General Public License version 2.1 or version 3 as published by the Free
0022 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
0023 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
0024 ** following information to ensure the GNU Lesser General Public License
0025 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
0026 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
0027 **
0028 ** As a special exception, The Qt Company gives you certain additional
0029 ** rights. These rights are described in The Qt Company LGPL Exception
0030 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
0031 **
0032 ** $QT_END_LICENSE$
0033 **
0034 ****************************************************************************/
0035 
0036 #ifndef QTCOLORBUTTON_H
0037 #define QTCOLORBUTTON_H
0038 
0039 #include <QToolButton>
0040 
0041 QT_BEGIN_NAMESPACE
0042 
0043 class QtColorButton : public QToolButton
0044 {
0045     Q_OBJECT
0046     Q_PROPERTY(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered)
0047 public:
0048     explicit QtColorButton(QWidget *parent = nullptr);
0049     ~QtColorButton() override;
0050 
0051     bool isBackgroundCheckered() const;
0052     void setBackgroundCheckered(bool checkered);
0053 
0054     QColor color() const;
0055 
0056 public Q_SLOTS:
0057 
0058     void setColor(const QColor &color);
0059 
0060 Q_SIGNALS:
0061     void colorChanged(const QColor &color);
0062 protected:
0063     void paintEvent(QPaintEvent *event) override;
0064     void mousePressEvent(QMouseEvent *event) override;
0065     void mouseMoveEvent(QMouseEvent *event) override;
0066 #ifndef QT_NO_DRAGANDDROP
0067     void dragEnterEvent(QDragEnterEvent *event) override;
0068     void dragLeaveEvent(QDragLeaveEvent *event) override;
0069     void dropEvent(QDropEvent *event) override;
0070 #endif
0071 private:
0072     QScopedPointer<class QtColorButtonPrivate> d_ptr;
0073     Q_DECLARE_PRIVATE(QtColorButton)
0074     Q_DISABLE_COPY(QtColorButton)
0075     Q_PRIVATE_SLOT(d_func(), void slotEditColor())
0076 };
0077 
0078 QT_END_NAMESPACE
0079 
0080 #endif