Skip to content

Commit

Permalink
[themes] Avoid hardcoded black for default console timestamp colors
Browse files Browse the repository at this point in the history
(fixes #21860)
  • Loading branch information
nirvn committed Apr 17, 2019
1 parent 62a5bc4 commit 2ee051c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/gui/qgsmessagelogviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,33 @@ void QgsMessageLogViewer::logMessage( const QString &message, const QString &tag

QString levelString;
QgsSettings settings;
QColor color;
QPalette pal = qApp->palette();
QString defaultColorName = pal.color( QPalette::WindowText ).name();
QString colorName;
switch ( level )
{
case Qgis::Info:
levelString = QStringLiteral( "INFO" );
color = QColor( settings.value( QStringLiteral( "colors/info" ), QStringLiteral( "#000000" ) ).toString() );
colorName = settings.value( QStringLiteral( "colors/info" ), QString() ).toString();
break;
case Qgis::Warning:
levelString = QStringLiteral( "WARNING" );
color = QColor( settings.value( QStringLiteral( "colors/warning" ), QStringLiteral( "#000000" ) ).toString() );
colorName = settings.value( QStringLiteral( "colors/warning" ), QString() ).toString();
break;
case Qgis::Critical:
levelString = QStringLiteral( "CRITICAL" );
color = QColor( settings.value( QStringLiteral( "colors/critical" ), QStringLiteral( "#000000" ) ).toString() );
colorName = settings.value( QStringLiteral( "colors/critical" ), QString() ).toString();
break;
case Qgis::Success:
levelString = QStringLiteral( "SUCCESS" );
color = QColor( settings.value( QStringLiteral( "colors/success" ), QStringLiteral( "#000000" ) ).toString() );
colorName = settings.value( QStringLiteral( "colors/success" ), QString() ).toString();
break;
case Qgis::None:
levelString = QStringLiteral( "NONE" );
color = QColor( settings.value( QStringLiteral( "colors/default" ), QStringLiteral( "#000000" ) ).toString() );
colorName = settings.value( QStringLiteral( "colors/default" ), QString() ).toString();
break;
}
QColor color = QColor( !colorName.isEmpty() ? colorName : defaultColorName );

QString prefix = QStringLiteral( "<font color=\"%1\">%2 &nbsp;&nbsp;&nbsp; %3 &nbsp;&nbsp;&nbsp;</font>" )
.arg( color.name(), QDateTime::currentDateTime().toString( Qt::ISODate ), levelString );
Expand Down

0 comments on commit 2ee051c

Please sign in to comment.