libplasma
containment.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PLASMA_CONTAINMENT_H
00021 #define PLASMA_CONTAINMENT_H
00022
00023 #include <QtGui/QGraphicsItem>
00024 #include <QtGui/QWidget>
00025
00026 #include <kplugininfo.h>
00027 #include <ksharedconfig.h>
00028 #include <kgenericfactory.h>
00029
00030 #include <plasma/applet.h>
00031 #include <plasma/phase.h>
00032
00033 #include "widgets/icon.h"
00034
00035 namespace Plasma
00036 {
00037
00038 class AppletHandle;
00039 class DataEngine;
00040 class Package;
00041 class Corona;
00042
00061 class PLASMA_EXPORT Containment : public Applet
00062 {
00063 Q_OBJECT
00064
00065 public:
00066 typedef QList<Applet*> List;
00067 typedef QHash<QString, Applet*> Dict;
00068
00069 enum Type { NoContainmentType = -1 ,
00070 DesktopContainment = 0 ,
00071 PanelContainment ,
00072 CustomContainment
00074 };
00075
00083 explicit Containment(QGraphicsItem* parent = 0,
00084 const QString& serviceId = QString(),
00085 uint containmentId = 0);
00086
00097 Containment(QObject* parent, const QVariantList& args);
00098
00099 ~Containment();
00100
00104 void init();
00105
00109 Type containmentType() const;
00110
00114 void setContainmentType(Containment::Type type);
00115
00122 FormFactor formFactor() const;
00123
00129 Location location() const;
00130
00147 static KPluginInfo::List knownContainments(const QString &category = QString(),
00148 const QString &parentApp = QString());
00149
00155 static KPluginInfo::List knownContainmentsForMimetype(const QString &mimetype);
00156
00170 Applet* addApplet(const QString& name, const QVariantList& args = QVariantList(),
00171 uint id = 0, const QRectF &geometry = QRectF(-1, -1, -1, -1),
00172 bool delayedInit = false);
00173
00177 Applet::List applets() const;
00178
00182 void clearApplets();
00183
00189 void addApplet(Applet *applet, const QPointF &pos = QPointF(-1, -1), bool dontInit = true);
00190
00195 virtual int indexAt(const QPointF &pos) const;
00196
00203 void setScreen(int screen);
00204
00209 int screen() const;
00210
00214 void saveConstraints(KConfigGroup* group) const;
00215
00219 void loadConstraints(KConfigGroup* group);
00220
00224 void emitLaunchActivated();
00225
00235 Plasma::Widget * addToolBoxTool(const QString &toolName = QString(), const QString &iconName = QString(), const QString &iconText = QString());
00236
00243 void enableToolBoxTool(const QString &toolname, bool enable);
00244
00248 bool isToolboxToolEnabled(const QString &toolname) const;
00249
00256 void containmentConstraintsUpdated(Plasma::Constraints constraints);
00257
00261 void showToolbox();
00262
00266 void hideToolbox();
00267
00268 Q_SIGNALS:
00272 void appletAdded(Plasma::Applet* applet);
00273
00277 void appletRemoved(Plasma::Applet* applet);
00278
00282 void launchActivated();
00283
00288 void zoomIn();
00289
00294 void zoomOut();
00295
00300 void showAddWidgets();
00301
00302 public Q_SLOTS:
00310 void setLocation(Plasma::Location location);
00311
00317 void setFormFactor(Plasma::FormFactor formFactor);
00318
00322 Corona* corona() const;
00323
00324 protected:
00325 void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
00326 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
00327 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
00328 bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
00329
00330 protected Q_SLOTS:
00334 void appletDestroyed(QObject*);
00335 void appletAnimationComplete(QGraphicsItem *item, Plasma::Phase::Animation anim);
00336 void dropEvent(QGraphicsSceneDragDropEvent* event);
00337
00338 private Q_SLOTS:
00339 void handleDisappeared(AppletHandle *handle);
00340 void destroyApplet();
00341
00342 private:
00343 QRectF geometryForApplet(Applet *applet) const;
00344 bool regionIsEmpty(const QRectF ®ion, Applet *ignoredApplet=0) const;
00345 void prepareApplet(Applet *applet, bool delayInit);
00346
00347 Q_DISABLE_COPY(Containment)
00348
00349 class Private;
00350 Private* const d;
00351 };
00352
00353 }
00354
00355
00356 #endif // multiple inclusion guard