diff options
author | Grace Karanja <gracie.karanja89@gmail.com> | 2015-02-11 09:26:17 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-02-11 08:00:39 -0800 |
commit | ef14798d6d5e575a08aa8affc0815962813ecf29 (patch) | |
tree | c32ea22fb11a25b389344298f922081629e40271 /qt-ui/mainwindow.cpp | |
parent | 013da6b0af3e3dd5d074f2dbbc342d9b948717b4 (diff) | |
download | subsurface-ef14798d6d5e575a08aa8affc0815962813ecf29.tar.gz |
Add undo stack
Add an instance of QUndoStack in the mainwindow, and add undo/redo
actions in the edit menu. The QUndoStack will have a collection
of QUndoCommands to process the undo and redo events.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r-- | qt-ui/mainwindow.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 9908e2402..a0e4f128d 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -36,6 +36,7 @@ #include "usermanual.h" #endif #include <QNetworkProxy> +#include <QUndoStack> MainWindow *MainWindow::m_Instance = NULL; @@ -180,6 +181,16 @@ MainWindow::MainWindow() : QMainWindow(), toolBar->setContentsMargins(zeroMargins); updateManager = new UpdateManager(this); + + undoStack = new QUndoStack(this); + QAction *undoAction = undoStack->createUndoAction(this, tr("&Undo")); + QAction *redoAction = undoStack->createRedoAction(this, tr("&Redo")); + undoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z)); + redoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z)); + QList<QAction*>undoRedoActions; + undoRedoActions.append(undoAction); + undoRedoActions.append(redoAction); + ui.menu_Edit->addActions(undoRedoActions); } MainWindow::~MainWindow() |