summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/configure.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/configure.cpp')
-rw-r--r--rbutil/rbutilqt/configure.cpp63
1 files changed, 51 insertions, 12 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index 68a8a91129..bf65c189a5 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -83,7 +83,7 @@ Config::Config(QWidget *parent,int index) : QDialog(parent)
83 connect(ui.configEncoder, SIGNAL(clicked()), this, SLOT(configEnc())); 83 connect(ui.configEncoder, SIGNAL(clicked()), this, SLOT(configEnc()));
84 connect(ui.comboTts, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsState(int))); 84 connect(ui.comboTts, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsState(int)));
85 connect(ui.treeDevices, SIGNAL(itemSelectionChanged()), this, SLOT(updateEncState())); 85 connect(ui.treeDevices, SIGNAL(itemSelectionChanged()), this, SLOT(updateEncState()));
86 86
87} 87}
88 88
89 89
@@ -91,6 +91,9 @@ Config::Config(QWidget *parent,int index) : QDialog(parent)
91void Config::accept() 91void Config::accept()
92{ 92{
93 qDebug() << "Config::accept()"; 93 qDebug() << "Config::accept()";
94 QString errormsg = tr("The following errors occurred:") + "<ul>";
95 bool error = false;
96
94 // proxy: save entered proxy values, not displayed. 97 // proxy: save entered proxy values, not displayed.
95 if(ui.radioManualProxy->isChecked()) { 98 if(ui.radioManualProxy->isChecked()) {
96 proxy.setScheme("http"); 99 proxy.setScheme("http");
@@ -99,7 +102,7 @@ void Config::accept()
99 proxy.setHost(ui.proxyHost->text()); 102 proxy.setHost(ui.proxyHost->text());
100 proxy.setPort(ui.proxyPort->text().toInt()); 103 proxy.setPort(ui.proxyPort->text().toInt());
101 } 104 }
102 105
103 settings->setProxy(proxy.toString()); 106 settings->setProxy(proxy.toString());
104 qDebug() << "new proxy:" << proxy; 107 qDebug() << "new proxy:" << proxy;
105 // proxy type 108 // proxy type
@@ -118,8 +121,25 @@ void Config::accept()
118 121
119 // mountpoint 122 // mountpoint
120 QString mp = ui.mountPoint->text(); 123 QString mp = ui.mountPoint->text();
121 if(QFileInfo(mp).isDir()) 124 if(mp.isEmpty()) {
125 errormsg += "<li>" + tr("No mountpoint given") + "</li>";
126 error = true;
127 }
128 else if(!QFileInfo(mp).exists()) {
129 errormsg += "<li>" + tr("Mountpoint does not exist") + "</li>";
130 error = true;
131 }
132 else if(!QFileInfo(mp).isDir()) {
133 errormsg += "<li>" + tr("Mountpoint is not a directory.") + "</li>";
134 error = true;
135 }
136 else if(!QFileInfo(mp).isWritable()) {
137 errormsg += "<li>" + tr("Mountpoint is not writeable") + "</li>";
138 error = true;
139 }
140 else {
122 settings->setMountpoint(QDir::fromNativeSeparators(mp)); 141 settings->setMountpoint(QDir::fromNativeSeparators(mp));
142 }
123 143
124 // platform 144 // platform
125 QString nplat; 145 QString nplat;
@@ -127,25 +147,44 @@ void Config::accept()
127 nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString(); 147 nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
128 settings->setCurPlatform(nplat); 148 settings->setCurPlatform(nplat);
129 } 149 }
150 else {
151 errormsg += "<li>" + tr("No player selected") + "</li>";
152 error = true;
153 }
130 154
131 // cache settings 155 // cache settings
132 if(QFileInfo(ui.cachePath->text()).isDir()) 156 if(QFileInfo(ui.cachePath->text()).isDir()) {
133 settings->setCachePath(ui.cachePath->text()); 157 if(!QFileInfo(ui.cachePath->text()).isWritable()) {
158 errormsg += "<li>" + tr("Cache path not writeable. Leave path empty "
159 "to default to systems temporary path.") + "</li>";
160 error = true;
161 }
162 else
163 settings->setCachePath(ui.cachePath->text());
164 }
134 else // default to system temp path 165 else // default to system temp path
135 settings->setCachePath( QDir::tempPath()); 166 settings->setCachePath(QDir::tempPath());
136 settings->setCacheDisable(ui.cacheDisable->isChecked()); 167 settings->setCacheDisable(ui.cacheDisable->isChecked());
137 settings->setCacheOffline(ui.cacheOfflineMode->isChecked()); 168 settings->setCacheOffline(ui.cacheOfflineMode->isChecked());
138 169
139 // tts settings 170 // tts settings
140 int i = ui.comboTts->currentIndex(); 171 int i = ui.comboTts->currentIndex();
141 settings->setCurTTS(ui.comboTts->itemData(i).toString()); 172 settings->setCurTTS(ui.comboTts->itemData(i).toString());
142 173
143 settings->setCurVersion(PUREVERSION); 174 settings->setCurVersion(PUREVERSION);
144 175
145 // sync settings 176 errormsg += "</ul>";
146 settings->sync(); 177 errormsg += tr("You need to fix the above errors before you can continue.");
147 this->close(); 178
148 emit settingsUpdated(); 179 if(error) {
180 QMessageBox::critical(this, tr("Configuration error"), errormsg);
181 }
182 else {
183 // sync settings
184 settings->sync();
185 this->close();
186 emit settingsUpdated();
187 }
149} 188}
150 189
151 190
@@ -158,7 +197,7 @@ void Config::abort()
158void Config::setSettings(RbSettings* sett) 197void Config::setSettings(RbSettings* sett)
159{ 198{
160 settings = sett; 199 settings = sett;
161 200
162 setUserSettings(); 201 setUserSettings();
163 setDevices(); 202 setDevices();
164} 203}