File indexing completed on 2024-04-21 14:56:00
0001 /* This file is part of the KDE project 0002 Copyright (C) 2006 Peter Simonsson <peter.simonsson@gmail.com> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #include "kundostack.h" 0021 0022 #include <QAction> 0023 #include <QKeySequence> 0024 #include <QList> 0025 0026 #include <kstandardaction.h> 0027 #include <kstandardshortcut.h> 0028 #include <kactioncollection.h> 0029 #include <klocalizedstring.h> 0030 0031 KUndoStack::KUndoStack(QObject *parent) 0032 : QUndoStack(parent) 0033 { 0034 } 0035 0036 QAction *KUndoStack::createRedoAction(KActionCollection *actionCollection, const QString &actionName) 0037 { 0038 QAction *action = QUndoStack::createRedoAction(actionCollection); 0039 0040 if (actionName.isEmpty()) { 0041 action->setObjectName(KStandardAction::name(KStandardAction::Redo)); 0042 } else { 0043 action->setObjectName(actionName); 0044 } 0045 0046 action->setIcon(QIcon::fromTheme("edit-redo")); 0047 action->setIconText(i18n("Redo")); 0048 action->setShortcuts(KStandardShortcut::redo()); 0049 0050 actionCollection->addAction(action->objectName(), action); 0051 0052 return action; 0053 } 0054 0055 QAction *KUndoStack::createUndoAction(KActionCollection *actionCollection, const QString &actionName) 0056 { 0057 QAction *action = QUndoStack::createUndoAction(actionCollection); 0058 0059 if (actionName.isEmpty()) { 0060 action->setObjectName(KStandardAction::name(KStandardAction::Undo)); 0061 } else { 0062 action->setObjectName(actionName); 0063 } 0064 0065 action->setIcon(QIcon::fromTheme("edit-undo")); 0066 action->setIconText(i18n("Undo")); 0067 action->setShortcuts(KStandardShortcut::undo()); 0068 0069 actionCollection->addAction(action->objectName(), action); 0070 0071 return action; 0072 } 0073 0074 #include "moc_kundostack.cpp"