17#include "moc_qgssymbolselectordialog.cpp" 
   40#include <QColorDialog> 
   42#include <QStandardItemModel> 
   43#include <QInputDialog> 
   50#include <QStandardItem> 
   54static const int SYMBOL_LAYER_ITEM_TYPE = QStandardItem::UserType + 1;
 
   64    mDDSize = mMarker->dataDefinedSize();
 
   65    mDDAngle = mMarker->dataDefinedAngle();
 
   67    if ( !mDDSize && !mDDAngle )
 
   74    mDDWidth = mLine->dataDefinedWidth();
 
   82void DataDefinedRestorer::save()
 
   86    mSize = mMarkerSymbolLayer->size();
 
   87    mAngle = mMarkerSymbolLayer->angle();
 
   88    mMarkerOffset = mMarkerSymbolLayer->offset();
 
   92    mWidth = mLineSymbolLayer->width();
 
   93    mLineOffset = mLineSymbolLayer->offset();
 
   97void DataDefinedRestorer::restore()
 
  101    if ( mDDSize && ( mSize != mMarkerSymbolLayer->size() || mMarkerOffset != mMarkerSymbolLayer->offset() ) )
 
  102      mMarker->setDataDefinedSize( mDDSize );
 
  103    if ( mDDAngle && mAngle != mMarkerSymbolLayer->angle() )
 
  104      mMarker->setDataDefinedAngle( mDDAngle );
 
  108    if ( mDDWidth && ( mWidth != mLineSymbolLayer->width() || mLineOffset != mLineSymbolLayer->offset() ) )
 
  109      mLine->setDataDefinedWidth( mDDWidth );
 
  116class SymbolLayerItem : 
public QStandardItem
 
  120      : mVectorLayer( vectorLayer )
 
  123      setLayer( layer, symbolType );
 
  127      : mVectorLayer( vectorLayer )
 
  138      mSymbolType = symbolType;
 
  152      if ( !mSize.isValid() )
 
  155        mSize = QSize( size, size );
 
  168      if ( 
auto *lParent = parent() )
 
  169        static_cast<SymbolLayerItem *
>( lParent )->updatePreview();
 
  172    int type()
 const override { 
return SYMBOL_LAYER_ITEM_TYPE; }
 
  173    bool isLayer() { 
return mIsLayer; }
 
  186    QVariant data( 
int role )
 const override 
  188      if ( role == Qt::DisplayRole || role == Qt::EditRole )
 
  200          switch ( mSymbol->type() )
 
  203              return QCoreApplication::translate( 
"SymbolLayerItem", 
"Marker" );
 
  205              return QCoreApplication::translate( 
"SymbolLayerItem", 
"Fill" );
 
  207              return QCoreApplication::translate( 
"SymbolLayerItem", 
"Line" );
 
  213      else if ( role == Qt::ForegroundRole && mIsLayer )
 
  215        if ( !mLayer->enabled() )
 
  217          QPalette 
pal = qApp->palette();
 
  218          QBrush brush = QStandardItem::data( role ).value<QBrush>();
 
  219          brush.setColor( 
pal.color( QPalette::Disabled, QPalette::WindowText ) );
 
  230      if ( role == Qt::CheckStateRole )
 
  232      return QStandardItem::data( role );
 
  238    QPointer<QgsVectorLayer> mVectorLayer;
 
  239    bool mIsLayer = 
false;
 
  242    QPointer<QScreen> mScreen;
 
  256  setWindowModality( Qt::WindowModal );
 
  260  this->layout()->setContentsMargins( 0, 0, 0, 0 );
 
  262  layersTree->setMaximumHeight( 
static_cast<int>( 
Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 7 ) );
 
  263  layersTree->setMinimumHeight( layersTree->maximumHeight() );
 
  264  lblPreview->setMaximumWidth( layersTree->maximumHeight() );
 
  272  iconLock.addFile( 
QgsApplication::iconPath( QStringLiteral( 
"unlocked.svg" ) ), QSize(), QIcon::Normal, QIcon::Off );
 
  273  iconLock.addFile( 
QgsApplication::iconPath( QStringLiteral( 
"unlocked.svg" ) ), QSize(), QIcon::Active, QIcon::Off );
 
  276  iconColorLock.addFile( 
QgsApplication::iconPath( QStringLiteral( 
"mIconColorLocked.svg" ) ), QSize(), QIcon::Normal, QIcon::On );
 
  277  iconColorLock.addFile( 
QgsApplication::iconPath( QStringLiteral( 
"mIconColorLocked.svg" ) ), QSize(), QIcon::Active, QIcon::On );
 
  278  iconColorLock.addFile( 
QgsApplication::iconPath( QStringLiteral( 
"mIconColorUnlocked.svg" ) ), QSize(), QIcon::Normal, QIcon::Off );
 
  279  iconColorLock.addFile( 
QgsApplication::iconPath( QStringLiteral( 
"mIconColorUnlocked.svg" ) ), QSize(), QIcon::Active, QIcon::Off );
 
  281  mLockColorAction = 
