QGIS API Documentation  2.99.0-Master (cb63e82)
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 "ui_qgscolordialog.h"
22 #include "qgis_gui.h"
23 
24 class QColor;
25 
33 class GUI_EXPORT QgsColorDialog : public QDialog, private Ui::QgsColorDialogBase
34 {
35 
36  Q_OBJECT
37 
38  public:
39 
45  QgsColorDialog( QWidget *parent = nullptr, Qt::WindowFlags fl = QgisGui::ModalDialogFlags,
46  const QColor &color = QColor() );
47 
51  QColor color() const;
52 
56  void setTitle( const QString &title );
57 
62  void setAllowAlpha( const bool allowAlpha );
63 
74  static QColor getLiveColor( const QColor &initialColor, QObject *updateObject, const char *updateSlot,
75  QWidget *parent = nullptr,
76  const QString &title = QString(),
77  const bool allowAlpha = true );
78 
87  static QColor getColor( const QColor &initialColor, QWidget *parent, const QString &title = QString(),
88  const bool allowAlpha = false );
89 
90  signals:
91 
95  void currentColorChanged( const QColor &color );
96 
97  public slots:
98 
102  void setColor( const QColor &color );
103 
104  protected:
105 
106  void closeEvent( QCloseEvent *e ) override;
107 
108  private slots:
109 
110  void on_mButtonBox_accepted();
111  void on_mButtonBox_rejected();
112  void on_mButtonBox_clicked( QAbstractButton *button );
113  void discardColor();
114 
115  private:
116 
117  QColor mPreviousColor;
118 
119  bool mAllowAlpha;
120 
123  void saveSettings();
124 
125 };
126 
127 #endif // #ifndef QGSCOLORDIALOG_H
A custom QGIS dialog for selecting a color.