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
This commit is contained in:
parent
d0d0a27bac
commit
8349a786af
|
@ -199,11 +199,15 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const
|
||||||
case IconRole:
|
case IconRole:
|
||||||
return d->categories.at(index.row())->icon();
|
return d->categories.at(index.row())->icon();
|
||||||
case SourceRole:
|
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 {
|
} else {
|
||||||
return d->categories.at(index.row())->source();
|
return source;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case PluginNameRole:
|
case PluginNameRole:
|
||||||
return d->categories.at(index.row())->pluginName();
|
return d->categories.at(index.row())->pluginName();
|
||||||
case VisibleRole:
|
case VisibleRole:
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
void appendCategory(const QString &iconName, const QString &name,
|
void appendCategory(const QString &iconName, const QString &name,
|
||||||
const QString &path, const QString &pluginName);
|
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);
|
const QString &path, const QString &pluginName, bool visible);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user