The applets now can associate with (one or more) certain mimetypes, and be called when that mime is dragged onto the desktop. Very rudimental for the moment, we should pass the name of the file to the applet. Added some copyrights I missed in the past.

Aaron: your turn now to discover the 'Mimetypes' key problem.
CCMAIL: aseigo@kde.org

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=694676
This commit is contained in:
Riccardo Iaconelli 2007-07-31 10:52:05 +00:00
parent 8d4debed10
commit 5aaccf0489
7 changed files with 35 additions and 3 deletions

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2005 by Aaron Seigo <aseigo@kde.org>
* Copyright (C) 2007 by Riccardo Iaconelli <riccardo@kde.org>
*
* 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]";

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2006-2007 by Aaron Seigo <aseigo@kde.org>
* Copyright (C) 2007 by Riccardo Iaconelli <riccardo@kde.org>
*
* 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.

View File

@ -1,6 +1,7 @@
/*
* Copyright (C) 2007 Matt Broadstone <mbroadst@gmail.com>
* Copyright (C) 2007 Aaron Seigo <aseigo@kde.org>
* Copyright (C) 2007 Riccardo Iaconelli <riccardo@kde.org>
*
* 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));
}

View File

@ -1,5 +1,6 @@
/******************************************************************************
* Copyright (C) 2007 by Aaron Seigo <aseigo@kde.org> *
* Copyright (C) 2007 by Riccardo Iaconelli <riccardo@kde.org> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *

View File

@ -1,5 +1,6 @@
/******************************************************************************
* Copyright (C) 2007 by Aaron Seigo <aseigo@kde.org> *
* Copyright (C) 2007 by Riccardo Iaconelli <riccardo@kde.org> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2007 by Aaron Seigo aseigo@kde.org
* Copyright (C) 2007 by Aaron Seigo <aseigo@kde.org>
* Copyright (C) 2007 by Riccardo Iaconelli <riccardo@kde.org>
* Copyright (C) 2007 by Matt Broadstone <mbroadst@gmail.com>
*
* This program is free software; you can redistribute it and/or modify

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2007 by Siraj Razick siraj@kde.org
* Copyright (C) 2007 by Siraj Razick <siraj@kde.org>
* Copyright (C) 2007 by Riccardo Iaconelli <riccardo@kde.org>
* Copyright (C) 2007 by Matt Broadstone <mbroadst@gmail.com>
*
* This program is free software; you can redistribute it and/or modify