Skip to content

Commit

Permalink
Show style name in layer properties dialog title
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Dec 18, 2017
1 parent 10b37f3 commit 944b587
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/core/qgsmaplayerstylemanager.sip
Expand Up @@ -195,6 +195,14 @@ Each call must be paired with restoreOverrideStyle()
Restore the original store after a call to setOverrideStyle()
%End

bool isDefault( const QString &styleName ) const;
%Docstring
Returns true if this is the default style

.. versionadded:: 3.0
:rtype: bool
%End

signals:
void styleAdded( const QString &name );
%Docstring
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -347,6 +347,8 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
}

QString title = QString( tr( "Layer Properties - %1" ) ).arg( mLayer->name() );
if ( !mLayer->styleManager()->isDefault( mLayer->styleManager()->currentStyle() ) )
title += QStringLiteral( " (%1)" ).arg( mLayer->styleManager()->currentStyle() );
restoreOptionsBaseUi( title );

mLayersDependenciesTreeGroup.reset( QgsProject::instance()->layerTreeRoot()->clone() );
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsmaplayerstylemanager.cpp
Expand Up @@ -224,6 +224,11 @@ bool QgsMapLayerStyleManager::restoreOverrideStyle()
return true;
}

bool QgsMapLayerStyleManager::isDefault( const QString &styleName ) const
{
return styleName == defaultStyleName();
}


// -----

Expand Down
7 changes: 7 additions & 0 deletions src/core/qgsmaplayerstylemanager.h
Expand Up @@ -165,6 +165,13 @@ class CORE_EXPORT QgsMapLayerStyleManager : public QObject
//! Restore the original store after a call to setOverrideStyle()
bool restoreOverrideStyle();

/**
* Returns true if this is the default style
*
* \since QGIS 3.0
*/
bool isDefault( const QString &styleName ) const;

signals:
//! Emitted when a new style has been added
void styleAdded( const QString &name );
Expand Down

0 comments on commit 944b587

Please sign in to comment.