2007-07-25 20:21:06 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Dominik Riebeling
|
2007-07-29 18:09:41 +00:00
|
|
|
* $Id$
|
2007-07-25 20:21:06 +00:00
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <QtGui>
|
|
|
|
|
2008-07-07 21:40:44 +00:00
|
|
|
#include "version.h"
|
2007-07-25 20:21:06 +00:00
|
|
|
#include "configure.h"
|
2007-08-05 19:48:04 +00:00
|
|
|
#include "autodetection.h"
|
2007-07-25 20:21:06 +00:00
|
|
|
#include "ui_configurefrm.h"
|
2007-08-07 16:48:45 +00:00
|
|
|
#include "browsedirtree.h"
|
2007-12-14 19:26:54 +00:00
|
|
|
#include "encoders.h"
|
2009-10-13 19:54:27 +00:00
|
|
|
#include "ttsbase.h"
|
2009-08-10 19:46:51 +00:00
|
|
|
#include "system.h"
|
2009-04-29 21:27:01 +00:00
|
|
|
#include "encttscfggui.h"
|
2009-05-09 16:59:14 +00:00
|
|
|
#include "rbsettings.h"
|
2010-01-24 21:12:11 +00:00
|
|
|
#include "serverinfo.h"
|
|
|
|
#include "systeminfo.h"
|
2009-06-27 15:04:53 +00:00
|
|
|
#include "utils.h"
|
2007-07-29 18:41:15 +00:00
|
|
|
#include <stdio.h>
|
2007-09-23 13:12:34 +00:00
|
|
|
#if defined(Q_OS_WIN32)
|
|
|
|
#if defined(UNICODE)
|
|
|
|
#define _UNICODE
|
|
|
|
#endif
|
|
|
|
#include <tchar.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
2007-07-29 18:41:15 +00:00
|
|
|
|
2008-07-25 19:28:24 +00:00
|
|
|
#define DEFAULT_LANG "English (en)"
|
2008-08-14 21:32:32 +00:00
|
|
|
#define DEFAULT_LANG_CODE "en"
|
2007-07-29 18:09:41 +00:00
|
|
|
|
2007-12-14 19:49:11 +00:00
|
|
|
Config::Config(QWidget *parent,int index) : QDialog(parent)
|
2007-07-25 20:21:06 +00:00
|
|
|
{
|
2007-08-12 20:40:50 +00:00
|
|
|
programPath = qApp->applicationDirPath() + "/";
|
2007-07-25 20:21:06 +00:00
|
|
|
ui.setupUi(this);
|
2007-12-14 19:49:11 +00:00
|
|
|
ui.tabConfiguration->setCurrentIndex(index);
|
2007-07-25 20:21:06 +00:00
|
|
|
ui.radioManualProxy->setChecked(true);
|
|
|
|
QRegExpValidator *proxyValidator = new QRegExpValidator(this);
|
|
|
|
QRegExp validate("[0-9]*");
|
|
|
|
proxyValidator->setRegExp(validate);
|
|
|
|
ui.proxyPort->setValidator(proxyValidator);
|
2010-04-02 19:22:32 +00:00
|
|
|
|
2007-07-29 18:09:41 +00:00
|
|
|
// build language list and sort alphabetically
|
|
|
|
QStringList langs = findLanguageFiles();
|
|
|
|
for(int i = 0; i < langs.size(); ++i)
|
2008-08-14 21:32:32 +00:00
|
|
|
lang.insert(languageName(langs.at(i))
|
|
|
|
+ QString(" (%1)").arg(langs.at(i)), langs.at(i));
|
|
|
|
lang.insert(DEFAULT_LANG, DEFAULT_LANG_CODE);
|
2007-07-29 18:09:41 +00:00
|
|
|
QMap<QString, QString>::const_iterator i = lang.constBegin();
|
|
|
|
while (i != lang.constEnd()) {
|
|
|
|
ui.listLanguages->addItem(i.key());
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
ui.listLanguages->setSelectionMode(QAbstractItemView::SingleSelection);
|
2007-08-01 07:10:10 +00:00
|
|
|
ui.proxyPass->setEchoMode(QLineEdit::Password);
|
2007-08-12 19:18:11 +00:00
|
|
|
ui.treeDevices->setAlternatingRowColors(true);
|
|
|
|
ui.listLanguages->setAlternatingRowColors(true);
|
2007-07-29 18:09:41 +00:00
|
|
|
|
2009-10-31 17:16:34 +00:00
|
|
|
/* Explicitly set some widgets to have left-to-right layout */
|
|
|
|
ui.treeDevices->setLayoutDirection(Qt::LeftToRight);
|
|
|
|
ui.mountPoint->setLayoutDirection(Qt::LeftToRight);
|
|
|
|
ui.proxyHost->setLayoutDirection(Qt::LeftToRight);
|
|
|
|
ui.proxyPort->setLayoutDirection(Qt::LeftToRight);
|
|
|
|
ui.proxyUser->setLayoutDirection(Qt::LeftToRight);
|
|
|
|
ui.proxyPass->setLayoutDirection(Qt::LeftToRight);
|
|
|
|
ui.listLanguages->setLayoutDirection(Qt::LeftToRight);
|
|
|
|
ui.cachePath->setLayoutDirection(Qt::LeftToRight);
|
2010-01-03 20:04:45 +00:00
|
|
|
ui.comboTts->setLayoutDirection(Qt::LeftToRight);
|
2009-10-31 17:16:34 +00:00
|
|
|
|
2007-07-30 19:35:48 +00:00
|
|
|
this->setModal(true);
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-07-25 20:21:06 +00:00
|
|
|
connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
|
|
|
|
connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(abort()));
|
|
|
|
connect(ui.radioNoProxy, SIGNAL(toggled(bool)), this, SLOT(setNoProxy(bool)));
|
2007-07-29 18:41:15 +00:00
|
|
|
connect(ui.radioSystemProxy, SIGNAL(toggled(bool)), this, SLOT(setSystemProxy(bool)));
|
2007-08-02 21:29:31 +00:00
|
|
|
connect(ui.browseMountPoint, SIGNAL(clicked()), this, SLOT(browseFolder()));
|
2007-08-05 19:48:04 +00:00
|
|
|
connect(ui.buttonAutodetect,SIGNAL(clicked()),this,SLOT(autodetect()));
|
2007-08-27 17:40:35 +00:00
|
|
|
connect(ui.buttonCacheBrowse, SIGNAL(clicked()), this, SLOT(browseCache()));
|
|
|
|
connect(ui.buttonCacheClear, SIGNAL(clicked()), this, SLOT(cacheClear()));
|
2007-12-15 13:13:57 +00:00
|
|
|
connect(ui.configTts, SIGNAL(clicked()), this, SLOT(configTts()));
|
2007-12-14 19:26:54 +00:00
|
|
|
connect(ui.configEncoder, SIGNAL(clicked()), this, SLOT(configEnc()));
|
2007-12-15 13:13:57 +00:00
|
|
|
connect(ui.comboTts, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsState(int)));
|
2008-07-06 19:57:22 +00:00
|
|
|
connect(ui.treeDevices, SIGNAL(itemSelectionChanged()), this, SLOT(updateEncState()));
|
2009-06-26 21:52:08 +00:00
|
|
|
connect(ui.testTTS,SIGNAL(clicked()),this,SLOT(testTts()));
|
2010-02-04 21:10:20 +00:00
|
|
|
connect(ui.showDisabled, SIGNAL(toggled(bool)), this, SLOT(showDisabled(bool)));
|
2009-05-09 16:59:14 +00:00
|
|
|
setUserSettings();
|
|
|
|
setDevices();
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
|
2009-08-08 12:12:49 +00:00
|
|
|
|
2007-07-25 20:21:06 +00:00
|
|
|
void Config::accept()
|
|
|
|
{
|
2009-06-07 10:17:03 +00:00
|
|
|
qDebug() << "[Config] checking configuration";
|
2009-02-24 23:36:31 +00:00
|
|
|
QString errormsg = tr("The following errors occurred:") + "<ul>";
|
|
|
|
bool error = false;
|
|
|
|
|
2007-07-29 18:09:41 +00:00
|
|
|
// proxy: save entered proxy values, not displayed.
|
2007-07-29 18:41:15 +00:00
|
|
|
if(ui.radioManualProxy->isChecked()) {
|
|
|
|
proxy.setScheme("http");
|
|
|
|
proxy.setUserName(ui.proxyUser->text());
|
|
|
|
proxy.setPassword(ui.proxyPass->text());
|
|
|
|
proxy.setHost(ui.proxyHost->text());
|
|
|
|
proxy.setPort(ui.proxyPort->text().toInt());
|
|
|
|
}
|
2009-02-24 23:36:31 +00:00
|
|
|
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::setValue(RbSettings::Proxy, proxy.toString());
|
2009-06-07 10:17:03 +00:00
|
|
|
qDebug() << "[Config] setting proxy to:" << proxy;
|
2007-07-29 18:09:41 +00:00
|
|
|
// proxy type
|
2007-07-25 20:21:06 +00:00
|
|
|
QString proxyType;
|
|
|
|
if(ui.radioNoProxy->isChecked()) proxyType = "none";
|
|
|
|
else if(ui.radioSystemProxy->isChecked()) proxyType = "system";
|
|
|
|
else proxyType = "manual";
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::setValue(RbSettings::ProxyType, proxyType);
|
2007-07-25 20:21:06 +00:00
|
|
|
|
2007-07-29 18:09:41 +00:00
|
|
|
// language
|
2009-08-08 12:12:49 +00:00
|
|
|
if(RbSettings::value(RbSettings::Language).toString() != language
|
|
|
|
&& !language.isEmpty()) {
|
2007-07-29 18:09:41 +00:00
|
|
|
QMessageBox::information(this, tr("Language changed"),
|
2011-02-04 23:28:34 +00:00
|
|
|
tr("You need to restart the application for the changed language "
|
|
|
|
"to take effect."));
|
2008-08-14 21:32:32 +00:00
|
|
|
}
|
2011-02-04 23:28:34 +00:00
|
|
|
RbSettings::setValue(RbSettings::Language, language);
|
2007-07-29 18:09:41 +00:00
|
|
|
|
2007-08-03 16:55:27 +00:00
|
|
|
// mountpoint
|
|
|
|
QString mp = ui.mountPoint->text();
|
2009-02-24 23:36:31 +00:00
|
|
|
if(mp.isEmpty()) {
|
|
|
|
errormsg += "<li>" + tr("No mountpoint given") + "</li>";
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
else if(!QFileInfo(mp).exists()) {
|
|
|
|
errormsg += "<li>" + tr("Mountpoint does not exist") + "</li>";
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
else if(!QFileInfo(mp).isDir()) {
|
|
|
|
errormsg += "<li>" + tr("Mountpoint is not a directory.") + "</li>";
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
else if(!QFileInfo(mp).isWritable()) {
|
|
|
|
errormsg += "<li>" + tr("Mountpoint is not writeable") + "</li>";
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
else {
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::setValue(RbSettings::Mountpoint, QDir::fromNativeSeparators(mp));
|
2009-02-24 23:36:31 +00:00
|
|
|
}
|
2007-08-03 16:55:27 +00:00
|
|
|
|
|
|
|
// platform
|
|
|
|
QString nplat;
|
2007-08-10 00:01:44 +00:00
|
|
|
if(ui.treeDevices->selectedItems().size() != 0) {
|
|
|
|
nplat = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::setValue(RbSettings::Platform, nplat);
|
2007-08-10 00:01:44 +00:00
|
|
|
}
|
2009-02-24 23:36:31 +00:00
|
|
|
else {
|
|
|
|
errormsg += "<li>" + tr("No player selected") + "</li>";
|
|
|
|
error = true;
|
|
|
|
}
|
2007-08-03 16:55:27 +00:00
|
|
|
|
2007-08-27 17:40:35 +00:00
|
|
|
// cache settings
|
2009-02-24 23:36:31 +00:00
|
|
|
if(QFileInfo(ui.cachePath->text()).isDir()) {
|
|
|
|
if(!QFileInfo(ui.cachePath->text()).isWritable()) {
|
|
|
|
errormsg += "<li>" + tr("Cache path not writeable. Leave path empty "
|
|
|
|
"to default to systems temporary path.") + "</li>";
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
else
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::setValue(RbSettings::CachePath, ui.cachePath->text());
|
2009-02-24 23:36:31 +00:00
|
|
|
}
|
2007-08-27 17:40:35 +00:00
|
|
|
else // default to system temp path
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::setValue(RbSettings::CachePath, QDir::tempPath());
|
|
|
|
RbSettings::setValue(RbSettings::CacheDisabled, ui.cacheDisable->isChecked());
|
|
|
|
RbSettings::setValue(RbSettings::CacheOffline, ui.cacheOfflineMode->isChecked());
|
2007-08-27 17:40:35 +00:00
|
|
|
|
2007-08-28 23:10:42 +00:00
|
|
|
// tts settings
|
2008-02-06 21:51:35 +00:00
|
|
|
int i = ui.comboTts->currentIndex();
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::setValue(RbSettings::Tts, ui.comboTts->itemData(i).toString());
|
2009-02-24 23:36:31 +00:00
|
|
|
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::setValue(RbSettings::RbutilVersion, PUREVERSION);
|
2008-07-07 21:40:44 +00:00
|
|
|
|
2009-02-24 23:36:31 +00:00
|
|
|
errormsg += "</ul>";
|
|
|
|
errormsg += tr("You need to fix the above errors before you can continue.");
|
|
|
|
|
|
|
|
if(error) {
|
|
|
|
QMessageBox::critical(this, tr("Configuration error"), errormsg);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// sync settings
|
2009-05-09 16:59:14 +00:00
|
|
|
RbSettings::sync();
|
2009-02-24 23:36:31 +00:00
|
|
|
this->close();
|
|
|
|
emit settingsUpdated();
|
|
|
|
}
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Config::abort()
|
|
|
|
{
|
2009-06-07 10:17:03 +00:00
|
|
|
qDebug() << "[Config] aborted.";
|
2007-07-25 20:21:06 +00:00
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
2009-08-08 12:12:49 +00:00
|
|
|
|
2008-01-19 18:33:33 +00:00
|
|
|
void Config::setUserSettings()
|
|
|
|
{
|
2007-08-02 21:29:31 +00:00
|
|
|
// set proxy
|
2009-05-09 16:59:14 +00:00
|
|
|
proxy = RbSettings::value(RbSettings::Proxy).toString();
|
2007-07-25 20:21:06 +00:00
|
|
|
|
2007-08-03 16:55:27 +00:00
|
|
|
if(proxy.port() > 0)
|
|
|
|
ui.proxyPort->setText(QString("%1").arg(proxy.port()));
|
|
|
|
else ui.proxyPort->setText("");
|
2007-07-29 18:09:41 +00:00
|
|
|
ui.proxyHost->setText(proxy.host());
|
|
|
|
ui.proxyUser->setText(proxy.userName());
|
|
|
|
ui.proxyPass->setText(proxy.password());
|
2007-07-25 20:21:06 +00:00
|
|
|
|
2009-05-09 16:59:14 +00:00
|
|
|
QString proxyType = RbSettings::value(RbSettings::ProxyType).toString();
|
2007-07-25 20:21:06 +00:00
|
|
|
if(proxyType == "manual") ui.radioManualProxy->setChecked(true);
|
|
|
|
else if(proxyType == "system") ui.radioSystemProxy->setChecked(true);
|
2007-08-09 16:01:02 +00:00
|
|
|
else ui.radioNoProxy->setChecked(true);
|
2007-07-25 20:21:06 +00:00
|
|
|
|
2007-07-29 18:09:41 +00:00
|
|
|
// set language selection
|
|
|
|
QList<QListWidgetItem*> a;
|
|
|
|
QString b;
|
|
|
|
// find key for lang value
|
|
|
|
QMap<QString, QString>::const_iterator i = lang.constBegin();
|
2009-05-09 16:59:14 +00:00
|
|
|
QString l = RbSettings::value(RbSettings::Language).toString();
|
2009-04-29 20:58:47 +00:00
|
|
|
if(l.isEmpty())
|
|
|
|
l = QLocale::system().name();
|
2007-07-29 18:09:41 +00:00
|
|
|
while (i != lang.constEnd()) {
|
2009-04-29 20:58:47 +00:00
|
|
|
if(i.value() == l) {
|
2007-07-29 18:09:41 +00:00
|
|
|
b = i.key();
|
|
|
|
break;
|
|
|
|
}
|
2009-04-29 20:58:47 +00:00
|
|
|
else if(l.startsWith(i.value(), Qt::CaseInsensitive)) {
|
2008-07-25 19:28:24 +00:00
|
|
|
// check if there is a base language (en -> en_US, etc.)
|
|
|
|
b = i.key();
|
|
|
|
break;
|
|
|
|
}
|
2007-07-29 18:09:41 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
a = ui.listLanguages->findItems(b, Qt::MatchExactly);
|
|
|
|
if(a.size() > 0)
|
|
|
|
ui.listLanguages->setCurrentItem(a.at(0));
|
2008-07-25 19:28:24 +00:00
|
|
|
// don't connect before language list has been set up to prevent
|
|
|
|
// triggering the signal by selecting the saved language.
|
|
|
|
connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage()));
|
2007-07-29 18:09:41 +00:00
|
|
|
|
2007-08-02 21:29:31 +00:00
|
|
|
// devices tab
|
2009-05-09 16:59:14 +00:00
|
|
|
ui.mountPoint->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::Mountpoint).toString()));
|
2007-08-02 21:29:31 +00:00
|
|
|
|
2007-08-27 17:40:35 +00:00
|
|
|
// cache tab
|
2009-05-09 16:59:14 +00:00
|
|
|
if(!QFileInfo(RbSettings::value(RbSettings::CachePath).toString()).isDir())
|
|
|
|
RbSettings::setValue(RbSettings::CachePath, QDir::tempPath());
|
|
|
|
ui.cachePath->setText(QDir::toNativeSeparators(RbSettings::value(RbSettings::CachePath).toString()));
|
|
|
|
ui.cacheDisable->setChecked(RbSettings::value(RbSettings::CacheDisabled).toBool());
|
|
|
|
ui.cacheOfflineMode->setChecked(RbSettings::value(RbSettings::CacheOffline).toBool());
|
|
|
|
updateCacheInfo(RbSettings::value(RbSettings::CachePath).toString());
|
2007-10-07 18:02:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Config::updateCacheInfo(QString path)
|
|
|
|
{
|
|
|
|
QList<QFileInfo> fs;
|
|
|
|
fs = QDir(path + "/rbutil-cache/").entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
|
2007-08-27 17:40:35 +00:00
|
|
|
qint64 sz = 0;
|
|
|
|
for(int i = 0; i < fs.size(); i++) {
|
|
|
|
sz += fs.at(i).size();
|
|
|
|
}
|
2007-10-07 21:26:53 +00:00
|
|
|
ui.cacheSize->setText(tr("Current cache size is %L1 kiB.")
|
2007-08-27 17:40:35 +00:00
|
|
|
.arg(sz/1024));
|
2007-08-02 21:29:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-04 21:10:20 +00:00
|
|
|
void Config::showDisabled(bool show)
|
|
|
|
{
|
|
|
|
qDebug() << "[Config] disabled targets shown:" << show;
|
|
|
|
if(show)
|
|
|
|
QMessageBox::warning(this, tr("Showing disabled targets"),
|
|
|
|
tr("You just enabled showing targets that are marked disabled. "
|
|
|
|
"Disabled targets are not recommended to end users. Please "
|
|
|
|
"use this option only if you know what you are doing."));
|
|
|
|
setDevices();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-19 18:33:33 +00:00
|
|
|
void Config::setDevices()
|
2007-08-02 21:29:31 +00:00
|
|
|
{
|
2009-06-07 10:17:03 +00:00
|
|
|
|
2007-08-02 21:29:31 +00:00
|
|
|
// setup devices table
|
2009-06-07 10:17:03 +00:00
|
|
|
qDebug() << "[Config] setting up devices list";
|
|
|
|
|
2010-02-04 21:10:20 +00:00
|
|
|
QStringList platformList;
|
|
|
|
if(ui.showDisabled->isChecked())
|
|
|
|
platformList = SystemInfo::platforms(SystemInfo::PlatformAllDisabled);
|
|
|
|
else
|
|
|
|
platformList = SystemInfo::platforms(SystemInfo::PlatformAll);
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-02 21:29:31 +00:00
|
|
|
QMap <QString, QString> manuf;
|
2009-06-07 10:17:03 +00:00
|
|
|
for(int it = 0; it < platformList.size(); it++)
|
2008-01-25 00:12:25 +00:00
|
|
|
{
|
2010-03-01 22:45:17 +00:00
|
|
|
QString curbrand = SystemInfo::platformValue(platformList.at(it),
|
|
|
|
SystemInfo::CurBrand).toString();
|
2008-01-25 00:12:25 +00:00
|
|
|
manuf.insertMulti(curbrand, platformList.at(it));
|
2007-08-02 21:29:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// set up devices table
|
|
|
|
ui.treeDevices->header()->hide();
|
|
|
|
ui.treeDevices->expandAll();
|
|
|
|
ui.treeDevices->setColumnCount(1);
|
|
|
|
QList<QTreeWidgetItem *> items;
|
|
|
|
|
|
|
|
// get manufacturers
|
|
|
|
QStringList brands = manuf.uniqueKeys();
|
|
|
|
QTreeWidgetItem *w;
|
|
|
|
QTreeWidgetItem *w2;
|
2007-08-03 16:30:37 +00:00
|
|
|
QTreeWidgetItem *w3 = 0;
|
2010-03-01 22:45:17 +00:00
|
|
|
|
|
|
|
QString selected = RbSettings::value(RbSettings::Platform).toString();
|
2007-08-02 21:29:31 +00:00
|
|
|
for(int c = 0; c < brands.size(); c++) {
|
|
|
|
w = new QTreeWidgetItem();
|
|
|
|
w->setFlags(Qt::ItemIsEnabled);
|
|
|
|
w->setText(0, brands.at(c));
|
|
|
|
items.append(w);
|
2010-03-01 22:45:17 +00:00
|
|
|
// go through platforms and add all players matching the current brand
|
2008-01-25 00:12:25 +00:00
|
|
|
for(int it = 0; it < platformList.size(); it++) {
|
2010-03-01 22:45:17 +00:00
|
|
|
// skip if not current brand
|
|
|
|
if(!manuf.values(brands.at(c)).contains(platformList.at(it)))
|
|
|
|
continue;
|
|
|
|
// construct display name
|
|
|
|
QString curname = SystemInfo::platformValue(platformList.at(it),
|
|
|
|
SystemInfo::CurName).toString() +
|
|
|
|
" (" +ServerInfo::platformValue(platformList.at(it),
|
|
|
|
ServerInfo::CurStatus).toString() +")";
|
2009-06-07 10:17:03 +00:00
|
|
|
qDebug() << "[Config] add supported device:" << brands.at(c) << curname;
|
2007-08-02 21:29:31 +00:00
|
|
|
w2 = new QTreeWidgetItem(w, QStringList(curname));
|
2008-01-25 00:12:25 +00:00
|
|
|
w2->setData(0, Qt::UserRole, platformList.at(it));
|
|
|
|
|
2010-03-01 22:45:17 +00:00
|
|
|
if(platformList.at(it) == selected) {
|
2007-08-02 21:29:31 +00:00
|
|
|
w2->setSelected(true);
|
|
|
|
w->setExpanded(true);
|
|
|
|
w3 = w2; // save pointer to hilight old selection
|
|
|
|
}
|
|
|
|
items.append(w2);
|
|
|
|
}
|
|
|
|
}
|
2010-02-04 21:10:20 +00:00
|
|
|
// remove any old items in list
|
|
|
|
QTreeWidgetItem* widgetitem;
|
|
|
|
do {
|
|
|
|
widgetitem = ui.treeDevices->takeTopLevelItem(0);
|
|
|
|
delete widgetitem;
|
|
|
|
}
|
|
|
|
while(widgetitem);
|
|
|
|
// add new items
|
2007-08-02 21:29:31 +00:00
|
|
|
ui.treeDevices->insertTopLevelItems(0, items);
|
2010-03-01 22:45:17 +00:00
|
|
|
if(w3 != 0) {
|
2007-08-03 16:30:37 +00:00
|
|
|
ui.treeDevices->setCurrentItem(w3); // hilight old selection
|
2010-03-01 22:45:17 +00:00
|
|
|
ui.treeDevices->scrollToItem(w3);
|
|
|
|
}
|
2007-08-28 23:10:42 +00:00
|
|
|
|
|
|
|
// tts / encoder tab
|
2009-06-07 10:17:03 +00:00
|
|
|
|
2007-12-14 19:26:54 +00:00
|
|
|
//encoders
|
2008-05-10 15:23:15 +00:00
|
|
|
updateEncState();
|
2008-02-06 21:51:35 +00:00
|
|
|
|
2007-12-14 19:26:54 +00:00
|
|
|
//tts
|
2008-02-12 21:45:50 +00:00
|
|
|
QStringList ttslist = TTSBase::getTTSList();
|
2008-02-06 21:51:35 +00:00
|
|
|
for(int a = 0; a < ttslist.size(); a++)
|
2008-02-12 21:45:50 +00:00
|
|
|
ui.comboTts->addItem(TTSBase::getTTSName(ttslist.at(a)), ttslist.at(a));
|
2007-12-15 13:13:57 +00:00
|
|
|
//update index of combobox
|
2009-05-09 16:59:14 +00:00
|
|
|
int index = ui.comboTts->findData(RbSettings::value(RbSettings::Tts).toString());
|
2007-08-30 22:20:11 +00:00
|
|
|
if(index < 0) index = 0;
|
2007-08-28 23:10:42 +00:00
|
|
|
ui.comboTts->setCurrentIndex(index);
|
2007-12-15 13:13:57 +00:00
|
|
|
updateTtsState(index);
|
2009-06-07 10:17:03 +00:00
|
|
|
|
2007-08-28 23:10:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-15 13:13:57 +00:00
|
|
|
void Config::updateTtsState(int index)
|
2007-08-28 23:10:42 +00:00
|
|
|
{
|
2008-02-06 21:51:35 +00:00
|
|
|
QString ttsName = ui.comboTts->itemData(index).toString();
|
2009-04-29 21:27:01 +00:00
|
|
|
TTSBase* tts = TTSBase::getTTS(this,ttsName);
|
2009-06-07 10:17:03 +00:00
|
|
|
|
2007-12-15 13:13:57 +00:00
|
|
|
if(tts->configOk())
|
|
|
|
{
|
2008-07-06 16:23:51 +00:00
|
|
|
ui.configTTSstatus->setText(tr("Configuration OK"));
|
2008-03-27 23:39:49 +00:00
|
|
|
ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
|
2007-12-15 13:13:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-06 16:23:51 +00:00
|
|
|
ui.configTTSstatus->setText(tr("Configuration INVALID"));
|
2008-03-27 23:39:49 +00:00
|
|
|
ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
|
2008-02-06 21:51:35 +00:00
|
|
|
}
|
2010-03-30 17:43:49 +00:00
|
|
|
|
|
|
|
delete tts; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
|
|
|
|
since that would delete the TTSBase instance on application exit*/
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
|
2008-05-10 15:23:15 +00:00
|
|
|
void Config::updateEncState()
|
2007-12-14 19:26:54 +00:00
|
|
|
{
|
2008-07-06 19:57:22 +00:00
|
|
|
if(ui.treeDevices->selectedItems().size() == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
|
2010-01-24 21:12:11 +00:00
|
|
|
QString encoder = SystemInfo::platformValue(devname,
|
|
|
|
SystemInfo::CurEncoder).toString();
|
|
|
|
ui.encoderName->setText(EncBase::getEncoderName(SystemInfo::platformValue(devname,
|
|
|
|
SystemInfo::CurEncoder).toString()));
|
2008-07-06 19:57:22 +00:00
|
|
|
|
2009-04-29 21:27:01 +00:00
|
|
|
EncBase* enc = EncBase::getEncoder(this,encoder);
|
2009-06-07 10:17:03 +00:00
|
|
|
|
2007-12-14 19:26:54 +00:00
|
|
|
if(enc->configOk())
|
|
|
|
{
|
2008-07-06 16:23:51 +00:00
|
|
|
ui.configEncstatus->setText(tr("Configuration OK"));
|
2008-03-27 23:39:49 +00:00
|
|
|
ui.configEncstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
|
2007-12-14 19:26:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-06 16:23:51 +00:00
|
|
|
ui.configEncstatus->setText(tr("Configuration INVALID"));
|
2008-03-27 23:39:49 +00:00
|
|
|
ui.configEncstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
|
2009-06-07 10:17:03 +00:00
|
|
|
}
|
2007-12-14 19:26:54 +00:00
|
|
|
}
|
2007-07-25 20:21:06 +00:00
|
|
|
|
2009-08-08 12:12:49 +00:00
|
|
|
|
2007-07-25 20:21:06 +00:00
|
|
|
void Config::setNoProxy(bool checked)
|
|
|
|
{
|
|
|
|
bool i = !checked;
|
|
|
|
ui.proxyPort->setEnabled(i);
|
|
|
|
ui.proxyHost->setEnabled(i);
|
|
|
|
ui.proxyUser->setEnabled(i);
|
|
|
|
ui.proxyPass->setEnabled(i);
|
|
|
|
}
|
|
|
|
|
2007-07-29 18:09:41 +00:00
|
|
|
|
2007-07-29 18:41:15 +00:00
|
|
|
void Config::setSystemProxy(bool checked)
|
|
|
|
{
|
2010-04-02 10:59:38 +00:00
|
|
|
ui.proxyPort->setEnabled(!checked);
|
|
|
|
ui.proxyHost->setEnabled(!checked);
|
|
|
|
ui.proxyUser->setEnabled(!checked);
|
|
|
|
ui.proxyPass->setEnabled(!checked);
|
2007-07-29 18:41:15 +00:00
|
|
|
if(checked) {
|
|
|
|
// save values in input box
|
|
|
|
proxy.setScheme("http");
|
|
|
|
proxy.setUserName(ui.proxyUser->text());
|
|
|
|
proxy.setPassword(ui.proxyPass->text());
|
|
|
|
proxy.setHost(ui.proxyHost->text());
|
|
|
|
proxy.setPort(ui.proxyPort->text().toInt());
|
|
|
|
// show system values in input box
|
2009-08-10 19:46:51 +00:00
|
|
|
QUrl envproxy = System::systemProxy();
|
2010-04-02 10:59:38 +00:00
|
|
|
qDebug() << "[Config] setting system proxy" << envproxy;
|
2007-12-23 10:11:51 +00:00
|
|
|
|
|
|
|
ui.proxyHost->setText(envproxy.host());
|
2007-09-23 13:12:34 +00:00
|
|
|
ui.proxyPort->setText(QString("%1").arg(envproxy.port()));
|
|
|
|
ui.proxyUser->setText(envproxy.userName());
|
|
|
|
ui.proxyPass->setText(envproxy.password());
|
|
|
|
|
2010-04-02 10:59:38 +00:00
|
|
|
if(envproxy.host().isEmpty() || envproxy.port() == -1) {
|
|
|
|
qDebug() << "[Config] sytem proxy is invalid.";
|
|
|
|
QMessageBox::warning(this, tr("Proxy Detection"),
|
|
|
|
tr("The System Proxy settings are invalid!\n"
|
|
|
|
"Rockbox Utility can't work with this proxy settings. "
|
|
|
|
"Make sure the system proxy is set correctly. Note that "
|
|
|
|
"\"proxy auto-config (PAC)\" scripts are not supported by "
|
|
|
|
"Rockbox Utility. If your system uses this you need "
|
|
|
|
"to use manual proxy settings."),
|
|
|
|
QMessageBox::Ok ,QMessageBox::Ok);
|
|
|
|
// the current proxy settings are invalid. Check the saved proxy
|
|
|
|
// type again.
|
|
|
|
if(RbSettings::value(RbSettings::ProxyType).toString() == "manual")
|
|
|
|
ui.radioManualProxy->setChecked(true);
|
|
|
|
else
|
|
|
|
ui.radioNoProxy->setChecked(true);
|
|
|
|
}
|
|
|
|
|
2007-07-29 18:41:15 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui.proxyHost->setText(proxy.host());
|
2007-08-03 16:55:27 +00:00
|
|
|
if(proxy.port() > 0)
|
|
|
|
ui.proxyPort->setText(QString("%1").arg(proxy.port()));
|
|
|
|
else ui.proxyPort->setText("");
|
2007-07-29 18:41:15 +00:00
|
|
|
ui.proxyUser->setText(proxy.userName());
|
|
|
|
ui.proxyPass->setText(proxy.password());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-29 18:09:41 +00:00
|
|
|
QStringList Config::findLanguageFiles()
|
|
|
|
{
|
2007-08-12 20:40:50 +00:00
|
|
|
QDir dir(programPath);
|
2007-07-29 18:09:41 +00:00
|
|
|
QStringList fileNames;
|
2007-09-03 14:37:00 +00:00
|
|
|
QStringList langs;
|
2007-07-29 18:09:41 +00:00
|
|
|
fileNames = dir.entryList(QStringList("*.qm"), QDir::Files, QDir::Name);
|
|
|
|
|
|
|
|
QDir resDir(":/lang");
|
|
|
|
fileNames += resDir.entryList(QStringList("*.qm"), QDir::Files, QDir::Name);
|
|
|
|
|
2007-09-03 14:37:00 +00:00
|
|
|
QRegExp exp("^rbutil_(.*)\\.qm");
|
|
|
|
for(int i = 0; i < fileNames.size(); i++) {
|
|
|
|
QString a = fileNames.at(i);
|
|
|
|
a.replace(exp, "\\1");
|
|
|
|
langs.append(a);
|
|
|
|
}
|
|
|
|
langs.sort();
|
2009-06-07 10:17:03 +00:00
|
|
|
qDebug() << "[Config] available lang files:" << langs;
|
2007-07-29 18:09:41 +00:00
|
|
|
|
2007-09-03 14:37:00 +00:00
|
|
|
return langs;
|
2007-07-29 18:09:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString Config::languageName(const QString &qmFile)
|
|
|
|
{
|
|
|
|
QTranslator translator;
|
|
|
|
|
2007-09-03 14:37:00 +00:00
|
|
|
QString file = "rbutil_" + qmFile;
|
|
|
|
if(!translator.load(file, programPath))
|
|
|
|
translator.load(file, ":/lang");
|
2007-07-29 18:09:41 +00:00
|
|
|
|
2008-07-05 21:35:23 +00:00
|
|
|
return translator.translate("Configure", "English",
|
|
|
|
"This is the localized language name, i.e. your language.");
|
2007-07-29 18:09:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Config::updateLanguage()
|
|
|
|
{
|
2009-06-07 10:17:03 +00:00
|
|
|
qDebug() << "[Config] update selected language";
|
2007-07-29 18:09:41 +00:00
|
|
|
QList<QListWidgetItem*> a = ui.listLanguages->selectedItems();
|
|
|
|
if(a.size() > 0)
|
2007-09-03 14:37:00 +00:00
|
|
|
language = lang.value(a.at(0)->text());
|
2009-06-07 10:17:03 +00:00
|
|
|
qDebug() << "[Config] new language:" << language;
|
2007-07-29 18:09:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-02 21:29:31 +00:00
|
|
|
void Config::browseFolder()
|
|
|
|
{
|
2007-09-14 20:22:53 +00:00
|
|
|
browser = new BrowseDirtree(this,tr("Select your device"));
|
2007-08-07 16:48:45 +00:00
|
|
|
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
|
|
|
browser->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
|
|
|
#elif defined(Q_OS_WIN32)
|
|
|
|
browser->setFilter(QDir::Drives);
|
|
|
|
#endif
|
2007-09-14 14:37:43 +00:00
|
|
|
#if defined(Q_OS_MACX)
|
|
|
|
browser->setRoot("/Volumes");
|
|
|
|
#elif defined(Q_OS_LINUX)
|
2007-09-14 20:10:54 +00:00
|
|
|
browser->setDir("/media");
|
2007-09-14 14:37:43 +00:00
|
|
|
#endif
|
2007-09-14 19:27:35 +00:00
|
|
|
if( ui.mountPoint->text() != "" )
|
|
|
|
{
|
2007-09-14 20:10:54 +00:00
|
|
|
browser->setDir(ui.mountPoint->text());
|
2007-09-14 19:27:35 +00:00
|
|
|
}
|
2007-08-07 16:48:45 +00:00
|
|
|
browser->show();
|
|
|
|
connect(browser, SIGNAL(itemChanged(QString)), this, SLOT(setMountpoint(QString)));
|
2007-08-02 21:29:31 +00:00
|
|
|
}
|
2007-08-05 19:48:04 +00:00
|
|
|
|
2007-08-07 16:48:45 +00:00
|
|
|
|
2007-08-27 17:40:35 +00:00
|
|
|
void Config::browseCache()
|
|
|
|
{
|
2010-02-16 21:34:39 +00:00
|
|
|
QString old = ui.cachePath->text();
|
|
|
|
if(!QFileInfo(old).isDir())
|
|
|
|
old = QDir::tempPath();
|
|
|
|
QString c = QFileDialog::getExistingDirectory(this, tr("Set Cache Path"), old);
|
|
|
|
if(c.isEmpty())
|
|
|
|
c = old;
|
|
|
|
else if(!QFileInfo(c).isDir())
|
|
|
|
c = QDir::tempPath();
|
|
|
|
ui.cachePath->setText(QDir::toNativeSeparators(c));
|
|
|
|
updateCacheInfo(c);
|
2007-08-27 17:40:35 +00:00
|
|
|
}
|
|
|
|
|
2009-08-08 12:12:49 +00:00
|
|
|
|
2007-08-07 16:48:45 +00:00
|
|
|
void Config::setMountpoint(QString m)
|
|
|
|
{
|
|
|
|
ui.mountPoint->setText(m);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-05 19:48:04 +00:00
|
|
|
void Config::autodetect()
|
|
|
|
{
|
|
|
|
Autodetection detector(this);
|
2008-05-21 22:03:37 +00:00
|
|
|
// disable tree during detection as "working" feedback.
|
|
|
|
// TODO: replace the tree view with a splash screen during this time.
|
|
|
|
ui.treeDevices->setEnabled(false);
|
2008-11-16 11:00:27 +00:00
|
|
|
this->setCursor(Qt::WaitCursor);
|
2008-05-21 22:27:48 +00:00
|
|
|
QCoreApplication::processEvents();
|
2007-08-05 19:48:04 +00:00
|
|
|
|
|
|
|
if(detector.detect()) //let it detect
|
|
|
|
{
|
|
|
|
QString devicename = detector.getDevice();
|
2007-08-30 18:14:56 +00:00
|
|
|
// deexpand all items
|
|
|
|
for(int a = 0; a < ui.treeDevices->topLevelItemCount(); a++)
|
|
|
|
ui.treeDevices->topLevelItem(a)->setExpanded(false);
|
|
|
|
//deselect the selected item(s)
|
2007-09-15 22:57:07 +00:00
|
|
|
for(int a = 0; a < ui.treeDevices->selectedItems().size(); a++)
|
2007-08-30 18:14:56 +00:00
|
|
|
ui.treeDevices->selectedItems().at(a)->setSelected(false);
|
2007-08-05 19:48:04 +00:00
|
|
|
|
|
|
|
// find the new item
|
2007-08-30 16:55:04 +00:00
|
|
|
// enumerate all platform items
|
2010-03-01 22:45:17 +00:00
|
|
|
QList<QTreeWidgetItem*> itmList
|
|
|
|
= ui.treeDevices->findItems("*",Qt::MatchWildcard);
|
2007-08-05 19:48:04 +00:00
|
|
|
for(int i=0; i< itmList.size();i++)
|
|
|
|
{
|
|
|
|
//enumerate device items
|
|
|
|
for(int j=0;j < itmList.at(i)->childCount();j++)
|
|
|
|
{
|
|
|
|
QString data = itmList.at(i)->child(j)->data(0, Qt::UserRole).toString();
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-30 16:55:04 +00:00
|
|
|
if(devicename == data) // item found
|
2007-08-05 19:48:04 +00:00
|
|
|
{
|
|
|
|
itmList.at(i)->child(j)->setSelected(true); //select the item
|
|
|
|
itmList.at(i)->setExpanded(true); //expand the platform item
|
2007-09-03 14:37:00 +00:00
|
|
|
//ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
|
2010-03-01 22:45:17 +00:00
|
|
|
ui.treeDevices->scrollToItem(itmList.at(i)->child(j));
|
2007-08-05 19:48:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-11-16 11:00:27 +00:00
|
|
|
this->unsetCursor();
|
2007-08-05 19:48:04 +00:00
|
|
|
|
2007-09-14 20:52:38 +00:00
|
|
|
if(!detector.errdev().isEmpty()) {
|
|
|
|
QString text;
|
|
|
|
if(detector.errdev() == "sansae200")
|
|
|
|
text = tr("Sansa e200 in MTP mode found!\n"
|
|
|
|
"You need to change your player to MSC mode for installation. ");
|
|
|
|
if(detector.errdev() == "h10")
|
|
|
|
text = tr("H10 20GB in MTP mode found!\n"
|
|
|
|
"You need to change your player to UMS mode for installation. ");
|
2010-02-20 22:11:11 +00:00
|
|
|
if(SystemInfo::platformValue(detector.errdev(),
|
|
|
|
SystemInfo::CurBootloaderMethod) == "ipod")
|
|
|
|
text = tr("%1 \"MacPod\" found!\n"
|
|
|
|
"Rockbox needs a FAT formatted Ipod (so-called \"WinPod\") "
|
|
|
|
"to run. ").arg(SystemInfo::platformValue(
|
|
|
|
detector.errdev(), SystemInfo::CurName).toString());
|
2007-09-14 20:52:38 +00:00
|
|
|
text += tr("Unless you changed this installation will fail!");
|
|
|
|
|
|
|
|
QMessageBox::critical(this, tr("Fatal error"), text, QMessageBox::Ok);
|
|
|
|
return;
|
|
|
|
}
|
2008-04-05 21:48:54 +00:00
|
|
|
if(!detector.incompatdev().isEmpty()) {
|
|
|
|
QString text;
|
2009-08-15 21:29:31 +00:00
|
|
|
text = tr("Detected an unsupported player:\n%1\n"
|
|
|
|
"Sorry, Rockbox doesn't run on your player.")
|
2010-01-24 21:12:11 +00:00
|
|
|
.arg(SystemInfo::platformValue(detector.incompatdev(),
|
|
|
|
SystemInfo::CurName).toString());
|
2009-08-15 21:29:31 +00:00
|
|
|
|
|
|
|
QMessageBox::critical(this, tr("Fatal: player incompatible"),
|
2008-04-05 21:48:54 +00:00
|
|
|
text, QMessageBox::Ok);
|
|
|
|
return;
|
|
|
|
}
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-05 19:48:04 +00:00
|
|
|
if(detector.getMountPoint() != "" )
|
|
|
|
{
|
2008-05-18 10:14:47 +00:00
|
|
|
ui.mountPoint->setText(QDir::toNativeSeparators(detector.getMountPoint()));
|
2007-08-05 19:48:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QMessageBox::warning(this, tr("Autodetection"),
|
|
|
|
tr("Could not detect a Mountpoint.\n"
|
|
|
|
"Select your Mountpoint manually."),
|
|
|
|
QMessageBox::Ok ,QMessageBox::Ok);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-16 11:00:27 +00:00
|
|
|
this->unsetCursor();
|
2007-08-05 19:48:04 +00:00
|
|
|
QMessageBox::warning(this, tr("Autodetection"),
|
|
|
|
tr("Could not detect a device.\n"
|
|
|
|
"Select your device and Mountpoint manually."),
|
|
|
|
QMessageBox::Ok ,QMessageBox::Ok);
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-05 19:48:04 +00:00
|
|
|
}
|
2008-05-21 22:03:37 +00:00
|
|
|
ui.treeDevices->setEnabled(true);
|
2007-08-05 19:48:04 +00:00
|
|
|
}
|
2007-08-07 16:48:45 +00:00
|
|
|
|
2009-08-08 12:12:49 +00:00
|
|
|
|
2007-08-27 17:40:35 +00:00
|
|
|
void Config::cacheClear()
|
|
|
|
{
|
|
|
|
if(QMessageBox::critical(this, tr("Really delete cache?"),
|
|
|
|
tr("Do you really want to delete the cache? "
|
|
|
|
"Make absolutely sure this setting is correct as it will "
|
|
|
|
"remove <b>all</b> files in this folder!").arg(ui.cachePath->text()),
|
|
|
|
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
|
|
|
|
return;
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-08-27 17:40:35 +00:00
|
|
|
QString cache = ui.cachePath->text() + "/rbutil-cache/";
|
|
|
|
if(!QFileInfo(cache).isDir()) {
|
|
|
|
QMessageBox::critical(this, tr("Path wrong!"),
|
|
|
|
tr("The cache path is invalid. Aborting."), QMessageBox::Ok);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QDir dir(cache);
|
|
|
|
QStringList fn;
|
|
|
|
fn = dir.entryList(QStringList("*"), QDir::Files, QDir::Name);
|
|
|
|
|
|
|
|
for(int i = 0; i < fn.size(); i++) {
|
|
|
|
QString f = cache + fn.at(i);
|
|
|
|
QFile::remove(f);
|
|
|
|
}
|
2009-05-09 16:59:14 +00:00
|
|
|
updateCacheInfo(RbSettings::value(RbSettings::CachePath).toString());
|
2007-08-27 17:40:35 +00:00
|
|
|
}
|
2007-08-28 23:10:42 +00:00
|
|
|
|
|
|
|
|
2007-12-15 13:13:57 +00:00
|
|
|
void Config::configTts()
|
2007-08-28 23:10:42 +00:00
|
|
|
{
|
2008-02-06 21:51:35 +00:00
|
|
|
int index = ui.comboTts->currentIndex();
|
2009-04-29 21:27:01 +00:00
|
|
|
TTSBase* tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString());
|
2009-06-07 10:17:03 +00:00
|
|
|
|
2009-06-15 19:41:16 +00:00
|
|
|
EncTtsCfgGui gui(this,tts,TTSBase::getTTSName(ui.comboTts->itemData(index).toString()));
|
2009-04-29 21:27:01 +00:00
|
|
|
gui.exec();
|
2007-12-15 13:13:57 +00:00
|
|
|
updateTtsState(ui.comboTts->currentIndex());
|
2010-03-30 17:43:49 +00:00
|
|
|
delete tts; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
|
|
|
|
since that would delete the TTSBase instance on application exit*/
|
2007-08-28 23:10:42 +00:00
|
|
|
}
|
2007-08-29 17:31:43 +00:00
|
|
|
|
2009-06-26 21:52:08 +00:00
|
|
|
void Config::testTts()
|
|
|
|
{
|
|
|
|
QString errstr;
|
|
|
|
int index = ui.comboTts->currentIndex();
|
|
|
|
TTSBase* tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString());
|
|
|
|
if(!tts->configOk())
|
|
|
|
{
|
2009-08-11 17:02:35 +00:00
|
|
|
QMessageBox::warning(this,tr("TTS configuration invalid"),
|
|
|
|
tr("TTS configuration invalid. \n Please configure TTS engine."));
|
2009-06-26 21:52:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!tts->start(&errstr))
|
|
|
|
{
|
2009-09-25 15:51:17 +00:00
|
|
|
QMessageBox::warning(this,tr("Could not start TTS engine."),
|
2009-08-11 17:02:35 +00:00
|
|
|
tr("Could not start TTS engine.\n") + errstr
|
|
|
|
+ tr("\nPlease configure TTS engine."));
|
2009-06-26 21:52:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QTemporaryFile file(this);
|
|
|
|
file.open();
|
|
|
|
QString filename = file.fileName();
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
if(tts->voice(tr("Rockbox Utility Voice Test"),filename,&errstr) == FatalError)
|
|
|
|
{
|
|
|
|
tts->stop();
|
2009-09-25 15:51:17 +00:00
|
|
|
QMessageBox::warning(this,tr("Could not voice test string."),
|
2009-08-11 17:02:35 +00:00
|
|
|
tr("Could not voice test string.\n") + errstr
|
|
|
|
+ tr("\nPlease configure TTS engine."));
|
2009-06-26 21:52:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-08-11 17:02:35 +00:00
|
|
|
tts->stop();
|
2009-06-27 15:04:53 +00:00
|
|
|
#if defined(Q_OS_LINUX)
|
2010-04-02 21:24:19 +00:00
|
|
|
QString exe = Utils::findExecutable("aplay");
|
|
|
|
if(exe == "") exe = Utils::findExecutable("play");
|
2009-06-27 15:04:53 +00:00
|
|
|
if(exe != "")
|
|
|
|
{
|
|
|
|
QProcess::execute(exe+" "+filename);
|
|
|
|
}
|
2009-08-11 17:02:35 +00:00
|
|
|
#else
|
2009-06-26 21:52:08 +00:00
|
|
|
QSound::play(filename);
|
2009-08-11 17:02:35 +00:00
|
|
|
#endif
|
2010-03-30 17:43:49 +00:00
|
|
|
|
|
|
|
delete tts; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
|
|
|
|
since that would delete the TTSBase instance on application exit*/
|
2009-06-26 21:52:08 +00:00
|
|
|
}
|
2007-08-29 17:31:43 +00:00
|
|
|
|
2007-12-14 19:26:54 +00:00
|
|
|
void Config::configEnc()
|
2007-08-29 17:31:43 +00:00
|
|
|
{
|
2009-04-29 21:27:01 +00:00
|
|
|
if(ui.treeDevices->selectedItems().size() == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
|
2010-01-24 21:12:11 +00:00
|
|
|
QString encoder = SystemInfo::platformValue(devname,
|
|
|
|
SystemInfo::CurEncoder).toString();
|
|
|
|
ui.encoderName->setText(EncBase::getEncoderName(SystemInfo::platformValue(devname,
|
|
|
|
SystemInfo::CurEncoder).toString()));
|
2009-04-29 21:27:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
EncBase* enc = EncBase::getEncoder(this,encoder);
|
2009-05-09 16:59:14 +00:00
|
|
|
|
2009-04-29 21:27:01 +00:00
|
|
|
EncTtsCfgGui gui(this,enc,EncBase::getEncoderName(encoder));
|
|
|
|
gui.exec();
|
|
|
|
|
2008-05-10 15:23:15 +00:00
|
|
|
updateEncState();
|
2007-08-29 17:31:43 +00:00
|
|
|
}
|
2009-08-11 17:02:35 +00:00
|
|
|
|