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 OS X 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")));
407 delete tts
; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
408 since that would delete the TTSBase instance on application exit*/
411 void Config::updateEncState()
413 if(ui
.treeDevices
->selectedItems().size() == 0)
416 QString devname
= ui
.treeDevices
->selectedItems().at(0)->data(0, Qt::UserRole
).toString();
417 QString encoder
= SystemInfo::platformValue(devname
,
418 SystemInfo::CurEncoder
).toString();
419 ui
.encoderName
->setText(EncBase::getEncoderName(SystemInfo::platformValue(devname
,
420 SystemInfo::CurEncoder
).toString()));
422 EncBase
* enc
= EncBase::getEncoder(this,encoder
);
426 ui
.configEncstatus
->setText(tr("Configuration OK"));
427 ui
.configEncstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
431 ui
.configEncstatus
->setText(tr("Configuration INVALID"));
432 ui
.configEncstatusimg
->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
437 void Config::setNoProxy(bool checked
)
440 ui
.proxyPort
->setEnabled(i
);
441 ui
.proxyHost
->setEnabled(i
);
442 ui
.proxyUser
->setEnabled(i
);
443 ui
.proxyPass
->setEnabled(i
);
447 void Config::setSystemProxy(bool checked
)
449 ui
.proxyPort
->setEnabled(!checked
);
450 ui
.proxyHost
->setEnabled(!checked
);
451 ui
.proxyUser
->setEnabled(!checked
);
452 ui
.proxyPass
->setEnabled(!checked
);
454 // save values in input box
455 proxy
.setScheme("http");
456 proxy
.setUserName(ui
.proxyUser
->text());
457 proxy
.setPassword(ui
.proxyPass
->text());
458 proxy
.setHost(ui
.proxyHost
->text());
459 proxy
.setPort(ui
.proxyPort
->text().toInt());
460 // show system values in input box
461 QUrl envproxy
= System::systemProxy();
462 qDebug() << "[Config] setting system proxy" << envproxy
;
464 ui
.proxyHost
->setText(envproxy
.host());
465 ui
.proxyPort
->setText(QString("%1").arg(envproxy
.port()));
466 ui
.proxyUser
->setText(envproxy
.userName());
467 ui
.proxyPass
->setText(envproxy
.password());
469 if(envproxy
.host().isEmpty() || envproxy
.port() == -1) {
470 qDebug() << "[Config] sytem proxy is invalid.";
471 QMessageBox::warning(this, tr("Proxy Detection"),
472 tr("The System Proxy settings are invalid!\n"
473 "Rockbox Utility can't work with this proxy settings. "
474 "Make sure the system proxy is set correctly. Note that "
475 "\"proxy auto-config (PAC)\" scripts are not supported by "
476 "Rockbox Utility. If your system uses this you need "
477 "to use manual proxy settings."),
478 QMessageBox::Ok
,QMessageBox::Ok
);
479 // the current proxy settings are invalid. Check the saved proxy
481 if(RbSettings::value(RbSettings::ProxyType
).toString() == "manual")
482 ui
.radioManualProxy
->setChecked(true);
484 ui
.radioNoProxy
->setChecked(true);
489 ui
.proxyHost
->setText(proxy
.host());
491 ui
.proxyPort
->setText(QString("%1").arg(proxy
.port()));
492 else ui
.proxyPort
->setText("");
493 ui
.proxyUser
->setText(proxy
.userName());
494 ui
.proxyPass
->setText(proxy
.password());
500 QStringList
Config::findLanguageFiles()
502 QDir
dir(programPath
);
503 QStringList fileNames
;
505 fileNames
= dir
.entryList(QStringList("*.qm"), QDir::Files
, QDir::Name
);
507 QDir
resDir(":/lang");
508 fileNames
+= resDir
.entryList(QStringList("*.qm"), QDir::Files
, QDir::Name
);
510 QRegExp
exp("^rbutil_(.*)\\.qm");
511 for(int i
= 0; i
< fileNames
.size(); i
++) {
512 QString a
= fileNames
.at(i
);
513 a
.replace(exp
, "\\1");
517 qDebug() << "[Config] available lang files:" << langs
;
523 QString
Config::languageName(const QString
&qmFile
)
525 QTranslator translator
;
527 QString file
= "rbutil_" + qmFile
;
528 if(!translator
.load(file
, programPath
))
529 translator
.load(file
, ":/lang");
531 return translator
.translate("Configure", "English",
532 "This is the localized language name, i.e. your language.");
536 void Config::updateLanguage()
538 qDebug() << "[Config] update selected language";
539 QList
<QListWidgetItem
*> a
= ui
.listLanguages
->selectedItems();
541 language
= lang
.value(a
.at(0)->text());
542 qDebug() << "[Config] new language:" << language
;
546 void Config::browseFolder()
548 browser
= new BrowseDirtree(this,tr("Select your device"));
549 #if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
550 browser
->setFilter(QDir::AllDirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
);
551 #elif defined(Q_OS_WIN32)
552 browser
->setFilter(QDir::Drives
);
554 #if defined(Q_OS_MACX)
555 browser
->setRoot("/Volumes");
556 #elif defined(Q_OS_LINUX)
557 browser
->setDir("/media");
559 if( ui
.mountPoint
->text() != "" )
561 browser
->setDir(ui
.mountPoint
->text());
564 connect(browser
, SIGNAL(itemChanged(QString
)), this, SLOT(setMountpoint(QString
)));
568 void Config::browseCache()
570 QString old
= ui
.cachePath
->text();
571 if(!QFileInfo(old
).isDir())
572 old
= QDir::tempPath();
573 QString c
= QFileDialog::getExistingDirectory(this, tr("Set Cache Path"), old
);
576 else if(!QFileInfo(c
).isDir())
577 c
= QDir::tempPath();
578 ui
.cachePath
->setText(QDir::toNativeSeparators(c
));
583 void Config::setMountpoint(QString m
)
585 ui
.mountPoint
->setText(m
);
589 void Config::autodetect()
591 Autodetection
detector(this);
592 // disable tree during detection as "working" feedback.
593 // TODO: replace the tree view with a splash screen during this time.
594 ui
.treeDevices
->setEnabled(false);
595 this->setCursor(Qt::WaitCursor
);
596 QCoreApplication::processEvents();
598 if(detector
.detect()) //let it detect
600 QString devicename
= detector
.getDevice();
601 // deexpand all items
602 for(int a
= 0; a
< ui
.treeDevices
->topLevelItemCount(); a
++)
603 ui
.treeDevices
->topLevelItem(a
)->setExpanded(false);
604 //deselect the selected item(s)
605 for(int a
= 0; a
< ui
.treeDevices
->selectedItems().size(); a
++)
606 ui
.treeDevices
->selectedItems().at(a
)->setSelected(false);
609 // enumerate all platform items
610 QList
<QTreeWidgetItem
*> itmList
611 = ui
.treeDevices
->findItems("*",Qt::MatchWildcard
);
612 for(int i
=0; i
< itmList
.size();i
++)
614 //enumerate device items
615 for(int j
=0;j
< itmList
.at(i
)->childCount();j
++)
617 QString data
= itmList
.at(i
)->child(j
)->data(0, Qt::UserRole
).toString();
619 if(devicename
== data
) // item found
621 itmList
.at(i
)->child(j
)->setSelected(true); //select the item
622 itmList
.at(i
)->setExpanded(true); //expand the platform item
623 //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
624 ui
.treeDevices
->scrollToItem(itmList
.at(i
)->child(j
));
631 if(!detector
.errdev().isEmpty()) {
633 if(detector
.errdev() == "sansae200")
634 text
= tr("Sansa e200 in MTP mode found!\n"
635 "You need to change your player to MSC mode for installation. ");
636 if(detector
.errdev() == "h10")
637 text
= tr("H10 20GB in MTP mode found!\n"
638 "You need to change your player to UMS mode for installation. ");
639 if(SystemInfo::platformValue(detector
.errdev(),
640 SystemInfo::CurBootloaderMethod
) == "ipod")
641 text
= tr("%1 \"MacPod\" found!\n"
642 "Rockbox needs a FAT formatted Ipod (so-called \"WinPod\") "
643 "to run. ").arg(SystemInfo::platformValue(
644 detector
.errdev(), SystemInfo::CurName
).toString());
645 text
+= tr("Unless you changed this installation will fail!");
647 QMessageBox::critical(this, tr("Fatal error"), text
, QMessageBox::Ok
);
650 if(!detector
.incompatdev().isEmpty()) {
652 text
= tr("Detected an unsupported player:\n%1\n"
653 "Sorry, Rockbox doesn't run on your player.")
654 .arg(SystemInfo::platformValue(detector
.incompatdev(),
655 SystemInfo::CurName
).toString());
657 QMessageBox::critical(this, tr("Fatal: player incompatible"),
658 text
, QMessageBox::Ok
);
662 if(detector
.getMountPoint() != "" )
664 ui
.mountPoint
->setText(QDir::toNativeSeparators(detector
.getMountPoint()));
668 QMessageBox::warning(this, tr("Autodetection"),
669 tr("Could not detect a Mountpoint.\n"
670 "Select your Mountpoint manually."),
671 QMessageBox::Ok
,QMessageBox::Ok
);
677 QMessageBox::warning(this, tr("Autodetection"),
678 tr("Could not detect a device.\n"
679 "Select your device and Mountpoint manually."),
680 QMessageBox::Ok
,QMessageBox::Ok
);
683 ui
.treeDevices
->setEnabled(true);
687 void Config::cacheClear()
689 if(QMessageBox::critical(this, tr("Really delete cache?"),
690 tr("Do you really want to delete the cache? "
691 "Make absolutely sure this setting is correct as it will "
692 "remove <b>all</b> files in this folder!").arg(ui
.cachePath
->text()),
693 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
696 QString cache
= ui
.cachePath
->text() + "/rbutil-cache/";
697 if(!QFileInfo(cache
).isDir()) {
698 QMessageBox::critical(this, tr("Path wrong!"),
699 tr("The cache path is invalid. Aborting."), QMessageBox::Ok
);
704 fn
= dir
.entryList(QStringList("*"), QDir::Files
, QDir::Name
);
706 for(int i
= 0; i
< fn
.size(); i
++) {
707 QString f
= cache
+ fn
.at(i
);
710 updateCacheInfo(RbSettings::value(RbSettings::CachePath
).toString());
714 void Config::configTts()
716 int index
= ui
.comboTts
->currentIndex();
717 TTSBase
* tts
= TTSBase::getTTS(this,ui
.comboTts
->itemData(index
).toString());
719 EncTtsCfgGui
gui(this,tts
,TTSBase::getTTSName(ui
.comboTts
->itemData(index
).toString()));
721 updateTtsState(ui
.comboTts
->currentIndex());
722 delete tts
; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
723 since that would delete the TTSBase instance on application exit*/
726 void Config::testTts()
729 int index
= ui
.comboTts
->currentIndex();
730 TTSBase
* tts
= TTSBase::getTTS(this,ui
.comboTts
->itemData(index
).toString());
733 QMessageBox::warning(this,tr("TTS configuration invalid"),
734 tr("TTS configuration invalid. \n Please configure TTS engine."));
738 if(!tts
->start(&errstr
))
740 QMessageBox::warning(this,tr("Could not start TTS engine."),
741 tr("Could not start TTS engine.\n") + errstr
742 + tr("\nPlease configure TTS engine."));
746 QTemporaryFile
file(this);
748 QString filename
= file
.fileName();
751 if(tts
->voice(tr("Rockbox Utility Voice Test"),filename
,&errstr
) == FatalError
)
754 QMessageBox::warning(this,tr("Could not voice test string."),
755 tr("Could not voice test string.\n") + errstr
756 + tr("\nPlease configure TTS engine."));
760 #if defined(Q_OS_LINUX)
761 QString exe
= findExecutable("aplay");
762 if(exe
== "") exe
= findExecutable("play");
765 QProcess::execute(exe
+" "+filename
);
768 QSound::play(filename
);
771 delete tts
; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
772 since that would delete the TTSBase instance on application exit*/
775 void Config::configEnc()
777 if(ui
.treeDevices
->selectedItems().size() == 0)
780 QString devname
= ui
.treeDevices
->selectedItems().at(0)->data(0, Qt::UserRole
).toString();
781 QString encoder
= SystemInfo::platformValue(devname
,
782 SystemInfo::CurEncoder
).toString();
783 ui
.encoderName
->setText(EncBase::getEncoderName(SystemInfo::platformValue(devname
,
784 SystemInfo::CurEncoder
).toString()));
787 EncBase
* enc
= EncBase::getEncoder(this,encoder
);
789 EncTtsCfgGui
gui(this,enc
,EncBase::getEncoderName(encoder
));