diff options
Diffstat (limited to 'rbutil/rbutilqt/configure.cpp')
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 108 |
1 files changed, 48 insertions, 60 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 00a899abb4..0752b1f2a5 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "tts.h" | 28 | #include "tts.h" |
29 | #include "detect.h" | 29 | #include "detect.h" |
30 | #include "encttscfggui.h" | 30 | #include "encttscfggui.h" |
31 | #include "rbsettings.h" | ||
31 | 32 | ||
32 | #include <stdio.h> | 33 | #include <stdio.h> |
33 | #if defined(Q_OS_WIN32) | 34 | #if defined(Q_OS_WIN32) |
@@ -85,10 +86,10 @@ Config::Config(QWidget *parent,int index) : QDialog(parent) | |||
85 | connect(ui.comboTts, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsState(int))); | 86 | connect(ui.comboTts, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsState(int))); |
86 | connect(ui.treeDevices, SIGNAL(itemSelectionChanged()), this, SLOT(updateEncState())); | 87 | connect(ui.treeDevices, SIGNAL(itemSelectionChanged()), this, SLOT(updateEncState())); |
87 | 88 | ||
89 | setUserSettings(); | ||
90 | setDevices(); | ||
88 | } | 91 | } |
89 | 92 | ||
90 | |||
91 | |||
92 | void Config::accept() | 93 | void Config::accept() |
93 | { | 94 | { |
94 | qDebug() << "Config::accept()"; | 95 | qDebug() << "Config::accept()"; |
@@ -104,20 +105,20 @@ void Config::accept() | |||
104 | proxy.setPort(ui.proxyPort->text().toInt()); | 105 | proxy.setPort(ui.proxyPort->text().toInt()); |
105 | } | 106 | } |
106 | 107 | ||
107 | settings->setValue(RbSettings::Proxy, proxy.toString()); | 108 | RbSettings::setValue(RbSettings::Proxy, proxy.toString()); |
108 | qDebug() << "new proxy:" << proxy; | 109 | qDebug() << "new proxy:" << proxy; |
109 | // proxy type | 110 | // proxy type |
110 | QString proxyType; | 111 | QString proxyType; |
111 | if(ui.radioNoProxy->isChecked()) proxyType = "none"; | 112 | if(ui.radioNoProxy->isChecked()) proxyType = "none"; |
112 | else if(ui.radioSystemProxy->isChecked()) proxyType = "system"; | 113 | else if(ui.radioSystemProxy->isChecked()) proxyType = "system"; |
113 | else proxyType = "manual"; | 114 | else proxyType = "manual"; |
114 | settings->setValue(RbSettings::ProxyType, proxyType); | 115 | RbSettings::setValue(RbSettings::ProxyType, proxyType); |
115 | 116 | ||
116 | // language | 117 | // language |
117 | if(settings->value(RbSettings::Language).toString() != language && !language.isEmpty()) { | 118 | if(RbSettings::value(RbSettings::Language).toString() != language && !language.isEmpty()) { |
118 | QMessageBox::information(this, tr("Language changed"), | 119 | QMessageBox::information(this, tr("Language changed"), |
119 | tr("You need to restart the application for the changed language to take effect.")); | 120 | tr("You need to restart the application for the changed language to take effect.")); |
120 | settings->setValue(RbSettings::Language, language); | 121 | RbSettings::setValue(RbSettings::Language, language); |
121 | } | 122 | } |
122 | 123 | ||
123 | // mountpoint | 124 | // mountpoint |
@@ -139,14 +140,14 @@ void Config::accept() | |||
139 | error = true; | 140 | error = true; |
140 | } | 141 | } |
141 | else { | 142 | else { |
142 | settings->setValue(RbSettings::Mountpoint, QDir::fromNativeSeparators(mp)); | 143 | RbSettings::setValue(RbSettings::Mountpoint, QDir::fromNativeSeparators(mp)); |
143 | } | 144 | } |
144 | 145 | ||
145 | // platform | 146 | // platform |
146 | QString nplat; | 147 | QString nplat; |
147 | if(ui.treeDevices->selectedItems().size() != 0) { | 148 | if(ui.treeDevices->selectedItems().size() != 0) { |
148 | nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString(); | 149 | nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString(); |
149 | settings->setValue(RbSettings::Platform, nplat); | 150 | RbSettings::setValue(RbSettings::Platform, nplat); |
150 | } | 151 | } |
151 | else { | 152 | else { |
152 | errormsg += "<li>" + tr("No player selected") + "</li>"; | 153 | errormsg += "<li>" + tr("No player selected") + "</li>"; |
@@ -161,18 +162,18 @@ void Config::accept() | |||
161 | error = true; | 162 | error = true; |
162 | } | 163 | } |
163 | else | 164 | else |
164 | settings->setValue(RbSettings::CachePath, ui.cachePath->text()); | 165 | RbSettings::setValue(RbSettings::CachePath, ui.cachePath->text()); |
165 | } | 166 | } |
166 | else // default to system temp path | 167 | else // default to system temp path |
167 | settings->setValue(RbSettings::CachePath, QDir::tempPath()); | 168 | RbSettings::setValue(RbSettings::CachePath, QDir::tempPath()); |
168 | settings->setValue(RbSettings::CacheDisabled, ui.cacheDisable->isChecked()); | 169 | RbSettings::setValue(RbSettings::CacheDisabled, ui.cacheDisable->isChecked()); |
169 | settings->setValue(RbSettings::CacheOffline, ui.cacheOfflineMode->isChecked()); | 170 | RbSettings::setValue(RbSettings::CacheOffline, ui.cacheOfflineMode->isChecked()); |
170 | 171 | ||
171 | // tts settings | 172 | // tts settings |
172 | int i = ui.comboTts->currentIndex(); | 173 | int i = ui.comboTts->currentIndex(); |
173 | settings->setValue(RbSettings::Tts, ui.comboTts->itemData(i).toString()); | 174 | RbSettings::setValue(RbSettings::Tts, ui.comboTts->itemData(i).toString()); |
174 | 175 | ||
175 | settings->setValue(RbSettings::RbutilVersion, PUREVERSION); | 176 | RbSettings::setValue(RbSettings::RbutilVersion, PUREVERSION); |
176 | 177 | ||
177 | errormsg += "</ul>"; | 178 | errormsg += "</ul>"; |
178 | errormsg += tr("You need to fix the above errors before you can continue."); | 179 | errormsg += tr("You need to fix the above errors before you can continue."); |
@@ -182,7 +183,7 @@ void Config::accept() | |||
182 | } | 183 | } |
183 | else { | 184 | else { |
184 | // sync settings | 185 | // sync settings |
185 | settings->sync(); | 186 | RbSettings::sync(); |
186 | this->close(); | 187 | this->close(); |
187 | emit settingsUpdated(); | 188 | emit settingsUpdated(); |
188 | } | 189 | } |
@@ -195,18 +196,10 @@ void Config::abort() | |||
195 | this->close(); | 196 | this->close(); |
196 | } | 197 | } |
197 | 198 | ||
198 | void Config::setSettings(RbSettings* sett) | ||
199 | { | ||
200 | settings = sett; | ||
201 | |||
202 | setUserSettings(); | ||
203 | setDevices(); | ||
204 | } | ||
205 | |||
206 | void Config::setUserSettings() | 199 | void Config::setUserSettings() |
207 | { | 200 | { |
208 | // set proxy | 201 | // set proxy |
209 | proxy = settings->value(RbSettings::Proxy).toString(); | 202 | proxy = RbSettings::value(RbSettings::Proxy).toString(); |
210 | 203 | ||
211 | if(proxy.port() > 0) | 204 | if(proxy.port() > 0) |
212 | ui.proxyPort->setText(QString("%1").arg(proxy.port())); | 205 | ui.proxyPort->setText(QString("%1").arg(proxy.port())); |
@@ -215,7 +208,7 @@ void Config::setUserSettings() | |||
215 | ui.proxyUser->setText(proxy.userName()); | 208 | ui.proxyUser->setText(proxy.userName()); |
216 | ui.proxyPass->setText(proxy.password()); | 209 | ui.proxyPass->setText(proxy.password()); |
217 | 210 | ||
218 | QString proxyType = settings->value(RbSettings::ProxyType).toString(); | 211 | QString proxyType = RbSettings::value(RbSettings::ProxyType).toString(); |
219 | if(proxyType == "manual") ui.radioManualProxy->setChecked(true); | 212 | if(proxyType == "manual") ui.radioManualProxy->setChecked(true); |
220 | else if(proxyType == "system") ui.radioSystemProxy->setChecked(true); | 213 | else if(proxyType == "system") ui.radioSystemProxy->setChecked(true); |
221 | else ui.radioNoProxy->setChecked(true); | 214 | else ui.radioNoProxy->setChecked(true); |
@@ -225,7 +218,7 @@ void Config::setUserSettings() | |||
225 | QString b; | 218 | QString b; |
226 | // find key for lang value | 219 | // find key for lang value |
227 | QMap<QString, QString>::const_iterator i = lang.constBegin(); | 220 | QMap<QString, QString>::const_iterator i = lang.constBegin(); |
228 | QString l = settings->value(RbSettings::Language).toString(); | 221 | QString l = RbSettings::value(RbSettings::Language).toString(); |
229 | if(l.isEmpty()) | 222 | if(l.isEmpty()) |
230 | l = QLocale::system().name(); | 223 | l = QLocale::system().name(); |
231 | while (i != lang.constEnd()) { | 224 | while (i != lang.constEnd()) { |
@@ -248,15 +241,15 @@ void Config::setUserSettings() | |||
248 | connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage())); | 241 | connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage())); |
249 | 242 | ||
250 | // devices tab | 243 | // devices tab |
251 | ui.mountPoint->setText(QDir::toNativeSeparators(settings->value(RbSettings::Mountpoint).toString())); | 244 | ui.mountPoint->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::Mountpoint).toString())); |
252 | 245 | ||
253 | // cache tab | 246 | // cache tab |
254 | if(!QFileInfo(settings->value(RbSettings::CachePath).toString()).isDir()) | 247 | if(!QFileInfo(RbSettings::value(RbSettings::CachePath).toString()).isDir()) |
255 | settings->setValue(RbSettings::CachePath, QDir::tempPath()); | 248 | RbSettings::setValue(RbSettings::CachePath, QDir::tempPath()); |
256 | ui.cachePath->setText(QDir::toNativeSeparators(settings->value(RbSettings::CachePath).toString())); | 249 | ui.cachePath->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::CachePath).toString())); |
257 | ui.cacheDisable->setChecked(settings->value(RbSettings::CacheDisabled).toBool()); | 250 | ui.cacheDisable->setChecked(RbSettings::value(RbSettings::CacheDisabled).toBool()); |
258 | ui.cacheOfflineMode->setChecked(settings->value(RbSettings::CacheOffline).toBool()); | 251 | ui.cacheOfflineMode->setChecked(RbSettings::value(RbSettings::CacheOffline).toBool()); |
259 | updateCacheInfo(settings->value(RbSettings::CachePath).toString()); | 252 | updateCacheInfo(RbSettings::value(RbSettings::CachePath).toString()); |
260 | } | 253 | } |
261 | 254 | ||
262 | 255 | ||
@@ -280,20 +273,20 @@ void Config::setDevices() | |||
280 | // setup devices table | 273 | // setup devices table |
281 | qDebug() << "Config::setDevices()"; | 274 | qDebug() << "Config::setDevices()"; |
282 | 275 | ||
283 | QStringList platformList = settings->platforms(); | 276 | QStringList platformList = RbSettings::platforms(); |
284 | 277 | ||
285 | QMap <QString, QString> manuf; | 278 | QMap <QString, QString> manuf; |
286 | QMap <QString, QString> devcs; | 279 | QMap <QString, QString> devcs; |
287 | for(int it = 0; it < platformList.size(); it++) | 280 | for(int it = 0; it < platformList.size(); it++) |
288 | { | 281 | { |
289 | QString curname = settings->name(platformList.at(it)); | 282 | QString curname = RbSettings::name(platformList.at(it)); |
290 | QString curbrand = settings->brand(platformList.at(it)); | 283 | QString curbrand = RbSettings::brand(platformList.at(it)); |
291 | manuf.insertMulti(curbrand, platformList.at(it)); | 284 | manuf.insertMulti(curbrand, platformList.at(it)); |
292 | devcs.insert(platformList.at(it), curname); | 285 | devcs.insert(platformList.at(it), curname); |
293 | } | 286 | } |
294 | 287 | ||
295 | QString platform; | 288 | QString platform; |
296 | platform = devcs.value(settings->value(RbSettings::Platform).toString()); | 289 | platform = devcs.value(RbSettings::value(RbSettings::Platform).toString()); |
297 | 290 | ||
298 | // set up devices table | 291 | // set up devices table |
299 | ui.treeDevices->header()->hide(); | 292 | ui.treeDevices->header()->hide(); |
@@ -316,8 +309,8 @@ void Config::setDevices() | |||
316 | // go through platforms again for sake of order | 309 | // go through platforms again for sake of order |
317 | for(int it = 0; it < platformList.size(); it++) { | 310 | for(int it = 0; it < platformList.size(); it++) { |
318 | 311 | ||
319 | QString curname = settings->name(platformList.at(it)); | 312 | QString curname = RbSettings::name(platformList.at(it)); |
320 | QString curbrand = settings->brand(platformList.at(it)); | 313 | QString curbrand = RbSettings::brand(platformList.at(it)); |
321 | 314 | ||
322 | if(curbrand != brands.at(c)) continue; | 315 | if(curbrand != brands.at(c)) continue; |
323 | qDebug() << "adding:" << brands.at(c) << curname; | 316 | qDebug() << "adding:" << brands.at(c) << curname; |
@@ -346,7 +339,7 @@ void Config::setDevices() | |||
346 | for(int a = 0; a < ttslist.size(); a++) | 339 | for(int a = 0; a < ttslist.size(); a++) |
347 | ui.comboTts->addItem(TTSBase::getTTSName(ttslist.at(a)), ttslist.at(a)); | 340 | ui.comboTts->addItem(TTSBase::getTTSName(ttslist.at(a)), ttslist.at(a)); |
348 | //update index of combobox | 341 | //update index of combobox |
349 | int index = ui.comboTts->findData(settings->value(RbSettings::Tts).toString()); | 342 | int index = ui.comboTts->findData(RbSettings::value(RbSettings::Tts).toString()); |
350 | if(index < 0) index = 0; | 343 | if(index < 0) index = 0; |
351 | ui.comboTts->setCurrentIndex(index); | 344 | ui.comboTts->setCurrentIndex(index); |
352 | updateTtsState(index); | 345 | updateTtsState(index); |
@@ -358,7 +351,6 @@ void Config::updateTtsState(int index) | |||
358 | { | 351 | { |
359 | QString ttsName = ui.comboTts->itemData(index).toString(); | 352 | QString ttsName = ui.comboTts->itemData(index).toString(); |
360 | TTSBase* tts = TTSBase::getTTS(this,ttsName); | 353 | TTSBase* tts = TTSBase::getTTS(this,ttsName); |
361 | tts->setCfg(settings); | ||
362 | 354 | ||
363 | if(tts->configOk()) | 355 | if(tts->configOk()) |
364 | { | 356 | { |
@@ -381,14 +373,13 @@ void Config::updateEncState() | |||
381 | return; | 373 | return; |
382 | 374 | ||
383 | QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString(); | 375 | QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString(); |
384 | QString olddevice = settings->value(RbSettings::Platform).toString(); | 376 | QString olddevice = RbSettings::value(RbSettings::Platform).toString(); |
385 | settings->setValue(RbSettings::Platform, devname); | 377 | RbSettings::setValue(RbSettings::Platform, devname); |
386 | QString encoder = settings->value(RbSettings::CurEncoder).toString(); | 378 | QString encoder = RbSettings::value(RbSettings::CurEncoder).toString(); |
387 | ui.encoderName->setText(EncBase::getEncoderName(settings->value(RbSettings::CurEncoder).toString())); | 379 | ui.encoderName->setText(EncBase::getEncoderName(RbSettings::value(RbSettings::CurEncoder).toString())); |
388 | settings->setValue(RbSettings::Platform, olddevice); | 380 | RbSettings::setValue(RbSettings::Platform, olddevice); |
389 | 381 | ||
390 | EncBase* enc = EncBase::getEncoder(this,encoder); | 382 | EncBase* enc = EncBase::getEncoder(this,encoder); |
391 | enc->setCfg(settings); | ||
392 | 383 | ||
393 | if(enc->configOk()) | 384 | if(enc->configOk()) |
394 | { | 385 | { |
@@ -546,7 +537,6 @@ void Config::setCache(QString c) | |||
546 | void Config::autodetect() | 537 | void Config::autodetect() |
547 | { | 538 | { |
548 | Autodetection detector(this); | 539 | Autodetection detector(this); |
549 | detector.setSettings(settings); | ||
550 | // disable tree during detection as "working" feedback. | 540 | // disable tree during detection as "working" feedback. |
551 | // TODO: replace the tree view with a splash screen during this time. | 541 | // TODO: replace the tree view with a splash screen during this time. |
552 | ui.treeDevices->setEnabled(false); | 542 | ui.treeDevices->setEnabled(false); |
@@ -601,10 +591,10 @@ void Config::autodetect() | |||
601 | QString text; | 591 | QString text; |
602 | // we need to set the platform here to get the brand from the | 592 | // we need to set the platform here to get the brand from the |
603 | // settings object | 593 | // settings object |
604 | settings->setValue(RbSettings::Platform, detector.incompatdev()); | 594 | RbSettings::setValue(RbSettings::Platform, detector.incompatdev()); |
605 | text = tr("Detected an unsupported %1 player variant. Sorry, " | 595 | text = tr("Detected an unsupported %1 player variant. Sorry, " |
606 | "Rockbox doesn't run on your player.") | 596 | "Rockbox doesn't run on your player.") |
607 | .arg(settings->value(RbSettings::CurBrand).toString()); | 597 | .arg(RbSettings::value(RbSettings::CurBrand).toString()); |
608 | 598 | ||
609 | QMessageBox::critical(this, tr("Fatal error: incompatible player found"), | 599 | QMessageBox::critical(this, tr("Fatal error: incompatible player found"), |
610 | text, QMessageBox::Ok); | 600 | text, QMessageBox::Ok); |
@@ -660,7 +650,7 @@ void Config::cacheClear() | |||
660 | QFile::remove(f); | 650 | QFile::remove(f); |
661 | qDebug() << "removed:" << f; | 651 | qDebug() << "removed:" << f; |
662 | } | 652 | } |
663 | updateCacheInfo(settings->value(RbSettings::CachePath).toString()); | 653 | updateCacheInfo(RbSettings::value(RbSettings::CachePath).toString()); |
664 | } | 654 | } |
665 | 655 | ||
666 | 656 | ||
@@ -669,8 +659,7 @@ void Config::configTts() | |||
669 | int index = ui.comboTts->currentIndex(); | 659 | int index = ui.comboTts->currentIndex(); |
670 | TTSBase* tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString()); | 660 | TTSBase* tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString()); |
671 | 661 | ||
672 | tts->setCfg(settings); | 662 | EncTtsCfgGui gui(this,tts,TTSBase::getTTSName(RbSettings::value(RbSettings::Tts).toString())); |
673 | EncTtsCfgGui gui(this,tts,TTSBase::getTTSName(settings->value(RbSettings::Tts).toString())); | ||
674 | gui.exec(); | 663 | gui.exec(); |
675 | updateTtsState(ui.comboTts->currentIndex()); | 664 | updateTtsState(ui.comboTts->currentIndex()); |
676 | } | 665 | } |
@@ -685,16 +674,15 @@ void Config::configEnc() | |||
685 | return; | 674 | return; |
686 | 675 | ||
687 | QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString(); | 676 | QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString(); |
688 | QString olddevice = settings->value(RbSettings::CurrentPlatform).toString(); | 677 | QString olddevice = RbSettings::value(RbSettings::CurrentPlatform).toString(); |
689 | settings->setValue(RbSettings::CurrentPlatform,devname); | 678 | RbSettings::setValue(RbSettings::CurrentPlatform,devname); |
690 | QString encoder = settings->value(RbSettings::CurEncoder).toString(); | 679 | QString encoder = RbSettings::value(RbSettings::CurEncoder).toString(); |
691 | ui.encoderName->setText(EncBase::getEncoderName(settings->value(RbSettings::CurEncoder).toString())); | 680 | ui.encoderName->setText(EncBase::getEncoderName(RbSettings::value(RbSettings::CurEncoder).toString())); |
692 | settings->setValue(RbSettings::CurrentPlatform,olddevice); | 681 | RbSettings::setValue(RbSettings::CurrentPlatform,olddevice); |
693 | 682 | ||
694 | 683 | ||
695 | EncBase* enc = EncBase::getEncoder(this,encoder); | 684 | EncBase* enc = EncBase::getEncoder(this,encoder); |
696 | 685 | ||
697 | enc->setCfg(settings); | ||
698 | EncTtsCfgGui gui(this,enc,EncBase::getEncoderName(encoder)); | 686 | EncTtsCfgGui gui(this,enc,EncBase::getEncoderName(encoder)); |
699 | gui.exec(); | 687 | gui.exec(); |
700 | 688 | ||