KXmlGui

kactioncategory.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2008 Michael Jansen <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KACTIONCATEGORY_H
9 #define KACTIONCATEGORY_H
10 
11 #include <kxmlgui_export.h>
12 
13 #include <QObject>
14 #include <QString>
15 #include <QList>
16 
17 #include <kstandardaction.h>
18 
19 #include "kactioncollection.h"
20 
21 struct KActionCategoryPrivate;
22 
23 class QAction;
24 
83 class KXMLGUI_EXPORT KActionCategory : public QObject
84 {
85  Q_OBJECT
86 
87  Q_PROPERTY(QString text READ text WRITE setText)
88 
89 public:
90 
94  explicit KActionCategory(const QString &text, KActionCollection *parent = nullptr);
95 
99  virtual ~KActionCategory();
100 
110  QAction *addAction(const QString &name, QAction *action);
111 
112  QAction *addAction(
114  const QObject *receiver = nullptr,
115  const char *member = nullptr);
116 
117  QAction *addAction(
119  const QString &name,
120  const QObject *receiver = nullptr,
121  const char *member = nullptr);
122 
123  QAction *addAction(
124  const QString &name,
125  const QObject *receiver = nullptr,
126  const char *member = nullptr);
127 
128  template<class ActionType>
129  ActionType *add(
130  const QString &name,
131  const QObject *receiver = nullptr,
132  const char *member = nullptr)
133  {
134  ActionType *action = collection()->add<ActionType>(name, receiver, member);
135  addAction(action);
136  return action;
137  }
138 
140 
144  const QList<QAction *> actions() const;
145 
149  KActionCollection *collection() const;
150 
154  QString text() const;
155 
159  void setText(const QString &text);
160 
161 private:
162 
166  void unlistAction(QAction *action);
167 
171  void addAction(QAction *action);
172 
174  friend class KActionCollectionPrivate;
175 
177  KActionCategoryPrivate *const d;
178 };
179 
180 #endif /* #ifndef KACTIONCATEGORY_H */
Categorize actions for KShortcutsEditor.
A container for a set of QAction objects.
Q_PROPERTY(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Sep 21 2020 22:51:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.