24#include "moc_qgsrasterlabelingwidget.cpp"
29 , mMessageBar( messageBar )
34 mLabelModeComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"labelingNone.svg" ) ), tr(
"No Labels" ), QStringLiteral(
"none" ) );
35 mLabelModeComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"labelingSingle.svg" ) ), tr(
"Label with Pixel Values" ), QStringLiteral(
"simple" ) );
37 connect( mLabelModeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsRasterLabelingWidget::labelModeChanged );
40 connect( mLabelRulesButton, &QAbstractButton::clicked,
this, &QgsRasterLabelingWidget::showLabelingEngineRulesPrivate );
41 connect( mEngineSettingsButton, &QAbstractButton::clicked,
this, &QgsRasterLabelingWidget::showEngineConfigDialogPrivate );
44 mEngineSettingsButton->setIconSize( QSize( iconSize16, iconSize16 ) );
45 mLabelRulesButton->setIconSize( QSize( iconSize16, iconSize16 ) );
70 QgsRasterLayer *layer = qobject_cast<QgsRasterLayer *>( mapLayer );
83 if ( mLayer->labelsEnabled() && labeling )
85 index = mLabelModeComboBox->findData( labeling->
type() );
88 settingsWidget->setLayer( mLayer );
89 settingsWidget->setLabeling( labeling );
97 if ( index != mLabelModeComboBox->currentIndex() )
99 mLabelModeComboBox->setCurrentIndex( index );
105 const QString mode = mLabelModeComboBox->currentData().toString();
106 if ( mode == QLatin1String(
"simple" ) )
108 auto labeling = std::make_unique<QgsRasterLayerSimpleLabeling>();
111 settingsWidget->updateLabeling( labeling.get() );
113 mLayer->setLabeling( labeling.release() );
114 mLayer->setLabelsEnabled(
true );
118 mLayer->setLabelsEnabled(
false );
127 mLayer->triggerRepaint();
130void QgsRasterLabelingWidget::labelModeChanged(
int index )
133 mStackedWidget->removeWidget( mWidget );
141 const QString mode = mLabelModeComboBox->currentData().toString();
142 if ( mode == QLatin1String(
"simple" ) )
149 settingsWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
150 settingsWidget->setContext( context );
152 settingsWidget->setDockMode(
dockMode() );
155 mWidget = settingsWidget;
158 auto labeling = std::make_unique<QgsRasterLayerSimpleLabeling>();
160 mLayer->setLabeling( labeling.release() );
167 mStackedWidget->addWidget( mWidget );
168 mStackedWidget->setCurrentWidget( mWidget );
174void QgsRasterLabelingWidget::showLabelingEngineRulesPrivate()
179void 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,...