QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgscolordialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscolordialog.h - color selection dialog
3 
4  ---------------------
5  begin : March 19, 2013
6  copyright : (C) 2013 by Larry Shaffer
7  email : larrys at dakcarto dot com
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSCOLORDIALOG_H
18 #define QGSCOLORDIALOG_H
19 
20 #include <QColorDialog>
21 #include "qgisgui.h"
22 #include "ui_qgscolordialog.h"
23 
24 class QColor;
25 
31 class GUI_EXPORT QgsColorDialog : public QObject
32 {
33  Q_OBJECT
34 
35  public:
37  ~QgsColorDialog();
38 
48  static QColor getLiveColor( const QColor& initialColor, QObject* updateObject, const char* updateSlot,
49  QWidget* parent = 0,
50  const QString& title = "",
51  QColorDialog::ColorDialogOptions options = 0 );
52 };
53 
54 
62 class GUI_EXPORT QgsColorDialogV2 : public QDialog, private Ui::QgsColorDialogBase
63 {
64 
65  Q_OBJECT
66 
67  public:
68 
74  QgsColorDialogV2( QWidget *parent = 0, Qt::WindowFlags fl = QgisGui::ModalDialogFlags,
75  const QColor& color = QColor() );
76 
78 
82  QColor color() const;
83 
87  void setTitle( const QString title );
88 
93  void setAllowAlpha( const bool allowAlpha );
94 
105  static QColor getLiveColor( const QColor& initialColor, QObject* updateObject, const char* updateSlot,
106  QWidget* parent = 0,
107  const QString& title = QString(),
108  const bool allowAlpha = true );
109 
118  static QColor getColor( const QColor &initialColor, QWidget *parent, const QString &title = QString(),
119  const bool allowAlpha = false );
120 
121  signals:
122 
126  void currentColorChanged( const QColor &color );
127 
128  public slots:
129 
133  void setColor( const QColor &color );
134 
135  protected:
136 
137  void closeEvent( QCloseEvent* e );
138 
139  void mousePressEvent( QMouseEvent* e );
140 
141  void mouseMoveEvent( QMouseEvent *e );
142 
143  void mouseReleaseEvent( QMouseEvent *e );
144 
145  void keyPressEvent( QKeyEvent *e );
146 
147  private slots:
148 
149  void on_mHueRadio_toggled( bool checked );
150  void on_mSaturationRadio_toggled( bool checked );
151  void on_mValueRadio_toggled( bool checked );
152  void on_mRedRadio_toggled( bool checked );
153  void on_mGreenRadio_toggled( bool checked );
154  void on_mBlueRadio_toggled( bool checked );
155 
156  void on_mButtonBox_accepted();
157  void on_mButtonBox_rejected();
158  void on_mButtonBox_clicked( QAbstractButton * button );
159  void on_mAddColorToSchemeButton_clicked();
160 
161  void exportColors();
162  void importColors();
163  void importPalette();
164  void removePalette();
165  void newPalette();
166 
167  void schemeIndexChanged( int index );
168  void listSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
169 
170  void on_mAddCustomColorButton_clicked();
171 
172  void on_mSampleButton_clicked();
173  void on_mTabWidget_currentChanged( int index );
174 
175  private:
176 
177  QColor mPreviousColor;
178 
179  bool mAllowAlpha;
180 
181  int mLastCustomColorIndex;
182 
183  bool mPickingColor;
184 
187  void saveSettings();
188 
194  void stopPicking( const QPoint& eventPos, const bool takeSample = true );
195 
200  QColor averageColor( const QImage &image ) const;
201 
206  QColor sampleColor( const QPoint &point ) const;
207 
210  void refreshSchemeComboBox();
211 
214  QString gplFilePath();
215 };
216 
217 #endif // #ifndef QGSCOLORDIALOG_H
static const Qt::WindowFlags ModalDialogFlags
Definition: qgisgui.h:47
static unsigned index
A custom QGIS dialog for selecting a color.
A native operating system dialog for selecting a color.