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
|
|
|
|
|
2012-09-24 17:18:55 +02:00
|
|
|
#include <kactioncollection.h>
|
2008-11-14 01:34:36 +01:00
|
|
|
#include <kmenu.h>
|
2008-11-14 00:08:58 +01:00
|
|
|
|
2012-07-17 14:21:45 +02:00
|
|
|
#include "plasma.h"
|
|
|
|
#include "applet.h"
|
|
|
|
#include "corona.h"
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
static const int INTER_CONTAINMENT_MARGIN = 6;
|
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;
|
|
|
|
|
2010-10-14 14:27:15 +02:00
|
|
|
namespace KIO
|
|
|
|
{
|
|
|
|
class Job;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
class ContainmentPrivate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ContainmentPrivate(Containment *c)
|
|
|
|
: q(c),
|
|
|
|
formFactor(Planar),
|
|
|
|
location(Floating),
|
|
|
|
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
|
|
|
type(Containment::NoContainmentType),
|
2009-11-05 21:27:08 +01:00
|
|
|
drawWallpaper(true),
|
2011-01-05 19:54:37 +01:00
|
|
|
containmentActionsSource(Global)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~ContainmentPrivate()
|
|
|
|
{
|
2011-11-22 09:14:54 +01:00
|
|
|
// qDeleteAll is broken with Qt4.8, delete it by hand
|
|
|
|
while (!applets.isEmpty()) {
|
|
|
|
delete applets.first();
|
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
applets.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
bool isPanelContainment() const;
|
2008-11-04 00:08:39 +01:00
|
|
|
void setLockToolText();
|
2012-09-24 13:58:54 +02:00
|
|
|
void appletDeleted(Applet*);
|
2010-04-28 19:42:12 +02:00
|
|
|
void appletAppeared(Applet*);
|
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();
|
2011-04-25 16:43:15 +02:00
|
|
|
void configChanged();
|
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
|
|
|
|
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-10-23 00:14:22 +02:00
|
|
|
|
2012-11-21 15:26:59 +01:00
|
|
|
|
2010-11-11 23:22:39 +01:00
|
|
|
QHash<QString, ContainmentActions*> *actionPlugins();
|
|
|
|
|
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;
|
2012-11-21 15:26:59 +01:00
|
|
|
QString wallpaper;
|
|
|
|
QString wallpaperMode;
|
2010-11-11 23:22:39 +01:00
|
|
|
QHash<QString, ContainmentActions*> localActionPlugins;
|
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;
|
2012-09-24 17:18:55 +02:00
|
|
|
QList<QAction *> toolBoxActions;
|
2011-05-20 09:41:19 +02:00
|
|
|
QString activityId;
|
2008-11-04 00:08:39 +01:00
|
|
|
Containment::Type type;
|
2009-11-05 21:27:08 +01:00
|
|
|
bool drawWallpaper : 1;
|
2010-11-11 23:22:39 +01:00
|
|
|
|
|
|
|
enum ContainmentActionsSource {
|
|
|
|
Global = 0,
|
|
|
|
Activity,
|
|
|
|
Local
|
|
|
|
};
|
|
|
|
ContainmentActionsSource containmentActionsSource;
|
|
|
|
static QHash<QString, ContainmentActions*> globalActionPlugins;
|
2012-07-17 14:21:45 +02:00
|
|
|
static const char defaultWallpaper[];
|
|
|
|
static const char defaultWallpaperMode[];
|
2008-11-04 00:08:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
#endif
|