From 7e9e103c53fd64272d9d3c153b10c6fd4f2eb213 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 18 Jan 2023 15:23:21 +0100 Subject: [PATCH] Issues: Fix ugly error text when item is selected Trying to make red text work on a various possibility of selection colors is futile. Just use the normal "blended" text color, like for file names that are found, for the selected item. Use the theme defined error color for items that are not selected. Fixes: QTCREATORBUG-27525 Change-Id: I423487fbf8b5333993774ccebcb488ffb156dc0e Reviewed-by: Alessandro Portale --- src/plugins/projectexplorer/taskwindow.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index dca99bf96c2..52e3899d654 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include @@ -940,20 +942,16 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, } } - QColor mix; - mix.setRgb( static_cast(0.7 * textColor.red() + 0.3 * backgroundColor.red()), - static_cast(0.7 * textColor.green() + 0.3 * backgroundColor.green()), - static_cast(0.7 * textColor.blue() + 0.3 * backgroundColor.blue())); - painter->setPen(mix); - + const QColor mix = StyleHelper::mergedColors(textColor, backgroundColor, 70); const QString directory = QDir::toNativeSeparators(index.data(TaskModel::File).toString()); int secondBaseLine = positions.top() + fm.ascent() + height + leading; - if (index.data(TaskModel::FileNotFound).toBool() - && !directory.isEmpty()) { - QString fileNotFound = Tr::tr("File not found: %1").arg(directory); - painter->setPen(Qt::red); + if (index.data(TaskModel::FileNotFound).toBool() && !directory.isEmpty()) { + const QString fileNotFound = Tr::tr("File not found: %1").arg(directory); + const QColor errorColor = selected ? mix : creatorTheme()->color(Theme::TextColorError); + painter->setPen(errorColor); painter->drawText(positions.textAreaLeft(), secondBaseLine, fileNotFound); } else { + painter->setPen(mix); painter->drawText(positions.textAreaLeft(), secondBaseLine, directory); } }