From 8349a786af99a7adf5add84d911982bc579f3e78 Mon Sep 17 00:00:00 2001 From: Martin Klapetek Date: Mon, 9 Nov 2015 14:33:10 -0500 Subject: [PATCH] Allow adding config categories dynamically This allows to add custom config categories from JS dynamically. This is needed for the calendar event plugins, which are known only at runtime and this enables to load their QML config files (which are supplied as absolute paths) and show them in the applet config dialog. REVIEW: 125966 --- src/plasmaquick/configmodel.cpp | 10 +++++++--- src/plasmaquick/configmodel.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plasmaquick/configmodel.cpp b/src/plasmaquick/configmodel.cpp index c452bb4cc..df537c1e7 100644 --- a/src/plasmaquick/configmodel.cpp +++ b/src/plasmaquick/configmodel.cpp @@ -199,11 +199,15 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const case IconRole: return d->categories.at(index.row())->icon(); case SourceRole: - if (d->appletInterface) { - return QUrl::fromLocalFile(d->appletInterface.data()->package().filePath("ui", d->categories.at(index.row())->source())); + { + const QString source = d->categories.at(index.row())->source(); + // Quick check if source is an absolute path or not + if (d->appletInterface && !(source.startsWith('/') && source.endsWith(QLatin1String("qml")))) { + return QUrl::fromLocalFile(d->appletInterface.data()->package().filePath("ui", source)); } else { - return d->categories.at(index.row())->source(); + return source; } + } case PluginNameRole: return d->categories.at(index.row())->pluginName(); case VisibleRole: diff --git a/src/plasmaquick/configmodel.h b/src/plasmaquick/configmodel.h index dad8a6fa1..ed2df2e53 100644 --- a/src/plasmaquick/configmodel.h +++ b/src/plasmaquick/configmodel.h @@ -83,7 +83,7 @@ public: void appendCategory(const QString &iconName, const QString &name, const QString &path, const QString &pluginName); - void appendCategory(const QString &iconName, const QString &name, + Q_INVOKABLE void appendCategory(const QString &iconName, const QString &name, const QString &path, const QString &pluginName, bool visible); /**