Utils: Make the "shadow" under toolbar icons optional

In preparation od a "Flat Light" theme, where shadows under the icons
would have a negative impact.

Change-Id: I2d9d3563c90336640513c1a970a432898dd63cfc
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
This commit is contained in:
Alessandro Portale
2016-06-17 18:52:24 +02:00
committed by Alessandro Portale
parent 5ff15e89f2
commit abb63602de
6 changed files with 9 additions and 4 deletions

View File

@@ -188,6 +188,7 @@ ApplyThemePaletteGlobally=true
FlatSideBarIcons=true FlatSideBarIcons=true
FlatProjectsMode=true FlatProjectsMode=true
FlatMenuBar=true FlatMenuBar=true
ToolBarIconShadow=true
[Gradients] [Gradients]
DetailsWidgetHeaderGradient\1\color=0 DetailsWidgetHeaderGradient\1\color=0

View File

@@ -182,6 +182,7 @@ ApplyThemePaletteGlobally=false
FlatSideBarIcons=false FlatSideBarIcons=false
FlatProjectsMode=false FlatProjectsMode=false
FlatMenuBar=false FlatMenuBar=false
ToolBarIconShadow=true
[Gradients] [Gradients]
DetailsWidgetHeaderGradient\1\color=ffffff DetailsWidgetHeaderGradient\1\color=ffffff

View File

@@ -192,6 +192,7 @@ ApplyThemePaletteGlobally=false
FlatSideBarIcons=true FlatSideBarIcons=true
FlatProjectsMode=false FlatProjectsMode=false
FlatMenuBar=false FlatMenuBar=false
ToolBarIconShadow=true
[Gradients] [Gradients]
DetailsWidgetHeaderGradient\1\color=0 DetailsWidgetHeaderGradient\1\color=0

View File

@@ -129,7 +129,7 @@ static QPixmap masksToIcon(const MasksAndColors &masks, const QPixmap &combinedM
p.drawPixmap(0, 0, maskToColorAndAlpha((*maskImage).first, (*maskImage).second)); p.drawPixmap(0, 0, maskToColorAndAlpha((*maskImage).first, (*maskImage).second));
} }
if (style & Icon::DropShadow) { if (style & Icon::DropShadow && creatorTheme()->flag(Theme::ToolBarIconShadow)) {
const QPixmap shadowMask = maskToColorAndAlpha(combinedMask, Qt::black); const QPixmap shadowMask = maskToColorAndAlpha(combinedMask, Qt::black);
p.setCompositionMode(QPainter::CompositionMode_DestinationOver); p.setCompositionMode(QPainter::CompositionMode_DestinationOver);
p.setOpacity(0.05); p.setOpacity(0.05);

View File

@@ -315,7 +315,8 @@ void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter,
if (!enabled) { if (!enabled) {
drawCommonStyleArrow(image.rect(), creatorTheme()->color(Theme::IconsDisabledColor)); drawCommonStyleArrow(image.rect(), creatorTheme()->color(Theme::IconsDisabledColor));
} else { } else {
drawCommonStyleArrow(image.rect().translated(0, devicePixelRatio), toolBarDropShadowColor()); if (creatorTheme()->flag(Theme::ToolBarIconShadow))
drawCommonStyleArrow(image.rect().translated(0, devicePixelRatio), toolBarDropShadowColor());
drawCommonStyleArrow(image.rect(), creatorTheme()->color(Theme::IconsBaseColor)); drawCommonStyleArrow(image.rect(), creatorTheme()->color(Theme::IconsBaseColor));
} }
painter.end(); painter.end();
@@ -393,7 +394,7 @@ void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect,
const bool hasDisabledState = icon.availableSizes(QIcon::Disabled).contains(px.size()); const bool hasDisabledState = icon.availableSizes(QIcon::Disabled).contains(px.size());
if (!hasDisabledState) if (!hasDisabledState)
px = disabledSideBarIcon(icon.pixmap(window, rect.size())); px = disabledSideBarIcon(icon.pixmap(window, rect.size()));
} else { } else if (creatorTheme()->flag(Theme::ToolBarIconShadow)) {
// Draw shadow // Draw shadow
QImage tmp(px.size() + QSize(radius * 2, radius * 2 + 1), QImage::Format_ARGB32_Premultiplied); QImage tmp(px.size() + QSize(radius * 2, radius * 2 + 1), QImage::Format_ARGB32_Premultiplied);
tmp.fill(Qt::transparent); tmp.fill(Qt::transparent);

View File

@@ -274,7 +274,8 @@ public:
ApplyThemePaletteGlobally, ApplyThemePaletteGlobally,
FlatSideBarIcons, FlatSideBarIcons,
FlatProjectsMode, FlatProjectsMode,
FlatMenuBar FlatMenuBar,
ToolBarIconShadow
}; };
enum WidgetStyle { enum WidgetStyle {