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

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • 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 
32 KUndoStack::KUndoStack(QObject* parent)
33 : QUndoStack(parent)
34 {
35 }
36 
37 QAction* 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 
56 QAction* 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"
i18n
QString i18n(const char *text)
KActionCollection
A container for a set of QAction objects.
Definition: kactioncollection.h:56
KStandardAction::Redo
Definition: kstandardaction.h:133
KStandardShortcut::redo
const KShortcut & redo()
Redo.
Definition: kstandardshortcut.cpp:341
QAction::setIconText
void setIconText(const QString &text)
kactioncollection.h
KStandardShortcut::undo
const KShortcut & undo()
Undo last operation.
Definition: kstandardshortcut.cpp:340
QAction::setIcon
void setIcon(const QIcon &icon)
KStandardAction::name
const char * name(StandardAction id)
This will return the internal name of a given standard action.
Definition: kstandardaction.cpp:223
KActionCollection::addAction
QAction * addAction(const QString &name, QAction *action)
Add an action under the given name to the collection.
Definition: kactioncollection.cpp:217
KStandardAction::Undo
Definition: kstandardaction.h:133
klocale.h
QAction::setShortcuts
void setShortcuts(const QList< QKeySequence > &shortcuts)
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
QUndoStack::createUndoAction
QAction * createUndoAction(QObject *parent, const QString &prefix) const
QObject
QObject::setObjectName
void setObjectName(const QString &name)
QString::isEmpty
bool isEmpty() const
KIcon
A wrapper around QIcon that provides KDE icon features.
Definition: kicon.h:40
QString
kstandardaction.h
QUndoStack::createRedoAction
QAction * createRedoAction(QObject *parent, const QString &prefix) const
kstandardshortcut.h
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
kundostack.h
QAction
QUndoStack
KUndoStack::KUndoStack
KUndoStack(QObject *parent=0)
Constructs a KUndoStack with parent as parent.
Definition: kundostack.cpp:32
kicon.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:00 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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

Search



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