changeset 483:a582c6417004

Some textual updates; include final URL path element in default for local file on clone
author Chris Cannam
date Wed, 17 Aug 2011 15:53:17 +0100
parents c6ea3eb00635
children 896b7903e8f2
files src/mainwindow.cpp src/multichoicedialog.cpp src/multichoicedialog.h
diffstat 3 files changed, 36 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/mainwindow.cpp	Tue Aug 16 17:13:35 2011 +0100
+++ b/src/mainwindow.cpp	Wed Aug 17 15:53:17 2011 +0100
@@ -2063,7 +2063,7 @@
             (this,
              tr("Failed to run Mercurial"),
              tr("Failed to run Mercurial"),
-             tr("The Mercurial program either could not be found or failed to run.<br>Check that the Mercurial program path is correct in %1.").arg(setstr),
+             tr("The Mercurial program either could not be found or failed to run.<br><br>Check that the Mercurial program path is correct in %1.").arg(setstr),
              output);
         settings(SettingsDialog::PathsTab);
         return;
@@ -2166,7 +2166,9 @@
         (this,
          tr("Command failed"),
          tr("Command failed"),
-         tr("A Mercurial command failed to run correctly.  This may indicate an installation problem or some other problem with EasyMercurial.<br><br>See &ldquo;More Details&rdquo; for the command output."),
+         (output == "" ?
+          tr("A Mercurial command failed to run correctly.  This may indicate an installation problem or some other problem with EasyMercurial.") :
+          tr("A Mercurial command failed to run correctly.  This may indicate an installation problem or some other problem with EasyMercurial.<br><br>See &ldquo;More Details&rdquo; for the command output.")),
          output);
 }
 
--- a/src/multichoicedialog.cpp	Tue Aug 16 17:13:35 2011 +0100
+++ b/src/multichoicedialog.cpp	Wed Aug 17 15:53:17 2011 +0100
@@ -171,11 +171,15 @@
     QDir home(QDir::home());
     QDir dflt;
 
+    dflt = QDir(home.filePath(tr("Documents")));
+    DEBUG << "testing " << dflt << endl;
+    if (dflt.exists()) return dflt.canonicalPath();
+
     dflt = QDir(home.filePath(tr("My Documents")));
     DEBUG << "testing " << dflt << endl;
     if (dflt.exists()) return dflt.canonicalPath();
 
-    dflt = QDir(home.filePath(tr("Documents")));
+    dflt = QDir(home.filePath(tr("Desktop")));
     DEBUG << "testing " << dflt << endl;
     if (dflt.exists()) return dflt.canonicalPath();
 
@@ -218,6 +222,7 @@
 MultiChoiceDialog::urlChanged(const QString &s)
 {
     updateOkButton();
+    updateFileComboFromURL();
 }
 
 void
@@ -227,16 +232,11 @@
 }
 
 void
-MultiChoiceDialog::updateOkButton()
+MultiChoiceDialog::updateFileComboFromURL()
 {
-/* This doesn't work well
     if (m_argTypes[m_currentChoice] != UrlToDirectoryArg) {
         return;
     }
-    QDir dirPath(m_fileCombo->currentText());
-    if (!dirPath.exists()) {
-        if (!dirPath.cdUp()) return;
-    }
     QString url = m_urlCombo->currentText();
     if (QRegExp("^\\w+://").indexIn(url) < 0) {
         return;
@@ -246,8 +246,23 @@
     if (urlDirName == "" || urlDirName == url) {
         return;
     }
-    m_fileCombo->lineEdit()->setText(dirPath.filePath(urlDirName));
-*/
+    QString dirPath = m_fileCombo->currentText();
+    QString defaultPath = getDefaultPath();
+    if (dirPath == defaultPath) {
+        dirPath += QDir::separator() + urlDirName;
+    } else if (dirPath == defaultPath + QDir::separator()) {
+        dirPath += urlDirName;
+    } else {
+        QDir d(dirPath);
+        d.cdUp();
+        dirPath = d.filePath(urlDirName);
+    }
+    m_fileCombo->lineEdit()->setText(dirPath);
+}
+
+void
+MultiChoiceDialog::updateOkButton()
+{
     if (m_argTypes[m_currentChoice] == UrlToDirectoryArg) {
         m_okButton->setEnabled(getArgument() != "" &&
                                getAdditionalArgument() != "");
@@ -289,15 +304,17 @@
 
     m_descriptionLabel->setText(m_descriptions[id]);
 
-    m_fileLabel->hide();
-    m_fileCombo->hide();
     m_browseButton->hide();
+
     m_urlLabel->hide();
+    m_urlCombo->clear();
     m_urlCombo->hide();
 
+    m_fileLabel->hide();
+    m_fileCombo->clear();
+    m_fileCombo->hide();
+
     QSharedPointer<RecentFiles> rf = m_recentFiles[id];
-    m_fileCombo->clear();
-    m_urlCombo->clear();
 
     switch (m_argTypes[id]) {
         
@@ -334,6 +351,7 @@
         m_fileLabel->show();
         m_fileCombo->show();
         m_fileCombo->lineEdit()->setText(getDefaultPath());
+        updateFileComboFromURL();
         m_browseButton->show();
         break;
     }
--- a/src/multichoicedialog.h	Tue Aug 16 17:13:35 2011 +0100
+++ b/src/multichoicedialog.h	Wed Aug 17 15:53:17 2011 +0100
@@ -65,6 +65,7 @@
     void browse();
 
 private:
+    void updateFileComboFromURL();
     void updateOkButton();
     
     QMap<QString, QString> m_texts;