[kcmkwin/compositing] Use BuiltinEffects to find all built-in effects
The EffectData in BuiltinEffects is extended by all the data needed for the desktop effects KCM: * display name * comment * category * video-url * exclusive group * internal This information is taken directly from the desktop files. The Built-in effects are now also resolved through the BuiltInEffects namespace and the KServiceTypeTrader query is adjusted to only find the scripted effects. Unfortunately this introduces another round of adding "kwin4_effect_" to load and save the effects correctly. This will be removed once all KCMs are adjusted to use the new BuiltInEffects.
This commit is contained in:
parent
3e32bf9f56
commit
a784c91844
5 changed files with 322 additions and 24 deletions
|
@ -73,252 +73,484 @@ inline Effect *createHelper()
|
|||
return new T();
|
||||
}
|
||||
|
||||
struct EffectData {
|
||||
QString name;
|
||||
bool enabled;
|
||||
std::function<Effect*()> createFunction;
|
||||
std::function<bool()> supportedFunction;
|
||||
std::function<bool()> enabledFunction;
|
||||
};
|
||||
|
||||
static const QVector<EffectData> s_effectData = {
|
||||
{
|
||||
QString(),
|
||||
QString(),
|
||||
QString(),
|
||||
QString(),
|
||||
QString(),
|
||||
QUrl(),
|
||||
false,
|
||||
false,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("blur"),
|
||||
i18nc("Name of a KWin Effect", "Blur"),
|
||||
i18nc("Comment describing the KWin Effect", "Blurs the background behind semi-transparent windows"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
true,
|
||||
false,
|
||||
&createHelper<BlurEffect>,
|
||||
&BlurEffect::supported,
|
||||
&BlurEffect::enabledByDefault
|
||||
}, {
|
||||
QStringLiteral("contrast"),
|
||||
i18nc("Name of a KWin Effect", "Background contrast"),
|
||||
i18nc("Comment describing the KWin Effect", "Improve contrast and readability behind semi-transparent windows"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
true,
|
||||
false,
|
||||
&createHelper<ContrastEffect>,
|
||||
&ContrastEffect::supported,
|
||||
&ContrastEffect::enabledByDefault
|
||||
}, {
|
||||
QStringLiteral("coverswitch"),
|
||||
i18nc("Name of a KWin Effect", "Cover Switch"),
|
||||
i18nc("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,
|
||||
&createHelper<CoverSwitchEffect>,
|
||||
&CoverSwitchEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("cube"),
|
||||
i18nc("Name of a KWin Effect", "Desktop Cube"),
|
||||
i18nc("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,
|
||||
&createHelper<CubeEffect>,
|
||||
&CubeEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("cubeslide"),
|
||||
i18nc("Name of a KWin Effect", "Desktop Cube Animation"),
|
||||
i18nc("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,
|
||||
&createHelper<CubeSlideEffect>,
|
||||
&CubeSlideEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("dashboard"),
|
||||
i18nc("Name of a KWin Effect", "Dashboard"),
|
||||
i18nc("Comment describing the KWin Effect", "Desaturate the desktop when displaying the Plasma dashboard"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
true,
|
||||
true,
|
||||
&createHelper<DashboardEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("desktopgrid"),
|
||||
i18nc("Name of a KWin Effect", "Desktop Grid"),
|
||||
i18nc("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,
|
||||
&createHelper<DesktopGridEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("diminactive"),
|
||||
i18nc("Name of a KWin Effect", "Dim Inactive"),
|
||||
i18nc("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,
|
||||
&createHelper<DimInactiveEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("dimscreen"),
|
||||
i18nc("Name of a KWin Effect", "Dim Screen for Administrator Mode"),
|
||||
i18nc("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,
|
||||
&createHelper<DimScreenEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("fallapart"),
|
||||
i18nc("Name of a KWin Effect", "Fall Apart"),
|
||||
i18nc("Comment describing the KWin Effect", "Closed windows fall into pieces"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
false,
|
||||
false,
|
||||
&createHelper<FallApartEffect>,
|
||||
&FallApartEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("flipswitch"),
|
||||
i18nc("Name of a KWin Effect", "Flip Switch"),
|
||||
i18nc("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,
|
||||
&createHelper<FlipSwitchEffect>,
|
||||
&FlipSwitchEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("glide"),
|
||||
i18nc("Name of a KWin Effect", "Glide"),
|
||||
i18nc("Comment describing the KWin Effect", "Windows Glide Effect as they are open and closed"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
false,
|
||||
false,
|
||||
&createHelper<GlideEffect>,
|
||||
&GlideEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("highlightwindow"),
|
||||
i18nc("Name of a KWin Effect", "Highlight Window"),
|
||||
i18nc("Comment describing the KWin Effect", "Highlight the appropriate window when hovering over taskbar entries"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
true,
|
||||
true,
|
||||
&createHelper<HighlightWindowEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("invert"),
|
||||
i18nc("Name of a KWin Effect", "Invert"),
|
||||
i18nc("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,
|
||||
&createHelper<InvertEffect>,
|
||||
&InvertEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("kscreen"),
|
||||
i18nc("Name of a KWin Effect", "Kscreen"),
|
||||
i18nc("Comment describing the KWin Effect", "Helper Effect for KScreen"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
true,
|
||||
true,
|
||||
&createHelper<KscreenEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("logout"),
|
||||
i18nc("Name of a KWin Effect", "Logout"),
|
||||
i18nc("Comment describing the KWin Effect", "Desaturate the desktop when displaying the logout dialog"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
true,
|
||||
false,
|
||||
&createHelper<LogoutEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("lookingglass"),
|
||||
i18nc("Name of a KWin Effect", "Looking Glass"),
|
||||
i18nc("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,
|
||||
&createHelper<LookingGlassEffect>,
|
||||
&LookingGlassEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("magiclamp"),
|
||||
i18nc("Name of a KWin Effect", "Magic Lamp"),
|
||||
i18nc("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,
|
||||
&createHelper<MagicLampEffect>,
|
||||
&MagicLampEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("magnifier"),
|
||||
i18nc("Name of a KWin Effect", "Magnifier"),
|
||||
i18nc("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,
|
||||
&createHelper<MagnifierEffect>,
|
||||
&MagnifierEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("minimizeanimation"),
|
||||
i18nc("Name of a KWin Effect", "Minimize Animation"),
|
||||
i18nc("Comment describing the KWin Effect", "Animate the minimizing of windows"),
|
||||
QStringLiteral("Appearance"),
|
||||
QStringLiteral("minimize"),
|
||||
QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/minimize.ogv")),
|
||||
true,
|
||||
false,
|
||||
&createHelper<MinimizeAnimationEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("mouseclick"),
|
||||
i18nc("Name of a KWin Effect", "Mouse Click Animation"),
|
||||
i18nc("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,
|
||||
&createHelper<MouseClickEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("mousemark"),
|
||||
i18nc("Name of a KWin Effect", "Mouse Mark"),
|
||||
i18nc("Comment describing the KWin Effect", "Allows you to draw lines on the desktop"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
false,
|
||||
false,
|
||||
&createHelper<MouseMarkEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("presentwindows"),
|
||||
i18nc("Name of a KWin Effect", "Present Windows"),
|
||||
i18nc("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,
|
||||
&createHelper<PresentWindowsEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("resize"),
|
||||
i18nc("Name of a KWin Effect", "Resize Window"),
|
||||
i18nc("Comment describing the KWin Effect", "Resizes windows with a fast texture scale instead of updating contents"),
|
||||
QStringLiteral("Window Management"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
false,
|
||||
false,
|
||||
&createHelper<ResizeEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("screenedge"),
|
||||
i18nc("Name of a KWin Effect", "Screen Edge"),
|
||||
i18nc("Comment describing the KWin Effect", "Highlights a screen edge when approaching"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
true,
|
||||
false,
|
||||
&createHelper<ScreenEdgeEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("screenshot"),
|
||||
i18nc("Name of a KWin Effect", "Screenshot"),
|
||||
i18nc("Comment describing the KWin Effect", "Helper effect for KSnapshot"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
true,
|
||||
true,
|
||||
&createHelper<ScreenShotEffect>,
|
||||
&ScreenShotEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("sheet"),
|
||||
i18nc("Name of a KWin Effect", "Sheet"),
|
||||
i18nc("Comment describing the KWin Effect", "Make modal dialogs smoothly fly in and out when they are shown or hidden"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
false,
|
||||
false,
|
||||
&createHelper<SheetEffect>,
|
||||
&SheetEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("showfps"),
|
||||
i18nc("Name of a KWin Effect", "Show FPS"),
|
||||
i18nc("Comment describing the KWin Effect", "Display KWin's performance in the corner of the screen"),
|
||||
QStringLiteral("Tools"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
false,
|
||||
false,
|
||||
&createHelper<ShowFpsEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("showpaint"),
|
||||
i18nc("Name of a KWin Effect", "Show Paint"),
|
||||
i18nc("Comment describing the KWin Effect", "Highlight areas of the desktop that have been recently updated"),
|
||||
QStringLiteral("Tools"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
false,
|
||||
false,
|
||||
&createHelper<ShowPaintEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("slide"),
|
||||
i18nc("Name of a KWin Effect", "Slide"),
|
||||
i18nc("Comment describing the KWin Effect", "Slide windows across the screen 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,
|
||||
&createHelper<SlideEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("slideback"),
|
||||
i18nc("Name of a KWin Effect", "Slide Back"),
|
||||
i18nc("Comment describing the KWin Effect", "Slide back windows when another window is raised"),
|
||||
QStringLiteral("Focus"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
false,
|
||||
false,
|
||||
&createHelper<SlideBackEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("slidingpopups"),
|
||||
i18nc("Name of a KWin Effect", "Sliding popups"),
|
||||
i18nc("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,
|
||||
&createHelper<SlidingPopupsEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("snaphelper"),
|
||||
i18nc("Name of a KWin Effect", "Snap Helper"),
|
||||
i18nc("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,
|
||||
&createHelper<SnapHelperEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("startupfeedback"),
|
||||
i18nc("Name of a KWin Effect", "Startup Feedback"),
|
||||
i18nc("Comment describing the KWin Effect", "Helper effect for startup feedback"),
|
||||
QStringLiteral("Candy"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
true,
|
||||
true,
|
||||
&createHelper<StartupFeedbackEffect>,
|
||||
&StartupFeedbackEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("thumbnailaside"),
|
||||
i18nc("Name of a KWin Effect", "Thumbnail Aside"),
|
||||
i18nc("Comment describing the KWin Effect", "Display window thumbnails on the edge of the screen"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
false,
|
||||
false,
|
||||
&createHelper<ThumbnailAsideEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("trackmouse"),
|
||||
i18nc("Name of a KWin Effect", "Track Mouse"),
|
||||
i18nc("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,
|
||||
&createHelper<TrackMouseEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("windowgeometry"),
|
||||
i18nc("Name of a KWin Effect", "Window Geometry"),
|
||||
i18nc("Comment describing the KWin Effect", "Display window geometries on move/resize"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
false,
|
||||
true,
|
||||
&createHelper<WindowGeometry>,
|
||||
nullptr,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("wobblywindows"),
|
||||
i18nc("Name of a KWin Effect", "Wobbly Windows"),
|
||||
i18nc("Comment describing the KWin Effect", "Deform windows while they are moving"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(QStringLiteral("http://files.kde.org/plasma/kwin/effect-videos/wobbly_windows.ogv")),
|
||||
false,
|
||||
false,
|
||||
&createHelper<WobblyWindowsEffect>,
|
||||
&WobblyWindowsEffect::supported,
|
||||
nullptr
|
||||
}, {
|
||||
QStringLiteral("zoom"),
|
||||
i18nc("Name of a KWin Effect", "Zoom"),
|
||||
i18nc("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,
|
||||
&createHelper<ZoomEffect>,
|
||||
nullptr,
|
||||
nullptr
|
||||
|
@ -418,6 +650,11 @@ QString nameForEffect(BuiltInEffect effect)
|
|||
return s_effectData.at(index(effect)).name;
|
||||
}
|
||||
|
||||
const EffectData &effectData(BuiltInEffect effect)
|
||||
{
|
||||
return s_effectData.at(index(effect));
|
||||
}
|
||||
|
||||
} // BuiltInEffects
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define KWIN_EFFECT_BUILTINS_H
|
||||
#include <kwineffects_export.h>
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -76,6 +77,20 @@ enum class BuiltInEffect
|
|||
namespace BuiltInEffects
|
||||
{
|
||||
|
||||
struct EffectData {
|
||||
QString name;
|
||||
QString displayName;
|
||||
QString comment;
|
||||
QString category;
|
||||
QString exclusiveCategory;
|
||||
QUrl video;
|
||||
bool enabled;
|
||||
bool internal;
|
||||
std::function<Effect*()> createFunction;
|
||||
std::function<bool()> supportedFunction;
|
||||
std::function<bool()> enabledFunction;
|
||||
};
|
||||
|
||||
KWINEFFECTS_EXPORT Effect *create(BuiltInEffect effect);
|
||||
KWINEFFECTS_EXPORT bool available(const QString &name);
|
||||
KWINEFFECTS_EXPORT bool supported(BuiltInEffect effect);
|
||||
|
@ -85,6 +100,7 @@ KWINEFFECTS_EXPORT QString nameForEffect(BuiltInEffect effect);
|
|||
KWINEFFECTS_EXPORT BuiltInEffect builtInForName(const QString &name);
|
||||
KWINEFFECTS_EXPORT QStringList availableEffectNames();
|
||||
KWINEFFECTS_EXPORT QList<BuiltInEffect> availableEffects();
|
||||
KWINEFFECTS_EXPORT const EffectData &effectData(BuiltInEffect effect);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
|
|||
|
||||
remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_STRICT_ITERATORS -DQT_NO_CAST_FROM_BYTEARRAY)
|
||||
|
||||
include_directories(${KWIN_SOURCE_DIR}/effects)
|
||||
|
||||
################# configure checks and create the configured files #################
|
||||
|
||||
# now create config headers
|
||||
|
@ -36,6 +38,7 @@ target_link_libraries(kwincompositing
|
|||
KF5::KCMUtils
|
||||
KF5::NewStuff
|
||||
KF5::Declarative
|
||||
kwin4_effect_builtins
|
||||
)
|
||||
|
||||
|
||||
|
@ -66,7 +69,9 @@ target_link_libraries(effectModelTest
|
|||
KF5::Service
|
||||
KF5::KCMUtils
|
||||
KF5::NewStuff
|
||||
KF5::Declarative)
|
||||
KF5::Declarative
|
||||
kwin4_effect_builtins
|
||||
)
|
||||
|
||||
INSTALL(DIRECTORY qml DESTINATION ${DATA_INSTALL_DIR}/kwincompositing)
|
||||
INSTALL(TARGETS kwincompositing DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
|
|
|
@ -66,6 +66,13 @@ void EffectConfig::openConfig(const QString &serviceName, bool scripted)
|
|||
kcm = KPluginTrader::createInstanceFromQuery<KCModule>(s_pluginDir, QString(),
|
||||
QStringLiteral("[X-KDE-ParentComponents] == '%1'").arg(serviceName),
|
||||
&dialog);
|
||||
if (!kcm) {
|
||||
// HACK: try again with "kwin4_effect_"<serviceName>
|
||||
const QString name = QStringLiteral("kwin4_effect_") + serviceName;
|
||||
kcm = KPluginTrader::createInstanceFromQuery<KCModule>(s_pluginDir, QString(),
|
||||
QStringLiteral("[X-KDE-ParentComponents] == '%1'").arg(name),
|
||||
&dialog);
|
||||
}
|
||||
}
|
||||
if (!kcm) {
|
||||
return;
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
#include "model.h"
|
||||
#include "effectconfig.h"
|
||||
#include "compositing.h"
|
||||
#include <config-kwin.h>
|
||||
#include <kwin_effects_interface.h>
|
||||
#include <effect_builtins.h>
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <KPluginInfo>
|
||||
|
@ -214,17 +216,44 @@ bool EffectModel::setData(const QModelIndex& index, const QVariant& value, int r
|
|||
|
||||
void EffectModel::loadEffects()
|
||||
{
|
||||
EffectData effect;
|
||||
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins");
|
||||
|
||||
beginResetModel();
|
||||
m_effectsChanged.clear();
|
||||
m_effectsList.clear();
|
||||
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
|
||||
const KPluginInfo::List configs = KPluginTrader::self()->query(QStringLiteral("kf5/kwin/effects/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.effectStatus = kwinConfig.readEntry(QStringLiteral("kwin4_effect_") + effect.serviceName + "Enabled", 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() == QStringLiteral("kwin4_effect_") + data.name;
|
||||
});
|
||||
effect.configurable = it != configs.end();
|
||||
|
||||
m_effectsList << effect;
|
||||
}
|
||||
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect", QStringLiteral("[X-Plasma-API] == 'javascript'"));
|
||||
for(KService::Ptr service : offers) {
|
||||
const QString effectPluginPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kservices5/"+ service->entryPath(), QStandardPaths::LocateFile);
|
||||
KPluginInfo plugin(effectPluginPath);
|
||||
EffectData effect;
|
||||
|
||||
effect.name = plugin.name();
|
||||
effect.description = plugin.comment();
|
||||
|
@ -240,15 +269,13 @@ void EffectModel::loadEffects()
|
|||
effect.supported = true;
|
||||
effect.exclusiveGroup = service->property(QStringLiteral("X-KWin-Exclusive-Category"), QVariant::String).toString();
|
||||
effect.internal = service->property(QStringLiteral("X-KWin-Internal"), QVariant::Bool).toBool();
|
||||
effect.scripted = service->property(QStringLiteral("X-Plasma-API"), QVariant::String).toString().toLower() == QStringLiteral("javascript");
|
||||
effect.scripted = true;
|
||||
|
||||
auto it = std::find_if(configs.begin(), configs.end(), [&plugin](const KPluginInfo &info) {
|
||||
return info.property(QStringLiteral("X-KDE-ParentComponents")).toString() == plugin.pluginName();
|
||||
});
|
||||
effect.configurable = it != configs.end();
|
||||
if (!effect.configurable && effect.scripted && !service->pluginKeyword().isEmpty()) {
|
||||
if (!service->pluginKeyword().isEmpty()) {
|
||||
// scripted effects have their pluginName() as the keyword
|
||||
effect.configurable = service->property(QStringLiteral("X-KDE-ParentComponents")).toString() == service->pluginKeyword();
|
||||
} else {
|
||||
effect.configurable = false;
|
||||
}
|
||||
|
||||
m_effectsList << effect;
|
||||
|
@ -351,15 +378,21 @@ void EffectModel::syncConfig()
|
|||
{
|
||||
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins");
|
||||
|
||||
for (auto it = m_effectsList.begin(); it != m_effectsList.end(); it++) {
|
||||
EffectData effect = *(it);
|
||||
for (auto it = m_effectsList.constBegin(); it != m_effectsList.constEnd(); it++) {
|
||||
const EffectData &effect = *(it);
|
||||
|
||||
bool effectConfigStatus = kwinConfig.readEntry(effect.serviceName + "Enabled", false);
|
||||
QString key = effect.serviceName + QStringLiteral("Enabled");
|
||||
// HACK: workaround for built-in effects, needs to be removed once everything is transited to new names
|
||||
if (!key.startsWith(QStringLiteral("kwin4_effect_"))) {
|
||||
key = QStringLiteral("kwin4_effect_") + key;
|
||||
}
|
||||
|
||||
if (effect.effectStatus) {
|
||||
kwinConfig.writeEntry(effect.serviceName + "Enabled", effect.effectStatus);
|
||||
} else if (effect.effectStatus != effectConfigStatus) {
|
||||
kwinConfig.writeEntry(effect.serviceName + "Enabled", effect.effectStatus);
|
||||
const bool effectConfigStatus = kwinConfig.readEntry(key, effect.enabledByDefault);
|
||||
|
||||
if (effect.effectStatus != effectConfigStatus) {
|
||||
kwinConfig.writeEntry(key, effect.effectStatus);
|
||||
} else {
|
||||
kwinConfig.deleteEntry(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue