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:
parent
8d4debed10
commit
5aaccf0489
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005 by Aaron Seigo <aseigo@kde.org>
|
* 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
|
* 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
|
* 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);
|
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)
|
QStringList Applet::knownCategories(const QString &parentApp)
|
||||||
{
|
{
|
||||||
QString constraint = "exist [X-KDE-PluginInfo-Category]";
|
QString constraint = "exist [X-KDE-PluginInfo-Category]";
|
||||||
|
9
applet.h
9
applet.h
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2007 by Aaron Seigo <aseigo@kde.org>
|
* 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
|
* 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
|
* 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(),
|
static KPluginInfo::List knownApplets(const QString &category = QString(),
|
||||||
const QString &parentApp = 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
|
* Returns a list of all the categories used by
|
||||||
* installed applets.
|
* installed applets.
|
||||||
|
12
corona.cpp
12
corona.cpp
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2007 Matt Broadstone <mbroadst@gmail.com>
|
* Copyright (C) 2007 Matt Broadstone <mbroadst@gmail.com>
|
||||||
* Copyright (C) 2007 Aaron Seigo <aseigo@kde.org>
|
* 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
|
* 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
|
* 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())) {
|
} else if (KUrl::List::canDecode(event->mimeData())) {
|
||||||
KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
|
KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
|
||||||
foreach (const KUrl& url, urls) {
|
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;
|
QStringList args;
|
||||||
args << url.url();
|
args << url.url();
|
||||||
Applet* button = addApplet("url", args);
|
Applet* button = addApplet("url", args);
|
||||||
if (button) {
|
if (button) {
|
||||||
//button->setSize(128,128);
|
// button->setSize(128,128);
|
||||||
button->setPos(event->scenePos() - QPoint(button->boundingRect().width()/2,
|
button->setPos(event->scenePos() - QPoint(button->boundingRect().width()/2,
|
||||||
button->boundingRect().height()/2));
|
button->boundingRect().height()/2));
|
||||||
}
|
}
|
||||||
|
@ -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> *
|
||||||
* *
|
* *
|
||||||
* This library is free software; you can redistribute it and/or *
|
* This library is free software; you can redistribute it and/or *
|
||||||
* modify it under the terms of the GNU Library General Public *
|
* modify it under the terms of the GNU Library General Public *
|
||||||
|
@ -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> *
|
||||||
* *
|
* *
|
||||||
* This library is free software; you can redistribute it and/or *
|
* This library is free software; you can redistribute it and/or *
|
||||||
* modify it under the terms of the GNU Library General Public *
|
* modify it under the terms of the GNU Library General Public *
|
||||||
|
@ -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>
|
* Copyright (C) 2007 by Matt Broadstone <mbroadst@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -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>
|
* Copyright (C) 2007 by Matt Broadstone <mbroadst@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
Loading…
Reference in New Issue
Block a user