QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 = nullptr,
50  const QString& title = "",
51  const QColorDialog::ColorDialogOptions& options = nullptr );
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 = nullptr, const 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 = nullptr,
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 ) override;
138 
139  private slots:
140 
141  void on_mButtonBox_accepted();
142  void on_mButtonBox_rejected();
143  void on_mButtonBox_clicked( QAbstractButton * button );
144 
145  private:
146 
147  QColor mPreviousColor;
148 
149  bool mAllowAlpha;
150 
153  void saveSettings();
154 
155 };
156 
157 #endif // #ifndef QGSCOLORDIALOG_H
static const Qt::WindowFlags ModalDialogFlags
Definition: qgisgui.h:50
virtual void closeEvent(QCloseEvent *e)
A custom QGIS dialog for selecting a color.
typedef ColorDialogOptions
A native operating system dialog for selecting a color.
typedef WindowFlags