Skip to content

Commit 944b587

Browse files
committedDec 18, 2017
Show style name in layer properties dialog title
1 parent 10b37f3 commit 944b587

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed
 

‎python/core/qgsmaplayerstylemanager.sip

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ Each call must be paired with restoreOverrideStyle()
195195
Restore the original store after a call to setOverrideStyle()
196196
%End
197197

198+
bool isDefault( const QString &styleName ) const;
199+
%Docstring
200+
Returns true if this is the default style
201+
202+
.. versionadded:: 3.0
203+
:rtype: bool
204+
%End
205+
198206
signals:
199207
void styleAdded( const QString &name );
200208
%Docstring

‎src/app/qgsvectorlayerproperties.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
347347
}
348348

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

352354
mLayersDependenciesTreeGroup.reset( QgsProject::instance()->layerTreeRoot()->clone() );

‎src/core/qgsmaplayerstylemanager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ bool QgsMapLayerStyleManager::restoreOverrideStyle()
224224
return true;
225225
}
226226

227+
bool QgsMapLayerStyleManager::isDefault( const QString &styleName ) const
228+
{
229+
return styleName == defaultStyleName();
230+
}
231+
227232

228233
// -----
229234

‎src/core/qgsmaplayerstylemanager.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ class CORE_EXPORT QgsMapLayerStyleManager : public QObject
165165
//! Restore the original store after a call to setOverrideStyle()
166166
bool restoreOverrideStyle();
167167

168+
/**
169+
* Returns true if this is the default style
170+
*
171+
* \since QGIS 3.0
172+
*/
173+
bool isDefault( const QString &styleName ) const;
174+
168175
signals:
169176
//! Emitted when a new style has been added
170177
void styleAdded( const QString &name );

0 commit comments

Comments
 (0)
Please sign in to comment.