48#include <QStandardItem>
51#include "moc_qgslayerpropertieswidget.cpp"
53using namespace Qt::StringLiterals;
60 if ( !abstractMetadata )
62 QgsDebugError(
"Failed to find symbol layer's entry in registry: " + name );
68 QgsDebugError(
"Failed to cast symbol layer's metadata: " + name );
75static void _initWidgetFunctions()
77 static bool sInitialized =
false;
124 connect( mEnabledCheckBox, &QCheckBox::toggled,
this, &QgsLayerPropertiesWidget::mEnabledCheckBox_toggled );
128 _initWidgetFunctions();
141 const int idx = cboLayerType->findData(
mLayer->layerType() );
142 cboLayerType->setCurrentIndex( idx );
144 connect( mEnabledCheckBox, &QAbstractButton::toggled, mEnabledDDBtn, &QWidget::setEnabled );
145 mEnabledCheckBox->setChecked(
mLayer->enabled() );
155 if ( !
mLayer->paintEffect() )
158 mLayer->paintEffect()->setEnabled(
false );
160 mEffectWidget->setPaintEffect(
mLayer->paintEffect() );
169 mContext.setSymbolType(
mSymbol->type() );
184 mEffectWidget->setDockMode( this->
dockMode() );
191 const auto constSymbolLayerIds = symbolLayerIds;
192 for (
const QString &symbolLayerId : constSymbolLayerIds )
198 const auto constLineLayerIds = lineLayerIds;
199 for (
const QString &lineLayerId : constLineLayerIds )
204 const QString visibleName = layerInfo->
visibleName();
205 const QString name = tr(
"Outline: %1" ).arg( visibleName );
206 cboLayerType->addItem( name, lineLayerId );
214 if ( stackedWidget->currentWidget() != pageDummy )
217 if (
QgsSymbolLayerWidget *w = qobject_cast<QgsSymbolLayerWidget *>( stackedWidget->currentWidget() ) )
219 stackedWidget->removeWidget( stackedWidget->currentWidget() );
224 const QString layerType = layer->
layerType();
233 stackedWidget->addWidget( w );
234 stackedWidget->setCurrentWidget( w );
242 stackedWidget->setCurrentWidget( pageDummy );
247 if (
auto *lExpressionContext = mContext.expressionContext() )
248 return *lExpressionContext;
251 if (
auto *lMapCanvas = mContext.mapCanvas() )
253 expContext = lMapCanvas->createExpressionContext();
272 expContext << symbolScope;
285 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
306void QgsLayerPropertiesWidget::updateProperty()
319 const QString newLayerType = cboLayerType->currentData().toString();
320 if ( layer->
layerType() == newLayerType )
337 if ( generator->subSymbol() && generator->subSymbol()->symbolLayerCount() > 0 )
338 properties = generator->subSymbol()->symbolLayer( 0 )->properties();
357 generator->setSubSymbol( markerSymbol.release() );
364 generator->setSubSymbol( lineSymbol.release() );
371 generator->setSubSymbol( fillSymbol.release() );
392 const QString defaultFont = fontMarker->fontFamily();
393 const QFontDatabase fontDb;
394 if ( !fontDb.hasFamily( defaultFont ) )
397 const QStringList candidates = fontDb.families( QFontDatabase::WritingSystem::Symbol );
398 bool foundGoodCandidate =
false;
399 for (
const QString &candidate : candidates )
401 if ( fontDb.writingSystems( candidate ).size() == 1 )
404 fontMarker->setFontFamily( candidate );
405 foundGoodCandidate =
true;
409 if ( !foundGoodCandidate && !candidates.empty() )
412 QString candidate = candidates.at( 0 );
413 fontMarker->setFontFamily( candidate );
418 const QFontMetrics fontMetrics( fontMarker->fontFamily() );
419 ushort character = fontMarker->character().at( 0 ).unicode();
420 for ( ; character < 1000; ++character )
422 if ( fontMetrics.inFont( QChar( character ) ) )
424 fontMarker->setCharacter( QChar( character ) );
439 bool paintEffectToggled =
false;
440 if (
mLayer->paintEffect() &&
mLayer->paintEffect()->enabled() )
442 mLayer->paintEffect()->setEnabled(
false );
443 paintEffectToggled =
true;
446 if ( paintEffectToggled )
448 mLayer->paintEffect()->setEnabled(
true );
453void QgsLayerPropertiesWidget::reloadLayer()
458void QgsLayerPropertiesWidget::mEnabledCheckBox_toggled(
bool enabled )
460 mLayer->setEnabled( enabled );
@ Millimeters
Millimeters.
static QgsSymbolLayerRegistry * symbolLayerRegistry()
Returns the application's symbol layer registry, used for managing symbol layers.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
static const QString EXPR_CLUSTER_SIZE
Inbuilt variable name for cluster size variable.
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
static const QString EXPR_GEOMETRY_RING_NUM
Inbuilt variable name for geometry ring number variable.
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
QgsExpressionContextScope * lastScope()
Returns the last scope added to the context.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
static const QString EXPR_CLUSTER_COLOR
Inbuilt variable name for cluster color variable.
A marker symbol layer which displays characters rendered using a font.
A symbol layer subclass which alters rendered feature shapes through the use of QGIS expressions.
Contains configuration for rendering maps.
Struct for storing maximum and minimum scales for measurements in map units.
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects.
static QgsProject * instance()
Returns the QgsProject singleton instance.
Registry of available symbol layer classes.
QStringList symbolLayersForType(Qgis::SymbolType type)
Returns a list of available symbol layers for a specified symbol type.
QgsSymbolLayerAbstractMetadata * symbolLayerMetadata(const QString &name) const
Returns metadata for specified symbol layer. Returns nullptr if not found.
static QPicture symbolLayerPreviewPicture(const QgsSymbolLayer *layer, Qgis::RenderUnit units, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::SymbolType parentSymbolType=Qgis::SymbolType::Hybrid)
Draws a symbol layer preview to a QPicture.
Abstract base class for symbol layers.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
Property
Data definable properties.
@ LayerEnabled
Whether symbol layer is enabled.
virtual QVariantMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Abstract base class for all rendered symbols.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
Qgis::SymbolType type() const
Returns the symbol's type.
Represents a vector layer which manages a vector based dataset.
#define QgsDebugError(str)
QList< QgsSymbolLayer * > QgsSymbolLayerList
QgsSymbolLayerWidget *(* QgsSymbolLayerWidgetFunc)(QgsVectorLayer *)
Single variable definition for use within a QgsExpressionContextScope.