From 851e36013cc961cf239807d2b258bc58feb815bc Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 18 Dec 2024 16:05:06 +1000 Subject: [PATCH] Show labeling in raster layer properties dialog --- src/gui/raster/qgsrasterlayerproperties.cpp | 10 ++ src/gui/raster/qgsrasterlayerproperties.h | 3 + src/ui/qgsrasterlayerpropertiesbase.ui | 116 +++++++++++--------- 3 files changed, 79 insertions(+), 50 deletions(-) diff --git a/src/gui/raster/qgsrasterlayerproperties.cpp b/src/gui/raster/qgsrasterlayerproperties.cpp index 58fcdb826818..a8db645d107b 100644 --- a/src/gui/raster/qgsrasterlayerproperties.cpp +++ b/src/gui/raster/qgsrasterlayerproperties.cpp @@ -69,6 +69,7 @@ #include "qgswebframe.h" #include "qgsexpressionfinder.h" #include "qgsexpressionbuilderdialog.h" +#include "qgsrasterlabelingwidget.h" #if WITH_QTWEBKIT #include #endif @@ -120,6 +121,12 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv transparencyScrollArea->setWidget( mRasterTransparencyWidget ); + mLabelingWidget = new QgsRasterLabelingWidget( mRasterLayer, canvas, this ); + QVBoxLayout *vl = new QVBoxLayout(); + vl->setContentsMargins( 0, 0, 0, 0 ); + vl->addWidget( mLabelingWidget ); + mOptsPage_Labeling->setLayout( vl ); + connect( buttonBuildPyramids, &QPushButton::clicked, this, &QgsRasterLayerProperties::buttonBuildPyramids_clicked ); connect( mCrsSelector, &QgsProjectionSelectionWidget::crsChanged, this, &QgsRasterLayerProperties::mCrsSelector_crsChanged ); connect( mRenderTypeComboBox, static_cast( &QComboBox::currentIndexChanged ), this, &QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged ); @@ -743,6 +750,7 @@ void QgsRasterLayerProperties::sync() return; mRasterTransparencyWidget->syncToLayer(); + mLabelingWidget->syncToLayer( mRasterLayer ); if ( provider->dataType( 1 ) == Qgis::DataType::ARGB32 || provider->dataType( 1 ) == Qgis::DataType::ARGB32_Premultiplied ) @@ -954,6 +962,8 @@ void QgsRasterLayerProperties::apply() QgsRasterRenderer *rasterRenderer = mRasterLayer->renderer(); mRasterTransparencyWidget->applyToRasterRenderer( rasterRenderer ); + mLabelingWidget->apply(); + if ( rasterRenderer ) { // Sync the layer styling widget diff --git a/src/gui/raster/qgsrasterlayerproperties.h b/src/gui/raster/qgsrasterlayerproperties.h index 3c2c1852fa0a..70902c4f2d81 100644 --- a/src/gui/raster/qgsrasterlayerproperties.h +++ b/src/gui/raster/qgsrasterlayerproperties.h @@ -46,6 +46,7 @@ class QgsPropertyOverrideButton; class QgsRasterTransparencyWidget; class QgsRasterAttributeTableWidget; class QgsWebView; +class QgsRasterLabelingWidget; /** * \ingroup gui @@ -212,6 +213,8 @@ class GUI_EXPORT QgsRasterLayerProperties : public QgsLayerPropertiesDialog, pri QgsRasterTransparencyWidget *mRasterTransparencyWidget = nullptr; + QgsRasterLabelingWidget *mLabelingWidget = nullptr; + /** * Widget with temporal inputs, to be used by temporal based raster layers. */ diff --git a/src/ui/qgsrasterlayerpropertiesbase.ui b/src/ui/qgsrasterlayerpropertiesbase.ui index c572982b5b32..c01ce6fb0b09 100644 --- a/src/ui/qgsrasterlayerpropertiesbase.ui +++ b/src/ui/qgsrasterlayerpropertiesbase.ui @@ -137,6 +137,18 @@ :/images/themes/default/propertyicons/transparency.svg:/images/themes/default/propertyicons/transparency.svg + + + Labels + + + Labels + + + + :/images/themes/default/mActionLabeling.svg:/images/themes/default/mActionLabeling.svg + + Histogram @@ -320,8 +332,8 @@ 0 0 - 354 - 457 + 320 + 455 @@ -350,7 +362,7 @@ false - + vectorgeneral @@ -358,7 +370,7 @@ 6 - + Qt::StrongFocus @@ -443,8 +455,8 @@ 0 0 - 665 - 365 + 643 + 680 @@ -471,7 +483,7 @@ Band Rendering - + rasterstyle @@ -516,13 +528,13 @@ Layer Rendering - + false - + rasterstyle - + true @@ -877,13 +889,13 @@ false - + false - + rasterstyle - + true @@ -985,6 +997,7 @@ + @@ -1012,8 +1025,8 @@ 0 0 - 643 - 681 + 98 + 39 @@ -1075,7 +1088,7 @@ false - + rastergeneral @@ -1095,7 +1108,7 @@ 6 - + @@ -1188,8 +1201,8 @@ 0 0 - 543 - 184 + 504 + 187 @@ -1256,10 +1269,13 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell';"><br /></span></p></body></html> +hr { height: 1px; border-width: 0; } +li.unchecked::marker { content: "\2610"; } +li.checked::marker { content: "\2612"; } +</style></head><body style=" font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:11pt;"><br /></span></p></body></html> @@ -1622,8 +1638,8 @@ You can also import an existing raster attribute table from a VAT.DBF file and a 0 0 - 374 - 694 + 331 + 709 @@ -1644,7 +1660,7 @@ You can also import an existing raster attribute table from a VAT.DBF file and a Description - + rastermeta @@ -1780,7 +1796,7 @@ You can also import an existing raster attribute table from a VAT.DBF file and a Attribution - + vectormeta @@ -1826,7 +1842,7 @@ You can also import an existing raster attribute table from a VAT.DBF file and a Metadata URL - + vectormeta @@ -2030,11 +2046,16 @@ You can also import an existing raster attribute table from a VAT.DBF file and a - QgsCollapsibleGroupBox - QGroupBox -
qgscollapsiblegroupbox.h
+ QgsScrollArea + QScrollArea +
qgsscrollarea.h
1
+ + QgsDoubleSpinBox + QDoubleSpinBox +
qgsdoublespinbox.h
+
QgsColorButton QToolButton @@ -2042,9 +2063,21 @@ You can also import an existing raster attribute table from a VAT.DBF file and a 1 - QgsDoubleSpinBox - QDoubleSpinBox -
qgsdoublespinbox.h
+ QgsSpinBox + QSpinBox +
qgsspinbox.h
+ 1 +
+ + QgsCollapsibleGroupBox + QGroupBox +
qgscollapsiblegroupbox.h
+ 1 +
+ + QgsBlendModeComboBox + QComboBox +
qgsblendmodecombobox.h
QgsFilterLineEdit @@ -2062,18 +2095,6 @@ You can also import an existing raster attribute table from a VAT.DBF file and a QWidget
qgsscalerangewidget.h
- - QgsSpinBox - QSpinBox -
qgsspinbox.h
- 1 -
- - QgsScrollArea - QScrollArea -
qgsscrollarea.h
- 1 -
QgsLayerTreeEmbeddedConfigWidget QWidget @@ -2085,11 +2106,6 @@ You can also import an existing raster attribute table from a VAT.DBF file and a QWidget
qgscodeeditorhtml.h
- - QgsBlendModeComboBox - QComboBox -
qgsblendmodecombobox.h
-
QgsImageSourceLineEdit QWidget