diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 7bbd793ec..885e6feb4 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -948,7 +948,34 @@ void MainWindow::OpenRecentProject() { QAction *action = qobject_cast(sender()); if (action) - LoadProjectFile(action->data().toString()); + { + const QString project = action->data().toString(); + QFileInfo inf(project); + if (inf.exists()) + { + LoadProjectFile(project); + } + else + { + QString text(tr("The project file\n\n%1\n\n could not be found!\n\n" + "Do you want to remove the file from the recently " + "used projects -list?").arg(project)); + + QMessageBox msg(QMessageBox::Warning, + tr("Cppcheck"), + text, + QMessageBox::Yes | QMessageBox::No, + this); + + msg.setDefaultButton(QMessageBox::No); + int rv = msg.exec(); + if (rv == QMessageBox::Yes) + { + RemoveProjectMRU(project); + } + + } + } } void MainWindow::UpdateMRUMenuItems() @@ -986,3 +1013,12 @@ void MainWindow::AddProjectMRU(const QString &project) mSettings->setValue(SETTINGS_MRU_PROJECTS, files); UpdateMRUMenuItems(); } + +void MainWindow::RemoveProjectMRU(const QString &project) +{ + QStringList files = mSettings->value(SETTINGS_MRU_PROJECTS).toStringList(); + files.removeAll(project); + + mSettings->setValue(SETTINGS_MRU_PROJECTS, files); + UpdateMRUMenuItems(); +} diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 7d9f6272f..62ed4d807 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -405,6 +405,12 @@ protected: */ void AddProjectMRU(const QString &project); + /** + * @brief Remove project file (path) from the MRU list. + * @param project Full path of the project file to remove. + */ + void RemoveProjectMRU(const QString &project); + /** * @brief Program settings *