26#include "moc_qgsrasterlabelingwidget.cpp"
28using namespace Qt::StringLiterals;
33 , mMessageBar( messageBar )
41 connect( mLabelModeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsRasterLabelingWidget::labelModeChanged );
44 connect( mLabelRulesButton, &QAbstractButton::clicked,
this, &QgsRasterLabelingWidget::showLabelingEngineRulesPrivate );
45 connect( mEngineSettingsButton, &QAbstractButton::clicked,
this, &QgsRasterLabelingWidget::showEngineConfigDialogPrivate );
48 mEngineSettingsButton->setIconSize( QSize( iconSize16, iconSize16 ) );
49 mLabelRulesButton->setIconSize( QSize( iconSize16, iconSize16 ) );
74 QgsRasterLayer *layer = qobject_cast<QgsRasterLayer *>( mapLayer );
87 if ( mLayer->labelsEnabled() && labeling )
89 index = mLabelModeComboBox->findData( labeling->
type() );
92 settingsWidget->setLayer( mLayer );
93 settingsWidget->setLabeling( labeling );
101 if ( index != mLabelModeComboBox->currentIndex() )
103 mLabelModeComboBox->setCurrentIndex( index );
109 const QString mode = mLabelModeComboBox->currentData().toString();
110 if ( mode ==
"simple"_L1 )
112 auto labeling = std::make_unique<QgsRasterLayerSimpleLabeling>();
115 settingsWidget->updateLabeling( labeling.get() );
117 mLayer->setLabeling( labeling.release() );
118 mLayer->setLabelsEnabled(
true );
122 mLayer->setLabelsEnabled(
false );
131 mLayer->triggerRepaint();
134void QgsRasterLabelingWidget::labelModeChanged(
int index )
137 mStackedWidget->removeWidget( mWidget );
145 const QString mode = mLabelModeComboBox->currentData().toString();
146 if ( mode ==
"simple"_L1 )
153 settingsWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
154 settingsWidget->setContext( context );
156 settingsWidget->setDockMode(
dockMode() );
159 mWidget = settingsWidget;
162 auto labeling = std::make_unique<QgsRasterLayerSimpleLabeling>();
164 mLayer->setLabeling( labeling.release() );
171 mStackedWidget->addWidget( mWidget );
172 mStackedWidget->setCurrentWidget( mWidget );
178void QgsRasterLabelingWidget::showLabelingEngineRulesPrivate()
183void QgsRasterLabelingWidget::showEngineConfigDialogPrivate()
Abstract base class for labeling settings for raster layers.
virtual QString type() const =0
Unique type string of the labeling configuration implementation.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
A bar for displaying non-blocking messages to the user.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void setDirty(bool b=true)
Flag the project as dirty (modified).
Basic implementation of the labeling interface for raster layers.
Represents a raster layer.
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.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...