KXmlGui

kundoactions.cpp
1 /*
2  This file is part of the KDE project
3  SPDX-FileCopyrightText: 2006 Peter Simonsson <[email protected]>
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 <kactioncollection.h>
14 #include <kstandardaction.h>
15 #include <kstandardshortcut.h>
16 #include <klocalizedstring.h>
17 
18 QAction *KUndoActions::createRedoAction(QUndoStack *undoStack, KActionCollection *actionCollection, const QString &actionName)
19 {
20  QAction *action = undoStack->createRedoAction(actionCollection);
21 
22  if (actionName.isEmpty()) {
24  } else {
25  action->setObjectName(actionName);
26  }
27 
28  action->setIcon(QIcon::fromTheme(QStringLiteral("edit-redo")));
29  action->setIconText(i18n("Redo"));
30  actionCollection->setDefaultShortcuts(action, KStandardShortcut::redo());
31 
32  actionCollection->addAction(action->objectName(), action);
33 
34  return action;
35 }
36 
37 QAction *KUndoActions::createUndoAction(QUndoStack *undoStack, KActionCollection *actionCollection, const QString &actionName)
38 {
39  QAction *action = undoStack->createUndoAction(actionCollection);
40 
41  if (actionName.isEmpty()) {
43  } else {
44  action->setObjectName(actionName);
45  }
46 
47  action->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
48  action->setIconText(i18n("Undo"));
49  actionCollection->setDefaultShortcuts(action, KStandardShortcut::undo());
50 
51  actionCollection->addAction(action->objectName(), action);
52 
53  return action;
54 }
A container for a set of QAction objects.
const QList< QKeySequence > & redo()
KXMLGUI_EXPORT QAction * createUndoAction(QUndoStack *undoStack, KActionCollection *actionCollection, const QString &actionName=QString())
Creates an undo action with the default KDE shortcut and icon and adds it to actionCollection.
void setIconText(const QString &text)
Q_INVOKABLE void setDefaultShortcuts(QAction *action, const QList< QKeySequence > &shortcuts)
Set the default shortcuts for the given action.
void setIcon(const QIcon &icon)
const char * name(StandardAction id)
Q_INVOKABLE QAction * addAction(const QString &name, QAction *action)
Add an action under the given name to the collection.
const QList< QKeySequence > & undo()
QAction * createUndoAction(QObject *parent, const QString &prefix) const const
void setObjectName(const QString &name)
bool isEmpty() const const
QAction * createRedoAction(QObject *parent, const QString &prefix) const const
QString i18n(const char *text, const TYPE &arg...)
QIcon fromTheme(const QString &name)
KXMLGUI_EXPORT QAction * createRedoAction(QUndoStack *undoStack, KActionCollection *actionCollection, const QString &actionName=QString())
Creates an redo action with the default shortcut and icon and adds it to actionCollection.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 12 2020 22:50:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.