KDE 4.6 PyKDE API Reference

- KDE's Python API

# ContainmentActions Class Reference

`from PyKDE4.plasma import *`

Inherits: QObject
Namespace: Plasma

## Detailed Description

ContainmentActions plasma/containmentactions.h <Plasma/ContainmentActions>

The base ContainmentActions class

"ContainmentActions" are components that provide actions (usually displaying a contextmenu) in response to an event with a position (usually a mouse event).

ContainmentActions plugins are registered using .desktop files. These files should be named using the following naming scheme:

plasma-containmentactions-<pluginname>.desktop

## Methods

| __init__ (self, QObject parent=0)
| __init__ (self, QObject parent, [QVariant] args)
| configurationAccepted (self)
bool | configurationRequired (self)
Plasma.Containment | containment (self)
| contextEvent (self, QEvent event)
[QAction] | contextualActions (self)
QWidget | createConfigurationInterface (self, QWidget parent)
Plasma.DataEngine | dataEngine (self, QString name)
bool | event (self, QEvent e)
QString | icon (self)
| init (self, KConfigGroup config)
bool | isInitialized (self)
QString | name (self)
| paste (self, QPointF scenePos, QPoint screenPos)
QString | pluginName (self)
QPoint | popupPosition (self, QSize s, QEvent event)
| restore (self, KConfigGroup config)
| save (self, KConfigGroup config)
| setConfigurationRequired (self, bool needsConfiguring=1)
| setContainment (self, Plasma.Containment newContainment)

## Static Methods

QString | eventToString (QEvent event)
[KPluginInfo] | listContainmentActionsInfo ()
Plasma.ContainmentActions | load (Plasma.Containment parent, QString name, [QVariant] args=QVariantList())
Plasma.ContainmentActions | load (Plasma.Containment parent, KPluginInfo info, [QVariant] args=QVariantList())
KSharedPtr<Plasma::PackageStructure> | packageStructure ()

## Method Documentation

__init__ | ( | self, |
|  | QObject | parent=0
| ) |  |  |

Default constructor for an empty or null containmentactions

__init__ | ( | self, |
|  | QObject | parent,
|  | [QVariant] | args
| ) |  |  |

This constructor is to be used with the plugin loading systems found in KPluginInfo and KService. The argument list is expected to have one element: the KService service ID for the desktop entry.

Parameters:

  | parent | a QObject parent; you probably want to pass in 0
  | args | a list of strings containing one entry: the service id

configurationAccepted | ( |  | self ) |

This method is called when the user's configuration changes are accepted

bool configurationRequired | ( |  | self ) |

Returns:
  true if the containmentactions currently needs to be configured, otherwise, false

Plasma.Containment containment | ( |  | self ) |

Returns:
  the containment the plugin is associated with.

contextEvent | ( | self, |
|  | QEvent | event
| ) |  |  |

Implement this to respond to events. The user can configure whatever button and modifier they like, so please don't look at those parameters. The event may be a QGraphicsSceneMouseEvent or a QGraphicsSceneWheelEvent.

[QAction] contextualActions | ( |  | self ) |

Implement this to provide a list of actions that can be added to another menu for example, when right-clicking an applet, the "Activity Options" submenu is populated with this.

QWidget createConfigurationInterface | ( | self, |
|  | QWidget | parent
| ) |  |  |

Returns the widget used in the configuration dialog. Add the configuration interface of the containmentactions to this widget.

Plasma.DataEngine dataEngine | ( | self, |
|  | QString | name
| ) |  |  |

Loads the given DataEngine

Tries to load the data engine given by name. Each engine is only loaded once, and that instance is re-used on all subsequent requests.

If the data engine was not found, an invalid data engine is returned (see DataEngine.isValid()).

Note that you should <em>not</em> delete the returned engine.

Parameters:

  | name | Name of the data engine to load

Returns:
  pointer to the data engine if it was loaded, or an invalid data engine if the requested engine could not be loaded

bool event | ( | self, |
|  | QEvent | e
| ) |  |  |

@reimplemented

QString icon | ( |  | self ) |

Returns the icon related to this containmentactions

init | ( | self, |
|  | KConfigGroup | config
| ) |  |  |

This method is called once the containmentactions is loaded or settings are changed.

Parameters:

  | config | Config group to load settings

bool isInitialized | ( |  | self ) |

Returns:
  true if initialized (usually by calling restore), false otherwise

QString name | ( |  | self ) |

Returns the user-visible name for the containmentactions, as specified in the .desktop file.

Returns:
  the user-visible name for the containmentactions.

paste | ( | self, |
|  | QPointF | scenePos,
|  | QPoint | screenPos
| ) |  |  |

pastes the clipboard at a given location

QString pluginName | ( |  | self ) |

Returns the plugin name for the containmentactions

QPoint popupPosition | ( | self, |
|  | QSize | s,
|  | QEvent | event
| ) |  |  |

Returns a popup position appropriate to the event and the size.

@arg s size of the popup @arg event a pointer to the event that triggered the popup

Returns:
  the preferred top-left position for the popup

Since:
  4.6

restore | ( | self, |
|  | KConfigGroup | config
| ) |  |  |

This method should be called once the plugin is loaded or settings are changed.

Parameters:

  | config | Config group to load settings

See also:
  init

save | ( | self, |
|  | KConfigGroup | config
| ) |  |  |

This method is called when settings need to be saved.

Parameters:

  | config | Config group to save settings

setConfigurationRequired | ( | self, |
|  | bool | needsConfiguring=1
| ) |  |  |

When the containmentactions needs to be configured before being usable, this method can be called to denote that action is required

Parameters:

  | needsConfiguring | true if the applet needs to be configured, or false if it doesn't

setContainment | ( | self, |
|  | Plasma.Containment | newContainment
| ) |  |  |

newContainment the containment the plugin should be associated with.

Since:
  4.6

## Static Method Documentation

QString eventToString | ( | QEvent | event
| ) |  |  |

Turns a mouse or wheel event into a string suitable for a ContainmentActions

Returns:
  the string representation of the event

[KPluginInfo] listContainmentActionsInfo | ( |  | ) |

Returns a list of all known containmentactions plugins.

Returns:
  list of containmentactions plugins

Plasma.ContainmentActions load | ( | Plasma.Containment | parent,
|  | QString | name,
|  | [QVariant] | args=QVariantList()
| ) |  |  |

Attempts to load a containmentactions

Returns a pointer to the containmentactions if successful. The caller takes responsibility for the containmentactions, including deleting it when no longer needed.

Parameters:

  parent

  the parent containment.
  Since:
    4.6 null is allowed.
  Parameters:

    | info | KPluginInfo object for the desired containmentactions
    | args | to send the containmentactions extra arguments

  Returns:
    a pointer to the loaded containmentactions, or 0 on load failure

Plasma.ContainmentActions load | ( | Plasma.Containment | parent,
|  | KPluginInfo | info,
|  | [QVariant] | args=QVariantList()
| ) |  |  |

Attempts to load a containmentactions

Returns a pointer to the containmentactions if successful. The caller takes responsibility for the containmentactions, including deleting it when no longer needed.

Parameters:

  parent

  the parent containment.
  Since:
    4.6 null is allowed.
  Parameters:

    | info | KPluginInfo object for the desired containmentactions
    | args | to send the containmentactions extra arguments

  Returns:
    a pointer to the loaded containmentactions, or 0 on load failure

KSharedPtr<Plasma::PackageStructure> packageStructure | ( |  | ) |

Returns the Package specialization for containmentactions.