Plasma
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
00021 #ifndef PLASMA_CONTAINMENT_H
00022 #define PLASMA_CONTAINMENT_H
00023
00024 #include <QtGui/QGraphicsItem>
00025 #include <QtGui/QWidget>
00026 #include <QtGui/QStyleOptionGraphicsItem>
00027
00028 #include <kplugininfo.h>
00029 #include <ksharedconfig.h>
00030 #include <kgenericfactory.h>
00031
00032 #include <plasma/applet.h>
00033 #include <plasma/animator.h>
00034
00035 namespace Plasma
00036 {
00037
00038 class AppletHandle;
00039 class DataEngine;
00040 class Package;
00041 class Corona;
00042 class View;
00043 class Wallpaper;
00044 class ContainmentPrivate;
00045
00067 class PLASMA_EXPORT Containment : public Applet
00068 {
00069 Q_OBJECT
00070
00071 public:
00072 class PLASMA_EXPORT StyleOption : public QStyleOptionGraphicsItem
00073 {
00074 public:
00075 explicit StyleOption();
00076 explicit StyleOption(const StyleOption &other);
00077 explicit StyleOption(const QStyleOptionGraphicsItem &other);
00078
00079 enum StyleOptionType {
00080 Type = SO_CustomBase + 1
00081 };
00082 enum StyleOptionVersion {
00083 Version = QStyleOptionGraphicsItem::Version + 1
00084 };
00085
00091 Plasma::View *view;
00092 };
00093
00094 enum Type {
00095 NoContainmentType = -1,
00096 DesktopContainment = 0,
00097 PanelContainment,
00098 CustomContainment = 127,
00100 CustomPanelContainment = 128
00101 };
00102
00110 explicit Containment(QGraphicsItem *parent = 0,
00111 const QString &serviceId = QString(),
00112 uint containmentId = 0);
00113
00124 Containment(QObject *parent, const QVariantList &args);
00125
00126 ~Containment();
00127
00131 void init();
00132
00136 Type containmentType() const;
00137
00141 Corona *corona() const;
00142
00159 static KPluginInfo::List listContainments(const QString &category = QString(),
00160 const QString &parentApp = QString());
00161
00167 static KPluginInfo::List listContainmentsForMimetype(const QString &mimetype);
00168
00180 Applet *addApplet(const QString &name, const QVariantList &args = QVariantList(),
00181 const QRectF &geometry = QRectF(-1, -1, -1, -1));
00182
00194 void addApplet(Applet *applet, const QPointF &pos = QPointF(-1, -1), bool dontInit = true);
00195
00199 Applet::List applets() const;
00200
00204 void clearApplets();
00205
00213 void setScreen(int screen, int desktop = -1);
00214
00219 int screen() const;
00220
00224 int desktop() const;
00225
00230 void save(KConfigGroup &group) const;
00231
00236 void restore(KConfigGroup &group);
00237
00244 void enableAction(const QString &name, bool enable);
00245
00249 void addToolBoxAction(QAction *action);
00250
00254 void removeToolBoxAction(QAction *action);
00255
00261 void setToolBoxOpen(bool open);
00262
00266 void openToolBox();
00267
00271 void closeToolBox();
00272
00277 void addAssociatedWidget(QWidget *widget);
00278
00283 void removeAssociatedWidget(QWidget *widget);
00284
00288 bool drawWallpaper();
00289
00298 void setWallpaper(const QString &pluginName, const QString &mode = QString());
00299
00303 Plasma::Wallpaper *wallpaper() const;
00304
00311 void setActivity(const QString &activity);
00312
00316 QString activity() const;
00317
00322 void showContextMenu(const QPointF &containmentPos, const QPoint &screenPos);
00323
00332 virtual void showDropZone(const QPoint pos);
00333
00334 Q_SIGNALS:
00338 void appletAdded(Plasma::Applet *applet, const QPointF &pos);
00339
00343 void appletRemoved(Plasma::Applet *applet);
00344
00348 void zoomRequested(Plasma::Containment *containment, Plasma::ZoomDirection direction);
00349
00353 void toolBoxToggled();
00354
00359 void addSiblingContainment(Plasma::Containment *);
00360
00368 void showAddWidgetsInterface(const QPointF &pos);
00369
00378 void screenChanged(int wasScreen, int isScreen, Plasma::Containment *containment);
00379
00383 void configureRequested(Plasma::Containment *containment);
00384
00388 void contextChanged(Plasma::Context *context);
00389
00390 public Q_SLOTS:
00398 void setLocation(Plasma::Location location);
00399
00405 void setFormFactor(Plasma::FormFactor formFactor);
00406
00410 void addSiblingContainment();
00411
00415 void focusNextApplet();
00416
00420 void focusPreviousApplet();
00421
00427 void destroy();
00428
00436 void destroy(bool confirm);
00437
00442 void showConfigurationInterface();
00443
00444 protected:
00448 void setContainmentType(Containment::Type type);
00449
00453 void setDrawWallpaper(bool drawWallpaper);
00454
00461 virtual void saveContents(KConfigGroup &group) const;
00462
00469 virtual void restoreContents(KConfigGroup &group);
00470
00471 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
00472 void mousePressEvent(QGraphicsSceneMouseEvent *event);
00473 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
00474 void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
00475 void keyPressEvent(QKeyEvent *event);
00476 void wheelEvent(QGraphicsSceneWheelEvent *event);
00477 bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
00478 QVariant itemChange(GraphicsItemChange change, const QVariant &value);
00479
00484 void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
00485
00490 void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
00491
00496 void dropEvent(QGraphicsSceneDragDropEvent *event);
00497
00502 void resizeEvent(QGraphicsSceneResizeEvent *event);
00503
00507 const QGraphicsItem *toolBoxItem() const;
00508
00509 private:
00510 Q_PRIVATE_SLOT(d, void appletDestroyed(QObject*))
00511 Q_PRIVATE_SLOT(d, void containmentAppletAnimationComplete(QGraphicsItem *item,
00512 Plasma::Animator::Animation anim))
00513 Q_PRIVATE_SLOT(d, void triggerShowAddWidgets())
00514 Q_PRIVATE_SLOT(d, void handleDisappeared(AppletHandle *handle))
00515 Q_PRIVATE_SLOT(d, void positionToolBox())
00516 Q_PRIVATE_SLOT(d, void zoomIn())
00517 Q_PRIVATE_SLOT(d, void zoomOut())
00518 Q_PRIVATE_SLOT(d, void toggleDesktopImmutability())
00519 Q_PRIVATE_SLOT(d, void requestConfiguration())
00520
00521 friend class Applet;
00522 friend class AppletPrivate;
00523 friend class CoronaPrivate;
00524 friend class ContainmentPrivate;
00525 ContainmentPrivate *const d;
00526 };
00527
00528 }
00529
00530 #endif // multiple inclusion guard