|
Krita Source Code Documentation
|
A container for a set of QAction objects. More...
#include <kactioncollection.h>
Inheritance diagram for KisKActionCollection:Signals | |
| QT_MOC_COMPAT void | actionHighlighted (QAction *action) |
| void | actionHovered (QAction *action) |
| void | actionTriggered (QAction *action) |
| void | inserted (QAction *action) |
Public Member Functions | |
| QAction * | action (const QString &name) const |
| QAction * | action (int index) const |
| const QList< QActionGroup * > | actionGroups () const |
| QList< QAction * > | actions () const |
| const QList< QAction * > | actionsWithoutGroup () const |
| template<class ActionType > | |
| ActionType * | add (const QString &name, const QObject *receiver=0, const char *member=0) |
| QAction * | addAction (const QString &name, const QObject *receiver=0, const char *member=0) |
| Q_INVOKABLE QAction * | addAction (const QString &name, QAction *action) |
| QAction * | addAction (KStandardAction::StandardAction actionType, const QObject *receiver=0, const char *member=0) |
| QAction * | addAction (KStandardAction::StandardAction actionType, const QString &name, const QObject *receiver=0, const char *member=0) |
| void | addActions (const QList< QAction * > &actions) |
| void | addAssociatedWidget (QWidget *widget) |
| Q_INVOKABLE QAction * | addCategorizedAction (const QString &name, QAction *action, const QString &categoryName) |
| QList< QWidget * > | associatedWidgets () const |
| void | associateWidget (QWidget *widget) const |
| QList< KisKActionCategory * > | categories () const |
| void | clear () |
| void | clearAssociatedWidgets () |
| QString | componentDisplayName () const |
| QString | componentName () const |
| QString | configGroup () const |
| int | count () const |
| QKeySequence | defaultShortcut (QAction *action) const |
| QList< QKeySequence > | defaultShortcuts (QAction *action) const |
| KisKActionCategory * | getCategory (const QString &categoryName) |
| bool | isEmpty () const |
| bool | isShortcutsConfigurable (QAction *action) const |
| KisKActionCollection (QObject *parent, const QString &cName=QString()) | |
| const KisKXMLGUIClient * | parentGUIClient () const |
| void | readSettings () |
| void | removeAction (QAction *action) |
| void | removeAssociatedWidget (QWidget *widget) |
| void | setComponentDisplayName (const QString &displayName) |
| void | setComponentName (const QString &componentName) |
| void | setConfigGroup (const QString &group) |
| void | setDefaultShortcut (QAction *action, const QKeySequence &shortcut) |
| Q_INVOKABLE void | setDefaultShortcuts (QAction *action, const QList< QKeySequence > &shortcuts) |
| void | setShortcutsConfigurable (QAction *action, bool configurable) |
| QAction * | takeAction (QAction *action) |
| void | updateShortcuts () |
| void | writeSettings (KConfigGroup *config=0, bool writeScheme=false, QAction *oneAction=0) const |
| ~KisKActionCollection () override | |
Static Public Member Functions | |
| static const QList< KisKActionCollection * > & | allCollections () |
Protected Slots | |
| virtual QT_MOC_COMPAT void | slotActionHighlighted () |
| virtual void | slotActionTriggered () |
Protected Member Functions | |
| void | connectNotify (const QMetaMethod &signal) override |
| Overridden to perform connections when someone wants to know whether an action was highlighted or triggered. | |
Properties | |
| QString | configGroup |
Private Slots | |
| void | slotActionHovered () |
Private Member Functions | |
| KisKActionCollection (const KisKXMLGUIClient *parent) | |
Private Attributes | |
| class KisKActionCollectionPrivate *const | d |
Friends | |
| class | KisKActionCollectionPrivate |
| class | KisKXMLGUIClient |
A container for a set of QAction objects.
KisKActionCollection 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, KisKActionCollection provides several convenience functions for locating named actions, and actions grouped by QActionGroup.
Definition at line 43 of file kactioncollection.h.
|
explicit |
Constructor. Allows specification of a component name other than the default application name, where needed (remember to call setComponentDisplayName() too).
Definition at line 89 of file kactioncollection.cpp.
References d, KisKActionCollectionPrivate::q, KisKActionCollectionPrivate::s_allCollections, and setComponentName().
|
override |
Destructor.
Definition at line 110 of file kactioncollection.cpp.
References d, and KisKActionCollectionPrivate::s_allCollections.
|
private |
Definition at line 99 of file kactioncollection.cpp.
References d, KisKActionCollectionPrivate::m_componentName, KisKActionCollectionPrivate::m_parentGUIClient, KisKActionCollectionPrivate::q, and KisKActionCollectionPrivate::s_allCollections.
| QAction * KisKActionCollection::action | ( | const QString & | name | ) | const |
Get the action with the given name from the action collection.
| name | Name of the QAction |
Definition at line 145 of file kactioncollection.cpp.
References action(), KisKActionCollectionPrivate::actionByName, and d.
| QAction * KisKActionCollection::action | ( | int | index | ) | const |
Return the QAction* at position "index" in the action collection.
This is equivalent to actions().value(index);
Definition at line 156 of file kactioncollection.cpp.
References actions().
| const QList< QActionGroup * > KisKActionCollection::actionGroups | ( | ) | const |
Returns the list of all QActionGroups associated with actions in this action collection.
Definition at line 232 of file kactioncollection.cpp.
References action(), KisKActionCollectionPrivate::actions, and d.
|
signal |
Indicates that action was highlighted (hovered over).
|
signal |
Indicates that action was hovered.
| QList< QAction * > KisKActionCollection::actions | ( | ) | const |
Returns the list of QActions which belong to this action collection.
The list is guaranteed to be in the same order the action were put into the collection.
Definition at line 217 of file kactioncollection.cpp.
References KisKActionCollectionPrivate::actions, and d.
| const QList< QAction * > KisKActionCollection::actionsWithoutGroup | ( | ) | const |
Returns the list of QActions without an QAction::actionGroup() which belong to this action collection.
Definition at line 222 of file kactioncollection.cpp.
References action(), KisKActionCollectionPrivate::actions, and d.
|
signal |
Indicates that action was triggered
|
inline |
Creates a new action under the given name, adds it to the collection and connects the action's triggered(bool) signal to the specified receiver/member. The receiver slot may accept either a bool or no parameters at all (i.e. slotTriggered(bool) or slotTriggered() ). The type of the action is specified by the template parameter ActionType.
NOTE: KDE prior to 4.2 connected the triggered() signal instead of the triggered(bool) signal.
| name | The internal name of the action (e.g. "file-open"). |
| receiver | The QObject to connect the triggered(bool) signal to. Leave 0 if no connection is desired. |
| member | The SLOT to connect the triggered(bool) signal to. Leave 0 if no connection is desired. |
Definition at line 415 of file kactioncollection.h.
| QAction * KisKActionCollection::addAction | ( | const QString & | name, |
| const QObject * | receiver = 0, | ||
| const char * | member = 0 ) |
Creates a new action under the given name to the collection and connects the action's triggered(bool) signal to the specified receiver/member. The newly created action is returned.
NOTE: KDE prior to 4.2 used the triggered() signal instead of the triggered(bool) signal.
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.
| name | The name by which the action be retrieved again from the collection. |
| receiver | The QObject to connect the triggered(bool) signal to. Leave 0 if no connection is desired. |
| member | The SLOT to connect the triggered(bool) signal to. Leave 0 if no connection is desired. |
Definition at line 371 of file kactioncollection.cpp.
References addAction().
| QAction * KisKActionCollection::addAction | ( | const QString & | name, |
| QAction * | action ) |
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 (but will not delete it).
| name | The name by which the action be retrieved again from the collection. |
| action | The action to add. |
Definition at line 247 of file kactioncollection.cpp.
References action(), KisKActionCollectionPrivate::actionByName, KisKActionCollectionPrivate::actions, KisKActionCollectionPrivate::associatedWidgets, KisKActionCollectionPrivate::connectHovered, KisKActionCollectionPrivate::connectTriggered, d, inserted(), KisKActionCollectionPrivate::setComponentForAction(), slotActionHovered(), slotActionTriggered(), and takeAction().
| QAction * KisKActionCollection::addAction | ( | KStandardAction::StandardAction | actionType, |
| const QObject * | receiver = 0, | ||
| const char * | member = 0 ) |
Creates a new standard action, adds it to the collection and connects the action's triggered(bool) signal to the specified receiver/member. The newly created action is also returned.
Note: Using KStandardAction::OpenRecent will cause a different signal than triggered(bool) to be used, see KStandardAction for more information.
The action can be retrieved later from the collection by its standard name as per KStandardAction::stdName.
| actionType | The standard action type of the action to create. |
| receiver | The QObject to connect the triggered(bool) signal to. Leave 0 if no connection is desired. |
| member | The SLOT to connect the triggered(bool) signal to. Leave 0 if no connection is desired. |
Definition at line 350 of file kactioncollection.cpp.
References action(), and KStandardAction::create().
| QAction * KisKActionCollection::addAction | ( | KStandardAction::StandardAction | actionType, |
| const QString & | name, | ||
| const QObject * | receiver = 0, | ||
| const char * | member = 0 ) |
Creates a new standard action, adds to the collection under the given name and connects the action's triggered(bool) signal to the specified receiver/member. The newly created action is also returned.
Note: Using KStandardAction::OpenRecent will cause a different signal than triggered(bool) to be used, see KStandardAction for more information.
The action can be retrieved later from the collection by the specified name.
| actionType | The standard action type of the action to create. |
| name | The name by which the action be retrieved again from the collection. |
| receiver | The QObject to connect the triggered(bool) signal to. Leave 0 if no connection is desired. |
| member | The SLOT to connect the triggered(bool) signal to. Leave 0 if no connection is desired. |
Definition at line 356 of file kactioncollection.cpp.
References action(), addAction(), and KStandardAction::create().
Adds a list of actions to the collection.
The objectName of the actions is used as their internal name in the collection.
Uses addAction(QString, QAction*).
| actions | the list of the actions to add. |
Definition at line 322 of file kactioncollection.cpp.
References action(), actions(), and addAction().
| void KisKActionCollection::addAssociatedWidget | ( | 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+)
Definition at line 654 of file kactioncollection.cpp.
References actions(), KisKActionCollectionPrivate::associatedWidgets, and d.
| QAction * KisKActionCollection::addCategorizedAction | ( | const QString & | name, |
| QAction * | action, | ||
| const QString & | categoryName ) |
Adds a new action to the collection in category category.
The category will be created if it does not already exist.
Definition at line 242 of file kactioncollection.cpp.
References action(), KisKActionCategory::addAction(), and getCategory().
|
static |
Access the list of all action collections in existence for this app
Definition at line 640 of file kactioncollection.cpp.
References KisKActionCollectionPrivate::s_allCollections.
| QList< QWidget * > KisKActionCollection::associatedWidgets | ( | ) | const |
Return a list of all associated widgets.
Definition at line 720 of file kactioncollection.cpp.
References KisKActionCollectionPrivate::associatedWidgets, and d.
| void KisKActionCollection::associateWidget | ( | QWidget * | widget | ) | const |
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.
Definition at line 645 of file kactioncollection.cpp.
| QList< KisKActionCategory * > KisKActionCollection::categories | ( | ) | const |
Returns the KActionCategories inside this collection
Definition at line 118 of file kactioncollection.cpp.
| void KisKActionCollection::clear | ( | ) |
Clears the entire action collection, deleting all actions.
Definition at line 138 of file kactioncollection.cpp.
References KisKActionCollectionPrivate::actionByName, KisKActionCollectionPrivate::actions, and d.
| void KisKActionCollection::clearAssociatedWidgets | ( | ) |
Clear all associated widgets and remove the actions from those widgets.
Definition at line 725 of file kactioncollection.cpp.
References action(), actions(), KisKActionCollectionPrivate::associatedWidgets, and d.
| QString KisKActionCollection::componentDisplayName | ( | ) | const |
The display name for the associated component.
Definition at line 201 of file kactioncollection.cpp.
References d, isEmpty(), and KisKActionCollectionPrivate::m_componentDisplayName.
| QString KisKActionCollection::componentName | ( | ) | const |
The component name with which this class is associated.
Definition at line 191 of file kactioncollection.cpp.
References d, and KisKActionCollectionPrivate::m_componentName.
| QString KisKActionCollection::configGroup | ( | ) | const |
Returns the KConfig group with which settings will be loaded and saved.
Definition at line 414 of file kactioncollection.cpp.
References KisKActionCollectionPrivate::configGroup, and d.
|
overrideprotected |
Overridden to perform connections when someone wants to know whether an action was highlighted or triggered.
Definition at line 613 of file kactioncollection.cpp.
References action(), actions(), KisKActionCollectionPrivate::connectHovered, KisKActionCollectionPrivate::connectTriggered, d, slotActionHovered(), and slotActionTriggered().
| int KisKActionCollection::count | ( | ) | const |
Returns the number of actions in the collection.
This is equivalent to actions().count().
Definition at line 162 of file kactioncollection.cpp.
References KisKActionCollectionPrivate::actions, and d.
| QKeySequence KisKActionCollection::defaultShortcut | ( | QAction * | action | ) | const |
Get the default primary shortcut for the given action.
| action | the action for which the default primary shortcut should be returned. |
Definition at line 380 of file kactioncollection.cpp.
References action(), and defaultShortcuts().
| QList< QKeySequence > KisKActionCollection::defaultShortcuts | ( | QAction * | action | ) | const |
Get the default shortcuts for the given action.
| action | the action for which the default shortcuts should be returned. |
Definition at line 386 of file kactioncollection.cpp.
References action().
| KisKActionCategory * KisKActionCollection::getCategory | ( | const QString & | categoryName | ) |
Gets a category with name name inside this collection.
Creates a new category if one does not exist.
Definition at line 123 of file kactioncollection.cpp.
References categories(), and KisKActionCategory::text.
|
signal |
Indicates that action was inserted into this action collection.
| bool KisKActionCollection::isEmpty | ( | ) | const |
Returns whether the action collection is empty or not.
Definition at line 167 of file kactioncollection.cpp.
References count().
| bool KisKActionCollection::isShortcutsConfigurable | ( | QAction * | action | ) | const |
Returns true if the given action's shortcuts may be configured by the user.
| action | the action for the hint should be verified. |
Definition at line 402 of file kactioncollection.cpp.
| const KisKXMLGUIClient * KisKActionCollection::parentGUIClient | ( | ) | const |
The parent KisKXMLGUIClient, or null if not available.
Definition at line 212 of file kactioncollection.cpp.
References d, and KisKActionCollectionPrivate::m_parentGUIClient.
| void KisKActionCollection::readSettings | ( | ) |
Read all key associations from config.
If config is zero, read all key associations from the application's configuration file KSharedConfig::openConfig(), in the group set by setConfigGroup().
Definition at line 435 of file kactioncollection.cpp.
References action(), KisKActionCollectionPrivate::actionByName, d, KisActionRegistry::instance(), and isShortcutsConfigurable().
| void KisKActionCollection::removeAction | ( | QAction * | action | ) |
Removes an action from the collection and deletes it.
| action | The action to remove. |
Definition at line 329 of file kactioncollection.cpp.
References action(), and takeAction().
| void KisKActionCollection::removeAssociatedWidget | ( | 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.
Definition at line 664 of file kactioncollection.cpp.
References action(), actions(), KisKActionCollectionPrivate::associatedWidgets, and d.
| void KisKActionCollection::setComponentDisplayName | ( | const QString & | displayName | ) |
Set the component display name associated with this action collection. (e.g. for the toolbar editor) KXmlGuiClient::setComponentName takes care of calling this.
Definition at line 196 of file kactioncollection.cpp.
References d, and KisKActionCollectionPrivate::m_componentDisplayName.
| void KisKActionCollection::setComponentName | ( | const QString & | componentName | ) |
Set the componentName associated with this action collection.
| componentName | the name which is to be associated with this action collection, or QString() to indicate the app name. This is used to load/save settings into XML files. KXmlGuiClient::setComponentName takes care of calling this. |
Definition at line 172 of file kactioncollection.cpp.
References count(), d, and KisKActionCollectionPrivate::m_componentName.
| void KisKActionCollection::setConfigGroup | ( | const QString & | group | ) |
Sets group as the KConfig group with which settings will be loaded and saved.
Definition at line 419 of file kactioncollection.cpp.
References KisKActionCollectionPrivate::configGroup, and d.
| void KisKActionCollection::setDefaultShortcut | ( | QAction * | action, |
| const QKeySequence & | shortcut ) |
Set the default shortcut for the given action. Since 5.2, this also calls action->setShortcut(shortcut), i.e. the default shortcut is made active initially.
| action | the action for which the default shortcut should be set. |
| shortcut | the shortcut to use for the given action in its specified shortcutContext() |
Definition at line 391 of file kactioncollection.cpp.
References action(), and setDefaultShortcuts().
| void KisKActionCollection::setDefaultShortcuts | ( | QAction * | action, |
| const QList< QKeySequence > & | shortcuts ) |
Set the default shortcuts for the given action. Since 5.2, this also calls action->setShortcuts(shortcuts), i.e. the default shortcut is made active initially.
| action | the action for which the default shortcut should be set. |
| shortcuts | the shortcuts to use for the given action in its specified shortcutContext() |
Definition at line 396 of file kactioncollection.cpp.
References action().
| void KisKActionCollection::setShortcutsConfigurable | ( | QAction * | action, |
| bool | configurable ) |
Indicate whether the user may configure the action's shortcuts.
| action | the action for the hint should be verified. |
| configurable | set to true if the shortcuts of the given action may be configured by the user, otherwise false. |
Definition at line 409 of file kactioncollection.cpp.
References action().
|
protectedvirtualslot |
Definition at line 594 of file kactioncollection.cpp.
References slotActionHovered().
|
privateslot |
Definition at line 599 of file kactioncollection.cpp.
References action(), actionHighlighted(), and actionHovered().
|
protectedvirtualslot |
Definition at line 586 of file kactioncollection.cpp.
References action(), and actionTriggered().
| QAction * KisKActionCollection::takeAction | ( | QAction * | action | ) |
Removes an action from the collection.
| action | the action to remove. |
Definition at line 334 of file kactioncollection.cpp.
References action(), KisKActionCollectionPrivate::associatedWidgets, d, and KisKActionCollectionPrivate::unlistAction().
| void KisKActionCollection::updateShortcuts | ( | ) |
Update shortcuts from the KisActionRegistry.
Definition at line 424 of file kactioncollection.cpp.
References KisKActionCollectionPrivate::actionByName, d, and KisActionRegistry::instance().
| void KisKActionCollection::writeSettings | ( | KConfigGroup * | config = 0, |
| bool | writeScheme = false, | ||
| QAction * | oneAction = 0 ) const |
Write the current configurable key associations. If is nonzero, use that configuration group.
Otherwise, the output file is determined as follows. 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.
| config | Config object to save to, or null (see above) |
| writeScheme | set to true if we export all settings as new shortcut scheme |
| 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. |
Definition at line 517 of file kactioncollection.cpp.
References action(), KisKActionCollectionPrivate::actionByName, actions(), configGroup, d, defaultShortcuts(), isShortcutsConfigurable(), and KisKActionCollectionPrivate::writeKisKXMLGUIConfigFile().
|
friend |
Definition at line 489 of file kactioncollection.h.
|
friend |
Definition at line 45 of file kactioncollection.h.
|
private |
Definition at line 490 of file kactioncollection.h.
|
readwrite |
Definition at line 49 of file kactioncollection.h.