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 ); painter->drawPixmap(QPoint(warnRect.left(), warnRect.top()),pm );
} }
if ((option.state & QStyle::State_Selected) auto palette = option.palette;
&& (option.state & QStyle::State_Active)
if (qApp->style()->inherits("QWindowsVistaStyle")) {
// Hack: Windows Vista's light blue is not contrasting enough for white // 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 { } else {
painter->setPen(option.palette.color(QPalette::Text)); painter->setPen(palette.color(cg, QPalette::Text));
} }
QString elidedAlias = aliasFm.elidedText(aliasText, Qt::ElideRight, aliasRect.width()); QString elidedAlias = aliasFm.elidedText(aliasText, Qt::ElideRight, aliasRect.width());
painter->setFont(aliasFont); painter->setFont(aliasFont);
@ -272,7 +285,7 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
pBarOpt.maximum = 100; pBarOpt.maximum = 100;
pBarOpt.progress = overallPercent; pBarOpt.progress = overallPercent;
pBarOpt.orientation = Qt::Horizontal; pBarOpt.orientation = Qt::Horizontal;
pBarOpt.palette = option.palette; pBarOpt.palette = palette;
pBarOpt.rect = pBRect; pBarOpt.rect = pBRect;
QApplication::style()->drawControl( QStyle::CE_ProgressBar, &pBarOpt, painter ); QApplication::style()->drawControl( QStyle::CE_ProgressBar, &pBarOpt, painter );