KActionCollection Class Reference
from PyKDE4.kdeui import *
Inherits: QObject
Detailed Description
A container for a set of QAction objects.
KActionCollection manages a set of QAction objects. It allows them to be grouped for organized presentation of configuration to the user, saving + loading of configuration, and optionally for automatic plugging into specified widget(s).
Additionally, KActionCollection provides several convenience functions for locating named actions, and actions grouped by QActionGroup.
- Note:
- If you create your own action collection and need to assign shortcuts to the actions within, you have to call associateWidget() or addAssociatedWidget() to have them working.
Signals | |
actionHighlighted (QAction action) | |
actionHovered (QAction action) | |
actionTriggered (QAction action) | |
inserted (QAction action) | |
removed (QAction action) | |
Methods | |
__init__ (self, QObject parent, KComponentData cData=KComponentData()) | |
__init__ (self, KXMLGUIClient parent) | |
QAction | action (self, int index) |
QAction | action (self, QString name) |
[QActionGrou] | actionGroups (self) |
actionHighlighted (self, QAction action) | |
actionHovered (self, QAction action) | |
actionTriggered (self, QAction action) | |
[QActio] | actions (self) |
[QActio] | actionsWithoutGroup (self) |
QAction | addAction (self, QString name, QAction action) |
KAction | addAction (self, QString name, KAction action) |
KAction | addAction (self, KStandardAction.StandardAction actionType, QObject receiver=0, QString member=0) |
KAction | addAction (self, KStandardAction.StandardAction actionType, QString name, QObject receiver=0, QString member=0) |
KAction | addAction (self, QString name, QObject receiver=0, QString member=0) |
addAssociatedWidget (self, QWidget widget) | |
associateWidget (self, QWidget widget) | |
[QWidge] | associatedWidgets (self) |
clear (self) | |
clearAssociatedWidgets (self) | |
KComponentData | componentData (self) |
QString | configGroup (self) |
bool | configIsGlobal (self) |
connectNotify (self, QString signal) | |
int | count (self) |
exportGlobalShortcuts (self, KConfigGroup config, bool writeDefaults=0) | |
importGlobalShortcuts (self, KConfigGroup config) | |
inserted (self, QAction action) | |
bool | isEmpty (self) |
KXMLGUIClient | parentGUIClient (self) |
readSettings (self, KConfigGroup config=0) | |
removeAction (self, QAction action) | |
removeAssociatedWidget (self, QWidget widget) | |
removed (self, QAction action) | |
setComponentData (self, KComponentData componentData) | |
setConfigGlobal (self, bool global) | |
setConfigGroup (self, QString group) | |
slotActionHighlighted (self) | |
slotActionTriggered (self) | |
QAction | takeAction (self, QAction action) |
writeSettings (self, KConfigGroup config=0, bool writeDefaults=0, QAction oneAction=0) | |
Static Methods | |
[KActionCollectio] | allCollections () |
Method Documentation
__init__ | ( | self, | ||
QObject | parent, | |||
KComponentData | cData=KComponentData() | |||
) |
Constructor. Allows specification of a KComponentData other than the default global KComponentData, where needed.
__init__ | ( | self, | ||
KXMLGUIClient | parent | |||
) |
QAction action | ( | self, | ||
int | index | |||
) |
Return the QAction* at position "index" in the action collection.
This is equivalent to actions().value(index);
Get the action with the given name from the action collection.
- Parameters:
-
name Name of the KAction
- Returns:
- A pointer to the KAction in the collection which matches the parameters or null if nothing matches.
[QActionGrou] actionGroups | ( | self ) |
Returns the list of all QActionGroups associated with actions in this action collection.
actionHighlighted | ( | self, | ||
QAction | action | |||
) |
Indicates that action was highlighted (hovered over).
- Deprecated:
- Replaced by actionHovered(QAction* action);
- Signal syntax:
QObject.connect(source, SIGNAL("actionHighlighted(QAction*)"), target_slot)
actionHovered | ( | self, | ||
QAction | action | |||
) |
Indicates that action was hovered.
- Signal syntax:
QObject.connect(source, SIGNAL("actionHovered(QAction*)"), target_slot)
actionTriggered | ( | self, | ||
QAction | action | |||
) |
Indicates that action was triggered
- Signal syntax:
QObject.connect(source, SIGNAL("actionTriggered(QAction*)"), target_slot)
[QActio] actions | ( | self ) |
Returns the list of KActions which belong to this action collection.
[QActio] actionsWithoutGroup | ( | self ) |
Returns the list of KActions without an QAction.actionGroup() which belong to this action collection.
Add an action under the given name to the collection.
Inserting an action that was previously inserted under a different name will replace the old entry, i.e. the action will not be available under the old name anymore but only under the new one.
Inserting an action under a name that is already used for another action will replace the other action in the collection.
- Parameters:
-
name The name by which the action be retrieved again from the collection. action The action to add.
KAction addAction | ( | self, | ||
KStandardAction.StandardAction | actionType, | |||
QObject | receiver=0, | |||
QString | member=0 | |||
) |
Creates a new standard action, adds it to the collection and connects the action's triggered() signal to the specified receiver/member. The newly created action is also returned.
The action can be retrieved later from the collection by its standard name as per KStandardAction.stdName.
KAction addAction | ( | self, | ||
KStandardAction.StandardAction | actionType, | |||
QString | name, | |||
QObject | receiver=0, | |||
QString | member=0 | |||
) |
Creates a new standard action, adds to the collection under the given name and connects the action's triggered() signal to the specified receiver/member. The newly created action is also returned.
The action can be retrieved later from the collection by the specified name.
Creates a new action under the given name to the collection and connects the action's triggered() signal to the specified receiver/member. The newly created action is returned.
Inserting an action that was previously inserted under a different name will replace the old entry, i.e. the action will not be available under the old name anymore but only under the new one.
Inserting an action under a name that is already used for another action will replace the other action in the collection.
- Parameters:
-
name The name by which the action be retrieved again from the collection. action The action to add.
addAssociatedWidget | ( | self, | ||
QWidget | widget | |||
) |
Associate all actions in this collection to the given widget, including any actions added after this association is made.
This does not change the action's shortcut context, so if you need to have the actions only trigger when the widget has focus, you'll need to set the shortcut context on each action to Qt.WidgetShortcut (or better still, Qt.WidgetWithChildrenShortcut with Qt 4.4+)
[KActionCollectio] allCollections | ( | ) |
Access the list of all action collections in existence for this app
associateWidget | ( | self, | ||
QWidget | widget | |||
) |
Associate all actions in this collection to the given widget. Unlike addAssociatedWidget, this method only adds all current actions in the collection to the given widget. Any action added after this call will not be added to the given widget automatically. So this is just a shortcut for a foreach loop and a widget->addAction call.
[QWidge] associatedWidgets | ( | self ) |
Return a list of all associated widgets.
clear | ( | self ) |
Clears the entire action collection, deleting all actions.
clearAssociatedWidgets | ( | self ) |
Clear all associated widgets and remove the actions from those widgets.
KComponentData componentData | ( | self ) |
The KComponentData with which this class is associated.
QString configGroup | ( | self ) |
Returns the KConfig group with which settings will be loaded and saved.
bool configIsGlobal | ( | self ) |
Returns whether this action collection's configuration should be global to KDE ( true ), or specific to the application ( false ).
connectNotify | ( | self, | ||
QString | signal | |||
) |
Overridden to perform connections when someone wants to know whether an action was highlighted or triggered
int count | ( | self ) |
Returns the number of actions in the collection.
This is equivalent to actions().count().
exportGlobalShortcuts | ( | self, | ||
KConfigGroup | config, | |||
bool | writeDefaults=0 | |||
) |
Export the current configurable global key associations to config.
- Since:
- 4.1
- Parameters:
-
config Config object to save to
- Parameters:
-
writeDefaults set to true to write settings which are already at defaults.
importGlobalShortcuts | ( | self, | ||
KConfigGroup | config | |||
) |
Import from config all configurable global key associations.
- Since:
- 4.1
- Parameters:
-
config Config object to read from
inserted | ( | self, | ||
QAction | action | |||
) |
Indicates that action was inserted into this action collection.
- Signal syntax:
QObject.connect(source, SIGNAL("inserted(QAction*)"), target_slot)
bool isEmpty | ( | self ) |
Returns whether the action collection is empty or not.
KXMLGUIClient parentGUIClient | ( | self ) |
The parent KXMLGUIClient, or null if not available.
readSettings | ( | self, | ||
KConfigGroup | config=0 | |||
) |
Read all key associations from config.
If config is zero, read all key associations from the application's configuration file KGlobal.config(), in the group set by setConfigGroup().
removeAction | ( | self, | ||
QAction | action | |||
) |
Removes an action from the collection and deletes it.
- Parameters:
-
action The action to remove.
removeAssociatedWidget | ( | self, | ||
QWidget | widget | |||
) |
Remove an association between all actions in this collection and the given widget, i.e. remove those actions from the widget, and stop associating newly added actions as well.
removed | ( | self, | ||
QAction | action | |||
) |
Indicates that action was removed from this action collection.
- Deprecated:
- Signal syntax:
QObject.connect(source, SIGNAL("removed(QAction*)"), target_slot)
setComponentData | ( | self, | ||
KComponentData | componentData | |||
) |
Set the componentData associated with this action collection.
- Warning:
- Don't call this method on a KActionCollection that contains actions. This is not supported.
- Parameters:
-
componentData the KComponentData which is to be associated with this action collection, or an invalid KComponentData instance to indicate the default KComponentData.
setConfigGlobal | ( | self, | ||
bool | global | |||
) |
Set whether this action collection's configuration should be global to KDE ( true ), or specific to the application ( false ).
setConfigGroup | ( | self, | ||
QString | group | |||
) |
Sets group as the KConfig group with which settings will be loaded and saved.
slotActionHighlighted | ( | self ) |
- Internal:
- Deprecated:
- Replaced by slotActionHovered();
slotActionTriggered | ( | self ) |
Removes an action from the collection.
- Parameters:
-
action the action to remove.
writeSettings | ( | self, | ||
KConfigGroup | config=0, | |||
bool | writeDefaults=0, | |||
QAction | oneAction=0 | |||
) |
Write the current configurable key associations to config. What the function does if config is zero depends. If this action collection belongs to a KXMLGuiClient the setting are saved to the kxmlgui definition file. If not the settings are written to the applications config file.
- Note:
- oneAction() and writeDefaults() have no meaning for the kxmlgui configuration file.
- Parameters:
-
config Config object to save to, or null (see above)
- Parameters:
-
writeDefaults set to true to write settings which are already at defaults.
- Parameters:
-
oneAction pass an action here if you just want to save the values for one action, eg. if you know that action is the only one which has changed.