Krita Source Code Documentation
Loading...
Searching...
No Matches
KoDualColorButton.h
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2
3 SPDX-FileCopyrightText: 1999 Daniel M. Duley <mosfet@kde.org>
4 SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org>
5 SPDX-FileCopyrightText: 2026 Arkady Flury <arkady.flury@gmail.com>
6
7 SPDX-License-Identifier: LGPL-2.0-only
8*/
9
10#ifndef KODUALCOLORBUTTON_H
11#define KODUALCOLORBUTTON_H
12
13#include <kritaui_export.h>
15
16
17#include <QWidget>
18
19class KoColor;
20class KoColorSpace;
41class KRITAUI_EXPORT KoDualColorButton : public QWidget
42{
43 Q_OBJECT
44 Q_ENUMS( Selection )
45 Q_PROPERTY( KoColor foregroundColor READ foregroundColor WRITE setForegroundColor )
46 Q_PROPERTY( KoColor backgroundColor READ backgroundColor WRITE setBackgroundColor )
47 Q_PROPERTY( bool popDialog READ popDialog WRITE setPopDialog )
48
49
50 public:
51 enum Selection {
53 Background
54 };
55 QRect foregroundRect = QRect( 0, 0, 14, 14);
56 QRect backgroundRect = QRect( 14, 14, 28, 28);
58 QPixmap resetPixmap;
59 QPixmap arrowBitmap;
60
61 bool resetColours = false;
62
71 KoDualColorButton(KisCanvasResourceProvider *canvasResourceProvider,
72 const KoColorDisplayRendererInterface *displayRenderer,
73 QWidget *parent = 0, QWidget* dialogParent = 0);
74
78 ~KoDualColorButton() override;
79
83 KoColor foregroundColor() const;
84
85
86
87
91 KoColor backgroundColor() const;
92
98 bool popDialog() const;
99
104 QSize sizeHint() const override;
105
106 public Q_SLOTS:
107 void updateArrows();
108
109 void ResetColours();
110 void swapColours();
111
112 void setColorDialogState(Selection state);
113
114
115 virtual void paint_icons(QPainter &painter);
116
120 void setForegroundColor( const KoColor &color );
121
125 void setBackgroundColor( const KoColor &color );
126
127 void foregroundSelect(bool usePlatformDialog);
128 void backgroundSelect(bool usePlatformDialog);
129
130 void slotSetForegroundColorFromDialog (const KoColor color);
131 void slotSetBackgroundColorFromDialog (const KoColor color);
132 void slotColorDialogClosed();
133
134 void setDisplayRenderer(const KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance());
135
141 void updateColorSpace();
142
150 QColor getColorFromDisplayRenderer(KoColor c);
151
157 void setPopDialog( bool popDialog );
158
159 void openForegroundDialog();
160
161 void openBackgroundDialog();
162 Q_SIGNALS:
166 void foregroundColorChanged( const KoColor &color );
167
171 void backgroundColorChanged( const KoColor &color );
172
173 protected:
182 void paintEvent( QPaintEvent *event ) override;
183 virtual void mousePressEvent( QMouseEvent *event ) override;
184 virtual void mouseMoveEvent( QMouseEvent *event ) override;
185 virtual void mouseReleaseEvent( QMouseEvent *event ) override;
186 void dragEnterEvent( QDragEnterEvent *event ) override;
187 void dropEvent( QDropEvent *event ) override;
188 void changeEvent(QEvent *event) override;
189 bool event(QEvent *event) override;
190
191 private:
192 class Private;
193 Private *const d;
194
195
196};
197
198#endif
199
A widget for selecting two related colors.
void foregroundColorChanged(const KoColor &color)
void backgroundColorChanged(const KoColor &color)
static KoColorDisplayRendererInterface * instance()