KActionCategory Class
Categorize actions for KShortcutsEditor. More...
Header: | #include <KActionCategory> |
CMake: | find_package(KF6 REQUIRED COMPONENTS XmlGui) target_link_libraries(mytarget PRIVATE KF6::XmlGui) |
Inherits: | QObject |
Properties
- text : QString
Public Functions
KActionCategory(const QString &text, KActionCollection *parent = nullptr) | |
virtual | ~KActionCategory() override |
const QList<QAction *> | actions() const |
QAction * | addAction(const QString &name, QAction *action) |
QAction * | addAction(KStandardAction::StandardAction actionType, const QObject *receiver = nullptr, const char *member = nullptr) |
QAction * | addAction(const QString &name, const QObject *receiver = nullptr, const char *member = nullptr) |
QAction * | addAction(KStandardAction::StandardAction actionType, const QString &name, const QObject *receiver = nullptr, const char *member = nullptr) |
KActionCollection * | collection() const |
void | setText(const QString &text) |
QString | text() const |
Detailed Description
KActionCategory provides a second level to organize the actions in KShortcutsEditor.
The first possibility is using more than one action collection. Each actions collection becomes a top level node.
- action collection 1
- first action
- second action
- third action
- action collection 2
- first action
- second action
- third action
Using KActionCategory it's possible to group the actions of one collection.
- action collection 1
- first action
- first category
- action 1 in category
- action 2 in category
- second action
The usage is analogous to action collections. Just create a category and use it instead of the collection to create the actions.
The synchronization between KActionCollection and KActionCategory is done internally. There is for example no need to remove actions from a category. It is done implicitly if the action is removed from the associated collection.
KActionCategory *file = new KActionCategory(i18n("File"), actionCollection()); file->addAction( KStandardActions::New, //< see KStandardAction this, //< Receiver &MyApp::fileNew); //< Slot // ... more actions added to file ... KActionCategory *edit = new KActionCategory(i18n("Edit"), actionCollection()); edit->addAction( KStandardActions::Copy, //< see KStandardAction this, //< Receiver &MyApp::fileNew); //< Slot // ...
Member Function Documentation
[explicit]
KActionCategory::KActionCategory(const QString &text, KActionCollection *parent = nullptr)
Constructs a new KActionCategory object named text as a child of parent.
[override virtual noexcept]
KActionCategory::~KActionCategory()
Destructor.
const QList<QAction *> KActionCategory::actions() const
Returns the actions belonging to this category.
QAction *KActionCategory::addAction(const QString &name, QAction *action)
Adds an action to the category.
These methods are provided for your convenience. They call the corresponding method of KActionCollection.
QAction *KActionCategory::addAction(KStandardAction::StandardAction actionType, const QObject *receiver = nullptr, const char *member = nullptr)
This function overloads addAction(const QString &name, QAction *action).
QAction *KActionCategory::addAction(const QString &name, const QObject *receiver = nullptr, const char *member = nullptr)
* @deprecated since 6.9, use PMF overload ======= /*! *
This function overloads addAction(const QString &name, QAction *action).
>>>>>>> eedf9c04 (Port to QDoc)
QAction *KActionCategory::addAction(KStandardAction::StandardAction actionType, const QString &name, const QObject *receiver = nullptr, const char *member = nullptr)
This function overloads addAction(const QString &name, QAction *action).
KActionCollection *KActionCategory::collection() const
Returns the action collection this category is associated with.
void KActionCategory::setText(const QString &text)
Sets the action category's descriptive text.
Note: Setter function for property text.
See also text().
QString KActionCategory::text() const
Returns the action category's descriptive text.
Note: Getter function for property text.
See also setText().