accountsettings: Use right palette when using reversed palette

Issue #2654

The problem is that the WindowsVistaStyle does something wierd with the palette
when drawing the text, and we should do the same then.
This commit is contained in:
Olivier Goffart 2015-01-05 12:17:05 +01:00
parent 225e6c6b9f
commit 517dea6958

View file

@ -186,13 +186,26 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
painter->drawPixmap(QPoint(warnRect.left(), warnRect.top()),pm );
}
if ((option.state & QStyle::State_Selected)
&& (option.state & QStyle::State_Active)
auto palette = option.palette;
if (qApp->style()->inherits("QWindowsVistaStyle")) {
// Hack: Windows Vista's light blue is not contrasting enough for white
&& !qApp->style()->inherits("QWindowsVistaStyle")) {
painter->setPen(option.palette.color(QPalette::HighlightedText));
// (code from QWindowsVistaStyle::drawControl for CE_ItemViewItem)
palette.setColor(QPalette::All, QPalette::HighlightedText, palette.color(QPalette::Active, QPalette::Text));
palette.setColor(QPalette::All, QPalette::Highlight, palette.base().color().darker(108));
}
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
? QPalette::Normal : QPalette::Disabled;
if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
cg = QPalette::Inactive;
if (option.state & QStyle::State_Selected) {
painter->setPen(palette.color(cg, QPalette::HighlightedText));
} else {
painter->setPen(option.palette.color(QPalette::Text));
painter->setPen(palette.color(cg, QPalette::Text));
}
QString elidedAlias = aliasFm.elidedText(aliasText, Qt::ElideRight, aliasRect.width());
painter->setFont(aliasFont);
@ -272,7 +285,7 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
pBarOpt.maximum = 100;
pBarOpt.progress = overallPercent;
pBarOpt.orientation = Qt::Horizontal;
pBarOpt.palette = option.palette;
pBarOpt.palette = palette;
pBarOpt.rect = pBRect;
QApplication::style()->drawControl( QStyle::CE_ProgressBar, &pBarOpt, painter );