FS#8961 - Anti-Aliased Fonts.
[kugel-rb.git] / rbutil / rbutilqt / configure.cpp
blob857242a60cc4081fbc500a20d1114961cbddd5be
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 "system.h"
30 #include "encttscfggui.h"
31 #include "rbsettings.h"
32 #include "utils.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()));
88 connect(ui.testTTS,SIGNAL(clicked()),this,SLOT(testTts()));
89 setUserSettings();
90 setDevices();
94 void Config::accept()
96 qDebug() << "[Config] checking configuration";
97 QString errormsg = tr("The following errors occurred:") + "<ul>";
98 bool error = false;
100 // proxy: save entered proxy values, not displayed.
101 if(ui.radioManualProxy->isChecked()) {
102 proxy.setScheme("http");
103 proxy.setUserName(ui.proxyUser->text());
104 proxy.setPassword(ui.proxyPass->text());
105 proxy.setHost(ui.proxyHost->text());
106 proxy.setPort(ui.proxyPort->text().toInt());
109 RbSettings::setValue(RbSettings::Proxy, proxy.toString());
110 qDebug() << "[Config] setting proxy to:" << proxy;
111 // proxy type
112 QString proxyType;
113 if(ui.radioNoProxy->isChecked()) proxyType = "none";
114 else if(ui.radioSystemProxy->isChecked()) proxyType = "system";
115 else proxyType = "manual";
116 RbSettings::setValue(RbSettings::ProxyType, proxyType);
118 // language
119 if(RbSettings::value(RbSettings::Language).toString() != language
120 && !language.isEmpty()) {
121 QMessageBox::information(this, tr("Language changed"),
122 tr("You need to restart the application for the changed language to take effect."));
123 RbSettings::setValue(RbSettings::Language, language);
126 // mountpoint
127 QString mp = ui.mountPoint->text();
128 if(mp.isEmpty()) {
129 errormsg += "<li>" + tr("No mountpoint given") + "</li>";
130 error = true;
132 else if(!QFileInfo(mp).exists()) {
133 errormsg += "<li>" + tr("Mountpoint does not exist") + "</li>";
134 error = true;
136 else if(!QFileInfo(mp).isDir()) {
137 errormsg += "<li>" + tr("Mountpoint is not a directory.") + "</li>";
138 error = true;
140 else if(!QFileInfo(mp).isWritable()) {
141 errormsg += "<li>" + tr("Mountpoint is not writeable") + "</li>";
142 error = true;
144 else {
145 RbSettings::setValue(RbSettings::Mountpoint, QDir::fromNativeSeparators(mp));
148 // platform
149 QString nplat;
150 if(ui.treeDevices->selectedItems().size() != 0) {
151 nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
152 RbSettings::setValue(RbSettings::Platform, nplat);
154 else {
155 errormsg += "<li>" + tr("No player selected") + "</li>";
156 error = true;
159 // cache settings
160 if(QFileInfo(ui.cachePath->text()).isDir()) {
161 if(!QFileInfo(ui.cachePath->text()).isWritable()) {
162 errormsg += "<li>" + tr("Cache path not writeable. Leave path empty "
163 "to default to systems temporary path.") + "</li>";
164 error = true;
166 else
167 RbSettings::setValue(RbSettings::CachePath, ui.cachePath->text());
169 else // default to system temp path
170 RbSettings::setValue(RbSettings::CachePath, QDir::tempPath());
171 RbSettings::setValue(RbSettings::CacheDisabled, ui.cacheDisable->isChecked());
172 RbSettings::setValue(RbSettings::CacheOffline, ui.cacheOfflineMode->isChecked());
174 // tts settings
175 int i = ui.comboTts->currentIndex();
176 RbSettings::setValue(RbSettings::Tts, ui.comboTts->itemData(i).toString());
178 RbSettings::setValue(RbSettings::RbutilVersion, PUREVERSION);
180 errormsg += "</ul>";
181 errormsg += tr("You need to fix the above errors before you can continue.");
183 if(error) {
184 QMessageBox::critical(this, tr("Configuration error"), errormsg);
186 else {
187 // sync settings
188 RbSettings::sync();
189 this->close();
190 emit settingsUpdated();
195 void Config::abort()
197 qDebug() << "[Config] aborted.";
198 this->close();
202 void Config::setUserSettings()
204 // set proxy
205 proxy = RbSettings::value(RbSettings::Proxy).toString();
207 if(proxy.port() > 0)
208 ui.proxyPort->setText(QString("%1").arg(proxy.port()));
209 else ui.proxyPort->setText("");
210 ui.proxyHost->setText(proxy.host());
211 ui.proxyUser->setText(proxy.userName());
212 ui.proxyPass->setText(proxy.password());
214 QString proxyType = RbSettings::value(RbSettings::ProxyType).toString();
215 if(proxyType == "manual") ui.radioManualProxy->setChecked(true);
216 else if(proxyType == "system") ui.radioSystemProxy->setChecked(true);
217 else ui.radioNoProxy->setChecked(true);
219 // set language selection
220 QList<QListWidgetItem*> a;
221 QString b;
222 // find key for lang value
223 QMap<QString, QString>::const_iterator i = lang.constBegin();
224 QString l = RbSettings::value(RbSettings::Language).toString();
225 if(l.isEmpty())
226 l = QLocale::system().name();
227 while (i != lang.constEnd()) {
228 if(i.value() == l) {
229 b = i.key();
230 break;
232 else if(l.startsWith(i.value(), Qt::CaseInsensitive)) {
233 // check if there is a base language (en -> en_US, etc.)
234 b = i.key();
235 break;
237 i++;
239 a = ui.listLanguages->findItems(b, Qt::MatchExactly);
240 if(a.size() > 0)
241 ui.listLanguages->setCurrentItem(a.at(0));
242 // don't connect before language list has been set up to prevent
243 // triggering the signal by selecting the saved language.
244 connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage()));
246 // devices tab
247 ui.mountPoint->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::Mountpoint).toString()));
249 // cache tab
250 if(!QFileInfo(RbSettings::value(RbSettings::CachePath).toString()).isDir())
251 RbSettings::setValue(RbSettings::CachePath, QDir::tempPath());
252 ui.cachePath->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::CachePath).toString()));
253 ui.cacheDisable->setChecked(RbSettings::value(RbSettings::CacheDisabled).toBool());
254 ui.cacheOfflineMode->setChecked(RbSettings::value(RbSettings::CacheOffline).toBool());
255 updateCacheInfo(RbSettings::value(RbSettings::CachePath).toString());
259 void Config::updateCacheInfo(QString path)
261 QList<QFileInfo> fs;
262 fs = QDir(path + "/rbutil-cache/").entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
263 qint64 sz = 0;
264 for(int i = 0; i < fs.size(); i++) {
265 sz += fs.at(i).size();
267 ui.cacheSize->setText(tr("Current cache size is %L1 kiB.")
268 .arg(sz/1024));
272 void Config::setDevices()
275 // setup devices table
276 qDebug() << "[Config] setting up devices list";
278 QStringList platformList = RbSettings::platforms();
280 QMap <QString, QString> manuf;
281 QMap <QString, QString> devcs;
282 for(int it = 0; it < platformList.size(); it++)
284 QString curname = RbSettings::name(platformList.at(it));
285 QString curbrand = RbSettings::brand(platformList.at(it));
286 manuf.insertMulti(curbrand, platformList.at(it));
287 devcs.insert(platformList.at(it), curname);
290 QString platform;
291 platform = devcs.value(RbSettings::value(RbSettings::Platform).toString());
293 // set up devices table
294 ui.treeDevices->header()->hide();
295 ui.treeDevices->expandAll();
296 ui.treeDevices->setColumnCount(1);
297 QList<QTreeWidgetItem *> items;
299 // get manufacturers
300 QStringList brands = manuf.uniqueKeys();
301 QTreeWidgetItem *w;
302 QTreeWidgetItem *w2;
303 QTreeWidgetItem *w3 = 0;
304 for(int c = 0; c < brands.size(); c++) {
305 w = new QTreeWidgetItem();
306 w->setFlags(Qt::ItemIsEnabled);
307 w->setText(0, brands.at(c));
308 items.append(w);
310 // go through platforms again for sake of order
311 for(int it = 0; it < platformList.size(); it++) {
313 QString curname = RbSettings::name(platformList.at(it));
314 QString curbrand = RbSettings::brand(platformList.at(it));
316 if(curbrand != brands.at(c)) continue;
317 qDebug() << "[Config] add supported device:" << brands.at(c) << curname;
318 w2 = new QTreeWidgetItem(w, QStringList(curname));
319 w2->setData(0, Qt::UserRole, platformList.at(it));
321 if(platform.contains(curname)) {
322 w2->setSelected(true);
323 w->setExpanded(true);
324 w3 = w2; // save pointer to hilight old selection
326 items.append(w2);
329 ui.treeDevices->insertTopLevelItems(0, items);
330 if(w3 != 0)
331 ui.treeDevices->setCurrentItem(w3); // hilight old selection
333 // tts / encoder tab
335 //encoders
336 updateEncState();
338 //tts
339 QStringList ttslist = TTSBase::getTTSList();
340 for(int a = 0; a < ttslist.size(); a++)
341 ui.comboTts->addItem(TTSBase::getTTSName(ttslist.at(a)), ttslist.at(a));
342 //update index of combobox
343 int index = ui.comboTts->findData(RbSettings::value(RbSettings::Tts).toString());
344 if(index < 0) index = 0;
345 ui.comboTts->setCurrentIndex(index);
346 updateTtsState(index);
351 void Config::updateTtsState(int index)
353 QString ttsName = ui.comboTts->itemData(index).toString();
354 TTSBase* tts = TTSBase::getTTS(this,ttsName);
356 if(tts->configOk())
358 ui.configTTSstatus->setText(tr("Configuration OK"));
359 ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
361 else
363 ui.configTTSstatus->setText(tr("Configuration INVALID"));
364 ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
368 void Config::updateEncState()
370 if(ui.treeDevices->selectedItems().size() == 0)
371 return;
373 QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
374 QString encoder = RbSettings::platformValue(devname,
375 RbSettings::CurEncoder).toString();
376 ui.encoderName->setText(EncBase::getEncoderName(RbSettings::platformValue(devname,
377 RbSettings::CurEncoder).toString()));
379 EncBase* enc = EncBase::getEncoder(this,encoder);
381 if(enc->configOk())
383 ui.configEncstatus->setText(tr("Configuration OK"));
384 ui.configEncstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
386 else
388 ui.configEncstatus->setText(tr("Configuration INVALID"));
389 ui.configEncstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
394 void Config::setNoProxy(bool checked)
396 bool i = !checked;
397 ui.proxyPort->setEnabled(i);
398 ui.proxyHost->setEnabled(i);
399 ui.proxyUser->setEnabled(i);
400 ui.proxyPass->setEnabled(i);
404 void Config::setSystemProxy(bool checked)
406 bool i = !checked;
407 ui.proxyPort->setEnabled(i);
408 ui.proxyHost->setEnabled(i);
409 ui.proxyUser->setEnabled(i);
410 ui.proxyPass->setEnabled(i);
411 if(checked) {
412 // save values in input box
413 proxy.setScheme("http");
414 proxy.setUserName(ui.proxyUser->text());
415 proxy.setPassword(ui.proxyPass->text());
416 proxy.setHost(ui.proxyHost->text());
417 proxy.setPort(ui.proxyPort->text().toInt());
418 // show system values in input box
419 QUrl envproxy = System::systemProxy();
421 ui.proxyHost->setText(envproxy.host());
423 ui.proxyPort->setText(QString("%1").arg(envproxy.port()));
424 ui.proxyUser->setText(envproxy.userName());
425 ui.proxyPass->setText(envproxy.password());
428 else {
429 ui.proxyHost->setText(proxy.host());
430 if(proxy.port() > 0)
431 ui.proxyPort->setText(QString("%1").arg(proxy.port()));
432 else ui.proxyPort->setText("");
433 ui.proxyUser->setText(proxy.userName());
434 ui.proxyPass->setText(proxy.password());
440 QStringList Config::findLanguageFiles()
442 QDir dir(programPath);
443 QStringList fileNames;
444 QStringList langs;
445 fileNames = dir.entryList(QStringList("*.qm"), QDir::Files, QDir::Name);
447 QDir resDir(":/lang");
448 fileNames += resDir.entryList(QStringList("*.qm"), QDir::Files, QDir::Name);
450 QRegExp exp("^rbutil_(.*)\\.qm");
451 for(int i = 0; i < fileNames.size(); i++) {
452 QString a = fileNames.at(i);
453 a.replace(exp, "\\1");
454 langs.append(a);
456 langs.sort();
457 qDebug() << "[Config] available lang files:" << langs;
459 return langs;
463 QString Config::languageName(const QString &qmFile)
465 QTranslator translator;
467 QString file = "rbutil_" + qmFile;
468 if(!translator.load(file, programPath))
469 translator.load(file, ":/lang");
471 return translator.translate("Configure", "English",
472 "This is the localized language name, i.e. your language.");
476 void Config::updateLanguage()
478 qDebug() << "[Config] update selected language";
479 QList<QListWidgetItem*> a = ui.listLanguages->selectedItems();
480 if(a.size() > 0)
481 language = lang.value(a.at(0)->text());
482 qDebug() << "[Config] new language:" << language;
486 void Config::browseFolder()
488 browser = new BrowseDirtree(this,tr("Select your device"));
489 #if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
490 browser->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
491 #elif defined(Q_OS_WIN32)
492 browser->setFilter(QDir::Drives);
493 #endif
494 #if defined(Q_OS_MACX)
495 browser->setRoot("/Volumes");
496 #elif defined(Q_OS_LINUX)
497 browser->setDir("/media");
498 #endif
499 if( ui.mountPoint->text() != "" )
501 browser->setDir(ui.mountPoint->text());
503 browser->show();
504 connect(browser, SIGNAL(itemChanged(QString)), this, SLOT(setMountpoint(QString)));
508 void Config::browseCache()
510 cbrowser = new BrowseDirtree(this);
511 #if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
512 cbrowser->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
513 #elif defined(Q_OS_WIN32)
514 cbrowser->setFilter(QDir::Drives | QDir::AllDirs | QDir::NoDotAndDotDot);
515 #endif
516 cbrowser->setDir(ui.cachePath->text());
517 connect(cbrowser, SIGNAL(itemChanged(QString)), this, SLOT(setCache(QString)));
518 cbrowser->show();
523 void Config::setMountpoint(QString m)
525 ui.mountPoint->setText(m);
529 void Config::setCache(QString c)
531 ui.cachePath->setText(c);
532 updateCacheInfo(c);
536 void Config::autodetect()
538 Autodetection detector(this);
539 // disable tree during detection as "working" feedback.
540 // TODO: replace the tree view with a splash screen during this time.
541 ui.treeDevices->setEnabled(false);
542 this->setCursor(Qt::WaitCursor);
543 QCoreApplication::processEvents();
545 if(detector.detect()) //let it detect
547 QString devicename = detector.getDevice();
548 // deexpand all items
549 for(int a = 0; a < ui.treeDevices->topLevelItemCount(); a++)
550 ui.treeDevices->topLevelItem(a)->setExpanded(false);
551 //deselect the selected item(s)
552 for(int a = 0; a < ui.treeDevices->selectedItems().size(); a++)
553 ui.treeDevices->selectedItems().at(a)->setSelected(false);
555 // find the new item
556 // enumerate all platform items
557 QList<QTreeWidgetItem*> itmList= ui.treeDevices->findItems("*",Qt::MatchWildcard);
558 for(int i=0; i< itmList.size();i++)
560 //enumerate device items
561 for(int j=0;j < itmList.at(i)->childCount();j++)
563 QString data = itmList.at(i)->child(j)->data(0, Qt::UserRole).toString();
565 if(devicename == data) // item found
567 itmList.at(i)->child(j)->setSelected(true); //select the item
568 itmList.at(i)->setExpanded(true); //expand the platform item
569 //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
570 break;
574 this->unsetCursor();
576 if(!detector.errdev().isEmpty()) {
577 QString text;
578 if(detector.errdev() == "sansae200")
579 text = tr("Sansa e200 in MTP mode found!\n"
580 "You need to change your player to MSC mode for installation. ");
581 if(detector.errdev() == "h10")
582 text = tr("H10 20GB in MTP mode found!\n"
583 "You need to change your player to UMS mode for installation. ");
584 text += tr("Unless you changed this installation will fail!");
586 QMessageBox::critical(this, tr("Fatal error"), text, QMessageBox::Ok);
587 return;
589 if(!detector.incompatdev().isEmpty()) {
590 QString text;
591 text = tr("Detected an unsupported player:\n%1\n"
592 "Sorry, Rockbox doesn't run on your player.")
593 .arg(RbSettings::platformValue(detector.incompatdev(),
594 RbSettings::CurName).toString());
596 QMessageBox::critical(this, tr("Fatal: player incompatible"),
597 text, QMessageBox::Ok);
598 return;
601 if(detector.getMountPoint() != "" )
603 ui.mountPoint->setText(QDir::toNativeSeparators(detector.getMountPoint()));
605 else
607 QMessageBox::warning(this, tr("Autodetection"),
608 tr("Could not detect a Mountpoint.\n"
609 "Select your Mountpoint manually."),
610 QMessageBox::Ok ,QMessageBox::Ok);
613 else
615 this->unsetCursor();
616 QMessageBox::warning(this, tr("Autodetection"),
617 tr("Could not detect a device.\n"
618 "Select your device and Mountpoint manually."),
619 QMessageBox::Ok ,QMessageBox::Ok);
622 ui.treeDevices->setEnabled(true);
626 void Config::cacheClear()
628 if(QMessageBox::critical(this, tr("Really delete cache?"),
629 tr("Do you really want to delete the cache? "
630 "Make absolutely sure this setting is correct as it will "
631 "remove <b>all</b> files in this folder!").arg(ui.cachePath->text()),
632 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
633 return;
635 QString cache = ui.cachePath->text() + "/rbutil-cache/";
636 if(!QFileInfo(cache).isDir()) {
637 QMessageBox::critical(this, tr("Path wrong!"),
638 tr("The cache path is invalid. Aborting."), QMessageBox::Ok);
639 return;
641 QDir dir(cache);
642 QStringList fn;
643 fn = dir.entryList(QStringList("*"), QDir::Files, QDir::Name);
645 for(int i = 0; i < fn.size(); i++) {
646 QString f = cache + fn.at(i);
647 QFile::remove(f);
649 updateCacheInfo(RbSettings::value(RbSettings::CachePath).toString());
653 void Config::configTts()
655 int index = ui.comboTts->currentIndex();
656 TTSBase* tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString());
658 EncTtsCfgGui gui(this,tts,TTSBase::getTTSName(ui.comboTts->itemData(index).toString()));
659 gui.exec();
660 updateTtsState(ui.comboTts->currentIndex());
663 void Config::testTts()
665 QString errstr;
666 int index = ui.comboTts->currentIndex();
667 TTSBase* tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString());
668 if(!tts->configOk())
670 QMessageBox::warning(this,tr("TTS configuration invalid"),
671 tr("TTS configuration invalid. \n Please configure TTS engine."));
672 return;
675 if(!tts->start(&errstr))
677 QMessageBox::warning(this,tr("Could not start TTS engine"),
678 tr("Could not start TTS engine.\n") + errstr
679 + tr("\nPlease configure TTS engine."));
680 return;
683 QTemporaryFile file(this);
684 file.open();
685 QString filename = file.fileName();
686 file.close();
688 if(tts->voice(tr("Rockbox Utility Voice Test"),filename,&errstr) == FatalError)
690 tts->stop();
691 QMessageBox::warning(this,tr("Could not voice test string"),
692 tr("Could not voice test string.\n") + errstr
693 + tr("\nPlease configure TTS engine."));
694 return;
696 tts->stop();
697 #if defined(Q_OS_LINUX)
698 QString exe = findExecutable("aplay");
699 if(exe == "") exe = findExecutable("play");
700 if(exe != "")
702 QProcess::execute(exe+" "+filename);
704 #else
705 QSound::play(filename);
706 #endif
709 void Config::configEnc()
711 if(ui.treeDevices->selectedItems().size() == 0)
712 return;
714 QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
715 QString encoder = RbSettings::platformValue(devname,
716 RbSettings::CurEncoder).toString();
717 ui.encoderName->setText(EncBase::getEncoderName(RbSettings::platformValue(devname,
718 RbSettings::CurEncoder).toString()));
721 EncBase* enc = EncBase::getEncoder(this,encoder);
723 EncTtsCfgGui gui(this,enc,EncBase::getEncoderName(encoder));
724 gui.exec();
726 updateEncState();