From 13b575f7a90ef97f3b30f2a2f74bd19d58d375e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 5 Nov 2016 15:51:51 +0100 Subject: [PATCH] GH-1711 fix inactive element shading in Dark and Bright themes --- application/CMakeLists.txt | 2 ++ application/themes/BrightTheme.cpp | 8 +------- application/themes/BrightTheme.h | 5 ++--- application/themes/DarkTheme.cpp | 8 +------- application/themes/DarkTheme.h | 5 ++--- application/themes/FusionTheme.cpp | 32 ++++++++++++++++++++++++++++++ application/themes/FusionTheme.h | 14 +++++++++++++ 7 files changed, 54 insertions(+), 20 deletions(-) create mode 100644 application/themes/FusionTheme.cpp create mode 100644 application/themes/FusionTheme.h diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index 38729de44..5ac7001dd 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -107,6 +107,8 @@ SET(MULTIMC_SOURCES InstanceWindow.cpp # GUI - themes + themes/FusionTheme.cpp + themes/FusionTheme.h themes/BrightTheme.cpp themes/BrightTheme.h themes/DarkTheme.cpp diff --git a/application/themes/BrightTheme.cpp b/application/themes/BrightTheme.cpp index b4d59b1fe..83d8f0b21 100644 --- a/application/themes/BrightTheme.cpp +++ b/application/themes/BrightTheme.cpp @@ -10,11 +10,6 @@ QString BrightTheme::name() return QObject::tr("Bright"); } -QString BrightTheme::qtTheme() -{ - return "Fusion"; -} - QPalette BrightTheme::colorScheme() { QPalette brightPalette; @@ -29,10 +24,9 @@ QPalette BrightTheme::colorScheme() brightPalette.setColor(QPalette::ButtonText, QColor(49,54,59)); brightPalette.setColor(QPalette::BrightText, Qt::red); brightPalette.setColor(QPalette::Link, QColor(41, 128, 185)); - brightPalette.setColor(QPalette::Highlight, QColor(61, 174, 233)); brightPalette.setColor(QPalette::HighlightedText, QColor(239,240,241)); - return brightPalette; + return fadeInactive(brightPalette, 0.5f, QColor(239,240,241)); } diff --git a/application/themes/BrightTheme.h b/application/themes/BrightTheme.h index e7e0f834f..85b7041b9 100644 --- a/application/themes/BrightTheme.h +++ b/application/themes/BrightTheme.h @@ -1,13 +1,12 @@ #pragma once -#include "ITheme.h" +#include "FusionTheme.h" -class BrightTheme: public ITheme +class BrightTheme: public FusionTheme { public: virtual ~BrightTheme() {} - QString qtTheme() override; QString id() override; QString name() override; QString appStyleSheet() override; diff --git a/application/themes/DarkTheme.cpp b/application/themes/DarkTheme.cpp index 497be1f42..143dd5336 100644 --- a/application/themes/DarkTheme.cpp +++ b/application/themes/DarkTheme.cpp @@ -10,11 +10,6 @@ QString DarkTheme::name() return QObject::tr("Dark"); } -QString DarkTheme::qtTheme() -{ - return "Fusion"; -} - QPalette DarkTheme::colorScheme() { QPalette darkPalette; @@ -29,10 +24,9 @@ QPalette DarkTheme::colorScheme() darkPalette.setColor(QPalette::ButtonText, Qt::white); darkPalette.setColor(QPalette::BrightText, Qt::red); darkPalette.setColor(QPalette::Link, QColor(42, 130, 218)); - darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218)); darkPalette.setColor(QPalette::HighlightedText, Qt::black); - return darkPalette; + return fadeInactive(darkPalette, 0.5f, QColor(49,54,59)); } diff --git a/application/themes/DarkTheme.h b/application/themes/DarkTheme.h index 8552851d5..a8c17de77 100644 --- a/application/themes/DarkTheme.h +++ b/application/themes/DarkTheme.h @@ -1,13 +1,12 @@ #pragma once -#include "ITheme.h" +#include "FusionTheme.h" -class DarkTheme: public ITheme +class DarkTheme: public FusionTheme { public: virtual ~DarkTheme() {} - QString qtTheme() override; QString id() override; QString name() override; QString appStyleSheet() override; diff --git a/application/themes/FusionTheme.cpp b/application/themes/FusionTheme.cpp new file mode 100644 index 000000000..fa2ccf64d --- /dev/null +++ b/application/themes/FusionTheme.cpp @@ -0,0 +1,32 @@ +#include "FusionTheme.h" +#include "rainbow.h" + +QString FusionTheme::qtTheme() +{ + return "Fusion"; +} + +QPalette FusionTheme::fadeInactive(QPalette in, qreal bias, QColor color) +{ + auto blend = [&in, bias, color](QPalette::ColorRole role) + { + QColor from = in.color(QPalette::Active, role); + QColor blended = Rainbow::mix(from, color, bias); + in.setColor(QPalette::Disabled, role, blended); + }; + blend(QPalette::Window); + blend(QPalette::WindowText); + blend(QPalette::Base); + blend(QPalette::AlternateBase); + blend(QPalette::ToolTipBase); + blend(QPalette::ToolTipText); + blend(QPalette::Text); + blend(QPalette::Button); + blend(QPalette::ButtonText); + blend(QPalette::BrightText); + blend(QPalette::Link); + blend(QPalette::Highlight); + blend(QPalette::HighlightedText); + return in; +} + diff --git a/application/themes/FusionTheme.h b/application/themes/FusionTheme.h new file mode 100644 index 000000000..2f938eb94 --- /dev/null +++ b/application/themes/FusionTheme.h @@ -0,0 +1,14 @@ +#pragma once + +#include "ITheme.h" + +class FusionTheme: public ITheme +{ +public: + virtual ~FusionTheme() {} + + QString qtTheme() override; + +protected: + QPalette fadeInactive(QPalette in, qreal bias, QColor color); +};