diff --git a/kcmkwin/kwintabbox/CMakeLists.txt b/kcmkwin/kwintabbox/CMakeLists.txt
index e736b449dc..e51df0b2dc 100644
--- a/kcmkwin/kwintabbox/CMakeLists.txt
+++ b/kcmkwin/kwintabbox/CMakeLists.txt
@@ -1,4 +1,4 @@
-include_directories( ${KWIN_SOURCE_DIR}/tabbox ${KWIN_SOURCE_DIR})
+include_directories( ${KWIN_SOURCE_DIR}/effects ${KWIN_SOURCE_DIR}/tabbox ${KWIN_SOURCE_DIR})
########### next target ###############
@@ -21,7 +21,9 @@ target_link_libraries(kcm_kwintabbox
KF5::I18n
KF5::Service
KF5::NewStuff
- XCB::XCB)
+ XCB::XCB
+ kwin4_effect_builtins
+)
install(TARGETS kcm_kwintabbox DESTINATION ${PLUGIN_INSTALL_DIR} )
diff --git a/kcmkwin/kwintabbox/main.cpp b/kcmkwin/kwintabbox/main.cpp
index 8e4d159f5f..dfe3ddbce6 100644
--- a/kcmkwin/kwintabbox/main.cpp
+++ b/kcmkwin/kwintabbox/main.cpp
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*********************************************************************/
#include "main.h"
+#include
// Qt
#include
@@ -35,6 +36,7 @@ along with this program. If not, see .
#include
#include
#include
+#include
#include
#include
#include
@@ -158,18 +160,10 @@ KWinTabBoxConfig::~KWinTabBoxConfig()
void KWinTabBoxConfig::initLayoutLists()
{
// search the effect names
- // TODO: way to recognize if a effect is not found
- KServiceTypeTrader* trader = KServiceTypeTrader::self();
- KService::List services;
- QString coverswitch;
- QString flipswitch;
- services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_coverswitch'");
- if (!services.isEmpty())
- coverswitch = services.first()->name();
- services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_flipswitch'");
- if (!services.isEmpty())
- flipswitch = services.first()->name();
+ QString coverswitch = BuiltInEffects::effectData(BuiltInEffect::CoverSwitch).displayName;
+ QString flipswitch = BuiltInEffects::effectData(BuiltInEffect::FlipSwitch).displayName;
+ KServiceTypeTrader* trader = KServiceTypeTrader::self();
KService::List offers = trader->query("KWin/WindowSwitcher");
QStringList layoutNames, layoutPlugins, layoutPaths;
foreach (KService::Ptr service, offers) {
@@ -227,9 +221,9 @@ void KWinTabBoxConfig::load()
updateUiFromConfig(ui[i], *(tabBoxConfig[i]));
KConfigGroup effectconfig(m_config, "Plugins");
- if (effectEnabled("coverswitch", effectconfig) && KConfigGroup(m_config, "Effect-CoverSwitch").readEntry(group[i], false))
+ if (effectEnabled(BuiltInEffect::CoverSwitch, effectconfig) && KConfigGroup(m_config, "Effect-CoverSwitch").readEntry(group[i], false))
ui[i]->effectCombo->setCurrentIndex(CoverSwitch);
- else if (effectEnabled("flipswitch", effectconfig) && KConfigGroup(m_config, "Effect-FlipSwitch").readEntry(group[i], false))
+ else if (effectEnabled(BuiltInEffect::FlipSwitch, effectconfig) && KConfigGroup(m_config, "Effect-FlipSwitch").readEntry(group[i], false))
ui[i]->effectCombo->setCurrentIndex(FlipSwitch);
QString action;
@@ -391,14 +385,10 @@ void KWinTabBoxConfig::defaults()
emit changed(true);
}
-bool KWinTabBoxConfig::effectEnabled(const QString& effect, const KConfigGroup& cfg) const
+bool KWinTabBoxConfig::effectEnabled(const BuiltInEffect& effect, const KConfigGroup& cfg) const
{
- KService::List services = KServiceTypeTrader::self()->query(
- "KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_" + effect + '\'');
- if (services.isEmpty())
- return false;
- QVariant v = services.first()->property("X-KDE-PluginInfo-EnabledByDefault");
- return cfg.readEntry("kwin4_effect_" + effect + "Enabled", v.toBool());
+ // HACK: remove kwin4_effect_
+ return cfg.readEntry("kwin4_effect_" + BuiltInEffects::nameForEffect(effect) + "Enabled", BuiltInEffects::enabledByDefault(effect));
}
void KWinTabBoxConfig::updateUiFromConfig(KWinTabBoxConfigForm* ui, const KWin::TabBox::TabBoxConfig& config)
@@ -498,20 +488,30 @@ void KWinTabBoxConfig::configureEffectClicked()
connect(buttonBox, SIGNAL(accepted()), configDialog, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), configDialog, SLOT(reject()));
- KCModuleProxy* proxy = new KCModuleProxy(effect == CoverSwitch ? "coverswitch_config" : "flipswitch_config");
- connect(configDialog, SIGNAL(defaultClicked()), proxy, SLOT(defaults()));
+ // HACK: kwin4_effect_ needs to be removed
+ const QString name = QStringLiteral("kwin4_effect_") + BuiltInEffects::nameForEffect(effect == CoverSwitch ? BuiltInEffect::CoverSwitch : BuiltInEffect::FlipSwitch);
+
+ KCModule *kcm = KPluginTrader::createInstanceFromQuery(QStringLiteral("kf5/kwin/effects/configs/"), QString(),
+ QStringLiteral("[X-KDE-ParentComponents] == '%1'").arg(name),
+ configDialog);
+ if (!kcm) {
+ delete configDialog;
+ return;
+ }
+
+ connect(buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, kcm, &KCModule::defaults);
QWidget *showWidget = new QWidget(configDialog);
QVBoxLayout *layout = new QVBoxLayout;
showWidget->setLayout(layout);
- layout->addWidget(proxy);
+ layout->addWidget(kcm);
configDialog->layout()->addWidget(showWidget);
configDialog->layout()->addWidget(buttonBox);
if (configDialog->exec() == QDialog::Accepted) {
- proxy->save();
+ kcm->save();
} else {
- proxy->load();
+ kcm->load();
}
delete configDialog;
}
diff --git a/kcmkwin/kwintabbox/main.h b/kcmkwin/kwintabbox/main.h
index f8b5ac257d..d454e26e3d 100644
--- a/kcmkwin/kwintabbox/main.h
+++ b/kcmkwin/kwintabbox/main.h
@@ -32,6 +32,7 @@ class KActionCollection;
namespace KWin
{
+enum class BuiltInEffect;
namespace TabBox
{
@@ -87,7 +88,7 @@ private:
TabBox::TabBoxConfig m_tabBoxConfig;
TabBox::TabBoxConfig m_tabBoxAlternativeConfig;
- bool effectEnabled(const QString& effect, const KConfigGroup& cfg) const;
+ bool effectEnabled(const BuiltInEffect& effect, const KConfigGroup& cfg) const;
};
} // namespace