From 02af5d80b603322fe3539e8e6629ae5d719c9dbb Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 16 Feb 2016 21:06:44 +0100 Subject: [PATCH] Themes: Enable UI recoloring for flat themes Change-Id: I1907c42a769124b7505bd7afaf6c4da910f3f407 Reviewed-by: Tobias Hunger --- share/qtcreator/themes/dark.creatortheme | 8 ++++---- src/libs/utils/stylehelper.cpp | 5 +++++ src/libs/utils/stylehelper.h | 1 + src/plugins/coreplugin/fancyactionbar.cpp | 4 +++- src/plugins/coreplugin/fancytabwidget.cpp | 15 +++++++-------- src/plugins/coreplugin/manhattanstyle.cpp | 12 +++++++++--- 6 files changed, 29 insertions(+), 16 deletions(-) diff --git a/share/qtcreator/themes/dark.creatortheme b/share/qtcreator/themes/dark.creatortheme index bc0e02b0bdd..e430089bb8b 100644 --- a/share/qtcreator/themes/dark.creatortheme +++ b/share/qtcreator/themes/dark.creatortheme @@ -6,9 +6,9 @@ DefaultTextEditorColorScheme=dark.xml [Palette] shadowBackground=ff232323 text=ffe7e7e7 -textDisabled=ff909090 -hoverBackground=ff515151 -selectedBackground=ff151515 +textDisabled=7fffffff +hoverBackground=35ffffff +selectedBackground=66000000 normalBackground=ff333333 alternateBackground=ff515151 error=ffff0000 @@ -19,7 +19,7 @@ BackgroundColorDark=shadowBackground BackgroundColorHover=hoverBackground BackgroundColorNormal=normalBackground BackgroundColorDisabled=ff444444 -BackgroundColorSelected=ff909090 +BackgroundColorSelected=7effffff BadgeLabelBackgroundColorChecked=normalBackground BadgeLabelBackgroundColorUnchecked=selectedBackground BadgeLabelTextColorChecked=text diff --git a/src/libs/utils/stylehelper.cpp b/src/libs/utils/stylehelper.cpp index c0f201c794e..9431cbe18d8 100644 --- a/src/libs/utils/stylehelper.cpp +++ b/src/libs/utils/stylehelper.cpp @@ -108,6 +108,11 @@ QColor StyleHelper::baseColor(bool lightColored) return m_baseColor.lighter(230); } +bool StyleHelper::isBaseColorDefault() +{ + return m_requestedBaseColor == DEFAULT_BASE_COLOR; +} + QColor StyleHelper::highlightColor(bool lightColored) { QColor result = baseColor(lightColored); diff --git a/src/libs/utils/stylehelper.h b/src/libs/utils/stylehelper.h index 7e483c43f1d..5ac91df433e 100644 --- a/src/libs/utils/stylehelper.h +++ b/src/libs/utils/stylehelper.h @@ -56,6 +56,7 @@ public: // This is our color table, all colors derive from baseColor static QColor requestedBaseColor() { return m_requestedBaseColor; } static QColor baseColor(bool lightColored = false); + static bool isBaseColorDefault(); static QColor panelTextColor(bool lightColored = false); static QColor highlightColor(bool lightColored = false); static QColor shadowColor(bool lightColored = false); diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp index 8b641a4991d..c6ffccefb6f 100644 --- a/src/plugins/coreplugin/fancyactionbar.cpp +++ b/src/plugins/coreplugin/fancyactionbar.cpp @@ -272,7 +272,9 @@ 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(), creatorTheme()->color(Theme::FancyTabBarBackgroundColor)); + painter.fillRect(event->rect(), StyleHelper::isBaseColorDefault() + ? creatorTheme()->color(Theme::FancyTabBarBackgroundColor) + : StyleHelper::baseColor()); } QColor light = StyleHelper::sidebarHighlight(); diff --git a/src/plugins/coreplugin/fancytabwidget.cpp b/src/plugins/coreplugin/fancytabwidget.cpp index 75b8e69adb8..7efcaf64d2b 100644 --- a/src/plugins/coreplugin/fancytabwidget.cpp +++ b/src/plugins/coreplugin/fancytabwidget.cpp @@ -119,7 +119,9 @@ 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(), creatorTheme()->color(Theme::FancyTabBarBackgroundColor)); + p.fillRect(event->rect(), StyleHelper::isBaseColorDefault() + ? creatorTheme()->color(Theme::FancyTabBarBackgroundColor) + : StyleHelper::baseColor()); } for (int i = 0; i < count(); ++i) @@ -320,14 +322,11 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const const float fader = m_tabs[tabIndex]->fader(); if (fader > 0 && !HostOsInfo::isMacHost() && !selected && enabled) { painter->save(); - if (creatorTheme()->widgetStyle() == Theme::StyleFlat) { - QColor c = creatorTheme()->color(Theme::BackgroundColorHover); - c.setAlpha(255 * fader); - painter->fillRect(rect, c); - } else { - painter->setOpacity(fader); + painter->setOpacity(fader); + if (creatorTheme()->widgetStyle() == Theme::StyleFlat) + painter->fillRect(rect, creatorTheme()->color(Theme::BackgroundColorHover)); + else FancyToolButton::hoverOverlay(painter, rect); - } painter->restore(); } diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index aaf842247f6..83d821985ae 100644 --- a/src/plugins/coreplugin/manhattanstyle.cpp +++ b/src/plugins/coreplugin/manhattanstyle.cpp @@ -664,7 +664,9 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt const bool dis = !(mbi->state & State_Enabled); if (creatorTheme()->widgetStyle() == Theme::StyleFlat) - painter->fillRect(option->rect, creatorTheme()->color(Theme::MenuBarItemBackgroundColor)); + painter->fillRect(option->rect, StyleHelper::isBaseColorDefault() + ? creatorTheme()->color(Theme::MenuBarItemBackgroundColor) + : StyleHelper::baseColor()); else StyleHelper::menuGradient(painter, option->rect, option->rect); @@ -802,7 +804,9 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt option->rect.bottomRight() + QPointF(0.5, 0.5)); painter->restore(); } else { - painter->fillRect(option->rect, creatorTheme()->color(Theme::MenuBarEmptyAreaBackgroundColor)); + painter->fillRect(option->rect, StyleHelper::isBaseColorDefault() + ? creatorTheme()->color(Theme::MenuBarEmptyAreaBackgroundColor) + : StyleHelper::baseColor()); } } break; @@ -824,7 +828,9 @@ 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, creatorTheme()->color(Theme::ToolBarBackgroundColor)); + painter->fillRect(rect, StyleHelper::isBaseColorDefault() + ? creatorTheme()->color(Theme::ToolBarBackgroundColor) + : StyleHelper::baseColor(drawLightColored)); else if (horizontal) StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored); else