Utils: Replace Theme::widgetStyle with a flag

Theme::widgetStyle with its two possible return values makes less sense
than a bool flag. Especially since we already have several separate
theme flags for ui elements which might be "flat" or not.

Change-Id: Ic521bb58c04386b735b784079de05e521bc1f45f
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Alessandro Portale
2016-06-15 17:41:33 +02:00
committed by Alessandro Portale
parent eeadfbba8c
commit 8588cf268f
17 changed files with 56 additions and 85 deletions

View File

@@ -455,7 +455,13 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
// Fill the line edit background
QRectF backgroundRect = option->rect;
const bool enabled = option->state & State_Enabled;
if (Utils::creatorTheme()->widgetStyle() == Utils::Theme::StyleDefault) {
if (Utils::creatorTheme()->flag(Theme::FlatToolBars)) {
painter->save();
if (!enabled)
painter->setOpacity(0.75);
painter->fillRect(backgroundRect, option->palette.base());
painter->restore();
} else {
backgroundRect.adjust(1, 1, -1, -1);
painter->setBrushOrigin(backgroundRect.topLeft());
painter->fillRect(backgroundRect, option->palette.base());
@@ -467,12 +473,6 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
StyleHelper::drawCornerImage(enabled ? bg : bg_disabled,
painter, option->rect, 5, 5, 5, 5);
} else {
painter->save();
if (!enabled)
painter->setOpacity(0.75);
painter->fillRect(backgroundRect, option->palette.base());
painter->restore();
}
const bool hasFocus = state & State_HasFocus;
@@ -499,7 +499,7 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
if (pressed) {
const QColor shade = creatorTheme()->color(Theme::FancyToolButtonSelectedColor);
painter->fillRect(rect, shade);
if (creatorTheme()->widgetStyle() == Theme::StyleDefault) {
if (!creatorTheme()->flag(Theme::FlatToolBars)) {
const QRectF borderRect = QRectF(rect).adjusted(0.5, 0.5, -0.5, -0.5);
painter->drawLine(borderRect.topLeft() + QPointF(1, 0), borderRect.topRight() - QPointF(1, 0));
painter->drawLine(borderRect.topLeft(), borderRect.bottomLeft());
@@ -527,7 +527,9 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
case PE_PanelStatusBar:
{
if (creatorTheme()->widgetStyle() == Theme::StyleDefault) {
if (creatorTheme()->flag(Theme::FlatToolBars)) {
painter->fillRect(rect, StyleHelper::baseColor());
} else {
painter->save();
QLinearGradient grad = StyleHelper::statusBarGradient(rect);
painter->fillRect(rect, grad);
@@ -538,8 +540,6 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
painter->setPen(StyleHelper::borderColor().darker(110)); //TODO: make themable
painter->drawLine(borderRect.topLeft(), borderRect.topRight());
painter->restore();
} else {
painter->fillRect(rect, StyleHelper::baseColor());
}
}
break;
@@ -819,7 +819,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)
if (creatorTheme()->flag(Theme::FlatToolBars))
painter->fillRect(rect, StyleHelper::baseColor(drawLightColored));
else if (horizontal)
StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored);
@@ -836,9 +836,9 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
// Note: This is a hack to determine if the
// toolbar should draw the top or bottom outline
// (needed for the find toolbar for instance)
const QColor hightLight = creatorTheme()->widgetStyle() == Theme::StyleDefault
? StyleHelper::sidebarHighlight()
: creatorTheme()->color(Theme::FancyToolBarSeparatorColor);
const QColor hightLight = creatorTheme()->flag(Theme::FlatToolBars)
? creatorTheme()->color(Theme::FancyToolBarSeparatorColor)
: StyleHelper::sidebarHighlight();
const QColor borderColor = drawLightColored
? QColor(255, 255, 255, 180) : hightLight;
if (widget && widget->property("topBorder").toBool()) {
@@ -1017,7 +1017,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
void ManhattanStyle::drawButtonSeparator(QPainter *painter, const QRect &rect, bool reverse) const
{
const QRectF borderRect = QRectF(rect).adjusted(0.5, 0.5, -0.5, -0.5);
if (creatorTheme()->widgetStyle() == Theme::StyleFlat) {
if (creatorTheme()->flag(Theme::FlatToolBars)) {
const int margin = 3;
painter->setPen(creatorTheme()->color(Theme::FancyToolBarSeparatorColor));
painter->drawLine(borderRect.topRight() + QPointF(0, margin),