Move Runner plugins code out of Interface::loadPlugins and into Runner

as indicated in Tasks.

A simple static function does the job IMHO, but if we want something
like a RunnerLoader/Trader class (which can also load a specified
single runner?) I can work on that.

One more question in mind :). Should we make all runners loadable in
runtime?


svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=638445
This commit is contained in:
Barış Metin 2007-03-02 00:06:52 +00:00
parent 585852a0de
commit 248e733a1f
2 changed files with 24 additions and 0 deletions

View File

@ -18,6 +18,7 @@
#include <QAction>
#include <KActionCollection>
#include <KServiceTypeTrader>
#include "runner.h"
@ -94,4 +95,22 @@ void Runner::runExactMatch()
exec( d->term );
}
Runner::List Runner::loadRunners( QWidget* parent )
{
List runners;
KService::List offers = KServiceTypeTrader::self()->query( "KRunner/Runner" );
foreach ( KService::Ptr service, offers ) {
Runner* runner = KService::createInstance<Runner>( service, parent );
if ( runner ) {
kDebug() << "loaded runner : " << service->name() << endl ;
runners.append( runner );
}
else {
kDebug() << "failed to load runner : " << service->name() << endl ;
}
}
return runners;
}
#include "runner.moc"

View File

@ -60,6 +60,11 @@ class KDE_EXPORT Runner : public QObject
KActionCollection* matches( const QString& term, int max, int offset );
/**
* Static method is called to load and get a list available of Runners.
*/
static List loadRunners( QWidget* parent );
signals:
/**
* When emitted, the interface will update itself to show the new