1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2012 by Dominik Riebeling
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
17 ****************************************************************************/
21 #include "manualwidget.h"
23 #include "rbsettings.h"
24 #include "serverinfo.h"
25 #include "systeminfo.h"
27 ManualWidget::ManualWidget(QWidget
*parent
) : QWidget(parent
)
30 ui
.radioPdf
->setChecked(true);
31 connect(ui
.buttonDownloadManual
, SIGNAL(clicked()), this, SLOT(downloadManual()));
35 QString
ManualWidget::manualUrl(ManualFormat format
)
37 if(RbSettings::value(RbSettings::Platform
).toString().isEmpty()) {
41 QString buildservermodel
= SystemInfo::value(SystemInfo::CurBuildserverModel
).toString();
42 QString modelman
= SystemInfo::value(SystemInfo::CurManual
).toString();
43 QString manualbasename
;
45 if(modelman
.isEmpty()) {
46 manualbasename
= "rockbox-" + buildservermodel
;
49 manualbasename
= "rockbox-" + modelman
;
52 QString manual
= SystemInfo::value(SystemInfo::ManualUrl
).toString();
55 manual
.replace("%EXTENSION%", "pdf");
58 manual
.replace("%EXTENSION%", "html");
59 manualbasename
+= "/rockbox-build";
62 manual
.replace("%EXTENSION%", "zip");
63 manualbasename
+= "-html";
69 manual
.replace("%MANUALBASENAME%", manualbasename
);
74 void ManualWidget::updateManual()
76 if(!RbSettings::value(RbSettings::Platform
).toString().isEmpty())
78 ui
.labelPdfManual
->setText(tr("<a href='%1'>PDF Manual</a>")
79 .arg(manualUrl(ManualPdf
)));
80 ui
.labelHtmlManual
->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
81 .arg(manualUrl(ManualHtml
)));
84 ui
.labelPdfManual
->setText(tr("Select a device for a link to the correct manual"));
85 ui
.labelHtmlManual
->setText(tr("<a href='%1'>Manual Overview</a>")
86 .arg("http://www.rockbox.org/manual.shtml"));
91 void ManualWidget::downloadManual(void)
93 if(RbUtilQt::chkConfig(this)) {
96 if(QMessageBox::question(this, tr("Confirm download"),
97 tr("Do you really want to download the manual? The manual will be saved "
98 "to the root folder of your player."),
99 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) {
102 QString manual
= SystemInfo::value(SystemInfo::CurManual
).toString();
103 if(manual
.isEmpty()) {
104 manual
= "rockbox-" + SystemInfo::value(SystemInfo::CurBuildserverModel
).toString();
107 QDate date
= QDate::fromString(ServerInfo::value(
108 ServerInfo::DailyDate
).toString(), Qt::ISODate
);
111 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
113 ZipInstaller
*installer
= new ZipInstaller(this);
114 installer
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
115 if(!RbSettings::value(RbSettings::CacheDisabled
).toBool())
116 installer
->setCache(true);
118 if(ui
.radioPdf
->isChecked()) {
119 manualurl
= manualUrl(ManualPdf
);
120 installer
->setLogSection("Manual (PDF)");
121 installer
->setTarget("/" + manual
+ ".pdf");
124 manualurl
= manualUrl(ManualZip
);
125 installer
->setLogSection("Manual (HTML)");
126 installer
->setTarget("/" + manual
+ "-" + date
.toString("yyyyMMdd") + "-html.zip");
128 qDebug() << "[ManualWidget] Manual URL:" << manualurl
;
130 installer
->setLogVersion(ServerInfo::value(ServerInfo::DailyDate
).toString());
131 installer
->setUrl(manualurl
);
132 installer
->setUnzip(false);
134 connect(installer
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
135 connect(installer
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
136 connect(installer
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
137 connect(logger
, SIGNAL(aborted()), installer
, SLOT(abort()));
138 installer
->install();