QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "ui_qgscompoundcolorwidget.h"
20
21#include "qgis.h"
22#include "qgis_gui.h"
23#include "qgis_sip.h"
24#include "qgspanelwidget.h"
25
26class QgsScreenHelper;
27
34
35class GUI_EXPORT QgsCompoundColorWidget : public QgsPanelWidget, private Ui::QgsCompoundColorWidgetBase
36{
37 Q_OBJECT
38
39 public:
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
68 void setAllowOpacity( bool allowOpacity );
69
76 void setColorModelEditable( bool colorModelEditable );
77
83 void setDiscarded( bool discarded ) { mDiscarded = discarded; }
84
95 static QgsUserColorScheme *importUserPaletteFromFile( QWidget *parent );
96
107 static QgsUserColorScheme *createNewUserPalette( QWidget *parent );
108
119 static bool removeUserPalette( QgsUserColorScheme *scheme, QWidget *parent );
120
121 signals:
122
127 void currentColorChanged( const QColor &color );
128
129 public slots:
130
135 void setColor( const QColor &color );
136
141 void setPreviousColor( const QColor &color );
142
143 protected:
144 void hideEvent( QHideEvent *e ) override;
145
146 void mousePressEvent( QMouseEvent *e ) override;
147
148 void mouseMoveEvent( QMouseEvent *e ) override;
149
150 void mouseReleaseEvent( QMouseEvent *e ) override;
151
152 void keyPressEvent( QKeyEvent *e ) override;
153
154 private slots:
155
156 void onColorButtonGroupToggled( int, bool checked );
157
158 void mAddColorToSchemeButton_clicked();
159
160 void importPalette();
161 void removePalette();
162 void newPalette();
163
164 void schemeIndexChanged( int index );
165 void listSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
166
167 void mAddCustomColorButton_clicked();
168
169 void mSampleButton_clicked();
170 void mTabWidget_currentChanged( int index );
171
172 void mActionShowInButtons_toggled( bool state );
173
178 void _setColor( const QColor &color );
179
180 private:
181 static QScreen *findScreenAt( QPoint pos );
182
187 void updateComponent();
188
189 QgsScreenHelper *mScreenHelper = nullptr;
190
191 bool mAllowAlpha = true;
192
193 int mLastCustomColorIndex = 0;
194
195 bool mPickingColor = false;
196
197 bool mDiscarded = false;
198
199 QList<QPair<QRadioButton *, QgsColorWidget::ColorComponent>> mRgbRadios;
200 QList<QPair<QRadioButton *, QgsColorWidget::ColorComponent>> mCmykRadios;
201 QButtonGroup *mCmykGroup = nullptr;
202 QButtonGroup *mRgbGroup = nullptr;
203
207 void saveSettings();
208
215 void stopPicking( QPoint eventPos, bool takeSample = true );
216
222 QColor averageColor( const QImage &image ) const;
223
229 QColor sampleColor( QPoint point ) const;
230
234 void refreshSchemeComboBox();
235
239 static QString gplFilePath();
240
242 void updateActionsForCurrentScheme();
243
245};
246
247#endif // QGSCOMPOUNDCOLORWIDGET_H
A custom QGIS widget for selecting a color, including options for selecting colors via hue wheel,...
@ LayoutDefault
Use the default (rectangular) layout.
@ LayoutVertical
Use a narrower, vertically stacked layout.
void currentColorChanged(const QColor &color)
Emitted when the dialog's color changes.
void hideEvent(QHideEvent *e) override
QgsCompoundColorWidget(QWidget *parent=nullptr, const QColor &color=QColor(), Layout layout=LayoutDefault)
Constructor for QgsCompoundColorWidget.
void mousePressEvent(QMouseEvent *e) override
void setPreviousColor(const QColor &color)
Sets the color to show in an optional "previous color" section.
void setDiscarded(bool discarded)
Sets whether the widget's color has been "discarded" and the selected color should not be stored in t...
void mouseMoveEvent(QMouseEvent *e) override
void setColor(const QColor &color)
Sets the current color for the dialog.
QColor color() const
Returns the current color for the dialog.
void mouseReleaseEvent(QMouseEvent *e) override
QgsPanelWidget(QWidget *parent=nullptr)
Base class for any widget that can be shown as an 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