10#include <kwin_export.h>
12#include <KPluginMetaData>
13#include <KSharedConfig>
20#include <QStaticPlugin>
25class EffectPluginFactory;
71 virtual void setConfig(KSharedConfig::Ptr config);
82 virtual bool hasEffect(
const QString &name)
const = 0;
183 LoadEffectFlags readConfig(
const QString &effectName,
bool defaultValue)
const;
186 KSharedConfig::Ptr m_config;
189template<
typename Loader,
typename QueueType>
220 template<
typename Loader,
typename QueueType>
224template<
typename Loader,
typename QueueType>
230 , m_effectLoader(parent)
231 , m_dequeueScheduled(false)
234 void enqueue(
const QPair<QueueType, LoadEffectFlags> value)
236 m_queue.enqueue(value);
242 m_dequeueScheduled =
false;
248 if (m_queue.isEmpty()) {
251 m_dequeueScheduled =
false;
252 const auto pair = m_queue.dequeue();
253 m_effectLoader->loadEffect(pair.first, pair.second);
258 void scheduleDequeue()
260 if (m_queue.isEmpty() || m_dequeueScheduled) {
263 m_dequeueScheduled =
true;
266 Loader *m_effectLoader;
267 bool m_dequeueScheduled;
268 QQueue<QPair<QueueType, LoadEffectFlags>> m_queue;
281 bool hasEffect(
const QString &name)
const override;
282 bool isEffectSupported(
const QString &name)
const override;
283 QStringList listOfKnownEffects()
const override;
285 void clear()
override;
286 void queryAndLoadAll()
override;
287 bool loadEffect(
const QString &name)
override;
288 bool loadEffect(
const KPluginMetaData &effect, LoadEffectFlags flags);
291 QList<KPluginMetaData> findAllEffects()
const;
292 KPluginMetaData findEffect(
const QString &name)
const;
293 bool loadJavascriptEffect(
const KPluginMetaData &effect);
294 bool loadDeclarativeEffect(
const KPluginMetaData &effect);
296 QStringList m_loadedEffects;
298 QMetaObject::Connection m_queryConnection;
308 bool hasEffect(
const QString &name)
const override;
312 void clear()
override;
314 bool loadEffect(
const QString &name)
override;
315 bool loadEffect(
const KPluginMetaData &info, LoadEffectFlags flags);
320 QList<KPluginMetaData> findAllEffects()
const;
321 KPluginMetaData findEffect(
const QString &name)
const;
323 QStringList m_loadedEffects;
324 QString m_pluginSubDirectory;
333 bool hasEffect(
const QString &name)
const override;
334 bool isEffectSupported(
const QString &name)
const override;
335 QStringList listOfKnownEffects()
const override;
336 bool loadEffect(
const QString &name)
override;
337 void queryAndLoadAll()
override;
338 void setConfig(KSharedConfig::Ptr config)
override;
339 void clear()
override;
342 QList<AbstractEffectLoader *> m_loaders;
346Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::LoadEffectFlags)
Helper class to queue the loading of Effects.
AbstractEffectLoadQueue(QObject *parent=nullptr)
Interface to describe how an effect loader has to function.
virtual QStringList listOfKnownEffects() const =0
All the Effects this loader knows of.
void effectLoaded(KWin::Effect *effect, const QString &name)
The loader emits this signal when it successfully loaded an effect.
virtual void queryAndLoadAll()=0
The Effect Loader should query its store for all available effects and try to load them.
virtual bool hasEffect(const QString &name) const =0
Whether this Effect Loader can load the Effect with the given name.
virtual void clear()=0
Clears the load queue, that is all scheduled Effects are discarded from loading.
virtual bool loadEffect(const QString &name)=0
Synchronous loading of the Effect with the given name.
virtual bool isEffectSupported(const QString &name) const =0
Whether the Effect with the given name is supported by the compositing backend.
Base class for all KWin effects.
void enqueue(const QPair< QueueType, LoadEffectFlags > value)
EffectLoadQueue(Loader *parent)
void setPluginSubDirectory(const QString &directory)
bool isEffectSupported(const QString &name) const override
Whether the Effect with the given name is supported by the compositing backend.
bool loadEffect(const QString &name) override
Synchronous loading of the Effect with the given name.
void clear() override
Clears the load queue, that is all scheduled Effects are discarded from loading.
bool hasEffect(const QString &name) const override
Whether this Effect Loader can load the Effect with the given name.
void queryAndLoadAll() override
The Effect Loader should query its store for all available effects and try to load them.
QStringList listOfKnownEffects() const override
All the Effects this loader knows of.
PluginEffectLoader(QObject *parent=nullptr)
~PluginEffectLoader() override
Can load scripted Effects.
LoadEffectFlag
Flags defining how a Loader should load an Effect.
@ CheckDefaultFunction
The Check Default Function needs to be invoked if the Effect provides it.
@ Load
Effect should be loaded.