From ab487246e903a8af283ef773d5c5d08b1921880e Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig <jens.bache-wiig@nokia.com> Date: Fri, 5 Jun 2009 13:59:10 +0200 Subject: [PATCH] Fixes: Make selection rect a little darker Details: Looked a bit too light in certain themes including mac. --- src/plugins/coreplugin/stylehelper.cpp | 10 ++++++++++ src/plugins/coreplugin/stylehelper.h | 1 + src/plugins/texteditor/basetexteditor.cpp | 7 +++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/plugins/coreplugin/stylehelper.cpp b/src/plugins/coreplugin/stylehelper.cpp index 42ca012cf31..4c723449511 100644 --- a/src/plugins/coreplugin/stylehelper.cpp +++ b/src/plugins/coreplugin/stylehelper.cpp @@ -48,6 +48,16 @@ static int range(float x, int min, int max) } */ +QColor StyleHelper::mergedColors(const QColor &colorA, const QColor &colorB, int factor) +{ + const int maxFactor = 100; + QColor tmp = colorA; + tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor); + tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor); + tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor); + return tmp; +} + qreal StyleHelper::sidebarFontSize() { #if defined(Q_WS_MAC) diff --git a/src/plugins/coreplugin/stylehelper.h b/src/plugins/coreplugin/stylehelper.h index 173f12cbf51..32cc200b84a 100644 --- a/src/plugins/coreplugin/stylehelper.h +++ b/src/plugins/coreplugin/stylehelper.h @@ -55,6 +55,7 @@ public: static QColor shadowColor(); static QColor borderColor(); static QColor buttonTextColor() { return QColor(0x4c4c4c); } + static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50); // Sets the base color and makes sure all top level widgets are updated static void setBaseColor(const QColor &color); diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 914c565552c..f398b82cdb4 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -42,6 +42,7 @@ #include <coreplugin/coreconstants.h> #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/manhattanstyle.h> +#include <coreplugin/stylehelper.h> #include <extensionsystem/pluginmanager.h> #include <find/basetextfind.h> #include <texteditor/fontsettings.h> @@ -2260,13 +2261,11 @@ static void drawRectBox(QPainter *painter, const QRect &rect, bool start, bool e QRgb b = pal.base().color().rgb(); QRgb h = pal.highlight().color().rgb(); - QColor c = QColor((qRed(b)*2+qRed(h))/3, - (qGreen(b)*2+qGreen(h))/3, - (qBlue(b)*2+qBlue(h))/3); + QColor c = StyleHelper::mergedColors(b,h, 40); QLinearGradient grad(rect.topLeft(), rect.topRight()); grad.setColorAt(0, c.lighter(110)); - grad.setColorAt(1, c.lighter(160)); + grad.setColorAt(1, c.lighter(130)); QColor outline = c; QRect r = rect; -- GitLab