Mercurial > hg > easyhg
changeset 362:73fb5ef55744
Merge from branch "feature_91b". Really fixes #91
author | Chris Cannam |
---|---|
date | Thu, 17 Mar 2011 17:34:40 +0000 |
parents | f34848e8094b (diff) 4cd753e083cc (current diff) |
children | f89e50d748ed 9bafea5ac56f |
files | mainwindow.cpp mainwindow.h |
diffstat | 2 files changed, 37 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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 <QToolButton> #include <QSettings> #include <QInputDialog> +#include <QWidgetAction> #include <QRegExp> #include <QShortcut> #include <QUrl> @@ -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<QAction *>(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("<qt><b>Initialise a repository here?</b><br><br>You asked to open \"%1\".<br>This folder does not contain a Mercurial repository.<br><br>Would you like to initialise a repository here?</qt>") + tr("<qt><b>Initialise a repository here?</b><br><br>You asked to open \"%1\".<br>This folder is not a Mercurial working copy.<br><br>Would you like to initialise a repository here?</qt>") .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();
--- 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;