diff --git a/panelsvg.cpp b/panelsvg.cpp index 9593b7c42..931a947e4 100644 --- a/panelsvg.cpp +++ b/panelsvg.cpp @@ -154,13 +154,6 @@ void PanelSvg::setElementPrefix(Plasma::Location location) d->location = location; } -bool PanelSvg::hasElementPrefix(const QString & prefix) const -{ - //for now it simply checks if a center element exists, - //because it could make sense for certain themes to not have all the elements - return hasElement(prefix + "-center"); -} - void PanelSvg::setElementPrefix(const QString & prefix) { const QString oldPrefix(d->prefix); @@ -191,6 +184,34 @@ void PanelSvg::setElementPrefix(const QString & prefix) d->location = Floating; } +bool PanelSvg::hasElementPrefix(const QString & prefix) const +{ + //for now it simply checks if a center element exists, + //because it could make sense for certain themes to not have all the elements + return hasElement(prefix + "-center"); +} + +bool PanelSvg::hasElementPrefix(Plasma::Location location) const +{ + switch (location) { + case TopEdge: + return hasElementPrefix("north"); + break; + case BottomEdge: + return hasElementPrefix("south"); + break; + case LeftEdge: + return hasElementPrefix("west"); + break; + case RightEdge: + return hasElementPrefix("east"); + break; + default: + return hasElementPrefix(QString()); + break; + } +} + QString PanelSvg::prefix() { if (d->prefix.isEmpty()) { diff --git a/panelsvg.h b/panelsvg.h index 2d37867ea..110f29922 100644 --- a/panelsvg.h +++ b/panelsvg.h @@ -140,6 +140,16 @@ class PLASMA_EXPORT PanelSvg : public Svg */ bool hasElementPrefix(const QString & prefix) const; + /** + * This is an overloaded method provided for convenience equivalent to + * hasElementPrefix("north"), hasElementPrefix("south") + * hasElementPrefix("west") and hasElementPrefix("east") + * @return true if the svg has the necessary elements with the given prefix + * to draw a panel. + * @arg location the given prefix we want to check if drawable + */ + bool hasElementPrefix(Plasma::Location location) const; + /** * Returns the prefix for SVG elements of the PanelSvg * @return the prefix