make Applet use the newer plugin loading mechanisms

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=705972
This commit is contained in:
Aaron J. Seigo 2007-08-29 02:33:22 +00:00
parent c911115b10
commit 559647f5cc
6 changed files with 23 additions and 25 deletions

View File

@ -342,9 +342,9 @@ Applet::Applet(QGraphicsItem *parent,
d->init(this);
}
Applet::Applet(QObject* parentObject, const QStringList& args)
Applet::Applet(QObject* parentObject, const QVariantList& args)
: Widget(0,parentObject),
d(new Private(KService::serviceByStorageId(args.count() > 0 ? args[0] : QString()),
d(new Private(KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString()),
args.count() > 1 ? args[1].toInt() : 0))
{
d->init(this);
@ -689,7 +689,7 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
d->shadow->generate();
}
qreal zoomLevel = painter->transform().m11() / transform().m11();
//qreal zoomLevel = painter->transform().m11() / transform().m11();
//kDebug() << "qreal " << zoomLevel << " = " << painter->transform().m11() << " / " << transform().m11();
//if (fabs(zoomLevel - scalingFactor(Plasma::DesktopZoom)) < std::numeric_limits<double>::epsilon()) { // Show Desktop
if (d->background) {
@ -911,7 +911,7 @@ QStringList Applet::knownCategories(const QString &parentApp)
return categories;
}
Applet* Applet::loadApplet(const QString& appletName, uint appletId, const QStringList& args)
Applet* Applet::loadApplet(const QString& appletName, uint appletId, const QVariantList& args)
{
if (appletName.isEmpty()) {
return 0;
@ -931,20 +931,19 @@ Applet* Applet::loadApplet(const QString& appletName, uint appletId, const QStri
appletId = Private::nextId();
}
QStringList allArgs;
QString id;
id.setNum(appletId);
allArgs << offers.first()->storageId() << id << args;
Applet* applet = KService::createInstance<Plasma::Applet>(offers.first(), 0, allArgs);
QVariantList allArgs;
allArgs << offers.first()->storageId() << appletId << args;
QString error;
Applet* applet = KService::createInstance<Plasma::Applet>(offers.first(), 0, allArgs, &error);
if (!applet) {
kDebug() << "Couldn't load applet \"" << appletName << "\"!";
kDebug() << "Couldn't load applet \"" << appletName << "\"! reason given: " << error;
}
return applet;
}
Applet* Applet::loadApplet(const KPluginInfo& info, uint appletId, const QStringList& args)
Applet* Applet::loadApplet(const KPluginInfo& info, uint appletId, const QVariantList& args)
{
if (!info.isValid()) {
return 0;

View File

@ -91,7 +91,7 @@ class PLASMA_EXPORT Applet : public Widget
* @arg args a list of strings containing two entries: the service id
* and the applet id
*/
Applet(QObject* parent, const QStringList& args);
Applet(QObject* parent, const QVariantList& args);
~Applet();
@ -300,7 +300,7 @@ class PLASMA_EXPORT Applet : public Widget
* @return a pointer to the loaded applet, or 0 on load failure
**/
static Applet* loadApplet(const QString &name, uint appletId = 0,
const QStringList& args = QStringList());
const QVariantList& args = QVariantList());
/**
* Attempts to load an applet
@ -315,7 +315,7 @@ class PLASMA_EXPORT Applet : public Widget
* @return a pointer to the loaded applet, or 0 on load failure
**/
static Applet* loadApplet(const KPluginInfo& info, uint appletId = 0,
const QStringList& args = QStringList());
const QVariantList& args = QVariantList());
/**
* This method is called when the interface should be painted.
@ -579,8 +579,7 @@ class PLASMA_EXPORT Applet : public Widget
* Register an applet when it is contained in a loadable module
*/
#define K_EXPORT_PLASMA_APPLET(libname, classname) \
K_EXPORT_COMPONENT_FACTORY( \
plasma_applet_##libname, \
KGenericFactory<classname>("plasma_applet_" #libname))
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
K_EXPORT_PLUGIN(factory("plasma_applet_" #libname))
#endif // multiple inclusion guard

View File

@ -192,11 +192,11 @@ void Corona::saveApplets() const
void Corona::loadApplets(const QString& config)
{
clearApplets();
KConfig appletConfig(config, KConfig::OnlyLocal);
foreach (const QString& group, appletConfig.groupList()) {
KConfigGroup cg(&appletConfig, group);
addApplet(cg.readEntry("plugin", QString()), QStringList(),
addApplet(cg.readEntry("plugin", QString()), QVariantList(),
group.toUInt(), cg.readEntry("geometry", QRectF()));
}
}
@ -212,7 +212,7 @@ void Corona::clearApplets()
d->applets.clear();
}
Applet* Corona::addApplet(const QString& name, const QStringList& args, uint id, const QRectF& geometry)
Applet* Corona::addApplet(const QString& name, const QVariantList& args, uint id, const QRectF& geometry)
{
Applet* applet = Applet::loadApplet(name, id, args);
if (!applet) {
@ -303,7 +303,7 @@ void Corona::dropEvent(QGraphicsSceneDragDropEvent *event)
QString plasmoidName;
plasmoidName = event->mimeData()->data(d->mimetype);
QRectF geom(event->scenePos(), QSize(0, 0));
addApplet(plasmoidName, QStringList(), 0, geom);
addApplet(plasmoidName, QVariantList(), 0, geom);
event->acceptProposedAction();
} else if (KUrl::List::canDecode(event->mimeData())) {
KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
@ -311,7 +311,7 @@ void Corona::dropEvent(QGraphicsSceneDragDropEvent *event)
KMimeType::Ptr mime = KMimeType::findByUrl(url);
QString mimeName = mime->name();
QRectF geom(event->scenePos(), QSize(0, 0));
QStringList args;
QVariantList args;
args << url.url();
// kDebug() << mimeName;
KPluginInfo::List appletList = Applet::knownAppletsForMimetype(mimeName);

View File

@ -134,7 +134,7 @@ public Q_SLOTS:
*
* @return a pointer to the applet on success, or 0 on failure
*/
Applet* addApplet(const QString& name, const QStringList& args = QStringList(),
Applet* addApplet(const QString& name, const QVariantList& args = QVariantList(),
uint id = 0, const QRectF &geometry = QRectF(-1, -1, -1, -1));
/**

View File

@ -74,7 +74,7 @@ GLApplet::GLApplet(QGraphicsItem *parent,
}
}
GLApplet::GLApplet(QObject *parent, const QStringList &args)
GLApplet::GLApplet(QObject *parent, const QVariantList &args)
: Applet(parent, args),
d(new Private)
{

View File

@ -56,7 +56,7 @@ class PLASMA_EXPORT GLApplet : public Applet
* @arg args a list of strings containing two entries: the service id
* and the applet id
*/
GLApplet(QObject *parent, const QStringList &args);
GLApplet(QObject *parent, const QVariantList &args);
~GLApplet();