Move all .desktop files of effects to $SERVICES_DIR/kwin and use ksycoca to e.g. get list of available effects.
As effect's full internal name is used when looking up the effect, you now need to provide the full name (e.g. kwin4_effect_blur instead of just blur) when loading effects via dcop. svn path=/trunk/KDE/kdebase/workspace/; revision=669032
This commit is contained in:
parent
6118496212
commit
2ace94d3c8
3 changed files with 27 additions and 21 deletions
26
effects.cpp
26
effects.cpp
|
@ -25,6 +25,9 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#include "kdesktopfile.h"
|
||||
#include "kconfiggroup.h"
|
||||
#include "kstandarddirs.h"
|
||||
#include <kservice.h>
|
||||
#include <kservicetypetrader.h>
|
||||
#include <kplugininfo.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -37,8 +40,6 @@ EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type)
|
|||
: EffectsHandler(type)
|
||||
, keyboard_grab_effect( NULL )
|
||||
{
|
||||
foreach( const QString& effect, options->defaultEffects )
|
||||
loadEffect( effect );
|
||||
}
|
||||
|
||||
EffectsHandlerImpl::~EffectsHandlerImpl()
|
||||
|
@ -571,17 +572,17 @@ unsigned long EffectsHandlerImpl::xrenderBufferPicture()
|
|||
|
||||
KLibrary* EffectsHandlerImpl::findEffectLibrary( const QString& effectname )
|
||||
{
|
||||
QString libname = "kwin4_effect_" + effectname.toLower();
|
||||
QString internalname = effectname.toLower();
|
||||
|
||||
QString desktopfile = KStandardDirs::locate("appdata",
|
||||
"effects/" + effectname.toLower() + ".desktop");
|
||||
if( !desktopfile.isEmpty() )
|
||||
{
|
||||
KDesktopFile desktopconf( desktopfile );
|
||||
KConfigGroup conf = desktopconf.desktopGroup();
|
||||
libname = conf.readEntry( "X-KDE-Library", libname );
|
||||
}
|
||||
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(internalname);
|
||||
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect", constraint);
|
||||
if(offers.isEmpty())
|
||||
{
|
||||
kError( 1212 ) << k_funcinfo << "Couldn't find effect " << effectname << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString libname = offers.first()->library();
|
||||
KLibrary* library = KLibLoader::self()->library(libname);
|
||||
if( !library )
|
||||
{
|
||||
|
@ -620,6 +621,9 @@ void EffectsHandlerImpl::loadEffect( const QString& name )
|
|||
assert( current_draw_window == 0 );
|
||||
assert( current_transform == 0 );
|
||||
|
||||
if( !name.startsWith("kwin4_effect_") )
|
||||
kWarning( 1212 ) << k_funcinfo << "Effect names usually have kwin4_effect_ prefix" << endl;
|
||||
|
||||
// Make sure a single effect won't be loaded multiple times
|
||||
for(QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); it++)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Adds effect plugin with given name. Sources are given after the name
|
||||
macro(KWIN4_ADD_EFFECT name)
|
||||
kde4_automoc(kwin4_effect_${name} ${ARGN})
|
||||
kde4_automoc(${ARGN})
|
||||
kde4_add_plugin(kwin4_effect_${name} ${ARGN})
|
||||
target_link_libraries(kwin4_effect_${name} kwineffects ${KDE4_KDEUI_LIBS})
|
||||
install(TARGETS kwin4_effect_${name} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
|
@ -10,6 +10,8 @@ include_directories(
|
|||
${CMAKE_SOURCE_DIR}/workspace/kwin/lib
|
||||
)
|
||||
|
||||
install( FILES kwineffect.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
|
||||
|
||||
|
||||
|
||||
### builtins - most important, ready-to-use effects
|
||||
|
@ -44,7 +46,7 @@ install( FILES
|
|||
scalein.desktop
|
||||
thumbnailaside.desktop
|
||||
zoom.desktop
|
||||
DESTINATION ${DATA_INSTALL_DIR}/kwin/effects )
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
||||
|
||||
if(OPENGL_FOUND)
|
||||
# opengl-based effects
|
||||
|
@ -63,7 +65,7 @@ if(OPENGL_FOUND)
|
|||
mousemark.desktop
|
||||
shadow.desktop
|
||||
trackmouse.desktop
|
||||
DESTINATION ${DATA_INSTALL_DIR}/kwin/effects )
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
||||
install( FILES
|
||||
data/trackmouse.png
|
||||
data/explosion.frag
|
||||
|
@ -84,7 +86,7 @@ if( OPENGL_FOUND AND X11_Xrender_FOUND )
|
|||
)
|
||||
install( FILES
|
||||
showfps.desktop
|
||||
DESTINATION ${DATA_INSTALL_DIR}/kwin/effects )
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
||||
endif( OPENGL_FOUND AND X11_Xrender_FOUND )
|
||||
|
||||
# add the plugin
|
||||
|
@ -115,7 +117,7 @@ install( FILES
|
|||
shakymove.desktop
|
||||
test_input.desktop
|
||||
test_thumbnail.desktop
|
||||
DESTINATION ${DATA_INSTALL_DIR}/kwin/effects )
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
||||
|
||||
if(OPENGL_FOUND)
|
||||
# opengl test/demo stuff
|
||||
|
@ -131,7 +133,7 @@ if(OPENGL_FOUND)
|
|||
demo_showpicture.desktop
|
||||
test_fbo.desktop
|
||||
wavywindows.desktop
|
||||
DESTINATION ${DATA_INSTALL_DIR}/kwin/effects )
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
||||
|
||||
install( FILES
|
||||
data/liquid.frag
|
||||
|
@ -154,6 +156,6 @@ macro_bool_to_01( CAPTURY_FOUND HAVE_CAPTURY )
|
|||
if( HAVE_CAPTURY )
|
||||
KWIN4_ADD_EFFECT(videorecord videorecord.cpp)
|
||||
target_link_libraries(kwin4_effect_videorecord ${CAPTURY_LDFLAGS})
|
||||
install( FILES videorecord.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin/effects )
|
||||
install( FILES videorecord.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
||||
endif( HAVE_CAPTURY )
|
||||
|
||||
|
|
|
@ -12,12 +12,12 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
|
||||
#include <kgenericfactory.h>
|
||||
#include <kaboutdata.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <kconfig.h>
|
||||
#include <kdebug.h>
|
||||
#include <kpluginselector.h>
|
||||
#include <kservicetypetrader.h>
|
||||
#include <kplugininfo.h>
|
||||
#include <kservice.h>
|
||||
|
||||
#include <QtDBus/QtDBus>
|
||||
#include <QBoxLayout>
|
||||
|
@ -46,8 +46,8 @@ KWinEffectsConfig::KWinEffectsConfig(QWidget *parent, const QStringList &)
|
|||
connect(mPluginSelector, SIGNAL(changed(bool)), this, SLOT(changed()));
|
||||
|
||||
// Find all .desktop files of the effects
|
||||
QStringList desktopFiles = KGlobal::dirs()->findAllResources("data", "kwin/effects/*.desktop");
|
||||
QList<KPluginInfo*> effectinfos = KPluginInfo::fromFiles(desktopFiles);
|
||||
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
|
||||
QList<KPluginInfo*> effectinfos = KPluginInfo::fromServices(offers);
|
||||
|
||||
// Add them to the plugin selector
|
||||
mPluginSelector->addPlugins(effectinfos, i18n("Appearance"), "Appearance", mKWinConfig);
|
||||
|
|
Loading…
Reference in a new issue