changeset 183:01580704de3e

* Implement "Change Remote Location"
author Chris Cannam
date Sun, 19 Dec 2010 12:01:37 +0000
parents bf366e0b9050
children 1220f26d6f35
files mainwindow.cpp multichoicedialog.cpp
diffstat 2 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mainwindow.cpp	Fri Dec 17 10:01:02 2010 +0000
+++ b/mainwindow.cpp	Sun Dec 19 12:01:37 2010 +0000
@@ -915,7 +915,32 @@
 
 void MainWindow::changeRemoteRepo()
 {
-    //!!! so we want a "multi-choice" thingy but with remote only? and then we rewrite the local hgrc??
+    // This will involve rewriting the local .hgrc
+
+    QFileInfo hgrc(workFolderPath + "/.hg/hgrc");
+    if (!hgrc.exists() || !hgrc.isWritable()) {
+        //!!! visible error!
+        return;
+    }
+
+    MultiChoiceDialog *d = new MultiChoiceDialog
+        (tr("Change Remote Location"),
+         tr("<qt><big>Change the remote location</big></qt>"),
+         this);
+
+    d->addChoice("remote",
+                 tr("<qt><center><img src=\":images/browser-64.png\"><br>Remote repository</center></qt>"),
+                 tr("Provide a new URL to use for push and pull actions from the current local repository."),
+                 MultiChoiceDialog::UrlArg);
+
+    if (d->exec() == QDialog::Accepted) {
+        QSettings s(hgrc.canonicalFilePath(), QSettings::IniFormat);
+        s.beginGroup("paths");
+        s.setValue("default", d->getArgument());
+        hgQueryPaths();
+    }
+
+    delete d;
 }
 
 void MainWindow::open(QString local)
--- a/multichoicedialog.cpp	Fri Dec 17 10:01:02 2010 +0000
+++ b/multichoicedialog.cpp	Sun Dec 19 12:01:37 2010 +0000
@@ -152,6 +152,7 @@
     SelectableLabel *cb = new SelectableLabel;
     cb->setSelectedText(text);
     cb->setUnselectedText(text);
+    cb->setMaximumWidth(270);
 
     m_choiceLayout->addWidget(cb);
     m_choiceButtons[cb] = id;
@@ -307,6 +308,7 @@
     case UrlArg:
         m_urlLabel->show();
         m_urlCombo->show();
+        m_urlCombo->addItems(rf->getRecent());
         break;
 
     case UrlToDirectoryArg: