Core: Improved theme-awareness in application menu painting

Using theme colors rather than hard-coded ones and at the same some
simplification.

This is needed for an upcoming "Flat Light" theme.

Change-Id: I8a8715a16d1b246c5228978633143eb64d371701
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Alessandro Portale
2016-06-17 19:00:59 +02:00
committed by Alessandro Portale
parent 6750607244
commit 3b30617758
3 changed files with 20 additions and 13 deletions

View File

@@ -677,24 +677,18 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
if (act) {
// Fill|
if (creatorTheme()->flag(Theme::FlatMenuBar)) {
painter->fillRect(option->rect, creatorTheme()->color(Theme::FancyToolButtonHoverColor));
} else {
QColor baseColor = StyleHelper::baseColor();
QLinearGradient grad(option->rect.topLeft(), option->rect.bottomLeft());
grad.setColorAt(0, baseColor.lighter(120));
grad.setColorAt(1, baseColor.lighter(130));
painter->fillRect(option->rect, grad);
}
const QColor fillColor = StyleHelper::alphaBlendedColors(
StyleHelper::baseColor(), creatorTheme()->color(Theme::FancyToolButtonHoverColor));
painter->fillRect(option->rect, fillColor);
QPalette pal = mbi->palette;
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
if (!styleHint(SH_UnderlineShortcut, mbi, widget))
alignment |= Qt::TextHideMnemonic;
pal.setBrush(QPalette::Text, dis ? Qt::gray : QColor(0, 0, 0, 60));
drawItemText(painter, item.rect.translated(0, 1), alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text);
pal.setBrush(QPalette::Text, dis ? Qt::gray : Qt::white);
drawItemText(painter, item.rect, alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text);
pal.setBrush(QPalette::Text, creatorTheme()->color(dis
? Theme::IconsDisabledColor
: Theme::PanelTextColorLight));
drawItemText(painter, item.rect, alignment, pal, !dis, mbi->text, QPalette::Text);
}
}
painter->restore();