[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.
icc-effect-5.14.5
Martin Gräßlin 2014-03-24 11:02:28 +01:00
parent ba12fe3cc0
commit 42ff5e0c08
4 changed files with 21 additions and 13 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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();

View File

@ -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();
/**