new QAction( tr( 
"Lock Color" ), 
this );
 
  282  mLockColorAction->setToolTip( tr( 
"Avoid changing the color of the layer when the symbol color is changed" ) );
 
  283  mLockColorAction->setCheckable( 
true );
 
  284  mLockColorAction->setIcon( iconColorLock );
 
  286  QIcon iconSelectLock;
 
  287  iconSelectLock.addFile( 
QgsApplication::iconPath( QStringLiteral( 
"mIconSelectLocked.svg" ) ), QSize(), QIcon::Normal, QIcon::On );
 
  288  iconSelectLock.addFile( 
QgsApplication::iconPath( QStringLiteral( 
"mIconSelectLocked.svg" ) ), QSize(), QIcon::Active, QIcon::On );
 
  289  iconSelectLock.addFile( 
QgsApplication::iconPath( QStringLiteral( 
"mIconSelectUnlocked.svg" ) ), QSize(), QIcon::Normal, QIcon::Off );
 
  290  iconSelectLock.addFile( 
QgsApplication::iconPath( QStringLiteral( 
"mIconSelectUnlocked.svg" ) ), QSize(), QIcon::Active, QIcon::Off );
 
  292  mLockSelectionColorAction = 
new QAction( tr( 
"Lock Color When Selected" ), 
this );
 
  293  mLockSelectionColorAction->setToolTip( tr( 
"Avoid changing the color of the layer when a feature is selected" ) );
 
  294  mLockSelectionColorAction->setCheckable( 
true );
 
  295  mLockSelectionColorAction->setIcon( iconSelectLock );
 
  297  QMenu *lockMenu = 
new QMenu( 
this );
 
  298  lockMenu->addAction( mLockColorAction );
 
  299  lockMenu->addAction( mLockSelectionColorAction );
 
  300  btnLock->setMenu( lockMenu );
 
  301  btnLock->setPopupMode( QToolButton::InstantPopup );
 
  307  mSymbolLayersModel = 
new QStandardItemModel( layersTree );
 
  309  layersTree->setModel( mSymbolLayersModel );
 
  310  layersTree->setHeaderHidden( 
true );
 
  322    mPreviewExpressionContext.
