diff --git a/src/lib/repository.h b/src/lib/repository.h --- a/src/lib/repository.h +++ b/src/lib/repository.h @@ -153,6 +153,13 @@ */ void reload(); + /** + * Add a custom search path to the repo. + * This path will be searched in addition to the usual locations for + * syntax and theme definition files. + */ + void addSearchPath(const QString &path); + private: Q_DISABLE_COPY(Repository) friend class RepositoryPrivate; diff --git a/src/lib/repository.cpp b/src/lib/repository.cpp --- a/src/lib/repository.cpp +++ b/src/lib/repository.cpp @@ -138,6 +138,9 @@ loadSyntaxFolder(repo, QStringLiteral(":/org.kde.syntax-highlighting/syntax")); + foreach (const auto &path, m_extraSearchPaths) + loadSyntaxFolder(repo, path + QStringLiteral("/syntax")); + m_sortedDefs.reserve(m_defs.size()); for (auto it = m_defs.constBegin(); it != m_defs.constEnd(); ++it) m_sortedDefs.push_back(it.value()); @@ -153,6 +156,9 @@ foreach (const auto &dir, dirs) loadThemeFolder(dir); loadThemeFolder(QStringLiteral(":/org.kde.syntax-highlighting/themes")); + + foreach (const auto &path, m_extraSearchPaths) + loadThemeFolder(path + QStringLiteral("/themes")); } void RepositoryPrivate::loadSyntaxFolder(Repository *repo, const QString &path) @@ -266,3 +272,9 @@ d->load(this); } + +void Repository::addSearchPath(const QString &path) +{ + d->m_extraSearchPaths.append(path); + reload(); +} diff --git a/src/lib/repository_p.h b/src/lib/repository_p.h --- a/src/lib/repository_p.h +++ b/src/lib/repository_p.h @@ -47,6 +47,8 @@ quint16 foldingRegionId(const QString &defName, const QString &foldName); quint16 nextFormatId(); + QVector m_extraSearchPaths; + QHash m_defs; QVector m_sortedDefs;