QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgscompoundcolorwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscompoundcolorwidget.h
3  ------------------------
4  begin : April 2016
5  copyright : (C) 2016 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
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 
16 #ifndef QGSCOMPOUNDCOLORWIDGET_H
17 #define QGSCOMPOUNDCOLORWIDGET_H
18 
19 #include "qgisgui.h"
20 #include "qgspanelwidget.h"
21 #include "ui_qgscompoundcolorwidget.h"
22 
30 class GUI_EXPORT QgsCompoundColorWidget : public QgsPanelWidget, private Ui::QgsCompoundColorWidgetBase
31 {
32 
33  Q_OBJECT
34 
35  public:
36 
38  enum Layout
39  {
40  LayoutDefault = 0,
42  };
43 
49  QgsCompoundColorWidget( QWidget *parent = nullptr, const QColor& color = QColor(), Layout layout = LayoutDefault );
50 
52 
56  QColor color() const;
57 
62  void setAllowAlpha( const bool allowAlpha );
63 
64  signals:
65 
69  void currentColorChanged( const QColor &color );
70 
71  public slots:
72 
76  void setColor( const QColor &color );
77 
81  void setPreviousColor( const QColor& color );
82 
83  protected:
84 
85  void mousePressEvent( QMouseEvent* e ) override;
86 
87  void mouseMoveEvent( QMouseEvent *e ) override;
88 
89  void mouseReleaseEvent( QMouseEvent *e ) override;
90 
91  void keyPressEvent( QKeyEvent *e ) override;
92 
93  private slots:
94 
95  void on_mHueRadio_toggled( bool checked );
96  void on_mSaturationRadio_toggled( bool checked );
97  void on_mValueRadio_toggled( bool checked );
98  void on_mRedRadio_toggled( bool checked );
99  void on_mGreenRadio_toggled( bool checked );
100  void on_mBlueRadio_toggled( bool checked );
101 
102  void on_mAddColorToSchemeButton_clicked();
103 
104  void exportColors();
105  void importColors();
106  void importPalette();
107  void removePalette();
108  void newPalette();
109 
110  void schemeIndexChanged( int index );
111  void listSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
112 
113  void on_mAddCustomColorButton_clicked();
114 
115  void on_mSampleButton_clicked();
116  void on_mTabWidget_currentChanged( int index );
117 
118  private slots:
119 
120  void on_mActionShowInButtons_toggled( bool state );
121 
122  private:
123 
124  bool mAllowAlpha;
125 
126  int mLastCustomColorIndex;
127 
128  bool mPickingColor;
129 
132  void saveSettings();
133 
139  void stopPicking( QPoint eventPos, const bool takeSample = true );
140 
145  QColor averageColor( const QImage &image ) const;
146 
151  QColor sampleColor( QPoint point ) const;
152 
155  void refreshSchemeComboBox();
156 
159  QString gplFilePath();
160 
162  void updateActionsForCurrentScheme();
163 };
164 
165 #endif // QGSCOMPOUNDCOLORWIDGET_H
static unsigned index
Base class for any widget that can be shown as a inline panel.
virtual void mouseReleaseEvent(QMouseEvent *event)
void keyPressEvent(QKeyEvent *event)
Overridden key press event to handle the esc event on the widget.
virtual void mousePressEvent(QMouseEvent *event)
A custom QGIS widget for selecting a color, including options for selecting colors via hue wheel...
virtual void mouseMoveEvent(QMouseEvent *event)