From 3e993467f38b074aed9988d2e2ef991e82c60a8a Mon Sep 17 00:00:00 2001 From: Stefan Dinkelacker Date: Mon, 20 Nov 2017 15:38:03 +0100 Subject: [PATCH] Introduce themed iconAccentColor (#ff00ff) --- Plugins/org.blueberry.ui.qt/resources/darkstyle.qss | 1 + Plugins/org.blueberry.ui.qt/resources/defaultstyle.qss | 5 +++++ .../org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.cpp | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/Plugins/org.blueberry.ui.qt/resources/darkstyle.qss b/Plugins/org.blueberry.ui.qt/resources/darkstyle.qss index a947465b9cf..21554f33c51 100644 --- a/Plugins/org.blueberry.ui.qt/resources/darkstyle.qss +++ b/Plugins/org.blueberry.ui.qt/resources/darkstyle.qss @@ -40,6 +40,7 @@ See LICENSE.txt or http://www.mitk.org for details. /* foregroundColor = #adb1b6 iconColor = #adb1b6 <- This line is parsed by MITK + iconAccentColor = #db7039 <- This line is parsed by MITK backgroundColor = #323231 inactiveColor = #1d1d1c highlightColor = #3399cc diff --git a/Plugins/org.blueberry.ui.qt/resources/defaultstyle.qss b/Plugins/org.blueberry.ui.qt/resources/defaultstyle.qss index ac9d9f77ef1..f6aaccadf2f 100644 --- a/Plugins/org.blueberry.ui.qt/resources/defaultstyle.qss +++ b/Plugins/org.blueberry.ui.qt/resources/defaultstyle.qss @@ -1,3 +1,8 @@ +/* + iconColor = #000000 <- This line is parsed by MITK + iconAccentColor = #000000 <- This line is parsed by MITK +*/ + berry--QCTabBar::tab { background: palette(window); min-height: 24px; diff --git a/Plugins/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.cpp b/Plugins/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.cpp index c71efb0bcf6..7847141e915 100644 --- a/Plugins/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.cpp +++ b/Plugins/org.blueberry.ui.qt/src/berryAbstractUICTKPlugin.cpp @@ -301,7 +301,15 @@ QByteArray AbstractUICTKPlugin::ApplyTheme(const QByteArray &originalSVG) ? match.captured(1) : QStringLiteral("#000000"); + re.setPattern(QStringLiteral("iconAccentColor\\s*[=:]\\s*(#[0-9a-f]{6})")); + match = re.match(styleSheet); + + auto iconAccentColor = match.hasMatch() + ? match.captured(1) + : QStringLiteral("#000000"); + auto themedSVG = QString(originalSVG).replace(QStringLiteral("#00ff00"), iconColor, Qt::CaseInsensitive); + themedSVG = themedSVG.replace(QStringLiteral("#ff00ff"), iconAccentColor, Qt::CaseInsensitive); return themedSVG.toLatin1(); }