QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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#include "qgis.h"
24
25class QgsScreenHelper;
26
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
69 void setAllowOpacity( bool allowOpacity );
70
77 void setColorModelEditable( bool colorModelEditable );
78
84 void setDiscarded( bool discarded ) { mDiscarded = discarded; }
85
96 static QgsUserColorScheme *importUserPaletteFromFile( QWidget *parent );
97
108 static QgsUserColorScheme *createNewUserPalette( QWidget *parent );
109
120 static bool removeUserPalette( QgsUserColorScheme *scheme, QWidget *parent );
121
122 signals:
123
128 void currentColorChanged( const QColor &color );
129
130 public slots:
131
136 void setColor( const QColor &color );
137
142 void setPreviousColor( const QColor &color );
143
144 protected:
145
146 void hideEvent( QHideEvent *e ) override;
147
148 void mousePressEvent( QMouseEvent *e ) override;
149
150 void mouseMoveEvent( QMouseEvent *e ) override;
151
152 void mouseReleaseEvent( QMouseEvent *e ) override;
153
154 void keyPressEvent( QKeyEvent *e ) override;
155
156 private slots:
157
158 void onColorButtonGroupToggled( int, bool checked );
159
160 void mAddColorToSchemeButton_clicked();
161
162 void importPalette();
163 void removePalette();
164 void newPalette();
165
166 void schemeIndexChanged( int index );
167 void listSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
168
169 void mAddCustomColorButton_clicked();
170
171 void mSampleButton_clicked();
172 void mTabWidget_currentChanged( int index );
173
174 void mActionShowInButtons_toggled( bool state );
175
180 void _setColor( const QColor &color );
181
182 private:
183
184 static QScreen *findScreenAt( QPoint pos );
185
190 void updateComponent();
191
192 QgsScreenHelper *mScreenHelper = nullptr;
193
194 bool mAllowAlpha = true;
195
196 int mLastCustomColorIndex = 0;
197
198 bool mPickingColor = false;
199
200 bool mDiscarded = false;
201
202 QList<QPair<QRadioButton *, QgsColorWidget::ColorComponent>> mRgbRadios;
203 QList<QPair<QRadioButton *, QgsColorWidget::ColorComponent>> mCmykRadios;
204 QButtonGroup *mCmykGroup = nullptr;
205 QButtonGroup *mRgbGroup = nullptr;
206
210 void saveSettings();
211
218 void stopPicking( QPoint eventPos, bool takeSample = true );
219
225 QColor averageColor( const QImage &image ) const;
226
232 QColor sampleColor( QPoint point ) const;
233
237 void refreshSchemeComboBox();
238
242 static QString gplFilePath();
243
245 void updateActionsForCurrentScheme();
246
247 friend class TestQgsCompoundColorWidget;
248};
249
250#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