Add reloadEffect() and isEffectLoaded() and use them

svn path=/trunk/KDE/kdebase/workspace/; revision=669433
This commit is contained in:
Rivo Laks 2007-05-29 11:42:47 +00:00
parent 86c92d7985
commit e3d45c99f0
2 changed files with 29 additions and 18 deletions

View file

@ -64,9 +64,11 @@ void EffectsHandlerImpl::reconfigure()
KPluginInfo plugininfo( service );
plugininfo.load( &conf );
if( plugininfo.isPluginEnabled() )
bool isloaded = isEffectLoaded( plugininfo.pluginName() );
bool shouldbeloaded = plugininfo.isPluginEnabled();
if( shouldbeloaded && !isloaded)
loadEffect( plugininfo.pluginName() );
else
else if( !shouldbeloaded && isloaded )
unloadEffect( plugininfo.pluginName() );
}
}
@ -615,21 +617,10 @@ KLibrary* EffectsHandlerImpl::findEffectLibrary( const QString& effectname )
void EffectsHandlerImpl::toggleEffect( const QString& name )
{
assert( current_paint_screen == 0 );
assert( current_paint_window == 0 );
assert( current_draw_window == 0 );
assert( current_transform == 0 );
// 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++)
{
if( (*it).first == name )
{
unloadEffect( name );
return;
}
}
loadEffect( name );
if( isEffectLoaded( name ))
unloadEffect( name );
else
loadEffect( name );
}
void EffectsHandlerImpl::loadEffect( const QString& name )
@ -714,6 +705,24 @@ void EffectsHandlerImpl::unloadEffect( const QString& name )
kDebug( 1212 ) << "EffectsHandler::unloadEffect : Effect not loaded : " << name << endl;
}
void EffectsHandlerImpl::reloadEffect( const QString& name )
{
if( isEffectLoaded( name ))
{
unloadEffect( name );
loadEffect( name );
}
}
bool EffectsHandlerImpl::isEffectLoaded( const QString& name )
{
for( QVector< EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); it++)
if ( (*it).first == name )
return true;
return false;
}
//****************************************
// EffectWindowImpl

View file

@ -111,7 +111,9 @@ class EffectsHandlerImpl : public EffectsHandler
void loadEffect( const QString& name );
void toggleEffect( const QString& name );
void unloadEffect( const QString& name );
void reloadEffect( const QString& name );
bool isEffectLoaded( const QString& name );
ToplevelList elevatedWindows() const;
protected: