From 40bb6faa3078e5dbbd6c2b174ab5129bfd0c0bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 21 Mar 2014 12:09:13 +0100 Subject: [PATCH] [kwin] Add enabledByDefault boolean value to the BuiltInEffects For each effect the value from the desktop file is added. This will allow to query all effects which need to be loaded without looking for the service files. --- effects/effect_builtins.cpp | 99 ++++++++++++++++++++++--------------- effects/effect_builtins.h | 1 + 2 files changed, 59 insertions(+), 41 deletions(-) diff --git a/effects/effect_builtins.cpp b/effects/effect_builtins.cpp index 0d43f5d368..a83356a63a 100644 --- a/effects/effect_builtins.cpp +++ b/effects/effect_builtins.cpp @@ -81,6 +81,7 @@ public: bool supported(BuiltInEffect effect) const; bool checkEnabledByDefault(const QByteArray &name) const; bool checkEnabledByDefault(BuiltInEffect effect) const; + bool enabledByDefault(BuiltInEffect effect) const; QList availableEffectNames() const; QList availableEffects() const; BuiltInEffect builtInForName(const QByteArray &name) const; @@ -93,52 +94,54 @@ private: QMap m_createHash; QMap m_supportedHash; QMap m_checkEnabledHash; + QMap m_enabledByDefault; }; EffectLoader::EffectLoader() { -#define EFFECT(name, className) \ +#define EFFECT(name, className, enabled) \ m_effects.insert(QByteArrayLiteral(#name).toLower(), BuiltInEffect::name);\ - m_createHash.insert(BuiltInEffect::name, &createHelper< className >); - EFFECT(Blur, BlurEffect) - EFFECT(Contrast, ContrastEffect) - EFFECT(CoverSwitch, CoverSwitchEffect) - EFFECT(Cube, CubeEffect) - EFFECT(CubeSlide, CubeSlideEffect) - EFFECT(Dashboard, DashboardEffect) - EFFECT(DesktopGrid, DesktopGridEffect) - EFFECT(DimInactive, DimInactiveEffect) - EFFECT(DimScreen, DimScreenEffect) - EFFECT(FallApart, FallApartEffect) - EFFECT(FlipSwitch, FlipSwitchEffect) - EFFECT(Glide, GlideEffect) - EFFECT(HighlightWindow, HighlightWindowEffect) - EFFECT(Invert, InvertEffect) - EFFECT(Kscreen, KscreenEffect) - EFFECT(Logout, LogoutEffect) - EFFECT(LookingGlass, LookingGlassEffect) - EFFECT(MagicLamp, MagicLampEffect) - EFFECT(Magnifier, MagnifierEffect) - EFFECT(MinimizeAnimation, MinimizeAnimationEffect) - EFFECT(MouseClick, MouseClickEffect) - EFFECT(MouseMark, MouseMarkEffect) - EFFECT(PresentWindows, PresentWindowsEffect) - EFFECT(Resize, ResizeEffect) - EFFECT(ScreenEdge, ScreenEdgeEffect) - EFFECT(ScreenShot, ScreenShotEffect) - EFFECT(Sheet, SheetEffect) - EFFECT(ShowFps, ShowFpsEffect) - EFFECT(ShowPaint, ShowPaintEffect) - EFFECT(Slide, SlideEffect) - EFFECT(SlideBack, SlideBackEffect) - EFFECT(SlidingPopups, SlidingPopupsEffect) - EFFECT(SnapHelper, SnapHelperEffect) - EFFECT(StartupFeedback, StartupFeedbackEffect) - EFFECT(ThumbnailAside, ThumbnailAsideEffect) - EFFECT(TrackMouse, TrackMouseEffect) - EFFECT(WindowGeometry, WindowGeometry) - EFFECT(WobblyWindows, WobblyWindowsEffect) - EFFECT(Zoom, ZoomEffect) + m_createHash.insert(BuiltInEffect::name, &createHelper< className >); \ + m_enabledByDefault.insert(BuiltInEffect::name, enabled); + EFFECT(Blur, BlurEffect, true) + EFFECT(Contrast, ContrastEffect, true) + EFFECT(CoverSwitch, CoverSwitchEffect, false) + EFFECT(Cube, CubeEffect, false) + EFFECT(CubeSlide, CubeSlideEffect, false) + EFFECT(Dashboard, DashboardEffect, true) + EFFECT(DesktopGrid, DesktopGridEffect, true) + EFFECT(DimInactive, DimInactiveEffect, false) + EFFECT(DimScreen, DimScreenEffect, false) + EFFECT(FallApart, FallApartEffect, false) + EFFECT(FlipSwitch, FlipSwitchEffect, false) + EFFECT(Glide, GlideEffect, false) + EFFECT(HighlightWindow, HighlightWindowEffect, true) + EFFECT(Invert, InvertEffect, false) + EFFECT(Kscreen, KscreenEffect, true) + EFFECT(Logout, LogoutEffect, true) + EFFECT(LookingGlass, LookingGlassEffect, false) + EFFECT(MagicLamp, MagicLampEffect, false) + EFFECT(Magnifier, MagnifierEffect, false) + EFFECT(MinimizeAnimation, MinimizeAnimationEffect, true) + EFFECT(MouseClick, MouseClickEffect, false) + EFFECT(MouseMark, MouseMarkEffect, false) + EFFECT(PresentWindows, PresentWindowsEffect, true) + EFFECT(Resize, ResizeEffect, false) + EFFECT(ScreenEdge, ScreenEdgeEffect, true) + EFFECT(ScreenShot, ScreenShotEffect, true) + EFFECT(Sheet, SheetEffect, false) + EFFECT(ShowFps, ShowFpsEffect, false) + EFFECT(ShowPaint, ShowPaintEffect, false) + EFFECT(Slide, SlideEffect, true) + EFFECT(SlideBack, SlideBackEffect, false) + EFFECT(SlidingPopups, SlidingPopupsEffect, true) + EFFECT(SnapHelper, SnapHelperEffect, false) + EFFECT(StartupFeedback, StartupFeedbackEffect, true) + EFFECT(ThumbnailAside, ThumbnailAsideEffect, false) + EFFECT(TrackMouse, TrackMouseEffect, false) + EFFECT(WindowGeometry, WindowGeometry, false) + EFFECT(WobblyWindows, WobblyWindowsEffect, false) + EFFECT(Zoom, ZoomEffect, true) #undef EFFECT @@ -221,6 +224,15 @@ bool EffectLoader::checkEnabledByDefault(BuiltInEffect effect) const return true; } +bool EffectLoader::enabledByDefault(BuiltInEffect effect) const +{ + auto it = m_enabledByDefault.constFind(effect); + if (it != m_enabledByDefault.constEnd()) { + return it.value(); + } + return false; +} + QList< QByteArray > EffectLoader::availableEffectNames() const { return m_effects.keys(); @@ -285,6 +297,11 @@ bool checkEnabledByDefault(BuiltInEffect effect) return s_effectLoader->checkEnabledByDefault(effect); } +bool enabledByDefault(BuiltInEffect effect) +{ + return s_effectLoader->enabledByDefault(effect); +} + QList< QByteArray > availableEffectNames() { return s_effectLoader->availableEffectNames(); diff --git a/effects/effect_builtins.h b/effects/effect_builtins.h index 454e94a7ab..2971c0c735 100644 --- a/effects/effect_builtins.h +++ b/effects/effect_builtins.h @@ -85,6 +85,7 @@ KWINEFFECTS_EXPORT bool supported(const QByteArray &name); KWINEFFECTS_EXPORT bool supported(BuiltInEffect effect); KWINEFFECTS_EXPORT bool checkEnabledByDefault(const QByteArray &name); KWINEFFECTS_EXPORT bool checkEnabledByDefault(BuiltInEffect effect); +KWINEFFECTS_EXPORT bool enabledByDefault(BuiltInEffect effect); KWINEFFECTS_EXPORT QByteArray nameForEffect(BuiltInEffect effect); KWINEFFECTS_EXPORT BuiltInEffect builtInForName(const QByteArray &name); KWINEFFECTS_EXPORT QList availableEffectNames();