1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Riebeling
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 ****************************************************************************/
23 #include "configure.h"
24 #include "autodetection.h"
25 #include "ui_configurefrm.h"
26 #include "browsedirtree.h"
30 #include "encttscfggui.h"
31 #include "rbsettings.h"
32 #include "serverinfo.h"
33 #include "systeminfo.h"
36 #if defined(Q_OS_WIN32)
44 #define DEFAULT_LANG "English (en)"
45 #define DEFAULT_LANG_CODE "en"
47 Config::Config(QWidget
*parent
,int index
) : QDialog(parent
)
49 programPath
= qApp
->applicationDirPath() + "/";
51 ui
.tabConfiguration
->setCurrentIndex(index
);
52 ui
.radioManualProxy
->setChecked(true);
53 QRegExpValidator
*proxyValidator
= new QRegExpValidator(this);
54 QRegExp
validate("[0-9]*");
55 proxyValidator
->setRegExp(validate
);
56 ui
.proxyPort
->setValidator(proxyValidator
);
57 #if !defined(Q_OS_LINUX) && !defined(Q_OS_WIN32)
58 ui
.radioSystemProxy
->setEnabled(false); // not on macox for now
60 // build language list and sort alphabetically
61 QStringList langs
= findLanguageFiles();
62 for(int i
= 0; i
< langs
.size(); ++i
)
63 lang
.insert(languageName(langs
.at(i
))
64 + QString(" (%1)").arg(langs
.at(i
)), langs
.at(i
));
65 lang
.insert(DEFAULT_LANG
, DEFAULT_LANG_CODE
);
66 QMap
<QString
, QString
>::const_iterator i
= lang
.constBegin();
67 while (i
!= lang
.constEnd()) {
68 ui
.listLanguages
->addItem(i
.key());
71 ui
.listLanguages
->setSelectionMode(QAbstractItemView::SingleSelection
);
72 ui
.proxyPass
->setEchoMode(QLineEdit::Password
);
73 ui
.treeDevices
->setAlternatingRowColors(true);
74 ui
.listLanguages
->setAlternatingRowColors(true);
76 /* Explicitly set some widgets to have left-to-right layout */
77 ui
.treeDevices
->setLayoutDirection(Qt::LeftToRight
);
78 ui
.mountPoint
->setLayoutDirection(Qt::LeftToRight
);
79 ui
.proxyHost
->setLayoutDirection(Qt::LeftToRight
);
80 ui
.proxyPort
->setLayoutDirection(Qt::LeftToRight
);
81 ui
.proxyUser
->setLayoutDirection(Qt::LeftToRight
);
82 ui
.proxyPass
->setLayoutDirection(Qt::LeftToRight
);
83 ui
.listLanguages
->setLayoutDirection(Qt::LeftToRight
);
84 ui
.cachePath
->setLayoutDirection(Qt::LeftToRight
);
85 ui
.comboTts
->setLayoutDirection(Qt::LeftToRight
);
89 connect(ui
.buttonOk
, SIGNAL(clicked()), this, SLOT(accept()));
90 connect(ui
.buttonCancel
, SIGNAL(clicked()), this, SLOT(abort()));
91 connect(ui
.radioNoProxy
, SIGNAL(toggled(bool)), this, SLOT(setNoProxy(bool)));
92 connect(ui
.radioSystemProxy
, SIGNAL(toggled(bool)), this, SLOT(setSystemProxy(bool)));
93 connect(ui
.browseMountPoint
, SIGNAL(clicked()), this, SLOT(browseFolder()));
94 connect(ui
.buttonAutodetect
,SIGNAL(clicked()),this,SLOT(autodetect()));
95 connect(ui
.buttonCacheBrowse
, SIGNAL(clicked()), this, SLOT(browseCache()));
96 connect(ui
.buttonCacheClear
, SIGNAL(clicked()), this, SLOT(cacheClear()));
97 connect(ui
.configTts
, SIGNAL(clicked()), this, SLOT(configTts()));
98 connect(ui
.configEncoder
, SIGNAL(clicked()), this, SLOT(configEnc()));
99 connect(ui
.comboTts
, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsState(int)));
100 connect(ui
.treeDevices
, SIGNAL(itemSelectionChanged()), this, SLOT(updateEncState()));
101 connect(ui
.testTTS
,SIGNAL(clicked()),this,SLOT(testTts()));
102 connect(ui
.showDisabled
, SIGNAL(toggled(bool)), this, SLOT(showDisabled(bool)));
108 void Config::accept()
110 qDebug() << "[Config] checking configuration";
111 QString errormsg
= tr("The following errors occurred:") + "<ul>";
114 // proxy: save entered proxy values, not displayed.
115 if(ui
.radioManualProxy
->isChecked()) {
116 proxy
.setScheme("http");
117 proxy
.setUserName(ui
.proxyUser
->text());
118 proxy
.setPassword(ui
.proxyPass
->text());
119 proxy
.setHost(ui
.proxyHost
->text());
120 proxy
.setPort(ui
.proxyPort
->text().toInt());
123 RbSettings::setValue(RbSettings::Proxy
, proxy
.toString());
124 qDebug() << "[Config] setting proxy to:" << proxy
;
127 if(ui
.radioNoProxy
->isChecked()) proxyType
= "none";
128 else if(ui
.radioSystemProxy
->isChecked()) proxyType
= "system";
129 else proxyType
= "manual";
130 RbSettings::setValue(RbSettings::ProxyType
, proxyType
);
133 if(RbSettings::value(RbSettings::Language
).toString() != language
134 && !language
.isEmpty()) {
135 QMessageBox::information(this, tr("Language changed"),
136 tr("You need to restart the application for the changed language to take effect."));
137 RbSettings::setValue(RbSettings::Language
, language
);
141 QString mp
= ui
.mountPoint
->text();
143 errormsg
+= "<li>" + tr("No mountpoint given") + "</li>";
146 else if(!QFileInfo(mp
).exists()) {
147 errormsg
+= "<li>" + tr("Mountpoint does not exist") + "</li>";
150 else if(!QFileInfo(mp
).isDir()) {
151 errormsg
+= "<li>" + tr("Mountpoint is not a directory.") + "</li>";
154 else if(!QFileInfo(mp
).isWritable()) {
155 errormsg
+= "<li>" + tr("Mountpoint is not writeable") + "</li>";
159 RbSettings::setValue(RbSettings::Mountpoint
, QDir::fromNativeSeparators(mp
));
164 if(ui
.treeDevices
->selectedItems().size() != 0) {
165 nplat
= ui
.treeDevices
->selectedItems().at(0)->data(0, Qt::UserRole
).toString();
166 RbSettings::setValue(RbSettings::Platform
, nplat
);
169 errormsg
+= "<li>" + tr("No player selected") + "</li>";
174 if(QFileInfo(ui
.cachePath
->text()).isDir()) {
175 if(!QFileInfo(ui
.cachePath
->text()).isWritable()) {
176 errormsg
+= "<li>" + tr("Cache path not writeable. Leave path empty "
177 "to default to systems temporary path.") + "</li>";
181 RbSettings::setValue(RbSettings::CachePath
, ui
.cachePath
->text());
183 else // default to system temp path
184 RbSettings::setValue(RbSettings::CachePath
, QDir::tempPath());
185 RbSettings::setValue(RbSettings::CacheDisabled
, ui
.cacheDisable
->isChecked());
186 RbSettings::setValue(RbSettings::CacheOffline
, ui
.cacheOfflineMode
->isChecked());
189 int i
= ui
.comboTts
->currentIndex();
190 RbSettings::setValue(RbSettings::Tts
, ui
.comboTts
->itemData(i
).toString());
192 RbSettings::setValue(RbSettings::RbutilVersion
, PUREVERSION
);
195 errormsg
+= tr("You need to fix the above errors before you can continue.");
198 QMessageBox::critical(this, tr("Configuration error"), errormsg
);
204 emit
settingsUpdated();
211 qDebug() << "[Config] aborted.";
216 void Config::setUserSettings()
219 proxy
= RbSettings::value(RbSettings::Proxy
).toString();
222 ui
.proxyPort
->setText(QString("%1").arg(proxy
.port()));
223 else ui
.proxyPort
->setText("");
224 ui
.proxyHost
->setText(proxy
.host());
225 ui
.proxyUser
->setText(proxy
.userName());
226 ui
.proxyPass
->setText(proxy
.password());
228 QString proxyType
= RbSettings::value(RbSettings::ProxyType
).toString();
229 if(proxyType
== "manual") ui
.radioManualProxy
->setChecked(true);
230 else if(proxyType
== "system") ui
.radioSystemProxy
->setChecked(true);
231 else ui
.radioNoProxy
->setChecked(true);
233 // set language selection
234 QList
<QListWidgetItem
*> a
;
236 // find key for lang value
237 QMap
<QString
, QString
>::const_iterator i
= lang
.constBegin();
238 QString l
= RbSettings::value(RbSettings::Language
).toString();
240 l
= QLocale::system().name();
241 while (i
!= lang
.constEnd()) {
246 else if(l
.startsWith(i
.value(), Qt::CaseInsensitive
)) {
247 // check if there is a base language (en -> en_US, etc.)
253 a
= ui
.listLanguages
->findItems(b
, Qt::MatchExactly
);
255 ui
.listLanguages
->setCurrentItem(a
.at(0));
256 // don't connect before language list has been set up to prevent
257 // triggering the signal by selecting the saved language.
258 connect(ui
.listLanguages
, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage()));
261 ui
.mountPoint
->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::Mountpoint
).toString()));
264 if(!QFileInfo(RbSettings::value(RbSettings::CachePath
).toString()).isDir())
265 RbSettings::setValue(RbSettings::CachePath
, QDir::tempPath());
266 ui
.cachePath
->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::CachePath
).toString()));
267 ui
.cacheDisable
->setChecked(RbSettings::value(RbSettings::CacheDisabled
).toBool());
268 ui
.cacheOfflineMode
->setChecked(RbSettings::value(RbSettings::CacheOffline
).toBool());
269 updateCacheInfo(RbSettings::value(RbSettings::CachePath
).toString());
273 void Config::updateCacheInfo(QString path
)
276 fs
= QDir(path
+ "/rbutil-cache/").entryInfoList(QDir::Files
| QDir::NoDotAndDotDot
);
278 for(int i
= 0; i
< fs
.size(); i
++) {
279 sz
+= fs
.at(i
).size();
281 ui
.cacheSize
->setText(tr("Current cache size is %L1 kiB.")
286 void Config::showDisabled(bool show
)
288 qDebug() << "[Config] disabled targets shown:" << show
;
290 QMessageBox::warning(this, tr("Showing disabled targets"),
291 tr("You just enabled showing targets that are marked disabled. "
292 "Disabled targets are not recommended to end users. Please "
293 "use this option only if you know what you are doing."));
299 void Config::setDevices()
302 // setup devices table
303 qDebug() << "[Config] setting up devices list";
305 QStringList platformList
;
306 if(ui
.showDisabled
->isChecked())
307 platformList
= SystemInfo::platforms(SystemInfo::PlatformAllDisabled
);
309 platformList
= SystemInfo::platforms(SystemInfo::PlatformAll
);
311 QMap
<QString
, QString
> manuf
;
312 for(int it
= 0; it
< platformList
.size(); it
++)
314 QString curbrand
= SystemInfo::platformValue(platformList
.at(it
),
315 SystemInfo::CurBrand
).toString();
316 manuf
.insertMulti(curbrand
, platformList
.at(it
));
319 // set up devices table
320 ui
.treeDevices
->header()->hide();
321 ui
.treeDevices
->expandAll();
322 ui
.treeDevices
->setColumnCount(1);
323 QList
<QTreeWidgetItem
*> items
;
326 QStringList brands
= manuf
.uniqueKeys();
329 QTreeWidgetItem
*w3
= 0;
331 QString selected
= RbSettings::value(RbSettings::Platform
).toString();
332 for(int c
= 0; c
< brands
.size(); c
++) {
333 w
= new QTreeWidgetItem();
334 w
->setFlags(Qt::ItemIsEnabled
);
335 w
->setText(0, brands
.at(c
));
337 // go through platforms and add all players matching the current brand
338 for(int it
= 0; it
< platformList
.size(); it
++) {
339 // skip if not current brand
340 if(!manuf
.values(brands
.at(c
)).contains(platformList
.at(it
)))
342 // construct display name
343 QString curname
= SystemInfo::platformValue(platformList
.at(it
),
344 SystemInfo::CurName
).toString() +
345 " (" +ServerInfo::platformValue(platformList
.at(it
),
346 ServerInfo::CurStatus
).toString() +")";
347 qDebug() << "[Config] add supported device:" << brands
.at(c
) << curname
;
348 w2
= new QTreeWidgetItem(w
, QStringList(curname
));
349 w2
->setData(0, Qt::UserRole
, platformList
.at(it
));
351 if(platformList
.at(it
) == selected
) {
352 w2
->setSelected(true);
353 w
->setExpanded(true);
354 w3
= w2
; // save pointer to hilight old selection
359 // remove any old items in list
360 QTreeWidgetItem
* widgetitem
;
362 widgetitem
= ui
.treeDevices
->takeTopLevelItem(0);
367 ui
.treeDevices
->insertTopLevelItems(0, items
);
369 ui
.treeDevices
->setCurrentItem(w3
); // hilight old selection
370 ui
.treeDevices
->scrollToItem(w3
);
379 QStringList ttslist
= TTSBase::getTTSList();
380 for(int a
= 0; a
< ttslist
.size(); a
++)
381 ui
.comboTts
->addItem(TTSBase::getTTSName(ttslist
.at(a
)), ttslist
.at(a
));
382 //update index of combobox
383 int index
= ui
.comboTts
->findData(RbSettings::value(RbSettings::Tts
).toString());
384 if(index
< 0) index
= 0;
385 ui
.comboTts
->setCurrentIndex(index
);
386 updateTtsState(index
);
391 void Config::updateTtsState(int index
)
393 QString ttsName
= ui
.comboTts
->itemData(index
).toString();
394 TTSBase
* tts
= TTSBase::getTTS(this,ttsName
);
398 ui
.configTTSstatus
->setText(tr("Configuration OK"));
399 ui
.configTTSstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
403 ui
.configTTSstatus
->setText(tr("Configuration INVALID"));
404 ui
.configTTSstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
408 void Config::updateEncState()
410 if(ui
.treeDevices
->selectedItems().size() == 0)
413 QString devname
= ui
.treeDevices
->selectedItems().at(0)->data(0, Qt::UserRole
).toString();
414 QString encoder
= SystemInfo::platformValue(devname
,
415 SystemInfo::CurEncoder
).toString();
416 ui
.encoderName
->setText(EncBase::getEncoderName(SystemInfo::platformValue(devname
,
417 SystemInfo::CurEncoder
).toString()));
419 EncBase
* enc
= EncBase::getEncoder(this,encoder
);
423 ui
.configEncstatus
->setText(tr("Configuration OK"));
424 ui
.configEncstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
428 ui
.configEncstatus
->setText(tr("Configuration INVALID"));
429 ui
.configEncstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
434 void Config::setNoProxy(bool checked
)
437 ui
.proxyPort
->setEnabled(i
);
438 ui
.proxyHost
->setEnabled(i
);
439 ui
.proxyUser
->setEnabled(i
);
440 ui
.proxyPass
->setEnabled(i
);
444 void Config::setSystemProxy(bool checked
)
447 ui
.proxyPort
->setEnabled(i
);
448 ui
.proxyHost
->setEnabled(i
);
449 ui
.proxyUser
->setEnabled(i
);
450 ui
.proxyPass
->setEnabled(i
);
452 // save values in input box
453 proxy
.setScheme("http");
454 proxy
.setUserName(ui
.proxyUser
->text());
455 proxy
.setPassword(ui
.proxyPass
->text());
456 proxy
.setHost(ui
.proxyHost
->text());
457 proxy
.setPort(ui
.proxyPort
->text().toInt());
458 // show system values in input box
459 QUrl envproxy
= System::systemProxy();
461 ui
.proxyHost
->setText(envproxy
.host());
463 ui
.proxyPort
->setText(QString("%1").arg(envproxy
.port()));
464 ui
.proxyUser
->setText(envproxy
.userName());
465 ui
.proxyPass
->setText(envproxy
.password());
469 ui
.proxyHost
->setText(proxy
.host());
471 ui
.proxyPort
->setText(QString("%1").arg(proxy
.port()));
472 else ui
.proxyPort
->setText("");
473 ui
.proxyUser
->setText(proxy
.userName());
474 ui
.proxyPass
->setText(proxy
.password());
480 QStringList
Config::findLanguageFiles()
482 QDir
dir(programPath
);
483 QStringList fileNames
;
485 fileNames
= dir
.entryList(QStringList("*.qm"), QDir::Files
, QDir::Name
);
487 QDir
resDir(":/lang");
488 fileNames
+= resDir
.entryList(QStringList("*.qm"), QDir::Files
, QDir::Name
);
490 QRegExp
exp("^rbutil_(.*)\\.qm");
491 for(int i
= 0; i
< fileNames
.size(); i
++) {
492 QString a
= fileNames
.at(i
);
493 a
.replace(exp
, "\\1");
497 qDebug() << "[Config] available lang files:" << langs
;
503 QString
Config::languageName(const QString
&qmFile
)
505 QTranslator translator
;
507 QString file
= "rbutil_" + qmFile
;
508 if(!translator
.load(file
, programPath
))
509 translator
.load(file
, ":/lang");
511 return translator
.translate("Configure", "English",
512 "This is the localized language name, i.e. your language.");
516 void Config::updateLanguage()
518 qDebug() << "[Config] update selected language";
519 QList
<QListWidgetItem
*> a
= ui
.listLanguages
->selectedItems();
521 language
= lang
.value(a
.at(0)->text());
522 qDebug() << "[Config] new language:" << language
;
526 void Config::browseFolder()
528 browser
= new BrowseDirtree(this,tr("Select your device"));
529 #if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
530 browser
->setFilter(QDir::AllDirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
);
531 #elif defined(Q_OS_WIN32)
532 browser
->setFilter(QDir::Drives
);
534 #if defined(Q_OS_MACX)
535 browser
->setRoot("/Volumes");
536 #elif defined(Q_OS_LINUX)
537 browser
->setDir("/media");
539 if( ui
.mountPoint
->text() != "" )
541 browser
->setDir(ui
.mountPoint
->text());
544 connect(browser
, SIGNAL(itemChanged(QString
)), this, SLOT(setMountpoint(QString
)));
548 void Config::browseCache()
550 QString old
= ui
.cachePath
->text();
551 if(!QFileInfo(old
).isDir())
552 old
= QDir::tempPath();
553 QString c
= QFileDialog::getExistingDirectory(this, tr("Set Cache Path"), old
);
556 else if(!QFileInfo(c
).isDir())
557 c
= QDir::tempPath();
558 ui
.cachePath
->setText(QDir::toNativeSeparators(c
));
563 void Config::setMountpoint(QString m
)
565 ui
.mountPoint
->setText(m
);
569 void Config::autodetect()
571 Autodetection
detector(this);
572 // disable tree during detection as "working" feedback.
573 // TODO: replace the tree view with a splash screen during this time.
574 ui
.treeDevices
->setEnabled(false);
575 this->setCursor(Qt::WaitCursor
);
576 QCoreApplication::processEvents();
578 if(detector
.detect()) //let it detect
580 QString devicename
= detector
.getDevice();
581 // deexpand all items
582 for(int a
= 0; a
< ui
.treeDevices
->topLevelItemCount(); a
++)
583 ui
.treeDevices
->topLevelItem(a
)->setExpanded(false);
584 //deselect the selected item(s)
585 for(int a
= 0; a
< ui
.treeDevices
->selectedItems().size(); a
++)
586 ui
.treeDevices
->selectedItems().at(a
)->setSelected(false);
589 // enumerate all platform items
590 QList
<QTreeWidgetItem
*> itmList
591 = ui
.treeDevices
->findItems("*",Qt::MatchWildcard
);
592 for(int i
=0; i
< itmList
.size();i
++)
594 //enumerate device items
595 for(int j
=0;j
< itmList
.at(i
)->childCount();j
++)
597 QString data
= itmList
.at(i
)->child(j
)->data(0, Qt::UserRole
).toString();
599 if(devicename
== data
) // item found
601 itmList
.at(i
)->child(j
)->setSelected(true); //select the item
602 itmList
.at(i
)->setExpanded(true); //expand the platform item
603 //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
604 ui
.treeDevices
->scrollToItem(itmList
.at(i
)->child(j
));
611 if(!detector
.errdev().isEmpty()) {
613 if(detector
.errdev() == "sansae200")
614 text
= tr("Sansa e200 in MTP mode found!\n"
615 "You need to change your player to MSC mode for installation. ");
616 if(detector
.errdev() == "h10")
617 text
= tr("H10 20GB in MTP mode found!\n"
618 "You need to change your player to UMS mode for installation. ");
619 if(SystemInfo::platformValue(detector
.errdev(),
620 SystemInfo::CurBootloaderMethod
) == "ipod")
621 text
= tr("%1 \"MacPod\" found!\n"
622 "Rockbox needs a FAT formatted Ipod (so-called \"WinPod\") "
623 "to run. ").arg(SystemInfo::platformValue(
624 detector
.errdev(), SystemInfo::CurName
).toString());
625 text
+= tr("Unless you changed this installation will fail!");
627 QMessageBox::critical(this, tr("Fatal error"), text
, QMessageBox::Ok
);
630 if(!detector
.incompatdev().isEmpty()) {
632 text
= tr("Detected an unsupported player:\n%1\n"
633 "Sorry, Rockbox doesn't run on your player.")
634 .arg(SystemInfo::platformValue(detector
.incompatdev(),
635 SystemInfo::CurName
).toString());
637 QMessageBox::critical(this, tr("Fatal: player incompatible"),
638 text
, QMessageBox::Ok
);
642 if(detector
.getMountPoint() != "" )
644 ui
.mountPoint
->setText(QDir::toNativeSeparators(detector
.getMountPoint()));
648 QMessageBox::warning(this, tr("Autodetection"),
649 tr("Could not detect a Mountpoint.\n"
650 "Select your Mountpoint manually."),
651 QMessageBox::Ok
,QMessageBox::Ok
);
657 QMessageBox::warning(this, tr("Autodetection"),
658 tr("Could not detect a device.\n"
659 "Select your device and Mountpoint manually."),
660 QMessageBox::Ok
,QMessageBox::Ok
);
663 ui
.treeDevices
->setEnabled(true);
667 void Config::cacheClear()
669 if(QMessageBox::critical(this, tr("Really delete cache?"),
670 tr("Do you really want to delete the cache? "
671 "Make absolutely sure this setting is correct as it will "
672 "remove <b>all</b> files in this folder!").arg(ui
.cachePath
->text()),
673 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
676 QString cache
= ui
.cachePath
->text() + "/rbutil-cache/";
677 if(!QFileInfo(cache
).isDir()) {
678 QMessageBox::critical(this, tr("Path wrong!"),
679 tr("The cache path is invalid. Aborting."), QMessageBox::Ok
);
684 fn
= dir
.entryList(QStringList("*"), QDir::Files
, QDir::Name
);
686 for(int i
= 0; i
< fn
.size(); i
++) {
687 QString f
= cache
+ fn
.at(i
);
690 updateCacheInfo(RbSettings::value(RbSettings::CachePath
).toString());
694 void Config::configTts()
696 int index
= ui
.comboTts
->currentIndex();
697 TTSBase
* tts
= TTSBase::getTTS(this,ui
.comboTts
->itemData(index
).toString());
699 EncTtsCfgGui
gui(this,tts
,TTSBase::getTTSName(ui
.comboTts
->itemData(index
).toString()));
701 updateTtsState(ui
.comboTts
->currentIndex());
704 void Config::testTts()
707 int index
= ui
.comboTts
->currentIndex();
708 TTSBase
* tts
= TTSBase::getTTS(this,ui
.comboTts
->itemData(index
).toString());
711 QMessageBox::warning(this,tr("TTS configuration invalid"),
712 tr("TTS configuration invalid. \n Please configure TTS engine."));
716 if(!tts
->start(&errstr
))
718 QMessageBox::warning(this,tr("Could not start TTS engine."),
719 tr("Could not start TTS engine.\n") + errstr
720 + tr("\nPlease configure TTS engine."));
724 QTemporaryFile
file(this);
726 QString filename
= file
.fileName();
729 if(tts
->voice(tr("Rockbox Utility Voice Test"),filename
,&errstr
) == FatalError
)
732 QMessageBox::warning(this,tr("Could not voice test string."),
733 tr("Could not voice test string.\n") + errstr
734 + tr("\nPlease configure TTS engine."));
738 #if defined(Q_OS_LINUX)
739 QString exe
= findExecutable("aplay");
740 if(exe
== "") exe
= findExecutable("play");
743 QProcess::execute(exe
+" "+filename
);
746 QSound::play(filename
);
750 void Config::configEnc()
752 if(ui
.treeDevices
->selectedItems().size() == 0)
755 QString devname
= ui
.treeDevices
->selectedItems().at(0)->data(0, Qt::UserRole
).toString();
756 QString encoder
= SystemInfo::platformValue(devname
,
757 SystemInfo::CurEncoder
).toString();
758 ui
.encoderName
->setText(EncBase::getEncoderName(SystemInfo::platformValue(devname
,
759 SystemInfo::CurEncoder
).toString()));
762 EncBase
* enc
= EncBase::getEncoder(this,encoder
);
764 EncTtsCfgGui
gui(this,enc
,EncBase::getEncoderName(encoder
));