From 3e17a2d0a2079ab0321abda27700c63e02ef1c58 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 20 Nov 2017 15:32:58 +0100 Subject: [PATCH] Remove duplicate boilerplate code Summary: Don't replicate logic present in ::colorGroup for every color() call Reviewers: #plasma, #frameworks, mart Reviewed By: #plasma, mart Subscribers: plasma-devel Tags: #plasma, #frameworks Differential Revision: https://phabricator.kde.org/D8914 --- src/declarativeimports/core/colorscope.cpp | 56 +++------------------- 1 file changed, 7 insertions(+), 49 deletions(-) diff --git a/src/declarativeimports/core/colorscope.cpp b/src/declarativeimports/core/colorscope.cpp index ebea34e50..f7134c5cd 100644 --- a/src/declarativeimports/core/colorscope.cpp +++ b/src/declarativeimports/core/colorscope.cpp @@ -135,79 +135,37 @@ Plasma::Theme::ColorGroup ColorScope::colorGroup() const QColor ColorScope::textColor() const { - if (m_inherit) { - ColorScope *s = findParentScope(); - if (s) { - return s->textColor(); - } - } - return m_theme.color(Plasma::Theme::TextColor, m_group); + return m_theme.color(Plasma::Theme::TextColor, colorGroup()); } QColor ColorScope::highlightColor() const { - if (m_inherit) { - ColorScope *s = findParentScope(); - if (s) { - return s->highlightColor(); - } - } - return m_theme.color(Plasma::Theme::HighlightColor, m_group); + return m_theme.color(Plasma::Theme::HighlightColor, colorGroup()); } QColor ColorScope::highlightedTextColor() const { - if (m_inherit) { - ColorScope *s = findParentScope(); - if (s) { - return s->highlightedTextColor(); - } - } - return m_theme.color(Plasma::Theme::HighlightedTextColor, m_group); + return m_theme.color(Plasma::Theme::HighlightedTextColor, colorGroup()); } QColor ColorScope::backgroundColor() const { - if (m_inherit) { - ColorScope *s = findParentScope(); - if (s) { - return s->backgroundColor(); - } - } - return m_theme.color(Plasma::Theme::BackgroundColor, m_group); + return m_theme.color(Plasma::Theme::BackgroundColor, colorGroup()); } QColor ColorScope::positiveTextColor() const { - if (m_inherit) { - ColorScope *s = findParentScope(); - if (s) { - return s->positiveTextColor(); - } - } - return m_theme.color(Plasma::Theme::PositiveTextColor, m_group); + return m_theme.color(Plasma::Theme::PositiveTextColor, colorGroup()); } QColor ColorScope::neutralTextColor() const { - if (m_inherit) { - ColorScope *s = findParentScope(); - if (s) { - return s->neutralTextColor(); - } - } - return m_theme.color(Plasma::Theme::NeutralTextColor, m_group); + return m_theme.color(Plasma::Theme::NeutralTextColor, colorGroup()); } QColor ColorScope::negativeTextColor() const { - if (m_inherit) { - ColorScope *s = findParentScope(); - if (s) { - return s->negativeTextColor(); - } - } - return m_theme.color(Plasma::Theme::NegativeTextColor, m_group); + return m_theme.color(Plasma::Theme::NegativeTextColor, colorGroup()); } bool ColorScope::inherit() const