QGIS API Documentation  3.0.2-Girona (307d082)
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 "qgsguiutils.h"
20 #include "qgis.h"
21 #include "qgspanelwidget.h"
22 #include "ui_qgscompoundcolorwidget.h"
23 #include "qgis_gui.h"
24 
33 class GUI_EXPORT QgsCompoundColorWidget : public QgsPanelWidget, private Ui::QgsCompoundColorWidgetBase
34 {
35 
36  Q_OBJECT
37 
38  public:
39 
41  enum Layout
42  {
43  LayoutDefault = 0,
45  };
46 
53  QgsCompoundColorWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QColor &color = QColor(), Layout layout = LayoutDefault );
54 
55  ~QgsCompoundColorWidget() override;
56 
61  QColor color() const;
62 
69  void setAllowOpacity( const bool allowOpacity );
70 
77  void setDiscarded( bool discarded ) { mDiscarded = discarded; }
78 
79  signals:
80 
85  void currentColorChanged( const QColor &color );
86 
87  public slots:
88 
93  void setColor( const QColor &color );
94 
99  void setPreviousColor( const QColor &color );
100 
101  protected:
102 
103  void mousePressEvent( QMouseEvent *e ) override;
104 
105  void mouseMoveEvent( QMouseEvent *e ) override;
106 
107  void mouseReleaseEvent( QMouseEvent *e ) override;
108 
109  void keyPressEvent( QKeyEvent *e ) override;
110 
111  private slots:
112 
113  void mHueRadio_toggled( bool checked );
114  void mSaturationRadio_toggled( bool checked );
115  void mValueRadio_toggled( bool checked );
116  void mRedRadio_toggled( bool checked );
117  void mGreenRadio_toggled( bool checked );
118  void mBlueRadio_toggled( bool checked );
119 
120  void mAddColorToSchemeButton_clicked();
121 
122  void importPalette();
123  void removePalette();
124  void newPalette();
125 
126  void schemeIndexChanged( int index );
127  void listSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
128 
129  void mAddCustomColorButton_clicked();
130 
131  void mSampleButton_clicked();
132  void mTabWidget_currentChanged( int index );
133 
134  private slots:
135 
136  void mActionShowInButtons_toggled( bool state );
137 
138  private:
139 
140  static QScreen *findScreenAt( QPoint pos );
141 
142  bool mAllowAlpha = true;
143 
144  int mLastCustomColorIndex = 0;
145 
146  bool mPickingColor = false;
147 
148  bool mDiscarded = false;
149 
153  void saveSettings();
154 
161  void stopPicking( QPoint eventPos, const bool takeSample = true );
162 
168  QColor averageColor( const QImage &image ) const;
169 
175  QColor sampleColor( QPoint point ) const;
176 
180  void refreshSchemeComboBox();
181 
185  QString gplFilePath();
186 
188  void updateActionsForCurrentScheme();
189 };
190 
191 #endif // QGSCOMPOUNDCOLORWIDGET_H
void setDiscarded(bool discarded)
Sets whether the widget's color has been "discarded" and the selected color should not be stored in t...
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
Base class for any widget that can be shown as a inline panel.
A custom QGIS widget for selecting a color, including options for selecting colors via hue wheel...
void keyPressEvent(QKeyEvent *event) override
Overridden key press event to handle the esc event on the widget.
Use a narrower, vertically stacked layout.