KirigamiActionCollection

Search for usage in LXR

#include <KirigamiActionCollection>

Inheritance diagram for KirigamiActionCollection:

Properties

QString configGroup
 
bool configIsGlobal
 
- Properties inherited from QObject
 objectName
 

Signals

void actionHovered (QAction *action)
 
void actionTriggered (QAction *action)
 
void changed ()
 
void inserted (QAction *action)
 

Public Member Functions

 KirigamiActionCollection (QObject *parent, const QString &cName=QString())
 
 ~KirigamiActionCollection () override
 
Q_INVOKABLE QActionaction (const QString &name) const
 
QActionaction (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 Receiver *receiver, Func slot)
 
QActionaddAction (const QString &name, const Receiver *receiver, Func slot)
 
Q_INVOKABLE QActionaddAction (const QString &name, QAction *action)
 
QActionaddAction (KStandardActions::StandardAction actionType, const QString &name, const Receiver *receiver, Func slot)
 
void addActions (const QList< QAction * > &actions)
 
void clear ()
 
QString componentDisplayName () const
 
QString componentName () const
 
QString configGroup () const
 
bool configIsGlobal () const
 
int count () const
 
bool isEmpty () const
 
void readSettings (KConfigGroup *config=nullptr)
 
void removeAction (QAction *action)
 
void setComponentDisplayName (const QString &displayName)
 
void setComponentName (const QString &componentName)
 
void setConfigGlobal (bool global)
 
void setConfigGroup (const QString &group)
 
QActiontakeAction (QAction *action)
 
void writeSettings (KConfigGroup *config=nullptr, bool writeDefaults=false, QAction *oneAction=nullptr) const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static const QList< KirigamiActionCollection * > & allCollections ()
 
static QKeySequence defaultShortcut (QAction *action)
 
static QList< QKeySequencedefaultShortcuts (QAction *action)
 
static bool isShortcutsConfigurable (QAction *action)
 
static void setDefaultShortcut (QAction *action, const QKeySequence &shortcut)
 
static Q_INVOKABLE void setDefaultShortcuts (QAction *action, const QList< QKeySequence > &shortcuts)
 
static void setShortcutsConfigurable (QAction *action, bool configurable)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Protected Slots

virtual void slotActionTriggered ()
 

Protected Member Functions

void connectNotify (const QMetaMethod &signal) override
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

A container for a set of QAction objects.

KirigamiActionCollection 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, KirigamiActionCollection provides several convenience functions for locating named actions, and actions grouped by QActionGroup.

Since
KirigamiAddons 1.4.0

Definition at line 43 of file kirigamiactioncollection.h.

Property Documentation

◆ configGroup

QString KirigamiActionCollection::configGroup
readwrite

Definition at line 47 of file kirigamiactioncollection.h.

◆ configIsGlobal

bool KirigamiActionCollection::configIsGlobal
readwrite

Definition at line 48 of file kirigamiactioncollection.h.

Constructor & Destructor Documentation

◆ KirigamiActionCollection()

KirigamiActionCollection::KirigamiActionCollection ( QObject * parent,
const QString & cName = QString() )
explicit

Constructor.

Allows specification of a component name other than the default application name, where needed (remember to call setComponentDisplayName() too).

Definition at line 69 of file kirigamiactioncollection.cpp.

◆ ~KirigamiActionCollection()

KirigamiActionCollection::~KirigamiActionCollection ( )
override

Destructor.

Definition at line 77 of file kirigamiactioncollection.cpp.

Member Function Documentation

◆ action() [1/2]

QAction * KirigamiActionCollection::action ( const QString & name) const

Get the action with the given name from the action collection.

This won't return the action for the menus defined using a "<Menu>" tag in XMLGUI files (e.g. "<Menu name="menuId">" in "applicationNameui.rc"). To access menu actions defined like this, use e.g.

qobject_cast<QMenu *>(guiFactory()->container("menuId", this));
T qobject_cast(QObject *object)

after having called setupGUI() or createGUI().

Parameters
nameName of the QAction
Returns
A pointer to the QAction in the collection which matches the parameters or null if nothing matches.

Definition at line 89 of file kirigamiactioncollection.cpp.

◆ action() [2/2]

QAction * KirigamiActionCollection::action ( int index) const

Return the QAction* at position index in the action collection.

This is equivalent to actions().value(index);

Definition at line 100 of file kirigamiactioncollection.cpp.

◆ actionGroups()

const QList< QActionGroup * > KirigamiActionCollection::actionGroups ( ) const

Returns the list of all QActionGroups associated with actions in this action collection.

Definition at line 162 of file kirigamiactioncollection.cpp.

◆ actionHovered

void KirigamiActionCollection::actionHovered ( QAction * action)
signal

Indicates that action was hovered.

◆ actions()

QList< QAction * > KirigamiActionCollection::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 146 of file kirigamiactioncollection.cpp.

◆ actionsWithoutGroup()

const QList< QAction * > KirigamiActionCollection::actionsWithoutGroup ( ) const

Returns the list of QActions without an QAction::actionGroup() which belong to this action collection.

Definition at line 151 of file kirigamiactioncollection.cpp.

◆ actionTriggered

void KirigamiActionCollection::actionTriggered ( QAction * action)
signal

Indicates that action was triggered.

◆ add()

template<class ActionType >
ActionType * KirigamiActionCollection::add ( const QString & name,
const Receiver * receiver,
Func slot )
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 type of the action is specified by the template parameter ActionType.

The KirigamiActionCollection takes ownership of the action object.

Parameters
nameThe internal name of the action (e.g. "file-open").
receiverThe QObject to connect the triggered(bool) signal to.
slotThe slot or lambda to connect the triggered(bool) signal to.
Returns
new action of the given type ActionType.
See also
add(const QString &, const QObject *, const char *)

Definition at line 334 of file kirigamiactioncollection.h.

◆ addAction() [1/3]

QAction * KirigamiActionCollection::addAction ( const QString & name,
const Receiver * receiver,
Func slot )
inline

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.

Parameters
nameThe internal name of the action (e.g. "file-open").
receiverThe QObject to connect the triggered(bool) signal to.
slotThe slot or lambda to connect the triggered(bool) signal to.
Returns
new action of the given type ActionType.

Definition at line 358 of file kirigamiactioncollection.h.

◆ addAction() [2/3]

QAction * KirigamiActionCollection::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).

If KAuthorized::authorizeAction() reports that the action is not authorized, it will be disabled and hidden.

The ownership of the action object is not transferred. If the action is destroyed it will be removed automatically from the KirigamiActionCollection.

Parameters
nameThe name by which the action be retrieved again from the collection.
actionThe action to add.
Returns
the same as the action given as parameter. This is just for convenience (chaining calls) and consistency with the other addAction methods, you can also simply ignore the return value.

Definition at line 173 of file kirigamiactioncollection.cpp.

◆ addAction() [3/3]

QAction * KirigamiActionCollection::addAction ( KStandardActions::StandardAction actionType,
const QString & name,
const Receiver * receiver,
Func slot )
inline

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.

The action can be retrieved later from the collection by its standard name as per KStandardActions::stdName.

The KirigamiActionCollection takes ownership of the action object.

Parameters
actionTypeThe standard action type of the action to create.
nameThe name by which the action be retrieved again from the collection.
receiverThe QObject to connect the triggered(bool) signal to.
slotThe slot or lambda to connect the triggered(bool) signal to.
Returns
new action of the given type ActionType.

Definition at line 303 of file kirigamiactioncollection.h.

◆ addActions()

void KirigamiActionCollection::addActions ( const QList< QAction * > & actions)

Adds a list of actions to the collection.

The objectName of the actions is used as their internal name in the collection.

The ownership of the action objects is not transferred. If the action is destroyed it will be removed automatically from the KirigamiActionCollection.

Uses addAction(const QString&, QAction*).

Parameters
actionsthe list of the actions to add.
See also
addAction()

Definition at line 260 of file kirigamiactioncollection.cpp.

◆ allCollections()

const QList< KirigamiActionCollection * > & KirigamiActionCollection::allCollections ( )
static

Access the list of all action collections in existence for this app.

Definition at line 493 of file kirigamiactioncollection.cpp.

◆ changed

void KirigamiActionCollection::changed ( )
signal

Emitted when an action has been inserted into, or removed from, this action collection.

◆ clear()

void KirigamiActionCollection::clear ( )

Clears the entire action collection, deleting all actions.

Definition at line 82 of file kirigamiactioncollection.cpp.

◆ componentDisplayName()

QString KirigamiActionCollection::componentDisplayName ( ) const

The display name for the associated component.

Definition at line 135 of file kirigamiactioncollection.cpp.

◆ componentName()

QString KirigamiActionCollection::componentName ( ) const

The component name with which this class is associated.

Definition at line 125 of file kirigamiactioncollection.cpp.

◆ configGroup()

QString KirigamiActionCollection::configGroup ( ) const

Returns the KConfig group with which settings will be loaded and saved.

Definition at line 318 of file kirigamiactioncollection.cpp.

◆ configIsGlobal()

bool KirigamiActionCollection::configIsGlobal ( ) const

Returns whether this action collection's configuration should be global to KDE ( true ), or specific to the application ( false ).

Definition at line 328 of file kirigamiactioncollection.cpp.

◆ connectNotify()

void KirigamiActionCollection::connectNotify ( const QMetaMethod & signal)
overrideprotectedvirtual

Overridden to perform connections when someone wants to know whether an action was highlighted or triggered.

Reimplemented from QObject.

Definition at line 467 of file kirigamiactioncollection.cpp.

◆ count()

int KirigamiActionCollection::count ( ) const

Returns the number of actions in the collection.

This is equivalent to actions().count().

Definition at line 106 of file kirigamiactioncollection.cpp.

◆ defaultShortcut()

QKeySequence KirigamiActionCollection::defaultShortcut ( QAction * action)
static

Get the default primary shortcut for the given action.

Parameters
actionthe action for which the default primary shortcut should be returned.
Returns
the default primary shortcut of the given action

Definition at line 284 of file kirigamiactioncollection.cpp.

◆ defaultShortcuts()

QList< QKeySequence > KirigamiActionCollection::defaultShortcuts ( QAction * action)
static

Get the default shortcuts for the given action.

Parameters
actionthe action for which the default shortcuts should be returned.
Returns
the default shortcuts of the given action

Definition at line 290 of file kirigamiactioncollection.cpp.

◆ inserted

void KirigamiActionCollection::inserted ( QAction * action)
signal

Indicates that action was inserted into this action collection.

◆ isEmpty()

bool KirigamiActionCollection::isEmpty ( ) const

Returns whether the action collection is empty or not.

Definition at line 111 of file kirigamiactioncollection.cpp.

◆ isShortcutsConfigurable()

bool KirigamiActionCollection::isShortcutsConfigurable ( QAction * action)
static

Returns true if the given action's shortcuts may be configured by the user.

Parameters
actionthe action for the hint should be verified.

Definition at line 306 of file kirigamiactioncollection.cpp.

◆ readSettings()

void KirigamiActionCollection::readSettings ( KConfigGroup * config = nullptr)

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 338 of file kirigamiactioncollection.cpp.

◆ removeAction()

void KirigamiActionCollection::removeAction ( QAction * action)

Removes an action from the collection and deletes it.

Parameters
actionThe action to remove.

Definition at line 267 of file kirigamiactioncollection.cpp.

◆ setComponentDisplayName()

void KirigamiActionCollection::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 130 of file kirigamiactioncollection.cpp.

◆ setComponentName()

void KirigamiActionCollection::setComponentName ( const QString & componentName)

Set the componentName associated with this action collection.

Warning
Don't call this method on a KirigamiActionCollection that contains actions. This is not supported.
Parameters
componentDatathe 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 116 of file kirigamiactioncollection.cpp.

◆ setConfigGlobal()

void KirigamiActionCollection::setConfigGlobal ( bool global)

Set whether this action collection's configuration should be global to KDE ( true ), or specific to the application ( false ).

Definition at line 333 of file kirigamiactioncollection.cpp.

◆ setConfigGroup()

void KirigamiActionCollection::setConfigGroup ( const QString & group)

Sets group as the KConfig group with which settings will be loaded and saved.

Definition at line 323 of file kirigamiactioncollection.cpp.

◆ setDefaultShortcut()

void KirigamiActionCollection::setDefaultShortcut ( QAction * action,
const QKeySequence & shortcut )
static

Set the default shortcut for the given action.

Parameters
actionthe action for which the default shortcut should be set.
shortcutthe shortcut to use for the given action in its specified shortcutContext()

Definition at line 295 of file kirigamiactioncollection.cpp.

◆ setDefaultShortcuts()

void KirigamiActionCollection::setDefaultShortcuts ( QAction * action,
const QList< QKeySequence > & shortcuts )
static

Set the default shortcuts for the given action.

Parameters
actionthe action for which the default shortcut should be set.
shortcutsthe shortcuts to use for the given action in its specified shortcutContext()

Definition at line 300 of file kirigamiactioncollection.cpp.

◆ setShortcutsConfigurable()

void KirigamiActionCollection::setShortcutsConfigurable ( QAction * action,
bool configurable )
static

Indicate whether the user may configure the action's shortcuts.

Parameters
actionthe action for the hint should be verified.
configurableset to true if the shortcuts of the given action may be configured by the user, otherwise false.

Definition at line 313 of file kirigamiactioncollection.cpp.

◆ slotActionTriggered

void KirigamiActionCollection::slotActionTriggered ( )
protectedvirtualslot

Definition at line 432 of file kirigamiactioncollection.cpp.

◆ takeAction()

QAction * KirigamiActionCollection::takeAction ( QAction * action)

Removes an action from the collection.

The ownership of the action object is not changed.

Parameters
actionthe action to remove.

Definition at line 272 of file kirigamiactioncollection.cpp.

◆ writeSettings()

void KirigamiActionCollection::writeSettings ( KConfigGroup * config = nullptr,
bool writeDefaults = false,
QAction * oneAction = nullptr ) const

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
configConfig object to save to, or null (see above)
writeDefaultsset to true to write settings which are already at defaults.
oneActionpass 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 369 of file kirigamiactioncollection.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:54:39 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.