setFeature( mPreviewFeature );
 
  330  QItemSelectionModel *selModel = layersTree->selectionModel();
 
  333  loadSymbol( mSymbol, 
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->invisibleRootItem() ) );
 
  341  connect( mLockSelectionColorAction, &QAction::toggled, 
this, [
this]( 
bool checked ) {
 
  349    updateLockButtonIcon();
 
  355  updateLockButtonIcon();
 
  360  const QModelIndex newIndex = layersTree->model()->index( 0, 0 );
 
  361  layersTree->setCurrentIndex( newIndex );
 
 
  390  widget->mOwnedSymbol = std::move( 
symbol );
 
 
  396  if ( !mAdvancedMenu )
 
  398    mAdvancedMenu = 
new QMenu( 
this );
 
  402  return mAdvancedMenu;
 
 
  411    mPreviewExpressionContext = *lExpressionContext;
 
  415    mPreviewExpressionContext.
setFeature( mPreviewFeature );
 
  418  QWidget *widget = stackedWidget->currentWidget();
 
  421    layerProp->setContext( 
context );
 
  425    listWidget->setContext( 
context );
 
 
  445    mSymbolLayersModel->clear();
 
  446    parent = 
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->invisibleRootItem() );
 
  449  SymbolLayerItem *symbolItem = 
new SymbolLayerItem( 
symbol, mVectorLayer, screen() );
 
  450  QFont boldFont = symbolItem->font();
 
  451  boldFont.setBold( 
true );
 
  452  symbolItem->setFont( boldFont );
 
  453  parent->appendRow( symbolItem );
 
  456  for ( 
int i = count - 1; i >= 0; i-- )
 
  459    layerItem->setEditable( 
false );
 
  460    symbolItem->appendRow( layerItem );
 
  465    layersTree->setExpanded( layerItem->index(), 
true );
 
  467  layersTree->setExpanded( symbolItem->index(), 
true );
 
  469  if ( mSymbol == 
symbol && !layersTree->currentIndex().isValid() )
 
  472    layersTree->setCurrentIndex( symbolItem->index() );
 
 
  476void QgsSymbolSelectorWidget::reloadSymbol()
 
  478  mSymbolLayersModel->clear();
 
  479  loadSymbol( mSymbol, 
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->invisibleRootItem() ) );
 
  482void QgsSymbolSelectorWidget::updateUi()
 
  484  const QModelIndex currentIdx = layersTree->currentIndex();
 
  485  if ( !currentIdx.isValid() )
 
  488  SymbolLayerItem *item = 
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->itemFromIndex( currentIdx ) );
 
  489  if ( !item->isLayer() )
 
  491    btnUp->setEnabled( 
false );
 
  492    btnDown->setEnabled( 
false );
 
  493    btnRemoveLayer->setEnabled( 
false );
 
  494    btnLock->setEnabled( 
false );
 
  495    btnDuplicate->setEnabled( 
false );
 
  499  const int rowCount = item->parent()->rowCount();
 
  500  const int currentRow = item->row();
 
  502  btnUp->setEnabled( currentRow > 0 );
 
  503  btnDown->setEnabled( currentRow < rowCount - 1 );
 
  504  btnRemoveLayer->setEnabled( rowCount > 1 );
 
  505  btnLock->setEnabled( 
true );
 
  506  btnDuplicate->setEnabled( 
true );
 
  514  std::unique_ptr<QgsSymbol> symbolClone( mSymbol->
clone() );
 
  516  lblPreview->setPixmap( QPixmap::fromImage( preview ) );
 
  518  if ( !mBlockModified )
 
 
  525  SymbolLayerItem *item = currentLayerItem();
 
  527    item->updatePreview();
 
 
  532SymbolLayerItem *QgsSymbolSelectorWidget::currentLayerItem()
 
  534  const QModelIndex idx = layersTree->currentIndex();
 
  535  if ( !idx.isValid() )
 
  538  SymbolLayerItem *item = 
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->itemFromIndex( idx ) );
 
  539  if ( !item->isLayer() )
 
  547  const QModelIndex idx = layersTree->currentIndex();
 
  548  if ( !idx.isValid() )
 
  551  SymbolLayerItem *item = 
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->itemFromIndex( idx ) );
 
  552  if ( item->isLayer() )
 
  553    return item->layer();
 
  562  SymbolLayerItem *currentItem = 
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->itemFromIndex( layersTree->currentIndex() ) );
 
  566  if ( currentItem->isLayer() )
 
  568    SymbolLayerItem *parent = 
static_cast<SymbolLayerItem *
>( currentItem->parent() );
 
  569    mDataDefineRestorer.reset( 
new DataDefinedRestorer( parent->symbol(), currentItem->layer() ) );
 
  573    setWidget( layerProp );
 
  584    mDataDefineRestorer.reset();
 
  586    currentItem->symbol()->setLayer( mVectorLayer );
 
  590    symbolsList->setContext( mContext );
 
  592    setWidget( symbolsList );
 
 
  600  SymbolLayerItem *currentItem = 
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->itemFromIndex( layersTree->currentIndex() ) );
 
  601  if ( !currentItem || currentItem->isLayer() )
 
  605  if ( currentItem->parent() )
 
  609    SymbolLayerItem *parent = 
