KXmlGui

kundoactions.cpp
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(actionCollection);
22
23 if (actionName.isEmpty()) {
25 } else {
26 action->setObjectName(actionName);
27 }
28
29 action->setIcon(QIcon::fromTheme(QStringLiteral("edit-redo")));
30 action->setIconText(i18n("Redo"));
32
33 actionCollection->addAction(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(actionCollection);
41
42 if (actionName.isEmpty()) {
44 } else {
45 action->setObjectName(actionName);
46 }
47
48 action->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
49 action->setIconText(i18n("Undo"));
51
52 actionCollection->addAction(action->objectName(), action);
53
54 return action;
55}
A container for a set of QAction objects.
Q_INVOKABLE QAction * addAction(const QString &name, QAction *action)
Add an action under the given name to the collection.
static Q_INVOKABLE void setDefaultShortcuts(QAction *action, const QList< QKeySequence > &shortcuts)
Set the default shortcuts for the given action.
QString i18n(const char *text, const TYPE &arg...)
QString name(StandardAction id)
const QList< QKeySequence > & undo()
const QList< QKeySequence > & redo()
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.
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 setIcon(const QIcon &icon)
void setIconText(const QString &text)
QIcon fromTheme(const QString &name)
void setObjectName(QAnyStringView name)
bool isEmpty() const const
QAction * createRedoAction(QObject *parent, const QString &prefix) const const
QAction * createUndoAction(QObject *parent, const QString &prefix) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:54:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.