From 370bcd5a4184c491870b296e45dfd7c7236f3511 Mon Sep 17 00:00:00 2001 From: Bent Witthold Date: Sat, 6 Dec 2025 10:36:21 +0100 Subject: [PATCH] Retrieve QUndoStack pointer from core and create actions for undo and redo. --- mainwindow.cpp | 15 +++++++++++++++ mainwindow.h | 2 ++ 2 files changed, 17 insertions(+) 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;