Skip to content

Commit

Permalink
Merge pull request #42681 from suricactus/layer_props_page
Browse files Browse the repository at this point in the history
Open a specific page in the layer properties dialog using the iface instance
  • Loading branch information
m-kuhn committed Apr 8, 2021
2 parents b057ad5 + 2788303 commit 3cf8a98
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 7 deletions.
37 changes: 35 additions & 2 deletions python/gui/auto_generated/qgisinterface.sip.in
Expand Up @@ -1138,9 +1138,42 @@ Removes the specified ``dock`` widget from main window (without deleting it).
.. seealso:: :py:func:`addDockWidget`
%End

virtual void showLayerProperties( QgsMapLayer *l ) = 0;
virtual void showLayerProperties( QgsMapLayer *l, const QString &page = QString() ) = 0;
%Docstring
Open layer properties dialog
Opens layer properties dialog for the layer ``l``.
Optionally, a ``page`` to open can be specified (since QGIS 3.20).
The list below contains valid page names:

Vector Layer:
mOptsPage_Information, mOptsPage_Source, mOptsPage_Style, mOptsPage_Labels,
mOptsPage_Masks, mOptsPage_Diagrams, mOptsPage_SourceFields, mOptsPage_AttributesForm,
mOptsPage_Joins, mOptsPage_AuxiliaryStorage, mOptsPage_Actions, mOptsPage_Display,
mOptsPage_Rendering, mOptsPage_Temporal, mOptsPage_Variables, mOptsPage_Metadata,
mOptsPage_DataDependencies, mOptsPage_Legend, mOptsPage_Server

Raster Layer:
mOptsPage_Information, mOptsPage_Source, mOptsPage_Style, mOptsPage_Transparency,
mOptsPage_Histogram, mOptsPage_Rendering, mOptsPage_Temporal, mOptsPage_Pyramids,
mOptsPage_Metadata, mOptsPage_Legend, mOptsPage_Server

Mesh Layer:
mOptsPage_Information, mOptsPage_Source, mOptsPage_Style, mOptsPage_StyleContent,
mOptsPage_Rendering, mOptsPage_Temporal, mOptsPage_Metadata

Point Cloud Layer:
mOptsPage_Information, mOptsPage_Source, mOptsPage_Metadata, mOptsPage_Statistics

Vector Tile Layer:
mOptsPage_Information, mOptsPage_Style, mOptsPage_Labeling, mOptsPage_Metadata

.. note::

Page names are subject to change without notice between QGIS versions,
they are not considered part of the stable API.

.. note::

More strings may be available depending on the context, e.g. via plugins.
%End

virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgisappinterface.cpp
Expand Up @@ -497,11 +497,11 @@ QgsAdvancedDigitizingDockWidget *QgisAppInterface::cadDockWidget()
return qgis->cadDockWidget();
}

void QgisAppInterface::showLayerProperties( QgsMapLayer *l )
void QgisAppInterface::showLayerProperties( QgsMapLayer *l, const QString &page )
{
if ( l && qgis )
{
qgis->showLayerProperties( l );
qgis->showLayerProperties( l, page );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappinterface.h
Expand Up @@ -137,7 +137,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
void addTabifiedDockWidget( Qt::DockWidgetArea area, QDockWidget *dockwidget, const QStringList &tabifyWith = QStringList(), bool raiseTab = false ) override;
void removeDockWidget( QDockWidget *dockwidget ) override;
QgsAdvancedDigitizingDockWidget *cadDockWidget() override;
void showLayerProperties( QgsMapLayer *l ) override;
void showLayerProperties( QgsMapLayer *l, const QString &page = QString() ) override;
QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) override;
void addWindow( QAction *action ) override;
void removeWindow( QAction *action ) override;
Expand Down
35 changes: 33 additions & 2 deletions src/gui/qgisinterface.h
Expand Up @@ -971,8 +971,39 @@ class GUI_EXPORT QgisInterface : public QObject
*/
virtual void removeDockWidget( QDockWidget *dockwidget ) = 0;

//! Open layer properties dialog
virtual void showLayerProperties( QgsMapLayer *l ) = 0;
/**
* Opens layer properties dialog for the layer \a l.
* Optionally, a \a page to open can be specified (since QGIS 3.20).
* The list below contains valid page names:
*
* Vector Layer:
* mOptsPage_Information, mOptsPage_Source, mOptsPage_Style, mOptsPage_Labels,
* mOptsPage_Masks, mOptsPage_Diagrams, mOptsPage_SourceFields, mOptsPage_AttributesForm,
* mOptsPage_Joins, mOptsPage_AuxiliaryStorage, mOptsPage_Actions, mOptsPage_Display,
* mOptsPage_Rendering, mOptsPage_Temporal, mOptsPage_Variables, mOptsPage_Metadata,
* mOptsPage_DataDependencies, mOptsPage_Legend, mOptsPage_Server
*
* Raster Layer:
* mOptsPage_Information, mOptsPage_Source, mOptsPage_Style, mOptsPage_Transparency,
* mOptsPage_Histogram, mOptsPage_Rendering, mOptsPage_Temporal, mOptsPage_Pyramids,
* mOptsPage_Metadata, mOptsPage_Legend, mOptsPage_Server
*
* Mesh Layer:
* mOptsPage_Information, mOptsPage_Source, mOptsPage_Style, mOptsPage_StyleContent,
* mOptsPage_Rendering, mOptsPage_Temporal, mOptsPage_Metadata
*
* Point Cloud Layer:
* mOptsPage_Information, mOptsPage_Source, mOptsPage_Metadata, mOptsPage_Statistics
*
* Vector Tile Layer:
* mOptsPage_Information, mOptsPage_Style, mOptsPage_Labeling, mOptsPage_Metadata
*
* \note Page names are subject to change without notice between QGIS versions,
* they are not considered part of the stable API.
*
* \note More strings may be available depending on the context, e.g. via plugins.
*/
virtual void showLayerProperties( QgsMapLayer *l, const QString &page = QString() ) = 0;

//! Open attribute table dialog
virtual QDialog *showAttributeTable( QgsVectorLayer *l, const QString &filterExpression = QString() ) = 0;
Expand Down

0 comments on commit 3cf8a98

Please sign in to comment.