diff --git a/kcmkwin/kwinscreenedges/CMakeLists.txt b/kcmkwin/kwinscreenedges/CMakeLists.txt
index 4e30e70454..29ad4a9e4f 100644
--- a/kcmkwin/kwinscreenedges/CMakeLists.txt
+++ b/kcmkwin/kwinscreenedges/CMakeLists.txt
@@ -1,3 +1,4 @@
+include_directories(${KWIN_SOURCE_DIR}/effects)
set(
kcm_kwinscreenedges_PART_SRCS
main.cpp
@@ -14,6 +15,7 @@ target_link_libraries( kcm_kwinscreenedges ${X11_LIBRARIES}
KF5::I18n
KF5::Service
KF5::Plasma
+ kwin4_effect_builtins
)
install( TARGETS kcm_kwinscreenedges DESTINATION ${PLUGIN_INSTALL_DIR} )
diff --git a/kcmkwin/kwinscreenedges/main.cpp b/kcmkwin/kwinscreenedges/main.cpp
index 4676f2b78c..c952521033 100644
--- a/kcmkwin/kwinscreenedges/main.cpp
+++ b/kcmkwin/kwinscreenedges/main.cpp
@@ -20,14 +20,12 @@ along with this program. If not, see .
*********************************************************************/
#include "main.h"
-
-#include
+#include
#include
#include
#include
#include
-#include
#include
K_PLUGIN_FACTORY(KWinScreenEdgesConfigFactory, registerPlugin();)
@@ -156,14 +154,10 @@ void KWinScreenEdgesConfig::sanitizeCooldown()
}
// Copied from kcmkwin/kwincompositing/main.cpp
-bool KWinScreenEdgesConfig::effectEnabled(const QString& effect, const KConfigGroup& cfg) const
+bool KWinScreenEdgesConfig::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));
}
//-----------------------------------------------------------------------------
@@ -194,40 +188,16 @@ void KWinScreenEdgesConfig::monitorInit()
m_ui->monitor->setEdgeItemEnabled(int(Monitor::Right), 4, false);
m_ui->monitor->setEdgeItemEnabled(int(Monitor::Bottom), 4, false);
- // Search the effect names
- KServiceTypeTrader* trader = KServiceTypeTrader::self();
- KService::List services;
- services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_presentwindows'");
- if (services.isEmpty()) {
- // adding empty strings in case the effect is not found
- // TODO: after string freeze add a info that the effect is missing
- monitorAddItem(QString());
- monitorAddItem(QString());
- } else {
- monitorAddItem(services.first()->name() + " - " + i18n("All Desktops"));
- monitorAddItem(services.first()->name() + " - " + i18n("Current Desktop"));
- monitorAddItem(services.first()->name() + " - " + i18n("Current Application"));
- }
- services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_desktopgrid'");
- if (services.isEmpty()) {
- // adding empty strings in case the effect is not found
- // TODO: after string freeze add a info that the effect is missing
- monitorAddItem(QString());
- } else {
- monitorAddItem(services.first()->name());
- }
- services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_cube'");
- if (services.isEmpty()) {
- // adding empty strings in case the effect is not found
- // TODO: after string freeze add a info that the effect is missing
- monitorAddItem(QString());
- monitorAddItem(QString());
- monitorAddItem(QString());
- } else {
- monitorAddItem(services.first()->name() + " - " + i18n("Cube"));
- monitorAddItem(services.first()->name() + " - " + i18n("Cylinder"));
- monitorAddItem(services.first()->name() + " - " + i18n("Sphere"));
- }
+ // Add the effects
+ const QString presentWindowsName = BuiltInEffects::effectData(BuiltInEffect::PresentWindows).displayName;
+ monitorAddItem(i18n("%1 - All Desktops", presentWindowsName));
+ monitorAddItem(i18n("%1 - Current Desktop", presentWindowsName));
+ monitorAddItem(i18n("%1 - Current Application", presentWindowsName));
+ monitorAddItem(BuiltInEffects::effectData(BuiltInEffect::DesktopGrid).displayName);
+ const QString cubeName = BuiltInEffects::effectData(BuiltInEffect::Cube).displayName;
+ monitorAddItem(i18n("%1 - Cube", cubeName));
+ monitorAddItem(i18n("%1 - Cylinder", cubeName));
+ monitorAddItem(i18n("%1 - Sphere", cubeName));
monitorAddItem(i18n("Toggle window switching"));
monitorAddItem(i18n("Toggle alternative window switching"));
@@ -421,16 +391,16 @@ void KWinScreenEdgesConfig::monitorShowEvent()
config = KConfigGroup(m_config, "Plugins");
// Present Windows
- bool enabled = effectEnabled("presentwindows", config);
+ bool enabled = effectEnabled(BuiltInEffect::PresentWindows, config);
monitorItemSetEnabled(int(PresentWindowsCurrent), enabled);
monitorItemSetEnabled(int(PresentWindowsAll), enabled);
// Desktop Grid
- enabled = effectEnabled("desktopgrid", config);
+ enabled = effectEnabled(BuiltInEffect::DesktopGrid, config);
monitorItemSetEnabled(int(DesktopGrid), enabled);
// Desktop Cube
- enabled = effectEnabled("cube", config);
+ enabled = effectEnabled(BuiltInEffect::Cube, config);
monitorItemSetEnabled(int(Cube), enabled);
monitorItemSetEnabled(int(Cylinder), enabled);
monitorItemSetEnabled(int(Sphere), enabled);
diff --git a/kcmkwin/kwinscreenedges/main.h b/kcmkwin/kwinscreenedges/main.h
index 571fd5f22d..16117eef50 100644
--- a/kcmkwin/kwinscreenedges/main.h
+++ b/kcmkwin/kwinscreenedges/main.h
@@ -32,6 +32,7 @@ class QShowEvent;
namespace KWin
{
+enum class BuiltInEffect;
class KWinScreenEdgesConfigForm : public QWidget, public Ui::KWinScreenEdgesConfigForm
{
@@ -74,7 +75,7 @@ private:
TabBoxAlternative
};
- bool effectEnabled(const QString& effect, const KConfigGroup& cfg) const;
+ bool effectEnabled(const BuiltInEffect& effect, const KConfigGroup& cfg) const;
void monitorAddItem(const QString& item);
void monitorItemSetEnabled(int index, bool enabled);