QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgssymbolbutton.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbolbutton.h
3  -----------------
4  Date : July 2017
5  Copyright : (C) 2017 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 #include "qgssymbolbutton.h"
17 #include "qgspanelwidget.h"
18 #include "qgsexpressioncontext.h"
20 #include "qgsvectorlayer.h"
22 #include "qgsstyle.h"
23 #include "qgscolorwidgets.h"
24 #include "qgscolorschemeregistry.h"
25 #include "qgscolorswatchgrid.h"
26 #include "qgssymbollayerutils.h"
27 #include "qgsguiutils.h"
28 #include <QMenu>
29 #include <QClipboard>
30 #include <QDrag>
31 
32 QgsSymbolButton::QgsSymbolButton( QWidget *parent, const QString &dialogTitle )
33  : QToolButton( parent )
34  , mDialogTitle( dialogTitle.isEmpty() ? tr( "Symbol Settings" ) : dialogTitle )
35 {
36  mSymbol.reset( QgsFillSymbol::createSimple( QgsStringMap() ) );
37 
38  setAcceptDrops( true );
39  connect( this, &QAbstractButton::clicked, this, &QgsSymbolButton::showSettingsDialog );
40 
41  //setup dropdown menu
42  mMenu = new QMenu( this );
43  connect( mMenu, &QMenu::aboutToShow, this, &QgsSymbolButton::prepareMenu );
44  setMenu( mMenu );
45  setPopupMode( QToolButton::MenuButtonPopup );
46 
47  //make sure height of button looks good under different platforms
48  QSize size = QToolButton::minimumSizeHint();
49  int fontHeight = static_cast< int >( Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 1.4 );
50  mSizeHint = QSize( size.width(), std::max( size.height(), fontHeight ) );
51 }
52 
54 {
55 
56  return mSizeHint;
57 }
58 
60 {
61  return mSizeHint;
62 }
63 
65 {
66  if ( type != mType )
67  {
68  switch ( type )
69  {
70  case QgsSymbol::Marker:
71  mSymbol.reset( QgsMarkerSymbol::createSimple( QgsStringMap() ) );
72  break;
73 
74  case QgsSymbol::Line:
75  mSymbol.reset( QgsLineSymbol::createSimple( QgsStringMap() ) );
76  break;
77 
78  case QgsSymbol::Fill:
79  mSymbol.reset( QgsFillSymbol::createSimple( QgsStringMap() ) );
80  break;
81 
82  case QgsSymbol::Hybrid:
83  break;
84  }
85  }
86  updatePreview();
87  mType = type;
88 }
89 
90 void QgsSymbolButton::showSettingsDialog()
91 {
92  QgsExpressionContext context;
93  if ( mExpressionContextGenerator )
94  context = mExpressionContextGenerator->createExpressionContext();
95  else
96  {
98  }
99  QgsSymbol *newSymbol = mSymbol->clone();
100 
101  QgsSymbolWidgetContext symbolContext;
102  symbolContext.setExpressionContext( &context );
103  symbolContext.setMapCanvas( mMapCanvas );
104 
106  if ( panel && panel->dockMode() )
107  {
108  QgsSymbolSelectorWidget *d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), mLayer, nullptr );
109  d->setContext( symbolContext );
110  connect( d, &QgsPanelWidget::widgetChanged, this, &QgsSymbolButton::updateSymbolFromWidget );
111  connect( d, &QgsPanelWidget::panelAccepted, this, &QgsSymbolButton::cleanUpSymbolSelector );
112  panel->openPanel( d );
113  }
114  else
115  {
116  QgsSymbolSelectorDialog dialog( newSymbol, QgsStyle::defaultStyle(), mLayer, nullptr );
117  dialog.setWindowTitle( mDialogTitle );
118  dialog.setContext( symbolContext );
119  if ( dialog.exec() )
120  {
121  setSymbol( newSymbol );
122  }
123  else
124  {
125  delete newSymbol;
126  }
127 
128  // reactivate button's window
129  activateWindow();
130  }
131 }
132 
133 void QgsSymbolButton::updateSymbolFromWidget()
134 {
135  if ( QgsSymbolSelectorWidget *w = qobject_cast<QgsSymbolSelectorWidget *>( sender() ) )
136  setSymbol( w->symbol()->clone() );
137 }
138 
139 void QgsSymbolButton::cleanUpSymbolSelector( QgsPanelWidget *container )
140 {
141  QgsSymbolSelectorWidget *w = qobject_cast<QgsSymbolSelectorWidget *>( container );
142  if ( !w )
143  return;
144 
145  delete w->symbol();
146 }
147 
149 {
150  return mMapCanvas;
151 }
152 
154 {
155  mMapCanvas = mapCanvas;
156 }
157 
159 {
160  return mLayer;
161 }
162 
164 {
165  mLayer = layer;
166 }
167 
169 {
170  mExpressionContextGenerator = generator;
171 }
172 
174 {
175  mSymbol.reset( symbol );
176  updatePreview();
177  emit changed();
178 }
179 
180 void QgsSymbolButton::setColor( const QColor &color )
181 {
182  QColor opaque = color;
183  opaque.setAlphaF( 1.0 );
184 
185  if ( opaque == mSymbol->color() )
186  return;
187 
188  mSymbol->setColor( opaque );
189  updatePreview();
190  emit changed();
191 }
192 
194 {
195  QApplication::clipboard()->setMimeData( QgsSymbolLayerUtils::symbolToMimeData( mSymbol.get() ) );
196 }
197 
199 {
200  std::unique_ptr< QgsSymbol > symbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) );
201  if ( symbol && symbol->type() == mType )
202  setSymbol( symbol.release() );
203 }
204 
206 {
207  QApplication::clipboard()->setMimeData( QgsSymbolLayerUtils::colorToMimeData( mSymbol->color() ) );
208 }
209 
211 {
212  QColor clipColor;
213  bool hasAlpha = false;
214  if ( colorFromMimeData( QApplication::clipboard()->mimeData(), clipColor, hasAlpha ) )
215  {
216  //paste color
217  setColor( clipColor );
219  }
220 }
221 
222 void QgsSymbolButton::mousePressEvent( QMouseEvent *e )
223 {
224  if ( e->button() == Qt::RightButton )
225  {
226  QToolButton::showMenu();
227  return;
228  }
229  else if ( e->button() == Qt::LeftButton )
230  {
231  mDragStartPosition = e->pos();
232  }
233  QToolButton::mousePressEvent( e );
234 }
235 
236 void QgsSymbolButton::mouseMoveEvent( QMouseEvent *e )
237 {
238  //handle dragging colors/symbols from button
239 
240  if ( !( e->buttons() & Qt::LeftButton ) )
241  {
242  //left button not depressed, so not a drag
243  QToolButton::mouseMoveEvent( e );
244  return;
245  }
246 
247  if ( ( e->pos() - mDragStartPosition ).manhattanLength() < QApplication::startDragDistance() )
248  {
249  //mouse not moved, so not a drag
250  QToolButton::mouseMoveEvent( e );
251  return;
252  }
253 
254  //user is dragging
255  QDrag *drag = new QDrag( this );
256  drag->setMimeData( QgsSymbolLayerUtils::colorToMimeData( mSymbol->color() ) );
257  drag->setPixmap( QgsColorWidget::createDragIcon( mSymbol->color() ) );
258  drag->exec( Qt::CopyAction );
259  setDown( false );
260 }
261 
262 void QgsSymbolButton::dragEnterEvent( QDragEnterEvent *e )
263 {
264  //is dragged data valid color data?
265  QColor mimeColor;
266  bool hasAlpha = false;
267 
268  if ( colorFromMimeData( e->mimeData(), mimeColor, hasAlpha ) )
269  {
270  //if so, we accept the drag, and temporarily change the button's color
271  //to match the dragged color. This gives immediate feedback to the user
272  //that colors can be dropped here
273  e->acceptProposedAction();
274  updatePreview( mimeColor );
275  }
276 }
277 
278 void QgsSymbolButton::dragLeaveEvent( QDragLeaveEvent *e )
279 {
280  Q_UNUSED( e );
281  //reset button color
282  updatePreview();
283 }
284 
285 void QgsSymbolButton::dropEvent( QDropEvent *e )
286 {
287  //is dropped data valid format data?
288  QColor mimeColor;
289  bool hasAlpha = false;
290  if ( colorFromMimeData( e->mimeData(), mimeColor, hasAlpha ) )
291  {
292  //accept drop and set new color
293  e->acceptProposedAction();
294  mimeColor.setAlphaF( 1.0 );
295  mSymbol->setColor( mimeColor );
297  updatePreview();
298  emit changed();
299  }
300  updatePreview();
301 }
302 
303 void QgsSymbolButton::prepareMenu()
304 {
305  //we need to tear down and rebuild this menu every time it is shown. Otherwise the space allocated to any
306  //QgsColorSwatchGridAction is not recalculated by Qt and the swatch grid may not be the correct size
307  //for the number of colors shown in the grid. Note that we MUST refresh color swatch grids every time this
308  //menu is opened, otherwise color schemes like the recent color scheme grid are meaningless
309  mMenu->clear();
310 
311  QAction *configureAction = new QAction( tr( "Configure Symbol…" ), this );
312  mMenu->addAction( configureAction );
313  connect( configureAction, &QAction::triggered, this, &QgsSymbolButton::showSettingsDialog );
314 
315  QAction *copySymbolAction = new QAction( tr( "Copy Symbol" ), this );
316  mMenu->addAction( copySymbolAction );
317  connect( copySymbolAction, &QAction::triggered, this, &QgsSymbolButton::copySymbol );
318  QAction *pasteSymbolAction = new QAction( tr( "Paste Symbol" ), this );
319  //enable or disable paste action based on current clipboard contents. We always show the paste
320  //action, even if it's disabled, to give hint to the user that pasting symbols is possible
321  std::unique_ptr< QgsSymbol > tempSymbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) );
322  if ( tempSymbol && tempSymbol->type() == mType )
323  {
324  const int iconSize = QgsGuiUtils::scaleIconSize( 16 );
325  pasteSymbolAction->setIcon( QgsSymbolLayerUtils::symbolPreviewIcon( tempSymbol.get(), QSize( iconSize, iconSize ), 1 ) );
326  }
327  else
328  {
329  pasteSymbolAction->setEnabled( false );
330  }
331  mMenu->addAction( pasteSymbolAction );
332  connect( pasteSymbolAction, &QAction::triggered, this, &QgsSymbolButton::pasteSymbol );
333 
334  mMenu->addSeparator();
335 
336  QgsColorWheel *colorWheel = new QgsColorWheel( mMenu );
337  colorWheel->setColor( mSymbol->color() );
338  QgsColorWidgetAction *colorAction = new QgsColorWidgetAction( colorWheel, mMenu, mMenu );
339  colorAction->setDismissOnColorSelection( false );
340  connect( colorAction, &QgsColorWidgetAction::colorChanged, this, &QgsSymbolButton::setColor );
341  mMenu->addAction( colorAction );
342 
344  QColor alphaColor = mSymbol->color();
345  alphaColor.setAlphaF( mSymbol->opacity() );
346  alphaRamp->setColor( alphaColor );
347  QgsColorWidgetAction *alphaAction = new QgsColorWidgetAction( alphaRamp, mMenu, mMenu );
348  alphaAction->setDismissOnColorSelection( false );
349  connect( alphaAction, &QgsColorWidgetAction::colorChanged, this, [ = ]( const QColor & color )
350  {
351  double opacity = color.alphaF();
352  mSymbol->setOpacity( opacity );
353  updatePreview();
354  emit changed();
355  } );
356  connect( colorAction, &QgsColorWidgetAction::colorChanged, alphaRamp, [alphaRamp]( const QColor & color ) { alphaRamp->setColor( color, false ); }
357  );
358  mMenu->addAction( alphaAction );
359 
360  //get schemes with ShowInColorButtonMenu flag set
361  QList< QgsColorScheme * > schemeList = QgsApplication::colorSchemeRegistry()->schemes( QgsColorScheme::ShowInColorButtonMenu );
362  QList< QgsColorScheme * >::iterator it = schemeList.begin();
363  for ( ; it != schemeList.end(); ++it )
364  {
365  QgsColorSwatchGridAction *colorAction = new QgsColorSwatchGridAction( *it, mMenu, QStringLiteral( "symbology" ), this );
366  colorAction->setBaseColor( mSymbol->color() );
367  mMenu->addAction( colorAction );
368  connect( colorAction, &QgsColorSwatchGridAction::colorChanged, this, &QgsSymbolButton::setColor );
369  connect( colorAction, &QgsColorSwatchGridAction::colorChanged, this, &QgsSymbolButton::addRecentColor );
370  }
371 
372  mMenu->addSeparator();
373 
374  QAction *copyColorAction = new QAction( tr( "Copy Color" ), this );
375  mMenu->addAction( copyColorAction );
376  connect( copyColorAction, &QAction::triggered, this, &QgsSymbolButton::copyColor );
377 
378  QAction *pasteColorAction = new QAction( tr( "Paste Color" ), this );
379  //enable or disable paste action based on current clipboard contents. We always show the paste
380  //action, even if it's disabled, to give hint to the user that pasting colors is possible
381  QColor clipColor;
382  bool hasAlpha = false;
383  if ( colorFromMimeData( QApplication::clipboard()->mimeData(), clipColor, hasAlpha ) )
384  {
385  pasteColorAction->setIcon( createColorIcon( clipColor ) );
386  }
387  else
388  {
389  pasteColorAction->setEnabled( false );
390  }
391  mMenu->addAction( pasteColorAction );
392  connect( pasteColorAction, &QAction::triggered, this, &QgsSymbolButton::pasteColor );
393 }
394 
395 void QgsSymbolButton::addRecentColor( const QColor &color )
396 {
398 }
399 
400 
402 {
403  if ( e->type() == QEvent::EnabledChange )
404  {
405  updatePreview();
406  }
407  QToolButton::changeEvent( e );
408 }
409 
410 void QgsSymbolButton::showEvent( QShowEvent *e )
411 {
412  updatePreview();
413  QToolButton::showEvent( e );
414 }
415 
416 void QgsSymbolButton::resizeEvent( QResizeEvent *event )
417 {
418  QToolButton::resizeEvent( event );
419  //recalculate icon size and redraw icon
420  mIconSize = QSize();
421  updatePreview();
422 }
423 
424 void QgsSymbolButton::updatePreview( const QColor &color, QgsSymbol *tempSymbol )
425 {
426  std::unique_ptr< QgsSymbol > previewSymbol;
427 
428  if ( tempSymbol )
429  previewSymbol.reset( tempSymbol->clone() );
430  else
431  previewSymbol.reset( mSymbol->clone() );
432 
433  if ( color.isValid() )
434  previewSymbol->setColor( color );
435 
436  QSize currentIconSize;
437  //icon size is button size with a small margin
438  if ( menu() )
439  {
440  if ( !mIconSize.isValid() )
441  {
442  //calculate size of push button part of widget (ie, without the menu dropdown button part)
443  QStyleOptionToolButton opt;
444  initStyleOption( &opt );
445  QRect buttonSize = QApplication::style()->subControlRect( QStyle::CC_ToolButton, &opt, QStyle::SC_ToolButton,
446  this );
447  //make sure height of icon looks good under different platforms
448 #ifdef Q_OS_WIN
449  mIconSize = QSize( buttonSize.width() - 10, height() - 6 );
450 #else
451  mIconSize = QSize( buttonSize.width() - 10, height() - 12 );
452 #endif
453  }
454  currentIconSize = mIconSize;
455  }
456  else
457  {
458  //no menu
459 #ifdef Q_OS_WIN
460  currentIconSize = QSize( width() - 10, height() - 6 );
461 #else
462  currentIconSize = QSize( width() - 10, height() - 12 );
463 #endif
464  }
465 
466  if ( !currentIconSize.isValid() || currentIconSize.width() <= 0 || currentIconSize.height() <= 0 )
467  {
468  return;
469  }
470 
471  //create an icon pixmap
472  QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( previewSymbol.get(), currentIconSize );
473  setIconSize( currentIconSize );
474  setIcon( icon );
475 
476  // set tooltip
477  // create very large preview image
478  int width = static_cast< int >( Qgis::UI_SCALE_FACTOR * fontMetrics().width( 'X' ) * 23 );
479  int height = static_cast< int >( width / 1.61803398875 ); // golden ratio
480 
481  QPixmap pm = QgsSymbolLayerUtils::symbolPreviewPixmap( previewSymbol.get(), QSize( width, height ), height / 20 );
482  QByteArray data;
483  QBuffer buffer( &data );
484  pm.save( &buffer, "PNG", 100 );
485  setToolTip( QStringLiteral( "<img src='data:image/png;base64, %3'>" ).arg( QString( data.toBase64() ) ) );
486 }
487 
488 bool QgsSymbolButton::colorFromMimeData( const QMimeData *mimeData, QColor &resultColor, bool &hasAlpha )
489 {
490  hasAlpha = false;
491  QColor mimeColor = QgsSymbolLayerUtils::colorFromMimeData( mimeData, hasAlpha );
492 
493  if ( mimeColor.isValid() )
494  {
495  resultColor = mimeColor;
496  return true;
497  }
498 
499  //could not get color from mime data
500  return false;
501 }
502 
503 QPixmap QgsSymbolButton::createColorIcon( const QColor &color ) const
504 {
505  //create an icon pixmap
506  const int iconSize = QgsGuiUtils::scaleIconSize( 16 );
507  QPixmap pixmap( iconSize, iconSize );
508  pixmap.fill( Qt::transparent );
509 
510  QPainter p;
511  p.begin( &pixmap );
512 
513  //draw color over pattern
514  p.setBrush( QBrush( color ) );
515 
516  //draw border
517  p.setPen( QColor( 197, 197, 197 ) );
518  p.drawRect( 0, 0, iconSize - 1, iconSize - 1 );
519  p.end();
520  return pixmap;
521 }
522 
523 void QgsSymbolButton::setDialogTitle( const QString &title )
524 {
525  mDialogTitle = title;
526 }
527 
528 QString QgsSymbolButton::dialogTitle() const
529 {
530  return mDialogTitle;
531 }
532 
534 {
535  return mSymbol.get();
536 }
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
A color swatch grid which can be embedded into a menu.
static QgsSymbol * symbolFromMimeData(const QMimeData *data)
Attempts to parse mime data as a symbol.
static QPixmap symbolPreviewPixmap(QgsSymbol *symbol, QSize size, int padding=0, QgsRenderContext *customContext=nullptr)
Returns a pixmap preview for a color ramp.
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
QSize minimumSizeHint() const override
bool dockMode()
Returns the dock mode state.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
void copyColor()
Copies the current symbol color to the clipboard.
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition: qgis.h:152
QgsSymbol * symbol()
Returns the symbol that is currently active in the widget.
void mousePressEvent(QMouseEvent *e) override
virtual void setColor(const QColor &color, bool emitSignals=false)
Sets the color for the widget.
static QgsLineSymbol * createSimple(const QgsStringMap &properties)
Create a line symbol with one symbol layer: SimpleLine with specified properties. ...
Definition: qgssymbol.cpp:1139
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly...
QString dialogTitle() const
Returns the title for the symbol settings dialog window.
void setDialogTitle(const QString &title)
Sets the title for the symbol settings dialog window.
static QgsFillSymbol * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
Definition: qgssymbol.cpp:1150
void showEvent(QShowEvent *e) override
QgsVectorLayer * layer() const
Returns the layer associated with the widget.
void changed()
Emitted when the symbol&#39;s settings are changed.
void colorChanged(const QColor &color)
Emitted when a color has been selected from the widget.
Base class for any widget that can be shown as a inline panel.
Line symbol.
Definition: qgssymbol.h:86
Show scheme in color button drop-down menu.
void panelAccepted(QgsPanelWidget *panel)
Emitted when the panel is accepted by the user.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:577
void pasteSymbol()
Pastes a symbol from the clipboard.
void pasteColor()
Pastes a color from the clipboard to the symbol.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:74
static QgsStyle * defaultStyle()
Returns default application-wide style.
Definition: qgsstyle.cpp:46
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
SymbolType
Type of the symbol.
Definition: qgssymbol.h:83
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void resizeEvent(QResizeEvent *event) override
static QIcon symbolPreviewIcon(QgsSymbol *symbol, QSize size, int padding=0)
Returns an icon preview for a color ramp.
A color wheel widget.
QgsSymbolButton(QWidget *parent=nullptr, const QString &dialogTitle=QString())
Construct a new symbol button.
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget...
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
Alpha component (opacity) of color.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
A color ramp widget.
void mouseMoveEvent(QMouseEvent *e) override
void setColor(const QColor &color, bool emitSignals=false) override
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer&#39;s project and layer.
Symbol selector widget that can be used to select and build a symbol.
void setColor(const QColor &color)
Sets the current color for the symbol.
static void addRecentColor(const QColor &color)
Adds a color to the list of recent colors.
void widgetChanged()
Emitted when the widget state changes.
void changeEvent(QEvent *e) override
void setExpressionContext(QgsExpressionContext *context)
Sets the optional expression context used for the widget.
Abstract interface for generating an expression context.
Marker symbol.
Definition: qgssymbol.h:85
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application&#39;s color scheme registry, used for managing color schemes. ...
Fill symbol.
Definition: qgssymbol.h:87
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
void setLayer(QgsVectorLayer *layer)
Sets a layer to associate with the widget.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
An action containing a color widget, which can be embedded into a menu.
void dropEvent(QDropEvent *e) override
static QMimeData * colorToMimeData(const QColor &color)
Creates mime data from a color.
void dragLeaveEvent(QDragLeaveEvent *e) override
QSize sizeHint() const override
void setMapCanvas(QgsMapCanvas *canvas)
Sets a map canvas to associate with the widget.
static QMimeData * symbolToMimeData(QgsSymbol *symbol)
Creates new mime data from a symbol.
void setSymbol(QgsSymbol *symbol)
Sets the symbol for the button.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
static QgsMarkerSymbol * createSimple(const QgsStringMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
Definition: qgssymbol.cpp:1128
void copySymbol()
Copies the current symbol to the clipboard.
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
void setDismissOnColorSelection(bool dismiss)
Sets whether the parent menu should be dismissed and closed when a color is selected from the action&#39;...
Represents a vector layer which manages a vector based data sets.
void setSymbolType(QgsSymbol::SymbolType type)
Sets the symbol type which the button requires.
static QPixmap createDragIcon(const QColor &color)
Create an icon for dragging colors.
QList< QgsColorScheme * > schemes() const
Returns all color schemes in the registry.
void dragEnterEvent(QDragEnterEvent *e) override
QgsSymbol * symbol()
Returns the current symbol defined by the button.
Hybrid symbol.
Definition: qgssymbol.h:88
static QColor colorFromMimeData(const QMimeData *data, bool &hasAlpha)
Attempts to parse mime data as a color.
void colorChanged(const QColor &color)
Emitted when a color has been selected from the widget.
void setBaseColor(const QColor &baseColor)
Sets the base color for the color grid.