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
|
|
@ -83,7 +83,7 @@ Config::Config(QWidget *parent,int index) : QDialog(parent)
|
||||||
connect(ui.configEncoder, SIGNAL(clicked()), this, SLOT(configEnc()));
|
connect(ui.configEncoder, SIGNAL(clicked()), this, SLOT(configEnc()));
|
||||||
connect(ui.comboTts, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsState(int)));
|
connect(ui.comboTts, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsState(int)));
|
||||||
connect(ui.treeDevices, SIGNAL(itemSelectionChanged()), this, SLOT(updateEncState()));
|
connect(ui.treeDevices, SIGNAL(itemSelectionChanged()), this, SLOT(updateEncState()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -91,6 +91,9 @@ Config::Config(QWidget *parent,int index) : QDialog(parent)
|
||||||
void Config::accept()
|
void Config::accept()
|
||||||
{
|
{
|
||||||
qDebug() << "Config::accept()";
|
qDebug() << "Config::accept()";
|
||||||
|
QString errormsg = tr("The following errors occurred:") + "<ul>";
|
||||||
|
bool error = false;
|
||||||
|
|
||||||
// proxy: save entered proxy values, not displayed.
|
// proxy: save entered proxy values, not displayed.
|
||||||
if(ui.radioManualProxy->isChecked()) {
|
if(ui.radioManualProxy->isChecked()) {
|
||||||
proxy.setScheme("http");
|
proxy.setScheme("http");
|
||||||
|
|
@ -99,7 +102,7 @@ void Config::accept()
|
||||||
proxy.setHost(ui.proxyHost->text());
|
proxy.setHost(ui.proxyHost->text());
|
||||||
proxy.setPort(ui.proxyPort->text().toInt());
|
proxy.setPort(ui.proxyPort->text().toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
settings->setProxy(proxy.toString());
|
settings->setProxy(proxy.toString());
|
||||||
qDebug() << "new proxy:" << proxy;
|
qDebug() << "new proxy:" << proxy;
|
||||||
// proxy type
|
// proxy type
|
||||||
|
|
@ -118,8 +121,25 @@ void Config::accept()
|
||||||
|
|
||||||
// mountpoint
|
// mountpoint
|
||||||
QString mp = ui.mountPoint->text();
|
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));
|
settings->setMountpoint(QDir::fromNativeSeparators(mp));
|
||||||
|
}
|
||||||
|
|
||||||
// platform
|
// platform
|
||||||
QString nplat;
|
QString nplat;
|
||||||
|
|
@ -127,25 +147,44 @@ void Config::accept()
|
||||||
nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
|
nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
|
||||||
settings->setCurPlatform(nplat);
|
settings->setCurPlatform(nplat);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
errormsg += "<li>" + tr("No player selected") + "</li>";
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
|
||||||
// cache settings
|
// cache settings
|
||||||
if(QFileInfo(ui.cachePath->text()).isDir())
|
if(QFileInfo(ui.cachePath->text()).isDir()) {
|
||||||
settings->setCachePath(ui.cachePath->text());
|
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
|
else // default to system temp path
|
||||||
settings->setCachePath( QDir::tempPath());
|
settings->setCachePath(QDir::tempPath());
|
||||||
settings->setCacheDisable(ui.cacheDisable->isChecked());
|
settings->setCacheDisable(ui.cacheDisable->isChecked());
|
||||||
settings->setCacheOffline(ui.cacheOfflineMode->isChecked());
|
settings->setCacheOffline(ui.cacheOfflineMode->isChecked());
|
||||||
|
|
||||||
// tts settings
|
// tts settings
|
||||||
int i = ui.comboTts->currentIndex();
|
int i = ui.comboTts->currentIndex();
|
||||||
settings->setCurTTS(ui.comboTts->itemData(i).toString());
|
settings->setCurTTS(ui.comboTts->itemData(i).toString());
|
||||||
|
|
||||||
settings->setCurVersion(PUREVERSION);
|
settings->setCurVersion(PUREVERSION);
|
||||||
|
|
||||||
// sync settings
|
errormsg += "</ul>";
|
||||||
settings->sync();
|
errormsg += tr("You need to fix the above errors before you can continue.");
|
||||||
this->close();
|
|
||||||
emit settingsUpdated();
|
if(error) {
|
||||||
|
QMessageBox::critical(this, tr("Configuration error"), errormsg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// sync settings
|
||||||
|
settings->sync();
|
||||||
|
this->close();
|
||||||
|
emit settingsUpdated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -158,7 +197,7 @@ void Config::abort()
|
||||||
void Config::setSettings(RbSettings* sett)
|
void Config::setSettings(RbSettings* sett)
|
||||||
{
|
{
|
||||||
settings = sett;
|
settings = sett;
|
||||||
|
|
||||||
setUserSettings();
|
setUserSettings();
|
||||||
setDevices();
|
setDevices();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue