From f556057924e559e4238f9fb4063059897d1b55a6 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 30 Jun 2016 13:43:20 +0200 Subject: [PATCH] Core: Make FancyActionBar actions theme aware The text in the FancyActionBar actions had hardcoded text colors, which by accidend looked OK with the current themes. But light themes require these texts to follow the theme. This patch removes the uncommon "shadows" under the text, instead of trying to make text shadows themable. Change-Id: Ie0e3a9673f24ead64dcdd8963319dc1908afb3aa Reviewed-by: Alessandro Portale --- src/plugins/coreplugin/fancyactionbar.cpp | 24 ++++++----------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp index 14d3868f9cf..28a334637cb 100644 --- a/src/plugins/coreplugin/fancyactionbar.cpp +++ b/src/plugins/coreplugin/fancyactionbar.cpp @@ -206,23 +206,14 @@ void FancyToolButton::paintEvent(QPaintEvent *event) QPoint textOffset = centerRect.center() - QPoint(iconRect.width()/2, iconRect.height()/2); textOffset = textOffset - QPoint(0, lineHeight + 4); QRectF r(0, textOffset.y(), rect().width(), lineHeight); - QColor penColor; - if (isEnabled()) - penColor = Qt::white; - else - penColor = Qt::gray; - painter.setPen(penColor); + painter.setPen(creatorTheme()->color(isEnabled() + ? Theme::PanelTextColorLight + : Theme::IconsDisabledColor)); // draw project name const int margin = 6; const qreal availableWidth = r.width() - margin; QString ellidedProjectName = fm.elidedText(projectName, Qt::ElideMiddle, availableWidth); - if (isEnabled()) { - const QRectF shadowR = r.translated(0, 1); - painter.setPen(QColor(30, 30, 30, 80)); - painter.drawText(shadowR, textFlags, ellidedProjectName); - painter.setPen(penColor); - } painter.drawText(r, textFlags, ellidedProjectName); // draw build configuration name @@ -240,15 +231,12 @@ void FancyToolButton::paintEvent(QPaintEvent *event) splitBuildConfiguration = splitInTwoLines(buildConfiguration, boldFm, availableWidth); } // draw the two lines for the build configuration + painter.setPen(creatorTheme()->color(isEnabled() + ? Theme::FancyTabWidgetEnabledSelectedTextColor + : Theme::FancyTabWidgetDisabledSelectedTextColor)); for (int i = 0; i < 2; ++i) { if (splitBuildConfiguration[i].isEmpty()) continue; - if (isEnabled()) { - const QRectF shadowR = buildConfigRect[i].translated(0, 1); - painter.setPen(QColor(30, 30, 30, 80)); - painter.drawText(shadowR, textFlags, splitBuildConfiguration[i]); - painter.setPen(penColor); - } painter.drawText(buildConfigRect[i], textFlags, splitBuildConfiguration[i]); }