static_cast<SymbolLayerItem *
>( currentItem->parent() );
 
  610    parent->removeRow( 0 );
 
  612    layersTree->setCurrentIndex( parent->child( 0 )->index() );
 
  613    parent->updatePreview();
 
  619    const QModelIndex newIndex = layersTree->model()->index( 0, 0 );
 
  620    layersTree->setCurrentIndex( newIndex );
 
 
  627void QgsSymbolSelectorWidget::setWidget( QWidget *widget )
 
  629  const int index = stackedWidget->addWidget( widget );
 
  630  stackedWidget->setCurrentIndex( index );
 
  631  if ( mPresentWidget )
 
  632    mPresentWidget->deleteLater();
 
  633  mPresentWidget = widget;
 
  636void QgsSymbolSelectorWidget::updateLockButton()
 
  641  mLockColorAction->setChecked( layer->
isLocked() );
 
  644  updateLockButtonIcon();
 
  647void QgsSymbolSelectorWidget::updateLockButtonIcon()
 
  649  if ( mLockColorAction->isChecked() && mLockSelectionColorAction->isChecked() )
 
  651  else if ( mLockColorAction->isChecked() )
 
  653  else if ( mLockSelectionColorAction->isChecked() )
 
  661  const QModelIndex idx = layersTree->currentIndex();
 
  662  if ( !idx.isValid() )
 
  666  SymbolLayerItem *item = 
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->itemFromIndex( idx ) );
 
  667  if ( item->isLayer() )
 
  669    insertIdx = item->row();
 
  670    item = 
static_cast<SymbolLayerItem *
>( item->parent() );
 
  673  QgsSymbol *parentSymbol = item->symbol();
 
  683    newLayerPtr = newLayer.get();
 
  684    if ( insertIdx == -1 )
 
  687      parentSymbol->
insertSymbolLayer( item->rowCount() - insertIdx, newLayer.release() );
 
  692    static_cast<QgsMarkerSymbol *
>( parentSymbol )->setDataDefinedSize( ddSize );
 
  694    static_cast<QgsMarkerSymbol *
>( parentSymbol )->setDataDefinedAngle( ddAngle );
 
  696    static_cast<QgsLineSymbol *
>( parentSymbol )->setDataDefinedWidth( ddWidth );
 
  700  SymbolLayerItem *newLayerItem = 
new SymbolLayerItem( newLayerPtr, parentSymbol->
type(), mVectorLayer, screen() ); 
 
  701  item->insertRow( insertIdx == -1 ? 0 : insertIdx, newLayerItem );
 
  702  item->updatePreview();
 
  704  layersTree->setCurrentIndex( mSymbolLayersModel->indexFromItem( newLayerItem ) );
 
 
  711  SymbolLayerItem *item = currentLayerItem();
 
  712  const int row = item->row();
 
  713  SymbolLayerItem *parent = 
static_cast<SymbolLayerItem *
>( item->parent() );
 
  715  const int layerIdx = parent->rowCount() - row - 1; 
 
  716  QgsSymbol *parentSymbol = parent->symbol();
 
  719  parent->removeRow( row );
 
  720  parent->updatePreview();
 
  722  const QModelIndex newIdx = parent->child( 0 )->index();
 
  723  layersTree->setCurrentIndex( newIdx );
 
 
  733  moveLayerByOffset( +1 );
 
 
  738  moveLayerByOffset( -1 );
 
 
  741void QgsSymbolSelectorWidget::moveLayerByOffset( 
int offset )
 
  743  SymbolLayerItem *item = currentLayerItem();
 
  746  const int row = item->row();
 
  748  SymbolLayerItem *parent = 
static_cast<SymbolLayerItem *
>( item->parent() );
 
  749  QgsSymbol *parentSymbol = parent->symbol();
 
  751  const int layerIdx = parent->rowCount() - row - 1;
 
  756  QList<QStandardItem *> rowItems = parent->takeRow( row );
 
  757  parent->insertRows( row + offset, rowItems );
 
  758  parent->updatePreview();
 
  760  const QModelIndex newIdx = rowItems[0]->index();
 
  761  layersTree->setCurrentIndex( newIdx );
 
  772  layer->
setLocked( mLockColorAction->isChecked() );
 
  773  updateLockButtonIcon();
 
 
  779  const QModelIndex idx = layersTree->currentIndex();
 
  780  if ( !idx.isValid() )
 
  783  SymbolLayerItem *item = 
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->itemFromIndex( idx ) );
 
  784  if ( !item->isLayer() )
 
  789  const int insertIdx = item->row();
 
  790  item = 
static_cast<SymbolLayerItem *
>( item->parent() );
 
  792  QgsSymbol *parentSymbol = item->symbol();
 
  796  if ( insertIdx == -1 )
 
  801  SymbolLayerItem *newLayerItem = 
new SymbolLayerItem( newLayer, parentSymbol->
type(), mVectorLayer, screen() );
 
  802  item->insertRow( insertIdx == -1 ? 0 : insertIdx, newLayerItem );
 
  806    layersTree->setExpanded( newLayerItem->index(), 
true );
 
  808  item->updatePreview();
 
  810  layersTree->setCurrentIndex( mSymbolLayersModel->indexFromItem( newLayerItem ) );
 
 
  817  SymbolLayerItem *item = currentLayerItem();
 
  819  if ( item->rowCount() > 0 )
 
  821    item->removeRow( 0 );
 
  831    layersTree->setExpanded( item->index(), 
true );
 
  835  const int layerIdx = item->parent()->rowCount() - item->row() - 1;
 
  838  item->updatePreview();
 
 
  847  setLayout( 
new QVBoxLayout() );
 
  850  mButtonBox = 
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok );
 
  852  connect( mButtonBox, &QDialogButtonBox::accepted, 
this, &QDialog::accept );
 
  853  connect( mButtonBox, &QDialogButtonBox::rejected, 
this, &QDialog::reject );
 
  854  connect( mButtonBox, &QDialogButtonBox::helpRequested, 
this, &QgsSymbolSelectorDialog::showHelp );
 
  856  layout()->addWidget( mSelectorWidget );
 
  857  layout()->addWidget( mButtonBox );
 
  861  mSelectorWidget->setMinimumSize( 460, 560 );
 
  862  setObjectName( QStringLiteral( 
"SymbolSelectorDialog" ) );
 
  869    layout()->setContentsMargins( 0, 0, 0, 0 );
 
  873    setWindowTitle( tr( 
"Symbol Selector" ) );
 
 
  890  return mSelectorWidget->
context();
 
 
  895  return mSelectorWidget->
symbol();
 
 
  901  if ( !isWindow() && e->key() == Qt::Key_Escape )
 
  907    QDialog::keyPressEvent( e );
 
 
  911void QgsSymbolSelectorDialog::reloadSymbol()
 
  913  mSelectorWidget->reloadSymbol();
 
  921void QgsSymbolSelectorDialog::updateUi()
 
  923  mSelectorWidget->updateUi();
 
  926void QgsSymbolSelectorDialog::updateLockButton()
 
  928  mSelectorWidget->updateLockButton();
 
  931SymbolLayerItem *QgsSymbolSelectorDialog::currentLayerItem()
 
  933  return mSelectorWidget->currentLayerItem();
 
  938  return mSelectorWidget->currentLayer();
 
  941void QgsSymbolSelectorDialog::moveLayerByOffset( 
int offset )
 
  943  mSelectorWidget->moveLayerByOffset( offset );
 
  946void QgsSymbolSelectorDialog::setWidget( QWidget *widget )
 
  948  mSelectorWidget->setWidget( widget );
 
 1011void QgsSymbolSelectorDialog::showHelp()
 
 1016void QgsSymbolSelectorWidget::projectDataChanged()
 
 1018  mBlockModified = 
true;
 
 1021  mBlockModified = 
false;
 
 1024void QgsSymbolSelectorWidget::layersAboutToBeRemoved( 
const QList<QgsMapLayer *> &layers )
 
 1026  if ( mVectorLayer && layers.contains( mVectorLayer ) )
 
QFlags< SymbolLayerUserFlag > SymbolLayerUserFlags
Symbol layer user flags.
 
@ Millimeters
Millimeters.
 
@ FlagIncludeCrosshairsForMarkerSymbols
Include a crosshairs reference image in the background of marker symbol previews.
 
@ DisableSelectionRecoloring
If present, indicates that the symbol layer should not be recolored when rendering selected features.
 
static const double UI_SCALE_FACTOR
UI scaling factor.
 
static QgsSymbolLayerRegistry * symbolLayerRegistry()
Returns the application's symbol layer registry, used for managing symbol layers.
 
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
 
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images.
 
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
 
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
 
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
 
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
 
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
 
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
 
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
 
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
 
Wrapper for iterator of features from vector data provider or vector layer.
 
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
 
Wraps a request for features to a vector layer (or directly its vector data provider).
 
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
 
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
 
void remoteImageFetched(const QString &url)
Emitted when the cache has finished retrieving an image file from a remote url.
 
