1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2006 Peter Simonsson <peter.simonsson@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "kundoactions.h"
9
10#include <QAction>
11#include <QUndoStack>
12
13#include <KLocalizedString>
14#include <KStandardAction>
15#include <KStandardShortcut>
16
17#include <kactioncollection.h>
18
19QAction *KUndoActions::createRedoAction(QUndoStack *undoStack, KActionCollection *actionCollection, const QString &actionName)
20{
21 QAction *action = undoStack->createRedoAction(parent: actionCollection);
22
23 if (actionName.isEmpty()) {
24 action->setObjectName(KStandardAction::name(id: KStandardAction::Redo));
25 } else {
26 action->setObjectName(actionName);
27 }
28
29 action->setIcon(QIcon::fromTheme(QStringLiteral("edit-redo")));
30 action->setIconText(i18n("Redo"));
31 KActionCollection::setDefaultShortcuts(action, shortcuts: KStandardShortcut::redo());
32
33 actionCollection->addAction(name: action->objectName(), action);
34
35 return action;
36}
37
38QAction *KUndoActions::createUndoAction(QUndoStack *undoStack, KActionCollection *actionCollection, const QString &actionName)
39{
40 QAction *action = undoStack->createUndoAction(parent: actionCollection);
41
42 if (actionName.isEmpty()) {
43 action->setObjectName(KStandardAction::name(id: KStandardAction::Undo));
44 } else {
45 action->setObjectName(actionName);
46 }
47
48 action->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
49 action->setIconText(i18n("Undo"));
50 KActionCollection::setDefaultShortcuts(action, shortcuts: KStandardShortcut::undo());
51
52 actionCollection->addAction(name: action->objectName(), action);
53
54 return action;
55}
56

source code of kxmlgui/src/kundoactions.cpp