[kwin] Move finding of scripted effect source file to ScriptedEffect
New ScriptedEffect::create(KService::Ptr). This is a preparation for adding the ordering directly to the Effect.
This commit is contained in:
parent
ba12fe3cc0
commit
42ff5e0c08
4 changed files with 21 additions and 13 deletions
|
@ -36,7 +36,7 @@ Q_DECLARE_METATYPE(KWin::Effect*)
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
ScriptedEffect *ScriptedEffect::create(const QString &, const QString &)
|
||||
ScriptedEffect *ScriptedEffect::create(KService::Ptr)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -243,18 +243,7 @@ bool ScriptedEffectLoader::loadEffect(KService::Ptr effect, LoadEffectFlags flag
|
|||
return false;
|
||||
}
|
||||
|
||||
const QString scriptName = effect->property(QStringLiteral("X-Plasma-MainScript")).toString();
|
||||
if (scriptName.isEmpty()) {
|
||||
qDebug() << "X-Plasma-MainScript not set";
|
||||
return false;
|
||||
}
|
||||
const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||
QStringLiteral(KWIN_NAME) + QStringLiteral("/effects/") + name + QStringLiteral("/contents/") + scriptName);
|
||||
if (scriptFile.isNull()) {
|
||||
qDebug() << "Could not locate the effect script";
|
||||
return false;
|
||||
}
|
||||
ScriptedEffect *e = ScriptedEffect::create(name, scriptFile);
|
||||
ScriptedEffect *e = ScriptedEffect::create(effect);
|
||||
if (!e) {
|
||||
qDebug() << "Could not initialize scripted effect: " << name;
|
||||
return false;
|
||||
|
|
|
@ -366,6 +366,23 @@ void fpx2FromScriptValue(const QScriptValue &value, KWin::FPx2 &fpx2)
|
|||
}
|
||||
}
|
||||
|
||||
ScriptedEffect *ScriptedEffect::create(KService::Ptr effect)
|
||||
{
|
||||
const QString name = effect->property(QStringLiteral("X-KDE-PluginInfo-Name")).toString();
|
||||
const QString scriptName = effect->property(QStringLiteral("X-Plasma-MainScript")).toString();
|
||||
if (scriptName.isEmpty()) {
|
||||
qDebug() << "X-Plasma-MainScript not set";
|
||||
return nullptr;
|
||||
}
|
||||
const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||
QStringLiteral(KWIN_NAME) + QStringLiteral("/effects/") + name + QStringLiteral("/contents/") + scriptName);
|
||||
if (scriptFile.isNull()) {
|
||||
qDebug() << "Could not locate the effect script";
|
||||
return nullptr;
|
||||
}
|
||||
return ScriptedEffect::create(name, scriptFile);
|
||||
}
|
||||
|
||||
ScriptedEffect *ScriptedEffect::create(const QString& effectName, const QString& pathToScript)
|
||||
{
|
||||
ScriptedEffect *effect = new ScriptedEffect();
|
||||
|
|
|
@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define KWIN_SCRIPTEDEFFECT_H
|
||||
|
||||
#include <kwinanimationeffect.h>
|
||||
#include <KService>
|
||||
|
||||
class KConfigLoader;
|
||||
class QScriptEngine;
|
||||
|
@ -105,6 +106,7 @@ public:
|
|||
virtual void reconfigure(ReconfigureFlags flags);
|
||||
QString activeConfig() const;
|
||||
void setActiveConfig(const QString &name);
|
||||
static ScriptedEffect *create(KService::Ptr effect);
|
||||
static ScriptedEffect *create(const QString &effectName, const QString &pathToScript);
|
||||
virtual ~ScriptedEffect();
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue