2012-02-14 20:02:52 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 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 <QWidget>
|
|
|
|
#include <QMessageBox>
|
2012-02-14 20:02:52 +00:00
|
|
|
#include <QDebug>
|
|
|
|
#include "manualwidget.h"
|
|
|
|
#include "rbutilqt.h"
|
|
|
|
#include "rbsettings.h"
|
|
|
|
#include "serverinfo.h"
|
|
|
|
#include "systeminfo.h"
|
2013-11-03 10:08:18 +00:00
|
|
|
#include "Logger.h"
|
2012-02-14 20:02:52 +00:00
|
|
|
|
|
|
|
ManualWidget::ManualWidget(QWidget *parent) : QWidget(parent)
|
|
|
|
{
|
|
|
|
ui.setupUi(this);
|
|
|
|
ui.radioPdf->setChecked(true);
|
2012-09-05 20:39:47 +00:00
|
|
|
m_platform = RbSettings::value(RbSettings::Platform).toString();
|
2012-02-14 20:02:52 +00:00
|
|
|
connect(ui.buttonDownloadManual, SIGNAL(clicked()), this, SLOT(downloadManual()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ManualWidget::updateManual()
|
|
|
|
{
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "updating manual URLs";
|
2012-09-05 20:39:47 +00:00
|
|
|
m_platform = RbSettings::value(RbSettings::Platform).toString();
|
|
|
|
if(!m_platform.isEmpty())
|
2012-02-14 20:02:52 +00:00
|
|
|
{
|
|
|
|
ui.labelPdfManual->setText(tr("<a href='%1'>PDF Manual</a>")
|
2012-09-05 20:39:47 +00:00
|
|
|
.arg(ServerInfo::platformValue(m_platform, ServerInfo::ManualPdfUrl).toString()));
|
2012-02-14 20:02:52 +00:00
|
|
|
ui.labelHtmlManual->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
|
2012-09-05 20:39:47 +00:00
|
|
|
.arg(ServerInfo::platformValue(m_platform, ServerInfo::ManualHtmlUrl).toString()));
|
2012-02-14 20:02:52 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui.labelPdfManual->setText(tr("Select a device for a link to the correct manual"));
|
|
|
|
ui.labelHtmlManual->setText(tr("<a href='%1'>Manual Overview</a>")
|
|
|
|
.arg("http://www.rockbox.org/manual.shtml"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ManualWidget::downloadManual(void)
|
|
|
|
{
|
|
|
|
if(RbUtilQt::chkConfig(this)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(QMessageBox::question(this, tr("Confirm download"),
|
|
|
|
tr("Do you really want to download the manual? The manual will be saved "
|
|
|
|
"to the root folder of your player."),
|
|
|
|
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QString manual = SystemInfo::value(SystemInfo::CurManual).toString();
|
|
|
|
if(manual.isEmpty()) {
|
|
|
|
manual = "rockbox-" + SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
ProgressLoggerGui* logger = new ProgressLoggerGui(this);
|
|
|
|
logger->show();
|
|
|
|
ZipInstaller *installer = new ZipInstaller(this);
|
|
|
|
installer->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
|
|
|
|
if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
|
|
|
|
installer->setCache(true);
|
|
|
|
|
|
|
|
if(ui.radioPdf->isChecked()) {
|
2012-09-05 20:39:47 +00:00
|
|
|
installer->setUrl(ServerInfo::platformValue(m_platform,
|
2012-06-18 21:24:00 +00:00
|
|
|
ServerInfo::ManualPdfUrl).toString());
|
2012-02-14 20:02:52 +00:00
|
|
|
installer->setLogSection("Manual (PDF)");
|
|
|
|
installer->setTarget("/" + manual + ".pdf");
|
|
|
|
}
|
|
|
|
else {
|
2012-09-05 20:39:47 +00:00
|
|
|
installer->setUrl(ServerInfo::platformValue(m_platform,
|
2012-06-18 21:24:00 +00:00
|
|
|
ServerInfo::ManualZipUrl).toString());
|
2012-02-14 20:02:52 +00:00
|
|
|
installer->setLogSection("Manual (HTML)");
|
2012-06-02 22:50:01 +00:00
|
|
|
installer->setTarget("/" + manual + "-" + "-html.zip");
|
2012-02-14 20:02:52 +00:00
|
|
|
}
|
2012-05-23 19:05:28 +00:00
|
|
|
installer->setLogVersion();
|
2012-02-14 20:02:52 +00:00
|
|
|
installer->setUnzip(false);
|
|
|
|
|
|
|
|
connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
|
|
|
|
connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
|
|
|
|
connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
|
|
|
|
connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
|
|
|
|
installer->install();
|
|
|
|
}
|
|
|
|
|
2012-06-30 08:50:28 +00:00
|
|
|
|
|
|
|
void ManualWidget::changeEvent(QEvent *e)
|
|
|
|
{
|
|
|
|
if(e->type() == QEvent::LanguageChange) {
|
|
|
|
ui.retranslateUi(this);
|
|
|
|
updateManual();
|
|
|
|
} else {
|
|
|
|
QWidget::changeEvent(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|