Utils: Improved handling of StyleHelper::baseColor

This change makes sure that the "UI coloring" feature respects the
original brightness of the current theme. It prevents dark themes from
getting a too light recoloring and vice versa.

Extra benefit: this allows to remove much recently introduced code.

Change-Id: Ib2c96e7ed172a4cc97520aa4b5d180cc6353c661
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
Alessandro Portale
2016-03-21 12:48:06 +01:00
parent 2baa1f8b77
commit ddde4bdd27
7 changed files with 22 additions and 31 deletions

View File

@@ -272,9 +272,7 @@ void FancyActionBar::paintEvent(QPaintEvent *event)
if (creatorTheme()->widgetStyle () == Theme::StyleFlat) {
// this paints the background of the bottom portion of the
// left tab bar
painter.fillRect(event->rect(), StyleHelper::isBaseColorDefault()
? creatorTheme()->color(Theme::FancyTabBarBackgroundColor)
: StyleHelper::baseColor());
painter.fillRect(event->rect(), StyleHelper::baseColor());
painter.setPen(creatorTheme()->color(Theme::FancyToolBarSeparatorColor));
painter.drawLine(borderRect.topLeft(), borderRect.topRight());
} else {

View File

@@ -118,9 +118,7 @@ void FancyTabBar::paintEvent(QPaintEvent *event)
if (creatorTheme()->widgetStyle() == Theme::StyleFlat) {
// draw background of upper part of left tab widget
// (Welcome, ... Help)
p.fillRect(event->rect(), StyleHelper::isBaseColorDefault()
? creatorTheme()->color(Theme::FancyTabBarBackgroundColor)
: StyleHelper::baseColor());
p.fillRect(event->rect(), StyleHelper::baseColor());
}
for (int i = 0; i < count(); ++i)

View File

@@ -528,9 +528,7 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
painter->drawLine(borderRect.topLeft(), borderRect.topRight());
painter->restore();
} else {
painter->fillRect(rect, StyleHelper::isBaseColorDefault()
? creatorTheme()->color(Theme::PanelStatusBarBackgroundColor)
: StyleHelper::baseColor());
painter->fillRect(rect, StyleHelper::baseColor());
}
}
break;
@@ -653,9 +651,7 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
const bool dis = !(mbi->state & State_Enabled);
if (creatorTheme()->flag(Theme::FlatMenuBar))
painter->fillRect(option->rect, StyleHelper::isBaseColorDefault()
? creatorTheme()->color(Theme::MenuBarItemBackgroundColor)
: StyleHelper::baseColor());
painter->fillRect(option->rect, StyleHelper::baseColor());
else
StyleHelper::menuGradient(painter, option->rect, option->rect);
@@ -793,9 +789,7 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
option->rect.bottomRight() + QPointF(0.5, 0.5));
painter->restore();
} else {
painter->fillRect(option->rect, StyleHelper::isBaseColorDefault()
? creatorTheme()->color(Theme::MenuBarEmptyAreaBackgroundColor)
: StyleHelper::baseColor());
painter->fillRect(option->rect, StyleHelper::baseColor());
}
}
break;
@@ -817,9 +811,7 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
bool drawLightColored = lightColored(widget);
// draws the background of the 'Type hierarchy', 'Projects' headers
if (creatorTheme()->widgetStyle() == Theme::StyleFlat)
painter->fillRect(rect, StyleHelper::isBaseColorDefault()
? creatorTheme()->color(Theme::ToolBarBackgroundColor)
: StyleHelper::baseColor(drawLightColored));
painter->fillRect(rect, StyleHelper::baseColor(drawLightColored));
else if (horizontal)
StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored);
else

View File

@@ -296,9 +296,7 @@ void FutureProgress::paintEvent(QPaintEvent *)
{
QPainter p(this);
if (creatorTheme()->widgetStyle() == Theme::StyleFlat) {
p.fillRect(rect(), StyleHelper::isBaseColorDefault()
? creatorTheme()->color(Theme::FutureProgressBackgroundColor)
: StyleHelper::baseColor());
p.fillRect(rect(), StyleHelper::baseColor());
} else {
QLinearGradient grad = StyleHelper::statusBarGradient(rect());
p.fillRect(rect(), grad);