KWidgetsAddons

kcolorbutton.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 1997 Martin Jones <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KCOLORBUTTON_H
9 #define KCOLORBUTTON_H
10 
11 #include <kwidgetsaddons_export.h>
12 
13 #include <QPushButton>
14 
15 class KColorButtonPrivate;
27 class KWIDGETSADDONS_EXPORT KColorButton : public QPushButton
28 {
29  Q_OBJECT
30  Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY changed USER true)
31  Q_PROPERTY(QColor defaultColor READ defaultColor WRITE setDefaultColor)
32  Q_PROPERTY(bool alphaChannelEnabled READ isAlphaChannelEnabled WRITE setAlphaChannelEnabled)
33 
34 public:
38  explicit KColorButton(QWidget *parent = nullptr);
39 
43  explicit KColorButton(const QColor &c, QWidget *parent = nullptr);
44 
48  KColorButton(const QColor &c, const QColor &defaultColor, QWidget *parent = nullptr);
49 
50  ~KColorButton() override;
51 
55  QColor color() const;
56 
60  void setColor(const QColor &c);
61 
67  void setAlphaChannelEnabled(bool alpha);
68 
73  bool isAlphaChannelEnabled() const;
74 
79  QColor defaultColor() const;
80 
84  void setDefaultColor(const QColor &c);
85 
86  QSize sizeHint() const override;
87  QSize minimumSizeHint() const override;
88 
89 Q_SIGNALS:
94  void changed(const QColor &newColor);
95 
96 protected:
97  void paintEvent(QPaintEvent *pe) override;
98  void dragEnterEvent(QDragEnterEvent *) override;
99  void dropEvent(QDropEvent *) override;
100  void mousePressEvent(QMouseEvent *e) override;
101  void mouseMoveEvent(QMouseEvent *e) override;
102  void keyPressEvent(QKeyEvent *e) override;
103 
104 private:
105  class KColorButtonPrivate;
106  KColorButtonPrivate *const d;
107  Q_PRIVATE_SLOT(d, void _k_colorChosen())
108 };
109 
110 #endif
111 
virtual void dropEvent(QDropEvent *event)
virtual QSize sizeHint() const const override
virtual void dragEnterEvent(QDragEnterEvent *event)
virtual void mouseMoveEvent(QMouseEvent *e) override
virtual QSize minimumSizeHint() const const override
virtual void mousePressEvent(QMouseEvent *e) override
Q_PROPERTY(...)
A pushbutton to display or allow user selection of a color.
Definition: kcolorbutton.h:27
virtual void paintEvent(QPaintEvent *) override
virtual void keyPressEvent(QKeyEvent *e) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Jul 4 2020 22:44:22 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.