# HG changeset patch # User Chris Cannam # Date 1300383280 0 # Node ID 73fb5ef55744c8f1e02d4946f5dacdffda6568d3 # Parent f34848e8094b726536bf630655fd50d98f766f57# Parent 4cd753e083cc6227813b5df64b3342b1d77b83a4 Merge from branch "feature_91b". Really fixes #91 diff -r 4cd753e083cc -r 73fb5ef55744 mainwindow.cpp --- a/mainwindow.cpp Thu Mar 17 17:34:23 2011 +0000 +++ b/mainwindow.cpp Thu Mar 17 17:34:40 2011 +0000 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -129,6 +130,7 @@ cs->addDefaultName(getUserInfo()); hgTest(); + updateRecentMenu(); } @@ -1132,11 +1134,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); @@ -1175,6 +1177,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 @@ -1365,7 +1375,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) @@ -2271,6 +2281,7 @@ m_stateUnknown = false; enableDisableActions(); m_hgTabs->updateHistory(); + updateRecentMenu(); } } @@ -2565,6 +2576,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 @@ -2644,6 +2673,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 4cd753e083cc -r 73fb5ef55744 mainwindow.h --- a/mainwindow.h Thu Mar 17 17:34:23 2011 +0000 +++ b/mainwindow.h Thu Mar 17 17:34:40 2011 +0000 @@ -58,6 +58,7 @@ void about(); void settings(); void open(); + void recentMenuActivated(); void changeRemoteRepo(); void startupDialog(); void clearSelections(); @@ -117,6 +118,8 @@ void hgQueryParents(); void hgLog(); void hgLogIncremental(QStringList prune); + + void updateRecentMenu(); void createActions(); void connectActions(); void connectTabsSignals(); @@ -217,6 +220,7 @@ // Menus QMenu *m_fileMenu; + QMenu *m_recentMenu; QMenu *m_advancedMenu; QMenu *m_helpMenu;