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
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 #include "widgets/icon.h"
00036
00037 namespace Plasma
00038 {
00039
00040 class AppletHandle;
00041 class DataEngine;
00042 class Package;
00043 class Corona;
00044 class View;
00045 class ContainmentPrivate;
00046
00066 class PLASMA_EXPORT Containment : public Applet
00067 {
00068 Q_OBJECT
00069
00070 public:
00071 class StyleOption : public QStyleOptionGraphicsItem
00072 {
00073 public:
00074 explicit StyleOption();
00075 explicit StyleOption(const StyleOption &other);
00076 explicit StyleOption(const QStyleOptionGraphicsItem &other);
00077
00078 enum StyleOptionType { Type = SO_CustomBase + 1 };
00079 enum StyleOptionVersion { Version = QStyleOptionGraphicsItem::Version + 1 };
00080
00086 Plasma::View *view;
00087 };
00088
00089 enum Type { NoContainmentType = -1 ,
00090 DesktopContainment = 0 ,
00091 PanelContainment ,
00092 CustomContainment = 127 ,
00094 CustomPanelContainment = 128
00095 };
00096
00104 explicit Containment(QGraphicsItem *parent = 0,
00105 const QString &serviceId = QString(),
00106 uint containmentId = 0);
00107
00118 Containment(QObject *parent, const QVariantList &args);
00119
00120 ~Containment();
00121
00125 void init();
00126
00130 Type containmentType() const;
00131
00135 Corona* corona() const;
00136
00153 static KPluginInfo::List listContainments(const QString &category = QString(),
00154 const QString &parentApp = QString());
00155
00161 static KPluginInfo::List listContainmentsForMimetype(const QString &mimetype);
00162
00176 Applet* addApplet(const QString &name, const QVariantList &args = QVariantList(),
00177 const QRectF &geometry = QRectF(-1, -1, -1, -1));
00178
00185 void addApplet(Applet *applet, const QPointF &pos = QPointF(-1, -1), bool dontInit = true);
00186
00190 Applet::List applets() const;
00191
00195 void clearApplets();
00196
00203 void setScreen(int screen);
00204
00209 int screen() const;
00210
00215 QPoint effectiveScreenPos() const;
00216
00220 void save(KConfigGroup &group) const;
00221
00225 void restore(KConfigGroup &group);
00226
00233 void enableAction(const QString &name, bool enable);
00234
00238 void addToolBoxTool(QAction *action);
00239
00243 void removeToolBoxTool(QAction *action);
00244
00250 void setToolBoxOpen(bool open);
00251
00255 void openToolBox();
00256
00260 void closeToolBox();
00261
00266 void addAssociatedWidget(QWidget *widget);
00267
00272 void removeAssociatedWidget(QWidget *widget);
00273
00274 Q_SIGNALS:
00278 void appletAdded(Plasma::Applet *applet, const QPointF &pos);
00279
00283 void appletRemoved(Plasma::Applet *applet);
00284
00288 void zoomRequested(Plasma::Containment *containment, Plasma::ZoomDirection direction);
00289
00293 void toolBoxToggled();
00294
00299 void addSiblingContainment(Plasma::Containment *);
00300
00308 void showAddWidgetsInterface(const QPointF &pos);
00309
00318 void screenChanged(int wasScreen, int isScreen, Plasma::Containment *containment);
00319
00324 void focusRequested(Plasma::Containment *containment);
00325
00326 public Q_SLOTS:
00334 void setLocation(Plasma::Location location);
00335
00341 void setFormFactor(Plasma::FormFactor formFactor);
00342
00346 void addSiblingContainment();
00347
00351 void focusNextApplet();
00352
00356 void focusPreviousApplet();
00357
00363 void destroy();
00364
00365 protected:
00369 void setContainmentType(Containment::Type type);
00370
00377 virtual void saveContents(KConfigGroup &group) const;
00378
00385 virtual void restoreContents(KConfigGroup &group);
00386
00387
00388 void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
00389 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
00390 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
00391 void keyPressEvent(QKeyEvent *event);
00392 bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
00393 QVariant itemChange(GraphicsItemChange change, const QVariant &value);
00394
00398 void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
00399
00403 void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
00404
00408 void dropEvent(QGraphicsSceneDragDropEvent *event);
00409
00410 private:
00411 Q_PRIVATE_SLOT(d, void appletDestroyed(QObject*))
00412 Q_PRIVATE_SLOT(d, void containmentAppletAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation anim))
00413 Q_PRIVATE_SLOT(d, void triggerShowAddWidgets())
00414 Q_PRIVATE_SLOT(d, void handleDisappeared(AppletHandle *handle))
00415 Q_PRIVATE_SLOT(d, void positionToolBox())
00416 Q_PRIVATE_SLOT(d, void zoomIn())
00417 Q_PRIVATE_SLOT(d, void zoomOut())
00418 Q_PRIVATE_SLOT(d, void toggleDesktopImmutability())
00419
00420 friend class Applet;
00421 friend class ContainmentPrivate;
00422 ContainmentPrivate* const d;
00423 };
00424
00425 }
00426
00427
00428 #endif // multiple inclusion guard