changeset 342:3824e8bb91eb

Use ~/Documents or ~/My Documents as default folder path, not ~
author Chris Cannam
date Tue, 15 Mar 2011 12:43:29 +0000
parents bb189827f6d1
children 435b6f0b6eeb
files multichoicedialog.cpp multichoicedialog.h
diffstat 2 files changed, 22 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/multichoicedialog.cpp	Tue Mar 15 12:00:31 2011 +0000
+++ b/multichoicedialog.cpp	Tue Mar 15 12:43:29 2011 +0000
@@ -165,17 +165,31 @@
     }
 }
 
+QString
+MultiChoiceDialog::getDefaultPath() const
+{
+    QDir home(QDir::home());
+    QDir dflt;
+
+    dflt = QDir(home.filePath(tr("My Documents")));
+    DEBUG << "testing " << dflt << endl;
+    if (dflt.exists()) return dflt.canonicalPath();
+
+    dflt = QDir(home.filePath(tr("Documents")));
+    DEBUG << "testing " << dflt << endl;
+    if (dflt.exists()) return dflt.canonicalPath();
+
+    DEBUG << "all failed, returning " << home << endl;
+    return home.canonicalPath();
+}
+
 void
 MultiChoiceDialog::browse()
 {
     QString origin = getArgument();
 
     if (origin == "") {
-#ifdef Q_OS_WIN32
-        origin = "c:";
-#else
-        origin = QDir::homePath();
-#endif
+        origin = getDefaultPath();
     }
 
     QString path = origin;
@@ -319,7 +333,7 @@
         m_fileLabel->setText(tr("&Folder:"));
         m_fileLabel->show();
         m_fileCombo->show();
-        m_fileCombo->lineEdit()->setText(QDir::homePath());
+        m_fileCombo->lineEdit()->setText(getDefaultPath());
         m_browseButton->show();
         break;
     }
--- a/multichoicedialog.h	Tue Mar 15 12:00:31 2011 +0000
+++ b/multichoicedialog.h	Tue Mar 15 12:43:29 2011 +0000
@@ -83,6 +83,8 @@
     QLabel *m_urlLabel;
     QComboBox *m_urlCombo;
     QAbstractButton *m_okButton;
+
+    QString getDefaultPath() const;
 };
 
 #endif // MULTICHOICEDIALOG_H