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 <QStandardPaths>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
static const QString s_pluginDir = QStringLiteral("kf5/kwin/effects/configs/");
|
||||||
|
|
||||||
namespace KWin {
|
namespace KWin {
|
||||||
namespace Compositing {
|
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
|
//setup the UI
|
||||||
QDialog dialog;
|
QDialog dialog;
|
||||||
|
|
||||||
// create the KCModule through the plugintrader
|
// create the KCModule through the plugintrader
|
||||||
KCModule *kcm = KPluginTrader::createInstanceFromQuery<KCModule>(QStringLiteral("kf5/kwin/effects/configs/"), QString(),
|
KCModule *kcm = nullptr;
|
||||||
QStringLiteral("[X-KDE-ParentComponents] == '%1'").arg(serviceName),
|
if (scripted) {
|
||||||
&dialog);
|
// 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) {
|
if (!kcm) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
explicit EffectConfig(QObject *parent = 0);
|
explicit EffectConfig(QObject *parent = 0);
|
||||||
QString serviceName(const QString &serviceName);
|
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_INVOKABLE void openGHNS();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|
|
@ -69,6 +69,7 @@ QHash< int, QByteArray > EffectModel::roleNames() const
|
||||||
roleNames[SupportedRole] = "SupportedRole";
|
roleNames[SupportedRole] = "SupportedRole";
|
||||||
roleNames[ExclusiveRole] = "ExclusiveRole";
|
roleNames[ExclusiveRole] = "ExclusiveRole";
|
||||||
roleNames[ConfigurableRole] = "ConfigurableRole";
|
roleNames[ConfigurableRole] = "ConfigurableRole";
|
||||||
|
roleNames[ScriptedRole] = QByteArrayLiteral("ScriptedRole");
|
||||||
return roleNames;
|
return roleNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,6 +140,8 @@ QVariant EffectModel::data(const QModelIndex &index, int role) const
|
||||||
return m_effectsList.at(index.row()).internal;
|
return m_effectsList.at(index.row()).internal;
|
||||||
case ConfigurableRole:
|
case ConfigurableRole:
|
||||||
return m_effectsList.at(index.row()).configurable;
|
return m_effectsList.at(index.row()).configurable;
|
||||||
|
case ScriptedRole:
|
||||||
|
return m_effectsList.at(index.row()).scripted;
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -207,11 +210,16 @@ void EffectModel::loadEffects()
|
||||||
effect.supported = true;
|
effect.supported = true;
|
||||||
effect.exclusiveGroup = service->property(QStringLiteral("X-KWin-Exclusive-Category"), QVariant::String).toString();
|
effect.exclusiveGroup = service->property(QStringLiteral("X-KWin-Exclusive-Category"), QVariant::String).toString();
|
||||||
effect.internal = service->property(QStringLiteral("X-KWin-Internal"), QVariant::Bool).toBool();
|
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) {
|
auto it = std::find_if(configs.begin(), configs.end(), [&plugin](const KPluginInfo &info) {
|
||||||
return info.property(QStringLiteral("X-KDE-ParentComponents")).toString() == plugin.pluginName();
|
return info.property(QStringLiteral("X-KDE-ParentComponents")).toString() == plugin.pluginName();
|
||||||
});
|
});
|
||||||
effect.configurable = it != configs.end();
|
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;
|
m_effectsList << effect;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ struct EffectData {
|
||||||
QString exclusiveGroup;
|
QString exclusiveGroup;
|
||||||
bool internal;
|
bool internal;
|
||||||
bool configurable;
|
bool configurable;
|
||||||
|
bool scripted;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EffectModel : public QAbstractItemModel
|
class EffectModel : public QAbstractItemModel
|
||||||
|
@ -73,7 +74,8 @@ public:
|
||||||
SupportedRole,
|
SupportedRole,
|
||||||
ExclusiveRole,
|
ExclusiveRole,
|
||||||
InternalRole,
|
InternalRole,
|
||||||
ConfigurableRole
|
ConfigurableRole,
|
||||||
|
ScriptedRole
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit EffectModel(QObject *parent = 0);
|
explicit EffectModel(QObject *parent = 0);
|
||||||
|
|
|
@ -130,7 +130,7 @@ Rectangle {
|
||||||
enabled: effectStatusCheckBox.checked
|
enabled: effectStatusCheckBox.checked
|
||||||
iconName: "configure"
|
iconName: "configure"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
effectConfig.openConfig(model.ServiceNameRole);
|
effectConfig.openConfig(model.ServiceNameRole, model.ScriptedRole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue