28#include "moc_qgssymbolselectordialog.cpp"
30using namespace Qt::StringLiterals;
46#include <QColorDialog>
48#include <QStandardItemModel>
49#include <QInputDialog>
56#include <QStandardItem>
61static const int SYMBOL_LAYER_ITEM_TYPE = QStandardItem::UserType + 1;
71 mDDSize = mMarker->dataDefinedSize();
72 mDDAngle = mMarker->dataDefinedAngle();
74 if ( !mDDSize && !mDDAngle )
81 mDDWidth = mLine->dataDefinedWidth();
89void DataDefinedRestorer::save()
93 mSize = mMarkerSymbolLayer->size();
94 mAngle = mMarkerSymbolLayer->angle();
95 mMarkerOffset = mMarkerSymbolLayer->offset();
99 mWidth = mLineSymbolLayer->width();
100 mLineOffset = mLineSymbolLayer->offset();
104void DataDefinedRestorer::restore()
106 if ( mMarker && mMarker->symbolLayerCount() > 1 )
108 if ( mDDSize && ( mSize != mMarkerSymbolLayer->size() || mMarkerOffset != mMarkerSymbolLayer->offset() ) )
109 mMarker->setDataDefinedSize( mDDSize );
110 if ( mDDAngle && mAngle != mMarkerSymbolLayer->angle() )
111 mMarker->setDataDefinedAngle( mDDAngle );
113 else if ( mLine && mLine->symbolLayerCount() > 1 )
115 if ( mDDWidth && ( mWidth != mLineSymbolLayer->width() || mLineOffset != mLineSymbolLayer->offset() ) )
116 mLine->setDataDefinedWidth( mDDWidth );
123class SymbolLayerItem :
public QStandardItem
126 explicit SymbolLayerItem( QgsSymbolLayer *layer,
Qgis::SymbolType symbolType, QgsVectorLayer *vectorLayer, QScreen *screen )
127 : mVectorLayer( vectorLayer )
129 setLayer( layer, symbolType, screen );
132 explicit SymbolLayerItem( QgsSymbol *symbol, QgsVectorLayer *vectorLayer, QScreen *screen )
133 : mVectorLayer( vectorLayer )
135 setSymbol( symbol, screen );
138 void setLayer( QgsSymbolLayer *layer,
Qgis::SymbolType symbolType, QScreen *screen )
143 mSymbolType = symbolType;
144 updatePreview( screen );
147 void setSymbol( QgsSymbol *symbol, QScreen *screen )
152 updatePreview( screen );
155 void updatePreview( QScreen *screen )
157 if ( !mSize.isValid() )
160 mSize = QSize( size, size );
167 QgsExpressionContext expContext;
173 if (
auto *lParent = parent() )
174 static_cast<SymbolLayerItem *
>( lParent )->updatePreview( screen );
177 int type()
const override {
return SYMBOL_LAYER_ITEM_TYPE; }
178 bool isLayer()
const {
return mIsLayer; }
181 QgsSymbol *symbol() {
return mSymbol; }
183 QgsSymbolLayer *layer() {
return mLayer; }
185 QVariant data(
int role )
const override
187 if ( role == Qt::DisplayRole || role == Qt::EditRole )
199 switch ( mSymbol->type() )
202 return QCoreApplication::translate(
"SymbolLayerItem",
"Marker" );
204 return QCoreApplication::translate(
"SymbolLayerItem",
"Fill" );
206 return QCoreApplication::translate(
"SymbolLayerItem",
"Line" );
212 else if ( role == Qt::ForegroundRole && mIsLayer )
214 if ( !mLayer->enabled() )
216 QPalette pal = qApp->palette();
217 QBrush brush = QStandardItem::data( role ).value<QBrush>();
218 brush.setColor( pal.color( QPalette::Disabled, QPalette::WindowText ) );
229 if ( role == Qt::CheckStateRole )
231 return QStandardItem::data( role );
235 QgsSymbolLayer *mLayer =
nullptr;
236 QgsSymbol *mSymbol =
nullptr;
237 QPointer<QgsVectorLayer> mVectorLayer;
238 bool mIsLayer =
false;
254 setWindowModality( Qt::WindowModal );
258 this->layout()->setContentsMargins( 0, 0, 0, 0 );
260 layersTree->setMaximumHeight(
static_cast<int>(
Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 7 ) );
261 layersTree->setMinimumHeight( layersTree->maximumHeight() );
262 lblPreview->setMaximumWidth( layersTree->maximumHeight() );
276 iconColorLock.addFile(
QgsApplication::iconPath( u
"mIconColorUnlocked.svg"_s ), QSize(), QIcon::Normal, QIcon::Off );
277 iconColorLock.addFile(
QgsApplication::iconPath( u
"mIconColorUnlocked.svg"_s ), QSize(), QIcon::Active, QIcon::Off );
279 mLockColorAction =
new QAction( tr(
"Lock Color" ),
this );
280 mLockColorAction->setToolTip( tr(
"Avoid changing the color of the layer when the symbol color is changed" ) );
281 mLockColorAction->setCheckable(
true );
282 mLockColorAction->setIcon( iconColorLock );
284 QIcon iconSelectLock;
285 iconSelectLock.addFile(
QgsApplication::iconPath( u
"mIconSelectLocked.svg"_s ), QSize(), QIcon::Normal, QIcon::On );
286 iconSelectLock.addFile(
QgsApplication::iconPath( u
"mIconSelectLocked.svg"_s ), QSize(), QIcon::Active, QIcon::On );
287 iconSelectLock.addFile(
QgsApplication::iconPath( u
"mIconSelectUnlocked.svg"_s ), QSize(), QIcon::Normal, QIcon::Off );
288 iconSelectLock.addFile(
QgsApplication::iconPath( u
"mIconSelectUnlocked.svg"_s ), QSize(), QIcon::Active, QIcon::Off );
290 mLockSelectionColorAction =
new QAction( tr(
"Lock Color When Selected" ),
this );
291 mLockSelectionColorAction->setToolTip( tr(
"Avoid changing the color of the layer when a feature is selected" ) );
292 mLockSelectionColorAction->setCheckable(
true );
293 mLockSelectionColorAction->setIcon( iconSelectLock );
295 QMenu *lockMenu =
new QMenu(
this );
296 lockMenu->addAction( mLockColorAction );
297 lockMenu->addAction( mLockSelectionColorAction );
298 btnLock->setMenu( lockMenu );
299 btnLock->setPopupMode( QToolButton::InstantPopup );
305 mSymbolLayersModel =
new QStandardItemModel( layersTree );
307 layersTree->setModel( mSymbolLayersModel );
308 layersTree->setHeaderHidden(
true );
320 mPreviewExpressionContext.setFeature( mPreviewFeature );
328 QItemSelectionModel *selModel = layersTree->selectionModel();
331 loadSymbol( mSymbol,
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->invisibleRootItem() ) );
339 connect( mLockSelectionColorAction, &QAction::toggled,
this, [
this](
bool checked ) {
347 updateLockButtonIcon();
353 updateLockButtonIcon();
358 const QModelIndex newIndex = layersTree->model()->index( 0, 0 );
359 layersTree->setCurrentIndex( newIndex );
392 widget->mOwnedSymbol = std::move(
symbol );
398 if ( !mAdvancedMenu )
400 mAdvancedMenu =
new QMenu(
this );
404 return mAdvancedMenu;
411 if (
auto *lExpressionContext = mContext.expressionContext() )
413 mPreviewExpressionContext = *lExpressionContext;
417 mPreviewExpressionContext.setFeature( mPreviewFeature );
420 QWidget *widget = stackedWidget->currentWidget();
423 layerProp->setContext(
context );
427 listWidget->setContext(
context );
447 mSymbolLayersModel->clear();
448 parent =
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->invisibleRootItem() );
451 SymbolLayerItem *symbolItem =
new SymbolLayerItem(
symbol, mVectorLayer, screen() );
452 QFont boldFont = symbolItem->font();
453 boldFont.setBold(
true );
454 symbolItem->setFont( boldFont );
455 parent->appendRow( symbolItem );
457 const int count =
symbol->symbolLayerCount();
458 for (
int i = count - 1; i >= 0; i-- )
460 SymbolLayerItem *layerItem =
new SymbolLayerItem(
symbol->symbolLayer( i ),
symbol->type(), mVectorLayer, screen() );
461 layerItem->setEditable(
false );
462 symbolItem->appendRow( layerItem );
463 if (
symbol->symbolLayer( i )->subSymbol() )
467 layersTree->setExpanded( layerItem->index(),
true );
469 layersTree->setExpanded( symbolItem->index(),
true );
471 if ( mSymbol ==
symbol && !layersTree->currentIndex().isValid() )
474 layersTree->setCurrentIndex( symbolItem->index() );
478void QgsSymbolSelectorWidget::reloadSymbol()
480 mSymbolLayersModel->clear();
481 loadSymbol( mSymbol,
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->invisibleRootItem() ) );
484void QgsSymbolSelectorWidget::updateUi()
486 const QModelIndex currentIdx = layersTree->currentIndex();
487 if ( !currentIdx.isValid() )
490 SymbolLayerItem *item =
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->itemFromIndex( currentIdx ) );
491 if ( !item->isLayer() )
493 btnUp->setEnabled(
false );
494 btnDown->setEnabled(
false );
495 btnRemoveLayer->setEnabled(
false );
496 btnLock->setEnabled(
false );
497 btnDuplicate->setEnabled(
false );
501 const int rowCount = item->parent()->rowCount();
502 const int currentRow = item->row();
504 btnUp->setEnabled( currentRow > 0 );
505 btnDown->setEnabled( currentRow < rowCount - 1 );
506 btnRemoveLayer->setEnabled( rowCount > 1 );
507 btnLock->setEnabled(
true );
508 btnDuplicate->setEnabled(
true );
516 std::unique_ptr<QgsSymbol> symbolClone( mSymbol->clone() );
518 lblPreview->setPixmap( QPixmap::fromImage( preview ) );
524 SymbolLayerItem *item = currentLayerItem();
526 item->updatePreview( screen() );
531SymbolLayerItem *QgsSymbolSelectorWidget::currentLayerItem()
533 const QModelIndex idx = layersTree->currentIndex();
534 if ( !idx.isValid() )
537 SymbolLayerItem *item =
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->itemFromIndex( idx ) );
538 if ( !item->isLayer() )
546 const QModelIndex idx = layersTree->currentIndex();
547 if ( !idx.isValid() )
550 SymbolLayerItem *item =
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->itemFromIndex( idx ) );
551 if ( item->isLayer() )
552 return item->layer();
561 SymbolLayerItem *currentItem =
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->itemFromIndex( layersTree->currentIndex() ) );
565 if ( currentItem->isLayer() )
567 SymbolLayerItem *parent =
static_cast<SymbolLayerItem *
>( currentItem->parent() );
568 mDataDefineRestorer = std::make_unique<DataDefinedRestorer>( parent->symbol(), currentItem->layer() );
572 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( screen() );
619 const QModelIndex newIndex = layersTree->model()->index( 0, 0 );
620 layersTree->setCurrentIndex( newIndex );
623 emitSymbolModified();
628void QgsSymbolSelectorWidget::setWidget( QWidget *widget )
630 const int index = stackedWidget->addWidget( widget );
631 stackedWidget->setCurrentIndex( index );
632 if ( mPresentWidget )
633 mPresentWidget->deleteLater();
634 mPresentWidget = widget;
637void QgsSymbolSelectorWidget::updateLockButton()
639 QgsSymbolLayer *layer = currentLayer();
642 mLockColorAction->setChecked( layer->
isLocked() );
645 updateLockButtonIcon();
648void QgsSymbolSelectorWidget::updateLockButtonIcon()
650 if ( mLockColorAction->isChecked() && mLockSelectionColorAction->isChecked() )
652 else if ( mLockColorAction->isChecked() )
654 else if ( mLockSelectionColorAction->isChecked() )
662 const QModelIndex idx = layersTree->currentIndex();
663 if ( !idx.isValid() )
667 SymbolLayerItem *item =
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->itemFromIndex( idx ) );
668 if ( item->isLayer() )
670 insertIdx = item->row();
671 item =
static_cast<SymbolLayerItem *
>( item->parent() );
674 QgsSymbol *parentSymbol = item->symbol();
684 newLayerPtr = newLayer.get();
685 if ( insertIdx == -1 )
688 parentSymbol->
insertSymbolLayer( item->rowCount() - insertIdx, newLayer.release() );
693 static_cast<QgsMarkerSymbol *
>( parentSymbol )->setDataDefinedSize( ddSize );
695 static_cast<QgsMarkerSymbol *
>( parentSymbol )->setDataDefinedAngle( ddAngle );
697 static_cast<QgsLineSymbol *
>( parentSymbol )->setDataDefinedWidth( ddWidth );
701 SymbolLayerItem *newLayerItem =
new SymbolLayerItem( newLayerPtr, parentSymbol->
type(), mVectorLayer, screen() );
702 item->insertRow( insertIdx == -1 ? 0 : insertIdx, newLayerItem );
703 item->updatePreview( screen() );
705 layersTree->setCurrentIndex( mSymbolLayersModel->indexFromItem( newLayerItem ) );
708 emitSymbolModified();
713 SymbolLayerItem *item = currentLayerItem();
714 const int row = item->row();
715 SymbolLayerItem *parent =
static_cast<SymbolLayerItem *
>( item->parent() );
717 const int layerIdx = parent->rowCount() - row - 1;
718 QgsSymbol *parentSymbol = parent->symbol();
721 parent->removeRow( row );
722 parent->updatePreview( screen() );
724 const QModelIndex newIdx = parent->child( 0 )->index();
725 layersTree->setCurrentIndex( newIdx );
729 emitSymbolModified();
736 moveLayerByOffset( +1 );
741 moveLayerByOffset( -1 );
744void QgsSymbolSelectorWidget::moveLayerByOffset(
int offset )
746 SymbolLayerItem *item = currentLayerItem();
749 const int row = item->row();
751 SymbolLayerItem *parent =
static_cast<SymbolLayerItem *
>( item->parent() );
752 QgsSymbol *parentSymbol = parent->symbol();
754 const int layerIdx = parent->rowCount() - row - 1;
759 QList<QStandardItem *> rowItems = parent->takeRow( row );
760 parent->insertRows( row + offset, rowItems );
761 parent->updatePreview( screen() );
763 const QModelIndex newIdx = rowItems[0]->index();
764 layersTree->setCurrentIndex( newIdx );
767 emitSymbolModified();
776 layer->
setLocked( mLockColorAction->isChecked() );
777 updateLockButtonIcon();
783 const QModelIndex idx = layersTree->currentIndex();
784 if ( !idx.isValid() )
787 SymbolLayerItem *item =
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->itemFromIndex( idx ) );
788 if ( !item->isLayer() )
793 const int insertIdx = item->row();
794 item =
static_cast<SymbolLayerItem *
>( item->parent() );
796 QgsSymbol *parentSymbol = item->symbol();
800 if ( insertIdx == -1 )
805 SymbolLayerItem *newLayerItem =
new SymbolLayerItem( newLayer, parentSymbol->
type(), mVectorLayer, screen() );
806 item->insertRow( insertIdx == -1 ? 0 : insertIdx, newLayerItem );
810 layersTree->setExpanded( newLayerItem->index(),
true );
812 item->updatePreview( screen() );
814 layersTree->setCurrentIndex( mSymbolLayersModel->indexFromItem( newLayerItem ) );
817 emitSymbolModified();
822 SymbolLayerItem *item = currentLayerItem();
824 if ( item->rowCount() > 0 )
826 item->removeRow( 0 );
828 QgsSymbol *
symbol =
static_cast<SymbolLayerItem *
>( item->parent() )->symbol();
831 item->setLayer( newLayer,
symbol->type(), screen() );
836 layersTree->setExpanded( item->index(),
true );
840 const int layerIdx = item->parent()->rowCount() - item->row() - 1;
841 symbol->changeSymbolLayer( layerIdx, newLayer );
843 item->updatePreview( screen() );
845 emitSymbolModified();
850void QgsSymbolSelectorWidget::updateListIcons()
852 QScreen *currentScreen = screen();
853 std::function<void( SymbolLayerItem * item )> updateItem;
854 updateItem = [currentScreen, &updateItem]( SymbolLayerItem *item ) {
855 for (
int row = 0; row < item->rowCount(); ++row )
857 if (
auto child =
dynamic_cast< SymbolLayerItem *
>( item->child( row ) ) )
860 child->updatePreview( currentScreen );
865 updateItem(
static_cast<SymbolLayerItem *
>( mSymbolLayersModel->invisibleRootItem() ) );
872 setLayout(
new QVBoxLayout() );
875 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok );
877 connect( mButtonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
878 connect( mButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
879 connect( mButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsSymbolSelectorDialog::showHelp );
881 layout()->addWidget( mSelectorWidget );
882 layout()->addWidget( mButtonBox );
886 mSelectorWidget->setMinimumSize( 460, 560 );
887 setObjectName( u
"SymbolSelectorDialog"_s );
894 layout()->setContentsMargins( 0, 0, 0, 0 );
898 setWindowTitle( tr(
"Symbol Selector" ) );
900 mSelectorWidget->setDockMode( embedded );
905 return mSelectorWidget->advancedMenu();
910 mSelectorWidget->setContext(
context );
915 return mSelectorWidget->context();
920 return mSelectorWidget->symbol();
926 if ( !isWindow() && e->key() == Qt::Key_Escape )
932 QDialog::keyPressEvent( e );
936void QgsSymbolSelectorDialog::reloadSymbol()
938 mSelectorWidget->reloadSymbol();
943 mSelectorWidget->loadSymbol(
symbol, parent );
946void QgsSymbolSelectorDialog::updateUi()
948 mSelectorWidget->updateUi();
951void QgsSymbolSelectorDialog::updateLockButton()
953 mSelectorWidget->updateLockButton();
956SymbolLayerItem *QgsSymbolSelectorDialog::currentLayerItem()
958 return mSelectorWidget->currentLayerItem();
963 return mSelectorWidget->currentLayer();
966void QgsSymbolSelectorDialog::moveLayerByOffset(
int offset )
968 mSelectorWidget->moveLayerByOffset( offset );
971void QgsSymbolSelectorDialog::setWidget( QWidget *widget )
973 mSelectorWidget->setWidget( widget );
978 mSelectorWidget->moveLayerDown();
983 mSelectorWidget->moveLayerUp();
988 mSelectorWidget->addLayer();
993 mSelectorWidget->removeLayer();
998 mSelectorWidget->lockLayer();
1003 mSelectorWidget->duplicateLayer();
1008 mSelectorWidget->layerChanged();
1013 mSelectorWidget->updateLayerPreview();
1018 mSelectorWidget->updatePreview();
1023 mSelectorWidget->symbolChanged();
1028 mSelectorWidget->changeLayer( layer );
1036void QgsSymbolSelectorDialog::showHelp()
1041void QgsSymbolSelectorWidget::projectDataChanged()
1043 mBlockModified =
true;
1046 mBlockModified =
false;
1049void QgsSymbolSelectorWidget::layersAboutToBeRemoved(
const QList<QgsMapLayer *> &layers )
1051 if ( mVectorLayer && layers.contains( mVectorLayer ) )
1057void QgsSymbolSelectorWidget::emitSymbolModified()
1059 if ( !mBlockModified )
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.
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).
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.
A utility class for dynamic handling of changes to screen properties.
void screenDpiChanged(double dpi)
Emitted whenever the screen dpi associated with the widget is changed.
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,...
Abstract base class for all rendered symbols.
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.
QgsSymbolLayer * takeSymbolLayer(int index)
Removes a symbol layer from the list and returns a pointer to it.
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