Skip to content
Permalink
Browse files

Move raster temporal properties to new tab, fix inconsistent margins

in all raster layer properties pages, and make clicking the temporal
indicator icon go straight to the layer's temporal property page
  • Loading branch information
nyalldawson committed Mar 13, 2020
1 parent 91c70fa commit 059e29328f7b7481c7b6cd05608a6cbf6377245d
@@ -34,6 +34,13 @@ Constructor
:param canvas: the QgsMapCanvas instance
:param parent: the parent of this widget
:param fl: windows flag
%End

void setCurrentPage( const QString &page );
%Docstring
Sets the dialog ``page`` (by object name) to show.

.. versionadded:: 3.14
%End

protected slots:
}
}

void QgisApp::showLayerProperties( QgsMapLayer *mapLayer )
void QgisApp::showLayerProperties( QgsMapLayer *mapLayer, const QString &page )
{
/*
TODO: Consider reusing the property dialogs again.
case QgsMapLayerType::RasterLayer:
{
QgsRasterLayerProperties *rasterLayerPropertiesDialog = new QgsRasterLayerProperties( mapLayer, mMapCanvas, this );
if ( !page.isEmpty() )
rasterLayerPropertiesDialog->setCurrentPage( page );

// Cannot use exec here due to raster transparency map tool:
// in order to pass focus to the canvas, the dialog needs to
// be hidden and shown in non-modal mode.
@@ -633,7 +633,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsLocatorWidget *locatorWidget() { return mLocatorWidget; }

//! show layer properties
void showLayerProperties( QgsMapLayer *mapLayer );
void showLayerProperties( QgsMapLayer *mapLayer, const QString &page = QString() );

//! returns pointer to map legend
QgsLayerTreeView *layerTreeView();
@@ -21,6 +21,7 @@
#include "qgslayertreemodel.h"
#include "qgslayertreeutils.h"
#include "qgsrasterlayer.h"
#include "qgsrasterlayerproperties.h"
#include "qgisapp.h"

QgsLayerTreeViewTemporalIndicatorProvider::QgsLayerTreeViewTemporalIndicatorProvider( QgsLayerTreeView *view )
@@ -49,7 +50,7 @@ void QgsLayerTreeViewTemporalIndicatorProvider::onIndicatorClicked( const QModel
switch ( layer->type() )
{
case QgsMapLayerType::RasterLayer:
QgisApp::instance()->showLayerProperties( qobject_cast<QgsRasterLayer *>( layer ) );
QgisApp::instance()->showLayerProperties( qobject_cast<QgsRasterLayer *>( layer ), QStringLiteral( "mOptsPage_Temporal" ) );
break;

case QgsMapLayerType::VectorLayer:
@@ -266,13 +266,13 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
QVBoxLayout *layout = new QVBoxLayout( metadataFrame );
layout->setMargin( 0 );
mMetadataWidget = new QgsMetadataWidget( this, mRasterLayer );
mMetadataWidget->layout()->setContentsMargins( -1, 0, -1, 0 );
mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
mMetadataWidget->setMapCanvas( mMapCanvas );
layout->addWidget( mMetadataWidget );
metadataFrame->setLayout( layout );

QVBoxLayout *temporalLayout = new QVBoxLayout( temporalFrame );
temporalLayout->setContentsMargins( -1, 0, -1, 0 );
temporalLayout->setContentsMargins( 0, 0, 0, 0 );
mTemporalWidget = new QgsRasterLayerTemporalPropertiesWidget( this, mRasterLayer );
temporalLayout->addWidget( mTemporalWidget );

@@ -491,6 +491,21 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
optionsStackedWidget_CurrentChanged( mOptionsStackedWidget->currentIndex() );
}

void QgsRasterLayerProperties::setCurrentPage( const QString &page )
{
//find the page with a matching widget name
for ( int idx = 0; idx < mOptionsStackedWidget->count(); ++idx )
{
QWidget *currentPage = mOptionsStackedWidget->widget( idx );
if ( currentPage->objectName() == page )
{
//found the page, set it as current
mOptionsStackedWidget->setCurrentIndex( idx );
return;
}
}
}

void QgsRasterLayerProperties::setupTransparencyTable( int nBands )
{
tableTransparency->clear();
@@ -75,6 +75,13 @@ class GUI_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
*/
QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent = nullptr, Qt::WindowFlags = QgsGuiUtils::ModalDialogFlags );

/**
* Sets the dialog \a page (by object name) to show.
*
* \since QGIS 3.14
*/
void setCurrentPage( const QString &page );

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 ;

0 comments on commit 059e293

Please sign in to comment.
You can’t perform that action at this time.