From 8333be2044cfa277a922da959251f19a43f66691 Mon Sep 17 00:00:00 2001 From: Bent Witthold Date: Tue, 23 Dec 2025 10:18:00 +0100 Subject: [PATCH] Items can be saved via menu action and when exiting application with unclean undo stack. --- mainwindow.cpp | 10 +++++++--- mainwindow.h | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index da456be..b372b16 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -77,7 +77,7 @@ void MainWindow::closeEvent(QCloseEvent* event) { switch (ret) { case QMessageBox::Save: - // TODO m_core->saveItems(); + emit saveItems(); event->accept(); break; case QMessageBox::Discard: @@ -233,6 +233,11 @@ void MainWindow::onShowUndoViewToggled(bool checked) { } } +void MainWindow::saveItems() { + showStatusMessage(tr("Invoked 'File|Save'")); + m_core->saveItems(); +} + void MainWindow::createActions() { // TODO add generic menu actions (file/new, edit/cut, ...) createFileActions(); @@ -258,8 +263,7 @@ void MainWindow::createFileActions() { m_saveAct = make_unique(tr("&Save"), this); m_saveAct->setShortcuts(QKeySequence::Save); m_saveAct->setStatusTip(tr("Save the document to disk")); - // connect(m_saveAct, &QAction::triggered, this, &MainWindow::save); - m_saveAct->setEnabled(false); + connect(m_saveAct.get(), &QAction::triggered, this, &MainWindow::saveItems); ui->menu_File->addAction(m_saveAct.get()); ui->menu_File->addSeparator(); diff --git a/mainwindow.h b/mainwindow.h index 652087d..1da27c5 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -54,6 +54,9 @@ class MainWindow : public QMainWindow { void onCleanStateChanged(bool clean); void onShowUndoViewToggled(bool checked); + /// 'File' slots + void saveItems(); + private: Ui::MainWindow* ui;