Krita Source Code Documentation
Loading...
Searching...
No Matches
kactioncollection.h
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 SPDX-FileCopyrightText: 1999 Reginald Stadlbauer <reggie@kde.org>
3 SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org>
4 SPDX-FileCopyrightText: 2000 Nicolas Hadacek <haadcek@kde.org>
5 SPDX-FileCopyrightText: 2000 Kurt Granroth <granroth@kde.org>
6 SPDX-FileCopyrightText: 2000 Michael Koch <koch@kde.org>
7 SPDX-FileCopyrightText: 2001 Holger Freyther <freyther@kde.org>
8 SPDX-FileCopyrightText: 2002 Ellis Whitehead <ellis@kde.org>
9 SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org>
10
11 SPDX-License-Identifier: LGPL-2.0-only
12*/
13
14#ifndef KACTIONCOLLECTION_H
15#define KACTIONCOLLECTION_H
16#include "config-xmlgui.h"
17#include <kritawidgetutils_export.h>
18#include <kstandardaction.h>
19#include <QObject>
20
21class QAction;
23class KConfigGroup;
24class QActionGroup;
25class QString;
27
43class KRITAWIDGETUTILS_EXPORT KisKActionCollection : public QObject
44{
45 friend class KisKXMLGUIClient;
46
47 Q_OBJECT
48
49 Q_PROPERTY(QString configGroup READ configGroup WRITE setConfigGroup)
50
51public:
56 explicit KisKActionCollection(QObject *parent, const QString &cName = QString());
57
61 ~KisKActionCollection() override;
62
66 static const QList<KisKActionCollection *> &allCollections();
67
71 void clear();
72
80 void associateWidget(QWidget *widget) const;
81
90 void addAssociatedWidget(QWidget *widget);
91
96 void removeAssociatedWidget(QWidget *widget);
97
101 QList<QWidget *> associatedWidgets() const;
102
106 void clearAssociatedWidgets();
107
111 QString configGroup() const;
112
116 void setConfigGroup(const QString &group);
117
125 void readSettings();
126
130 void updateShortcuts();
131
149 void writeSettings(KConfigGroup *config = 0, bool writeScheme = false, QAction *oneAction = 0) const;
150
156 int count() const;
157
161 bool isEmpty() const;
162
168 QAction *action(int index) const;
169
177 QAction *action(const QString &name) const;
178
185 QList<QAction *> actions() const;
186
190 const QList<QAction *> actionsWithoutGroup() const;
191
195 const QList<QActionGroup *> actionGroups() const;
196
207 void setComponentName(const QString &componentName);
208
210 QString componentName() const;
211
217 void setComponentDisplayName(const QString &displayName);
218
220 QString componentDisplayName() const;
221
225 const KisKXMLGUIClient *parentGUIClient() const;
226
227
231 QList<KisKActionCategory *> categories() const;
232
233
239 KisKActionCategory *getCategory(const QString &categoryName);
240
241Q_SIGNALS:
245 void inserted(QAction *action);
246
251 QT_MOC_COMPAT void actionHighlighted(QAction *action);
252
256 void actionHovered(QAction *action);
257
261 void actionTriggered(QAction *action);
262
263protected:
265 void connectNotify(const QMetaMethod &signal) override;
266
267protected Q_SLOTS:
268 virtual void slotActionTriggered();
269
274 QT_MOC_COMPAT virtual void slotActionHighlighted();
275
276private Q_SLOTS:
277 void slotActionHovered();
278
279public:
296 Q_INVOKABLE QAction *addAction(const QString &name, QAction *action);
297
303 Q_INVOKABLE QAction *addCategorizedAction(const QString &name, QAction *action, const QString &categoryName);
304
317 void addActions(const QList<QAction *> &actions);
318
323 void removeAction(QAction *action);
324
329 QAction *takeAction(QAction *action);
330
349 QAction *addAction(KStandardAction::StandardAction actionType, const QObject *receiver = 0, const char *member = 0);
350
369 QAction *addAction(KStandardAction::StandardAction actionType, const QString &name,
370 const QObject *receiver = 0, const char *member = 0);
371
394 QAction *addAction(const QString &name, const QObject *receiver = 0, const char *member = 0);
395
414 template<class ActionType>
415 ActionType *add(const QString &name, const QObject *receiver = 0, const char *member = 0)
416 {
417 ActionType *a = new ActionType(this);
418 if (receiver && member) {
419 connect(a, SIGNAL(triggered(bool)), receiver, member);
420 }
421 addAction(name, a);
422 return a;
423 }
424
432 QKeySequence defaultShortcut(QAction *action) const;
433
441 QList<QKeySequence> defaultShortcuts(QAction *action) const;
442
443 //TODO KF6: Make setDefaultShortcut static
453 void setDefaultShortcut(QAction *action, const QKeySequence &shortcut);
454
464 Q_INVOKABLE void setDefaultShortcuts(QAction *action, const QList<QKeySequence> &shortcuts);
465
472 bool isShortcutsConfigurable(QAction *action) const;
473
481 void setShortcutsConfigurable(QAction *action, bool configurable);
482
483private:
484 Q_PRIVATE_SLOT(d, void _k_actionDestroyed(QObject *))
485 Q_PRIVATE_SLOT(d, void _k_associatedWidgetDestroyed(QObject *))
486
487 KisKActionCollection(const KisKXMLGUIClient *parent); // used by KisKXMLGUIClient
488
491};
492
493#endif
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
A container for a set of QAction objects.
void inserted(QAction *action)
ActionType * add(const QString &name, const QObject *receiver=0, const char *member=0)
QT_MOC_COMPAT void actionHighlighted(QAction *action)
class KisKActionCollectionPrivate *const d
void actionTriggered(QAction *action)
void actionHovered(QAction *action)