Commit 948f5378 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

CollectionStatisticsDelegate: always set foreground color

In Qt5 the default painter has text color set to black during animations, which
means that expanding the collection tree in KMail temporarily renders the items
in black until the expanding animation is over. To fix this we always fallback
to foreground color from global palette.
parent e939cd0e
......@@ -200,6 +200,7 @@ void CollectionStatisticsDelegate::paint(QPainter *painter,
Q_D(const CollectionStatisticsDelegate);
PainterStateSaver stateSaver(painter);
qDebug() << index.column() << index.flags();
const QColor textColor = index.data(Qt::ForegroundRole).value<QColor>();
// First, paint the basic, but without the text. We remove the text
// in initStyleOption(), which gets called by QStyledItemDelegate::paint().
......@@ -224,6 +225,8 @@ void CollectionStatisticsDelegate::paint(QPainter *painter,
if (option.state & QStyle::State_Selected) {
painter->setPen(textColor.isValid() ? textColor : option.palette.highlightedText().color());
} else {
painter->setPen(textColor.isValid() ? textColor : option.palette.text().color());
}
Collection collection = firstColumn.data(EntityTreeModel::CollectionRole).value<Collection>();
......@@ -300,9 +303,6 @@ void CollectionStatisticsDelegate::paint(QPainter *painter,
QRect unreadRect = textRect;
folderRect.setRight(textRect.left() + folderWidth);
unreadRect = QRect(folderRect.right(), folderRect.top(), unreadRect.width(), unreadRect.height());
if (textColor.isValid()) {
painter->setPen(textColor);
}
// Draw folder name and unread count
painter->drawText(folderRect, Qt::AlignLeft | Qt::AlignVCenter, folderName);
......@@ -344,16 +344,10 @@ void CollectionStatisticsDelegate::paint(QPainter *painter,
//total size
if (index.column() == 3 && !expanded) {
if (textColor.isValid()) {
painter->setPen(textColor);
}
painter->drawText(textRect, option4.displayAlignment | Qt::AlignVCenter, KIO::convertSize((KIO::filesize_t)totalSize));
return;
}
if (textColor.isValid()) {
painter->setPen(textColor);
}
painter->drawText(textRect, option4.displayAlignment | Qt::AlignVCenter, text);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment