diff --git a/applet.cpp b/applet.cpp index a297c98e3..66f4a3551 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2005 by Aaron Seigo + * Copyright (C) 2007 by Riccardo Iaconelli * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License version 2 as @@ -758,6 +759,14 @@ KPluginInfo::List Applet::knownApplets(const QString &category, return KPluginInfo::fromServices(offers); } +KPluginInfo::List Applet::knownAppletsForMimetype(QString mimetype) +{ + QString constraint = QString("'%1' in [X-Plasma-Mimetypes]").arg(mimetype); + kDebug() << constraint << endl; + KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint); + return KPluginInfo::fromServices(offers); +} + QStringList Applet::knownCategories(const QString &parentApp) { QString constraint = "exist [X-KDE-PluginInfo-Category]"; diff --git a/applet.h b/applet.h index 2d3af1b6b..2195c786c 100644 --- a/applet.h +++ b/applet.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2006-2007 by Aaron Seigo + * Copyright (C) 2007 by Riccardo Iaconelli * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License version 2 as @@ -237,6 +238,14 @@ class PLASMA_EXPORT Applet : public QObject, public Widget static KPluginInfo::List knownApplets(const QString &category = QString(), const QString &parentApp = QString()); + /** + * Returns a list of all known applets associated with a certain mimetype in a hash keyed by a unique + * identifier for each applet + * + * @return list of applets + **/ + static KPluginInfo::List knownAppletsForMimetype(QString mimetype); + /** * Returns a list of all the categories used by * installed applets. diff --git a/corona.cpp b/corona.cpp index 16a058a4c..e69c55c78 100644 --- a/corona.cpp +++ b/corona.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2007 Matt Broadstone * Copyright (C) 2007 Aaron Seigo + * Copyright (C) 2007 Riccardo Iaconelli * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License version 2 as @@ -252,11 +253,20 @@ void Corona::dropEvent(QGraphicsSceneDragDropEvent *event) } else if (KUrl::List::canDecode(event->mimeData())) { KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); foreach (const KUrl& url, urls) { + KMimeType::Ptr mime = KMimeType::findByUrl(url); + QString mimeName = mime->name(); +// kDebug() << mimeName << endl; + KPluginInfo::List appletList = Applet::knownAppletsForMimetype(mimeName); + + + //FIXME: we should probably show a dialog here to choose which plasmoid load. + addApplet(appletList.first().pluginName()); + QStringList args; args << url.url(); Applet* button = addApplet("url", args); if (button) { - //button->setSize(128,128); +// button->setSize(128,128); button->setPos(event->scenePos() - QPoint(button->boundingRect().width()/2, button->boundingRect().height()/2)); } diff --git a/package.cpp b/package.cpp index bedd7beb9..1ec658b4c 100644 --- a/package.cpp +++ b/package.cpp @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2007 by Aaron Seigo * +* Copyright (C) 2007 by Riccardo Iaconelli * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * diff --git a/package.h b/package.h index 4467a3b6c..3b1ccb8b0 100644 --- a/package.h +++ b/package.h @@ -1,5 +1,6 @@ /****************************************************************************** * Copyright (C) 2007 by Aaron Seigo * +* Copyright (C) 2007 by Riccardo Iaconelli * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * diff --git a/widgets/icon.cpp b/widgets/icon.cpp index 40343a4f9..f4b0e6929 100644 --- a/widgets/icon.cpp +++ b/widgets/icon.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2007 by Aaron Seigo aseigo@kde.org + * Copyright (C) 2007 by Aaron Seigo + * Copyright (C) 2007 by Riccardo Iaconelli * Copyright (C) 2007 by Matt Broadstone * * This program is free software; you can redistribute it and/or modify diff --git a/widgets/icon.h b/widgets/icon.h index 7dd459a61..76ba7f4d8 100644 --- a/widgets/icon.h +++ b/widgets/icon.h @@ -1,5 +1,6 @@ /* -* Copyright (C) 2007 by Siraj Razick siraj@kde.org +* Copyright (C) 2007 by Siraj Razick +* Copyright (C) 2007 by Riccardo Iaconelli * Copyright (C) 2007 by Matt Broadstone * * This program is free software; you can redistribute it and/or modify