Skip to content

Commit

Permalink
Don't hard-code black and gray for layer tree items' text color
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Feb 11, 2019
1 parent f8f701c commit 4be150c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Expand Up @@ -304,7 +304,7 @@ Gets map of map layer style overrides (key: layer ID, value: style name) where a

void setLayerStyleOverrides( const QMap<QString, QString> &overrides );
%Docstring
Set map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one
Sets map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one

.. versionadded:: 2.10
%End
Expand Down
6 changes: 4 additions & 2 deletions src/core/layertree/qgslayertreemodel.cpp
Expand Up @@ -277,13 +277,15 @@ QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const
}
else if ( role == Qt::ForegroundRole )
{
QBrush brush( Qt::black, Qt::SolidPattern );
QBrush brush( qApp->palette().color( QPalette::Text ), Qt::SolidPattern );
if ( QgsLayerTree::isLayer( node ) )
{
const QgsMapLayer *layer = QgsLayerTree::toLayer( node )->layer();
if ( ( !node->isVisible() && ( !layer || layer->isSpatial() ) ) || ( layer && !layer->isInScaleRange( mLegendMapViewScale ) ) )
{
brush.setColor( Qt::gray );
QColor fadedTextColor = brush.color();
fadedTextColor.setAlpha( 66 );
brush.setColor( fadedTextColor );
}
}
return brush;
Expand Down
2 changes: 1 addition & 1 deletion src/core/layertree/qgslayertreemodel.h
Expand Up @@ -269,7 +269,7 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
QMap<QString, QString> layerStyleOverrides() const;

/**
* Set map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one
* Sets map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one
* \since QGIS 2.10
*/
void setLayerStyleOverrides( const QMap<QString, QString> &overrides );
Expand Down

0 comments on commit 4be150c

Please sign in to comment.