File indexing completed on 2024-09-01 13:31:38
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2006 Peter Simonsson <peter.simonsson@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "kundoactions.h" 0009 0010 #include <QAction> 0011 #include <QUndoStack> 0012 0013 #include <KLocalizedString> 0014 #include <KStandardAction> 0015 #include <KStandardShortcut> 0016 0017 #include <kactioncollection.h> 0018 0019 QAction *KUndoActions::createRedoAction(QUndoStack *undoStack, KActionCollection *actionCollection, const QString &actionName) 0020 { 0021 QAction *action = undoStack->createRedoAction(actionCollection); 0022 0023 if (actionName.isEmpty()) { 0024 action->setObjectName(QLatin1String(KStandardAction::name(KStandardAction::Redo))); 0025 } else { 0026 action->setObjectName(actionName); 0027 } 0028 0029 action->setIcon(QIcon::fromTheme(QStringLiteral("edit-redo"))); 0030 action->setIconText(i18n("Redo")); 0031 actionCollection->setDefaultShortcuts(action, KStandardShortcut::redo()); 0032 0033 actionCollection->addAction(action->objectName(), action); 0034 0035 return action; 0036 } 0037 0038 QAction *KUndoActions::createUndoAction(QUndoStack *undoStack, KActionCollection *actionCollection, const QString &actionName) 0039 { 0040 QAction *action = undoStack->createUndoAction(actionCollection); 0041 0042 if (actionName.isEmpty()) { 0043 action->setObjectName(QLatin1String(KStandardAction::name(KStandardAction::Undo))); 0044 } else { 0045 action->setObjectName(actionName); 0046 } 0047 0048 action->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo"))); 0049 action->setIconText(i18n("Undo")); 0050 actionCollection->setDefaultShortcuts(action, KStandardShortcut::undo()); 0051 0052 actionCollection->addAction(action->objectName(), action); 0053 0054 return action; 0055 }