diff --git a/mainwindow.cpp b/mainwindow.cpp index 9dc7987..f8fdb53 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -3,6 +3,7 @@ #include #include +#include #include "../../ApplicationConfig.h" #include "data/settingshandler.h" @@ -196,6 +197,20 @@ void MainWindow::createFileActions() { } void MainWindow::createEditActions() { + m_modelUndoStack = m_core->getModUndoStack(); + + connect(m_modelUndoStack.get(), SIGNAL(cleanChanged(bool)), this, + SLOT(onCleanStateChanged(bool))); + m_undoAct.reset(m_modelUndoStack->createUndoAction(this, tr("&Undo"))); + m_undoAct->setShortcuts(QKeySequence::Undo); + m_undoAct->setStatusTip(tr("Undo the last operation")); + ui->menu_Edit->addAction(m_undoAct.get()); + + m_redoAct.reset(m_modelUndoStack->createRedoAction(this, tr("&Redo"))); + m_redoAct->setShortcuts(QKeySequence::Redo); + m_redoAct->setStatusTip(tr("Redo the last operation")); + ui->menu_Edit->addAction(m_redoAct.get()); + m_cutAct = make_unique(tr("Cu&t"), this); m_cutAct->setShortcuts(QKeySequence::Cut); m_cutAct->setStatusTip( diff --git a/mainwindow.h b/mainwindow.h index 40ea7ec..de54266 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -7,6 +7,7 @@ QT_BEGIN_NAMESPACE class QAbstractItemModel; +class QUndoStack; namespace Ui { class MainWindow; } @@ -43,6 +44,7 @@ class MainWindow : public QMainWindow { // GenericCore* m_core; unique_ptr m_core; shared_ptr m_tableModel; + shared_ptr m_modelUndoStack; /// File actions unique_ptr m_newFileAct;