2007-07-25 20:21:06 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Dominik Riebeling
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-01-27 11:01:56 +00:00
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QProgressDialog>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QUrl>
|
2020-07-27 19:15:37 +00:00
|
|
|
#ifdef QT_MULTIMEDIA_LIB
|
2013-04-03 21:43:27 +00:00
|
|
|
#include <QSound>
|
2020-07-27 19:15:37 +00:00
|
|
|
#endif
|
2007-07-25 20:21:06 +00:00
|
|
|
|
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"
|
2012-01-06 19:19:32 +00:00
|
|
|
#include "encoderbase.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 "systeminfo.h"
|
2020-11-28 19:47:28 +00:00
|
|
|
#include "playerbuildinfo.h"
|
2009-06-27 15:04:53 +00:00
|
|
|
#include "utils.h"
|
2011-07-16 22:08:03 +00:00
|
|
|
#include "comboboxviewdelegate.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
|
2011-10-02 14:30:05 +00:00
|
|
|
#include "rbutilqt.h"
|
2007-07-29 18:41:15 +00:00
|
|
|
|
2012-01-06 19:19:32 +00:00
|
|
|
#include "systrace.h"
|
2013-11-03 10:08:18 +00:00
|
|
|
#include "Logger.h"
|
2012-01-06 19:19:32 +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);
|
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++;
|
|
|
|
}
|
2011-07-16 22:08:03 +00:00
|
|
|
|
|
|
|
ComboBoxViewDelegate *delegate = new ComboBoxViewDelegate(this);
|
|
|
|
ui.mountPoint->setItemDelegate(delegate);
|
|
|
|
#if !defined(DBG)
|
|
|
|
ui.mountPoint->setEditable(false);
|
|
|
|
#endif
|
|
|
|
|
2007-07-29 18:09:41 +00:00
|
|
|
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)));
|
2011-07-15 19:14:26 +00:00
|
|
|
connect(ui.refreshMountPoint, SIGNAL(clicked()), this, SLOT(refreshMountpoint()));
|
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)));
|
2011-07-15 19:14:26 +00:00
|
|
|
connect(ui.mountPoint, SIGNAL(editTextChanged(QString)), this, SLOT(updateMountpoint(QString)));
|
|
|
|
connect(ui.mountPoint, SIGNAL(currentIndexChanged(int)), this, SLOT(updateMountpoint(int)));
|
2013-03-19 21:01:36 +00:00
|
|
|
connect(ui.checkShowProxyPassword, SIGNAL(toggled(bool)), this, SLOT(showProxyPassword(bool)));
|
2011-04-03 14:04:21 +00:00
|
|
|
// delete this dialog after it finished automatically.
|
|
|
|
connect(this, SIGNAL(finished(int)), this, SLOT(deleteLater()));
|
|
|
|
|
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()
|
|
|
|
{
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "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());
|
2020-07-27 16:40:44 +00:00
|
|
|
proxy.setPort(ui.proxyPort->value());
|
2007-07-29 18:41:15 +00:00
|
|
|
}
|
2009-02-24 23:36:31 +00:00
|
|
|
|
2013-03-19 21:20:23 +00:00
|
|
|
// Encode the password using base64 before storing it to the configuration
|
|
|
|
// file.
|
|
|
|
// There are two reasons for doing this:
|
|
|
|
// - QUrl::toEncoded() has problems with some characters like the colon and
|
|
|
|
// @. Those are not percent encoded, causing the string getting parsed
|
|
|
|
// wrongly when reading it back (see FS#12166).
|
|
|
|
// - The password is cleartext in the configuration file.
|
|
|
|
// While using base64 doesn't provide any real security either it's at
|
|
|
|
// least better than plaintext.
|
|
|
|
// Since this program is open source any fixed mechanism to obfuscate /
|
|
|
|
// encrypt the password isn't much help either since anyone interested in
|
|
|
|
// the password can look at the sources. The best way would be to
|
|
|
|
// eventually use host OS functionality to store the password.
|
|
|
|
QUrl p = proxy;
|
|
|
|
p.setPassword(proxy.password().toUtf8().toBase64());
|
|
|
|
RbSettings::setValue(RbSettings::Proxy, p.toString());
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "setting proxy to:" << proxy.toString(QUrl::RemovePassword);
|
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
|
|
|
|
2011-02-04 23:28:34 +00:00
|
|
|
RbSettings::setValue(RbSettings::Language, language);
|
2007-07-29 18:09:41 +00:00
|
|
|
|
2012-04-24 21:02:24 +00:00
|
|
|
// make sure mountpoint is read from dropdown box
|
2012-04-30 20:06:59 +00:00
|
|
|
if(mountpoint.isEmpty()) {
|
|
|
|
updateMountpoint(ui.mountPoint->currentIndex());
|
|
|
|
}
|
2012-04-24 21:02:24 +00:00
|
|
|
|
2007-08-03 16:55:27 +00:00
|
|
|
// mountpoint
|
2011-07-15 19:14:26 +00:00
|
|
|
if(mountpoint.isEmpty()) {
|
2009-02-24 23:36:31 +00:00
|
|
|
errormsg += "<li>" + tr("No mountpoint given") + "</li>";
|
|
|
|
error = true;
|
|
|
|
}
|
2020-11-19 19:52:09 +00:00
|
|
|
else if(!QFileInfo::exists(mountpoint)) {
|
2009-02-24 23:36:31 +00:00
|
|
|
errormsg += "<li>" + tr("Mountpoint does not exist") + "</li>";
|
|
|
|
error = true;
|
|
|
|
}
|
2011-07-15 19:14:26 +00:00
|
|
|
else if(!QFileInfo(mountpoint).isDir()) {
|
2009-02-24 23:36:31 +00:00
|
|
|
errormsg += "<li>" + tr("Mountpoint is not a directory.") + "</li>";
|
|
|
|
error = true;
|
|
|
|
}
|
2011-07-15 19:14:26 +00:00
|
|
|
else if(!QFileInfo(mountpoint).isWritable()) {
|
2009-02-24 23:36:31 +00:00
|
|
|
errormsg += "<li>" + tr("Mountpoint is not writeable") + "</li>";
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
else {
|
2011-07-15 19:14:26 +00:00
|
|
|
RbSettings::setValue(RbSettings::Mountpoint,
|
|
|
|
QDir::fromNativeSeparators(mountpoint));
|
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());
|
2007-08-27 17:40:35 +00:00
|
|
|
|
2007-08-28 23:10:42 +00:00
|
|
|
// tts settings
|
2011-10-01 19:48:58 +00:00
|
|
|
RbSettings::setValue(RbSettings::UseTtsCorrections, ui.ttsCorrections->isChecked());
|
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()
|
|
|
|
{
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "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
|
2013-03-19 21:20:23 +00:00
|
|
|
proxy.setUrl(RbSettings::value(RbSettings::Proxy).toString(),
|
|
|
|
QUrl::StrictMode);
|
|
|
|
// password is base64 encoded in configuration.
|
|
|
|
QByteArray pw = QByteArray::fromBase64(proxy.password().toUtf8());
|
|
|
|
proxy.setPassword(pw);
|
2007-07-25 20:21:06 +00:00
|
|
|
|
2020-07-27 16:40:44 +00:00
|
|
|
ui.proxyPort->setValue(proxy.port());
|
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
|
2011-07-15 19:14:26 +00:00
|
|
|
refreshMountpoint();
|
2011-07-17 08:08:51 +00:00
|
|
|
mountpoint = QDir::toNativeSeparators(RbSettings::value(RbSettings::Mountpoint).toString());
|
2011-07-15 19:14:26 +00:00
|
|
|
setMountpoint(mountpoint);
|
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());
|
|
|
|
updateCacheInfo(RbSettings::value(RbSettings::CachePath).toString());
|
2011-10-01 19:48:58 +00:00
|
|
|
|
|
|
|
// TTS tab
|
|
|
|
ui.ttsCorrections->setChecked(RbSettings::value(RbSettings::UseTtsCorrections).toBool());
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-19 21:01:36 +00:00
|
|
|
void Config::showProxyPassword(bool show)
|
|
|
|
{
|
|
|
|
if(show)
|
|
|
|
ui.proxyPass->setEchoMode(QLineEdit::Normal);
|
|
|
|
else
|
|
|
|
ui.proxyPass->setEchoMode(QLineEdit::Password);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-04 21:10:20 +00:00
|
|
|
void Config::showDisabled(bool show)
|
|
|
|
{
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "disabled targets shown:" << show;
|
2010-02-04 21:10:20 +00:00
|
|
|
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
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "setting up devices list";
|
2009-06-07 10:17:03 +00:00
|
|
|
|
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
|
|
|
|
2020-08-08 16:20:28 +00:00
|
|
|
QMultiMap <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
|
|
|
{
|
2020-11-28 19:47:28 +00:00
|
|
|
QString curbrand = PlayerBuildInfo::instance()->value(
|
|
|
|
PlayerBuildInfo::Brand, platformList.at(it)).toString();
|
2020-08-08 16:20:28 +00:00
|
|
|
manuf.insert(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;
|
2020-11-19 19:36:57 +00:00
|
|
|
QTreeWidgetItem *w3 = nullptr;
|
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
|
2020-11-28 19:47:28 +00:00
|
|
|
QString curname = QString("%1 (%2)").arg(
|
|
|
|
PlayerBuildInfo::instance()->value(PlayerBuildInfo::DisplayName,
|
|
|
|
platformList.at(it)).toString(),
|
|
|
|
PlayerBuildInfo::instance()->statusAsString(platformList.at(it)));
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "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);
|
2020-11-19 19:36:57 +00:00
|
|
|
if(w3 != nullptr) {
|
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
|
|
|
|
2012-10-06 10:42:20 +00:00
|
|
|
if(!tts)
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, tr("TTS error"),
|
|
|
|
tr("The selected TTS failed to initialize. You can't use this TTS."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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"));
|
2020-09-27 10:37:28 +00:00
|
|
|
ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.svg")));
|
2020-07-27 19:15:37 +00:00
|
|
|
#ifdef QT_MULTIMEDIA_LIB
|
2011-03-13 14:57:58 +00:00
|
|
|
ui.testTTS->setEnabled(true);
|
2020-07-27 19:15:37 +00:00
|
|
|
#else
|
|
|
|
ui.testTTS->setEnabled(false);
|
|
|
|
#endif
|
2007-12-15 13:13:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-06 16:23:51 +00:00
|
|
|
ui.configTTSstatus->setText(tr("Configuration INVALID"));
|
2020-09-27 10:37:28 +00:00
|
|
|
ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.svg")));
|
2011-03-13 14:57:58 +00:00
|
|
|
ui.testTTS->setEnabled(false);
|
2008-02-06 21:51:35 +00:00
|
|
|
}
|
2011-07-17 08:08:51 +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();
|
2020-11-28 19:47:28 +00:00
|
|
|
QString encoder = PlayerBuildInfo::instance()->value(
|
|
|
|
PlayerBuildInfo::Encoder, devname).toString();
|
|
|
|
ui.encoderName->setText(EncoderBase::getEncoderName(
|
|
|
|
PlayerBuildInfo::instance()->value(PlayerBuildInfo::Encoder, devname).toString()));
|
2008-07-06 19:57:22 +00:00
|
|
|
|
2012-01-06 19:19:32 +00:00
|
|
|
EncoderBase* enc = EncoderBase::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"));
|
2020-09-27 10:37:28 +00:00
|
|
|
ui.configEncstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.svg")));
|
2007-12-14 19:26:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-06 16:23:51 +00:00
|
|
|
ui.configEncstatus->setText(tr("Configuration INVALID"));
|
2020-09-27 10:37:28 +00:00
|
|
|
ui.configEncstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.svg")));
|
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)
|
|
|
|
{
|
2013-03-19 21:01:36 +00:00
|
|
|
ui.proxyPort->setEnabled(!checked);
|
|
|
|
ui.proxyHost->setEnabled(!checked);
|
|
|
|
ui.proxyUser->setEnabled(!checked);
|
|
|
|
ui.proxyPass->setEnabled(!checked);
|
|
|
|
ui.checkShowProxyPassword->setEnabled(!checked);
|
|
|
|
ui.checkShowProxyPassword->setChecked(false);
|
|
|
|
showProxyPassword(false);
|
2007-07-25 20:21:06 +00:00
|
|
|
}
|
|
|
|
|
2007-07-29 18:09:41 +00:00
|
|
|
|
2007-07-29 18:41:15 +00:00
|
|
|
void Config::setSystemProxy(bool checked)
|
|
|
|
{
|
2013-03-19 21:01:36 +00:00
|
|
|
setNoProxy(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());
|
2020-07-27 16:40:44 +00:00
|
|
|
proxy.setPort(ui.proxyPort->value());
|
2007-07-29 18:41:15 +00:00
|
|
|
// show system values in input box
|
2009-08-10 19:46:51 +00:00
|
|
|
QUrl envproxy = System::systemProxy();
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "setting system proxy" << envproxy;
|
2007-12-23 10:11:51 +00:00
|
|
|
|
|
|
|
ui.proxyHost->setText(envproxy.host());
|
2020-07-27 16:40:44 +00:00
|
|
|
ui.proxyPort->setValue(envproxy.port());
|
2007-09-23 13:12:34 +00:00
|
|
|
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) {
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_WARNING() << "system proxy is invalid.";
|
2010-04-02 10:59:38 +00:00
|
|
|
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());
|
2020-07-27 16:40:44 +00:00
|
|
|
ui.proxyPort->setValue(proxy.port());
|
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();
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "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()
|
|
|
|
{
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "update selected language";
|
2011-10-02 14:30:05 +00:00
|
|
|
|
|
|
|
// remove all old translators
|
|
|
|
for(int i = 0; i < RbUtilQt::translators.size(); ++i) {
|
|
|
|
qApp->removeTranslator(RbUtilQt::translators.at(i));
|
|
|
|
// do not delete old translators, this confuses Qt.
|
|
|
|
}
|
|
|
|
RbUtilQt::translators.clear();
|
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());
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "new language:" << language;
|
2011-10-02 14:30:05 +00:00
|
|
|
|
|
|
|
QTranslator *translator = new QTranslator(qApp);
|
|
|
|
QTranslator *qttrans = new QTranslator(qApp);
|
|
|
|
QString absolutePath = QCoreApplication::instance()->applicationDirPath();
|
|
|
|
|
|
|
|
if(!translator->load("rbutil_" + language, absolutePath))
|
|
|
|
translator->load("rbutil_" + language, ":/lang");
|
|
|
|
if(!qttrans->load("qt_" + language,
|
|
|
|
QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
|
|
|
qttrans->load("qt_" + language, ":/lang");
|
|
|
|
|
|
|
|
qApp->installTranslator(translator);
|
|
|
|
qApp->installTranslator(qttrans);
|
2011-10-02 15:27:52 +00:00
|
|
|
//: This string is used to indicate the writing direction. Translate it
|
|
|
|
//: to "RTL" (without quotes) for RTL languages. Anything else will get
|
|
|
|
//: treated as LTR language.
|
|
|
|
if(QObject::tr("LTR") == "RTL")
|
|
|
|
qApp->setLayoutDirection(Qt::RightToLeft);
|
|
|
|
else
|
|
|
|
qApp->setLayoutDirection(Qt::LeftToRight);
|
|
|
|
|
2011-10-02 14:30:05 +00:00
|
|
|
RbUtilQt::translators.append(translator);
|
|
|
|
RbUtilQt::translators.append(qttrans);
|
|
|
|
|
2020-07-25 18:36:58 +00:00
|
|
|
QLocale::setDefault(QLocale(language));
|
2011-10-02 14:30:05 +00:00
|
|
|
|
2007-07-29 18:09:41 +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
|
|
|
|
2011-07-15 19:14:26 +00:00
|
|
|
void Config::refreshMountpoint()
|
|
|
|
{
|
|
|
|
// avoid QComboBox to send signals during rebuild to avoid changing to an
|
|
|
|
// unwanted item.
|
|
|
|
ui.mountPoint->blockSignals(true);
|
|
|
|
ui.mountPoint->clear();
|
2013-06-09 17:47:25 +00:00
|
|
|
QStringList mps = Utils::mountpoints(Utils::MountpointsSupported);
|
2011-07-15 19:14:26 +00:00
|
|
|
for(int i = 0; i < mps.size(); ++i) {
|
|
|
|
// add mountpoint as user data so we can change the displayed string
|
|
|
|
// later (to include volume label or similar)
|
|
|
|
// Skip unwritable mountpoints, they are not useable for us.
|
|
|
|
if(QFileInfo(mps.at(i)).isWritable()) {
|
2014-01-05 15:12:16 +00:00
|
|
|
QString description = tr("%1 (%2 GiB of %3 GiB free)")
|
2011-07-16 22:08:03 +00:00
|
|
|
.arg(Utils::filesystemName(mps.at(i)))
|
2011-07-15 19:14:26 +00:00
|
|
|
.arg((double)Utils::filesystemFree(mps.at(i))/(1<<30), 0, 'f', 2)
|
2011-07-16 22:08:03 +00:00
|
|
|
.arg((double)Utils::filesystemTotal(mps.at(i))/(1<<30), 0, 'f', 2);
|
|
|
|
ui.mountPoint->addItem(QDir::toNativeSeparators(mps.at(i)), description);
|
2011-07-15 19:14:26 +00:00
|
|
|
}
|
2013-08-18 16:47:39 +00:00
|
|
|
else {
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_WARNING() << "mountpoint not writable, skipping:" << mps.at(i);
|
2013-08-18 16:47:39 +00:00
|
|
|
}
|
2011-07-15 19:14:26 +00:00
|
|
|
}
|
|
|
|
if(!mountpoint.isEmpty()) {
|
|
|
|
setMountpoint(mountpoint);
|
|
|
|
}
|
|
|
|
ui.mountPoint->blockSignals(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Config::updateMountpoint(QString m)
|
|
|
|
{
|
|
|
|
if(!m.isEmpty()) {
|
2011-07-16 22:08:03 +00:00
|
|
|
mountpoint = QDir::fromNativeSeparators(m);
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "Mountpoint set to" << mountpoint;
|
2011-07-15 19:14:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Config::updateMountpoint(int idx)
|
|
|
|
{
|
|
|
|
if(idx == -1) {
|
|
|
|
return;
|
|
|
|
}
|
2011-07-16 22:08:03 +00:00
|
|
|
QString mp = ui.mountPoint->itemText(idx);
|
2011-07-15 19:14:26 +00:00
|
|
|
if(!mp.isEmpty()) {
|
2011-07-16 22:08:03 +00:00
|
|
|
mountpoint = QDir::fromNativeSeparators(mp);
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "Mountpoint set to" << mountpoint;
|
2011-07-15 19:14:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-07 16:48:45 +00:00
|
|
|
void Config::setMountpoint(QString m)
|
|
|
|
{
|
2011-07-15 19:14:26 +00:00
|
|
|
if(m.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-07-16 22:08:03 +00:00
|
|
|
int index = ui.mountPoint->findText(QDir::toNativeSeparators(m));
|
2011-07-15 19:14:26 +00:00
|
|
|
if(index != -1) {
|
|
|
|
ui.mountPoint->setCurrentIndex(index);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// keep a mountpoint that is not in the list for convenience (to allow
|
|
|
|
// easier development)
|
2011-07-16 22:08:03 +00:00
|
|
|
ui.mountPoint->addItem(QDir::toNativeSeparators(m));
|
2011-07-15 19:14:26 +00:00
|
|
|
ui.mountPoint->setCurrentIndex(ui.mountPoint->findText(m));
|
|
|
|
}
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "Mountpoint set to" << mountpoint;
|
2007-08-07 16:48:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2013-04-06 19:15:05 +00:00
|
|
|
detector.detect();
|
|
|
|
QList<struct Autodetection::Detected> detected;
|
|
|
|
detected = detector.detected();
|
|
|
|
this->unsetCursor();
|
|
|
|
if(detected.size() > 1) {
|
|
|
|
// FIXME: handle multiple found players.
|
2013-09-16 14:59:09 +00:00
|
|
|
QString msg;
|
|
|
|
msg = tr("Multiple devices have been detected. Please disconnect "
|
|
|
|
"all players but one and try again.");
|
|
|
|
msg += "<br/>";
|
|
|
|
msg += tr("Detected devices:");
|
|
|
|
msg += "<ul>";
|
|
|
|
for(int i = 0; i < detected.size(); ++i) {
|
2013-09-16 20:21:05 +00:00
|
|
|
QString mp = detected.at(i).mountpoint;
|
|
|
|
if(mp.isEmpty()) {
|
|
|
|
mp = tr("(unknown)");
|
|
|
|
}
|
2014-01-05 15:12:16 +00:00
|
|
|
msg += QString("<li>%1</li>").arg(tr("%1 at %2").arg(
|
2020-11-28 19:47:28 +00:00
|
|
|
PlayerBuildInfo::instance()->value(
|
|
|
|
PlayerBuildInfo::DisplayName,
|
|
|
|
detected.at(i).device).toString(),
|
2014-01-05 15:12:16 +00:00
|
|
|
QDir::toNativeSeparators(mp)));
|
2013-09-16 14:59:09 +00:00
|
|
|
}
|
|
|
|
msg += "</ul>";
|
|
|
|
msg += tr("Note: detecting connected devices might be ambiguous. "
|
|
|
|
"You might have less devices connected than listed. "
|
|
|
|
"In this case it might not be possible to detect your "
|
|
|
|
"player unambiguously.");
|
|
|
|
QMessageBox::information(this, tr("Device Detection"), msg);
|
2013-04-06 19:15:05 +00:00
|
|
|
ui.treeDevices->setEnabled(true);
|
|
|
|
}
|
|
|
|
else if(detected.size() == 0) {
|
|
|
|
QMessageBox::warning(this, tr("Device Detection"),
|
|
|
|
tr("Could not detect a device.\n"
|
|
|
|
"Select your device and Mountpoint manually."),
|
|
|
|
QMessageBox::Ok ,QMessageBox::Ok);
|
|
|
|
ui.treeDevices->setEnabled(true);
|
|
|
|
}
|
2013-09-18 21:30:15 +00:00
|
|
|
else if(detected.at(0).status != Autodetection::PlayerOk
|
|
|
|
&& detected.at(0).status != Autodetection::PlayerAmbiguous) {
|
2013-04-06 19:15:05 +00:00
|
|
|
QString msg;
|
|
|
|
switch(detected.at(0).status) {
|
|
|
|
case Autodetection::PlayerIncompatible:
|
|
|
|
msg += tr("Detected an unsupported player:\n%1\n"
|
|
|
|
"Sorry, Rockbox doesn't run on your player.")
|
2020-11-28 19:47:28 +00:00
|
|
|
.arg(PlayerBuildInfo::instance()->value(
|
|
|
|
PlayerBuildInfo::DisplayName,
|
|
|
|
detected.at(0).device).toString());
|
2013-04-06 19:15:05 +00:00
|
|
|
break;
|
|
|
|
case Autodetection::PlayerMtpMode:
|
|
|
|
msg = tr("%1 in MTP mode found!\n"
|
|
|
|
"You need to change your player to MSC mode for installation. ")
|
2020-11-28 19:47:28 +00:00
|
|
|
.arg(PlayerBuildInfo::instance()->value(
|
|
|
|
PlayerBuildInfo::DisplayName,
|
|
|
|
detected.at(0).device).toString());
|
2013-04-06 19:15:05 +00:00
|
|
|
break;
|
|
|
|
case Autodetection::PlayerWrongFilesystem:
|
2020-11-28 19:47:28 +00:00
|
|
|
if(PlayerBuildInfo::instance()->value(
|
|
|
|
PlayerBuildInfo::BootloaderMethod, detected.at(0).device) == "ipod") {
|
2013-04-06 19:15:05 +00:00
|
|
|
msg = tr("%1 \"MacPod\" found!\n"
|
|
|
|
"Rockbox needs a FAT formatted Ipod (so-called \"WinPod\") "
|
2020-11-28 19:47:28 +00:00
|
|
|
"to run. ").arg(PlayerBuildInfo::instance()->value(
|
|
|
|
PlayerBuildInfo::DisplayName,
|
|
|
|
detected.at(0).device).toString());
|
2013-04-06 19:15:05 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
msg = tr("The player contains an incompatible filesystem.\n"
|
|
|
|
"Make sure you selected the correct mountpoint and "
|
|
|
|
"the player is set up to use a filesystem compatible "
|
|
|
|
"with Rockbox.");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Autodetection::PlayerError:
|
|
|
|
default:
|
2013-09-18 21:30:15 +00:00
|
|
|
msg += tr("An unknown error occured during player detection.");
|
2013-04-06 19:15:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
QMessageBox::information(this, tr("Device Detection"), msg);
|
|
|
|
ui.treeDevices->setEnabled(true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
selectDevice(detected.at(0).device, detected.at(0).mountpoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Config::selectDevice(QString device, QString mountpoint)
|
|
|
|
{
|
|
|
|
// collapse all items
|
|
|
|
for(int a = 0; a < ui.treeDevices->topLevelItemCount(); a++)
|
|
|
|
ui.treeDevices->topLevelItem(a)->setExpanded(false);
|
|
|
|
// deselect the selected item(s)
|
|
|
|
for(int a = 0; a < ui.treeDevices->selectedItems().size(); a++)
|
|
|
|
ui.treeDevices->selectedItems().at(a)->setSelected(false);
|
|
|
|
|
|
|
|
// find the new item
|
|
|
|
// enumerate all platform items
|
|
|
|
QList<QTreeWidgetItem*> itmList
|
|
|
|
= ui.treeDevices->findItems("*",Qt::MatchWildcard);
|
|
|
|
for(int i=0; i< itmList.size();i++)
|
2007-08-05 19:48:04 +00:00
|
|
|
{
|
2013-04-06 19:15:05 +00:00
|
|
|
//enumerate device items
|
|
|
|
for(int j=0;j < itmList.at(i)->childCount();j++)
|
2007-08-05 19:48:04 +00:00
|
|
|
{
|
2013-04-06 19:15:05 +00:00
|
|
|
QString data = itmList.at(i)->child(j)->data(0, Qt::UserRole).toString();
|
|
|
|
// unset bold flag
|
|
|
|
QFont f = itmList.at(i)->child(j)->font(0);
|
|
|
|
f.setBold(false);
|
|
|
|
itmList.at(i)->child(j)->setFont(0, f);
|
|
|
|
|
|
|
|
if(device == data) // item found
|
2007-08-05 19:48:04 +00:00
|
|
|
{
|
2013-04-06 19:15:05 +00:00
|
|
|
f.setBold(true);
|
2011-04-22 17:39:05 +00:00
|
|
|
itmList.at(i)->child(j)->setFont(0, f);
|
2013-04-06 19:15:05 +00:00
|
|
|
itmList.at(i)->child(j)->setSelected(true); //select the item
|
|
|
|
itmList.at(i)->setExpanded(true); //expand the platform item
|
|
|
|
//ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j));
|
|
|
|
ui.treeDevices->scrollToItem(itmList.at(i)->child(j));
|
|
|
|
break;
|
2011-03-20 10:26:05 +00:00
|
|
|
}
|
2007-09-14 20:52:38 +00:00
|
|
|
}
|
2013-04-06 19:15:05 +00:00
|
|
|
}
|
|
|
|
this->unsetCursor();
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2013-04-06 19:15:05 +00:00
|
|
|
if(!mountpoint.isEmpty())
|
|
|
|
{
|
|
|
|
setMountpoint(mountpoint);
|
2007-08-05 19:48:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QMessageBox::warning(this, tr("Autodetection"),
|
2013-04-06 19:15:05 +00:00
|
|
|
tr("Could not detect a Mountpoint.\n"
|
|
|
|
"Select your Mountpoint manually."),
|
|
|
|
QMessageBox::Ok, QMessageBox::Ok);
|
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 "
|
2020-11-23 19:43:31 +00:00
|
|
|
"remove <b>all</b> files in this folder!"),
|
2007-08-27 17:40:35 +00:00
|
|
|
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-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());
|
2011-03-13 14:57:58 +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()
|
|
|
|
{
|
2020-07-27 19:15:37 +00:00
|
|
|
#ifdef QT_MULTIMEDIA_LIB
|
2009-06-26 21:52:08 +00:00
|
|
|
QString errstr;
|
|
|
|
int index = ui.comboTts->currentIndex();
|
2011-04-03 08:06:59 +00:00
|
|
|
TTSBase* tts;
|
|
|
|
tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString());
|
2012-10-06 10:42:20 +00:00
|
|
|
if(!tts)
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, tr("TTS error"),
|
|
|
|
tr("The selected TTS failed to initialize. You can't use this TTS."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ui.testTTS->setEnabled(false);
|
2009-06-26 21:52:08 +00:00
|
|
|
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."));
|
2011-03-13 14:57:58 +00:00
|
|
|
ui.testTTS->setEnabled(true);
|
2009-06-26 21:52:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-03-13 14:57:58 +00:00
|
|
|
|
2011-04-03 08:06:59 +00:00
|
|
|
QString filename;
|
2011-04-22 15:38:41 +00:00
|
|
|
QTemporaryFile file(this);
|
|
|
|
// keep filename empty if the TTS can do speaking for itself.
|
2011-04-03 08:06:59 +00:00
|
|
|
if(!(tts->capabilities() & TTSBase::CanSpeak)) {
|
|
|
|
file.open();
|
|
|
|
filename = file.fileName();
|
|
|
|
file.close();
|
|
|
|
}
|
2011-03-13 14:57:58 +00:00
|
|
|
|
2009-06-26 21:52:08 +00:00
|
|
|
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."));
|
2011-03-13 14:57:58 +00:00
|
|
|
ui.testTTS->setEnabled(false);
|
2009-06-26 21:52:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-08-11 17:02:35 +00:00
|
|
|
tts->stop();
|
2011-04-22 15:38:41 +00:00
|
|
|
if(!filename.isEmpty()) {
|
2011-04-03 08:06:59 +00:00
|
|
|
QSound::play(filename);
|
|
|
|
}
|
2011-03-13 14:57:58 +00:00
|
|
|
ui.testTTS->setEnabled(true);
|
|
|
|
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 */
|
2020-07-27 19:15:37 +00:00
|
|
|
#endif
|
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();
|
2020-11-28 19:47:28 +00:00
|
|
|
QString encoder = PlayerBuildInfo::instance()->value(
|
|
|
|
PlayerBuildInfo::Encoder, devname).toString();
|
|
|
|
ui.encoderName->setText(
|
|
|
|
EncoderBase::getEncoderName(PlayerBuildInfo::instance()->value(
|
|
|
|
PlayerBuildInfo::Encoder, devname).toString()));
|
2009-04-29 21:27:01 +00:00
|
|
|
|
|
|
|
|
2012-01-06 19:19:32 +00:00
|
|
|
EncoderBase* enc = EncoderBase::getEncoder(this,encoder);
|
2009-05-09 16:59:14 +00:00
|
|
|
|
2012-01-06 19:19:32 +00:00
|
|
|
EncTtsCfgGui gui(this,enc,EncoderBase::getEncoderName(encoder));
|
2009-04-29 21:27:01 +00:00
|
|
|
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
|
|
|
|
2011-10-02 14:30:05 +00:00
|
|
|
|
|
|
|
void Config::changeEvent(QEvent *e)
|
|
|
|
{
|
|
|
|
if(e->type() == QEvent::LanguageChange) {
|
|
|
|
ui.retranslateUi(this);
|
2011-10-02 14:36:38 +00:00
|
|
|
updateCacheInfo(ui.cachePath->text());
|
2011-10-02 14:30:05 +00:00
|
|
|
} else {
|
|
|
|
QWidget::changeEvent(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|