• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • kdeui
  • util
kundostack.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 Copyright (C) 2006 Peter Simonsson <peter.simonsson@gmail.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include "kundostack.h"
21
22#include <QAction>
23#include <QKeySequence>
24#include <QList>
25
26#include <kstandardaction.h>
27#include <kstandardshortcut.h>
28#include <kicon.h>
29#include <kactioncollection.h>
30#include <klocale.h>
31
32KUndoStack::KUndoStack(QObject* parent)
33: QUndoStack(parent)
34{
35}
36
37QAction* KUndoStack::createRedoAction(KActionCollection* actionCollection, const QString& actionName)
38{
39 QAction* action = QUndoStack::createRedoAction(actionCollection);
40
41 if(actionName.isEmpty()) {
42 action->setObjectName(KStandardAction::name(KStandardAction::Redo));
43 } else {
44 action->setObjectName(actionName);
45 }
46
47 action->setIcon(KIcon("edit-redo"));
48 action->setIconText(i18n("Redo"));
49 action->setShortcuts(KStandardShortcut::redo());
50
51 actionCollection->addAction(action->objectName(), action);
52
53 return action;
54}
55
56QAction* KUndoStack::createUndoAction(KActionCollection* actionCollection, const QString& actionName)
57{
58 QAction* action = QUndoStack::createUndoAction(actionCollection);
59
60 if(actionName.isEmpty()) {
61 action->setObjectName(KStandardAction::name(KStandardAction::Undo));
62 } else {
63 action->setObjectName(actionName);
64 }
65
66 action->setIcon(KIcon("edit-undo"));
67 action->setIconText(i18n("Undo"));
68 action->setShortcuts(KStandardShortcut::undo());
69
70 actionCollection->addAction(action->objectName(), action);
71
72 return action;
73}
74
75#include "kundostack.moc"
KActionCollection
A container for a set of QAction objects.
Definition: kactioncollection.h:57
KActionCollection::addAction
QAction * addAction(const QString &name, QAction *action)
Add an action under the given name to the collection.
Definition: kactioncollection.cpp:217
KIcon
A wrapper around QIcon that provides KDE icon features.
Definition: kicon.h:41
KUndoStack::createUndoAction
QAction * createUndoAction(KActionCollection *actionCollection, const QString &actionName=QString())
Creates an undo action with the default KDE shortcut and icon and adds it to actionCollection.
Definition: kundostack.cpp:56
KUndoStack::KUndoStack
KUndoStack(QObject *parent=0)
Constructs a KUndoStack with parent as parent.
Definition: kundostack.cpp:32
KUndoStack::createRedoAction
QAction * createRedoAction(KActionCollection *actionCollection, const QString &actionName=QString())
Creates an redo action with the default shortcut and icon and adds it to actionCollection.
Definition: kundostack.cpp:37
QAction
QObject
QUndoStack
kactioncollection.h
kicon.h
klocale.h
i18n
QString i18n(const char *text)
kstandardaction.h
kstandardshortcut.h
kundostack.h
KStandardAction::name
const char * name(StandardAction id)
This will return the internal name of a given standard action.
Definition: kstandardaction.cpp:223
KStandardAction::Undo
@ Undo
Definition: kstandardaction.h:133
KStandardAction::Redo
@ Redo
Definition: kstandardaction.h:133
KStandardShortcut::undo
const KShortcut & undo()
Undo last operation.
Definition: kstandardshortcut.cpp:340
KStandardShortcut::redo
const KShortcut & redo()
Redo.
Definition: kstandardshortcut.cpp:341
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal