summaryrefslogtreecommitdiff
path: root/src/libs
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@theqtcompany.com>2016-03-21 12:48:06 +0100
committerAlessandro Portale <alessandro.portale@theqtcompany.com>2016-03-21 14:23:23 +0000
commitddde4bdd273749fc244613c04d88856667e0920a (patch)
treeb89bac672eb1334bfa74f2c25c756a0613791e32 /src/libs
parent2baa1f8b7730611894a1b1e3daebfc0d88845852 (diff)
downloadqt-creator-ddde4bdd273749fc244613c04d88856667e0920a.tar.gz
Utils: Improved handling of StyleHelper::baseColor
This change makes sure that the "UI coloring" feature respects the original brightness of the current theme. It prevents dark themes from getting a too light recoloring and vice versa. Extra benefit: this allows to remove much recently introduced code. Change-Id: Ib2c96e7ed172a4cc97520aa4b5d180cc6353c661 Reviewed-by: hjk <hjk@theqtcompany.com>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/utils/stylehelper.cpp22
-rw-r--r--src/libs/utils/stylehelper.h1
2 files changed, 14 insertions, 9 deletions
diff --git a/src/libs/utils/stylehelper.cpp b/src/libs/utils/stylehelper.cpp
index 9431cbe18d..8de43c24bb 100644
--- a/src/libs/utils/stylehelper.cpp
+++ b/src/libs/utils/stylehelper.cpp
@@ -25,6 +25,7 @@
#include "stylehelper.h"
+#include "theme/theme.h"
#include "hostosinfo.h"
#include <QPixmapCache>
@@ -108,11 +109,6 @@ 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);
@@ -152,10 +148,20 @@ void StyleHelper::setBaseColor(const QColor &newcolor)
{
m_requestedBaseColor = newcolor;
+ const QColor themeBaseColor = creatorTheme()->color(Theme::PanelStatusBarBackgroundColor);
+ const QColor defaultBaseColor = QColor(DEFAULT_BASE_COLOR);
QColor color;
- color.setHsv(newcolor.hue(),
- newcolor.saturation() * 0.7,
- 64 + newcolor.value() / 3);
+
+ if (defaultBaseColor == newcolor) {
+ color = themeBaseColor;
+ } else {
+ const int valueDelta = (newcolor.value() - defaultBaseColor.value()) / 3;
+ const int value = qBound(0, themeBaseColor.value() + valueDelta, 255);
+
+ color.setHsv(newcolor.hue(),
+ newcolor.saturation() * 0.7,
+ value);
+ }
if (color.isValid() && color != m_baseColor) {
m_baseColor = color;
diff --git a/src/libs/utils/stylehelper.h b/src/libs/utils/stylehelper.h
index 5ac91df433..7e483c43f1 100644
--- a/src/libs/utils/stylehelper.h
+++ b/src/libs/utils/stylehelper.h
@@ -56,7 +56,6 @@ 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);