dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
qtcolorbutton.h
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #ifndef QTCOLORBUTTON_H
29 #define QTCOLORBUTTON_H
30 
31 #include "utils_global.h"
32 
33 #include <QToolButton>
34 
35 namespace Utils {
36 
37 class QTCREATOR_UTILS_EXPORT QtColorButton : public QToolButton
38 {
39  Q_OBJECT
40  Q_PROPERTY(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered)
41  Q_PROPERTY(bool alphaAllowed READ isAlphaAllowed WRITE setAlphaAllowed)
42 public:
43  QtColorButton(QWidget *parent = nullptr);
44  ~QtColorButton();
45 
46  bool isBackgroundCheckered() const;
47  void setBackgroundCheckered(bool checkered);
48 
49  bool isAlphaAllowed() const;
50  void setAlphaAllowed(bool allowed);
51 
52  QColor color() const;
53 
54 public slots:
55  void setColor(const QColor &color);
56 
57 signals:
58  void colorChanged(const QColor &color);
59 protected:
60  void paintEvent(QPaintEvent *event);
61  void mousePressEvent(QMouseEvent *event);
62  void mouseMoveEvent(QMouseEvent *event);
63 #ifndef QT_NO_DRAGANDDROP
64  void dragEnterEvent(QDragEnterEvent *event);
65  void dragLeaveEvent(QDragLeaveEvent *event);
66  void dropEvent(QDropEvent *event);
67 #endif
68 private:
69  class QtColorButtonPrivate *d_ptr;
70  friend class QtColorButtonPrivate;
71  Q_DISABLE_COPY(QtColorButton)
72  Q_PRIVATE_SLOT(d_ptr, void slotEditColor())
73 };
74 
75 } // namespace Utils
76 
77 #endif // QTCOLORBUTTON_H