Abstract base class for line symbol layers.
 
A line symbol type, for rendering LineString and MultiLineString geometries.
 
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
 
Struct for storing maximum and minimum scales for measurements in map units.
 
Abstract base class for marker symbol layers.
 
A marker symbol type, for rendering Point and MultiPoint geometries.
 
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
 
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
 
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
 
static QgsProject * instance()
Returns the QgsProject singleton instance.
 
void layersWillBeRemoved(const QStringList &layerIds)
Emitted when one or more layers are about to be removed from the registry.
 
void projectColorsChanged()
Emitted whenever the project's color scheme has been changed.
 
A store for object properties.
 
Stores properties relating to a screen.
 
A database of saved style entities, including symbols, color ramps, text formats and others.
 
void remoteSvgFetched(const QString &url)
Emitted when the cache has finished retrieving an SVG file from a remote url.
 
static std::unique_ptr< QgsSymbolLayer > defaultSymbolLayer(Qgis::SymbolType type)
create a new instance of symbol layer for specified symbol type with default settings
 
QgsSymbolLayerAbstractMetadata * symbolLayerMetadata(const QString &name) const
Returns metadata for specified symbol layer. Returns nullptr if not found.
 
static QIcon symbolLayerPreviewIcon(const QgsSymbolLayer *layer, Qgis::RenderUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::SymbolType parentSymbolType=Qgis::SymbolType::Hybrid, QgsMapLayer *mapLayer=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
Draws a symbol layer preview to an icon.
 
static QPixmap symbolPreviewPixmap(const QgsSymbol *symbol, QSize size, int padding=0, QgsRenderContext *customContext=nullptr, bool selected=false, const QgsExpressionContext *expressionContext=nullptr, const QgsLegendPatchShape *shape=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
Returns a pixmap preview for a color ramp.
 
static void resetSymbolLayerIds(QgsSymbol *symbol)
Regenerate recursively unique id from all symbol symbol layers.
 
Abstract base class for symbol layers.
 
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
 
Qgis::SymbolType type() const
 
bool isLocked() const
Returns true if the symbol layer colors are locked and the layer will ignore any symbol-level color c...
 
void setUserFlags(Qgis::SymbolLayerUserFlags flags)
Sets user-controlled flags which control the symbol layer's behavior.
 
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
 
Qgis::SymbolLayerUserFlags userFlags() const
Returns user-controlled flags which control the symbol layer's behavior.
 
void setLocked(bool locked)
Sets whether the layer's colors are locked.
 
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
 
QgsSymbolSelectorDialog(QgsSymbol *symbol, QgsStyle *style, QgsVectorLayer *vl, QWidget *parent=nullptr, bool embedded=false)
Constructor for QgsSymbolSelectorDialog.
 
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
 
QMenu * advancedMenu()
Returns menu for "advanced" button - create it if doesn't exist and show the advanced button.
 
void symbolChanged()
Slot to update tree when a new symbol from style.
 
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
 
QgsSymbol * symbol()
Returns the symbol that is currently active in the widget.
 
void keyPressEvent(QKeyEvent *e) override
 
void updateLayerPreview()
 
void duplicateLayer()
Duplicates the current symbol layer and places the duplicated layer above the current symbol layer.
 
void changeLayer(QgsSymbolLayer *layer)
Alters tree and sets proper widget when Layer Type is changed.
 
void loadSymbol(QgsSymbol *symbol, SymbolLayerItem *parent=nullptr)
Loads the given symbol into the widget.
 
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
 
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
 
Abstract base class for all rendered symbols.
 
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
 
bool appendSymbolLayer(QgsSymbolLayer *layer)
Appends a symbol layer at the end of the current symbol layer list.
 
bool insertSymbolLayer(int index, QgsSymbolLayer *layer)
Inserts a symbol layer to specified index.
 
bool changeSymbolLayer(int index, QgsSymbolLayer *layer)
Deletes the current layer at the specified index and replaces it with layer.
 
QgsSymbolLayer * takeSymbolLayer(int index)
Removes a symbol layer from the list and returns a pointer to it.
 
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
 
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
 
Qgis::SymbolType type() const
Returns the symbol's type.
 
Represents a vector layer which manages a vector based dataset.
 
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
 
#define Q_NOWARN_DEPRECATED_POP
 
#define Q_NOWARN_DEPRECATED_PUSH