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
6 SPDX-License-Identifier: LGPL-2.0-only
7*/
8
9#ifndef KODUALCOLORBUTTON_H
10#define KODUALCOLORBUTTON_H
11
12#include <kritaui_export.h>
14#include <QWidget>
15
16class KoColor;
17class KoColorSpace;
37class KRITAUI_EXPORT KoDualColorButton : public QWidget
38{
39 Q_OBJECT
40 Q_ENUMS( Selection )
41 Q_PROPERTY( KoColor foregroundColor READ foregroundColor WRITE setForegroundColor )
42 Q_PROPERTY( KoColor backgroundColor READ backgroundColor WRITE setBackgroundColor )
43 Q_PROPERTY( bool popDialog READ popDialog WRITE setPopDialog )
44
45
46 public:
47 enum Selection {
49 Background
50 };
51
59 KoDualColorButton(const KoColor &foregroundColor, const KoColor &backgroundColor,
60 QWidget *parent = 0, QWidget* dialogParent = 0 );
61
62 KoDualColorButton(const KoColor &foregroundColor, const KoColor &backgroundColor,
63 const KoColorDisplayRendererInterface *displayRenderer,
64 QWidget *parent = 0, QWidget* dialogParent = 0 );
65
69 ~KoDualColorButton() override;
70
75
80
86 bool popDialog() const;
87
92 QSize sizeHint() const override;
93
94 public Q_SLOTS:
98 void setForegroundColor( const KoColor &color );
99
103 void setBackgroundColor( const KoColor &color );
104
105 void slotSetForegroundColorFromDialog (const KoColor color);
106 void slotSetBackgroundColorFromDialog (const KoColor color);
107 void slotColorDialogClosed();
108
109 void setDisplayRenderer(const KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance());
110
116 void setColorSpace(const KoColorSpace *cs);
117
125 QColor getColorFromDisplayRenderer(KoColor c);
126
132 void setPopDialog( bool popDialog );
133
134 void openForegroundDialog();
135
136 void openBackgroundDialog();
137 Q_SIGNALS:
141 void foregroundColorChanged( const KoColor &color );
142
146 void backgroundColorChanged( const KoColor &color );
147
148 protected:
156 virtual void metrics( QRect &foregroundRect, QRect &backgroundRect );
157
158 void paintEvent( QPaintEvent *event ) override;
159 void mousePressEvent( QMouseEvent *event ) override;
160 void mouseMoveEvent( QMouseEvent *event ) override;
161 void mouseReleaseEvent( QMouseEvent *event ) override;
162 void dragEnterEvent( QDragEnterEvent *event ) override;
163 void dropEvent( QDropEvent *event ) override;
164 void changeEvent(QEvent *event) override;
165 bool event(QEvent *event) override;
166
167 private:
168 class Private;
169 Private *const d;
170};
171
172#endif
173
A widget for selecting two related colors.
bool popDialog() const
KoColor foregroundColor() const
KoColor backgroundColor() const
void foregroundColorChanged(const KoColor &color)
void backgroundColorChanged(const KoColor &color)
static KoColorDisplayRendererInterface * instance()