Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_color_button.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Wolthera van Hovell tot Westerflier <griffinvalley@gmail.com>
3 * This file is forked from the KF5 KColorButton
4 SPDX-FileCopyrightText: 1997 Martin Jones (mjones@kde.org)
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef KisColorButton_H
10#define KisColorButton_H
11#include <kritawidgets_export.h>
12
13#include <KoColor.h>
14#include <QPushButton>
15
16class KisColorButtonPrivate;
26class KRITAWIDGETS_EXPORT KisColorButton : public QPushButton
27{
28 Q_OBJECT
29
34 Q_PROPERTY(KoColor color READ color WRITE setColor NOTIFY changed USER true DESIGNABLE false)
35 Q_PROPERTY(KoColor defaultColor READ defaultColor WRITE setDefaultColor DESIGNABLE false)
36 Q_PROPERTY(bool alphaChannelEnabled READ isAlphaChannelEnabled WRITE setAlphaChannelEnabled)
37
38public:
42 explicit KisColorButton(QWidget *parent = 0);
43
47 explicit KisColorButton(const KoColor &c, QWidget *parent = 0);
48
52 KisColorButton(const KoColor &c, const KoColor &defaultColor, QWidget *parent = 0);
53
54 ~KisColorButton() override;
55
59 KoColor color() const;
60
65 void setAlphaChannelEnabled(bool alpha);
66
70 bool isAlphaChannelEnabled() const;
71
75 void setPaletteViewEnabled( bool enable);
76
81 bool paletteViewEnabled() const;
86 KoColor defaultColor() const;
87
91 void setDefaultColor(const KoColor &c);
92
93 QSize sizeHint() const override;
94 QSize minimumSizeHint() const override;
95
96public Q_SLOTS:
100 void setColor(const KoColor &c);
101Q_SIGNALS:
106 void changed(const KoColor &newColor);
107
108protected:
109 void paintEvent(QPaintEvent *pe) override;
110 void dragEnterEvent(QDragEnterEvent *) override;
111 void dropEvent(QDropEvent *) override;
112 void mousePressEvent(QMouseEvent *e) override;
113 void mouseMoveEvent(QMouseEvent *e) override;
114 void keyPressEvent(QKeyEvent *e) override;
115
116private:
119
120 Q_PRIVATE_SLOT(d, void _k_chooseColor())
121};
122
123#endif
A pushbutton to display or allow user selection of a color.