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
This commit is contained in:
Aleix Pol 2017-11-20 15:32:58 +01:00
parent aa4aa72d63
commit 3e17a2d0a2

View File

@ -135,79 +135,37 @@ Plasma::Theme::ColorGroup ColorScope::colorGroup() const
QColor ColorScope::textColor() const QColor ColorScope::textColor() const
{ {
if (m_inherit) { return m_theme.color(Plasma::Theme::TextColor, colorGroup());
ColorScope *s = findParentScope();
if (s) {
return s->textColor();
}
}
return m_theme.color(Plasma::Theme::TextColor, m_group);
} }
QColor ColorScope::highlightColor() const QColor ColorScope::highlightColor() const
{ {
if (m_inherit) { return m_theme.color(Plasma::Theme::HighlightColor, colorGroup());
ColorScope *s = findParentScope();
if (s) {
return s->highlightColor();
}
}
return m_theme.color(Plasma::Theme::HighlightColor, m_group);
} }
QColor ColorScope::highlightedTextColor() const QColor ColorScope::highlightedTextColor() const
{ {
if (m_inherit) { return m_theme.color(Plasma::Theme::HighlightedTextColor, colorGroup());
ColorScope *s = findParentScope();
if (s) {
return s->highlightedTextColor();
}
}
return m_theme.color(Plasma::Theme::HighlightedTextColor, m_group);
} }
QColor ColorScope::backgroundColor() const QColor ColorScope::backgroundColor() const
{ {
if (m_inherit) { return m_theme.color(Plasma::Theme::BackgroundColor, colorGroup());
ColorScope *s = findParentScope();
if (s) {
return s->backgroundColor();
}
}
return m_theme.color(Plasma::Theme::BackgroundColor, m_group);
} }
QColor ColorScope::positiveTextColor() const QColor ColorScope::positiveTextColor() const
{ {
if (m_inherit) { return m_theme.color(Plasma::Theme::PositiveTextColor, colorGroup());
ColorScope *s = findParentScope();
if (s) {
return s->positiveTextColor();
}
}
return m_theme.color(Plasma::Theme::PositiveTextColor, m_group);
} }
QColor ColorScope::neutralTextColor() const QColor ColorScope::neutralTextColor() const
{ {
if (m_inherit) { return m_theme.color(Plasma::Theme::NeutralTextColor, colorGroup());
ColorScope *s = findParentScope();
if (s) {
return s->neutralTextColor();
}
}
return m_theme.color(Plasma::Theme::NeutralTextColor, m_group);
} }
QColor ColorScope::negativeTextColor() const QColor ColorScope::negativeTextColor() const
{ {
if (m_inherit) { return m_theme.color(Plasma::Theme::NegativeTextColor, colorGroup());
ColorScope *s = findParentScope();
if (s) {
return s->negativeTextColor();
}
}
return m_theme.color(Plasma::Theme::NegativeTextColor, m_group);
} }
bool ColorScope::inherit() const bool ColorScope::inherit() const