QGIS API Documentation 3.39.0-Master (47f7b3a4989)
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
24class QgsScreenHelper;
25
33class GUI_EXPORT QgsCompoundColorWidget : public QgsPanelWidget, private Ui::QgsCompoundColorWidgetBase
34{
35
36 Q_OBJECT
37
38 public:
39
41 enum Layout
42 {
43 LayoutDefault = 0,
45 };
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
75 void setDiscarded( bool discarded ) { mDiscarded = discarded; }
76
87 static QgsUserColorScheme *importUserPaletteFromFile( QWidget *parent );
88
99 static QgsUserColorScheme *createNewUserPalette( QWidget *parent );
100
111 static bool removeUserPalette( QgsUserColorScheme *scheme, QWidget *parent );
112
113 signals:
114
119 void currentColorChanged( const QColor &color );
120
121 public slots:
122
127 void setColor( const QColor &color );
128
133 void setPreviousColor( const QColor &color );
134
135 protected:
136
137 void hideEvent( QHideEvent *e ) override;
138
139 void mousePressEvent( QMouseEvent *e ) override;
140
141 void mouseMoveEvent( QMouseEvent *e ) override;
142
143 void mouseReleaseEvent( QMouseEvent *e ) override;
144
145 void keyPressEvent( QKeyEvent *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
175 static QScreen *findScreenAt( QPoint pos );
176
181 void updateComponent();
182
183 QgsScreenHelper *mScreenHelper = nullptr;
184
185 bool mAllowAlpha = true;
186
187 int mLastCustomColorIndex = 0;
188
189 bool mPickingColor = false;
190
191 bool mDiscarded = false;
192
193 QList<QPair<QRadioButton *, QgsColorWidget::ColorComponent>> mRgbRadios;
194 QList<QPair<QRadioButton *, QgsColorWidget::ColorComponent>> mCmykRadios;
195 QButtonGroup *mCmykGroup = nullptr;
196 QButtonGroup *mRgbGroup = nullptr;
197
201 void saveSettings();
202
209 void stopPicking( QPoint eventPos, bool takeSample = true );
210
216 QColor averageColor( const QImage &image ) const;
217
223 QColor sampleColor( QPoint point ) const;
224
228 void refreshSchemeComboBox();
229
233 static QString gplFilePath();
234
236 void updateActionsForCurrentScheme();
237
238 friend class TestQgsCompoundColorWidget;
239};
240
241#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