changeset 604:98f57888d893

Ensure the URL combo never defaults to something that is not a URL
author Chris Cannam
date Tue, 03 Jul 2012 10:43:05 +0100
parents 10ef94e51f44
children ab92f695f776
files src/multichoicedialog.cpp src/multichoicedialog.h
diffstat 2 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/multichoicedialog.cpp	Tue Jul 03 10:08:44 2012 +0100
+++ b/src/multichoicedialog.cpp	Tue Jul 03 10:43:05 2012 +0100
@@ -275,6 +275,17 @@
     }
 }
 
+bool
+MultiChoiceDialog::urlComboNotUrl() const
+{
+    QString url = m_urlCombo->currentText();
+    if (QRegExp("^\\w+://").indexIn(url) < 0) {
+        return true;
+    } else {
+        return false;
+    }
+}
+
 void
 MultiChoiceDialog::choiceChanged()
 {
@@ -347,14 +358,18 @@
         m_urlLabel->show();
         m_urlCombo->show();
         m_urlCombo->addItems(rf->getRecent());
-        if (m_defaultEmpty[id]) m_urlCombo->lineEdit()->setText("");
+        if (m_defaultEmpty[id] || urlComboNotUrl()) {
+            m_urlCombo->lineEdit()->setText("");
+        }
         break;
 
     case UrlToDirectoryArg:
         m_urlLabel->show();
         m_urlCombo->show();
         m_urlCombo->addItems(rf->getRecent());
-        if (m_defaultEmpty[id]) m_urlCombo->lineEdit()->setText("");
+        if (m_defaultEmpty[id] || urlComboNotUrl()) {
+            m_urlCombo->lineEdit()->setText("");
+        }
         m_fileLabel->setText(tr("&Folder:"));
         m_fileLabel->show();
         m_fileCombo->show();
--- a/src/multichoicedialog.h	Tue Jul 03 10:08:44 2012 +0100
+++ b/src/multichoicedialog.h	Tue Jul 03 10:43:05 2012 +0100
@@ -88,6 +88,7 @@
     QAbstractButton *m_okButton;
 
     QString getDefaultPath() const;
+    bool urlComboNotUrl() const;
 };
 
 #endif // MULTICHOICEDIALOG_H