diff --git a/src/plugins/coreplugin/filemanager.cpp b/src/plugins/coreplugin/filemanager.cpp index f93a03f36f9..caabbeced3c 100644 --- a/src/plugins/coreplugin/filemanager.cpp +++ b/src/plugins/coreplugin/filemanager.cpp @@ -1077,6 +1077,17 @@ void FileManager::addToRecentFiles(const QString &fileName, const QString &edito d->m_recentFiles.prepend(RecentFile(fileName, editorId)); } +/*! + \fn void FileManager::clearRecentFiles() + + Clears the list of recent files. Should only be called by + the core plugin when the user chooses to clear it. +*/ +void FileManager::clearRecentFiles() +{ + d->m_recentFiles.clear(); +} + /*! \fn QStringList FileManager::recentFiles() const diff --git a/src/plugins/coreplugin/filemanager.h b/src/plugins/coreplugin/filemanager.h index 47fb008d7ba..a5ecd4dffc5 100644 --- a/src/plugins/coreplugin/filemanager.h +++ b/src/plugins/coreplugin/filemanager.h @@ -84,7 +84,9 @@ public: // recent files void addToRecentFiles(const QString &fileName, const QString &editorId = QString()); + Q_SLOT void clearRecentFiles(); QList recentFiles() const; + void saveSettings(); // current file diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 31918dd3fe1..49a9757002a 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -1317,6 +1317,13 @@ void MainWindow::aboutToShowRecentFiles() connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile())); } aci->menu()->setEnabled(hasRecentFiles); + + // add the Clear Menu item + if (hasRecentFiles) { + aci->menu()->addSeparator(); + QAction *action = aci->menu()->addAction(tr(QT_TRANSLATE_NOOP("Core::MainWindow", "Clear Menu"))); + connect(action, SIGNAL(triggered()), m_fileManager, SLOT(clearRecentFiles())); + } } void MainWindow::openRecentFile() diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index bfea5520a88..3acf25186a7 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -2221,8 +2221,7 @@ void ProjectExplorerPlugin::updateRecentProjectMenu() QMenu *menu = aci->menu(); menu->clear(); - menu->setEnabled(!d->m_recentProjects.isEmpty()); - + bool hasRecentProjects = false; //projects (ignore sessions, they used to be in this list) const StringPairListConstIterator end = d->m_recentProjects.constEnd(); for (StringPairListConstIterator it = d->m_recentProjects.constBegin(); it != end; ++it) { @@ -2232,7 +2231,22 @@ void ProjectExplorerPlugin::updateRecentProjectMenu() QAction *action = menu->addAction(Utils::withTildeHomePath(s.first)); action->setData(s.first); connect(action, SIGNAL(triggered()), this, SLOT(openRecentProject())); + hasRecentProjects = true; } + menu->setEnabled(hasRecentProjects); + + // add the Clear Menu item + if (hasRecentProjects) { + menu->addSeparator(); + QAction *action = menu->addAction(tr(QT_TRANSLATE_NOOP("Core::MainWindow", "Clear Menu"))); + connect(action, SIGNAL(triggered()), this, SLOT(clearRecentProjects())); + } +} + +void ProjectExplorerPlugin::clearRecentProjects() +{ + d->m_recentProjects.clear(); + updateWelcomePage(); } void ProjectExplorerPlugin::openRecentProject() diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 554280edde4..5885db4413d 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -196,6 +196,7 @@ private slots: void setStartupProject(ProjectExplorer::Project *project); void updateRecentProjectMenu(); + void clearRecentProjects(); void openRecentProject(); void openTerminalHere();