diff --git a/svg.cpp b/svg.cpp index 2b4a262c5..858eab344 100644 --- a/svg.cpp +++ b/svg.cpp @@ -66,6 +66,10 @@ class Svg::Private if (QDir::isAbsolutePath(imagePath)) { path = imagePath; themed = false; + + if (!QFile::exists(path)) { + kDebug() << "Plasma::Svg: file '" << path << "' does not exist!" << endl; + } } else { themePath = imagePath; themed = true; @@ -240,6 +244,12 @@ bool Svg::elementExists(const QString& elementId) const return d->renderer->elementExists(elementId); } +bool Svg::isValid() const +{ + d->createRenderer(); + return d->renderer->isValid(); +} + QSize Svg::size() const { return d->size.toSize(); diff --git a/svg.h b/svg.h index 7d0d8254a..f0804b5a6 100644 --- a/svg.h +++ b/svg.h @@ -149,6 +149,13 @@ class PLASMA_EXPORT Svg : public QObject **/ Q_INVOKABLE bool elementExists( const QString& elementId ) const; + /** + * @return true if the SVG file exists and the document is valid, + * otherwise false. This method can be expensive as it + * causes disk access. + **/ + Q_INVOKABLE bool isValid() const; + /** * Currently set size of the SVG * @return the current size of a given element