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()
{
cbrowser = new BrowseDirtree(this);
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
cbrowser->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
#elif defined(Q_OS_WIN32)
cbrowser->setFilter(QDir::Drives | QDir::AllDirs | QDir::NoDotAndDotDot);
#endif
cbrowser->setDir(ui.cachePath->text());
connect(cbrowser, SIGNAL(itemChanged(QString)), this, SLOT(setCache(QString)));
cbrowser->show();
QString old = ui.cachePath->text();
if(!QFileInfo(old).isDir())
old = QDir::tempPath();
QString c = QFileDialog::getExistingDirectory(this, tr("Set Cache Path"), old);
if(c.isEmpty())
c = old;
else if(!QFileInfo(c).isDir())
c = QDir::tempPath();
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()
{
Autodetection detector(this);

View file

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

View file

@ -42,28 +42,24 @@ InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent)
void InstallTalkWindow::browseFolder()
{
BrowseDirtree browser(this);
browser.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
QString selected;
QString startfolder;
if(QFileInfo(ui.lineTalkFolder->text()).isDir())
{
browser.setDir(ui.lineTalkFolder->text());
startfolder = ui.lineTalkFolder->text();
}
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();
setTalkFolder(browser.getSelected());
ui.lineTalkFolder->setText(selected);
}
}
void InstallTalkWindow::setTalkFolder(QString folder)
{
ui.lineTalkFolder->setText(folder);
}
void InstallTalkWindow::change()
{
@ -145,7 +141,8 @@ void InstallTalkWindow::updateSettings(void)
ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
.arg("Invalid encoder configuration!"));
setTalkFolder(RbSettings::value(RbSettings::LastTalkedFolder).toString());
ui.lineTalkFolder->setText(
RbSettings::value(RbSettings::LastTalkedFolder).toString());
emit settingsUpdated();
}

View file

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

View file

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