# HG changeset patch # User Chris Cannam # Date 1300379762 0 # Node ID f34848e8094b726536bf630655fd50d98f766f57 # Parent ea6f76c0aa768f9641b77986449ac856debaa672# Parent 550650bbb95953e5563efb7bf81e4b57e447fde7 Merge from branch "feature_91" diff -r ea6f76c0aa76 -r f34848e8094b mainwindow.cpp --- a/mainwindow.cpp Thu Mar 17 13:52:57 2011 +0000 +++ b/mainwindow.cpp Thu Mar 17 16:36:02 2011 +0000 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -129,6 +130,7 @@ cs->addDefaultName(getUserInfo()); hgTest(); + updateRecentMenu(); } @@ -1078,11 +1080,11 @@ QSettings settings; settings.beginGroup("General"); - QString lastChoice = settings.value("lastopentype", "local").toString(); + QString lastChoice = settings.value("lastopentype", "remote").toString(); if (lastChoice != "local" && lastChoice != "remote" && lastChoice != "init") { - lastChoice = "local"; + lastChoice = "remote"; } d->setCurrentChoice(lastChoice); @@ -1121,6 +1123,14 @@ } } +void MainWindow::recentMenuActivated() +{ + QAction *a = qobject_cast(sender()); + if (!a) return; + QString local = a->text(); + open(local); +} + void MainWindow::changeRemoteRepo() { // This will involve rewriting the local .hgrc @@ -1311,7 +1321,7 @@ { return (QMessageBox::question (this, tr("Folder has no repository"), - tr("Initialise a repository here?

You asked to open \"%1\".
This folder does not contain a Mercurial repository.

Would you like to initialise a repository here?
") + tr("Initialise a repository here?

You asked to open \"%1\".
This folder is not a Mercurial working copy.

Would you like to initialise a repository here?
") .arg(xmlEncode(arg)), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok) @@ -2217,6 +2227,7 @@ m_stateUnknown = false; enableDisableActions(); m_hgTabs->updateHistory(); + updateRecentMenu(); } } @@ -2505,6 +2516,24 @@ } } + +void MainWindow::updateRecentMenu() +{ + m_recentMenu->clear(); + RecentFiles rf("Recent-local"); + QStringList recent = rf.getRecent(); + if (recent.empty()) { + QLabel *label = new QLabel(tr("No recent local repositories")); + QWidgetAction *wa = new QWidgetAction(m_recentMenu); + wa->setDefaultWidget(label); + return; + } + foreach (QString r, recent) { + QAction *a = m_recentMenu->addAction(r); + connect(a, SIGNAL(activated()), this, SLOT(recentMenuActivated())); + } +} + void MainWindow::createActions() { //File actions @@ -2584,6 +2613,7 @@ m_fileMenu = menuBar()->addMenu(tr("File")); m_fileMenu -> addAction(m_openAct); + m_recentMenu = m_fileMenu->addMenu(tr("Open Recent")); m_fileMenu -> addAction(m_changeRemoteRepoAct); m_fileMenu -> addSeparator(); diff -r ea6f76c0aa76 -r f34848e8094b mainwindow.h --- a/mainwindow.h Thu Mar 17 13:52:57 2011 +0000 +++ b/mainwindow.h Thu Mar 17 16:36:02 2011 +0000 @@ -58,6 +58,7 @@ void about(); void settings(); void open(); + void recentMenuActivated(); void changeRemoteRepo(); void startupDialog(); void clearSelections(); @@ -115,6 +116,8 @@ void hgQueryParents(); void hgLog(); void hgLogIncremental(QStringList prune); + + void updateRecentMenu(); void createActions(); void connectActions(); void connectTabsSignals(); @@ -215,6 +218,7 @@ // Menus QMenu *m_fileMenu; + QMenu *m_recentMenu; QMenu *m_advancedMenu; QMenu *m_helpMenu;