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 "
137 RbSettings::setValue(RbSettings::Language
, language
);
140 QString mp
= ui
.mountPoint
->text();
142 errormsg
+= "<li>" + tr("No mountpoint given") + "</li>";
145 else if(!QFileInfo(mp
).exists()) {
146 errormsg
+= "<li>" + tr("Mountpoint does not exist") + "</li>";
149 else if(!QFileInfo(mp
).isDir()) {
150 errormsg
+= "<li>" + tr("Mountpoint is not a directory.") + "</li>";
153 else if(!QFileInfo(mp
).isWritable()) {
154 errormsg
+= "<li>" + tr("Mountpoint is not writeable") + "</li>";
158 RbSettings::setValue(RbSettings::Mountpoint
, QDir::fromNativeSeparators(mp
));
163 if(ui
.treeDevices
->selectedItems().size() != 0) {
164 nplat
= ui
.treeDevices
->selectedItems().at(0)->data(0, Qt::UserRole
).toString();
165 RbSettings::setValue(RbSettings::Platform
, nplat
);
168 errormsg
+= "<li>" + tr("No player selected") + "</li>";
173 if(QFileInfo(ui
.cachePath
->text()).isDir()) {
174 if(!QFileInfo(ui
.cachePath
->text()).isWritable()) {
175 errormsg
+= "<li>" + tr("Cache path not writeable. Leave path empty "
176 "to default to systems temporary path.") + "</li>";
180 RbSettings::setValue(RbSettings::CachePath
, ui
.cachePath
->text());
182 else // default to system temp path
183 RbSettings::setValue(RbSettings::CachePath
, QDir::tempPath());
184 RbSettings::setValue(RbSettings::CacheDisabled
, ui
.cacheDisable
->isChecked());
185 RbSettings::setValue(RbSettings::CacheOffline
, ui
.cacheOfflineMode
->isChecked());
188 int i
= ui
.comboTts
->currentIndex();
189 RbSettings::setValue(RbSettings::Tts
, ui
.comboTts
->itemData(i
).toString());
191 RbSettings::setValue(RbSettings::RbutilVersion
, PUREVERSION
);
194 errormsg
+= tr("You need to fix the above errors before you can continue.");
197 QMessageBox::critical(this, tr("Configuration error"), errormsg
);
203 emit
settingsUpdated();
210 qDebug() << "[Config] aborted.";
215 void Config::setUserSettings()
218 proxy
= RbSettings::value(RbSettings::Proxy
).toString();
221 ui
.proxyPort
->setText(QString("%1").arg(proxy
.port()));
222 else ui
.proxyPort
->setText("");
223 ui
.proxyHost
->setText(proxy
.host());
224 ui
.proxyUser
->setText(proxy
.userName());
225 ui
.proxyPass
->setText(proxy
.password());
227 QString proxyType
= RbSettings::value(RbSettings::ProxyType
).toString();
228 if(proxyType
== "manual") ui
.radioManualProxy
->setChecked(true);
229 else if(proxyType
== "system") ui
.radioSystemProxy
->setChecked(true);
230 else ui
.radioNoProxy
->setChecked(true);
232 // set language selection
233 QList
<QListWidgetItem
*> a
;
235 // find key for lang value
236 QMap
<QString
, QString
>::const_iterator i
= lang
.constBegin();
237 QString l
= RbSettings::value(RbSettings::Language
).toString();
239 l
= QLocale::system().name();
240 while (i
!= lang
.constEnd()) {
245 else if(l
.startsWith(i
.value(), Qt::CaseInsensitive
)) {
246 // check if there is a base language (en -> en_US, etc.)
252 a
= ui
.listLanguages
->findItems(b
, Qt::MatchExactly
);
254 ui
.listLanguages
->setCurrentItem(a
.at(0));
255 // don't connect before language list has been set up to prevent
256 // triggering the signal by selecting the saved language.
257 connect(ui
.listLanguages
, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage()));
260 ui
.mountPoint
->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::Mountpoint
).toString()));
263 if(!QFileInfo(RbSettings::value(RbSettings::CachePath
).toString()).isDir())
264 RbSettings::setValue(RbSettings::CachePath
, QDir::tempPath());
265 ui
.cachePath
->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::CachePath
).toString()));
266 ui
.cacheDisable
->setChecked(RbSettings::value(RbSettings::CacheDisabled
).toBool());
267 ui
.cacheOfflineMode
->setChecked(RbSettings::value(RbSettings::CacheOffline
).toBool());
268 updateCacheInfo(RbSettings::value(RbSettings::CachePath
).toString());
272 void Config::updateCacheInfo(QString path
)
275 fs
= QDir(path
+ "/rbutil-cache/").entryInfoList(QDir::Files
| QDir::NoDotAndDotDot
);
277 for(int i
= 0; i
< fs
.size(); i
++) {
278 sz
+= fs
.at(i
).size();
280 ui
.cacheSize
->setText(tr("Current cache size is %L1 kiB.")
285 void Config::showDisabled(bool show
)
287 qDebug() << "[Config] disabled targets shown:" << show
;
289 QMessageBox::warning(this, tr("Showing disabled targets"),
290 tr("You just enabled showing targets that are marked disabled. "
291 "Disabled targets are not recommended to end users. Please "
292 "use this option only if you know what you are doing."));
298 void Config::setDevices()
301 // setup devices table
302 qDebug() << "[Config] setting up devices list";
304 QStringList platformList
;
305 if(ui
.showDisabled
->isChecked())
306 platformList
= SystemInfo::platforms(SystemInfo::PlatformAllDisabled
);
308 platformList
= SystemInfo::platforms(SystemInfo::PlatformAll
);
310 QMap
<QString
, QString
> manuf
;
311 for(int it
= 0; it
< platformList
.size(); it
++)
313 QString curbrand
= SystemInfo::platformValue(platformList
.at(it
),
314 SystemInfo::CurBrand
).toString();
315 manuf
.insertMulti(curbrand
, platformList
.at(it
));
318 // set up devices table
319 ui
.treeDevices
->header()->hide();
320 ui
.treeDevices
->expandAll();
321 ui
.treeDevices
->setColumnCount(1);
322 QList
<QTreeWidgetItem
*> items
;
325 QStringList brands
= manuf
.uniqueKeys();
328 QTreeWidgetItem
*w3
= 0;
330 QString selected
= RbSettings::value(RbSettings::Platform
).toString();
331 for(int c
= 0; c
< brands
.size(); c
++) {
332 w
= new QTreeWidgetItem();
333 w
->setFlags(Qt::ItemIsEnabled
);
334 w
->setText(0, brands
.at(c
));
336 // go through platforms and add all players matching the current brand
337 for(int it
= 0; it
< platformList
.size(); it
++) {
338 // skip if not current brand
339 if(!manuf
.values(brands
.at(c
)).contains(platformList
.at(it
)))
341 // construct display name
342 QString curname
= SystemInfo::platformValue(platformList
.at(it
),
343 SystemInfo::CurName
).toString() +
344 " (" +ServerInfo::platformValue(platformList
.at(it
),
345 ServerInfo::CurStatus
).toString() +")";
346 qDebug() << "[Config] add supported device:" << brands
.at(c
) << curname
;
347 w2
= new QTreeWidgetItem(w
, QStringList(curname
));
348 w2
->setData(0, Qt::UserRole
, platformList
.at(it
));
350 if(platformList
.at(it
) == selected
) {
351 w2
->setSelected(true);
352 w
->setExpanded(true);
353 w3
= w2
; // save pointer to hilight old selection
358 // remove any old items in list
359 QTreeWidgetItem
* widgetitem
;
361 widgetitem
= ui
.treeDevices
->takeTopLevelItem(0);
366 ui
.treeDevices
->insertTopLevelItems(0, items
);
368 ui
.treeDevices
->setCurrentItem(w3
); // hilight old selection
369 ui
.treeDevices
->scrollToItem(w3
);
378 QStringList ttslist
= TTSBase::getTTSList();
379 for(int a
= 0; a
< ttslist
.size(); a
++)
380 ui
.comboTts
->addItem(TTSBase::getTTSName(ttslist
.at(a
)), ttslist
.at(a
));
381 //update index of combobox
382 int index
= ui
.comboTts
->findData(RbSettings::value(RbSettings::Tts
).toString());
383 if(index
< 0) index
= 0;
384 ui
.comboTts
->setCurrentIndex(index
);
385 updateTtsState(index
);
390 void Config::updateTtsState(int index
)
392 QString ttsName
= ui
.comboTts
->itemData(index
).toString();
393 TTSBase
* tts
= TTSBase::getTTS(this,ttsName
);
397 ui
.configTTSstatus
->setText(tr("Configuration OK"));
398 ui
.configTTSstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
402 ui
.configTTSstatus
->setText(tr("Configuration INVALID"));
403 ui
.configTTSstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
406 delete tts
; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
407 since that would delete the TTSBase instance on application exit*/
410 void Config::updateEncState()
412 if(ui
.treeDevices
->selectedItems().size() == 0)
415 QString devname
= ui
.treeDevices
->selectedItems().at(0)->data(0, Qt::UserRole
).toString();
416 QString encoder
= SystemInfo::platformValue(devname
,
417 SystemInfo::CurEncoder
).toString();
418 ui
.encoderName
->setText(EncBase::getEncoderName(SystemInfo::platformValue(devname
,
419 SystemInfo::CurEncoder
).toString()));
421 EncBase
* enc
= EncBase::getEncoder(this,encoder
);
425 ui
.configEncstatus
->setText(tr("Configuration OK"));
426 ui
.configEncstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
430 ui
.configEncstatus
->setText(tr("Configuration INVALID"));
431 ui
.configEncstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
436 void Config::setNoProxy(bool checked
)
439 ui
.proxyPort
->setEnabled(i
);
440 ui
.proxyHost
->setEnabled(i
);
441 ui
.proxyUser
->setEnabled(i
);
442 ui
.proxyPass
->setEnabled(i
);
446 void Config::setSystemProxy(bool checked
)
448 ui
.proxyPort
->setEnabled(!checked
);
449 ui
.proxyHost
->setEnabled(!checked
);
450 ui
.proxyUser
->setEnabled(!checked
);
451 ui
.proxyPass
->setEnabled(!checked
);
453 // save values in input box
454 proxy
.setScheme("http");
455 proxy
.setUserName(ui
.proxyUser
->text());
456 proxy
.setPassword(ui
.proxyPass
->text());
457 proxy
.setHost(ui
.proxyHost
->text());
458 proxy
.setPort(ui
.proxyPort
->text().toInt());
459 // show system values in input box
460 QUrl envproxy
= System::systemProxy();
461 qDebug() << "[Config] setting system proxy" << envproxy
;
463 ui
.proxyHost
->setText(envproxy
.host());
464 ui
.proxyPort
->setText(QString("%1").arg(envproxy
.port()));
465 ui
.proxyUser
->setText(envproxy
.userName());
466 ui
.proxyPass
->setText(envproxy
.password());
468 if(envproxy
.host().isEmpty() || envproxy
.port() == -1) {
469 qDebug() << "[Config] sytem proxy is invalid.";
470 QMessageBox::warning(this, tr("Proxy Detection"),
471 tr("The System Proxy settings are invalid!\n"
472 "Rockbox Utility can't work with this proxy settings. "
473 "Make sure the system proxy is set correctly. Note that "
474 "\"proxy auto-config (PAC)\" scripts are not supported by "
475 "Rockbox Utility. If your system uses this you need "
476 "to use manual proxy settings."),
477 QMessageBox::Ok
,QMessageBox::Ok
);
478 // the current proxy settings are invalid. Check the saved proxy
480 if(RbSettings::value(RbSettings::ProxyType
).toString() == "manual")
481 ui
.radioManualProxy
->setChecked(true);
483 ui
.radioNoProxy
->setChecked(true);
488 ui
.proxyHost
->setText(proxy
.host());
490 ui
.proxyPort
->setText(QString("%1").arg(proxy
.port()));
491 else ui
.proxyPort
->setText("");
492 ui
.proxyUser
->setText(proxy
.userName());
493 ui
.proxyPass
->setText(proxy
.password());
499 QStringList
Config::findLanguageFiles()
501 QDir
dir(programPath
);
502 QStringList fileNames
;
504 fileNames
= dir
.entryList(QStringList("*.qm"), QDir::Files
, QDir::Name
);
506 QDir
resDir(":/lang");
507 fileNames
+= resDir
.entryList(QStringList("*.qm"), QDir::Files
, QDir::Name
);
509 QRegExp
exp("^rbutil_(.*)\\.qm");
510 for(int i
= 0; i
< fileNames
.size(); i
++) {
511 QString a
= fileNames
.at(i
);
512 a
.replace(exp
, "\\1");
516 qDebug() << "[Config] available lang files:" << langs
;
522 QString
Config::languageName(const QString
&qmFile
)
524 QTranslator translator
;
526 QString file
= "rbutil_" + qmFile
;
527 if(!translator
.load(file
, programPath
))
528 translator
.load(file
, ":/lang");
530 return translator
.translate("Configure", "English",
531 "This is the localized language name, i.e. your language.");
535 void Config::updateLanguage()
537 qDebug() << "[Config] update selected language";
538 QList
<QListWidgetItem
*> a
= ui
.listLanguages
->selectedItems();
540 language
= lang
.value(a
.at(0)->text());
541 qDebug() << "[Config] new language:" << language
;
545 void Config::browseFolder()
547 browser
= new BrowseDirtree(this,tr("Select your device"));
548 #if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
549 browser
->setFilter(QDir::AllDirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
);
550 #elif defined(Q_OS_WIN32)
551 browser
->setFilter(QDir::Drives
);
553 #if defined(Q_OS_MACX)
554 browser
->setRoot("/Volumes");
555 #elif defined(Q_OS_LINUX)
556 browser
->setDir("/media");
558 if( ui
.mountPoint
->text() != "" )
560 browser
->setDir(ui
.mountPoint
->text());
563 connect(browser
, SIGNAL(itemChanged(QString
)), this, SLOT(setMountpoint(QString
)));
567 void Config::browseCache()
569 QString old
= ui
.cachePath
->text();
570 if(!QFileInfo(old
).isDir())
571 old
= QDir::tempPath();
572 QString c
= QFileDialog::getExistingDirectory(this, tr("Set Cache Path"), old
);
575 else if(!QFileInfo(c
).isDir())
576 c
= QDir::tempPath();
577 ui
.cachePath
->setText(QDir::toNativeSeparators(c
));
582 void Config::setMountpoint(QString m
)
584 ui
.mountPoint
->setText(m
);
588 void Config::autodetect()
590 Autodetection
detector(this);
591 // disable tree during detection as "working" feedback.
592 // TODO: replace the tree view with a splash screen during this time.
593 ui
.treeDevices
->setEnabled(false);
594 this->setCursor(Qt::WaitCursor
);
595 QCoreApplication::processEvents();
597 if(detector
.detect()) //let it detect
599 QString devicename
= detector
.getDevice();
600 // deexpand all items
601 for(int a
= 0; a
< ui
.treeDevices
->topLevelItemCount(); a
++)
602 ui
.treeDevices
->topLevelItem(a
)->setExpanded(false);
603 //deselect the selected item(s)
604 for(int a
= 0; a
< ui
.treeDevices
->selectedItems().size(); a
++)
605 ui
.treeDevices
->selectedItems().at(a
)->setSelected(false);
608 // enumerate all platform items
609 QList
<QTreeWidgetItem
*> itmList
610 = ui
.treeDevices
->findItems("*",Qt::MatchWildcard
);
611 for(int i
=0; i
< itmList
.size();i
++)
613 //enumerate device items
614 for(int j
=0;j
< itmList
.at(i
)->childCount();j
++)
616 QString data
= itmList
.at(i
)->child(j
)->data(0, Qt::UserRole
).toString();
618 if(devicename
== data
) // item found
620 itmList
.at(i
)->child(j
)->setSelected(true); //select the item
621 itmList
.at(i
)->setExpanded(true); //expand the platform item
622 //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
623 ui
.treeDevices
->scrollToItem(itmList
.at(i
)->child(j
));
630 if(!detector
.errdev().isEmpty()) {
632 if(detector
.errdev() == "sansae200")
633 text
= tr("Sansa e200 in MTP mode found!\n"
634 "You need to change your player to MSC mode for installation. ");
635 if(detector
.errdev() == "h10")
636 text
= tr("H10 20GB in MTP mode found!\n"
637 "You need to change your player to UMS mode for installation. ");
638 if(SystemInfo::platformValue(detector
.errdev(),
639 SystemInfo::CurBootloaderMethod
) == "ipod")
640 text
= tr("%1 \"MacPod\" found!\n"
641 "Rockbox needs a FAT formatted Ipod (so-called \"WinPod\") "
642 "to run. ").arg(SystemInfo::platformValue(
643 detector
.errdev(), SystemInfo::CurName
).toString());
644 text
+= tr("Unless you changed this installation will fail!");
646 QMessageBox::critical(this, tr("Fatal error"), text
, QMessageBox::Ok
);
649 if(!detector
.incompatdev().isEmpty()) {
651 text
= tr("Detected an unsupported player:\n%1\n"
652 "Sorry, Rockbox doesn't run on your player.")
653 .arg(SystemInfo::platformValue(detector
.incompatdev(),
654 SystemInfo::CurName
).toString());
656 QMessageBox::critical(this, tr("Fatal: player incompatible"),
657 text
, QMessageBox::Ok
);
661 if(detector
.getMountPoint() != "" )
663 ui
.mountPoint
->setText(QDir::toNativeSeparators(detector
.getMountPoint()));
667 QMessageBox::warning(this, tr("Autodetection"),
668 tr("Could not detect a Mountpoint.\n"
669 "Select your Mountpoint manually."),
670 QMessageBox::Ok
,QMessageBox::Ok
);
676 QMessageBox::warning(this, tr("Autodetection"),
677 tr("Could not detect a device.\n"
678 "Select your device and Mountpoint manually."),
679 QMessageBox::Ok
,QMessageBox::Ok
);
682 ui
.treeDevices
->setEnabled(true);
686 void Config::cacheClear()
688 if(QMessageBox::critical(this, tr("Really delete cache?"),
689 tr("Do you really want to delete the cache? "
690 "Make absolutely sure this setting is correct as it will "
691 "remove <b>all</b> files in this folder!").arg(ui
.cachePath
->text()),
692 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
695 QString cache
= ui
.cachePath
->text() + "/rbutil-cache/";
696 if(!QFileInfo(cache
).isDir()) {
697 QMessageBox::critical(this, tr("Path wrong!"),
698 tr("The cache path is invalid. Aborting."), QMessageBox::Ok
);
703 fn
= dir
.entryList(QStringList("*"), QDir::Files
, QDir::Name
);
705 for(int i
= 0; i
< fn
.size(); i
++) {
706 QString f
= cache
+ fn
.at(i
);
709 updateCacheInfo(RbSettings::value(RbSettings::CachePath
).toString());
713 void Config::configTts()
715 int index
= ui
.comboTts
->currentIndex();
716 TTSBase
* tts
= TTSBase::getTTS(this,ui
.comboTts
->itemData(index
).toString());
718 EncTtsCfgGui
gui(this,tts
,TTSBase::getTTSName(ui
.comboTts
->itemData(index
).toString()));
720 updateTtsState(ui
.comboTts
->currentIndex());
721 delete tts
; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
722 since that would delete the TTSBase instance on application exit*/
725 void Config::testTts()
728 int index
= ui
.comboTts
->currentIndex();
729 TTSBase
* tts
= TTSBase::getTTS(this,ui
.comboTts
->itemData(index
).toString());
732 QMessageBox::warning(this,tr("TTS configuration invalid"),
733 tr("TTS configuration invalid. \n Please configure TTS engine."));
737 if(!tts
->start(&errstr
))
739 QMessageBox::warning(this,tr("Could not start TTS engine."),
740 tr("Could not start TTS engine.\n") + errstr
741 + tr("\nPlease configure TTS engine."));
745 QTemporaryFile
file(this);
747 QString filename
= file
.fileName();
750 if(tts
->voice(tr("Rockbox Utility Voice Test"),filename
,&errstr
) == FatalError
)
753 QMessageBox::warning(this,tr("Could not voice test string."),
754 tr("Could not voice test string.\n") + errstr
755 + tr("\nPlease configure TTS engine."));
759 #if defined(Q_OS_LINUX)
760 QString exe
= Utils::findExecutable("aplay");
761 if(exe
== "") exe
= Utils::findExecutable("play");
764 QProcess::execute(exe
+" "+filename
);
767 QSound::play(filename
);
770 delete tts
; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
771 since that would delete the TTSBase instance on application exit*/
774 void Config::configEnc()
776 if(ui
.treeDevices
->selectedItems().size() == 0)
779 QString devname
= ui
.treeDevices
->selectedItems().at(0)->data(0, Qt::UserRole
).toString();
780 QString encoder
= SystemInfo::platformValue(devname
,
781 SystemInfo::CurEncoder
).toString();
782 ui
.encoderName
->setText(EncBase::getEncoderName(SystemInfo::platformValue(devname
,
783 SystemInfo::CurEncoder
).toString()));
786 EncBase
* enc
= EncBase::getEncoder(this,encoder
);
788 EncTtsCfgGui
gui(this,enc
,EncBase::getEncoderName(encoder
));