QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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 "qgis_sip.h"
20#include "qgspanelwidget.h"
21#include "ui_qgscompoundcolorwidget.h"
22#include "qgis_gui.h"
23
24class QgsScreenHelper;
25
34class GUI_EXPORT QgsCompoundColorWidget : public QgsPanelWidget, private Ui::QgsCompoundColorWidgetBase
35{
36
37 Q_OBJECT
38
39 public:
40
42 enum Layout
43 {
44 LayoutDefault = 0,
46 };
47
54 QgsCompoundColorWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QColor &color = QColor(), Layout layout = LayoutDefault );
55
56 ~QgsCompoundColorWidget() override;
57
62 QColor color() const;
63
70 void setAllowOpacity( bool allowOpacity );
71
78 void setDiscarded( bool discarded ) { mDiscarded = discarded; }
79
90 static QgsUserColorScheme *importUserPaletteFromFile( QWidget *parent );
91
102 static QgsUserColorScheme *createNewUserPalette( QWidget *parent );
103
114 static bool removeUserPalette( QgsUserColorScheme *scheme, QWidget *parent );
115
116 signals:
117
122 void currentColorChanged( const QColor &color );
123
124 public slots:
125
130 void setColor( const QColor &color );
131
136 void setPreviousColor( const QColor &color );
137
138 protected:
139
140 void hideEvent( QHideEvent *e ) override;
141
142 void mousePressEvent( QMouseEvent *e ) override;
143
144 void mouseMoveEvent( QMouseEvent *e ) override;
145
146 void mouseReleaseEvent( QMouseEvent *e ) override;
147
148 void keyPressEvent( QKeyEvent *e ) override;
149
150 private slots:
151
152 void mHueRadio_toggled( bool checked );
153 void mSaturationRadio_toggled( bool checked );
154 void mValueRadio_toggled( bool checked );
155 void mRedRadio_toggled( bool checked );
156 void mGreenRadio_toggled( bool checked );
157 void mBlueRadio_toggled( bool checked );
158
159 void mAddColorToSchemeButton_clicked();
160
161 void importPalette();
162 void removePalette();
163 void newPalette();
164
165 void schemeIndexChanged( int index );
166 void listSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
167
168 void mAddCustomColorButton_clicked();
169
170 void mSampleButton_clicked();
171 void mTabWidget_currentChanged( int index );
172
173 private slots:
174
175 void mActionShowInButtons_toggled( bool state );
176
177 private:
178
179 static QScreen *findScreenAt( QPoint pos );
180
181 QgsScreenHelper *mScreenHelper = nullptr;
182
183 bool mAllowAlpha = true;
184
185 int mLastCustomColorIndex = 0;
186
187 bool mPickingColor = false;
188
189 bool mDiscarded = false;
190
194 void saveSettings();
195
202 void stopPicking( QPoint eventPos, bool takeSample = true );
203
209 QColor averageColor( const QImage &image ) const;
210
216 QColor sampleColor( QPoint point ) const;
217
221 void refreshSchemeComboBox();
222
226 static QString gplFilePath();
227
229 void updateActionsForCurrentScheme();
230};
231
232#endif // QGSCOMPOUNDCOLORWIDGET_H
A custom QGIS widget for selecting a color, including options for selecting colors via hue wheel,...
@ LayoutVertical
Use a narrower, vertically stacked layout.
void currentColorChanged(const QColor &color)
Emitted when the dialog's color changes.
void setDiscarded(bool discarded)
Sets whether the widget's color has been "discarded" and the selected color should not be stored in t...
Base class for any widget that can be shown as a inline panel.
void keyPressEvent(QKeyEvent *event) override
Overridden key press event to handle the esc event on the widget.
A utility class for dynamic handling of changes to screen properties.
A color scheme which stores its colors in a gpl palette file within the "palettes" subfolder off the ...
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53