QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscolorbutton.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscolorbutton.h - Color button
3  --------------------------------------
4  Date : 12-Dec-2006
5  Copyright : (C) 2006 by Tom Elwertowski
6  Email : telwertowski at users dot sourceforge dot net
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSCOLORBUTTON_H
16 #define QGSCOLORBUTTON_H
17 
18 #include <QColorDialog>
19 #include <QPushButton>
20 #include <QTemporaryFile>
21 
22 
30 class GUI_EXPORT QgsColorButton: public QPushButton
31 {
32  Q_OBJECT
33 
34  public:
43  QgsColorButton( QWidget *parent = 0, QString cdt = "", QColorDialog::ColorDialogOptions cdo = 0 );
44  ~QgsColorButton();
45 
52  void setColor( const QColor &color );
59  QColor color() const;
60 
67  void setColorDialogOptions( QColorDialog::ColorDialogOptions cdo );
68 
75  QColorDialog::ColorDialogOptions colorDialogOptions();
76 
83  void setColorDialogTitle( QString cdt );
84 
91  QString colorDialogTitle();
92 
98  bool acceptLiveUpdates() { return mAcceptLiveUpdates; }
99 
106  void setAcceptLiveUpdates( bool accept ) { mAcceptLiveUpdates = accept; }
107 
108  public slots:
117  void setButtonBackground();
118 
119  signals:
127  void colorChanged( const QColor &color );
128 
129  protected:
130  void changeEvent( QEvent* e );
131 #if 0 // causes too many cyclical updates, but may be needed on some platforms
132  void paintEvent( QPaintEvent* e );
133 #endif
134  void showEvent( QShowEvent* e );
135  static const QPixmap& transpBkgrd();
136 
137  private:
139  QColor mColor;
140  QColorDialog::ColorDialogOptions mColorDialogOptions;
142  QTemporaryFile mTempPNG;
143  bool mColorSet; // added in QGIS 2.1
144 
145  private slots:
146  void onButtonClicked();
147 
153  void setValidColor( const QColor& newColor );
154 };
155 
156 #endif
void setAcceptLiveUpdates(bool accept)
Sets whether the button accepts live updates from QColorDialog.
A cross platform button subclass for selecting colors. Will open a color chooser dialog when clicked...
QColorDialog::ColorDialogOptions mColorDialogOptions
QString mColorDialogTitle
QTemporaryFile mTempPNG
bool acceptLiveUpdates()
Whether the button accepts live updates from QColorDialog.