kcmkwin: Load builtin effects from metadata files
Linking builtin effects against KCMs is really awkward. This change decouples builtin effects from KCMs that use EffectsModel. In order to discover builtin effects, metadata files are installed in kwin's data dir, which will be subsequently read by EffectsModel.
This commit is contained in:
parent
141947d2e8
commit
a3de9bc93b
3 changed files with 12 additions and 15 deletions
|
@ -60,6 +60,7 @@ endmacro()
|
|||
macro(KWIN4_ADD_EFFECT_MODULE name)
|
||||
kwin4_add_effect_backend(${name} OBJECT ${ARGN})
|
||||
target_compile_definitions(${name} PRIVATE QT_STATICPLUGIN)
|
||||
install(FILES metadata.json DESTINATION ${KDE_INSTALL_DATADIR}/${KWIN_NAME}/builtin-effects/${name}/)
|
||||
endmacro()
|
||||
|
||||
# Install the KWin/Effect service type
|
||||
|
|
|
@ -21,10 +21,6 @@ target_link_libraries(kcmkwincommon
|
|||
KF5::I18n
|
||||
KF5::Package
|
||||
KF5::KCMUtils
|
||||
|
||||
# EffectsModel dependencies
|
||||
kwineffects
|
||||
kwin4_effect_builtins
|
||||
)
|
||||
|
||||
set_target_properties(kcmkwincommon PROPERTIES
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include "effectsmodel.h"
|
||||
|
||||
#include <config-kwin.h>
|
||||
#include <effect_builtins.h>
|
||||
#include <kwineffects.h>
|
||||
#include <kwin_effects_interface.h>
|
||||
|
||||
#include <KAboutData>
|
||||
|
@ -31,12 +29,11 @@
|
|||
#include <QDBusPendingCall>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDirIterator>
|
||||
#include <QPushButton>
|
||||
#include <QStaticPlugin>
|
||||
#include <QStandardPaths>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
KWIN_IMPORT_BUILTIN_EFFECTS
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
|
@ -229,13 +226,16 @@ bool EffectsModel::setData(const QModelIndex &index, const QVariant &value, int
|
|||
|
||||
void EffectsModel::loadBuiltInEffects(const KConfigGroup &kwinConfig)
|
||||
{
|
||||
const QVector<QStaticPlugin> staticPlugins = QPluginLoader::staticPlugins();
|
||||
for (const QStaticPlugin &plugin : staticPlugins) {
|
||||
if (plugin.metaData().value("IID").toString() != EffectPluginFactory_iid) {
|
||||
continue;
|
||||
}
|
||||
const QString rootDirectory = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||
QStringLiteral("kwin/builtin-effects"),
|
||||
QStandardPaths::LocateDirectory);
|
||||
|
||||
const KPluginMetaData metaData = KPluginMetaData(plugin.metaData().value("MetaData").toObject(), QString());
|
||||
const QStringList nameFilters{QStringLiteral("metadata.json")};
|
||||
QDirIterator it(rootDirectory, nameFilters, QDir::Files, QDirIterator::Subdirectories);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
|
||||
const KPluginMetaData metaData(it.filePath());
|
||||
if (!metaData.isValid()) {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue