QGIS API Documentation 4.3.0-Master (0cef2469b72)
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;
28
35
36class GUI_EXPORT QgsCompoundColorWidget : public QgsPanelWidget, private Ui::QgsCompoundColorWidgetBase
37{
38 Q_OBJECT
39
40 public:
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 void hideEvent( QHideEvent *e ) override;
146
147 private slots:
148
149 void onColorButtonGroupToggled( int, bool checked );
150
151 void mAddColorToSchemeButton_clicked();
152
153 void importPalette();
154 void removePalette();
155 void newPalette();
156
157 void schemeIndexChanged( int index );
158 void listSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
159
160 void mAddCustomColorButton_clicked();
161
162 void mSampleButton_clicked();
163 void mTabWidget_currentChanged( int index );
164
165 void mActionShowInButtons_toggled( bool state );
166
171 void _setColor( const QColor &color );
172
173 private:
174 static QScreen *findScreenAt( QPoint pos );
175
180 void updateComponent();
181
182 QgsScreenHelper *mScreenHelper = nullptr;
183
184 bool mAllowAlpha = true;
185
186 int mLastCustomColorIndex = 0;
187
188 bool mDiscarded = false;
189
190 QList<QPair<QRadioButton *, QgsColorWidget::ColorComponent>> mRgbRadios;
191 QList<QPair<QRadioButton *, QgsColorWidget::ColorComponent>> mCmykRadios;
192 QButtonGroup *mCmykGroup = nullptr;
193 QButtonGroup *mRgbGroup = nullptr;
194
195 QgsColorPickerHelper *mPickerHelper = nullptr;
196
200 void saveSettings();
201
205 void refreshSchemeComboBox();
206
210 static QString gplFilePath();
211
213 void updateActionsForCurrentScheme();
214
215 void onColorPicked( const QColor &color );
216 void onColorHovered( const QColor &color );
217 void colorPickingCanceled();
218
220};
221
222#endif // QGSCOMPOUNDCOLORWIDGET_H
A utility class for sampling colors from the screen.
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 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 setColor(const QColor &color)
Sets the current color for the dialog.
QColor color() const
Returns the current color for the dialog.
QgsPanelWidget(QWidget *parent=nullptr)
Base class for any widget that can be shown as an inline panel.
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:52