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
);
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());
69 ui
.listLanguages
->setSelectionMode(QAbstractItemView::SingleSelection
);
70 ui
.proxyPass
->setEchoMode(QLineEdit::Password
);
71 ui
.treeDevices
->setAlternatingRowColors(true);
72 ui
.listLanguages
->setAlternatingRowColors(true);
74 /* Explicitly set some widgets to have left-to-right layout */
75 ui
.treeDevices
->setLayoutDirection(Qt::LeftToRight
);
76 ui
.mountPoint
->setLayoutDirection(Qt::LeftToRight
);
77 ui
.proxyHost
->setLayoutDirection(Qt::LeftToRight
);
78 ui
.proxyPort
->setLayoutDirection(Qt::LeftToRight
);
79 ui
.proxyUser
->setLayoutDirection(Qt::LeftToRight
);
80 ui
.proxyPass
->setLayoutDirection(Qt::LeftToRight
);
81 ui
.listLanguages
->setLayoutDirection(Qt::LeftToRight
);
82 ui
.cachePath
->setLayoutDirection(Qt::LeftToRight
);
83 ui
.comboTts
->setLayoutDirection(Qt::LeftToRight
);
87 connect(ui
.buttonOk
, SIGNAL(clicked()), this, SLOT(accept()));
88 connect(ui
.buttonCancel
, SIGNAL(clicked()), this, SLOT(abort()));
89 connect(ui
.radioNoProxy
, SIGNAL(toggled(bool)), this, SLOT(setNoProxy(bool)));
90 connect(ui
.radioSystemProxy
, SIGNAL(toggled(bool)), this, SLOT(setSystemProxy(bool)));
91 connect(ui
.browseMountPoint
, SIGNAL(clicked()), this, SLOT(browseFolder()));
92 connect(ui
.buttonAutodetect
,SIGNAL(clicked()),this,SLOT(autodetect()));
93 connect(ui
.buttonCacheBrowse
, SIGNAL(clicked()), this, SLOT(browseCache()));
94 connect(ui
.buttonCacheClear
, SIGNAL(clicked()), this, SLOT(cacheClear()));
95 connect(ui
.configTts
, SIGNAL(clicked()), this, SLOT(configTts()));
96 connect(ui
.configEncoder
, SIGNAL(clicked()), this, SLOT(configEnc()));
97 connect(ui
.comboTts
, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsState(int)));
98 connect(ui
.treeDevices
, SIGNAL(itemSelectionChanged()), this, SLOT(updateEncState()));
99 connect(ui
.testTTS
,SIGNAL(clicked()),this,SLOT(testTts()));
100 connect(ui
.showDisabled
, SIGNAL(toggled(bool)), this, SLOT(showDisabled(bool)));
106 void Config::accept()
108 qDebug() << "[Config] checking configuration";
109 QString errormsg
= tr("The following errors occurred:") + "<ul>";
112 // proxy: save entered proxy values, not displayed.
113 if(ui
.radioManualProxy
->isChecked()) {
114 proxy
.setScheme("http");
115 proxy
.setUserName(ui
.proxyUser
->text());
116 proxy
.setPassword(ui
.proxyPass
->text());
117 proxy
.setHost(ui
.proxyHost
->text());
118 proxy
.setPort(ui
.proxyPort
->text().toInt());
121 RbSettings::setValue(RbSettings::Proxy
, proxy
.toString());
122 qDebug() << "[Config] setting proxy to:" << proxy
;
125 if(ui
.radioNoProxy
->isChecked()) proxyType
= "none";
126 else if(ui
.radioSystemProxy
->isChecked()) proxyType
= "system";
127 else proxyType
= "manual";
128 RbSettings::setValue(RbSettings::ProxyType
, proxyType
);
131 if(RbSettings::value(RbSettings::Language
).toString() != language
132 && !language
.isEmpty()) {
133 QMessageBox::information(this, tr("Language changed"),
134 tr("You need to restart the application for the changed language to take effect."));
135 RbSettings::setValue(RbSettings::Language
, language
);
139 QString mp
= ui
.mountPoint
->text();
141 errormsg
+= "<li>" + tr("No mountpoint given") + "</li>";
144 else if(!QFileInfo(mp
).exists()) {
145 errormsg
+= "<li>" + tr("Mountpoint does not exist") + "</li>";
148 else if(!QFileInfo(mp
).isDir()) {
149 errormsg
+= "<li>" + tr("Mountpoint is not a directory.") + "</li>";
152 else if(!QFileInfo(mp
).isWritable()) {
153 errormsg
+= "<li>" + tr("Mountpoint is not writeable") + "</li>";
157 RbSettings::setValue(RbSettings::Mountpoint
, QDir::fromNativeSeparators(mp
));
162 if(ui
.treeDevices
->selectedItems().size() != 0) {
163 nplat
= ui
.treeDevices
->selectedItems().at(0)->data(0, Qt::UserRole
).toString();
164 RbSettings::setValue(RbSettings::Platform
, nplat
);
167 errormsg
+= "<li>" + tr("No player selected") + "</li>";
172 if(QFileInfo(ui
.cachePath
->text()).isDir()) {
173 if(!QFileInfo(ui
.cachePath
->text()).isWritable()) {
174 errormsg
+= "<li>" + tr("Cache path not writeable. Leave path empty "
175 "to default to systems temporary path.") + "</li>";
179 RbSettings::setValue(RbSettings::CachePath
, ui
.cachePath
->text());
181 else // default to system temp path
182 RbSettings::setValue(RbSettings::CachePath
, QDir::tempPath());
183 RbSettings::setValue(RbSettings::CacheDisabled
, ui
.cacheDisable
->isChecked());
184 RbSettings::setValue(RbSettings::CacheOffline
, ui
.cacheOfflineMode
->isChecked());
187 int i
= ui
.comboTts
->currentIndex();
188 RbSettings::setValue(RbSettings::Tts
, ui
.comboTts
->itemData(i
).toString());
190 RbSettings::setValue(RbSettings::RbutilVersion
, PUREVERSION
);
193 errormsg
+= tr("You need to fix the above errors before you can continue.");
196 QMessageBox::critical(this, tr("Configuration error"), errormsg
);
202 emit
settingsUpdated();
209 qDebug() << "[Config] aborted.";
214 void Config::setUserSettings()
217 proxy
= RbSettings::value(RbSettings::Proxy
).toString();
220 ui
.proxyPort
->setText(QString("%1").arg(proxy
.port()));
221 else ui
.proxyPort
->setText("");
222 ui
.proxyHost
->setText(proxy
.host());
223 ui
.proxyUser
->setText(proxy
.userName());
224 ui
.proxyPass
->setText(proxy
.password());
226 QString proxyType
= RbSettings::value(RbSettings::ProxyType
).toString();
227 if(proxyType
== "manual") ui
.radioManualProxy
->setChecked(true);
228 else if(proxyType
== "system") ui
.radioSystemProxy
->setChecked(true);
229 else ui
.radioNoProxy
->setChecked(true);
231 // set language selection
232 QList
<QListWidgetItem
*> a
;
234 // find key for lang value
235 QMap
<QString
, QString
>::const_iterator i
= lang
.constBegin();
236 QString l
= RbSettings::value(RbSettings::Language
).toString();
238 l
= QLocale::system().name();
239 while (i
!= lang
.constEnd()) {
244 else if(l
.startsWith(i
.value(), Qt::CaseInsensitive
)) {
245 // check if there is a base language (en -> en_US, etc.)
251 a
= ui
.listLanguages
->findItems(b
, Qt::MatchExactly
);
253 ui
.listLanguages
->setCurrentItem(a
.at(0));
254 // don't connect before language list has been set up to prevent
255 // triggering the signal by selecting the saved language.
256 connect(ui
.listLanguages
, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage()));
259 ui
.mountPoint
->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::Mountpoint
).toString()));
262 if(!QFileInfo(RbSettings::value(RbSettings::CachePath
).toString()).isDir())
263 RbSettings::setValue(RbSettings::CachePath
, QDir::tempPath());
264 ui
.cachePath
->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::CachePath
).toString()));
265 ui
.cacheDisable
->setChecked(RbSettings::value(RbSettings::CacheDisabled
).toBool());
266 ui
.cacheOfflineMode
->setChecked(RbSettings::value(RbSettings::CacheOffline
).toBool());
267 updateCacheInfo(RbSettings::value(RbSettings::CachePath
).toString());
271 void Config::updateCacheInfo(QString path
)
274 fs
= QDir(path
+ "/rbutil-cache/").entryInfoList(QDir::Files
| QDir::NoDotAndDotDot
);
276 for(int i
= 0; i
< fs
.size(); i
++) {
277 sz
+= fs
.at(i
).size();
279 ui
.cacheSize
->setText(tr("Current cache size is %L1 kiB.")
284 void Config::showDisabled(bool show
)
286 qDebug() << "[Config] disabled targets shown:" << show
;
288 QMessageBox::warning(this, tr("Showing disabled targets"),
289 tr("You just enabled showing targets that are marked disabled. "
290 "Disabled targets are not recommended to end users. Please "
291 "use this option only if you know what you are doing."));
297 void Config::setDevices()
300 // setup devices table
301 qDebug() << "[Config] setting up devices list";
303 QStringList platformList
;
304 if(ui
.showDisabled
->isChecked())
305 platformList
= SystemInfo::platforms(SystemInfo::PlatformAllDisabled
);
307 platformList
= SystemInfo::platforms(SystemInfo::PlatformAll
);
309 QMap
<QString
, QString
> manuf
;
310 for(int it
= 0; it
< platformList
.size(); it
++)
312 QString curbrand
= SystemInfo::platformValue(platformList
.at(it
),
313 SystemInfo::CurBrand
).toString();
314 manuf
.insertMulti(curbrand
, platformList
.at(it
));
317 // set up devices table
318 ui
.treeDevices
->header()->hide();
319 ui
.treeDevices
->expandAll();
320 ui
.treeDevices
->setColumnCount(1);
321 QList
<QTreeWidgetItem
*> items
;
324 QStringList brands
= manuf
.uniqueKeys();
327 QTreeWidgetItem
*w3
= 0;
329 QString selected
= RbSettings::value(RbSettings::Platform
).toString();
330 for(int c
= 0; c
< brands
.size(); c
++) {
331 w
= new QTreeWidgetItem();
332 w
->setFlags(Qt::ItemIsEnabled
);
333 w
->setText(0, brands
.at(c
));
335 // go through platforms and add all players matching the current brand
336 for(int it
= 0; it
< platformList
.size(); it
++) {
337 // skip if not current brand
338 if(!manuf
.values(brands
.at(c
)).contains(platformList
.at(it
)))
340 // construct display name
341 QString curname
= SystemInfo::platformValue(platformList
.at(it
),
342 SystemInfo::CurName
).toString() +
343 " (" +ServerInfo::platformValue(platformList
.at(it
),
344 ServerInfo::CurStatus
).toString() +")";
345 qDebug() << "[Config] add supported device:" << brands
.at(c
) << curname
;
346 w2
= new QTreeWidgetItem(w
, QStringList(curname
));
347 w2
->setData(0, Qt::UserRole
, platformList
.at(it
));
349 if(platformList
.at(it
) == selected
) {
350 w2
->setSelected(true);
351 w
->setExpanded(true);
352 w3
= w2
; // save pointer to hilight old selection
357 // remove any old items in list
358 QTreeWidgetItem
* widgetitem
;
360 widgetitem
= ui
.treeDevices
->takeTopLevelItem(0);
365 ui
.treeDevices
->insertTopLevelItems(0, items
);
367 ui
.treeDevices
->setCurrentItem(w3
); // hilight old selection
368 ui
.treeDevices
->scrollToItem(w3
);
377 QStringList ttslist
= TTSBase::getTTSList();
378 for(int a
= 0; a
< ttslist
.size(); a
++)
379 ui
.comboTts
->addItem(TTSBase::getTTSName(ttslist
.at(a
)), ttslist
.at(a
));
380 //update index of combobox
381 int index
= ui
.comboTts
->findData(RbSettings::value(RbSettings::Tts
).toString());
382 if(index
< 0) index
= 0;
383 ui
.comboTts
->setCurrentIndex(index
);
384 updateTtsState(index
);
389 void Config::updateTtsState(int index
)
391 QString ttsName
= ui
.comboTts
->itemData(index
).toString();
392 TTSBase
* tts
= TTSBase::getTTS(this,ttsName
);
396 ui
.configTTSstatus
->setText(tr("Configuration OK"));
397 ui
.configTTSstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
401 ui
.configTTSstatus
->setText(tr("Configuration INVALID"));
402 ui
.configTTSstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
405 delete tts
; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
406 since that would delete the TTSBase instance on application exit*/
409 void Config::updateEncState()
411 if(ui
.treeDevices
->selectedItems().size() == 0)
414 QString devname
= ui
.treeDevices
->selectedItems().at(0)->data(0, Qt::UserRole
).toString();
415 QString encoder
= SystemInfo::platformValue(devname
,
416 SystemInfo::CurEncoder
).toString();
417 ui
.encoderName
->setText(EncBase::getEncoderName(SystemInfo::platformValue(devname
,
418 SystemInfo::CurEncoder
).toString()));
420 EncBase
* enc
= EncBase::getEncoder(this,encoder
);
424 ui
.configEncstatus
->setText(tr("Configuration OK"));
425 ui
.configEncstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
429 ui
.configEncstatus
->setText(tr("Configuration INVALID"));
430 ui
.configEncstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
435 void Config::setNoProxy(bool checked
)
438 ui
.proxyPort
->setEnabled(i
);
439 ui
.proxyHost
->setEnabled(i
);
440 ui
.proxyUser
->setEnabled(i
);
441 ui
.proxyPass
->setEnabled(i
);
445 void Config::setSystemProxy(bool checked
)
447 ui
.proxyPort
->setEnabled(!checked
);
448 ui
.proxyHost
->setEnabled(!checked
);
449 ui
.proxyUser
->setEnabled(!checked
);
450 ui
.proxyPass
->setEnabled(!checked
);
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();
460 qDebug() << "[Config] setting system proxy" << envproxy
;
462 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());
467 if(envproxy
.host().isEmpty() || envproxy
.port() == -1) {
468 qDebug() << "[Config] sytem proxy is invalid.";
469 QMessageBox::warning(this, tr("Proxy Detection"),
470 tr("The System Proxy settings are invalid!\n"
471 "Rockbox Utility can't work with this proxy settings. "
472 "Make sure the system proxy is set correctly. Note that "
473 "\"proxy auto-config (PAC)\" scripts are not supported by "
474 "Rockbox Utility. If your system uses this you need "
475 "to use manual proxy settings."),
476 QMessageBox::Ok
,QMessageBox::Ok
);
477 // the current proxy settings are invalid. Check the saved proxy
479 if(RbSettings::value(RbSettings::ProxyType
).toString() == "manual")
480 ui
.radioManualProxy
->setChecked(true);
482 ui
.radioNoProxy
->setChecked(true);
487 ui
.proxyHost
->setText(proxy
.host());
489 ui
.proxyPort
->setText(QString("%1").arg(proxy
.port()));
490 else ui
.proxyPort
->setText("");
491 ui
.proxyUser
->setText(proxy
.userName());
492 ui
.proxyPass
->setText(proxy
.password());
498 QStringList
Config::findLanguageFiles()
500 QDir
dir(programPath
);
501 QStringList fileNames
;
503 fileNames
= dir
.entryList(QStringList("*.qm"), QDir::Files
, QDir::Name
);
505 QDir
resDir(":/lang");
506 fileNames
+= resDir
.entryList(QStringList("*.qm"), QDir::Files
, QDir::Name
);
508 QRegExp
exp("^rbutil_(.*)\\.qm");
509 for(int i
= 0; i
< fileNames
.size(); i
++) {
510 QString a
= fileNames
.at(i
);
511 a
.replace(exp
, "\\1");
515 qDebug() << "[Config] available lang files:" << langs
;
521 QString
Config::languageName(const QString
&qmFile
)
523 QTranslator translator
;
525 QString file
= "rbutil_" + qmFile
;
526 if(!translator
.load(file
, programPath
))
527 translator
.load(file
, ":/lang");
529 return translator
.translate("Configure", "English",
530 "This is the localized language name, i.e. your language.");
534 void Config::updateLanguage()
536 qDebug() << "[Config] update selected language";
537 QList
<QListWidgetItem
*> a
= ui
.listLanguages
->selectedItems();
539 language
= lang
.value(a
.at(0)->text());
540 qDebug() << "[Config] new language:" << language
;
544 void Config::browseFolder()
546 browser
= new BrowseDirtree(this,tr("Select your device"));
547 #if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
548 browser
->setFilter(QDir::AllDirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
);
549 #elif defined(Q_OS_WIN32)
550 browser
->setFilter(QDir::Drives
);
552 #if defined(Q_OS_MACX)
553 browser
->setRoot("/Volumes");
554 #elif defined(Q_OS_LINUX)
555 browser
->setDir("/media");
557 if( ui
.mountPoint
->text() != "" )
559 browser
->setDir(ui
.mountPoint
->text());
562 connect(browser
, SIGNAL(itemChanged(QString
)), this, SLOT(setMountpoint(QString
)));
566 void Config::browseCache()
568 QString old
= ui
.cachePath
->text();
569 if(!QFileInfo(old
).isDir())
570 old
= QDir::tempPath();
571 QString c
= QFileDialog::getExistingDirectory(this, tr("Set Cache Path"), old
);
574 else if(!QFileInfo(c
).isDir())
575 c
= QDir::tempPath();
576 ui
.cachePath
->setText(QDir::toNativeSeparators(c
));
581 void Config::setMountpoint(QString m
)
583 ui
.mountPoint
->setText(m
);
587 void Config::autodetect()
589 Autodetection
detector(this);
590 // disable tree during detection as "working" feedback.
591 // TODO: replace the tree view with a splash screen during this time.
592 ui
.treeDevices
->setEnabled(false);
593 this->setCursor(Qt::WaitCursor
);
594 QCoreApplication::processEvents();
596 if(detector
.detect()) //let it detect
598 QString devicename
= detector
.getDevice();
599 // deexpand all items
600 for(int a
= 0; a
< ui
.treeDevices
->topLevelItemCount(); a
++)
601 ui
.treeDevices
->topLevelItem(a
)->setExpanded(false);
602 //deselect the selected item(s)
603 for(int a
= 0; a
< ui
.treeDevices
->selectedItems().size(); a
++)
604 ui
.treeDevices
->selectedItems().at(a
)->setSelected(false);
607 // enumerate all platform items
608 QList
<QTreeWidgetItem
*> itmList
609 = ui
.treeDevices
->findItems("*",Qt::MatchWildcard
);
610 for(int i
=0; i
< itmList
.size();i
++)
612 //enumerate device items
613 for(int j
=0;j
< itmList
.at(i
)->childCount();j
++)
615 QString data
= itmList
.at(i
)->child(j
)->data(0, Qt::UserRole
).toString();
617 if(devicename
== data
) // item found
619 itmList
.at(i
)->child(j
)->setSelected(true); //select the item
620 itmList
.at(i
)->setExpanded(true); //expand the platform item
621 //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
622 ui
.treeDevices
->scrollToItem(itmList
.at(i
)->child(j
));
629 if(!detector
.errdev().isEmpty()) {
631 if(detector
.errdev() == "sansae200")
632 text
= tr("Sansa e200 in MTP mode found!\n"
633 "You need to change your player to MSC mode for installation. ");
634 if(detector
.errdev() == "h10")
635 text
= tr("H10 20GB in MTP mode found!\n"
636 "You need to change your player to UMS mode for installation. ");
637 if(SystemInfo::platformValue(detector
.errdev(),
638 SystemInfo::CurBootloaderMethod
) == "ipod")
639 text
= tr("%1 \"MacPod\" found!\n"
640 "Rockbox needs a FAT formatted Ipod (so-called \"WinPod\") "
641 "to run. ").arg(SystemInfo::platformValue(
642 detector
.errdev(), SystemInfo::CurName
).toString());
643 text
+= tr("Unless you changed this installation will fail!");
645 QMessageBox::critical(this, tr("Fatal error"), text
, QMessageBox::Ok
);
648 if(!detector
.incompatdev().isEmpty()) {
650 text
= tr("Detected an unsupported player:\n%1\n"
651 "Sorry, Rockbox doesn't run on your player.")
652 .arg(SystemInfo::platformValue(detector
.incompatdev(),
653 SystemInfo::CurName
).toString());
655 QMessageBox::critical(this, tr("Fatal: player incompatible"),
656 text
, QMessageBox::Ok
);
660 if(detector
.getMountPoint() != "" )
662 ui
.mountPoint
->setText(QDir::toNativeSeparators(detector
.getMountPoint()));
666 QMessageBox::warning(this, tr("Autodetection"),
667 tr("Could not detect a Mountpoint.\n"
668 "Select your Mountpoint manually."),
669 QMessageBox::Ok
,QMessageBox::Ok
);
675 QMessageBox::warning(this, tr("Autodetection"),
676 tr("Could not detect a device.\n"
677 "Select your device and Mountpoint manually."),
678 QMessageBox::Ok
,QMessageBox::Ok
);
681 ui
.treeDevices
->setEnabled(true);
685 void Config::cacheClear()
687 if(QMessageBox::critical(this, tr("Really delete cache?"),
688 tr("Do you really want to delete the cache? "
689 "Make absolutely sure this setting is correct as it will "
690 "remove <b>all</b> files in this folder!").arg(ui
.cachePath
->text()),
691 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
694 QString cache
= ui
.cachePath
->text() + "/rbutil-cache/";
695 if(!QFileInfo(cache
).isDir()) {
696 QMessageBox::critical(this, tr("Path wrong!"),
697 tr("The cache path is invalid. Aborting."), QMessageBox::Ok
);
702 fn
= dir
.entryList(QStringList("*"), QDir::Files
, QDir::Name
);
704 for(int i
= 0; i
< fn
.size(); i
++) {
705 QString f
= cache
+ fn
.at(i
);
708 updateCacheInfo(RbSettings::value(RbSettings::CachePath
).toString());
712 void Config::configTts()
714 int index
= ui
.comboTts
->currentIndex();
715 TTSBase
* tts
= TTSBase::getTTS(this,ui
.comboTts
->itemData(index
).toString());
717 EncTtsCfgGui
gui(this,tts
,TTSBase::getTTSName(ui
.comboTts
->itemData(index
).toString()));
719 updateTtsState(ui
.comboTts
->currentIndex());
720 delete tts
; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
721 since that would delete the TTSBase instance on application exit*/
724 void Config::testTts()
727 int index
= ui
.comboTts
->currentIndex();
728 TTSBase
* tts
= TTSBase::getTTS(this,ui
.comboTts
->itemData(index
).toString());
731 QMessageBox::warning(this,tr("TTS configuration invalid"),
732 tr("TTS configuration invalid. \n Please configure TTS engine."));
736 if(!tts
->start(&errstr
))
738 QMessageBox::warning(this,tr("Could not start TTS engine."),
739 tr("Could not start TTS engine.\n") + errstr
740 + tr("\nPlease configure TTS engine."));
744 QTemporaryFile
file(this);
746 QString filename
= file
.fileName();
749 if(tts
->voice(tr("Rockbox Utility Voice Test"),filename
,&errstr
) == FatalError
)
752 QMessageBox::warning(this,tr("Could not voice test string."),
753 tr("Could not voice test string.\n") + errstr
754 + tr("\nPlease configure TTS engine."));
758 #if defined(Q_OS_LINUX)
759 QString exe
= Utils::findExecutable("aplay");
760 if(exe
== "") exe
= Utils::findExecutable("play");
763 QProcess::execute(exe
+" "+filename
);
766 QSound::play(filename
);
769 delete tts
; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
770 since that would delete the TTSBase instance on application exit*/
773 void Config::configEnc()
775 if(ui
.treeDevices
->selectedItems().size() == 0)
778 QString devname
= ui
.treeDevices
->selectedItems().at(0)->data(0, Qt::UserRole
).toString();
779 QString encoder
= SystemInfo::platformValue(devname
,
780 SystemInfo::CurEncoder
).toString();
781 ui
.encoderName
->setText(EncBase::getEncoderName(SystemInfo::platformValue(devname
,
782 SystemInfo::CurEncoder
).toString()));
785 EncBase
* enc
= EncBase::getEncoder(this,encoder
);
787 EncTtsCfgGui
gui(this,enc
,EncBase::getEncoderName(encoder
));