Move constructing manual URL to ServerInfo class.
Change-Id: I4d2605b2389b4378e8311fc82057974e0eb238e6
This commit is contained in:
parent
beb61a93c5
commit
4f4e1d1f0e
5 changed files with 39 additions and 50 deletions
|
@ -35,6 +35,9 @@ const static struct {
|
|||
{ ServerInfo::RelCandidateVersion, ":platform:/rcversion", "" },
|
||||
{ ServerInfo::RelCandidateUrl, ":platform:/rcurl", "" },
|
||||
{ ServerInfo::CurStatus, ":platform:/status", "Unknown" },
|
||||
{ ServerInfo::ManualPdfUrl, ":platform:/manual_pdf", "" },
|
||||
{ ServerInfo::ManualHtmlUrl, ":platform:/manual_html", "" },
|
||||
{ ServerInfo::ManualZipUrl, ":platform:/manual_zip", "" },
|
||||
{ ServerInfo::BleedingRevision, "bleedingrev", "" },
|
||||
{ ServerInfo::BleedingDate, "bleedingdate", "" },
|
||||
{ ServerInfo::CurDevelUrl, ":platform:/develurl", "" },
|
||||
|
@ -126,6 +129,28 @@ void ServerInfo::readBuildInfo(QString file)
|
|||
break;
|
||||
}
|
||||
info.endGroup();
|
||||
|
||||
// manual URLs
|
||||
QString manualPdfUrl = manualBaseUrl;
|
||||
QString manualHtmlUrl = manualBaseUrl;
|
||||
QString manualZipUrl = manualBaseUrl;
|
||||
|
||||
QString buildservermodel = SystemInfo::platformValue(platforms.at(i),
|
||||
SystemInfo::CurBuildserverModel).toString();
|
||||
QString modelman = SystemInfo::platformValue(platforms.at(i),
|
||||
SystemInfo::CurManual).toString();
|
||||
QString manualBaseName = "rockbox-";
|
||||
|
||||
if(modelman.isEmpty()) manualBaseName += buildservermodel;
|
||||
else manualBaseName += modelman;
|
||||
|
||||
manualPdfUrl.replace("%EXTENSION%", "pdf");
|
||||
manualPdfUrl.replace("%MANUALBASENAME%", manualBaseName);
|
||||
manualHtmlUrl.replace("%EXTENSION%", "html");
|
||||
manualHtmlUrl.replace("%MANUALBASENAME%", manualBaseName + "/rockbox-build");
|
||||
manualZipUrl.replace("%EXTENSION%", "zip");
|
||||
manualZipUrl.replace("%MANUALBASENAME%", manualBaseName + "-html");
|
||||
|
||||
// set variants (if any)
|
||||
for(int j = 0; j < variants.size(); ++j) {
|
||||
setPlatformValue(variants.at(j), ServerInfo::CurStatus, status);
|
||||
|
@ -138,6 +163,10 @@ void ServerInfo::readBuildInfo(QString file)
|
|||
setPlatformValue(variants.at(j), ServerInfo::RelCandidateUrl, relCandidateUrl);
|
||||
}
|
||||
setPlatformValue(variants.at(j), ServerInfo::CurDevelUrl, develUrl);
|
||||
|
||||
setPlatformValue(variants.at(j), ServerInfo::ManualPdfUrl, manualPdfUrl);
|
||||
setPlatformValue(variants.at(j), ServerInfo::ManualHtmlUrl, manualHtmlUrl);
|
||||
setPlatformValue(variants.at(j), ServerInfo::ManualZipUrl, manualZipUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ class ServerInfo : public QObject
|
|||
CurStatus,
|
||||
CurReleaseUrl,
|
||||
CurDevelUrl,
|
||||
ManualPdfUrl,
|
||||
ManualHtmlUrl,
|
||||
ManualZipUrl,
|
||||
BleedingRevision,
|
||||
BleedingDate,
|
||||
RelCandidateVersion,
|
||||
|
|
|
@ -28,57 +28,19 @@ ManualWidget::ManualWidget(QWidget *parent) : QWidget(parent)
|
|||
{
|
||||
ui.setupUi(this);
|
||||
ui.radioPdf->setChecked(true);
|
||||
platform = RbSettings::value(RbSettings::Platform).toString();
|
||||
connect(ui.buttonDownloadManual, SIGNAL(clicked()), this, SLOT(downloadManual()));
|
||||
}
|
||||
|
||||
|
||||
QString ManualWidget::manualUrl(ManualFormat format)
|
||||
{
|
||||
if(RbSettings::value(RbSettings::Platform).toString().isEmpty()) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString buildservermodel = SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
|
||||
QString modelman = SystemInfo::value(SystemInfo::CurManual).toString();
|
||||
QString manualbasename;
|
||||
|
||||
if(modelman.isEmpty()) {
|
||||
manualbasename = "rockbox-" + buildservermodel;
|
||||
}
|
||||
else {
|
||||
manualbasename = "rockbox-" + modelman;
|
||||
}
|
||||
|
||||
QString manual = SystemInfo::value(SystemInfo::ManualUrl).toString();
|
||||
switch(format) {
|
||||
case ManualPdf:
|
||||
manual.replace("%EXTENSION%", "pdf");
|
||||
break;
|
||||
case ManualHtml:
|
||||
manual.replace("%EXTENSION%", "html");
|
||||
manualbasename += "/rockbox-build";
|
||||
break;
|
||||
case ManualZip:
|
||||
manual.replace("%EXTENSION%", "zip");
|
||||
manualbasename += "-html";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
manual.replace("%MANUALBASENAME%", manualbasename);
|
||||
return manual;
|
||||
}
|
||||
|
||||
|
||||
void ManualWidget::updateManual()
|
||||
{
|
||||
if(!RbSettings::value(RbSettings::Platform).toString().isEmpty())
|
||||
{
|
||||
ui.labelPdfManual->setText(tr("<a href='%1'>PDF Manual</a>")
|
||||
.arg(manualUrl(ManualPdf)));
|
||||
.arg(ServerInfo::platformValue(platform, ServerInfo::ManualPdfUrl).toString()));
|
||||
ui.labelHtmlManual->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
|
||||
.arg(manualUrl(ManualHtml)));
|
||||
.arg(ServerInfo::platformValue(platform, ServerInfo::ManualHtmlUrl).toString()));
|
||||
}
|
||||
else {
|
||||
ui.labelPdfManual->setText(tr("Select a device for a link to the correct manual"));
|
||||
|
@ -114,12 +76,12 @@ void ManualWidget::downloadManual(void)
|
|||
installer->setCache(true);
|
||||
|
||||
if(ui.radioPdf->isChecked()) {
|
||||
manualurl = manualUrl(ManualPdf);
|
||||
manualurl = ServerInfo::platformValue(platform, ServerInfo::ManualPdfUrl).toString();
|
||||
installer->setLogSection("Manual (PDF)");
|
||||
installer->setTarget("/" + manual + ".pdf");
|
||||
}
|
||||
else {
|
||||
manualurl = manualUrl(ManualZip);
|
||||
manualurl = ServerInfo::platformValue(platform, ServerInfo::ManualZipUrl).toString();
|
||||
installer->setLogSection("Manual (HTML)");
|
||||
installer->setTarget("/" + manual + "-" + "-html.zip");
|
||||
}
|
||||
|
|
|
@ -26,20 +26,15 @@ class ManualWidget : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum ManualFormat {
|
||||
ManualPdf,
|
||||
ManualHtml,
|
||||
ManualZip,
|
||||
};
|
||||
ManualWidget(QWidget *parent = 0);
|
||||
|
||||
public slots:
|
||||
void downloadManual(void);
|
||||
void updateManual();
|
||||
QString manualUrl(ManualFormat format);
|
||||
|
||||
private:
|
||||
Ui::ManualWidgetFrm ui;
|
||||
QString platform;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>644</width>
|
||||
<height>500</height>
|
||||
<height>448</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
|
|
Loading…
Reference in a new issue