Krita Source Code Documentation
Loading...
Searching...
No Matches
KisActionsSnapshot Class Reference

The KisActionsSnapshot class. More...

#include <KisActionsSnapshot.h>

Classes

struct  Private
 

Public Member Functions

QMap< QString, KisKActionCollection * > actionCollections ()
 
void addAction (const QString &name, QAction *action)
 registers the action in the snapshot and sorts it into a proper category. The action is not owned by the snapshot.
 
 KisActionsSnapshot ()
 
 ~KisActionsSnapshot ()
 

Private Attributes

const QScopedPointer< Privatem_d
 

Detailed Description

The KisActionsSnapshot class.

Definition at line 22 of file KisActionsSnapshot.h.

Constructor & Destructor Documentation

◆ KisActionsSnapshot()

KisActionsSnapshot::KisActionsSnapshot ( )

Definition at line 30 of file KisActionsSnapshot.cpp.

31 : m_d(new Private)
32{
34 m_d->nonRegisteredShortcuts = QSet<QString>(registeredShortcutIds.begin(), registeredShortcutIds.end());
35}
QList< QString > registeredShortcutIds() const
static KisActionRegistry * instance()
const QScopedPointer< Private > m_d

References KisActionRegistry::instance(), m_d, and KisActionRegistry::registeredShortcutIds().

◆ ~KisActionsSnapshot()

KisActionsSnapshot::~KisActionsSnapshot ( )

Definition at line 37 of file KisActionsSnapshot.cpp.

38{
39}

Member Function Documentation

◆ actionCollections()

QMap< QString, KisKActionCollection * > KisActionsSnapshot::actionCollections ( )

Returns all action collections of the current snapshot

WARNING: the collections are owned by the snapshot! Don't destroy the snapshot before you are done with the collections!

A small heuristics to show warnings only when unknown shortcuts appear in the non-registered list

Definition at line 67 of file KisActionsSnapshot.cpp.

68{
73 if (m_d->nonRegisteredShortcuts.size() > 4 &&
74 m_d->nonRegisteredShortcuts.size() < 160) {
75
76 warnKrita << "WARNING: The following shortcuts are not registered in the collection, "
77 "they might have wrong shortcuts in the end:";
78 Q_FOREACH (const QString &str, m_d->nonRegisteredShortcuts) {
79 warnKrita << str;
80 }
81 warnKrita << "=== end ===";
82 }
83
84 // try to workaround non-registered shortcuts by faking them manually
85 Q_FOREACH (const QString &str, m_d->nonRegisteredShortcuts) {
86 QAction *action = KisActionRegistry::instance()->makeQAction(str, 0);
87 m_d->fakeActions << action;
88 addAction(action->objectName(), action);
89 }
90
91 return m_d->actionCollections;
92}
QAction * makeQAction(const QString &name, QObject *parent=0)
void addAction(const QString &name, QAction *action)
registers the action in the snapshot and sorts it into a proper category. The action is not owned by ...
#define warnKrita
Definition kis_debug.h:87

References addAction(), KisActionRegistry::instance(), m_d, KisActionRegistry::makeQAction(), and warnKrita.

◆ addAction()

void KisActionsSnapshot::addAction ( const QString & name,
QAction * action )

registers the action in the snapshot and sorts it into a proper category. The action is not owned by the snapshot.

Parameters
nameid string of the action
actionthe action itself

Definition at line 41 of file KisActionsSnapshot.cpp.

42{
43 m_d->nonRegisteredShortcuts.remove(name);
45
46 if (!cat.isValid()) {
47 warnKrita << "WARNING: Uncategorized action" << name << "Dropping...";
48 return;
49 }
50
51#ifdef ACTIONS_CHECKSUM_SANITY_CHECK
52 if (!KisActionRegistry::instance()->sanityCheckPropertized(action->objectName())) {
53 warnKrita << "WARNING: action" << name << "was not propertized!" << ppVar(action->property("isShortcutConfigurable").toBool());
54 }
55#endif /* ACTIONS_CHECKSUM_SANITY_CHECK */
56
57 KisKActionCollection *collection = m_d->actionCollections[cat.componentName];
58
59 if (!collection) {
60 collection = new KisKActionCollection(0, cat.componentName);
61 m_d->actionCollections.insert(cat.componentName, collection);
62 }
63
64 collection->addCategorizedAction(name, action, cat.categoryName);
65}
ActionCategory fetchActionCategory(const QString &name) const
A container for a set of QAction objects.
Q_INVOKABLE QAction * addCategorizedAction(const QString &name, QAction *action, const QString &categoryName)
#define ppVar(var)
Definition kis_debug.h:155
const char * name(StandardAction id)

References KisKActionCollection::addCategorizedAction(), KisActionRegistry::ActionCategory::categoryName, KisActionRegistry::ActionCategory::componentName, KisActionRegistry::fetchActionCategory(), KisActionRegistry::instance(), KisActionRegistry::ActionCategory::isValid(), m_d, ppVar, and warnKrita.

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisActionsSnapshot::m_d
private

Definition at line 47 of file KisActionsSnapshot.h.


The documentation for this class was generated from the following files: