QGIS API Documentation  2.0.1-Dufour
 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 
144  private slots:
145  void onButtonClicked();
146 
152  void setValidColor( const QColor& newColor );
153 };
154 
155 #endif