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
This commit is contained in:
Dominik Riebeling 2010-02-16 21:34:39 +00:00
parent b1908e95e1
commit 7e91332e39
5 changed files with 24 additions and 36 deletions

View file

@ -549,16 +549,16 @@ void Config::browseFolder()
void Config::browseCache() void Config::browseCache()
{ {
cbrowser = new BrowseDirtree(this); QString old = ui.cachePath->text();
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX) if(!QFileInfo(old).isDir())
cbrowser->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); old = QDir::tempPath();
#elif defined(Q_OS_WIN32) QString c = QFileDialog::getExistingDirectory(this, tr("Set Cache Path"), old);
cbrowser->setFilter(QDir::Drives | QDir::AllDirs | QDir::NoDotAndDotDot); if(c.isEmpty())
#endif c = old;
cbrowser->setDir(ui.cachePath->text()); else if(!QFileInfo(c).isDir())
connect(cbrowser, SIGNAL(itemChanged(QString)), this, SLOT(setCache(QString))); c = QDir::tempPath();
cbrowser->show(); ui.cachePath->setText(QDir::toNativeSeparators(c));
updateCacheInfo(c);
} }
@ -568,13 +568,6 @@ void Config::setMountpoint(QString m)
} }
void Config::setCache(QString c)
{
ui.cachePath->setText(c);
updateCacheInfo(c);
}
void Config::autodetect() void Config::autodetect()
{ {
Autodetection detector(this); Autodetection detector(this);

View file

@ -64,7 +64,6 @@ class Config : public QDialog
void browseCache(void); void browseCache(void);
void autodetect(void); void autodetect(void);
void setMountpoint(QString); void setMountpoint(QString);
void setCache(QString);
void cacheClear(void); void cacheClear(void);
void configTts(void); void configTts(void);
void configEnc(void); void configEnc(void);

View file

@ -42,28 +42,24 @@ InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent)
void InstallTalkWindow::browseFolder() void InstallTalkWindow::browseFolder()
{ {
BrowseDirtree browser(this); QString selected;
browser.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); QString startfolder;
if(QFileInfo(ui.lineTalkFolder->text()).isDir()) if(QFileInfo(ui.lineTalkFolder->text()).isDir())
{ {
browser.setDir(ui.lineTalkFolder->text()); startfolder = ui.lineTalkFolder->text();
} }
else else
{ {
browser.setDir("/media"); // FIXME: This looks Linux specific startfolder = "/media"; // FIXME: This looks Linux specific
} }
if(browser.exec() == QDialog::Accepted) selected = QFileDialog::getExistingDirectory(this,
tr("Select folder to create talk files"), startfolder);
if(!selected.isEmpty())
{ {
qDebug() << browser.getSelected(); ui.lineTalkFolder->setText(selected);
setTalkFolder(browser.getSelected());
} }
} }
void InstallTalkWindow::setTalkFolder(QString folder)
{
ui.lineTalkFolder->setText(folder);
}
void InstallTalkWindow::change() void InstallTalkWindow::change()
{ {
@ -145,7 +141,8 @@ void InstallTalkWindow::updateSettings(void)
ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>") ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
.arg("Invalid encoder configuration!")); .arg("Invalid encoder configuration!"));
setTalkFolder(RbSettings::value(RbSettings::LastTalkedFolder).toString()); ui.lineTalkFolder->setText(
RbSettings::value(RbSettings::LastTalkedFolder).toString());
emit settingsUpdated(); emit settingsUpdated();
} }

View file

@ -40,7 +40,6 @@ class InstallTalkWindow : public QDialog
private slots: private slots:
void browseFolder(void); void browseFolder(void);
void setTalkFolder(QString folder);
void updateSettings(void); void updateSettings(void);
signals: signals:

View file

@ -735,11 +735,11 @@ void RbUtilQt::installBootloader()
"in a new folder \"%1\" created below the selected folder.\n" "in a new folder \"%1\" created below the selected folder.\n"
"Press \"No\" to skip this step.").arg(targetFolder), "Press \"No\" to skip this step.").arg(targetFolder),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
BrowseDirtree tree(this, tr("Browse backup folder")); backupDestination = QFileDialog::getExistingDirectory(this,
tree.setDir(QDir::home()); tr("Browse backup folder"), QDir::homePath());
tree.exec(); if(!backupDestination.isEmpty())
backupDestination += "/" + targetFolder;
backupDestination = tree.getSelected() + "/" + targetFolder;
qDebug() << "[RbUtil] backing up to" << backupDestination; qDebug() << "[RbUtil] backing up to" << backupDestination;
// backup needs to be done after the logger has been set up. // backup needs to be done after the logger has been set up.
} }