• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • sources
  • kde-4.12
  • kdelibs
  • kdeui
  • colors
kcolordialog.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 1997 Martin Jones (mjones@kde.org)
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 // <mweilguni@sime.com>
24 
25 #ifndef KCOLORDIALOG_H
26 #define KCOLORDIALOG_H
27 
28 #include <kdialog.h>
29 #include <QtGui/QPixmap>
30 #include <QtGui/QScrollArea>
31 #include <QtGui/QTableWidget>
32 #include <kcolorchoosermode.h>
33 
34 
40 class KDEUI_EXPORT KColorCells : public QTableWidget
41 {
42  Q_OBJECT
43  Q_PROPERTY(bool acceptDrags READ acceptDrags WRITE setAcceptDrags)
44  Q_PROPERTY(bool shading READ shading WRITE setShading)
45 
46 public:
55  KColorCells( QWidget *parent, int rows, int columns );
56  ~KColorCells();
57 
59  void setColor( int index, const QColor &col );
61  QColor color( int index ) const;
63  int count() const;
64 
65  void setShading(bool shade);
66  bool shading() const;
67 
68  void setAcceptDrags(bool acceptDrags);
69  bool acceptDrags() const;
70 
72  void setSelected(int index);
74  int selectedIndex() const;
75 
76 Q_SIGNALS:
78  void colorSelected( int index , const QColor& color );
80  void colorDoubleClicked( int index , const QColor& color );
81 
82 protected:
83  // the three methods below are used to ensure equal column widths and row heights
84  // for all cells and to update the widths/heights when the widget is resized
85  virtual int sizeHintForColumn(int column) const;
86  virtual int sizeHintForRow(int column) const;
87  virtual void resizeEvent( QResizeEvent* event );
88 
89  virtual void mouseReleaseEvent( QMouseEvent * );
90  virtual void mousePressEvent( QMouseEvent * );
91  virtual void mouseMoveEvent( QMouseEvent * );
92  virtual void dragEnterEvent( QDragEnterEvent * );
93  virtual void dragMoveEvent( QDragMoveEvent * );
94  virtual void dropEvent( QDropEvent *);
95  virtual void mouseDoubleClickEvent( QMouseEvent * );
96 
97  int positionToCell(const QPoint &pos, bool ignoreBorders=false) const;
98 
99 private:
100  class KColorCellsPrivate;
101  friend class KColorCellsPrivate;
102  KColorCellsPrivate *const d;
103 
104  Q_DISABLE_COPY(KColorCells)
105 };
106 
116 class KDEUI_EXPORT KColorPatch : public QFrame
117 {
118  Q_OBJECT
119  Q_PROPERTY(QColor color READ color WRITE setColor)
120 
121 public:
122  KColorPatch( QWidget *parent );
123  virtual ~KColorPatch();
124 
128  QColor color() const;
129 
135  void setColor( const QColor &col );
136 
137 Q_SIGNALS:
142  void colorChanged(const QColor&);
143 
144 protected:
145  virtual void paintEvent ( QPaintEvent * pe );
146  virtual void mouseMoveEvent( QMouseEvent * );
147  virtual void dragEnterEvent( QDragEnterEvent *);
148  virtual void dropEvent( QDropEvent *);
149 
150 private:
151  class KColorPatchPrivate;
152  KColorPatchPrivate *const d;
153 
154  Q_DISABLE_COPY(KColorPatch)
155 };
156 
210 class KDEUI_EXPORT KColorDialog : public KDialog
211 {
212  Q_OBJECT
213  Q_PROPERTY(bool isAlphaChannelEnabled READ isAlphaChannelEnabled WRITE setAlphaChannelEnabled)
214  Q_PROPERTY(QColor defaultColor READ defaultColor WRITE setDefaultColor)
215  Q_PROPERTY(QColor color READ color WRITE setColor)
216 
217  public:
221  explicit KColorDialog( QWidget *parent = 0L, bool modal = false );
225  ~KColorDialog();
226 
230  QColor color() const;
231 
242  static int getColor( QColor &theColor, QWidget *parent=0L );
243 
259  static int getColor( QColor &theColor, const QColor& defaultColor, QWidget *parent=0L );
260 
264  static QColor grabColor(const QPoint &p);
265 
272  void setDefaultColor( const QColor& defaultCol );
273 
277  QColor defaultColor() const;
278 
284  void setAlphaChannelEnabled(bool alpha);
285 
290  bool isAlphaChannelEnabled() const;
291 
292  public Q_SLOTS:
296  void setColor( const QColor &col );
297 
298  Q_SIGNALS:
304  void colorSelected( const QColor &col );
305 
306  private:
307  Q_PRIVATE_SLOT(d, void slotRGBChanged( void ))
308  Q_PRIVATE_SLOT(d, void slotAlphaChanged( void ))
309  Q_PRIVATE_SLOT(d, void slotHSVChanged( void ))
310  Q_PRIVATE_SLOT(d, void slotHtmlChanged( void ))
311  Q_PRIVATE_SLOT(d, void slotHSChanged( int, int ))
312  Q_PRIVATE_SLOT(d, void slotVChanged( int ))
313  Q_PRIVATE_SLOT(d, void slotAChanged( int ))
314  Q_PRIVATE_SLOT(d, void slotColorSelected( const QColor &col ))
315  Q_PRIVATE_SLOT(d, void slotColorSelected( const QColor &col, const QString &name ))
316  Q_PRIVATE_SLOT(d, void slotColorDoubleClicked( const QColor &col, const QString &name ))
317  Q_PRIVATE_SLOT(d, void slotColorPicker())
318  Q_PRIVATE_SLOT(d, void slotAddToCustomColors())
319  Q_PRIVATE_SLOT(d, void slotDefaultColorClicked())
320  Q_PRIVATE_SLOT(d, void slotModeChanged( int id ))
321 
325  Q_PRIVATE_SLOT(d, void slotWriteSettings())
326 
327  private:
331  void readSettings();
332 
333  protected:
334  virtual void mouseMoveEvent( QMouseEvent * );
335  virtual void mouseReleaseEvent( QMouseEvent * );
336  virtual void keyPressEvent( QKeyEvent * );
337  virtual bool eventFilter( QObject *obj, QEvent *ev );
338 
339  private:
340  class KColorDialogPrivate;
341  KColorDialogPrivate *const d;
342 
343  Q_DISABLE_COPY(KColorDialog)
344 };
345 
346 #endif // KCOLORDIALOG_H
QColor
kdialog.h
QTableWidget
QWidget
KStandardAction::name
const char * name(StandardAction id)
This will return the internal name of a given standard action.
Definition: kstandardaction.cpp:223
KDialog
A dialog base class with standard buttons and predefined layouts.
Definition: kdialog.h:128
QString
QObject
kcolorchoosermode.h
KColorCells
A table of editable color cells.
Definition: kcolordialog.h:40
KColorUtils::shade
QColor shade(const QColor &, qreal lumaAmount, qreal chromaAmount=0.0)
Adjust the luma and chroma components of a color.
Definition: kcolorutils.cpp:71
KColorPatch
A color displayer.
Definition: kcolordialog.h:116
QPoint
KColorDialog
A color selection dialog.
Definition: kcolordialog.h:210
QFrame
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:14 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal