Commit 49ea1706 authored by con's avatar con Committed by Eike Ziller

Add menu item to clear the recent projects/files menus.

Task-number: QTCREATORBUG-5136

Change-Id: I27d5c86832277be9525d95fd1e38a3b86f620974
Reviewed-on: http://codereview.qt.nokia.com/496Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 78f98c17
......@@ -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
......
......@@ -84,7 +84,9 @@ public:
// recent files
void addToRecentFiles(const QString &fileName, const QString &editorId = QString());
Q_SLOT void clearRecentFiles();
QList<RecentFile> recentFiles() const;
void saveSettings();
// current file
......
......@@ -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()
......
......@@ -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,9 +2231,24 @@ 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()
{
if (debug)
......
......@@ -196,6 +196,7 @@ private slots:
void setStartupProject(ProjectExplorer::Project *project);
void updateRecentProjectMenu();
void clearRecentProjects();
void openRecentProject();
void openTerminalHere();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment