From 7cabc7df1836653aaf9e6eeac36e3f7650b6faf2 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 18 Jul 2016 22:55:18 +0300 Subject: [PATCH 1/2] Fixed loading recent files in main window. --HG-- branch : develop --- src/app/valentina/mainwindow.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index fd3985e67..7235ac556 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -3636,13 +3636,12 @@ void MainWindow::CreateActions() { recentFileActs[i] = new QAction(this); recentFileActs[i]->setVisible(false); - connect(recentFileActs[i], &QAction::triggered, [this]() + connect(recentFileActs[i], &QAction::triggered, this, [this]() { - QAction *action = qobject_cast(sender()); - if (action) + if (QAction *action = qobject_cast(sender())) { const QString filePath = action->data().toString(); - if (not filePath.isEmpty()) + if (not filePath.isEmpty()) { LoadPattern(filePath); } From 8b438daa6ca6149ad09c030096ed91c32b227bc6 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 18 Jul 2016 22:58:14 +0300 Subject: [PATCH 2/2] Slot OpenRecentFile in Tape replaced by lambda. --HG-- branch : develop --- src/app/tape/tmainwindow.cpp | 25 +++++++++++-------------- src/app/tape/tmainwindow.h | 1 - 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index cfae1b38e..a0b5e2d67 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -1743,7 +1743,17 @@ void TMainWindow::SetupMenu() for (int i = 0; i < MaxRecentFiles; ++i) { recentFileActs[i] = new QAction(this); - connect(recentFileActs[i], &QAction::triggered, this, &TMainWindow::OpenRecentFile); + connect(recentFileActs[i], &QAction::triggered, this, [this]() + { + if (auto action = qobject_cast(sender())) + { + const QString filePath = action->data().toString(); + if (not filePath.isEmpty()) + { + LoadFile(filePath); + } + } + }); ui->menuFile->insertAction(ui->actionPreferences, recentFileActs[i]); recentFileActs[i]->setVisible(false); } @@ -2778,19 +2788,6 @@ void TMainWindow::CreateWindowMenu(QMenu *menu) } } -//--------------------------------------------------------------------------------------------------------------------- -void TMainWindow::OpenRecentFile() -{ - if (auto action=qobject_cast(sender())) - { - const QString filePath = action->data().toString(); - if (not filePath.isEmpty()) - { - LoadFile(filePath); - } - } -} - //--------------------------------------------------------------------------------------------------------------------- bool TMainWindow::IgnoreLocking(int error, const QString &path) { diff --git a/src/app/tape/tmainwindow.h b/src/app/tape/tmainwindow.h index c7dff2a39..80683d98f 100644 --- a/src/app/tape/tmainwindow.h +++ b/src/app/tape/tmainwindow.h @@ -75,7 +75,6 @@ private slots: void OpenStandard(); void OpenTemplate(); void CreateFromExisting(); - void OpenRecentFile(); void FileSave(); void FileSaveAs();