2008-11-04 00:08:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2007 by Aaron Seigo <aseigo@kde.org>
|
|
|
|
* Copyright 2008 by Ménard Alexis <darktears31@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CONTAINMENT_P_H
|
|
|
|
#define CONTAINMENT_P_H
|
|
|
|
|
2008-11-14 01:34:36 +01:00
|
|
|
#include <kmenu.h>
|
2008-11-14 00:08:58 +01:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
static const int INTER_CONTAINMENT_MARGIN = 6;
|
2008-12-01 13:40:08 +01:00
|
|
|
static const int TOOLBOX_MARGIN = 150;
|
2008-11-09 20:51:31 +01:00
|
|
|
static const int CONTAINMENT_COLUMNS = 2;
|
2008-11-04 00:08:39 +01:00
|
|
|
static const int VERTICAL_STACKING_OFFSET = 10000;
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class Containment;
|
|
|
|
class ToolBox;
|
|
|
|
|
|
|
|
class ContainmentPrivate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ContainmentPrivate(Containment *c)
|
|
|
|
: q(c),
|
|
|
|
formFactor(Planar),
|
|
|
|
location(Floating),
|
|
|
|
focusedApplet(0),
|
|
|
|
wallpaper(0),
|
|
|
|
screen(-1), // no screen
|
2008-11-17 05:34:55 +01:00
|
|
|
desktop(-1), // all desktops
|
2008-11-04 00:08:39 +01:00
|
|
|
toolBox(0),
|
|
|
|
con(0),
|
|
|
|
type(Containment::NoContainmentType),
|
|
|
|
drawWallpaper(true)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~ContainmentPrivate()
|
|
|
|
{
|
|
|
|
qDeleteAll(applets);
|
|
|
|
applets.clear();
|
2009-09-12 04:38:10 +02:00
|
|
|
|
|
|
|
qDeleteAll(dropMenus);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ToolBox *createToolBox();
|
|
|
|
void positionToolBox();
|
2009-04-24 21:28:17 +02:00
|
|
|
void updateToolBoxVisibility();
|
2008-11-04 00:08:39 +01:00
|
|
|
void triggerShowAddWidgets();
|
2008-11-10 02:26:27 +01:00
|
|
|
void requestConfiguration();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when constraints have been updated on this containment to provide
|
|
|
|
* constraint services common to all containments. Containments should still
|
|
|
|
* implement their own constraintsEvent method
|
|
|
|
*/
|
|
|
|
void containmentConstraintsEvent(Plasma::Constraints constraints);
|
|
|
|
|
|
|
|
bool regionIsEmpty(const QRectF ®ion, Applet *ignoredApplet=0) const;
|
|
|
|
void positionPanel(bool force = false);
|
2008-11-25 01:23:43 +01:00
|
|
|
void positionContainments();
|
2008-11-04 00:08:39 +01:00
|
|
|
void setLockToolText();
|
|
|
|
void handleDisappeared(AppletHandle *handle);
|
2009-01-28 08:58:17 +01:00
|
|
|
void appletDestroyed(Plasma::Applet*);
|
2008-11-04 00:08:39 +01:00
|
|
|
void containmentAppletAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation anim);
|
|
|
|
void zoomIn();
|
|
|
|
void zoomOut();
|
2009-09-12 04:38:10 +02:00
|
|
|
void clearDataForMimeJob(KIO::Job *job);
|
Make dropping remote content onto Plasma work
The idea is that you drop a file from a webpage, or basically a URL onto Plasma and Plasma creates a suitable applet to display this URL. For example an image frame for picture, or a previewer for pdf files. Downloading the data itself (and possibly saving it) is left to the applets. The mimetype needs to be retrieved as it cannot be determined from the URL.
The code pathes I've changed or added are, roughly:
- "something" is dropped onto Plasma
- if it's a remote URL, we don't know the mimetype of the object behind the URL yet
- a KIO::TransferJob is used to retrieve the mimetype asynchronously, and will call back
- we open a QMenu that says "Fetching file type..."
- If the user closes the menu while the mimetype is being retrieved, we will open a new one
- When the TransferJob calls back, and we have our mimetype, we offer a list of applets suitable for this kind of content
- If the user chooses to create an applet, we put the transfer job on hold to make it available for recycling by the applet
- If the user dismisses the offering, we kill the job
Thanks to marco for reviewing and everybody else for the input :)
Next steps are making some more applets work with this.
CCMAIL:plasma-devel@kde.org
svn path=/trunk/KDE/kdelibs/; revision=1009004
2009-08-09 00:01:16 +02:00
|
|
|
void mimeTypeRetrieved(KIO::Job *job, const QString &mimetype);
|
2008-11-14 00:08:58 +01:00
|
|
|
void containmentActions(KMenu &desktopMenu);
|
|
|
|
void appletActions(KMenu &desktopMenu, Applet *applet, bool includeApplet);
|
2009-08-30 20:52:10 +02:00
|
|
|
bool showContextMenu(const QPointF &point, const QPoint &screenPos, bool includeApplet, bool isMouseEvent);
|
2008-12-15 17:54:09 +01:00
|
|
|
void checkRemoveAction();
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
Applet *addApplet(const QString &name, const QVariantList &args = QVariantList(),
|
|
|
|
const QRectF &geometry = QRectF(-1, -1, -1, -1), uint id = 0,
|
|
|
|
bool delayedInit = false);
|
|
|
|
|
2009-05-03 22:22:14 +02:00
|
|
|
KActionCollection *actions();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* add the regular actions & keyboard shortcuts onto Applet's collection
|
|
|
|
*/
|
|
|
|
static void addDefaultActions(KActionCollection *actions);
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* give keyboard focus to applet within this containment
|
|
|
|
*/
|
|
|
|
void focusApplet(Plasma::Applet *applet);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the Context for this Containment
|
|
|
|
*/
|
|
|
|
Context *context();
|
|
|
|
|
2009-05-05 07:19:35 +02:00
|
|
|
/**
|
|
|
|
* Handles dropped/pasted mimetype data
|
2009-08-18 00:31:03 +02:00
|
|
|
* @param scenePos scene-relative position
|
|
|
|
* @param screenPos screen-relative position
|
|
|
|
* @param dropEvent the drop event (if null, the clipboard is used instead)
|
2009-05-05 07:19:35 +02:00
|
|
|
*/
|
2009-08-18 00:31:03 +02:00
|
|
|
void dropData(QPointF scenePos, QPoint screenPos, QGraphicsSceneDragDropEvent *dropEvent = 0);
|
2009-05-05 07:19:35 +02:00
|
|
|
|
2009-08-18 00:30:34 +02:00
|
|
|
/**
|
2009-08-18 00:31:32 +02:00
|
|
|
* inits the containmentactions if necessary
|
2009-08-18 00:30:34 +02:00
|
|
|
* if it needs configuring, this warns the user and returns false
|
|
|
|
* @return true if it's ok to run the action
|
|
|
|
*/
|
2009-08-18 00:31:32 +02:00
|
|
|
bool prepareContainmentActions(const QString &trigger, const QPoint &screenPos);
|
2009-08-18 00:30:34 +02:00
|
|
|
|
2009-08-30 20:52:05 +02:00
|
|
|
Applet *appletAt(const QPointF &point);
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
Containment *q;
|
|
|
|
FormFactor formFactor;
|
|
|
|
Location location;
|
|
|
|
Applet::List applets;
|
|
|
|
Applet *focusedApplet;
|
|
|
|
Plasma::Wallpaper *wallpaper;
|
|
|
|
QMap<Applet*, AppletHandle*> handles;
|
2009-08-18 00:31:32 +02:00
|
|
|
QHash<QString, ContainmentActions*> actionPlugins;
|
2008-11-04 00:08:39 +01:00
|
|
|
int screen;
|
2008-11-17 05:34:55 +01:00
|
|
|
int desktop;
|
2008-11-04 00:08:39 +01:00
|
|
|
ToolBox *toolBox;
|
|
|
|
Context *con;
|
|
|
|
Containment::Type type;
|
|
|
|
static bool s_positioning;
|
|
|
|
bool drawWallpaper;
|
Make dropping remote content onto Plasma work
The idea is that you drop a file from a webpage, or basically a URL onto Plasma and Plasma creates a suitable applet to display this URL. For example an image frame for picture, or a previewer for pdf files. Downloading the data itself (and possibly saving it) is left to the applets. The mimetype needs to be retrieved as it cannot be determined from the URL.
The code pathes I've changed or added are, roughly:
- "something" is dropped onto Plasma
- if it's a remote URL, we don't know the mimetype of the object behind the URL yet
- a KIO::TransferJob is used to retrieve the mimetype asynchronously, and will call back
- we open a QMenu that says "Fetching file type..."
- If the user closes the menu while the mimetype is being retrieved, we will open a new one
- When the TransferJob calls back, and we have our mimetype, we offer a list of applets suitable for this kind of content
- If the user chooses to create an applet, we put the transfer job on hold to make it available for recycling by the applet
- If the user dismisses the offering, we kill the job
Thanks to marco for reviewing and everybody else for the input :)
Next steps are making some more applets work with this.
CCMAIL:plasma-devel@kde.org
svn path=/trunk/KDE/kdelibs/; revision=1009004
2009-08-09 00:01:16 +02:00
|
|
|
QHash<KIO::Job*, QPointF> dropPoints;
|
2009-09-12 03:44:01 +02:00
|
|
|
QHash<KIO::Job*, KMenu*> dropMenus;
|
2008-11-04 00:08:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
#endif
|