diff --git a/effects/effect_builtins.cpp b/effects/effect_builtins.cpp index 6306bece9..b0e1ef6f8 100644 --- a/effects/effect_builtins.cpp +++ b/effects/effect_builtins.cpp @@ -1,775 +1,775 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 Martin Gräßlin This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include "effect_builtins.h" #ifdef EFFECT_BUILTINS // common effects #include "backgroundcontrast/contrast.h" #include "blur/blur.h" #include "colorpicker/colorpicker.h" #include "kscreen/kscreen.h" #include "presentwindows/presentwindows.h" #include "screenedge/screenedgeeffect.h" #include "screenshot/screenshot.h" #include "slidingpopups/slidingpopups.h" // Common effects only relevant to desktop #include "desktopgrid/desktopgrid.h" #include "diminactive/diminactive.h" #include "dimscreen/dimscreen.h" #include "fallapart/fallapart.h" #include "highlightwindow/highlightwindow.h" #include "magiclamp/magiclamp.h" #include "resize/resize.h" #include "showfps/showfps.h" #include "showpaint/showpaint.h" #include "slide/slide.h" #include "slideback/slideback.h" #include "thumbnailaside/thumbnailaside.h" #include "touchpoints/touchpoints.h" #include "windowgeometry/windowgeometry.h" #include "zoom/zoom.h" // OpenGL-specific effects for desktop #include "coverswitch/coverswitch.h" #include "cube/cube.h" #include "cubeslide/cubeslide.h" #include "flipswitch/flipswitch.h" #include "glide/glide.h" #include "invert/invert.h" #include "lookingglass/lookingglass.h" #include "magnifier/magnifier.h" #include "mouseclick/mouseclick.h" #include "mousemark/mousemark.h" #include "sheet/sheet.h" #include "snaphelper/snaphelper.h" #include "startupfeedback/startupfeedback.h" #include "trackmouse/trackmouse.h" #include "wobblywindows/wobblywindows.h" #endif #include #include #ifndef EFFECT_BUILTINS #define EFFECT_FALLBACK nullptr, nullptr, nullptr #else #define EFFECT_FALLBACK #endif namespace KWin { namespace BuiltInEffects { template inline Effect *createHelper() { return new T(); } static const QVector &effectData() { static const QVector s_effectData = { { QString(), QString(), QString(), QString(), QString(), QUrl(), false, false, nullptr, nullptr, nullptr }, { QStringLiteral("blur"), i18ndc("kwin_effects", "Name of a KWin Effect", "Blur"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Blurs the background behind semi-transparent windows"), QStringLiteral("Appearance"), QString(), QUrl(), true, false, #ifdef EFFECT_BUILTINS &createHelper, &BlurEffect::supported, &BlurEffect::enabledByDefault #endif EFFECT_FALLBACK }, { QStringLiteral("colorpicker"), i18ndc("kwin_effects", "Name of a KWin Effect", "Color Picker"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Supports picking a color"), QStringLiteral("Accessibility"), QString(), QUrl(), true, true, #ifdef EFFECT_BUILTINS &createHelper, &ColorPickerEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("contrast"), i18ndc("kwin_effects", "Name of a KWin Effect", "Background contrast"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Improve contrast and readability behind semi-transparent windows"), QStringLiteral("Appearance"), QString(), QUrl(), true, false, #ifdef EFFECT_BUILTINS &createHelper, &ContrastEffect::supported, &ContrastEffect::enabledByDefault #endif EFFECT_FALLBACK }, { QStringLiteral("coverswitch"), i18ndc("kwin_effects", "Name of a KWin Effect", "Cover Switch"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Display a Cover Flow effect for the alt+tab window switcher"), QStringLiteral("Window Management"), QString(), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/cover_switch.mp4")), false, true, #ifdef EFFECT_BUILTINS &createHelper, &CoverSwitchEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("cube"), i18ndc("kwin_effects", "Name of a KWin Effect", "Desktop Cube"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Display each virtual desktop on a side of a cube"), QStringLiteral("Window Management"), QString(), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/desktop_cube.ogv")), false, false, #ifdef EFFECT_BUILTINS &createHelper, &CubeEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("cubeslide"), i18ndc("kwin_effects", "Name of a KWin Effect", "Desktop Cube Animation"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Animate desktop switching with a cube"), QStringLiteral("Virtual Desktop Switching Animation"), QStringLiteral("desktop-animations"), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/desktop_cube_animation.ogv")), false, false, #ifdef EFFECT_BUILTINS &createHelper, &CubeSlideEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("desktopgrid"), i18ndc("kwin_effects", "Name of a KWin Effect", "Desktop Grid"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Zoom out so all desktops are displayed side-by-side in a grid"), QStringLiteral("Window Management"), QString(), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/desktop_grid.mp4")), true, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("diminactive"), i18ndc("kwin_effects", "Name of a KWin Effect", "Dim Inactive"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Darken inactive windows"), QStringLiteral("Focus"), QString(), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/dim_inactive.mp4")), false, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("dimscreen"), i18ndc("kwin_effects", "Name of a KWin Effect", "Dim Screen for Administrator Mode"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Darkens the entire screen when requesting root privileges"), QStringLiteral("Focus"), QString(), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/dim_administration.mp4")), false, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("fallapart"), i18ndc("kwin_effects", "Name of a KWin Effect", "Fall Apart"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Closed windows fall into pieces"), QStringLiteral("Candy"), QString(), QUrl(), false, false, #ifdef EFFECT_BUILTINS &createHelper, &FallApartEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("flipswitch"), i18ndc("kwin_effects", "Name of a KWin Effect", "Flip Switch"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Flip through windows that are in a stack for the alt+tab window switcher"), QStringLiteral("Window Management"), QString(), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/flip_switch.mp4")), false, false, #ifdef EFFECT_BUILTINS &createHelper, &FlipSwitchEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("glide"), i18ndc("kwin_effects", "Name of a KWin Effect", "Glide"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Glide windows as they appear or disappear"), - QStringLiteral("Appearance"), - QString(), + QStringLiteral("Window Open/Close Animation"), + QStringLiteral("toplevel-open-close-animation"), QUrl(), false, false, #ifdef EFFECT_BUILTINS &createHelper, &GlideEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("highlightwindow"), i18ndc("kwin_effects", "Name of a KWin Effect", "Highlight Window"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Highlight the appropriate window when hovering over taskbar entries"), QStringLiteral("Appearance"), QString(), QUrl(), true, true, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("invert"), i18ndc("kwin_effects", "Name of a KWin Effect", "Invert"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Inverts the color of the desktop and windows"), QStringLiteral("Accessibility"), QString(), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/invert.mp4")), false, false, #ifdef EFFECT_BUILTINS &createHelper, &InvertEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("kscreen"), i18ndc("kwin_effects", "Name of a KWin Effect", "Kscreen"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Helper Effect for KScreen"), QStringLiteral("Appearance"), QString(), QUrl(), true, true, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("lookingglass"), i18ndc("kwin_effects", "Name of a KWin Effect", "Looking Glass"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "A screen magnifier that looks like a fisheye lens"), QStringLiteral("Accessibility"), QStringLiteral("magnifiers"), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/looking_glass.ogv")), false, false, #ifdef EFFECT_BUILTINS &createHelper, &LookingGlassEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("magiclamp"), i18ndc("kwin_effects", "Name of a KWin Effect", "Magic Lamp"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Simulate a magic lamp when minimizing windows"), QStringLiteral("Appearance"), QStringLiteral("minimize"), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/magic_lamp.ogv")), false, false, #ifdef EFFECT_BUILTINS &createHelper, &MagicLampEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("magnifier"), i18ndc("kwin_effects", "Name of a KWin Effect", "Magnifier"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Magnify the section of the screen that is near the mouse cursor"), QStringLiteral("Accessibility"), QStringLiteral("magnifiers"), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/magnifier.ogv")), false, false, #ifdef EFFECT_BUILTINS &createHelper, &MagnifierEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("mouseclick"), i18ndc("kwin_effects", "Name of a KWin Effect", "Mouse Click Animation"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Creates an animation whenever a mouse button is clicked. This is useful for screenrecordings/presentations"), QStringLiteral("Accessibility"), QString(), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/mouse_click.mp4")), false, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("mousemark"), i18ndc("kwin_effects", "Name of a KWin Effect", "Mouse Mark"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Allows you to draw lines on the desktop"), QStringLiteral("Appearance"), QString(), QUrl(), false, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("presentwindows"), i18ndc("kwin_effects", "Name of a KWin Effect", "Present Windows"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Zoom out until all opened windows can be displayed side-by-side"), QStringLiteral("Window Management"), QString(), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/present_windows.mp4")), true, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("resize"), i18ndc("kwin_effects", "Name of a KWin Effect", "Resize Window"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Resizes windows with a fast texture scale instead of updating contents"), QStringLiteral("Window Management"), QString(), QUrl(), false, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("screenedge"), i18ndc("kwin_effects", "Name of a KWin Effect", "Screen Edge"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Highlights a screen edge when approaching"), QStringLiteral("Appearance"), QString(), QUrl(), true, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("screenshot"), i18ndc("kwin_effects", "Name of a KWin Effect", "Screenshot"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Helper effect for KSnapshot"), QStringLiteral("Appearance"), QString(), QUrl(), true, true, #ifdef EFFECT_BUILTINS &createHelper, &ScreenShotEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("sheet"), i18ndc("kwin_effects", "Name of a KWin Effect", "Sheet"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Make modal dialogs smoothly fly in and out when they are shown or hidden"), QStringLiteral("Candy"), QString(), QUrl(), false, false, #ifdef EFFECT_BUILTINS &createHelper, &SheetEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("showfps"), i18ndc("kwin_effects", "Name of a KWin Effect", "Show FPS"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Display KWin's performance in the corner of the screen"), QStringLiteral("Tools"), QString(), QUrl(), false, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("showpaint"), i18ndc("kwin_effects", "Name of a KWin Effect", "Show Paint"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Highlight areas of the desktop that have been recently updated"), QStringLiteral("Tools"), QString(), QUrl(), false, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("slide"), i18ndc("kwin_effects", "Name of a KWin Effect", "Slide"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Slide desktops when switching virtual desktops"), QStringLiteral("Virtual Desktop Switching Animation"), QStringLiteral("desktop-animations"), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/slide.ogv")), true, false, #ifdef EFFECT_BUILTINS &createHelper, &SlideEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("slideback"), i18ndc("kwin_effects", "Name of a KWin Effect", "Slide Back"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Slide back windows when another window is raised"), QStringLiteral("Focus"), QString(), QUrl(), false, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("slidingpopups"), i18ndc("kwin_effects", "Name of a KWin Effect", "Sliding popups"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Sliding animation for Plasma popups"), QStringLiteral("Appearance"), QString(), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/sliding_popups.mp4")), true, false, #ifdef EFFECT_BUILTINS &createHelper, &SlidingPopupsEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("snaphelper"), i18ndc("kwin_effects", "Name of a KWin Effect", "Snap Helper"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Help you locate the center of the screen when moving a window"), QStringLiteral("Accessibility"), QString(), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/snap_helper.mp4")), false, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("startupfeedback"), i18ndc("kwin_effects", "Name of a KWin Effect", "Startup Feedback"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Helper effect for startup feedback"), QStringLiteral("Candy"), QString(), QUrl(), true, true, #ifdef EFFECT_BUILTINS &createHelper, &StartupFeedbackEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("thumbnailaside"), i18ndc("kwin_effects", "Name of a KWin Effect", "Thumbnail Aside"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Display window thumbnails on the edge of the screen"), QStringLiteral("Appearance"), QString(), QUrl(), false, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("touchpoints"), i18ndc("kwin_effects", "Name of a KWin Effect", "Touch Points"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Visualize touch points"), QStringLiteral("Appearance"), QString(), QUrl(), false, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("trackmouse"), i18ndc("kwin_effects", "Name of a KWin Effect", "Track Mouse"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Display a mouse cursor locating effect when activated"), QStringLiteral("Accessibility"), QString(), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/track_mouse.mp4")), false, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("windowgeometry"), i18ndc("kwin_effects", "Name of a KWin Effect", "Window Geometry"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Display window geometries on move/resize"), QStringLiteral("Appearance"), QString(), QUrl(), false, true, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("wobblywindows"), i18ndc("kwin_effects", "Name of a KWin Effect", "Wobbly Windows"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Deform windows while they are moving"), QStringLiteral("Candy"), QString(), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/wobbly_windows.ogv")), false, false, #ifdef EFFECT_BUILTINS &createHelper, &WobblyWindowsEffect::supported, nullptr #endif EFFECT_FALLBACK }, { QStringLiteral("zoom"), i18ndc("kwin_effects", "Name of a KWin Effect", "Zoom"), i18ndc("kwin_effects", "Comment describing the KWin Effect", "Magnify the entire desktop"), QStringLiteral("Accessibility"), QStringLiteral("magnifiers"), QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/zoom.ogv")), true, false, #ifdef EFFECT_BUILTINS &createHelper, nullptr, nullptr #endif EFFECT_FALLBACK } }; return s_effectData; } static inline int index(BuiltInEffect effect) { return static_cast(effect); } Effect *create(BuiltInEffect effect) { const EffectData &data = effectData(effect); if (data.createFunction == nullptr) { return nullptr; } return data.createFunction(); } bool available(const QString &name) { auto it = std::find_if(effectData().begin(), effectData().end(), [name](const EffectData &data) { return data.name == name; } ); return it != effectData().end(); } bool supported(BuiltInEffect effect) { if (effect == BuiltInEffect::Invalid) { return false; } const EffectData &data = effectData(effect); if (data.supportedFunction == nullptr) { return true; } return data.supportedFunction(); } bool checkEnabledByDefault(BuiltInEffect effect) { if (effect == BuiltInEffect::Invalid) { return false; } const EffectData &data = effectData(effect); if (data.enabledFunction == nullptr) { return true; } return data.enabledFunction(); } bool enabledByDefault(BuiltInEffect effect) { return effectData(effect).enabled; } QStringList availableEffectNames() { QStringList result; for (const EffectData &data : effectData()) { if (data.name.isEmpty()) { continue; } result << data.name; } return result; } QList< BuiltInEffect > availableEffects() { QList result; for (int i = index(BuiltInEffect::Invalid) + 1; i <= index(BuiltInEffect::Zoom); ++i) { result << BuiltInEffect(i); } return result; } BuiltInEffect builtInForName(const QString &name) { auto it = std::find_if(effectData().begin(), effectData().end(), [name](const EffectData &data) { return data.name == name; } ); if (it == effectData().end()) { return BuiltInEffect::Invalid; } return BuiltInEffect(std::distance(effectData().begin(), it)); } QString nameForEffect(BuiltInEffect effect) { return effectData(effect).name; } const EffectData &effectData(BuiltInEffect effect) { return effectData().at(index(effect)); } } // BuiltInEffects } // namespace diff --git a/effects/fade/package/metadata.desktop b/effects/fade/package/metadata.desktop index 3368f09f0..223ef131e 100644 --- a/effects/fade/package/metadata.desktop +++ b/effects/fade/package/metadata.desktop @@ -1,162 +1,163 @@ [Desktop Entry] Name=Fade Name[af]=Vervaag Name[ar]=التلاشي Name[be]=Павольнае знікненне Name[bg]=Избледняване Name[bn]=ফেড Name[bs]=Utapanje Name[ca]=Apagat gradual Name[ca@valencia]=Apagat gradual Name[cs]=Blednutí Name[da]=Udtone Name[de]=Verblassen Name[el]=Ομαλή εμφάνιση Name[en_GB]=Fade Name[eo]=Dissolvi Name[es]=Fundido Name[et]=Hääbumine Name[eu]=Desagertzea Name[fa]=محو کردن Name[fi]=Häivytys Name[fr]=Fondu Name[fy]=Litte ferfage Name[ga]=Céimnigh Name[gl]=Esvaer Name[gu]=પીગળવું Name[he]=חשיפה והיעלמות Name[hi]=फीका Name[hne]=फीका Name[hr]=Lagano pojavljivanje Name[hu]=Fokozatos átmenet Name[ia]=Pallidi Name[id]=Fade Name[is]=Þynna út Name[it]=Dissolvi Name[ja]=フェード Name[kk]=Біртіндеп Name[km]=លេច​បន្តិច​ម្ដងៗ​ Name[kn]=ಮಾಸು/ಮಸುಕುಗೊಳಿಸು Name[ko]=페이드 Name[lt]=Išnykimas Name[lv]=Izdzist Name[mai]=फीका करू Name[mk]=Избледување Name[ml]=മങ്ങുക Name[mr]=फीके Name[nb]=Ton ut Name[nds]=Utblennen Name[ne]=फेड Name[nl]=Opkomen/vervagen Name[nn]=Ton inn og ut Name[pa]=ਫਿੱਕਾ Name[pl]=Zanikanie/wyłanianie Name[pt]=Desvanecer Name[pt_BR]=Fade Name[ro]=Decolorare Name[ru]=Растворение Name[se]=Rievdat šearratvuođa Name[si]=විවර්ණ Name[sk]=Zoslabiť Name[sl]=Pojavljanje in pojemanje Name[sr]=Утапање Name[sr@ijekavian]=Утапање Name[sr@ijekavianlatin]=Utapanje Name[sr@latin]=Utapanje Name[sv]=Tona Name[ta]=வெளிர் Name[te]=ఫేడ్ Name[tg]=Плавное появление и исчезновение Name[th]=ค่อย ๆ ชัด/ค่อย ๆ จางหาย Name[tr]=Kaybolma Name[ug]=سۇسلاشتۇر Name[uk]=Згасання Name[uz]=Soʻnish Name[uz@cyrillic]=Сўниш Name[vi]=Mờ dần Name[wa]=Blåwe Name[x-test]=xxFadexx Name[zh_CN]=淡入淡出 Name[zh_TW]=淡出 Icon=preferences-system-windows-effect-fade Comment=Make windows smoothly fade in and out when they are shown or hidden Comment[ar]=اجعل النوافذ تظهر وتتلاشى بنعومة عند إظهاراها وإخفائها Comment[bg]=Постепенно избледняване при показване и скриване на прозорците Comment[bs]=Prozori glatko izranjaju i utapaju se pri pojavljivanju i sakrivanju Comment[ca]=Fa que les finestres s'encenguin o s'apaguin de manera gradual quan es mostren o s'oculten Comment[ca@valencia]=Fa que les finestres s'encenguin o s'apaguin de manera gradual quan es mostren o s'oculten Comment[cs]=Nechá okna plynule zmizet/objevit se, pokud jsou zobrazeny resp. skryty Comment[da]=Få vinduer til at tone blidt ud og ind når de vises eller skjules Comment[de]=Blendet Fenster beim Öffnen/Schließen langsam ein bzw. aus. Comment[el]=Ομαλή εμφάνιση και απόκρυψη των παραθύρων Comment[en_GB]=Make windows smoothly fade in and out when they are shown or hidden Comment[eo]=Fenestroj glate maldissolvi/fordissolvi kiam ili videbliĝas aŭ kaŝiĝas Comment[es]=Hace que las ventanas aparezcan suavemente o se desvanezcan al mostrarlas u ocultarlas Comment[et]=Paneb aknad sujuvalt hääbuma või tugevnema, kui need peidetakse või nähtavale tuuakse Comment[eu]=Leihoak emeki agertzen eta desagertzen ditu haiek erakustean edo ezkutatzean Comment[fi]=Ikkunat tulevat näkyviin tai poistuvat näkyvistä pehmeästi häivyttäen Comment[fr]=Estompe ou fait apparaître en fondu les fenêtres lorsqu'elles sont affichées ou cachées Comment[fy]=Lit finters útstrutsen ferfage of opkomme as se te sjen binne of ferburgen wurde Comment[ga]=Leis seo, céimneoidh fuinneoga isteach agus amach agus iad á dtaispeáint nó á bhfolú Comment[gl]=Esvae/Fai opacas as xanelas con suavidade ao mostralas ou agochadas Comment[gu]=જ્યારે વિન્ડો બતાવવામાં અથવા છુપાવવામાં આવે છે ત્યારે તેમને સરળતાથી ઝાંખી અથવા પ્રકાશિત કરો Comment[he]=חשיפה והיעלמות חלקה של חלונות בעת הצגתם או הסתרתם Comment[hi]=जब विंडो को दिखाया या छुपाया जाता है तो उन्हें यह धीरे से फ़ीका करता है Comment[hne]=जब विंडो ल देखाय या लुकाय जाथे तहां ये मन ल, ए धीरे से फीका करथे Comment[hr]=Prozori će se lagano pojavljivati i nestajati kad ih se prikazuje ili sakriva Comment[hu]=Az ablakok folyamatosan áttűnő módon lesznek elrejtve és megjelenítve Comment[ia]=Face que fenestras pote dulcemente pallidir intra e foras quando illos es monstrate o celate Comment[id]=Buat jendela melesap lemah dan kuat ketika jendela ditampilkan atau disembunyikan Comment[is]=Lætur glugga þynnast mjúklega inn eða út, þegar þeir eru endurheimtir eða faldir Comment[it]=Fai dissolvere e comparire gradualmente le finestre quando vengono mostrate o nascoste Comment[ja]=ウィンドウの表示/非表示の切り替えを滑らかにフェードイン/フェードアウトします Comment[kk]=Көрсеткенде/жасырғанда терезелер біртіндеп пайда/ғайып болады Comment[km]=ធ្វើ​ឲ្យ​បង្អួច​លេច​បន្តិច​ម្តង​/លិចបន្តិច​ម្តង​យ៉ាង​រលូន ពេល​ពួក​វា​ត្រូវ​បាន​បង្ហាញ ឬ​លាក់ Comment[kn]=ಕಿಟಕಿಗಳನ್ನು ತೆರೆದಾಗ ಅಥವಾ ಅಡಗಿಸಿದಾಗ ಅವುಗಳು ಸುಗಮವಾಗಿ ಒಳಮಸುಳು/ಹೊರಮಸುಳುವಂತೆ ಮಾಡುತ್ತದೆ Comment[ko]=창이 보여지거나 감춰질 때 부드러운 페이드 인/아웃을 사용합니다 Comment[lt]=Sukuria efektą, kai langai pamažu išnyksta/atsiranda jei juos prašoma parodyti arba jie slepiami Comment[lv]=Liek logiem vienmērīgi izdzist un parādīties, kad tos parāda vai noslēpj Comment[ml]=ജാലകങ്ങള്‍ ഒളിപ്പിയ്ക്കുമ്പോഴോ കാണിയ്ക്കുമ്പോഴോ മങ്ങുന്നതും തെളിയുന്നതും പോലെ തോന്നിയ്ക്കുക Comment[mr]=चौकटी दर्शविताना किंवा लपविताना त्यांना गडद वा फीक्या करा Comment[nb]=Gjør at vinduer toner jevnt inn/ut når de vises eller skjules Comment[nds]=Finstern bi't Wiesen oder Versteken week in- oder utblennen Comment[nl]=Laat vensters vloeiend opkomen/vervagen als ze worden weergegeven of verborgen Comment[nn]=Ton vindauge inn og ut når dei vert viste eller gøymde Comment[pa]=ਜਦੋਂ ਵਿੰਡੋਜ਼ ਨੂੰ ਵੇਖਾਉਣਾ ਜਾਂ ਓਹਲੇ ਕਰਨਾ ਹੋਵੇ ਤਾਂ ਕੂਲੇ ਢੰਗ ਨਾਲ ਫੇਡ ਇਨ/ਆਉਟ ਕਰੋ Comment[pl]=Gładkie zanikanie i wyłanianie się okien przy ich otwieraniu i zamykaniu Comment[pt]=Fazer com que as janelas apareçam/desapareçam suavemente quando aparecem ou ficam escondidas Comment[pt_BR]=Faz as janelas aparecerem/desaparecerem suavemente quando são exibidas ou ocultadas Comment[ro]=Face ferestrele să se (de)coloreze când sunt afișate sau ascunse Comment[ru]=Закрывающиеся окна будут становиться всё более прозрачными, а потом совсем исчезать Comment[si]=පෙන්වන හා සඟවන විට කවුළු විවර්‍ණය කිරීම හා නොකිරීම සිදු කරන්න Comment[sk]=Okná sa plynule objavia/zmiznú pri ich zobrazení alebo skrytí Comment[sl]=Okna se prikažejo in izginejo postopoma Comment[sr]=Прозори глатко израњају и утапају се при појављивању и сакривању Comment[sr@ijekavian]=Прозори глатко израњају и утапају се при појављивању и сакривању Comment[sr@ijekavianlatin]=Prozori glatko izranjaju i utapaju se pri pojavljivanju i sakrivanju Comment[sr@latin]=Prozori glatko izranjaju i utapaju se pri pojavljivanju i sakrivanju Comment[sv]=Gör att fönster mjukt tonas in eller ut när de visas eller döljs Comment[ta]=Make windows smoothly fade in and out when they are shown or hidden Comment[th]=ทำให้หน้าต่างค่อย ๆ ชัดหรือค่อย ๆ จางหายเมื่อมีการแสดงหรือซ่อนหน้าต่าง Comment[tr]=Pencereler gösterilirken pürüzsüz bir şekilde belirginleştir, gizlenirken pürüzsüz bir şekilde soldur Comment[ug]=كۆزنەكنى كۆرسەتكەن ياكى يوشۇرغاندا كۆزنەكنى تەكشى سۇسلاشتۇر Comment[uk]=Плавна поява або зникнення вікон Comment[vi]=Làm cửa sổ mờ dần hay hiện dần khi chúng được ẩn đi hay hiện lên Comment[wa]=Fé blawi/disblawi doûçmint les finiesses cwand on les mostere ou k' on les catche Comment[x-test]=xxMake windows smoothly fade in and out when they are shown or hiddenxx Comment[zh_CN]=当窗口被显示或者隐藏时,使窗口平滑地淡入淡出 Comment[zh_TW]=顯示或隱藏視窗時以淡入、淡出方式呈現 Type=Service X-Plasma-API=javascript X-Plasma-MainScript=code/main.js X-KDE-ServiceTypes=KWin/Effect X-KDE-PluginInfo-Author=Philip Falkner, Martin Gräßlin X-KDE-PluginInfo-Email=philip.falkner@gmail.com, mgraesslin@kde.org X-KDE-PluginInfo-Name=kwin4_effect_fade X-KDE-PluginInfo-Version=0.2.0 -X-KDE-PluginInfo-Category=Appearance +X-KDE-PluginInfo-Category=Window Open/Close Animation X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=true X-KDE-Ordering=60 +X-KWin-Exclusive-Category=toplevel-open-close-animation diff --git a/effects/scale/package/metadata.desktop b/effects/scale/package/metadata.desktop index a16d1d594..ac0d8e39f 100644 --- a/effects/scale/package/metadata.desktop +++ b/effects/scale/package/metadata.desktop @@ -1,63 +1,64 @@ [Desktop Entry] Name=Scale Name[ca]=Escala Name[ca@valencia]=Escala Name[cs]=Měřítko Name[de]=Skalieren Name[el]=Κλιμάκωση Name[en_GB]=Scale Name[es]=Escalar Name[eu]=Eskalatu Name[fi]=Skaalaa Name[fr]=Échelle Name[gl]=Cambiar as dimensións Name[hu]=Nagyítás Name[id]=Scale Name[it]=Scala Name[ko]=크기 조정 Name[nl]=Schalen Name[nn]=Skalering Name[pl]=Skala Name[pt]=Escala Name[pt_BR]=Escala Name[ru]=Масштабирование Name[sk]=Škálovať Name[sv]=Skala Name[uk]=Масштабування Name[x-test]=xxScalexx Name[zh_CN]=缩放 Name[zh_TW]=縮放 Icon=preferences-system-windows-effect-scale Comment=Make windows smoothly scale in and out when they are shown or hidden Comment[ca]=Fa que les finestres entrin o surtin volant quan es mostren o s'oculten Comment[ca@valencia]=Fa que les finestres entrin o isquen volant quan es mostren o s'oculten Comment[de]=Ändert die Fenstergröße langsam beim Ein- oder Ausblenden Comment[gl]=Facer que as xanelas crezan ou decrezan suavemente cando se mostran ou agochan Comment[id]=Buat jendela menskala besar atau kecil secara mulus ketika ia ditampilkan atau disembunyikan Comment[nl]=Laat vensters vloeiend kleiner en groter schalen als ze worden getoond of verborgen Comment[nn]=Skaler vindauge jamt inn og ut når dei vert viste eller gøymde Comment[pt]=Fazer com que as janelas apareçam/desapareçam suavemente quando aparecem ou ficam escondidas Comment[pt_BR]=Faz com que as janelas aumentem ou reduzam o seu tamanho de forma suave ao serem exibidas ou ocultadas Comment[sv]=Gör att fönster mjukt skalas in eller ut när de visas eller döljs Comment[uk]=Плавне масштабування вікон при появі або приховуванні Comment[x-test]=xxMake windows smoothly scale in and out when they are shown or hiddenxx Comment[zh_CN]=窗口显示或隐藏时平滑缩放 Comment[zh_TW]=顯示或隱藏視窗時以平順的比例縮放方式呈現。 Type=Service X-KDE-ServiceTypes=KWin/Effect,KCModule X-KDE-PluginInfo-Author=Vlad Zagorodniy X-KDE-PluginInfo-Email=vladzzag@gmail.com X-KDE-PluginInfo-Name=kwin4_effect_scale X-KDE-PluginInfo-Version=1 -X-KDE-PluginInfo-Category=Appearance +X-KDE-PluginInfo-Category=Window Open/Close Animation X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=false X-KDE-Ordering=60 X-Plasma-API=javascript X-Plasma-MainScript=code/main.js X-KDE-PluginKeyword=kwin4_effect_scale X-KDE-Library=kcm_kwin4_genericscripted X-KDE-ParentComponents=kwin4_effect_scale X-KWin-Config-TranslationDomain=kwin_effects +X-KWin-Exclusive-Category=toplevel-open-close-animation diff --git a/kcmkwin/kwincompositing/model.cpp b/kcmkwin/kwincompositing/model.cpp index 9ce0873c9..5d9afc9b3 100644 --- a/kcmkwin/kwincompositing/model.cpp +++ b/kcmkwin/kwincompositing/model.cpp @@ -1,660 +1,662 @@ /************************************************************************** * KWin - the KDE window manager * * This file is part of the KDE project. * * * * Copyright (C) 2013 Antonis Tsiapaliokas * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * **************************************************************************/ #include "model.h" #include "effectconfig.h" #include "compositing.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace KWin { namespace Compositing { static QString translatedCategory(const QString &category) { static const QVector knownCategories = { QStringLiteral("Accessibility"), QStringLiteral("Appearance"), QStringLiteral("Candy"), QStringLiteral("Focus"), QStringLiteral("Show Desktop Animation"), QStringLiteral("Tools"), QStringLiteral("Virtual Desktop Switching Animation"), - QStringLiteral("Window Management") + QStringLiteral("Window Management"), + QStringLiteral("Window Open/Close Animation") }; static const QVector translatedCategories = { i18nc("Category of Desktop Effects, used as section header", "Accessibility"), i18nc("Category of Desktop Effects, used as section header", "Appearance"), i18nc("Category of Desktop Effects, used as section header", "Candy"), i18nc("Category of Desktop Effects, used as section header", "Focus"), i18nc("Category of Desktop Effects, used as section header", "Show Desktop Animation"), i18nc("Category of Desktop Effects, used as section header", "Tools"), i18nc("Category of Desktop Effects, used as section header", "Virtual Desktop Switching Animation"), - i18nc("Category of Desktop Effects, used as section header", "Window Management") + i18nc("Category of Desktop Effects, used as section header", "Window Management"), + i18nc("Category of Desktop Effects, used as section header", "Window Open/Close Animation") }; const int index = knownCategories.indexOf(category); if (index == -1) { qDebug() << "Unknown category '" << category << "' and thus not translated"; return category; } return translatedCategories[index]; } static EffectStatus effectStatus(bool enabled) { return enabled ? EffectStatus::Enabled : EffectStatus::Disabled; } EffectModel::EffectModel(QObject *parent) : QAbstractItemModel(parent) { } QHash< int, QByteArray > EffectModel::roleNames() const { QHash roleNames; roleNames[NameRole] = "NameRole"; roleNames[DescriptionRole] = "DescriptionRole"; roleNames[AuthorNameRole] = "AuthorNameRole"; roleNames[AuthorEmailRole] = "AuthorEmailRole"; roleNames[LicenseRole] = "LicenseRole"; roleNames[VersionRole] = "VersionRole"; roleNames[CategoryRole] = "CategoryRole"; roleNames[ServiceNameRole] = "ServiceNameRole"; roleNames[EffectStatusRole] = "EffectStatusRole"; roleNames[VideoRole] = "VideoRole"; roleNames[SupportedRole] = "SupportedRole"; roleNames[ExclusiveRole] = "ExclusiveRole"; roleNames[ConfigurableRole] = "ConfigurableRole"; roleNames[ScriptedRole] = QByteArrayLiteral("ScriptedRole"); return roleNames; } QModelIndex EffectModel::index(int row, int column, const QModelIndex &parent) const { if (parent.isValid() || column > 0 || column < 0 || row < 0 || row >= m_effectsList.count()) { return QModelIndex(); } return createIndex(row, column); } QModelIndex EffectModel::parent(const QModelIndex &child) const { Q_UNUSED(child) return QModelIndex(); } int EffectModel::columnCount(const QModelIndex &parent) const { Q_UNUSED(parent) return 1; } int EffectModel::rowCount(const QModelIndex &parent) const { if (parent.isValid()) { return 0; } return m_effectsList.count(); } QVariant EffectModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) { return QVariant(); } EffectData currentEffect = m_effectsList.at(index.row()); switch (role) { case Qt::DisplayRole: case NameRole: return m_effectsList.at(index.row()).name; case DescriptionRole: return m_effectsList.at(index.row()).description; case AuthorNameRole: return m_effectsList.at(index.row()).authorName; case AuthorEmailRole: return m_effectsList.at(index.row()).authorEmail; case LicenseRole: return m_effectsList.at(index.row()).license; case VersionRole: return m_effectsList.at(index.row()).version; case CategoryRole: return m_effectsList.at(index.row()).category; case ServiceNameRole: return m_effectsList.at(index.row()).serviceName; case EffectStatusRole: return (int)m_effectsList.at(index.row()).effectStatus; case VideoRole: return m_effectsList.at(index.row()).video; case SupportedRole: return m_effectsList.at(index.row()).supported; case ExclusiveRole: return m_effectsList.at(index.row()).exclusiveGroup; case InternalRole: return m_effectsList.at(index.row()).internal; case ConfigurableRole: return m_effectsList.at(index.row()).configurable; case ScriptedRole: return m_effectsList.at(index.row()).scripted; default: return QVariant(); } } bool EffectModel::setData(const QModelIndex& index, const QVariant& value, int role) { if (!index.isValid()) return QAbstractItemModel::setData(index, value, role); if (role == EffectModel::EffectStatusRole) { // note: whenever the StatusRole is modified (even to the same value) the entry // gets marked as changed and will get saved to the config file. This means the // config file could get polluted EffectData &data = m_effectsList[index.row()]; data.effectStatus = EffectStatus(value.toInt()); data.changed = true; emit dataChanged(index, index); if (data.effectStatus == EffectStatus::Enabled && !data.exclusiveGroup.isEmpty()) { // need to disable all other exclusive effects in the same category for (int i = 0; i < m_effectsList.size(); ++i) { if (i == index.row()) { continue; } EffectData &otherData = m_effectsList[i]; if (otherData.exclusiveGroup == data.exclusiveGroup) { otherData.effectStatus = EffectStatus::Disabled; otherData.changed = true; emit dataChanged(this->index(i, 0), this->index(i, 0)); } } } return true; } return QAbstractItemModel::setData(index, value, role); } void EffectModel::loadBuiltInEffects(const KConfigGroup &kwinConfig, const KPluginInfo::List &configs) { const auto builtins = BuiltInEffects::availableEffects(); for (auto builtin : builtins) { const BuiltInEffects::EffectData &data = BuiltInEffects::effectData(builtin); EffectData effect; effect.name = data.displayName; effect.description = data.comment; effect.authorName = i18n("KWin development team"); effect.authorEmail = QString(); // not used at all effect.license = QStringLiteral("GPL"); effect.version = QStringLiteral(KWIN_VERSION_STRING); effect.category = translatedCategory(data.category); effect.serviceName = data.name; effect.enabledByDefault = data.enabled; effect.enabledByDefaultFunction = (data.enabledFunction != nullptr); const QString enabledKey = QStringLiteral("%1Enabled").arg(effect.serviceName); if (kwinConfig.hasKey(enabledKey)) { effect.effectStatus = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", effect.enabledByDefault)); } else if (data.enabledFunction != nullptr) { effect.effectStatus = EffectStatus::EnabledUndeterminded; } else { effect.effectStatus = effectStatus(effect.enabledByDefault); } effect.video = data.video; effect.supported = true; effect.exclusiveGroup = data.exclusiveCategory; effect.internal = data.internal; effect.scripted = false; auto it = std::find_if(configs.begin(), configs.end(), [data](const KPluginInfo &info) { return info.property(QStringLiteral("X-KDE-ParentComponents")).toString() == data.name; }); effect.configurable = it != configs.end(); m_effectsList << effect; } } void EffectModel::loadJavascriptEffects(const KConfigGroup &kwinConfig) { const auto plugins = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Effect"), QStringLiteral("kwin/effects")); for (const KPluginMetaData &metaData : plugins) { KPluginInfo plugin(metaData); EffectData effect; effect.name = plugin.name(); effect.description = plugin.comment(); effect.authorName = plugin.author(); effect.authorEmail = plugin.email(); effect.license = plugin.license(); effect.version = plugin.version(); effect.category = translatedCategory(plugin.category()); effect.serviceName = plugin.pluginName(); effect.effectStatus = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", plugin.isPluginEnabledByDefault())); effect.enabledByDefault = plugin.isPluginEnabledByDefault(); effect.enabledByDefaultFunction = false; effect.video = plugin.property(QStringLiteral("X-KWin-Video-Url")).toUrl(); effect.supported = true; effect.exclusiveGroup = plugin.property(QStringLiteral("X-KWin-Exclusive-Category")).toString(); effect.internal = plugin.property(QStringLiteral("X-KWin-Internal")).toBool(); effect.scripted = true; const QString pluginKeyword = plugin.property(QStringLiteral("X-KDE-PluginKeyword")).toString(); if (!pluginKeyword.isEmpty()) { // scripted effects have their pluginName() as the keyword effect.configurable = plugin.property(QStringLiteral("X-KDE-ParentComponents")).toString() == pluginKeyword; } else { effect.configurable = false; } m_effectsList << effect; } } void EffectModel::loadPluginEffects(const KConfigGroup &kwinConfig, const KPluginInfo::List &configs) { static const QString subDir(QStringLiteral("kwin/effects/plugins/")); static const QString serviceType(QStringLiteral("KWin/Effect")); const QVector pluginEffects = KPluginLoader::findPlugins(subDir, [] (const KPluginMetaData &data) { return data.serviceTypes().contains(serviceType); }); for (KPluginMetaData pluginEffect : pluginEffects) { if (!pluginEffect.isValid()) continue; EffectData effect; effect.name = pluginEffect.name(); effect.description = pluginEffect.description(); effect.license = pluginEffect.license(); effect.version = pluginEffect.version(); effect.category = pluginEffect.category(); effect.serviceName = pluginEffect.pluginId(); effect.enabledByDefault = pluginEffect.isEnabledByDefault(); effect.supported = true; effect.enabledByDefaultFunction = false; effect.internal = false; effect.scripted = false; for (int i = 0; i < pluginEffect.authors().count(); ++i) { effect.authorName.append(pluginEffect.authors().at(i).name()); effect.authorEmail.append(pluginEffect.authors().at(i).emailAddress()); if (i+1 < pluginEffect.authors().count()) { effect.authorName.append(", "); effect.authorEmail.append(", "); } } if (pluginEffect.rawData().contains("org.kde.kwin.effect")) { const QJsonObject d(pluginEffect.rawData().value("org.kde.kwin.effect").toObject()); effect.exclusiveGroup = d.value("exclusiveGroup").toString(); effect.video = QUrl::fromUserInput(d.value("video").toString()); effect.enabledByDefaultFunction = d.value("enabledByDefaultMethod").toBool(); } const QString enabledKey = QStringLiteral("%1Enabled").arg(effect.serviceName); if (kwinConfig.hasKey(enabledKey)) { effect.effectStatus = effectStatus(kwinConfig.readEntry(effect.serviceName + "Enabled", effect.enabledByDefault)); } else if (effect.enabledByDefaultFunction) { effect.effectStatus = EffectStatus::EnabledUndeterminded; } else { effect.effectStatus = effectStatus(effect.enabledByDefault); } auto it = std::find_if(configs.begin(), configs.end(), [pluginEffect](const KPluginInfo &info) { return info.property(QStringLiteral("X-KDE-ParentComponents")).toString() == pluginEffect.pluginId(); }); effect.configurable = it != configs.end(); m_effectsList << effect; } } void EffectModel::loadEffects() { KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins"); beginResetModel(); m_effectsChanged.clear(); m_effectsList.clear(); const KPluginInfo::List configs = KPluginTrader::self()->query(QStringLiteral("kwin/effects/configs/")); loadBuiltInEffects(kwinConfig, configs); loadJavascriptEffects(kwinConfig); loadPluginEffects(kwinConfig, configs); qSort(m_effectsList.begin(), m_effectsList.end(), [](const EffectData &a, const EffectData &b) { if (a.category == b.category) { if (a.exclusiveGroup == b.exclusiveGroup) { return a.name < b.name; } return a.exclusiveGroup < b.exclusiveGroup; } return a.category < b.category; }); OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), QDBusConnection::sessionBus()); if (interface.isValid()) { QStringList effectNames; std::for_each(m_effectsList.constBegin(), m_effectsList.constEnd(), [&effectNames](const EffectData &data) { effectNames << data.serviceName; }); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(interface.areEffectsSupported(effectNames), this); watcher->setProperty("effectNames", effectNames); connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher *self) { const QStringList effectNames = self->property("effectNames").toStringList(); const QDBusPendingReply< QList< bool > > reply = *self; QList< bool> supportValues; if (reply.isValid()) { supportValues.append(reply.value()); } if (effectNames.size() == supportValues.size()) { for (int i = 0; i < effectNames.size(); ++i) { const bool supportedValue = supportValues.at(i); const QString &effectName = effectNames.at(i); auto it = std::find_if(m_effectsList.begin(), m_effectsList.end(), [effectName](const EffectData &data) { return data.serviceName == effectName; }); if (it != m_effectsList.end()) { if ((*it).supported != supportedValue) { (*it).supported = supportedValue; QModelIndex i = index(findRowByServiceName(effectName), 0); if (i.isValid()) { emit dataChanged(i, i, QVector() << SupportedRole); } } } } } self->deleteLater(); }); } m_effectsChanged = m_effectsList; endResetModel(); } int EffectModel::findRowByServiceName(const QString &serviceName) { for (int it = 0; it < m_effectsList.size(); it++) { if (m_effectsList.at(it).serviceName == serviceName) { return it; } } return -1; } void EffectModel::syncEffectsToKWin() { OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), QDBusConnection::sessionBus()); for (int it = 0; it < m_effectsList.size(); it++) { if (m_effectsList.at(it).effectStatus != m_effectsChanged.at(it).effectStatus) { if (m_effectsList.at(it).effectStatus != EffectStatus::Disabled) { interface.loadEffect(m_effectsList.at(it).serviceName); } else { interface.unloadEffect(m_effectsList.at(it).serviceName); } } } m_effectsChanged = m_effectsList; } void EffectModel::updateEffectStatus(const QModelIndex &rowIndex, EffectStatus effectState) { setData(rowIndex, (int)effectState, EffectModel::EffectStatusRole); } void EffectModel::syncConfig() { KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins"); for (auto it = m_effectsList.begin(); it != m_effectsList.end(); it++) { EffectData &effect = *(it); if (!effect.changed) { continue; } effect.changed = false; const QString key = effect.serviceName + QStringLiteral("Enabled"); const bool shouldEnable = (effect.effectStatus != EffectStatus::Disabled); const bool restoreToDefault = effect.enabledByDefaultFunction ? effect.effectStatus == EffectStatus::EnabledUndeterminded : shouldEnable == effect.enabledByDefault; if (restoreToDefault) { kwinConfig.deleteEntry(key); } else { kwinConfig.writeEntry(key, shouldEnable); } } kwinConfig.sync(); syncEffectsToKWin(); } void EffectModel::defaults() { for (int i = 0; i < m_effectsList.count(); ++i) { const auto &effect = m_effectsList.at(i); if (effect.enabledByDefaultFunction && effect.effectStatus != EffectStatus::EnabledUndeterminded) { updateEffectStatus(index(i, 0), EffectStatus::EnabledUndeterminded); } else if ((bool)effect.effectStatus != effect.enabledByDefault) { updateEffectStatus(index(i, 0), effect.enabledByDefault ? EffectStatus::Enabled : EffectStatus::Disabled); } } } EffectFilterModel::EffectFilterModel(QObject *parent) : QSortFilterProxyModel(parent) , m_effectModel(new EffectModel(this)) , m_filterOutUnsupported(true) , m_filterOutInternal(true) { setSourceModel(m_effectModel); connect(this, &EffectFilterModel::filterOutUnsupportedChanged, this, &EffectFilterModel::invalidateFilter); connect(this, &EffectFilterModel::filterOutInternalChanged, this, &EffectFilterModel::invalidateFilter); } const QString &EffectFilterModel::filter() const { return m_filter; } void EffectFilterModel::setFilter(const QString &filter) { if (filter == m_filter) { return; } m_filter = filter; emit filterChanged(); invalidateFilter(); } bool EffectFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { if (!m_effectModel) { return false; } QModelIndex index = m_effectModel->index(source_row, 0, source_parent); if (!index.isValid()) { return false; } if (m_filterOutUnsupported) { if (!index.data(EffectModel::SupportedRole).toBool()) { return false; } } if (m_filterOutInternal) { if (index.data(EffectModel::InternalRole).toBool()) { return false; } } if (m_filter.isEmpty()) { return true; } QVariant data = index.data(); if (!data.isValid()) { //An invalid QVariant is valid data return true; } if (m_effectModel->data(index, EffectModel::NameRole).toString().contains(m_filter, Qt::CaseInsensitive)) { return true; } else if (m_effectModel->data(index, EffectModel::DescriptionRole).toString().contains(m_filter, Qt::CaseInsensitive)) { return true; } if (index.data(EffectModel::CategoryRole).toString().contains(m_filter, Qt::CaseInsensitive)) { return true; } return false; } void EffectFilterModel::updateEffectStatus(int rowIndex, int effectState) { const QModelIndex sourceIndex = mapToSource(index(rowIndex, 0)); m_effectModel->updateEffectStatus(sourceIndex, EffectStatus(effectState)); } void EffectFilterModel::syncConfig() { m_effectModel->syncConfig(); } void EffectFilterModel::load() { m_effectModel->loadEffects(); } void EffectFilterModel::defaults() { m_effectModel->defaults(); } EffectView::EffectView(ViewType type, QWidget *parent) : QQuickWidget(parent) { qRegisterMetaType(); qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "EffectConfig"); qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "EffectFilterModel"); qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "Compositing"); qmlRegisterType("org.kde.kwin.kwincompositing", 1, 0, "CompositingType"); init(type); } void EffectView::init(ViewType type) { KDeclarative::KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(engine()); kdeclarative.setTranslationDomain(QStringLiteral(TRANSLATION_DOMAIN)); kdeclarative.setupContext(); kdeclarative.setupEngine(engine()); QString path; switch (type) { case CompositingSettingsView: path = QStringLiteral("kwincompositing/qml/main-compositing.qml"); break; case DesktopEffectsView: path = QStringLiteral("kwincompositing/qml/main.qml"); break; } QString mainFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, path, QStandardPaths::LocateFile); setResizeMode(QQuickWidget::SizeRootObjectToView); setSource(QUrl(mainFile)); rootObject()->setProperty("color", KColorScheme(QPalette::Active, KColorScheme::Window, KSharedConfigPtr(0)).background(KColorScheme::NormalBackground).color()); connect(rootObject(), SIGNAL(changed()), this, SIGNAL(changed())); setMinimumSize(initialSize()); connect(rootObject(), SIGNAL(implicitWidthChanged()), this, SLOT(slotImplicitSizeChanged())); connect(rootObject(), SIGNAL(implicitHeightChanged()), this, SLOT(slotImplicitSizeChanged())); } void EffectView::save() { if (auto *model = rootObject()->findChild(QStringLiteral("filterModel"))) { model->syncConfig(); } if (auto *compositing = rootObject()->findChild(QStringLiteral("compositing"))) { compositing->save(); } } void EffectView::load() { if (auto *model = rootObject()->findChild(QStringLiteral("filterModel"))) { model->load(); } if (auto *compositing = rootObject()->findChild(QStringLiteral("compositing"))) { compositing->reset(); } } void EffectView::defaults() { if (auto *model = rootObject()->findChild(QStringLiteral("filterModel"))) { model->defaults(); } if (auto *compositing = rootObject()->findChild(QStringLiteral("compositing"))) { compositing->defaults(); } } void EffectView::slotImplicitSizeChanged() { setMinimumSize(QSize(rootObject()->property("implicitWidth").toInt(), rootObject()->property("implicitHeight").toInt())); } }//end namespace Compositing }//end namespace KWin