diff --git a/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp b/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp index 10fb0a6ef..ae6051d42 100644 --- a/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp +++ b/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp @@ -19,10 +19,9 @@ #include "fallbackcomponent.h" - +#include #include - #include #include @@ -32,14 +31,38 @@ FallbackComponent::FallbackComponent(QObject *parent) { } -QString FallbackComponent::resolvePath(const QString &component, const QStringList &paths) +QString FallbackComponent::basePath() const +{ + return m_basePath; +} + +void FallbackComponent::setBasePath(const QString &basePath) +{ + if (basePath != m_basePath) { + m_basePath = basePath; + emit onBasePathChanged(); + } +} + +QStringList FallbackComponent::candidates() const +{ + return m_candidates; +} + +void FallbackComponent::setCandidates(const QStringList &candidates) +{ + m_candidates = candidates; + emit onCandidatesChanged(); +} + +QString FallbackComponent::filePath(const QString &key) { QString resolved; - foreach (const QString &path, paths) { - //kDebug() << "Searching for" << path; - const QString key = component + '/' + path; - if (m_paths.contains(key)) { - resolved = *m_paths.object(key); + + foreach (const QString &path, m_candidates) { + kDebug() << "Searching for!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << path; + if (m_possiblePaths.contains(key)) { + resolved = *m_possiblePaths.object(key); if (!resolved.isEmpty()) { break; } else { @@ -47,8 +70,14 @@ QString FallbackComponent::resolvePath(const QString &component, const QStringLi } } - resolved = KStandardDirs::locate("data", "plasma/" + key); - m_paths.insert(key, new QString(resolved)); + QDir tmpPath(m_basePath); + if (tmpPath.isAbsolute()) { + resolved = m_basePath + path; + } else { + resolved = KStandardDirs::locate("data", m_basePath + '/' + path); + } + + m_possiblePaths.insert(key, new QString(resolved)); if (!resolved.isEmpty()) { break; } diff --git a/declarativeimports/plasmaextracomponents/fallbackcomponent.h b/declarativeimports/plasmaextracomponents/fallbackcomponent.h index b5a13fa7e..6d1d1debf 100644 --- a/declarativeimports/plasmaextracomponents/fallbackcomponent.h +++ b/declarativeimports/plasmaextracomponents/fallbackcomponent.h @@ -23,19 +23,36 @@ #include #include - +#include class FallbackComponent : public QObject { Q_OBJECT +Q_PROPERTY(QString basePath READ basePath WRITE setBasePath NOTIFY onBasePathChanged) +Q_PROPERTY(QStringList candidates READ candidates WRITE setCandidates NOTIFY onCandidatesChanged) + public: FallbackComponent(QObject *parent = 0); - Q_INVOKABLE QString resolvePath(const QString &component, const QStringList &paths); + Q_INVOKABLE QString filePath(const QString& key); + + QString basePath() const; + void setBasePath(const QString &basePath); + + + QStringList candidates() const; + void setCandidates(const QStringList &candidates); + + +Q_SIGNALS: + void onBasePathChanged(); + void onCandidatesChanged(); private: - QCache m_paths; + QCache m_possiblePaths; + QString m_basePath; + QStringList m_candidates; }; #endif