Skip to content
Permalink
Browse files

add support for plugin dialogs raster layer properties

  • Loading branch information
Samweli authored and nyalldawson committed Feb 16, 2021
1 parent 36d7a8e commit a3883761cf5ce3fcc2d4228ff3adbcdf7b6e54b5
@@ -34,6 +34,11 @@ Constructor
:param canvas: the :py:class:`QgsMapCanvas` instance
:param parent: the parent of this widget
:param fl: windows flag
%End

void addPropertiesPageFactory( QgsMapLayerConfigWidgetFactory *factory );
%Docstring
Adds a properties page factory to the raster layer properties dialog.
%End

protected slots:
case QgsMapLayerType::RasterLayer:
{
QgsRasterLayerProperties *rasterLayerPropertiesDialog = new QgsRasterLayerProperties( mapLayer, mMapCanvas, this );

for ( QgsMapLayerConfigWidgetFactory *factory : qgis::as_const( mMapLayerPanelFactories ) )
{
rasterLayerPropertiesDialog->addPropertiesPageFactory( factory );
}

if ( !page.isEmpty() )
rasterLayerPropertiesDialog->setCurrentPage( page );

@@ -63,6 +63,7 @@
#include "qgsproviderregistry.h"
#include "qgsrasterlayertemporalproperties.h"
#include "qgsdoublevalidator.h"
#include "qgsmaplayerconfigwidgetfactory.h"

#include "qgsrasterlayertemporalpropertieswidget.h"
#include "qgsprojecttimesettings.h"
@@ -545,6 +546,23 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
mOptsPage_Server->setProperty( "helpPage", QStringLiteral( "working_with_raster/raster_properties.html#server-properties" ) );
}

void QgsRasterLayerProperties::addPropertiesPageFactory( QgsMapLayerConfigWidgetFactory *factory )
{
if ( !factory->supportsLayer( mRasterLayer ) || !factory->supportLayerPropertiesDialog() )
{
return;
}

QgsMapLayerConfigWidget *page = factory->createWidget( mRasterLayer, nullptr, false, this );
mLayerPropertiesPages << page;

const QString beforePage = factory->layerPropertiesPagePositionHint();
if ( beforePage.isEmpty() )
addPage( factory->title(), factory->title(), factory->icon(), page );
else
insertPage( factory->title(), factory->title(), factory->icon(), page, beforePage );
}

void QgsRasterLayerProperties::setupTransparencyTable( int nBands )
{
tableTransparency->clear();
@@ -930,6 +948,13 @@ void QgsRasterLayerProperties::sync()
mLegendConfigEmbeddedWidget->setLayer( mRasterLayer );

mTemporalWidget->syncToLayer();

const auto constMLayerPropertiesPages = mLayerPropertiesPages;
for ( QgsMapLayerConfigWidget *page : constMLayerPropertiesPages )
{
page->syncToLayer( mRasterLayer );
}

}

void QgsRasterLayerProperties::apply()
@@ -41,6 +41,8 @@ class QgsRasterHistogramWidget;
class QgsRasterLayerTemporalPropertiesWidget;
class QgsWebView;
class QgsProviderSourceWidget;
class QgsMapLayerConfigWidgetFactory;
class QgsMapLayerConfigWidget;


/**
@@ -77,6 +79,9 @@ class GUI_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
*/
QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent = nullptr, Qt::WindowFlags = QgsGuiUtils::ModalDialogFlags );

//! Adds a properties page factory to the raster layer properties dialog.
void addPropertiesPageFactory( QgsMapLayerConfigWidgetFactory *factory );

protected slots:
//! \brief auto slot executed when the active page in the main widget stack is changed
void optionsStackedWidget_CurrentChanged( int index ) override SIP_SKIP ;
@@ -191,6 +196,9 @@ class GUI_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
QAction *mActionLoadMetadata = nullptr;
QAction *mActionSaveMetadataAs = nullptr;

//! A list of additional pages provided by plugins
QList<QgsMapLayerConfigWidget *> mLayerPropertiesPages;

//! \brief A constant that signals property not used
const QString TRSTRING_NOT_SET;

0 comments on commit a388376

Please sign in to comment.