diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2010-02-16 21:34:39 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2010-02-16 21:34:39 +0000 |
commit | 7e91332e398db9f344e44df3b2ea29adc94ad56e (patch) | |
tree | 5f35421351efa7b816c4745c3d673c53f740ff76 | |
parent | b1908e95e130b766af113a264b145da06bbeeb31 (diff) | |
download | rockbox-7e91332e398db9f344e44df3b2ea29adc94ad56e.tar.gz rockbox-7e91332e398db9f344e44df3b2ea29adc94ad56e.zip |
Use QFileDialog::getExistingDirectory() for path selection.
This makes it possible for native dialogs to get used on Windows and OS X. The
mountpoint selection dialog needs special handling and still uses the
BrowseDirtree class for now.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24703 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 27 | ||||
-rw-r--r-- | rbutil/rbutilqt/configure.h | 1 | ||||
-rw-r--r-- | rbutil/rbutilqt/installtalkwindow.cpp | 23 | ||||
-rw-r--r-- | rbutil/rbutilqt/installtalkwindow.h | 1 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.cpp | 8 |
5 files changed, 24 insertions, 36 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 1f433d8903..2e2f2e3531 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp | |||
@@ -549,16 +549,16 @@ void Config::browseFolder() | |||
549 | 549 | ||
550 | void Config::browseCache() | 550 | void Config::browseCache() |
551 | { | 551 | { |
552 | cbrowser = new BrowseDirtree(this); | 552 | QString old = ui.cachePath->text(); |
553 | #if defined(Q_OS_LINUX) || defined(Q_OS_MACX) | 553 | if(!QFileInfo(old).isDir()) |
554 | cbrowser->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); | 554 | old = QDir::tempPath(); |
555 | #elif defined(Q_OS_WIN32) | 555 | QString c = QFileDialog::getExistingDirectory(this, tr("Set Cache Path"), old); |
556 | cbrowser->setFilter(QDir::Drives | QDir::AllDirs | QDir::NoDotAndDotDot); | 556 | if(c.isEmpty()) |
557 | #endif | 557 | c = old; |
558 | cbrowser->setDir(ui.cachePath->text()); | 558 | else if(!QFileInfo(c).isDir()) |
559 | connect(cbrowser, SIGNAL(itemChanged(QString)), this, SLOT(setCache(QString))); | 559 | c = QDir::tempPath(); |
560 | cbrowser->show(); | 560 | ui.cachePath->setText(QDir::toNativeSeparators(c)); |
561 | 561 | updateCacheInfo(c); | |
562 | } | 562 | } |
563 | 563 | ||
564 | 564 | ||
@@ -568,13 +568,6 @@ void Config::setMountpoint(QString m) | |||
568 | } | 568 | } |
569 | 569 | ||
570 | 570 | ||
571 | void Config::setCache(QString c) | ||
572 | { | ||
573 | ui.cachePath->setText(c); | ||
574 | updateCacheInfo(c); | ||
575 | } | ||
576 | |||
577 | |||
578 | void Config::autodetect() | 571 | void Config::autodetect() |
579 | { | 572 | { |
580 | Autodetection detector(this); | 573 | Autodetection detector(this); |
diff --git a/rbutil/rbutilqt/configure.h b/rbutil/rbutilqt/configure.h index d2654907c1..3884d0d750 100644 --- a/rbutil/rbutilqt/configure.h +++ b/rbutil/rbutilqt/configure.h | |||
@@ -64,7 +64,6 @@ class Config : public QDialog | |||
64 | void browseCache(void); | 64 | void browseCache(void); |
65 | void autodetect(void); | 65 | void autodetect(void); |
66 | void setMountpoint(QString); | 66 | void setMountpoint(QString); |
67 | void setCache(QString); | ||
68 | void cacheClear(void); | 67 | void cacheClear(void); |
69 | void configTts(void); | 68 | void configTts(void); |
70 | void configEnc(void); | 69 | void configEnc(void); |
diff --git a/rbutil/rbutilqt/installtalkwindow.cpp b/rbutil/rbutilqt/installtalkwindow.cpp index fb604e71e2..8c09d684c8 100644 --- a/rbutil/rbutilqt/installtalkwindow.cpp +++ b/rbutil/rbutilqt/installtalkwindow.cpp | |||
@@ -42,28 +42,24 @@ InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent) | |||
42 | 42 | ||
43 | void InstallTalkWindow::browseFolder() | 43 | void InstallTalkWindow::browseFolder() |
44 | { | 44 | { |
45 | BrowseDirtree browser(this); | 45 | QString selected; |
46 | browser.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); | 46 | QString startfolder; |
47 | |||
48 | if(QFileInfo(ui.lineTalkFolder->text()).isDir()) | 47 | if(QFileInfo(ui.lineTalkFolder->text()).isDir()) |
49 | { | 48 | { |
50 | browser.setDir(ui.lineTalkFolder->text()); | 49 | startfolder = ui.lineTalkFolder->text(); |
51 | } | 50 | } |
52 | else | 51 | else |
53 | { | 52 | { |
54 | browser.setDir("/media"); // FIXME: This looks Linux specific | 53 | startfolder = "/media"; // FIXME: This looks Linux specific |
55 | } | 54 | } |
56 | if(browser.exec() == QDialog::Accepted) | 55 | selected = QFileDialog::getExistingDirectory(this, |
56 | tr("Select folder to create talk files"), startfolder); | ||
57 | if(!selected.isEmpty()) | ||
57 | { | 58 | { |
58 | qDebug() << browser.getSelected(); | 59 | ui.lineTalkFolder->setText(selected); |
59 | setTalkFolder(browser.getSelected()); | ||
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | void InstallTalkWindow::setTalkFolder(QString folder) | ||
64 | { | ||
65 | ui.lineTalkFolder->setText(folder); | ||
66 | } | ||
67 | 63 | ||
68 | void InstallTalkWindow::change() | 64 | void InstallTalkWindow::change() |
69 | { | 65 | { |
@@ -145,7 +141,8 @@ void InstallTalkWindow::updateSettings(void) | |||
145 | ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>") | 141 | ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>") |
146 | .arg("Invalid encoder configuration!")); | 142 | .arg("Invalid encoder configuration!")); |
147 | 143 | ||
148 | setTalkFolder(RbSettings::value(RbSettings::LastTalkedFolder).toString()); | 144 | ui.lineTalkFolder->setText( |
145 | RbSettings::value(RbSettings::LastTalkedFolder).toString()); | ||
149 | emit settingsUpdated(); | 146 | emit settingsUpdated(); |
150 | } | 147 | } |
151 | 148 | ||
diff --git a/rbutil/rbutilqt/installtalkwindow.h b/rbutil/rbutilqt/installtalkwindow.h index e7cc85aac7..e723f29af8 100644 --- a/rbutil/rbutilqt/installtalkwindow.h +++ b/rbutil/rbutilqt/installtalkwindow.h | |||
@@ -40,7 +40,6 @@ class InstallTalkWindow : public QDialog | |||
40 | 40 | ||
41 | private slots: | 41 | private slots: |
42 | void browseFolder(void); | 42 | void browseFolder(void); |
43 | void setTalkFolder(QString folder); | ||
44 | void updateSettings(void); | 43 | void updateSettings(void); |
45 | 44 | ||
46 | signals: | 45 | signals: |
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index 4698b3fc58..f5ff47d539 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp | |||
@@ -735,11 +735,11 @@ void RbUtilQt::installBootloader() | |||
735 | "in a new folder \"%1\" created below the selected folder.\n" | 735 | "in a new folder \"%1\" created below the selected folder.\n" |
736 | "Press \"No\" to skip this step.").arg(targetFolder), | 736 | "Press \"No\" to skip this step.").arg(targetFolder), |
737 | QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { | 737 | QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { |
738 | BrowseDirtree tree(this, tr("Browse backup folder")); | 738 | backupDestination = QFileDialog::getExistingDirectory(this, |
739 | tree.setDir(QDir::home()); | 739 | tr("Browse backup folder"), QDir::homePath()); |
740 | tree.exec(); | 740 | if(!backupDestination.isEmpty()) |
741 | backupDestination += "/" + targetFolder; | ||
741 | 742 | ||
742 | backupDestination = tree.getSelected() + "/" + targetFolder; | ||
743 | qDebug() << "[RbUtil] backing up to" << backupDestination; | 743 | qDebug() << "[RbUtil] backing up to" << backupDestination; |
744 | // backup needs to be done after the logger has been set up. | 744 | // backup needs to be done after the logger has been set up. |
745 | } | 745 | } |