FrameSvg: make hasElementPrefix() also handle prefix with trailing -

Summary:
there are a few places which potentially pass a prefix with a trailing -,
e.g. if using directly the value of FrameSvg::prefix() or
FrameSvg::actualPrefix(). Support the assumption in such code, unbreaking
its currently not working behaviour.

Reviewers: #plasma, mart

Reviewed By: #plasma, mart

Subscribers: apol, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D21174
This commit is contained in:
Friedrich W. H. Kossebau 2019-05-13 01:36:12 +02:00
parent 6af447a848
commit 8899389c9f
2 changed files with 6 additions and 3 deletions

View File

@ -144,9 +144,12 @@ bool FrameSvg::hasElementPrefix(const QString &prefix) const
//because it could make sense for certain themes to not have all the elements
if (prefix.isEmpty()) {
return hasElement(QStringLiteral("center"));
} else {
return hasElement(prefix % QLatin1String("-center"));
}
if (prefix.endsWith(QLatin1Char('-'))) {
return hasElement(prefix % QLatin1String("center"));
}
return hasElement(prefix % QLatin1String("-center"));
}
bool FrameSvg::hasElementPrefix(Plasma::Types::Location location) const

View File

@ -212,7 +212,7 @@ public:
/**
* @return true if the svg has the necessary elements with the given prefix
* to draw a frame
* @param prefix the given prefix we want to check if drawable
* @param prefix the given prefix we want to check if drawable (can have trailing '-' since 5.59)
*/
Q_INVOKABLE bool hasElementPrefix(const QString &prefix) const;