(Maybe the first) correction of the order the album art images are searched. Also...
[kugel-rb.git] / rbutil / rbutilqt / configure.cpp
blob0752b1f2a5e8b0509d8053dd0dc3071ceaec7534
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Riebeling
10 * $Id$
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include <QtGui>
22 #include "version.h"
23 #include "configure.h"
24 #include "autodetection.h"
25 #include "ui_configurefrm.h"
26 #include "browsedirtree.h"
27 #include "encoders.h"
28 #include "tts.h"
29 #include "detect.h"
30 #include "encttscfggui.h"
31 #include "rbsettings.h"
33 #include <stdio.h>
34 #if defined(Q_OS_WIN32)
35 #if defined(UNICODE)
36 #define _UNICODE
37 #endif
38 #include <tchar.h>
39 #include <windows.h>
40 #endif
42 #define DEFAULT_LANG "English (en)"
43 #define DEFAULT_LANG_CODE "en"
45 Config::Config(QWidget *parent,int index) : QDialog(parent)
47 programPath = qApp->applicationDirPath() + "/";
48 ui.setupUi(this);
49 ui.tabConfiguration->setCurrentIndex(index);
50 ui.radioManualProxy->setChecked(true);
51 QRegExpValidator *proxyValidator = new QRegExpValidator(this);
52 QRegExp validate("[0-9]*");
53 proxyValidator->setRegExp(validate);
54 ui.proxyPort->setValidator(proxyValidator);
55 #if !defined(Q_OS_LINUX) && !defined(Q_OS_WIN32)
56 ui.radioSystemProxy->setEnabled(false); // not on macox for now
57 #endif
58 // build language list and sort alphabetically
59 QStringList langs = findLanguageFiles();
60 for(int i = 0; i < langs.size(); ++i)
61 lang.insert(languageName(langs.at(i))
62 + QString(" (%1)").arg(langs.at(i)), langs.at(i));
63 lang.insert(DEFAULT_LANG, DEFAULT_LANG_CODE);
64 QMap<QString, QString>::const_iterator i = lang.constBegin();
65 while (i != lang.constEnd()) {
66 ui.listLanguages->addItem(i.key());
67 i++;
69 ui.listLanguages->setSelectionMode(QAbstractItemView::SingleSelection);
70 ui.proxyPass->setEchoMode(QLineEdit::Password);
71 ui.treeDevices->setAlternatingRowColors(true);
72 ui.listLanguages->setAlternatingRowColors(true);
74 this->setModal(true);
76 connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
77 connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(abort()));
78 connect(ui.radioNoProxy, SIGNAL(toggled(bool)), this, SLOT(setNoProxy(bool)));
79 connect(ui.radioSystemProxy, SIGNAL(toggled(bool)), this, SLOT(setSystemProxy(bool)));
80 connect(ui.browseMountPoint, SIGNAL(clicked()), this, SLOT(browseFolder()));
81 connect(ui.buttonAutodetect,SIGNAL(clicked()),this,SLOT(autodetect()));
82 connect(ui.buttonCacheBrowse, SIGNAL(clicked()), this, SLOT(browseCache()));
83 connect(ui.buttonCacheClear, SIGNAL(clicked()), this, SLOT(cacheClear()));
84 connect(ui.configTts, SIGNAL(clicked()), this, SLOT(configTts()));
85 connect(ui.configEncoder, SIGNAL(clicked()), this, SLOT(configEnc()));
86 connect(ui.comboTts, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsState(int)));
87 connect(ui.treeDevices, SIGNAL(itemSelectionChanged()), this, SLOT(updateEncState()));
89 setUserSettings();
90 setDevices();
93 void Config::accept()
95 qDebug() << "Config::accept()";
96 QString errormsg = tr("The following errors occurred:") + "<ul>";
97 bool error = false;
99 // proxy: save entered proxy values, not displayed.
100 if(ui.radioManualProxy->isChecked()) {
101 proxy.setScheme("http");
102 proxy.setUserName(ui.proxyUser->text());
103 proxy.setPassword(ui.proxyPass->text());
104 proxy.setHost(ui.proxyHost->text());
105 proxy.setPort(ui.proxyPort->text().toInt());
108 RbSettings::setValue(RbSettings::Proxy, proxy.toString());
109 qDebug() << "new proxy:" << proxy;
110 // proxy type
111 QString proxyType;
112 if(ui.radioNoProxy->isChecked()) proxyType = "none";
113 else if(ui.radioSystemProxy->isChecked()) proxyType = "system";
114 else proxyType = "manual";
115 RbSettings::setValue(RbSettings::ProxyType, proxyType);
117 // language
118 if(RbSettings::value(RbSettings::Language).toString() != language && !language.isEmpty()) {
119 QMessageBox::information(this, tr("Language changed"),
120 tr("You need to restart the application for the changed language to take effect."));
121 RbSettings::setValue(RbSettings::Language, language);
124 // mountpoint
125 QString mp = ui.mountPoint->text();
126 if(mp.isEmpty()) {
127 errormsg += "<li>" + tr("No mountpoint given") + "</li>";
128 error = true;
130 else if(!QFileInfo(mp).exists()) {
131 errormsg += "<li>" + tr("Mountpoint does not exist") + "</li>";
132 error = true;
134 else if(!QFileInfo(mp).isDir()) {
135 errormsg += "<li>" + tr("Mountpoint is not a directory.") + "</li>";
136 error = true;
138 else if(!QFileInfo(mp).isWritable()) {
139 errormsg += "<li>" + tr("Mountpoint is not writeable") + "</li>";
140 error = true;
142 else {
143 RbSettings::setValue(RbSettings::Mountpoint, QDir::fromNativeSeparators(mp));
146 // platform
147 QString nplat;
148 if(ui.treeDevices->selectedItems().size() != 0) {
149 nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
150 RbSettings::setValue(RbSettings::Platform, nplat);
152 else {
153 errormsg += "<li>" + tr("No player selected") + "</li>";
154 error = true;
157 // cache settings
158 if(QFileInfo(ui.cachePath->text()).isDir()) {
159 if(!QFileInfo(ui.cachePath->text()).isWritable()) {
160 errormsg += "<li>" + tr("Cache path not writeable. Leave path empty "
161 "to default to systems temporary path.") + "</li>";
162 error = true;
164 else
165 RbSettings::setValue(RbSettings::CachePath, ui.cachePath->text());
167 else // default to system temp path
168 RbSettings::setValue(RbSettings::CachePath, QDir::tempPath());
169 RbSettings::setValue(RbSettings::CacheDisabled, ui.cacheDisable->isChecked());
170 RbSettings::setValue(RbSettings::CacheOffline, ui.cacheOfflineMode->isChecked());
172 // tts settings
173 int i = ui.comboTts->currentIndex();
174 RbSettings::setValue(RbSettings::Tts, ui.comboTts->itemData(i).toString());
176 RbSettings::setValue(RbSettings::RbutilVersion, PUREVERSION);
178 errormsg += "</ul>";
179 errormsg += tr("You need to fix the above errors before you can continue.");
181 if(error) {
182 QMessageBox::critical(this, tr("Configuration error"), errormsg);
184 else {
185 // sync settings
186 RbSettings::sync();
187 this->close();
188 emit settingsUpdated();
193 void Config::abort()
195 qDebug() << "Config::abort()";
196 this->close();
199 void Config::setUserSettings()
201 // set proxy
202 proxy = RbSettings::value(RbSettings::Proxy).toString();
204 if(proxy.port() > 0)
205 ui.proxyPort->setText(QString("%1").arg(proxy.port()));
206 else ui.proxyPort->setText("");
207 ui.proxyHost->setText(proxy.host());
208 ui.proxyUser->setText(proxy.userName());
209 ui.proxyPass->setText(proxy.password());
211 QString proxyType = RbSettings::value(RbSettings::ProxyType).toString();
212 if(proxyType == "manual") ui.radioManualProxy->setChecked(true);
213 else if(proxyType == "system") ui.radioSystemProxy->setChecked(true);
214 else ui.radioNoProxy->setChecked(true);
216 // set language selection
217 QList<QListWidgetItem*> a;
218 QString b;
219 // find key for lang value
220 QMap<QString, QString>::const_iterator i = lang.constBegin();
221 QString l = RbSettings::value(RbSettings::Language).toString();
222 if(l.isEmpty())
223 l = QLocale::system().name();
224 while (i != lang.constEnd()) {
225 if(i.value() == l) {
226 b = i.key();
227 break;
229 else if(l.startsWith(i.value(), Qt::CaseInsensitive)) {
230 // check if there is a base language (en -> en_US, etc.)
231 b = i.key();
232 break;
234 i++;
236 a = ui.listLanguages->findItems(b, Qt::MatchExactly);
237 if(a.size() > 0)
238 ui.listLanguages->setCurrentItem(a.at(0));
239 // don't connect before language list has been set up to prevent
240 // triggering the signal by selecting the saved language.
241 connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage()));
243 // devices tab
244 ui.mountPoint->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::Mountpoint).toString()));
246 // cache tab
247 if(!QFileInfo(RbSettings::value(RbSettings::CachePath).toString()).isDir())
248 RbSettings::setValue(RbSettings::CachePath, QDir::tempPath());
249 ui.cachePath->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::CachePath).toString()));
250 ui.cacheDisable->setChecked(RbSettings::value(RbSettings::CacheDisabled).toBool());
251 ui.cacheOfflineMode->setChecked(RbSettings::value(RbSettings::CacheOffline).toBool());
252 updateCacheInfo(RbSettings::value(RbSettings::CachePath).toString());
256 void Config::updateCacheInfo(QString path)
258 QList<QFileInfo> fs;
259 fs = QDir(path + "/rbutil-cache/").entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
260 qint64 sz = 0;
261 for(int i = 0; i < fs.size(); i++) {
262 sz += fs.at(i).size();
263 qDebug() << fs.at(i).fileName() << fs.at(i).size();
265 ui.cacheSize->setText(tr("Current cache size is %L1 kiB.")
266 .arg(sz/1024));
270 void Config::setDevices()
273 // setup devices table
274 qDebug() << "Config::setDevices()";
276 QStringList platformList = RbSettings::platforms();
278 QMap <QString, QString> manuf;
279 QMap <QString, QString> devcs;
280 for(int it = 0; it < platformList.size(); it++)
282 QString curname = RbSettings::name(platformList.at(it));
283 QString curbrand = RbSettings::brand(platformList.at(it));
284 manuf.insertMulti(curbrand, platformList.at(it));
285 devcs.insert(platformList.at(it), curname);
288 QString platform;
289 platform = devcs.value(RbSettings::value(RbSettings::Platform).toString());
291 // set up devices table
292 ui.treeDevices->header()->hide();
293 ui.treeDevices->expandAll();
294 ui.treeDevices->setColumnCount(1);
295 QList<QTreeWidgetItem *> items;
297 // get manufacturers
298 QStringList brands = manuf.uniqueKeys();
299 QTreeWidgetItem *w;
300 QTreeWidgetItem *w2;
301 QTreeWidgetItem *w3 = 0;
302 for(int c = 0; c < brands.size(); c++) {
303 qDebug() << brands.at(c);
304 w = new QTreeWidgetItem();
305 w->setFlags(Qt::ItemIsEnabled);
306 w->setText(0, brands.at(c));
307 items.append(w);
309 // go through platforms again for sake of order
310 for(int it = 0; it < platformList.size(); it++) {
312 QString curname = RbSettings::name(platformList.at(it));
313 QString curbrand = RbSettings::brand(platformList.at(it));
315 if(curbrand != brands.at(c)) continue;
316 qDebug() << "adding:" << brands.at(c) << curname;
317 w2 = new QTreeWidgetItem(w, QStringList(curname));
318 w2->setData(0, Qt::UserRole, platformList.at(it));
320 if(platform.contains(curname)) {
321 w2->setSelected(true);
322 w->setExpanded(true);
323 w3 = w2; // save pointer to hilight old selection
325 items.append(w2);
328 ui.treeDevices->insertTopLevelItems(0, items);
329 if(w3 != 0)
330 ui.treeDevices->setCurrentItem(w3); // hilight old selection
332 // tts / encoder tab
334 //encoders
335 updateEncState();
337 //tts
338 QStringList ttslist = TTSBase::getTTSList();
339 for(int a = 0; a < ttslist.size(); a++)
340 ui.comboTts->addItem(TTSBase::getTTSName(ttslist.at(a)), ttslist.at(a));
341 //update index of combobox
342 int index = ui.comboTts->findData(RbSettings::value(RbSettings::Tts).toString());
343 if(index < 0) index = 0;
344 ui.comboTts->setCurrentIndex(index);
345 updateTtsState(index);
350 void Config::updateTtsState(int index)
352 QString ttsName = ui.comboTts->itemData(index).toString();
353 TTSBase* tts = TTSBase::getTTS(this,ttsName);
355 if(tts->configOk())
357 ui.configTTSstatus->setText(tr("Configuration OK"));
358 ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
360 else
362 ui.configTTSstatus->setText(tr("Configuration INVALID"));
363 ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
367 void Config::updateEncState()
369 // FIXME: this is a workaround to make the encoder follow the device selection
370 // even with the settings (and thus the device) being saved. Needs to be redone
371 // properly later by extending the settings object
372 if(ui.treeDevices->selectedItems().size() == 0)
373 return;
375 QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
376 QString olddevice = RbSettings::value(RbSettings::Platform).toString();
377 RbSettings::setValue(RbSettings::Platform, devname);
378 QString encoder = RbSettings::value(RbSettings::CurEncoder).toString();
379 ui.encoderName->setText(EncBase::getEncoderName(RbSettings::value(RbSettings::CurEncoder).toString()));
380 RbSettings::setValue(RbSettings::Platform, olddevice);
382 EncBase* enc = EncBase::getEncoder(this,encoder);
384 if(enc->configOk())
386 ui.configEncstatus->setText(tr("Configuration OK"));
387 ui.configEncstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
389 else
391 ui.configEncstatus->setText(tr("Configuration INVALID"));
392 ui.configEncstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
396 void Config::setNoProxy(bool checked)
398 bool i = !checked;
399 ui.proxyPort->setEnabled(i);
400 ui.proxyHost->setEnabled(i);
401 ui.proxyUser->setEnabled(i);
402 ui.proxyPass->setEnabled(i);
406 void Config::setSystemProxy(bool checked)
408 bool i = !checked;
409 ui.proxyPort->setEnabled(i);
410 ui.proxyHost->setEnabled(i);
411 ui.proxyUser->setEnabled(i);
412 ui.proxyPass->setEnabled(i);
413 if(checked) {
414 // save values in input box
415 proxy.setScheme("http");
416 proxy.setUserName(ui.proxyUser->text());
417 proxy.setPassword(ui.proxyPass->text());
418 proxy.setHost(ui.proxyHost->text());
419 proxy.setPort(ui.proxyPort->text().toInt());
420 // show system values in input box
421 QUrl envproxy = Detect::systemProxy();
423 ui.proxyHost->setText(envproxy.host());
425 ui.proxyPort->setText(QString("%1").arg(envproxy.port()));
426 ui.proxyUser->setText(envproxy.userName());
427 ui.proxyPass->setText(envproxy.password());
430 else {
431 ui.proxyHost->setText(proxy.host());
432 if(proxy.port() > 0)
433 ui.proxyPort->setText(QString("%1").arg(proxy.port()));
434 else ui.proxyPort->setText("");
435 ui.proxyUser->setText(proxy.userName());
436 ui.proxyPass->setText(proxy.password());
442 QStringList Config::findLanguageFiles()
444 QDir dir(programPath);
445 QStringList fileNames;
446 QStringList langs;
447 fileNames = dir.entryList(QStringList("*.qm"), QDir::Files, QDir::Name);
449 QDir resDir(":/lang");
450 fileNames += resDir.entryList(QStringList("*.qm"), QDir::Files, QDir::Name);
452 QRegExp exp("^rbutil_(.*)\\.qm");
453 for(int i = 0; i < fileNames.size(); i++) {
454 QString a = fileNames.at(i);
455 a.replace(exp, "\\1");
456 langs.append(a);
458 langs.sort();
459 qDebug() << "Config::findLanguageFiles()" << langs;
461 return langs;
465 QString Config::languageName(const QString &qmFile)
467 QTranslator translator;
469 QString file = "rbutil_" + qmFile;
470 if(!translator.load(file, programPath))
471 translator.load(file, ":/lang");
473 return translator.translate("Configure", "English",
474 "This is the localized language name, i.e. your language.");
478 void Config::updateLanguage()
480 qDebug() << "updateLanguage()";
481 QList<QListWidgetItem*> a = ui.listLanguages->selectedItems();
482 if(a.size() > 0)
483 language = lang.value(a.at(0)->text());
484 qDebug() << language;
488 void Config::browseFolder()
490 browser = new BrowseDirtree(this,tr("Select your device"));
491 #if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
492 browser->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
493 #elif defined(Q_OS_WIN32)
494 browser->setFilter(QDir::Drives);
495 #endif
496 #if defined(Q_OS_MACX)
497 browser->setRoot("/Volumes");
498 #elif defined(Q_OS_LINUX)
499 browser->setDir("/media");
500 #endif
501 if( ui.mountPoint->text() != "" )
503 browser->setDir(ui.mountPoint->text());
505 browser->show();
506 connect(browser, SIGNAL(itemChanged(QString)), this, SLOT(setMountpoint(QString)));
510 void Config::browseCache()
512 cbrowser = new BrowseDirtree(this);
513 #if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
514 cbrowser->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
515 #elif defined(Q_OS_WIN32)
516 cbrowser->setFilter(QDir::Drives | QDir::AllDirs | QDir::NoDotAndDotDot);
517 #endif
518 cbrowser->setDir(ui.cachePath->text());
519 connect(cbrowser, SIGNAL(itemChanged(QString)), this, SLOT(setCache(QString)));
520 cbrowser->show();
524 void Config::setMountpoint(QString m)
526 ui.mountPoint->setText(m);
530 void Config::setCache(QString c)
532 ui.cachePath->setText(c);
533 updateCacheInfo(c);
537 void Config::autodetect()
539 Autodetection detector(this);
540 // disable tree during detection as "working" feedback.
541 // TODO: replace the tree view with a splash screen during this time.
542 ui.treeDevices->setEnabled(false);
543 this->setCursor(Qt::WaitCursor);
544 QCoreApplication::processEvents();
546 if(detector.detect()) //let it detect
548 QString devicename = detector.getDevice();
549 // deexpand all items
550 for(int a = 0; a < ui.treeDevices->topLevelItemCount(); a++)
551 ui.treeDevices->topLevelItem(a)->setExpanded(false);
552 //deselect the selected item(s)
553 for(int a = 0; a < ui.treeDevices->selectedItems().size(); a++)
554 ui.treeDevices->selectedItems().at(a)->setSelected(false);
556 // find the new item
557 // enumerate all platform items
558 QList<QTreeWidgetItem*> itmList= ui.treeDevices->findItems("*",Qt::MatchWildcard);
559 for(int i=0; i< itmList.size();i++)
561 //enumerate device items
562 for(int j=0;j < itmList.at(i)->childCount();j++)
564 QString data = itmList.at(i)->child(j)->data(0, Qt::UserRole).toString();
566 if(devicename == data) // item found
568 itmList.at(i)->child(j)->setSelected(true); //select the item
569 itmList.at(i)->setExpanded(true); //expand the platform item
570 //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
571 break;
575 this->unsetCursor();
577 if(!detector.errdev().isEmpty()) {
578 QString text;
579 if(detector.errdev() == "sansae200")
580 text = tr("Sansa e200 in MTP mode found!\n"
581 "You need to change your player to MSC mode for installation. ");
582 if(detector.errdev() == "h10")
583 text = tr("H10 20GB in MTP mode found!\n"
584 "You need to change your player to UMS mode for installation. ");
585 text += tr("Unless you changed this installation will fail!");
587 QMessageBox::critical(this, tr("Fatal error"), text, QMessageBox::Ok);
588 return;
590 if(!detector.incompatdev().isEmpty()) {
591 QString text;
592 // we need to set the platform here to get the brand from the
593 // settings object
594 RbSettings::setValue(RbSettings::Platform, detector.incompatdev());
595 text = tr("Detected an unsupported %1 player variant. Sorry, "
596 "Rockbox doesn't run on your player.")
597 .arg(RbSettings::value(RbSettings::CurBrand).toString());
599 QMessageBox::critical(this, tr("Fatal error: incompatible player found"),
600 text, QMessageBox::Ok);
601 return;
604 if(detector.getMountPoint() != "" )
606 ui.mountPoint->setText(QDir::toNativeSeparators(detector.getMountPoint()));
608 else
610 QMessageBox::warning(this, tr("Autodetection"),
611 tr("Could not detect a Mountpoint.\n"
612 "Select your Mountpoint manually."),
613 QMessageBox::Ok ,QMessageBox::Ok);
616 else
618 this->unsetCursor();
619 QMessageBox::warning(this, tr("Autodetection"),
620 tr("Could not detect a device.\n"
621 "Select your device and Mountpoint manually."),
622 QMessageBox::Ok ,QMessageBox::Ok);
625 ui.treeDevices->setEnabled(true);
628 void Config::cacheClear()
630 if(QMessageBox::critical(this, tr("Really delete cache?"),
631 tr("Do you really want to delete the cache? "
632 "Make absolutely sure this setting is correct as it will "
633 "remove <b>all</b> files in this folder!").arg(ui.cachePath->text()),
634 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
635 return;
637 QString cache = ui.cachePath->text() + "/rbutil-cache/";
638 if(!QFileInfo(cache).isDir()) {
639 QMessageBox::critical(this, tr("Path wrong!"),
640 tr("The cache path is invalid. Aborting."), QMessageBox::Ok);
641 return;
643 QDir dir(cache);
644 QStringList fn;
645 fn = dir.entryList(QStringList("*"), QDir::Files, QDir::Name);
646 qDebug() << fn;
648 for(int i = 0; i < fn.size(); i++) {
649 QString f = cache + fn.at(i);
650 QFile::remove(f);
651 qDebug() << "removed:" << f;
653 updateCacheInfo(RbSettings::value(RbSettings::CachePath).toString());
657 void Config::configTts()
659 int index = ui.comboTts->currentIndex();
660 TTSBase* tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString());
662 EncTtsCfgGui gui(this,tts,TTSBase::getTTSName(RbSettings::value(RbSettings::Tts).toString()));
663 gui.exec();
664 updateTtsState(ui.comboTts->currentIndex());
668 void Config::configEnc()
670 // FIXME: this is a workaround to make the encoder follow the device selection
671 // even with the settings (and thus the device) being saved. Needs to be redone
672 // properly later by extending the settings object
673 if(ui.treeDevices->selectedItems().size() == 0)
674 return;
676 QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
677 QString olddevice = RbSettings::value(RbSettings::CurrentPlatform).toString();
678 RbSettings::setValue(RbSettings::CurrentPlatform,devname);
679 QString encoder = RbSettings::value(RbSettings::CurEncoder).toString();
680 ui.encoderName->setText(EncBase::getEncoderName(RbSettings::value(RbSettings::CurEncoder).toString()));
681 RbSettings::setValue(RbSettings::CurrentPlatform,olddevice);
684 EncBase* enc = EncBase::getEncoder(this,encoder);
686 EncTtsCfgGui gui(this,enc,EncBase::getEncoderName(encoder));
687 gui.exec();
689 updateEncState();