Load generic scripted config plugin for scripted effects
We check whether the effect is scripted and provides a config. If that is the case our normal approach for getting the config plugin fails and we use this case to try to load it again through the generic scripted config plugin. REVIEW: 116863 BUG: 332186
This commit is contained in:
parent
ca725b437f
commit
39b61238e5
5 changed files with 34 additions and 7 deletions
|
@ -32,6 +32,8 @@
|
|||
#include <QStandardPaths>
|
||||
#include <QString>
|
||||
|
||||
static const QString s_pluginDir = QStringLiteral("kf5/kwin/effects/configs/");
|
||||
|
||||
namespace KWin {
|
||||
namespace Compositing {
|
||||
|
||||
|
@ -40,15 +42,30 @@ EffectConfig::EffectConfig(QObject *parent)
|
|||
{
|
||||
}
|
||||
|
||||
void EffectConfig::openConfig(const QString &serviceName)
|
||||
void EffectConfig::openConfig(const QString &serviceName, bool scripted)
|
||||
{
|
||||
//setup the UI
|
||||
QDialog dialog;
|
||||
|
||||
// create the KCModule through the plugintrader
|
||||
KCModule *kcm = KPluginTrader::createInstanceFromQuery<KCModule>(QStringLiteral("kf5/kwin/effects/configs/"), QString(),
|
||||
QStringLiteral("[X-KDE-ParentComponents] == '%1'").arg(serviceName),
|
||||
&dialog);
|
||||
KCModule *kcm = nullptr;
|
||||
if (scripted) {
|
||||
// try generic module for scripted
|
||||
const auto offers = KPluginTrader::self()->query(s_pluginDir, QString(),
|
||||
QStringLiteral("[X-KDE-Library] == 'kcm_kwin4_genericscripted'"));
|
||||
if (!offers.isEmpty()) {
|
||||
const KPluginInfo &generic = offers.first();
|
||||
KPluginLoader loader(generic.libraryPath());
|
||||
KPluginFactory *factory = loader.factory();
|
||||
if (factory) {
|
||||
kcm = factory->create<KCModule>(serviceName, &dialog);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
kcm = KPluginTrader::createInstanceFromQuery<KCModule>(s_pluginDir, QString(),
|
||||
QStringLiteral("[X-KDE-ParentComponents] == '%1'").arg(serviceName),
|
||||
&dialog);
|
||||
}
|
||||
if (!kcm) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
explicit EffectConfig(QObject *parent = 0);
|
||||
QString serviceName(const QString &serviceName);
|
||||
|
||||
Q_INVOKABLE void openConfig(const QString &effectName);
|
||||
Q_INVOKABLE void openConfig(const QString &effectName, bool scripted);
|
||||
Q_INVOKABLE void openGHNS();
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
|
@ -69,6 +69,7 @@ QHash< int, QByteArray > EffectModel::roleNames() const
|
|||
roleNames[SupportedRole] = "SupportedRole";
|
||||
roleNames[ExclusiveRole] = "ExclusiveRole";
|
||||
roleNames[ConfigurableRole] = "ConfigurableRole";
|
||||
roleNames[ScriptedRole] = QByteArrayLiteral("ScriptedRole");
|
||||
return roleNames;
|
||||
}
|
||||
|
||||
|
@ -139,6 +140,8 @@ QVariant EffectModel::data(const QModelIndex &index, int role) const
|
|||
return m_effectsList.at(index.row()).internal;
|
||||
case ConfigurableRole:
|
||||
return m_effectsList.at(index.row()).configurable;
|
||||
case ScriptedRole:
|
||||
return m_effectsList.at(index.row()).scripted;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -207,11 +210,16 @@ void EffectModel::loadEffects()
|
|||
effect.supported = true;
|
||||
effect.exclusiveGroup = service->property(QStringLiteral("X-KWin-Exclusive-Category"), QVariant::String).toString();
|
||||
effect.internal = service->property(QStringLiteral("X-KWin-Internal"), QVariant::Bool).toBool();
|
||||
effect.scripted = service->property(QStringLiteral("X-Plasma-API"), QVariant::String).toString().toLower() == QStringLiteral("javascript");
|
||||
|
||||
auto it = std::find_if(configs.begin(), configs.end(), [&plugin](const KPluginInfo &info) {
|
||||
return info.property(QStringLiteral("X-KDE-ParentComponents")).toString() == plugin.pluginName();
|
||||
});
|
||||
effect.configurable = it != configs.end();
|
||||
if (!effect.configurable && effect.scripted && !service->pluginKeyword().isEmpty()) {
|
||||
// scripted effects have their pluginName() as the keyword
|
||||
effect.configurable = service->property(QStringLiteral("X-KDE-ParentComponents")).toString() == service->pluginKeyword();
|
||||
}
|
||||
|
||||
m_effectsList << effect;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ struct EffectData {
|
|||
QString exclusiveGroup;
|
||||
bool internal;
|
||||
bool configurable;
|
||||
bool scripted;
|
||||
};
|
||||
|
||||
class EffectModel : public QAbstractItemModel
|
||||
|
@ -73,7 +74,8 @@ public:
|
|||
SupportedRole,
|
||||
ExclusiveRole,
|
||||
InternalRole,
|
||||
ConfigurableRole
|
||||
ConfigurableRole,
|
||||
ScriptedRole
|
||||
};
|
||||
|
||||
explicit EffectModel(QObject *parent = 0);
|
||||
|
|
|
@ -130,7 +130,7 @@ Rectangle {
|
|||
enabled: effectStatusCheckBox.checked
|
||||
iconName: "configure"
|
||||
onClicked: {
|
||||
effectConfig.openConfig(model.ServiceNameRole);
|
||||
effectConfig.openConfig(model.ServiceNameRole, model.ScriptedRole);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue