• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

libplasma

Plasma::Containment

Plasma::Containment Class Reference

#include <containment.h>

Inheritance diagram for Plasma::Containment:

Inheritance graph
[legend]

List of all members.


Detailed Description

The base class for plugins that provide backgrounds and applet grouping containers.

Containment objects provide the means to group applets into functional sets. They also provide the following:

creation of focussing event

  • drawing of the background image (which can be interactive)
  • form factors (e.g. panel, desktop, full screen, etc)
  • applet layout management

Since containment is actually just a Plasma::Applet, all the techniques used for writing the visual presentation of Applets is applicable to Containtments. Containments are differentiated from Applets by being marked with the ServiceType of Plasma/Containment. Plugins registered with both the Applet and the Containment ServiceTypes can be loaded for us in either situation.

See techbase.kde.org for a tutorial on writing Containments using this class.

Definition at line 66 of file containment.h.


Public Types

enum  Type {
  NoContainmentType = -1, DesktopContainment = 0, PanelContainment, CustomContainment = 127,
  CustomPanelContainment = 128
}

Public Slots

void addSiblingContainment ()
void destroy ()
void focusNextApplet ()
void focusPreviousApplet ()
void setFormFactor (Plasma::FormFactor formFactor)
void setLocation (Plasma::Location location)

Signals

void addSiblingContainment (Plasma::Containment *)
void appletAdded (Plasma::Applet *applet, const QPointF &pos)
void appletRemoved (Plasma::Applet *applet)
void focusRequested (Plasma::Containment *containment)
void screenChanged (int wasScreen, int isScreen, Plasma::Containment *containment)
void showAddWidgetsInterface (const QPointF &pos)
void toolBoxToggled ()
void zoomRequested (Plasma::Containment *containment, Plasma::ZoomDirection direction)

Public Member Functions

void addApplet (Applet *applet, const QPointF &pos=QPointF(-1,-1), bool dontInit=true)
Applet * addApplet (const QString &name, const QVariantList &args=QVariantList(), const QRectF &geometry=QRectF(-1,-1,-1,-1))
void addAssociatedWidget (QWidget *widget)
void addToolBoxTool (QAction *action)
Applet::List applets () const
void clearApplets ()
void closeToolBox ()
 Containment (QObject *parent, const QVariantList &args)
 Containment (QGraphicsItem *parent=0, const QString &serviceId=QString(), uint containmentId=0)
Type containmentType () const
Corona * corona () const
QPoint effectiveScreenPos () const
void enableAction (const QString &name, bool enable)
void init ()
void openToolBox ()
void removeAssociatedWidget (QWidget *widget)
void removeToolBoxTool (QAction *action)
void restore (KConfigGroup &group)
void save (KConfigGroup &group) const
int screen () const
void setScreen (int screen)
void setToolBoxOpen (bool open)
 ~Containment ()

Static Public Member Functions

static KPluginInfo::List listContainments (const QString &category=QString(), const QString &parentApp=QString())
static KPluginInfo::List listContainmentsForMimetype (const QString &mimetype)

Protected Member Functions

void contextMenuEvent (QGraphicsSceneContextMenuEvent *event)
void dragEnterEvent (QGraphicsSceneDragDropEvent *event)
void dragMoveEvent (QGraphicsSceneDragDropEvent *event)
void dropEvent (QGraphicsSceneDragDropEvent *event)
void hoverEnterEvent (QGraphicsSceneHoverEvent *event)
void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
QVariant itemChange (GraphicsItemChange change, const QVariant &value)
void keyPressEvent (QKeyEvent *event)
virtual void restoreContents (KConfigGroup &group)
virtual void saveContents (KConfigGroup &group) const
bool sceneEventFilter (QGraphicsItem *watched, QEvent *event)
void setContainmentType (Containment::Type type)

Classes

class  StyleOption

Member Enumeration Documentation

enum Plasma::Containment::Type

Enumerator:
NoContainmentType 
DesktopContainment  A desktop containment.
PanelContainment  A desktop panel.
CustomContainment  A containment that is neither a desktop nor a panel, but something application specific.
CustomPanelContainment  A customized desktop panel.

Reimplemented from Plasma::Applet.

Definition at line 89 of file containment.h.


Constructor & Destructor Documentation

Plasma::Containment::Containment ( QGraphicsItem *  parent = 0,
const QString &  serviceId = QString(),
uint  containmentId = 0 
) [explicit]

Parameters:
parent the QGraphicsItem this applet is parented to

Parameters:
serviceId the name of the .desktop file containing the information about the widget
containmentId a unique id used to differentiate between multiple instances of the same Applet type

Definition at line 82 of file containment.cpp.

Plasma::Containment::Containment ( QObject *  parent,
const QVariantList &  args 
)

This constructor is to be used with the plugin loading systems found in KPluginInfo and KService.

The argument list is expected to have two elements: the KService service ID for the desktop entry and an applet ID which must be a base 10 number.

Parameters:
parent a QObject parent; you probably want to pass in 0
args a list of strings containing two entries: the service id and the applet id

Definition at line 95 of file containment.cpp.

Plasma::Containment::~Containment (  ) 

Definition at line 105 of file containment.cpp.


Member Function Documentation

void Plasma::Containment::addApplet ( Applet *  applet,
const QPointF &  pos = QPointF(-1, -1),
bool  dontInit = true 
)

add existing applet to this containment at pos

Parameters:
applet the applet that should be added
pos the containment-relative position
dontInit if true, init() will not be called on the applet

Definition at line 530 of file containment.cpp.

Applet * Plasma::Containment::addApplet ( const QString &  name,
const QVariantList &  args = QVariantList(),
const QRectF &  geometry = QRectF(-1, -1, -1, -1) 
)

Adds an applet to this Containment.

Parameters:
name the plugin name for the applet, as given by KPluginInfo::pluginName()
args argument list to pass to the plasmoid
id to assign to this applet, or 0 to auto-assign it a new id
geometry where to place the applet, or to auto-place it if an invalid is provided
delayedInit if true, init() will not be called on the applet
Returns:
a pointer to the applet on success, or 0 on failure

Definition at line 521 of file containment.cpp.

void Plasma::Containment::addAssociatedWidget ( QWidget *  widget  )  [virtual]

associate actions with this widget, including ones added after this call.

needed to make keyboard shortcuts work.

Reimplemented from Plasma::Applet.

Definition at line 929 of file containment.cpp.

void Plasma::Containment::addSiblingContainment (  )  [slot]

Tells the corona to create a new desktop containment.

Definition at line 507 of file containment.cpp.

void Plasma::Containment::addSiblingContainment ( Plasma::Containment *   )  [signal]

Emitted when the containment wants a new containment to be created.

Usually only used for desktop containments.

void Plasma::Containment::addToolBoxTool ( QAction *  action  ) 

Add an action to the toolbox.

Definition at line 892 of file containment.cpp.

void Plasma::Containment::appletAdded ( Plasma::Applet *  applet,
const QPointF &  pos 
) [signal]

This signal is emitted when a new applet is created by the containment.

void Plasma::Containment::appletRemoved ( Plasma::Applet *  applet  )  [signal]

This signal is emitted when an applet is destroyed.

Applet::List Plasma::Containment::applets (  )  const

Returns:
the applets currently in this Containment

Definition at line 598 of file containment.cpp.

void Plasma::Containment::clearApplets (  ) 

Removes all applets from this Containment.

Definition at line 512 of file containment.cpp.

void Plasma::Containment::closeToolBox (  ) 

Closes Containment's toolbox.

Definition at line 922 of file containment.cpp.

Containment::Type Plasma::Containment::containmentType (  )  const

Returns the type of containment.

Definition at line 305 of file containment.cpp.

void Plasma::Containment::contextMenuEvent ( QGraphicsSceneContextMenuEvent *  event  )  [protected]

Definition at line 334 of file containment.cpp.

Corona * Plasma::Containment::corona (  )  const

Returns the Corona (if any) that this Containment is hosted by.

Definition at line 329 of file containment.cpp.

void Plasma::Containment::destroy (  )  [virtual, slot]

Destroys this containment and all its applets (after a confirmation dialog); it will be removed nicely and deleted.

Its configuration will also be deleted.

Reimplemented from Plasma::Applet.

Definition at line 1022 of file containment.cpp.

void Plasma::Containment::dragEnterEvent ( QGraphicsSceneDragDropEvent *  event  )  [protected]

from QGraphicsItem

Definition at line 724 of file containment.cpp.

void Plasma::Containment::dragMoveEvent ( QGraphicsSceneDragDropEvent *  event  )  [protected]

from QGraphicsItem

Definition at line 732 of file containment.cpp.

void Plasma::Containment::dropEvent ( QGraphicsSceneDragDropEvent *  event  )  [protected]

from QGraphicsItem

appletList.isEmpty()

Definition at line 738 of file containment.cpp.

QPoint Plasma::Containment::effectiveScreenPos (  )  const

Returns:
where top left corner of the containment maps to for the currently set screen.

If no screen is associated, it will return QPoint()

Definition at line 653 of file containment.cpp.

void Plasma::Containment::enableAction ( const QString &  name,
bool  enable 
)

convenience function - enables or disables an action by name

Parameters:
name the name of the action in our collection
enable true to enable, false to disable

Definition at line 883 of file containment.cpp.

void Plasma::Containment::focusNextApplet (  )  [slot]

switch keyboard focus to the next of our applets

Definition at line 996 of file containment.cpp.

void Plasma::Containment::focusPreviousApplet (  )  [slot]

switch keyboard focus to the previous one of our applets

Definition at line 1009 of file containment.cpp.

void Plasma::Containment::focusRequested ( Plasma::Containment *  containment  )  [signal]

Emitted when the containment wants to become active.

Usually only used for desktop containments.

void Plasma::Containment::hoverEnterEvent ( QGraphicsSceneHoverEvent *  event  )  [protected]

Definition at line 797 of file containment.cpp.

void Plasma::Containment::hoverLeaveEvent ( QGraphicsSceneHoverEvent *  event  )  [protected]

Definition at line 808 of file containment.cpp.

void Plasma::Containment::init (  )  [virtual]

Reimplemented from Applet.

Reimplemented from Plasma::Applet.

Definition at line 110 of file containment.cpp.

QVariant Plasma::Containment::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
) [protected]

Reimplemented from QGraphicsItem.

Reimplemented from Plasma::Applet.

Definition at line 862 of file containment.cpp.

void Plasma::Containment::keyPressEvent ( QKeyEvent *  event  )  [protected]

Definition at line 817 of file containment.cpp.

KPluginInfo::List Plasma::Containment::listContainments ( const QString &  category = QString(),
const QString &  parentApp = QString() 
) [static]

Returns a list of all known containments.

Parameters:
category Only applets matchin this category will be returned. Useful in conjunction with knownCategories. If "Misc" is passed in, then applets without a Categories= entry are also returned. If an empty string is passed in, all applets are returned.
parentApp the application to filter applets on. Uses the X-KDE-ParentApp entry (if any) in the plugin info. The default value of QString() will result in a list containing only applets not specifically registered to an application.
Returns:
list of applets

Definition at line 689 of file containment.cpp.

KPluginInfo::List Plasma::Containment::listContainmentsForMimetype ( const QString &  mimetype  )  [static]

Returns a list of all known applets associated with a certain mimetype.

Returns:
list of applets

Definition at line 716 of file containment.cpp.

void Plasma::Containment::openToolBox (  ) 

Open the Containment's toolbox.

Definition at line 915 of file containment.cpp.

void Plasma::Containment::removeAssociatedWidget ( QWidget *  widget  )  [virtual]

un-associate actions from this widget, including ones added after this call.

needed to make keyboard shortcuts work.

Reimplemented from Plasma::Applet.

Definition at line 943 of file containment.cpp.

void Plasma::Containment::removeToolBoxTool ( QAction *  action  ) 

Remove an action from the toolbox.

Definition at line 899 of file containment.cpp.

void Plasma::Containment::restore ( KConfigGroup &  group  )  [virtual]

from Applet

Reimplemented from Plasma::Applet.

Definition at line 219 of file containment.cpp.

void Plasma::Containment::restoreContents ( KConfigGroup &  group  )  [protected, virtual]

Called when the contents of the containment should be loaded.

By default this loads all previously saved Applets

Parameters:
group the KConfigGroup to save settings under

Definition at line 277 of file containment.cpp.

void Plasma::Containment::save ( KConfigGroup &  group  )  const [virtual]

from Applet

Reimplemented from Plasma::Applet.

Definition at line 253 of file containment.cpp.

void Plasma::Containment::saveContents ( KConfigGroup &  group  )  const [protected, virtual]

Called when the contents of the containment should be saved.

By default this saves all loaded Applets

Parameters:
group the KConfigGroup to save settings under

Definition at line 268 of file containment.cpp.

bool Plasma::Containment::sceneEventFilter ( QGraphicsItem *  watched,
QEvent *  event 
) [protected]

Reimplemented from Plasma::Applet.

Definition at line 828 of file containment.cpp.

int Plasma::Containment::screen (  )  const

Returns:
the screen number this containment is serving as the desktop for or -1 if none

Definition at line 648 of file containment.cpp.

void Plasma::Containment::screenChanged ( int  wasScreen,
int  isScreen,
Plasma::Containment *  containment 
) [signal]

This signal indicates that a containment has been newly associated (or dissociated) with a physical screen.

Parameters:
wasScreen the screen it was associated with
isScreen the screen it is now associated with
containment the containment switching screens

void Plasma::Containment::setContainmentType ( Containment::Type  type  )  [protected]

Sets the type of this containment.

Definition at line 310 of file containment.cpp.

void Plasma::Containment::setFormFactor ( Plasma::FormFactor  formFactor  )  [slot]

Sets the form factor for this Containment.

This may cause changes in both the arrangement of Applets as well as the display choices of individual Applets.

Definition at line 453 of file containment.cpp.

void Plasma::Containment::setLocation ( Plasma::Location  location  )  [slot]

Informs the Corona as to what position it is in.

This is informational only, as the Corona doesn't change it's actual location. This is, however, passed on to Applets that may be managed by this Corona.

Parameters:
location the new location of this Corona

Definition at line 474 of file containment.cpp.

void Plasma::Containment::setScreen ( int  screen  ) 

Sets the physical screen this Containment is associated with.

Parameters:
screen the screen number this containment is the desktop for, or -1 if it is not serving as the desktop for any screen

Definition at line 603 of file containment.cpp.

void Plasma::Containment::setToolBoxOpen ( bool  open  ) 

Sets the open or closed state of the Containment's toolbox.

  • open true to open the ToolBox, false to close it

Definition at line 906 of file containment.cpp.

void Plasma::Containment::showAddWidgetsInterface ( const QPointF &  pos  )  [signal]

Emitted when the containment requests an add widgets dialog is shown.

Usually only used for desktop containments.

Parameters:
pos where in the containment this request was made from, or an invalid position (QPointF()) is not location specific

void Plasma::Containment::toolBoxToggled (  )  [signal]

Emitted when the user clicks on the toolbox.

void Plasma::Containment::zoomRequested ( Plasma::Containment *  containment,
Plasma::ZoomDirection  direction 
) [signal]

Emitted when the containment requests zooming in or out one step.


The documentation for this class was generated from the following files:
  • containment.h
  • containment.cpp

libplasma

Skip menu "libplasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal