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 ****************************************************************************/
22 #include "configure.h"
23 #include "autodetection.h"
24 #include "ui_configurefrm.h"
25 #include "browsedirtree.h"
28 #if defined(Q_OS_WIN32)
36 #define DEFAULT_LANG "English (C)"
38 Config::Config(QWidget
*parent
) : QDialog(parent
)
40 programPath
= qApp
->applicationDirPath() + "/";
42 ui
.tabConfiguration
->setCurrentIndex(0);
43 ui
.radioManualProxy
->setChecked(true);
44 QRegExpValidator
*proxyValidator
= new QRegExpValidator(this);
45 QRegExp
validate("[0-9]*");
46 proxyValidator
->setRegExp(validate
);
47 ui
.proxyPort
->setValidator(proxyValidator
);
48 #if !defined(Q_OS_LINUX) && !defined(Q_OS_WIN32)
49 ui
.radioSystemProxy
->setEnabled(false); // not on macox for now
51 // build language list and sort alphabetically
52 QStringList langs
= findLanguageFiles();
53 for(int i
= 0; i
< langs
.size(); ++i
)
54 lang
.insert(languageName(langs
.at(i
)) + tr(" (%1)").arg(langs
.at(i
)), langs
.at(i
));
55 lang
.insert(DEFAULT_LANG
, "");
56 QMap
<QString
, QString
>::const_iterator i
= lang
.constBegin();
57 while (i
!= lang
.constEnd()) {
58 ui
.listLanguages
->addItem(i
.key());
61 ui
.listLanguages
->setSelectionMode(QAbstractItemView::SingleSelection
);
62 connect(ui
.listLanguages
, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage()));
63 ui
.proxyPass
->setEchoMode(QLineEdit::Password
);
64 ui
.treeDevices
->setAlternatingRowColors(true);
65 ui
.listLanguages
->setAlternatingRowColors(true);
69 connect(ui
.buttonOk
, SIGNAL(clicked()), this, SLOT(accept()));
70 connect(ui
.buttonCancel
, SIGNAL(clicked()), this, SLOT(abort()));
71 connect(ui
.radioNoProxy
, SIGNAL(toggled(bool)), this, SLOT(setNoProxy(bool)));
72 connect(ui
.radioSystemProxy
, SIGNAL(toggled(bool)), this, SLOT(setSystemProxy(bool)));
73 connect(ui
.browseMountPoint
, SIGNAL(clicked()), this, SLOT(browseFolder()));
74 connect(ui
.buttonAutodetect
,SIGNAL(clicked()),this,SLOT(autodetect()));
75 connect(ui
.buttonCacheBrowse
, SIGNAL(clicked()), this, SLOT(browseCache()));
76 connect(ui
.buttonCacheClear
, SIGNAL(clicked()), this, SLOT(cacheClear()));
77 connect(ui
.browseTts
, SIGNAL(clicked()), this, SLOT(browseTts()));
78 connect(ui
.browseEncoder
, SIGNAL(clicked()), this, SLOT(browseEnc()));
79 connect(ui
.comboEncoder
, SIGNAL(currentIndexChanged(int)), this, SLOT(updateEncOpts(int)));
80 connect(ui
.comboTts
, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsOpts(int)));
87 qDebug() << "Config::accept()";
88 // proxy: save entered proxy values, not displayed.
89 if(ui
.radioManualProxy
->isChecked()) {
90 proxy
.setScheme("http");
91 proxy
.setUserName(ui
.proxyUser
->text());
92 proxy
.setPassword(ui
.proxyPass
->text());
93 proxy
.setHost(ui
.proxyHost
->text());
94 proxy
.setPort(ui
.proxyPort
->text().toInt());
96 userSettings
->setValue("proxy", proxy
.toString());
97 qDebug() << "new proxy:" << proxy
;
100 if(ui
.radioNoProxy
->isChecked()) proxyType
= "none";
101 else if(ui
.radioSystemProxy
->isChecked()) proxyType
= "system";
102 else proxyType
= "manual";
103 userSettings
->setValue("proxytype", proxyType
);
106 if(userSettings
->value("lang").toString() != language
)
107 QMessageBox::information(this, tr("Language changed"),
108 tr("You need to restart the application for the changed language to take effect."));
109 userSettings
->setValue("lang", language
);
112 QString mp
= ui
.mountPoint
->text();
113 if(QFileInfo(mp
).isDir())
114 userSettings
->setValue("mountpoint", mp
);
118 if(ui
.treeDevices
->selectedItems().size() != 0) {
119 nplat
= ui
.treeDevices
->selectedItems().at(0)->data(0, Qt::UserRole
).toString();
120 userSettings
->setValue("platform", nplat
);
124 if(QFileInfo(ui
.cachePath
->text()).isDir())
125 userSettings
->setValue("cachepath", ui
.cachePath
->text());
126 else // default to system temp path
127 userSettings
->setValue("cachepath", QDir::tempPath());
128 userSettings
->setValue("cachedisable", ui
.cacheDisable
->isChecked());
129 userSettings
->setValue("offline", ui
.cacheOfflineMode
->isChecked());
133 preset
= ui
.comboTts
->itemData(ui
.comboTts
->currentIndex(), Qt::UserRole
).toString();
134 userSettings
->setValue("ttspreset", preset
);
135 userSettings
->beginGroup(preset
);
137 if(QFileInfo(ui
.ttsExecutable
->text()).exists())
138 userSettings
->setValue("binary", ui
.ttsExecutable
->text());
139 userSettings
->setValue("options", ui
.ttsOptions
->text());
140 userSettings
->setValue("language", ui
.ttsLanguage
->text());
141 devices
->beginGroup(preset
);
142 userSettings
->setValue("template", devices
->value("template").toString());
143 userSettings
->setValue("type", devices
->value("tts").toString());
145 userSettings
->endGroup();
148 preset
= ui
.comboEncoder
->itemData(ui
.comboEncoder
->currentIndex(), Qt::UserRole
).toString();
149 userSettings
->setValue("encpreset", preset
);
150 userSettings
->beginGroup(preset
);
152 if(QFileInfo(ui
.encoderExecutable
->text()).isExecutable())
153 userSettings
->setValue("binary", ui
.encoderExecutable
->text());
154 userSettings
->setValue("options", ui
.encoderOptions
->text());
155 devices
->beginGroup(preset
);
156 userSettings
->setValue("template", devices
->value("template").toString());
157 userSettings
->setValue("type", devices
->value("tts").toString());
159 userSettings
->endGroup();
162 userSettings
->sync();
164 emit
settingsUpdated();
170 qDebug() << "Config::abort()";
175 void Config::setUserSettings(QSettings
*user
)
179 proxy
= userSettings
->value("proxy").toString();
182 ui
.proxyPort
->setText(QString("%1").arg(proxy
.port()));
183 else ui
.proxyPort
->setText("");
184 ui
.proxyHost
->setText(proxy
.host());
185 ui
.proxyUser
->setText(proxy
.userName());
186 ui
.proxyPass
->setText(proxy
.password());
188 QString proxyType
= userSettings
->value("proxytype", "system").toString();
189 if(proxyType
== "manual") ui
.radioManualProxy
->setChecked(true);
190 else if(proxyType
== "system") ui
.radioSystemProxy
->setChecked(true);
191 else ui
.radioNoProxy
->setChecked(true);
193 // set language selection
194 QList
<QListWidgetItem
*> a
;
196 // find key for lang value
197 QMap
<QString
, QString
>::const_iterator i
= lang
.constBegin();
198 while (i
!= lang
.constEnd()) {
199 if(i
.value() == userSettings
->value("lang").toString()) {
205 a
= ui
.listLanguages
->findItems(b
, Qt::MatchExactly
);
207 a
= ui
.listLanguages
->findItems(DEFAULT_LANG
, Qt::MatchExactly
);
209 ui
.listLanguages
->setCurrentItem(a
.at(0));
212 ui
.mountPoint
->setText(userSettings
->value("mountpoint").toString());
215 if(!QFileInfo(userSettings
->value("cachepath").toString()).isDir())
216 userSettings
->setValue("cachepath", QDir::tempPath());
217 ui
.cachePath
->setText(userSettings
->value("cachepath").toString());
218 ui
.cacheDisable
->setChecked(userSettings
->value("cachedisable", true).toBool());
219 ui
.cacheOfflineMode
->setChecked(userSettings
->value("offline").toBool());
220 updateCacheInfo(userSettings
->value("cachepath").toString());
224 void Config::updateCacheInfo(QString path
)
227 fs
= QDir(path
+ "/rbutil-cache/").entryInfoList(QDir::Files
| QDir::NoDotAndDotDot
);
229 for(int i
= 0; i
< fs
.size(); i
++) {
230 sz
+= fs
.at(i
).size();
231 qDebug() << fs
.at(i
).fileName() << fs
.at(i
).size();
233 ui
.cacheSize
->setText(tr("Current cache size is %1 kiB.")
238 void Config::setDevices(QSettings
*dev
)
241 // setup devices table
242 qDebug() << "Config::setDevices()";
243 devices
->beginGroup("platforms");
244 QStringList a
= devices
->childKeys();
247 QMap
<QString
, QString
> manuf
;
248 QMap
<QString
, QString
> devcs
;
249 for(int it
= 0; it
< a
.size(); it
++) {
251 devices
->beginGroup("platforms");
252 curdev
= devices
->value(a
.at(it
), "null").toString();
255 devices
->beginGroup(curdev
);
256 curname
= devices
->value("name", "null").toString();
257 QString curbrand
= devices
->value("brand", "").toString();
259 manuf
.insertMulti(curbrand
, curdev
);
260 devcs
.insert(curdev
, curname
);
264 platform
= devcs
.value(userSettings
->value("platform").toString());
266 // set up devices table
267 ui
.treeDevices
->header()->hide();
268 ui
.treeDevices
->expandAll();
269 ui
.treeDevices
->setColumnCount(1);
270 QList
<QTreeWidgetItem
*> items
;
273 QStringList brands
= manuf
.uniqueKeys();
276 QTreeWidgetItem
*w3
= 0;
277 for(int c
= 0; c
< brands
.size(); c
++) {
278 qDebug() << brands
.at(c
);
279 w
= new QTreeWidgetItem();
280 w
->setFlags(Qt::ItemIsEnabled
);
281 w
->setText(0, brands
.at(c
));
284 // go through platforms again for sake of order
285 for(int it
= 0; it
< a
.size(); it
++) {
287 devices
->beginGroup("platforms");
288 curdev
= devices
->value(a
.at(it
), "null").toString();
291 devices
->beginGroup(curdev
);
292 curname
= devices
->value("name", "null").toString();
293 QString curbrand
= devices
->value("brand", "").toString();
294 QString curicon
= devices
->value("icon", "").toString();
296 if(curbrand
!= brands
.at(c
)) continue;
297 qDebug() << "adding:" << brands
.at(c
) << curname
<< curdev
;
298 w2
= new QTreeWidgetItem(w
, QStringList(curname
));
299 w2
->setData(0, Qt::UserRole
, curdev
);
301 // icon.addFile(":/icons/devices/" + curicon + "-tiny.png");
302 // w2->setIcon(0, icon);
303 // ui.treeDevices->setIconSize(QSize(32, 32));
304 if(platform
.contains(curname
)) {
305 w2
->setSelected(true);
306 w
->setExpanded(true);
307 w3
= w2
; // save pointer to hilight old selection
312 ui
.treeDevices
->insertTopLevelItems(0, items
);
314 ui
.treeDevices
->setCurrentItem(w3
); // hilight old selection
319 devices
->beginGroup("encoders");
320 keys
= devices
->allKeys();
321 for(int i
=0; i
< keys
.size();i
++)
322 ui
.comboEncoder
->addItem(devices
->value(keys
.at(i
), "null").toString(),
326 devices
->beginGroup("tts");
327 keys
= devices
->allKeys();
328 for(int i
=0; i
< keys
.size();i
++)
331 devices
->beginGroup(keys
.at(i
));
332 QString os
= devices
->value("os").toString();
334 devices
->beginGroup("tts");
337 ui
.comboTts
->addItem(devices
->value(keys
.at(i
), "null").toString(), keys
.at(i
));
339 #if defined(Q_OS_WIN32)
341 ui
.comboTts
->addItem(devices
->value(keys
.at(i
), "null").toString(), keys
.at(i
));
347 index
= ui
.comboTts
->findData(userSettings
->value("ttspreset").toString(),
348 Qt::UserRole
, Qt::MatchExactly
);
349 if(index
< 0) index
= 0;
350 ui
.comboTts
->setCurrentIndex(index
);
351 updateTtsOpts(index
);
353 index
= ui
.comboEncoder
->findData(userSettings
->value("encpreset").toString(),
354 Qt::UserRole
, Qt::MatchExactly
);
355 if(index
< 0) index
= 0;
356 ui
.comboEncoder
->setCurrentIndex(index
);
357 updateEncOpts(index
);
362 void Config::updateEncOpts(int index
)
364 qDebug() << "updateEncOpts()";
367 QString c
= ui
.comboEncoder
->itemData(index
, Qt::UserRole
).toString();
368 devices
->beginGroup(c
);
369 ui
.encoderOptions
->setText(devices
->value("options").toString());
370 edit
= devices
->value("edit").toBool();
371 ui
.encoderOptions
->setEnabled(edit
);
372 e
= devices
->value("encoder").toString();
375 // try to autodetect encoder
376 #if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
377 QStringList path
= QString(getenv("PATH")).split(":", QString::SkipEmptyParts
);
378 #elif defined(Q_OS_WIN)
379 QStringList path
= QString(getenv("PATH")).split(";", QString::SkipEmptyParts
);
382 ui
.encoderExecutable
->setEnabled(true);
383 for(int i
= 0; i
< path
.size(); i
++) {
384 QString executable
= QDir::fromNativeSeparators(path
.at(i
)) + "/" + e
;
385 #if defined(Q_OS_WIN)
386 executable
+= ".exe";
387 QStringList ex
= executable
.split("\"", QString::SkipEmptyParts
);
388 executable
= ex
.join("");
390 if(QFileInfo(executable
).isExecutable()) {
391 qDebug() << "found:" << executable
;
392 ui
.encoderExecutable
->setText(QDir::toNativeSeparators(executable
));
393 // disallow changing the detected path if non-customizable profile
395 ui
.encoderExecutable
->setEnabled(false);
401 userSettings
->beginGroup(c
);
402 QString temp
= userSettings
->value("binary","null").toString();
403 if(temp
!= "null") ui
.encoderExecutable
->setText(temp
);
404 temp
= userSettings
->value("options","null").toString();
405 if(temp
!= "null") ui
.encoderOptions
->setText(temp
);
406 userSettings
->endGroup();
411 void Config::updateTtsOpts(int index
)
415 bool needsLanguageCfg
;
416 QString c
= ui
.comboTts
->itemData(index
, Qt::UserRole
).toString();
417 devices
->beginGroup(c
);
418 edit
= devices
->value("edit").toBool();
419 needsLanguageCfg
= devices
->value("needslanguagecfg").toBool();
420 ui
.ttsLanguage
->setVisible(needsLanguageCfg
);
421 ui
.ttsLanguageLabel
->setVisible(needsLanguageCfg
);
422 ui
.ttsOptions
->setText(devices
->value("options").toString());
423 ui
.ttsOptions
->setEnabled(devices
->value("edit").toBool());
424 e
= devices
->value("tts").toString();
427 #if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
428 QStringList path
= QString(getenv("PATH")).split(":", QString::SkipEmptyParts
);
429 #elif defined(Q_OS_WIN)
430 QStringList path
= QString(getenv("PATH")).split(";", QString::SkipEmptyParts
);
433 ui
.ttsExecutable
->setEnabled(true);
434 for(int i
= 0; i
< path
.size(); i
++) {
435 QString executable
= QDir::fromNativeSeparators(path
.at(i
)) + "/" + e
;
436 #if defined(Q_OS_WIN)
437 executable
+= ".exe";
438 QStringList ex
= executable
.split("\"", QString::SkipEmptyParts
);
439 executable
= ex
.join("");
441 qDebug() << executable
;
442 if(QFileInfo(executable
).isExecutable()) {
443 ui
.ttsExecutable
->setText(QDir::toNativeSeparators(executable
));
444 // disallow changing the detected path if non-customizable profile
446 ui
.ttsExecutable
->setEnabled(false);
452 userSettings
->beginGroup(c
);
453 QString temp
= userSettings
->value("binary","null").toString();
454 if(temp
!= "null") ui
.ttsExecutable
->setText(temp
);
455 temp
= userSettings
->value("options","null").toString();
456 if(temp
!= "null") ui
.ttsOptions
->setText(temp
);
457 temp
= userSettings
->value("language","null").toString();
458 if(temp
!= "null") ui
.ttsLanguage
->setText(temp
);
459 userSettings
->endGroup();
463 void Config::setNoProxy(bool checked
)
466 ui
.proxyPort
->setEnabled(i
);
467 ui
.proxyHost
->setEnabled(i
);
468 ui
.proxyUser
->setEnabled(i
);
469 ui
.proxyPass
->setEnabled(i
);
473 void Config::setSystemProxy(bool checked
)
476 ui
.proxyPort
->setEnabled(i
);
477 ui
.proxyHost
->setEnabled(i
);
478 ui
.proxyUser
->setEnabled(i
);
479 ui
.proxyPass
->setEnabled(i
);
481 // save values in input box
482 proxy
.setScheme("http");
483 proxy
.setUserName(ui
.proxyUser
->text());
484 proxy
.setPassword(ui
.proxyPass
->text());
485 proxy
.setHost(ui
.proxyHost
->text());
486 proxy
.setPort(ui
.proxyPort
->text().toInt());
487 // show system values in input box
489 #if defined(Q_OS_LINUX)
490 envproxy
= QUrl(getenv("http_proxy"));
492 #if defined(Q_OS_WIN32)
494 wchar_t proxyval
[80];
498 ret
= RegOpenKeyEx(HKEY_CURRENT_USER
, _TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"),
499 0, KEY_QUERY_VALUE
, &hk
);
500 if(ret
!= ERROR_SUCCESS
) return;
502 ret
= RegQueryValueEx(hk
, _TEXT("ProxyServer"), NULL
, NULL
, (LPBYTE
)proxyval
, &buflen
);
503 if(ret
!= ERROR_SUCCESS
) return;
506 envproxy
= QUrl("http://" + QString::fromWCharArray(proxyval
));
507 qDebug() << envproxy
;
508 ui
.proxyHost
->setText(envproxy
.host());
509 ui
.proxyPort
->setText(QString("%1").arg(envproxy
.port()));
510 ui
.proxyUser
->setText(envproxy
.userName());
511 ui
.proxyPass
->setText(envproxy
.password());
513 ui
.proxyHost
->setText(envproxy
.host());
514 ui
.proxyPort
->setText(QString("%1").arg(envproxy
.port()));
515 ui
.proxyUser
->setText(envproxy
.userName());
516 ui
.proxyPass
->setText(envproxy
.password());
520 ui
.proxyHost
->setText(proxy
.host());
522 ui
.proxyPort
->setText(QString("%1").arg(proxy
.port()));
523 else ui
.proxyPort
->setText("");
524 ui
.proxyUser
->setText(proxy
.userName());
525 ui
.proxyPass
->setText(proxy
.password());
531 QStringList
Config::findLanguageFiles()
533 QDir
dir(programPath
);
534 QStringList fileNames
;
536 fileNames
= dir
.entryList(QStringList("*.qm"), QDir::Files
, QDir::Name
);
538 QDir
resDir(":/lang");
539 fileNames
+= resDir
.entryList(QStringList("*.qm"), QDir::Files
, QDir::Name
);
541 QRegExp
exp("^rbutil_(.*)\\.qm");
542 for(int i
= 0; i
< fileNames
.size(); i
++) {
543 QString a
= fileNames
.at(i
);
544 a
.replace(exp
, "\\1");
548 qDebug() << "Config::findLanguageFiles()" << langs
;
554 QString
Config::languageName(const QString
&qmFile
)
556 QTranslator translator
;
558 QString file
= "rbutil_" + qmFile
;
559 if(!translator
.load(file
, programPath
))
560 translator
.load(file
, ":/lang");
562 return translator
.translate("Configure", "English");
566 void Config::updateLanguage()
568 qDebug() << "updateLanguage()";
569 QList
<QListWidgetItem
*> a
= ui
.listLanguages
->selectedItems();
571 language
= lang
.value(a
.at(0)->text());
572 qDebug() << language
;
576 void Config::browseFolder()
578 browser
= new BrowseDirtree(this,tr("Select your device"));
579 #if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
580 browser
->setFilter(QDir::AllDirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
);
581 #elif defined(Q_OS_WIN32)
582 browser
->setFilter(QDir::Drives
);
584 #if defined(Q_OS_MACX)
585 browser
->setRoot("/Volumes");
586 #elif defined(Q_OS_LINUX)
587 browser
->setDir("/media");
589 if( ui
.mountPoint
->text() != "" )
591 browser
->setDir(ui
.mountPoint
->text());
594 connect(browser
, SIGNAL(itemChanged(QString
)), this, SLOT(setMountpoint(QString
)));
598 void Config::browseCache()
600 cbrowser
= new BrowseDirtree(this);
601 #if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
602 cbrowser
->setFilter(QDir::AllDirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
);
603 #elif defined(Q_OS_WIN32)
604 cbrowser
->setFilter(QDir::Drives
);
606 cbrowser
->setDir(ui
.cachePath
->text());
608 connect(cbrowser
, SIGNAL(itemChanged(QString
)), this, SLOT(setCache(QString
)));
611 void Config::setMountpoint(QString m
)
613 ui
.mountPoint
->setText(m
);
617 void Config::setCache(QString c
)
619 ui
.cachePath
->setText(c
);
624 void Config::autodetect()
626 Autodetection
detector(this);
628 if(detector
.detect()) //let it detect
630 QString devicename
= detector
.getDevice();
631 // deexpand all items
632 for(int a
= 0; a
< ui
.treeDevices
->topLevelItemCount(); a
++)
633 ui
.treeDevices
->topLevelItem(a
)->setExpanded(false);
634 //deselect the selected item(s)
635 for(int a
= 0; a
< ui
.treeDevices
->selectedItems().size(); a
++)
636 ui
.treeDevices
->selectedItems().at(a
)->setSelected(false);
639 // enumerate all platform items
640 QList
<QTreeWidgetItem
*> itmList
= ui
.treeDevices
->findItems("*",Qt::MatchWildcard
);
641 for(int i
=0; i
< itmList
.size();i
++)
643 //enumerate device items
644 for(int j
=0;j
< itmList
.at(i
)->childCount();j
++)
646 QString data
= itmList
.at(i
)->child(j
)->data(0, Qt::UserRole
).toString();
648 if(devicename
== data
) // item found
650 itmList
.at(i
)->child(j
)->setSelected(true); //select the item
651 itmList
.at(i
)->setExpanded(true); //expand the platform item
652 //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
658 if(!detector
.errdev().isEmpty()) {
660 if(detector
.errdev() == "sansae200")
661 text
= tr("Sansa e200 in MTP mode found!\n"
662 "You need to change your player to MSC mode for installation. ");
663 if(detector
.errdev() == "h10")
664 text
= tr("H10 20GB in MTP mode found!\n"
665 "You need to change your player to UMS mode for installation. ");
666 text
+= tr("Unless you changed this installation will fail!");
668 QMessageBox::critical(this, tr("Fatal error"), text
, QMessageBox::Ok
);
672 if(detector
.getMountPoint() != "" )
674 ui
.mountPoint
->setText(detector
.getMountPoint());
678 QMessageBox::warning(this, tr("Autodetection"),
679 tr("Could not detect a Mountpoint.\n"
680 "Select your Mountpoint manually."),
681 QMessageBox::Ok
,QMessageBox::Ok
);
686 QMessageBox::warning(this, tr("Autodetection"),
687 tr("Could not detect a device.\n"
688 "Select your device and Mountpoint manually."),
689 QMessageBox::Ok
,QMessageBox::Ok
);
694 void Config::cacheClear()
696 if(QMessageBox::critical(this, tr("Really delete cache?"),
697 tr("Do you really want to delete the cache? "
698 "Make absolutely sure this setting is correct as it will "
699 "remove <b>all</b> files in this folder!").arg(ui
.cachePath
->text()),
700 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
703 QString cache
= ui
.cachePath
->text() + "/rbutil-cache/";
704 if(!QFileInfo(cache
).isDir()) {
705 QMessageBox::critical(this, tr("Path wrong!"),
706 tr("The cache path is invalid. Aborting."), QMessageBox::Ok
);
711 fn
= dir
.entryList(QStringList("*"), QDir::Files
, QDir::Name
);
714 for(int i
= 0; i
< fn
.size(); i
++) {
715 QString f
= cache
+ fn
.at(i
);
717 qDebug() << "removed:" << f
;
719 updateCacheInfo(userSettings
->value("cachepath").toString());
723 void Config::browseTts()
725 BrowseDirtree
browser(this);
726 browser
.setFilter(QDir::Dirs
| QDir::Files
| QDir::NoDotAndDotDot
);
728 if(QFileInfo(ui
.ttsExecutable
->text()).isDir())
730 browser
.setDir(ui
.ttsExecutable
->text());
732 if(browser
.exec() == QDialog::Accepted
)
734 qDebug() << browser
.getSelected();
735 QString exe
= browser
.getSelected();
736 if(!QFileInfo(exe
).exists())
738 ui
.ttsExecutable
->setText(exe
);
744 void Config::browseEnc()
746 BrowseDirtree
browser(this);
747 browser
.setFilter(QDir::Dirs
| QDir::Files
| QDir::NoDotAndDotDot
);
749 if(QFileInfo(ui
.encoderExecutable
->text()).isDir())
751 browser
.setDir(ui
.encoderExecutable
->text());
753 if(browser
.exec() == QDialog::Accepted
)
755 qDebug() << browser
.getSelected();
756 QString exe
= browser
.getSelected();
757 if(!QFileInfo(exe
).isExecutable())
759 ui
.encoderExecutable
->setText(exe
);