From a0f1e716c75cb748c462d0cc8d2aec586a08f63c Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 19 Jul 2016 17:27:23 +0200 Subject: [PATCH] Themes: Draw optional toolbar borders We need a new Theme flag for that. And it will initially only be set for the flat light theme. Task-number: QTCREATORBUG-16633 Change-Id: Id723e128364eb6186fe8e28e2087a3698b1bf632 Reviewed-by: Alessandro Portale --- share/qtcreator/themes/dark.creatortheme | 1 + share/qtcreator/themes/default.creatortheme | 1 + share/qtcreator/themes/flat-dark.creatortheme | 1 + share/qtcreator/themes/flat-light.creatortheme | 1 + share/qtcreator/themes/flat.creatortheme | 1 + src/libs/utils/theme/theme.h | 1 + src/plugins/coreplugin/fancytabwidget.cpp | 5 +++-- src/plugins/coreplugin/manhattanstyle.cpp | 17 ++++++++++++++--- 8 files changed, 23 insertions(+), 5 deletions(-) diff --git a/share/qtcreator/themes/dark.creatortheme b/share/qtcreator/themes/dark.creatortheme index cfb41b608bb..14f10164755 100644 --- a/share/qtcreator/themes/dark.creatortheme +++ b/share/qtcreator/themes/dark.creatortheme @@ -184,6 +184,7 @@ DrawIndicatorBranch=true DrawSearchResultWidgetFrame=false DrawTargetSelectorBottom=false DrawToolBarHighlights=true +DrawToolBarBorders=false ApplyThemePaletteGlobally=true FlatToolBars=true FlatSideBarIcons=true diff --git a/share/qtcreator/themes/default.creatortheme b/share/qtcreator/themes/default.creatortheme index ede12f035de..712a9685559 100644 --- a/share/qtcreator/themes/default.creatortheme +++ b/share/qtcreator/themes/default.creatortheme @@ -178,6 +178,7 @@ DrawIndicatorBranch=false DrawSearchResultWidgetFrame=true DrawTargetSelectorBottom=true DrawToolBarHighlights=true +DrawToolBarBorders=false ApplyThemePaletteGlobally=false FlatToolBars=false FlatSideBarIcons=false diff --git a/share/qtcreator/themes/flat-dark.creatortheme b/share/qtcreator/themes/flat-dark.creatortheme index 85577efb6a4..1944ca040b4 100644 --- a/share/qtcreator/themes/flat-dark.creatortheme +++ b/share/qtcreator/themes/flat-dark.creatortheme @@ -189,6 +189,7 @@ DrawIndicatorBranch=true DrawSearchResultWidgetFrame=false DrawTargetSelectorBottom=false DrawToolBarHighlights=false +DrawToolBarBorders=false ApplyThemePaletteGlobally=true FlatToolBars=true FlatSideBarIcons=true diff --git a/share/qtcreator/themes/flat-light.creatortheme b/share/qtcreator/themes/flat-light.creatortheme index 983f909bce7..f9d6c228214 100644 --- a/share/qtcreator/themes/flat-light.creatortheme +++ b/share/qtcreator/themes/flat-light.creatortheme @@ -188,6 +188,7 @@ DrawIndicatorBranch=true DrawSearchResultWidgetFrame=false DrawTargetSelectorBottom=false DrawToolBarHighlights=false +DrawToolBarBorders=true ApplyThemePaletteGlobally=false FlatToolBars=true FlatSideBarIcons=true diff --git a/share/qtcreator/themes/flat.creatortheme b/share/qtcreator/themes/flat.creatortheme index b9bf2c898ad..84850bed9ce 100644 --- a/share/qtcreator/themes/flat.creatortheme +++ b/share/qtcreator/themes/flat.creatortheme @@ -188,6 +188,7 @@ DrawIndicatorBranch=true DrawSearchResultWidgetFrame=false DrawTargetSelectorBottom=false DrawToolBarHighlights=false +DrawToolBarBorders=false ApplyThemePaletteGlobally=false FlatToolBars=true FlatSideBarIcons=true diff --git a/src/libs/utils/theme/theme.h b/src/libs/utils/theme/theme.h index e4a53620489..2c608b2483d 100644 --- a/src/libs/utils/theme/theme.h +++ b/src/libs/utils/theme/theme.h @@ -269,6 +269,7 @@ public: DrawSearchResultWidgetFrame, DrawIndicatorBranch, DrawToolBarHighlights, + DrawToolBarBorders, ComboBoxDrawTextShadow, DerivePaletteFromTheme, ApplyThemePaletteGlobally, diff --git a/src/plugins/coreplugin/fancytabwidget.cpp b/src/plugins/coreplugin/fancytabwidget.cpp index 3c8d4219c82..2da7460bf1f 100644 --- a/src/plugins/coreplugin/fancytabwidget.cpp +++ b/src/plugins/coreplugin/fancytabwidget.cpp @@ -413,9 +413,10 @@ public: { QWidget::paintEvent(event); - // Some Themes do not want highlights and shadows in the toolbars. + // Some Themes do not want highlights, shadows and borders in the toolbars. // But we definitely want a separator between FancyColorButton and FancyTabBar - if (!creatorTheme()->flag(Theme::DrawToolBarHighlights)) { + if (!creatorTheme()->flag(Theme::DrawToolBarHighlights) + && !creatorTheme()->flag(Theme::DrawToolBarBorders)) { QPainter p(this); p.setPen(StyleHelper::borderColor()); const QRectF innerRect = QRectF(rect()).adjusted(0.5, 0.5, -0.5, -0.5); diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index af9c1dc9c37..86540d02d91 100644 --- a/src/plugins/coreplugin/manhattanstyle.cpp +++ b/src/plugins/coreplugin/manhattanstyle.cpp @@ -527,20 +527,24 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption case PE_PanelStatusBar: { + const QRectF borderRect = QRectF(rect).adjusted(0.5, 0.5, -0.5, -0.5); + painter->save(); if (creatorTheme()->flag(Theme::FlatToolBars)) { painter->fillRect(rect, StyleHelper::baseColor()); } else { - painter->save(); QLinearGradient grad = StyleHelper::statusBarGradient(rect); painter->fillRect(rect, grad); - const QRectF borderRect = QRectF(rect).adjusted(0.5, 0.5, -0.5, -0.5); painter->setPen(QColor(255, 255, 255, 60)); painter->drawLine(borderRect.topLeft() + QPointF(0, 1), borderRect.topRight()+ QPointF(0, 1)); painter->setPen(StyleHelper::borderColor().darker(110)); //TODO: make themable painter->drawLine(borderRect.topLeft(), borderRect.topRight()); - painter->restore(); } + if (creatorTheme()->flag(Theme::DrawToolBarBorders)) { + painter->setPen(StyleHelper::borderColor()); + painter->drawLine(borderRect.topLeft(), borderRect.topRight()); + } + painter->restore(); } break; @@ -855,6 +859,13 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt painter->drawLine(borderRect.topRight(), borderRect.bottomRight()); } } + if (creatorTheme()->flag(Theme::DrawToolBarBorders)) { + painter->setPen(StyleHelper::borderColor()); + if (widget && widget->property("topBorder").toBool()) + painter->drawLine(borderRect.topLeft(), borderRect.topRight()); + else + painter->drawLine(borderRect.bottomLeft(), borderRect.bottomRight()); + } } break;