45#include "moc_qgsrendererpropertiesdialog.cpp"
47using namespace Qt::StringLiterals;
49static bool initVectorLayerRenderer(
const QString &name,
QgsRendererWidgetFunc f,
const QString &iconName = QString() )
61 if ( !iconName.isEmpty() )
70void QgsRendererPropertiesDialog::initRendererWidgetFunctions()
72 static bool sInitialized =
false;
99 mLayerRenderingGroupBox->setSettingGroup( u
"layerRenderingGroupBox"_s );
105 layout()->setContentsMargins( 0, 0, 0, 0 );
109 initRendererWidgetFunctions();
113 const auto constRenderers = renderers;
114 for (
const QString &name : constRenderers )
120 cboRenderers->setCurrentIndex( -1 );
126 connect( checkboxEnableOrderBy, &QAbstractButton::toggled, btnOrderBy, &QWidget::setEnabled );
127 connect( btnOrderBy, &QAbstractButton::clicked,
this, &QgsRendererPropertiesDialog::showOrderByDialog );
131 QList<QWidget *> widgets;
132 widgets << mOpacityWidget
134 << checkboxEnableOrderBy
135 << mBlendModeComboBox
136 << mFeatureBlendComboBox
145 for ( QWidget *widget : widgets )
155 else if (
QgsOpacityWidget *w = qobject_cast<QgsOpacityWidget *>( widget ) )
159 else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
163 else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
167 else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
171 else if (
QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
175 else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
179 else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
219 mDockMode = dockMode;
220 mEffectWidget->setDockMode( dockMode );
228 if ( cboRenderers->currentIndex() == -1 )
230 QgsDebugError( u
"No current item -- this should never happen!"_s );
234 const QString rendererName = cboRenderers->currentData().toString();
244 oldRenderer =
mLayer->renderer()->clone();
287 stackedWidget->setCurrentWidget( pageNoWidget );
312 mLayer->setBlendMode( mBlendModeComboBox->blendMode() );
313 mLayer->setFeatureBlendMode( mFeatureBlendComboBox->blendMode() );
316 mLayer->setOpacity( mOpacityWidget->opacity() );
334 QDialog *dlg =
new QDialog();
335 const QString key = u
"/UI/paneldialog/%1"_s.arg( panel->
panelTitle() );
337 dlg->restoreGeometry( settings.
value( key ).toByteArray() );
339 dlg->setLayout(
new QVBoxLayout() );
340 dlg->layout()->addWidget( panel );
341 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok );
342 connect( buttonBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept );
343 dlg->layout()->addWidget( buttonBox );
345 settings.
setValue( key, dlg->saveGeometry() );
350void QgsRendererPropertiesDialog::syncToLayer()
353 mFeatureBlendComboBox->setShowClippingModes( mBlendModeComboBox->showClippingModes() );
378 if (
mLayer->renderer() &&
mLayer->renderer()->orderByEnabled() )
380 checkboxEnableOrderBy->setChecked(
true );
384 btnOrderBy->setEnabled(
false );
385 checkboxEnableOrderBy->setChecked(
false );
391 const QString rendererName =
mLayer->renderer()->type();
393 const int rendererIdx = cboRenderers->findData( rendererName );
394 cboRenderers->setCurrentIndex( rendererIdx );
397 Q_ASSERT( rendererIdx != -1 &&
"there must be a renderer!" );
401void QgsRendererPropertiesDialog::showOrderByDialog()
403 QgsOrderByDialog dlg(
mLayer,
this );
416 checkboxEnableOrderBy->setChecked( orderByEnabled );
419void QgsRendererPropertiesDialog::updateUIState(
bool hidden )
421 mLayerRenderingGroupBox->setHidden( hidden );
422 cboRenderers->setHidden( hidden );
429 if ( !isWindow() && e->key() == Qt::Key_Escape )
435 QDialog::keyPressEvent( e );
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsRendererRegistry * rendererRegistry()
Returns the application's renderer registry, used for managing vector layer renderers.
Abstract base class for all 2D vector feature renderers.
void setOrderBy(const QgsFeatureRequest::OrderBy &orderBy)
Define the order in which features shall be processed by this renderer.
void setOrderByEnabled(bool enabled)
Sets whether custom ordering should be applied before features are processed by this renderer.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the renderer.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
Represents a list of OrderByClauses, with the most important first and the least important last.
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...
Map canvas is a class for displaying all GIS data types on a canvas.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
static bool layerIsContainedInGroupLayer(QgsProject *project, QgsMapLayer *layer)
Returns true if the specified layer is a child layer from any QgsGroupLayer in the given project.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void showPanel(QgsPanelWidget *panel)
Emit when you require a panel to be show in the interface.
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
QgsMapCanvas * mMapCanvas
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the dialog is shown, e.g., the associated map canvas and expression context...
void connectValueChanged(const QList< QWidget * > &widgets)
Connect the value changed event for the set of widgets to widgetChanged signal.
QgsFeatureRequest::OrderBy mOrderBy
QgsPaintEffect * mPaintEffect
QgsMessageBar * mMessageBar
void apply()
Apply the changes from the dialog to the layer.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the dialog.
void layerVariablesChanged()
Emitted when expression context variables on the associated vector layers have been changed.
void widgetChanged()
Emitted when something on the widget has changed.
~QgsRendererPropertiesDialog() override
void onOK()
Apply and accept the changes for the dialog.
void keyPressEvent(QKeyEvent *event) override
void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
QgsRendererWidget * mActiveWidget
QgsRendererPropertiesDialog(QgsVectorLayer *layer, QgsStyle *style, bool embedded=false, QWidget *parent=nullptr)
Constructor for QgsRendererPropertiesDialog.
void rendererChanged()
called when user changes renderer type
QStringList renderersList(QgsRendererAbstractMetadata::LayerTypes layerTypes=QgsRendererAbstractMetadata::All) const
Returns a list of available renderers.
QgsRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
A database of saved style entities, including symbols, color ramps, text formats and others.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
void setMessageBar(QgsMessageBar *bar)
Sets the message bar associated with the widget.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
Represents a vector layer which manages a vector based dataset.
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views.
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
QgsRendererWidget *(* QgsRendererWidgetFunc)(QgsVectorLayer *, QgsStyle *, QgsFeatureRenderer *)