42 #include <QMessageBox> 
   44 static bool _initRenderer( 
const QString &name, 
QgsRendererWidgetFunc f, 
const QString &iconName = QString() )
 
   56   if ( !iconName.isEmpty() )
 
   65 static void _initRendererWidgetFunctions()
 
   67   static bool sInitialized = 
false;
 
   94   mLayerRenderingGroupBox->setSettingGroup( QStringLiteral( 
"layerRenderingGroupBox" ) );
 
  100     layout()->setContentsMargins( 0, 0, 0, 0 );
 
  104   _initRendererWidgetFunctions();
 
  108   const auto constRenderers = renderers;
 
  109   for ( 
const QString &name : constRenderers )
 
  115   cboRenderers->setCurrentIndex( -1 ); 
 
  121   connect( checkboxEnableOrderBy, &QAbstractButton::toggled, btnOrderBy, &QWidget::setEnabled );
 
  122   connect( btnOrderBy, &QAbstractButton::clicked, 
this, &QgsRendererPropertiesDialog::showOrderByDialog );
 
  126   QList<QWidget *> widgets;
 
  127   widgets << mOpacityWidget
 
  129           << checkboxEnableOrderBy
 
  130           << mBlendModeComboBox
 
  131           << mFeatureBlendComboBox
 
  140   for ( QWidget *widget : widgets )
 
  144       connect( w, SIGNAL( changed ), 
this, slot );
 
  148       connect( w, SIGNAL( fieldChanged( QString ) ), 
this,  slot );
 
  150     else if ( 
QgsOpacityWidget *w = qobject_cast<QgsOpacityWidget *>( widget ) )
 
  152       connect( w, SIGNAL( opacityChanged( 
double ) ), 
this,  slot );
 
  154     else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
 
  156       connect( w, SIGNAL( currentIndexChanged( 
int ) ), 
this, slot );
 
  158     else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
 
  160       connect( w, SIGNAL( valueChanged( 
int ) ), 
this, slot );
 
  162     else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
 
  164       connect( w, SIGNAL( valueChanged( 
double ) ), 
this, slot );
 
  166     else if ( 
QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
 
  168       connect( w, SIGNAL( colorChanged( QColor ) ), 
this, slot );
 
  170     else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
 
  172       connect( w, SIGNAL( toggled( 
bool ) ), 
this, slot );
 
  174     else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
 
  176       connect( w, SIGNAL( textEdited( QString ) ), 
this, slot );
 
  177       connect( w, SIGNAL( textChanged( QString ) ), 
this, slot );
 
  181       connect( w, SIGNAL( changed() ), 
this, slot );
 
  214   mDockMode = dockMode;
 
  215   mEffectWidget->setDockMode( dockMode );
 
  223   if ( cboRenderers->currentIndex() == -1 )
 
  225     QgsDebugMsg( QStringLiteral( 
"No current item -- this should never happen!" ) );
 
  229   QString rendererName = cboRenderers->currentData().toString();
 
  282     stackedWidget->setCurrentWidget( pageNoWidget );
 
  329     QDialog *dlg = 
new QDialog();
 
  330     QString key = QStringLiteral( 
"/UI/paneldialog/%1" ).arg( panel->
panelTitle() );
 
  331     QgsSettings settings;
 
  332     dlg->restoreGeometry( settings.value( key ).toByteArray() );
 
  334     dlg->setLayout( 
new QVBoxLayout() );
 
  335     dlg->layout()->addWidget( panel );
 
  336     QDialogButtonBox *buttonBox = 
new QDialogButtonBox( QDialogButtonBox::Ok );
 
  337     connect( buttonBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept );
 
  338     dlg->layout()->addWidget( buttonBox );
 
  340     settings.setValue( key, dlg->saveGeometry() );
 
  345 void QgsRendererPropertiesDialog::syncToLayer()
 
  373     checkboxEnableOrderBy->setChecked( 
true );
 
  377     btnOrderBy->setEnabled( 
false );
 
  378     checkboxEnableOrderBy->setChecked( 
false );
 
  386     int rendererIdx = cboRenderers->findData( rendererName );
 
  387     cboRenderers->setCurrentIndex( rendererIdx );
 
  390     Q_ASSERT( rendererIdx != -1 && 
"there must be a renderer!" );
 
  395 void QgsRendererPropertiesDialog::showOrderByDialog()
 
  410   checkboxEnableOrderBy->setChecked( orderByEnabled );
 
  413 void QgsRendererPropertiesDialog::updateUIState( 
bool hidden )
 
  415   mLayerRenderingGroupBox->setHidden( hidden );
 
  416   cboRenderers->setHidden( hidden );
 
  423   if ( !isWindow() && e->key() == Qt::Key_Escape )
 
  429     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.
void setOrderBy(const QgsFeatureRequest::OrderBy &orderBy)
Define the order in which features shall be processed by this renderer.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of 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.
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer.
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by 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.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
This is a dialog to build and manage a list of order by clauses.
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
void connectValueChanged(const QList< QWidget * > &widgets, const char *slot)
Connect the given slot to the value changed event for the set of widgets Each widget is checked for t...
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...
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.
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 data sets.
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
void setFeatureBlendMode(QPainter::CompositionMode blendMode)
Sets the blending mode used for rendering each feature.
void setRenderer(QgsFeatureRenderer *r)
Sets the feature renderer which will be invoked to represent this layer in 2D map views.
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views.
#define QgsDebugMsgLevel(str, level)
QgsRendererWidget *(* QgsRendererWidgetFunc)(QgsVectorLayer *, QgsStyle *, QgsFeatureRenderer *)