KDELibs4Support

kcolordialog.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 1997 Martin Jones ([email protected])
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 //----------------------------------------------------------------------
20 // KDE color selection dialog.
21 
22 // layout management added Oct 1997 by Mario Weilguni
23 // <[email protected]>
24 
25 #ifndef KCOLORDIALOG_H
26 #define KCOLORDIALOG_H
27 
28 #include <kdialog.h>
29 #include <QPixmap>
30 #include <QScrollArea>
31 #include <QTableWidget>
32 #include <kcolorchoosermode.h>
33 
34 #include <kdelibs4support_export.h>
35 
41 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KColorCells : public QTableWidget
42 {
43  Q_OBJECT
44  Q_PROPERTY(bool acceptDrags READ acceptDrags WRITE setAcceptDrags)
45  Q_PROPERTY(bool shading READ shading WRITE setShading)
46 
47 public:
56  KColorCells(QWidget *parent, int rows, int columns);
57  ~KColorCells();
58 
60  void setColor(int index, const QColor &col);
62  QColor color(int index) const;
64  int count() const;
65 
66  void setShading(bool shade);
67  bool shading() const;
68 
69  void setAcceptDrags(bool acceptDrags);
70  bool acceptDrags() const;
71 
73  void setSelected(int index);
75  int selectedIndex() const;
76 
77 Q_SIGNALS:
79  void colorSelected(int index, const QColor &color);
81  void colorDoubleClicked(int index, const QColor &color);
82 
83 protected:
84  // the three methods below are used to ensure equal column widths and row heights
85  // for all cells and to update the widths/heights when the widget is resized
86  int sizeHintForColumn(int column) const override;
87  int sizeHintForRow(int column) const override;
88  void resizeEvent(QResizeEvent *event) override;
89 
90  void mouseReleaseEvent(QMouseEvent *) override;
91  void mousePressEvent(QMouseEvent *) override;
92  void mouseMoveEvent(QMouseEvent *) override;
93  void dragEnterEvent(QDragEnterEvent *) override;
94  void dragMoveEvent(QDragMoveEvent *) override;
95  void dropEvent(QDropEvent *) override;
96  void mouseDoubleClickEvent(QMouseEvent *) override;
97 
98  int positionToCell(const QPoint &pos, bool ignoreBorders = false) const;
99 
100 private:
101  class KColorCellsPrivate;
102  friend class KColorCellsPrivate;
103  KColorCellsPrivate *const d;
104 
106 };
107 
117 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KColorPatch : public QFrame
118 {
119  Q_OBJECT
120  Q_PROPERTY(QColor color READ color WRITE setColor)
121 
122 public:
123  KColorPatch(QWidget *parent);
124  virtual ~KColorPatch();
125 
129  QColor color() const;
130 
136  void setColor(const QColor &col);
137 
138 Q_SIGNALS:
143  void colorChanged(const QColor &);
144 
145 protected:
146  void paintEvent(QPaintEvent *pe) override;
147  void mouseMoveEvent(QMouseEvent *) override;
148  void dragEnterEvent(QDragEnterEvent *) override;
149  void dropEvent(QDropEvent *) override;
150 
151 private:
152  class KColorPatchPrivate;
153  KColorPatchPrivate *const d;
154 
156 };
157 
211 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KColorDialog : public KDialog
212 {
213  Q_OBJECT
214  Q_PROPERTY(bool isAlphaChannelEnabled READ isAlphaChannelEnabled WRITE setAlphaChannelEnabled)
215  Q_PROPERTY(QColor defaultColor READ defaultColor WRITE setDefaultColor)
216  Q_PROPERTY(QColor color READ color WRITE setColor)
217 
218 public:
222  KDELIBS4SUPPORT_DEPRECATED explicit KColorDialog(QWidget *parent = nullptr, bool modal = false);
226  ~KColorDialog();
227 
231  QColor color() const;
232 
243  static int getColor(QColor &theColor, QWidget *parent = nullptr);
244 
260  static int getColor(QColor &theColor, const QColor &defaultColor, QWidget *parent = nullptr);
261 
265  static QColor grabColor(const QPoint &p);
266 
273  void setDefaultColor(const QColor &defaultCol);
274 
278  QColor defaultColor() const;
279 
285  void setAlphaChannelEnabled(bool alpha);
286 
291  bool isAlphaChannelEnabled() const;
292 
293 public Q_SLOTS:
297  void setColor(const QColor &col);
298 
299 Q_SIGNALS:
305  void colorSelected(const QColor &col);
306 
307 private:
308  Q_PRIVATE_SLOT(d, void slotRGBChanged(void))
309  Q_PRIVATE_SLOT(d, void slotAlphaChanged(void))
310  Q_PRIVATE_SLOT(d, void slotHSVChanged(void))
311  Q_PRIVATE_SLOT(d, void slotHtmlChanged(void))
312  Q_PRIVATE_SLOT(d, void slotHSChanged(int, int))
313  Q_PRIVATE_SLOT(d, void slotVChanged(int))
314  Q_PRIVATE_SLOT(d, void slotAChanged(int))
315  Q_PRIVATE_SLOT(d, void slotColorSelected(const QColor &col))
316  Q_PRIVATE_SLOT(d, void slotColorSelected(const QColor &col, const QString &name))
317  Q_PRIVATE_SLOT(d, void slotColorDoubleClicked(const QColor &col, const QString &name))
318  Q_PRIVATE_SLOT(d, void slotColorPicker())
319  Q_PRIVATE_SLOT(d, void slotAddToCustomColors())
320  Q_PRIVATE_SLOT(d, void slotDefaultColorClicked())
321  Q_PRIVATE_SLOT(d, void slotModeChanged(int id))
322 
323 
326  Q_PRIVATE_SLOT(d, void slotWriteSettings())
327 
328 private:
332  void readSettings();
333 
334 protected:
335  void mouseMoveEvent(QMouseEvent *) override;
336  void mouseReleaseEvent(QMouseEvent *) override;
337  void keyPressEvent(QKeyEvent *) override;
338  bool eventFilter(QObject *obj, QEvent *ev) override;
339 
340 private:
341  class KColorDialogPrivate;
342  KColorDialogPrivate *const d;
343 
344  Q_DISABLE_COPY(KColorDialog)
345 };
346 
347 #endif // KCOLORDIALOG_H
virtual void dropEvent(QDropEvent *event)
virtual void dragEnterEvent(QDragEnterEvent *event)
virtual void resizeEvent(QResizeEvent *event) override
A dialog base class with standard buttons and predefined layouts.
Definition: kdialog.h:128
virtual void mouseReleaseEvent(QMouseEvent *event)
virtual void mouseReleaseEvent(QMouseEvent *event) override
virtual int sizeHintForRow(int row) const const override
virtual void paintEvent(QPaintEvent *) override
void keyPressEvent(QKeyEvent *) override
Definition: kdialog.cpp:416
virtual void mouseMoveEvent(QMouseEvent *event)
A table of editable color cells.
Definition: kcolordialog.h:41
virtual void dragEnterEvent(QDragEnterEvent *event) override
virtual void dropEvent(QDropEvent *event) override
A color displayer.
Definition: kcolordialog.h:117
Q_PROPERTY(...)
virtual void mouseMoveEvent(QMouseEvent *event) override
Q_DISABLE_COPY(Class)
A color selection dialog.
Definition: kcolordialog.h:211
virtual void mousePressEvent(QMouseEvent *event) override
virtual int sizeHintForColumn(int column) const const override
virtual bool eventFilter(QObject *o, QEvent *e) override
virtual void dragMoveEvent(QDragMoveEvent *event) override
virtual void mouseDoubleClickEvent(QMouseEvent *event) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun May 31 2020 23:00:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.