Skip to content

Commit

Permalink
Move raster temporal properties to new tab, fix inconsistent margins
Browse files Browse the repository at this point in the history
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 059e293
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 41 deletions.
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -14797,7 +14797,7 @@ void QgisApp::readProject( const QDomDocument &doc )
}
}

void QgisApp::showLayerProperties( QgsMapLayer *mapLayer )
void QgisApp::showLayerProperties( QgsMapLayer *mapLayer, const QString &page )
{
/*
TODO: Consider reusing the property dialogs again.
Expand All @@ -14821,6 +14821,9 @@ void QgisApp::showLayerProperties( QgsMapLayer *mapLayer )
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.
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.h
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgslayertreeviewtemporalindicator.cpp
Expand Up @@ -21,6 +21,7 @@
#include "qgslayertreemodel.h"
#include "qgslayertreeutils.h"
#include "qgsrasterlayer.h"
#include "qgsrasterlayerproperties.h"
#include "qgisapp.h"

QgsLayerTreeViewTemporalIndicatorProvider::QgsLayerTreeViewTemporalIndicatorProvider( QgsLayerTreeView *view )
Expand Down Expand Up @@ -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:
Expand Down
19 changes: 17 additions & 2 deletions src/gui/raster/qgsrasterlayerproperties.cpp
Expand Up @@ -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 );

Expand Down Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions src/gui/raster/qgsrasterlayerproperties.h
Expand Up @@ -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 ;
Expand Down

0 comments on commit 059e293

Please sign in to comment.