Skip to content

Commit

Permalink
Show labeling in raster layer properties dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 18, 2024
1 parent e5379a7 commit 851e360
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 50 deletions.
10 changes: 10 additions & 0 deletions src/gui/raster/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#include "qgswebframe.h"
#include "qgsexpressionfinder.h"
#include "qgsexpressionbuilderdialog.h"
#include "qgsrasterlabelingwidget.h"
#if WITH_QTWEBKIT
#include <QWebElement>
#endif
Expand Down Expand Up @@ -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<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterLayerProperties::mRenderTypeComboBox_currentIndexChanged );
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -954,6 +962,8 @@ void QgsRasterLayerProperties::apply()
QgsRasterRenderer *rasterRenderer = mRasterLayer->renderer();
mRasterTransparencyWidget->applyToRasterRenderer( rasterRenderer );

mLabelingWidget->apply();

if ( rasterRenderer )
{
// Sync the layer styling widget
Expand Down
3 changes: 3 additions & 0 deletions src/gui/raster/qgsrasterlayerproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class QgsPropertyOverrideButton;
class QgsRasterTransparencyWidget;
class QgsRasterAttributeTableWidget;
class QgsWebView;
class QgsRasterLabelingWidget;

/**
* \ingroup gui
Expand Down Expand Up @@ -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.
*/
Expand Down
116 changes: 66 additions & 50 deletions src/ui/qgsrasterlayerpropertiesbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@
<normaloff>:/images/themes/default/propertyicons/transparency.svg</normaloff>:/images/themes/default/propertyicons/transparency.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Labels</string>
</property>
<property name="toolTip">
<string>Labels</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionLabeling.svg</normaloff>:/images/themes/default/mActionLabeling.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Histogram</string>
Expand Down Expand Up @@ -320,8 +332,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>354</width>
<height>457</height>
<width>320</width>
<height>455</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
Expand Down Expand Up @@ -350,15 +362,15 @@
<property name="checkable">
<bool>false</bool>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">vectorgeneral</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QgsProjectionSelectionWidget" name="mCrsSelector">
<widget class="QgsProjectionSelectionWidget" name="mCrsSelector" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
Expand Down Expand Up @@ -443,8 +455,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>665</width>
<height>365</height>
<width>643</width>
<height>680</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
Expand All @@ -471,7 +483,7 @@
<property name="title">
<string>Band Rendering</string>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">rasterstyle</string>
</property>
<layout class="QGridLayout" name="gridLayout_14">
Expand Down Expand Up @@ -516,13 +528,13 @@
<property name="title">
<string>Layer Rendering</string>
</property>
<property name="collapsed">
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">rasterstyle</string>
</property>
<property name="saveCollapsedState">
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
Expand Down Expand Up @@ -877,13 +889,13 @@
<property name="checkable">
<bool>false</bool>
</property>
<property name="collapsed">
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">rasterstyle</string>
</property>
<property name="saveCollapsedState">
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
Expand Down Expand Up @@ -985,6 +997,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptsPage_Labeling"/>
<widget class="QWidget" name="mOptsPage_Histogram">
<layout class="QVBoxLayout" name="verticalLayout_15">
<property name="leftMargin">
Expand Down Expand Up @@ -1012,8 +1025,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>681</height>
<width>98</width>
<height>39</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
Expand Down Expand Up @@ -1075,7 +1088,7 @@
<property name="checked">
<bool>false</bool>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">rastergeneral</string>
</property>
<layout class="QGridLayout" name="_5">
Expand All @@ -1095,7 +1108,7 @@
<number>6</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QgsScaleRangeWidget" name="mScaleRangeWidget">
<widget class="QgsScaleRangeWidget" name="mScaleRangeWidget" native="true">
<property name="toolTip">
<string/>
</property>
Expand Down Expand Up @@ -1188,8 +1201,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>543</width>
<height>184</height>
<width>504</width>
<height>187</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
Expand Down Expand Up @@ -1256,10 +1269,13 @@
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Cantarell';&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Cantarell'; font-size:11pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -1622,8 +1638,8 @@ You can also import an existing raster attribute table from a VAT.DBF file and a
<rect>
<x>0</x>
<y>0</y>
<width>374</width>
<height>694</height>
<width>331</width>
<height>709</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_12">
Expand All @@ -1644,7 +1660,7 @@ You can also import an existing raster attribute table from a VAT.DBF file and a
<property name="title">
<string>Description</string>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">rastermeta</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
Expand Down Expand Up @@ -1780,7 +1796,7 @@ You can also import an existing raster attribute table from a VAT.DBF file and a
<property name="title">
<string>Attribution</string>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">vectormeta</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
Expand Down Expand Up @@ -1826,7 +1842,7 @@ You can also import an existing raster attribute table from a VAT.DBF file and a
<property name="title">
<string>Metadata URL</string>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">vectormeta</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_18">
Expand Down Expand Up @@ -2030,21 +2046,38 @@ You can also import an existing raster attribute table from a VAT.DBF file and a
</widget>
<customwidgets>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsColorButton</class>
<extends>QToolButton</extends>
<header>qgscolorbutton.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
<class>QgsSpinBox</class>
<extends>QSpinBox</extends>
<header>qgsspinbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsFilterLineEdit</class>
Expand All @@ -2062,18 +2095,6 @@ You can also import an existing raster attribute table from a VAT.DBF file and a
<extends>QWidget</extends>
<header>qgsscalerangewidget.h</header>
</customwidget>
<customwidget>
<class>QgsSpinBox</class>
<extends>QSpinBox</extends>
<header>qgsspinbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsScrollArea</class>
<extends>QScrollArea</extends>
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsLayerTreeEmbeddedConfigWidget</class>
<extends>QWidget</extends>
Expand All @@ -2085,11 +2106,6 @@ You can also import an existing raster attribute table from a VAT.DBF file and a
<extends>QWidget</extends>
<header>qgscodeeditorhtml.h</header>
</customwidget>
<customwidget>
<class>QgsBlendModeComboBox</class>
<extends>QComboBox</extends>
<header>qgsblendmodecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsImageSourceLineEdit</class>
<extends>QWidget</extends>
Expand Down

0 comments on commit 851e360

Please sign in to comment.