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;
|
|
|
|
|
2009-09-22 17:29:08 +02:00
|
|
|
class KJob;
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2009-09-22 17:29:08 +02:00
|
|
|
class AccessAppletJob;
|
2008-11-04 00:08:39 +01:00
|
|
|
class Containment;
|
2009-10-20 16:14:53 +02:00
|
|
|
class AbstractToolBox;
|
2009-12-16 23:33:30 +01:00
|
|
|
class Animation;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
class ContainmentPrivate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ContainmentPrivate(Containment *c)
|
|
|
|
: q(c),
|
|
|
|
formFactor(Planar),
|
|
|
|
location(Floating),
|
|
|
|
focusedApplet(0),
|
|
|
|
wallpaper(0),
|
|
|
|
screen(-1), // no screen
|
2010-05-19 04:43:07 +02:00
|
|
|
lastScreen(-1),
|
2008-11-17 05:34:55 +01:00
|
|
|
desktop(-1), // all desktops
|
2010-05-19 04:43:07 +02:00
|
|
|
lastDesktop(-1),
|
2008-11-04 00:08:39 +01:00
|
|
|
con(0),
|
|
|
|
type(Containment::NoContainmentType),
|
2009-10-23 00:14:22 +02:00
|
|
|
showDropZoneDelayTimer(0),
|
2009-11-05 21:27:08 +01:00
|
|
|
drawWallpaper(true),
|
|
|
|
dropZoneStarted(false)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~ContainmentPrivate()
|
|
|
|
{
|
|
|
|
qDeleteAll(applets);
|
|
|
|
applets.clear();
|
2009-09-12 04:38:10 +02:00
|
|
|
|
|
|
|
qDeleteAll(dropMenus);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2010-04-13 20:36:38 +02:00
|
|
|
void createToolBox();
|
2008-11-04 00:08:39 +01:00
|
|
|
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();
|
2010-05-06 00:33:52 +02:00
|
|
|
void checkStatus(Plasma::ItemStatus status);
|
2010-09-24 21:03:45 +02:00
|
|
|
void setScreen(int newScreen, int newDesktop, bool preventInvalidDesktops = true);
|
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);
|
|
|
|
|
2010-06-04 23:36:28 +02:00
|
|
|
void initApplets();
|
2010-04-13 20:36:38 +02:00
|
|
|
void checkContainmentFurniture();
|
2008-11-04 00:08:39 +01:00
|
|
|
bool regionIsEmpty(const QRectF ®ion, Applet *ignoredApplet=0) const;
|
|
|
|
void positionPanel(bool force = false);
|
2010-04-13 20:36:38 +02:00
|
|
|
bool isPanelContainment() const;
|
|
|
|
QPointF preferredPos(Corona *corona) const;
|
|
|
|
QPointF preferredPanelPos(Corona *corona) const;
|
2008-11-04 00:08:39 +01:00
|
|
|
void setLockToolText();
|
|
|
|
void handleDisappeared(AppletHandle *handle);
|
2010-04-28 19:42:12 +02:00
|
|
|
void appletDestroyed(Applet*);
|
2010-01-05 00:45:38 +01:00
|
|
|
void appletAppearAnimationComplete();
|
2010-04-28 19:42:12 +02:00
|
|
|
void appletAppeared(Applet*);
|
2009-09-12 04:38:10 +02:00
|
|
|
void clearDataForMimeJob(KIO::Job *job);
|
2009-09-22 17:29:08 +02:00
|
|
|
void remoteAppletReady(Plasma::AccessAppletJob *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);
|
2009-09-30 23:42:05 +02:00
|
|
|
void dropJobResult(KJob *);
|
2010-09-09 20:37:28 +02:00
|
|
|
void addContainmentActions(KMenu &desktopMenu, QEvent *event);
|
|
|
|
void addAppletActions(KMenu &desktopMenu, Applet *applet, QEvent *event);
|
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
|
|
|
|
*/
|
2009-10-14 01:07:35 +02:00
|
|
|
static void addDefaultActions(KActionCollection *actions, Containment *c = 0);
|
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();
|
|
|
|
|
2010-05-11 21:02:24 +02:00
|
|
|
/**
|
|
|
|
* propogates context changes
|
|
|
|
*/
|
|
|
|
void onContextChanged(Plasma::Context *con);
|
|
|
|
|
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
|
2010-09-09 20:37:28 +02:00
|
|
|
* if a menu is passed in, then it populates that menu with the actions from the plugin
|
|
|
|
* @param trigger the string to identify the correct plugin with
|
|
|
|
* @param screenPos used to show the configure menu, only used if no menu is passed in
|
|
|
|
* @param menu an optional menu to use to populate with actions, instead of triggering the
|
|
|
|
* action directly
|
2009-08-18 00:30:34 +02:00
|
|
|
* @return true if it's ok to run the action
|
|
|
|
*/
|
2010-09-09 20:37:28 +02:00
|
|
|
bool prepareContainmentActions(const QString &trigger, const QPoint &screenPos, KMenu *menu = 0);
|
2009-08-18 00:30:34 +02:00
|
|
|
|
2009-08-30 20:52:05 +02:00
|
|
|
Applet *appletAt(const QPointF &point);
|
|
|
|
|
2009-10-23 00:14:22 +02:00
|
|
|
/**
|
|
|
|
* Delayed drop zone display
|
|
|
|
*/
|
|
|
|
void showDropZoneDelayed();
|
|
|
|
|
2010-02-24 15:24:52 +01:00
|
|
|
static bool s_positioningPanels;
|
2009-10-23 00:14:22 +02:00
|
|
|
|
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;
|
2010-05-19 04:43:07 +02:00
|
|
|
int lastScreen;
|
2008-11-17 05:34:55 +01:00
|
|
|
int desktop;
|
2010-05-19 04:43:07 +02:00
|
|
|
int lastDesktop;
|
2009-11-25 20:46:33 +01:00
|
|
|
QWeakPointer<AbstractToolBox> toolBox;
|
2008-11-04 00:08:39 +01:00
|
|
|
Context *con;
|
|
|
|
Containment::Type type;
|
2009-09-22 17:29:08 +02:00
|
|
|
QHash<KJob*, QPointF> dropPoints;
|
|
|
|
QHash<KJob*, KMenu*> dropMenus;
|
2009-10-23 00:14:22 +02:00
|
|
|
QTimer *showDropZoneDelayTimer;
|
2009-11-05 21:27:08 +01:00
|
|
|
bool drawWallpaper : 1;
|
|
|
|
bool dropZoneStarted : 1;
|
2008-11-04 00:08:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
#endif
|