QGIS API Documentation 3.41.0-Master (cea29feecf2)
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 Q_OBJECT
37
38 public:
40 enum Layout
41 {
42 LayoutDefault = 0,
44 };
45
52 QgsCompoundColorWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, const QColor &color = QColor(), Layout layout = LayoutDefault );
53
54 ~QgsCompoundColorWidget() override;
55
60 QColor color() const;
61
67 void setAllowOpacity( bool allowOpacity );
68
75 void setColorModelEditable( bool colorModelEditable );
76
82 void setDiscarded( bool discarded ) { mDiscarded = discarded; }
83
94 static QgsUserColorScheme *importUserPaletteFromFile( QWidget *parent );
95
106 static QgsUserColorScheme *createNewUserPalette( QWidget *parent );
107
118 static bool removeUserPalette( QgsUserColorScheme *scheme, QWidget *parent );
119
120 signals:
121
126 void currentColorChanged( const QColor &color );
127
128 public slots:
129
134 void setColor( const QColor &color );
135
140 void setPreviousColor( const QColor &color );
141
142 protected:
143 void hideEvent( QHideEvent *e ) override;
144
145 void mousePressEvent( QMouseEvent *e ) override;
146
147 void mouseMoveEvent( QMouseEvent *e ) override;
148
149 void mouseReleaseEvent( QMouseEvent *e ) override;
150
151 void keyPressEvent( QKeyEvent *e ) override;
152
153 private slots:
154
155 void onColorButtonGroupToggled( int, bool checked );
156
157 void mAddColorToSchemeButton_clicked();
158
159 void importPalette();
160 void removePalette();
161 void newPalette();
162
163 void schemeIndexChanged( int index );
164 void listSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
165
166 void mAddCustomColorButton_clicked();
167
168 void mSampleButton_clicked();
169 void mTabWidget_currentChanged( int index );
170
171 void mActionShowInButtons_toggled( bool state );
172
177 void _setColor( const QColor &color );
178
179 private:
180 static QScreen *findScreenAt( QPoint pos );
181
186 void updateComponent();
187
188 QgsScreenHelper *mScreenHelper = nullptr;
189
190 bool mAllowAlpha = true;
191
192 int mLastCustomColorIndex = 0;
193
194 bool mPickingColor = false;
195
196 bool mDiscarded = false;
197
198 QList<QPair<QRadioButton *, QgsColorWidget::ColorComponent>> mRgbRadios;
199 QList<QPair<QRadioButton *, QgsColorWidget::ColorComponent>> mCmykRadios;
200 QButtonGroup *mCmykGroup = nullptr;
201 QButtonGroup *mRgbGroup = nullptr;
202
206 void saveSettings();
207
214 void stopPicking( QPoint eventPos, bool takeSample = true );
215
221 QColor averageColor( const QImage &image ) const;
222
228 QColor sampleColor( QPoint point ) const;
229
233 void refreshSchemeComboBox();
234
238 static QString gplFilePath();
239
241 void updateActionsForCurrentScheme();
242
243 friend class TestQgsCompoundColorWidget;
244};
245
246#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