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
00181 static KPluginInfo::List listContainmentsOfType(const QString &type,
00182 const QString &category = QString(),
00183 const QString &parentApp = QString());
00184
00188 static QStringList listContainmentTypes();
00189
00195 static KPluginInfo::List listContainmentsForMimetype(const QString &mimetype);
00196
00208 Applet *addApplet(const QString &name, const QVariantList &args = QVariantList(),
00209 const QRectF &geometry = QRectF(-1, -1, -1, -1));
00210
00222 void addApplet(Applet *applet, const QPointF &pos = QPointF(-1, -1), bool dontInit = true);
00223
00227 Applet::List applets() const;
00228
00232 void clearApplets();
00233
00241 void setScreen(int screen, int desktop = -1);
00242
00247 int screen() const;
00248
00252 int desktop() const;
00253
00258 void save(KConfigGroup &group) const;
00259
00264 void restore(KConfigGroup &group);
00265
00272 void enableAction(const QString &name, bool enable);
00273
00277 void addToolBoxAction(QAction *action);
00278
00282 void removeToolBoxAction(QAction *action);
00283
00289 void setToolBoxOpen(bool open);
00290
00294 void openToolBox();
00295
00299 void closeToolBox();
00300
00305 void addAssociatedWidget(QWidget *widget);
00306
00311 void removeAssociatedWidget(QWidget *widget);
00312
00316 bool drawWallpaper();
00317
00326 void setWallpaper(const QString &pluginName, const QString &mode = QString());
00327
00331 Plasma::Wallpaper *wallpaper() const;
00332
00339 void setActivity(const QString &activity);
00340
00344 QString activity() const;
00345
00350 void showContextMenu(const QPointF &containmentPos, const QPoint &screenPos);
00351
00360 virtual void showDropZone(const QPoint pos);
00361
00362 Q_SIGNALS:
00366 void appletAdded(Plasma::Applet *applet, const QPointF &pos);
00367
00371 void appletRemoved(Plasma::Applet *applet);
00372
00376 void zoomRequested(Plasma::Containment *containment, Plasma::ZoomDirection direction);
00377
00381 void toolBoxToggled();
00382
00387 void toolBoxVisibilityChanged(bool);
00388
00393 void addSiblingContainment(Plasma::Containment *);
00394
00402 void showAddWidgetsInterface(const QPointF &pos);
00403
00412 void screenChanged(int wasScreen, int isScreen, Plasma::Containment *containment);
00413
00417 void configureRequested(Plasma::Containment *containment);
00418
00422 void contextChanged(Plasma::Context *context);
00423
00424 public Q_SLOTS:
00432 void setLocation(Plasma::Location location);
00433
00439 void setFormFactor(Plasma::FormFactor formFactor);
00440
00444 void addSiblingContainment();
00445
00449 void focusNextApplet();
00450
00454 void focusPreviousApplet();
00455
00461 void destroy();
00462
00470 void destroy(bool confirm);
00471
00476 void showConfigurationInterface();
00477
00478 protected:
00482 void setContainmentType(Containment::Type type);
00483
00487 void setDrawWallpaper(bool drawWallpaper);
00488
00495 virtual void saveContents(KConfigGroup &group) const;
00496
00503 virtual void restoreContents(KConfigGroup &group);
00504
00505 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
00506 void mousePressEvent(QGraphicsSceneMouseEvent *event);
00507 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
00508 void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
00509 void keyPressEvent(QKeyEvent *event);
00510 void wheelEvent(QGraphicsSceneWheelEvent *event);
00511 bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
00512 QVariant itemChange(GraphicsItemChange change, const QVariant &value);
00513
00518 void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
00519
00524 void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
00525
00530 void dropEvent(QGraphicsSceneDragDropEvent *event);
00531
00536 void resizeEvent(QGraphicsSceneResizeEvent *event);
00537
00541 const QGraphicsItem *toolBoxItem() const;
00542
00543 private:
00544 Q_PRIVATE_SLOT(d, void appletDestroyed(Plasma::Applet*))
00545 Q_PRIVATE_SLOT(d, void containmentAppletAnimationComplete(QGraphicsItem *item,
00546 Plasma::Animator::Animation anim))
00547 Q_PRIVATE_SLOT(d, void triggerShowAddWidgets())
00548 Q_PRIVATE_SLOT(d, void handleDisappeared(AppletHandle *handle))
00549 Q_PRIVATE_SLOT(d, void positionToolBox())
00550 Q_PRIVATE_SLOT(d, void zoomIn())
00551 Q_PRIVATE_SLOT(d, void zoomOut())
00552 Q_PRIVATE_SLOT(d, void requestConfiguration())
00553 Q_PRIVATE_SLOT(d, void updateToolBoxVisibility())
00554
00555 friend class Applet;
00556 friend class AppletPrivate;
00557 friend class CoronaPrivate;
00558 friend class ContainmentPrivate;
00559 ContainmentPrivate *const d;
00560 };
00561
00562 }
00563
00564 #endif // multiple inclusion guard