summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/gui
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/gui')
-rw-r--r--rbutil/rbutilqt/gui/manualwidget.cpp140
-rw-r--r--rbutil/rbutilqt/gui/manualwidget.h46
-rw-r--r--rbutil/rbutilqt/gui/manualwidgetfrm.ui116
3 files changed, 302 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/gui/manualwidget.cpp b/rbutil/rbutilqt/gui/manualwidget.cpp
new file mode 100644
index 0000000000..f84da69a2a
--- /dev/null
+++ b/rbutil/rbutilqt/gui/manualwidget.cpp
@@ -0,0 +1,140 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2012 by Dominik Riebeling
10 *
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.
13 *
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
16 *
17 ****************************************************************************/
18
19#include <QtGui>
20#include <QDebug>
21#include "manualwidget.h"
22#include "rbutilqt.h"
23#include "rbsettings.h"
24#include "serverinfo.h"
25#include "systeminfo.h"
26
27ManualWidget::ManualWidget(QWidget *parent) : QWidget(parent)
28{
29 ui.setupUi(this);
30 ui.radioPdf->setChecked(true);
31 connect(ui.buttonDownloadManual, SIGNAL(clicked()), this, SLOT(downloadManual()));
32}
33
34
35QString ManualWidget::manualUrl(ManualFormat format)
36{
37 if(RbSettings::value(RbSettings::Platform).toString().isEmpty()) {
38 return QString();
39 }
40
41 QString buildservermodel = SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
42 QString modelman = SystemInfo::value(SystemInfo::CurManual).toString();
43 QString manualbasename;
44
45 if(modelman.isEmpty()) {
46 manualbasename = "rockbox-" + buildservermodel;
47 }
48 else {
49 manualbasename = "rockbox-" + modelman;
50 }
51
52 QString manual = SystemInfo::value(SystemInfo::ManualUrl).toString();
53 switch(format) {
54 case ManualPdf:
55 manual.replace("%EXTENSION%", "pdf");
56 break;
57 case ManualHtml:
58 manual.replace("%EXTENSION%", "html");
59 manualbasename += "/rockbox-build";
60 break;
61 case ManualZip:
62 manual.replace("%EXTENSION%", "-html.zip");
63 manualbasename += "/rockbox-build";
64 break;
65 default:
66 break;
67 };
68
69 manual.replace("%MANUALBASENAME%", manualbasename);
70 return manual;
71}
72
73
74void ManualWidget::updateManual()
75{
76 if(!RbSettings::value(RbSettings::Platform).toString().isEmpty())
77 {
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)));
82 }
83 else {
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"));
87 }
88}
89
90
91void ManualWidget::downloadManual(void)
92{
93 if(RbUtilQt::chkConfig(this)) {
94 return;
95 }
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) {
100 return;
101 }
102 QString manual = SystemInfo::value(SystemInfo::CurManual).toString();
103 if(manual.isEmpty()) {
104 manual = "rockbox-" + SystemInfo::value(SystemInfo::CurBuildserverModel).toString();
105 }
106
107 QDate date = QDate::fromString(ServerInfo::value(
108 ServerInfo::DailyDate).toString(), Qt::ISODate);
109 QString manualurl;
110
111 ProgressLoggerGui* logger = new ProgressLoggerGui(this);
112 logger->show();
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);
117
118 if(ui.radioPdf->isChecked()) {
119 manualurl = manualUrl(ManualPdf);
120 installer->setLogSection("Manual (PDF)");
121 installer->setTarget("/" + manual + ".pdf");
122 }
123 else {
124 manualurl = manualUrl(ManualZip);
125 installer->setLogSection("Manual (HTML)");
126 installer->setTarget("/" + manual + "-" + date.toString("yyyyMMdd") + "-html.zip");
127 }
128 qDebug() << "[ManualWidget] Manual URL:" << manualurl;
129
130 installer->setLogVersion(ServerInfo::value(ServerInfo::DailyDate).toString());
131 installer->setUrl(manualurl);
132 installer->setUnzip(false);
133
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();
139}
140
diff --git a/rbutil/rbutilqt/gui/manualwidget.h b/rbutil/rbutilqt/gui/manualwidget.h
new file mode 100644
index 0000000000..6de2de55bd
--- /dev/null
+++ b/rbutil/rbutilqt/gui/manualwidget.h
@@ -0,0 +1,46 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2012 by Dominik Riebeling
10 *
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.
13 *
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
16 *
17 ****************************************************************************/
18
19#ifndef MANUALWIDGET_H
20#define MANUALWIDGET_H
21
22#include <QtGui>
23#include "ui_manualwidgetfrm.h"
24
25class ManualWidget : public QWidget
26{
27 Q_OBJECT
28 public:
29 enum ManualFormat {
30 ManualPdf,
31 ManualHtml,
32 ManualZip,
33 };
34 ManualWidget(QWidget *parent = 0);
35
36 public slots:
37 void downloadManual(void);
38 void updateManual();
39 QString manualUrl(ManualFormat format);
40
41 private:
42 Ui::ManualWidgetFrm ui;
43};
44
45#endif
46
diff --git a/rbutil/rbutilqt/gui/manualwidgetfrm.ui b/rbutil/rbutilqt/gui/manualwidgetfrm.ui
new file mode 100644
index 0000000000..8757c4569e
--- /dev/null
+++ b/rbutil/rbutilqt/gui/manualwidgetfrm.ui
@@ -0,0 +1,116 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<ui version="4.0">
3 <class>ManualWidgetFrm</class>
4 <widget class="QWidget" name="ManualWidgetFrm">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>543</width>
10 <height>255</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>Form</string>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="0" column="0">
18 <widget class="QGroupBox" name="groupBox_2">
19 <property name="title">
20 <string>Read the manual</string>
21 </property>
22 <layout class="QGridLayout">
23 <item row="0" column="0">
24 <widget class="QLabel" name="labelPdfManual">
25 <property name="text">
26 <string>PDF manual</string>
27 </property>
28 <property name="openExternalLinks">
29 <bool>true</bool>
30 </property>
31 <property name="textInteractionFlags">
32 <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse</set>
33 </property>
34 </widget>
35 </item>
36 <item row="1" column="0">
37 <widget class="QLabel" name="labelHtmlManual">
38 <property name="text">
39 <string>HTML manual</string>
40 </property>
41 <property name="openExternalLinks">
42 <bool>true</bool>
43 </property>
44 <property name="textInteractionFlags">
45 <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse</set>
46 </property>
47 </widget>
48 </item>
49 </layout>
50 </widget>
51 </item>
52 <item row="1" column="0">
53 <widget class="QGroupBox" name="groupBox">
54 <property name="title">
55 <string>Download the manual</string>
56 </property>
57 <layout class="QGridLayout" name="_2">
58 <item row="0" column="0">
59 <layout class="QVBoxLayout" name="_3">
60 <item>
61 <widget class="QRadioButton" name="radioPdf">
62 <property name="text">
63 <string>&amp;PDF version</string>
64 </property>
65 </widget>
66 </item>
67 <item>
68 <widget class="QRadioButton" name="radioHtmlzip">
69 <property name="text">
70 <string>&amp;HTML version (zip file)</string>
71 </property>
72 </widget>
73 </item>
74 </layout>
75 </item>
76 <item row="0" column="1">
77 <spacer>
78 <property name="orientation">
79 <enum>Qt::Horizontal</enum>
80 </property>
81 <property name="sizeHint" stdset="0">
82 <size>
83 <width>40</width>
84 <height>20</height>
85 </size>
86 </property>
87 </spacer>
88 </item>
89 <item row="0" column="2">
90 <widget class="QPushButton" name="buttonDownloadManual">
91 <property name="text">
92 <string>Down&amp;load</string>
93 </property>
94 </widget>
95 </item>
96 </layout>
97 </widget>
98 </item>
99 <item row="2" column="0">
100 <spacer name="verticalSpacer">
101 <property name="orientation">
102 <enum>Qt::Vertical</enum>
103 </property>
104 <property name="sizeHint" stdset="0">
105 <size>
106 <width>20</width>
107 <height>40</height>
108 </size>
109 </property>
110 </spacer>
111 </item>
112 </layout>
113 </widget>
114 <resources/>
115 <connections/>
116</ui>