mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-10 21:55:10 -05:00
Check configuration for validity in the configuration dialog.
If the configuration is invalid display information about the issues and don't accept the values. Fixes issue reported in FS#9944. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20100 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
074bc6c09a
commit
194fe0e6f0
1 changed files with 51 additions and 12 deletions
|
|
@ -91,6 +91,9 @@ Config::Config(QWidget *parent,int index) : QDialog(parent)
|
|||
void Config::accept()
|
||||
{
|
||||
qDebug() << "Config::accept()";
|
||||
QString errormsg = tr("The following errors occurred:") + "<ul>";
|
||||
bool error = false;
|
||||
|
||||
// proxy: save entered proxy values, not displayed.
|
||||
if(ui.radioManualProxy->isChecked()) {
|
||||
proxy.setScheme("http");
|
||||
|
|
@ -118,8 +121,25 @@ void Config::accept()
|
|||
|
||||
// mountpoint
|
||||
QString mp = ui.mountPoint->text();
|
||||
if(QFileInfo(mp).isDir())
|
||||
if(mp.isEmpty()) {
|
||||
errormsg += "<li>" + tr("No mountpoint given") + "</li>";
|
||||
error = true;
|
||||
}
|
||||
else if(!QFileInfo(mp).exists()) {
|
||||
errormsg += "<li>" + tr("Mountpoint does not exist") + "</li>";
|
||||
error = true;
|
||||
}
|
||||
else if(!QFileInfo(mp).isDir()) {
|
||||
errormsg += "<li>" + tr("Mountpoint is not a directory.") + "</li>";
|
||||
error = true;
|
||||
}
|
||||
else if(!QFileInfo(mp).isWritable()) {
|
||||
errormsg += "<li>" + tr("Mountpoint is not writeable") + "</li>";
|
||||
error = true;
|
||||
}
|
||||
else {
|
||||
settings->setMountpoint(QDir::fromNativeSeparators(mp));
|
||||
}
|
||||
|
||||
// platform
|
||||
QString nplat;
|
||||
|
|
@ -127,10 +147,21 @@ void Config::accept()
|
|||
nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
|
||||
settings->setCurPlatform(nplat);
|
||||
}
|
||||
else {
|
||||
errormsg += "<li>" + tr("No player selected") + "</li>";
|
||||
error = true;
|
||||
}
|
||||
|
||||
// cache settings
|
||||
if(QFileInfo(ui.cachePath->text()).isDir())
|
||||
if(QFileInfo(ui.cachePath->text()).isDir()) {
|
||||
if(!QFileInfo(ui.cachePath->text()).isWritable()) {
|
||||
errormsg += "<li>" + tr("Cache path not writeable. Leave path empty "
|
||||
"to default to systems temporary path.") + "</li>";
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
settings->setCachePath(ui.cachePath->text());
|
||||
}
|
||||
else // default to system temp path
|
||||
settings->setCachePath(QDir::tempPath());
|
||||
settings->setCacheDisable(ui.cacheDisable->isChecked());
|
||||
|
|
@ -142,11 +173,19 @@ void Config::accept()
|
|||
|
||||
settings->setCurVersion(PUREVERSION);
|
||||
|
||||
errormsg += "</ul>";
|
||||
errormsg += tr("You need to fix the above errors before you can continue.");
|
||||
|
||||
if(error) {
|
||||
QMessageBox::critical(this, tr("Configuration error"), errormsg);
|
||||
}
|
||||
else {
|
||||
// sync settings
|
||||
settings->sync();
|
||||
this->close();
|
||||
emit settingsUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Config::abort()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue