Krita Source Code Documentation
Loading...
Searching...
No Matches
KisKUndoActions Namespace Reference

Functions

KRITAWIDGETUTILS_EXPORT QAction * createRedoAction (QUndoStack *undoStack, KisKActionCollection *actionCollection, const QString &actionName=QString())
 
KRITAWIDGETUTILS_EXPORT QAction * createUndoAction (QUndoStack *undoStack, KisKActionCollection *actionCollection, const QString &actionName=QString())
 

Detailed Description

Provides functions that creates undo/redo actions for a QUndoStack with KDE's default icons and shortcuts. See QUndoStack for more information.

Since
5.0

Function Documentation

◆ createRedoAction()

QAction * KisKUndoActions::createRedoAction ( QUndoStack * undoStack,
KisKActionCollection * actionCollection,
const QString & actionName = QString() )

Creates an redo action with the default shortcut and icon and adds it to actionCollection

Parameters
undoStackthe QUndoStack the action triggers the redo on
actionCollectionthe KisKActionCollection that should be the parent of the action
actionNamethe created action's object name, empty string will set it to the KDE default
Returns
the created action.

Definition at line 20 of file kundoactions.cpp.

21{
22 QAction *action = undoStack->createRedoAction(actionCollection);
23
24 if (actionName.isEmpty()) {
25 action->setObjectName(QLatin1String(KStandardAction::name(KStandardAction::Redo)));
26 } else {
27 action->setObjectName(actionName);
28 }
29
30 action->setIcon(KisIconUtils::loadIcon(QStringLiteral("edit-redo")));
31 action->setIconText(i18n("Redo"));
32 action->setShortcuts(KStandardShortcut::redo());
33
34 actionCollection->addAction(action->objectName(), action);
35
36 return action;
37}
Q_INVOKABLE QAction * addAction(const QString &name, QAction *action)
const char * name(StandardAction id)
QIcon loadIcon(const QString &name)

References KisKActionCollection::addAction(), KisIconUtils::loadIcon(), KStandardAction::name(), and KStandardAction::Redo.

◆ createUndoAction()

QAction * KisKUndoActions::createUndoAction ( QUndoStack * undoStack,
KisKActionCollection * actionCollection,
const QString & actionName = QString() )

Creates an undo action with the default KDE shortcut and icon and adds it to actionCollection

Parameters
undoStackthe QUndoStack the action triggers the undo on
actionCollectionthe KisKActionCollection that should be the parent of the action
actionNamethe created action's object name, empty string will set it to the KDE default
Returns
the created action.

Definition at line 39 of file kundoactions.cpp.

40{
41 QAction *action = undoStack->createUndoAction(actionCollection);
42
43 if (actionName.isEmpty()) {
44 action->setObjectName(QLatin1String(KStandardAction::name(KStandardAction::Undo)));
45 } else {
46 action->setObjectName(actionName);
47 }
48
49 action->setIcon(KisIconUtils::loadIcon(QStringLiteral("edit-undo")));
50 action->setIconText(i18n("Undo"));
51 action->setShortcuts(KStandardShortcut::undo());
52
53 actionCollection->addAction(action->objectName(), action);
54
55 return action;
56}

References KisKActionCollection::addAction(), KisIconUtils::loadIcon(), KStandardAction::name(), and KStandardAction::Undo.