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 Dec 21, 2018
1 parent 657f5a4 commit 9200f53
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,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
Original file line number Diff line number Diff line change
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 9200f53

Please sign in to comment.