diff options
Diffstat (limited to 'utils/rbutilqt/gui/selectiveinstallwidget.cpp')
-rw-r--r-- | utils/rbutilqt/gui/selectiveinstallwidget.cpp | 691 |
1 files changed, 691 insertions, 0 deletions
diff --git a/utils/rbutilqt/gui/selectiveinstallwidget.cpp b/utils/rbutilqt/gui/selectiveinstallwidget.cpp new file mode 100644 index 0000000000..9bfe7414a3 --- /dev/null +++ b/utils/rbutilqt/gui/selectiveinstallwidget.cpp | |||
@@ -0,0 +1,691 @@ | |||
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 <QWidget> | ||
20 | #include <QMessageBox> | ||
21 | #include <QFileDialog> | ||
22 | #include "selectiveinstallwidget.h" | ||
23 | #include "ui_selectiveinstallwidgetfrm.h" | ||
24 | #include "playerbuildinfo.h" | ||
25 | #include "rbsettings.h" | ||
26 | #include "rockboxinfo.h" | ||
27 | #include "progressloggergui.h" | ||
28 | #include "bootloaderinstallbase.h" | ||
29 | #include "bootloaderinstallhelper.h" | ||
30 | #include "themesinstallwindow.h" | ||
31 | #include "utils.h" | ||
32 | #include "Logger.h" | ||
33 | |||
34 | SelectiveInstallWidget::SelectiveInstallWidget(QWidget* parent) : QWidget(parent) | ||
35 | { | ||
36 | ui.setupUi(this); | ||
37 | ui.rockboxCheckbox->setChecked(RbSettings::value(RbSettings::InstallRockbox).toBool()); | ||
38 | ui.fontsCheckbox->setChecked(RbSettings::value(RbSettings::InstallFonts).toBool()); | ||
39 | ui.themesCheckbox->setChecked(RbSettings::value(RbSettings::InstallThemes).toBool()); | ||
40 | ui.pluginDataCheckbox->setChecked(RbSettings::value(RbSettings::InstallPluginData).toBool()); | ||
41 | ui.voiceCheckbox->setChecked(RbSettings::value(RbSettings::InstallVoice).toBool()); | ||
42 | ui.manualCheckbox->setChecked(RbSettings::value(RbSettings::InstallManual).toBool()); | ||
43 | |||
44 | ui.manualCombobox->addItem("PDF", "pdf"); | ||
45 | ui.manualCombobox->addItem("HTML (zip)", "zip"); | ||
46 | ui.manualCombobox->addItem("HTML", "html"); | ||
47 | |||
48 | // check if Rockbox is installed by looking after rockbox-info.txt. | ||
49 | // If installed uncheck bootloader installation. | ||
50 | RockboxInfo info(m_mountpoint); | ||
51 | ui.bootloaderCheckbox->setChecked(!info.success()); | ||
52 | |||
53 | m_logger = nullptr; | ||
54 | m_zipinstaller = nullptr; | ||
55 | m_themesinstaller = nullptr; | ||
56 | |||
57 | connect(ui.installButton, &QAbstractButton::clicked, | ||
58 | this, &SelectiveInstallWidget::startInstall); | ||
59 | connect(this, &SelectiveInstallWidget::installSkipped, | ||
60 | this, &SelectiveInstallWidget::continueInstall); | ||
61 | connect(ui.themesCustomize, &QAbstractButton::clicked, | ||
62 | this, &SelectiveInstallWidget::customizeThemes); | ||
63 | connect(ui.selectedVersion, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), | ||
64 | this, &SelectiveInstallWidget::selectedVersionChanged); | ||
65 | // update version information. This also handles setting the previously | ||
66 | // selected build type and bootloader disabling. | ||
67 | updateVersion(); | ||
68 | } | ||
69 | |||
70 | |||
71 | void SelectiveInstallWidget::selectedVersionChanged(int index) | ||
72 | { | ||
73 | m_buildtype = static_cast<PlayerBuildInfo::BuildType>(ui.selectedVersion->itemData(index).toInt()); | ||
74 | bool voice = true; | ||
75 | switch(m_buildtype) { | ||
76 | case PlayerBuildInfo::TypeRelease: | ||
77 | ui.selectedDescription->setText(tr("This is the latest stable " | ||
78 | "release available.")); | ||
79 | voice = true; | ||
80 | break; | ||
81 | case PlayerBuildInfo::TypeDevel: | ||
82 | ui.selectedDescription->setText(tr("The development version is " | ||
83 | "updated on every code change.")); | ||
84 | voice = false; | ||
85 | break; | ||
86 | case PlayerBuildInfo::TypeCandidate: | ||
87 | ui.selectedDescription->setText(tr("This will eventually become the " | ||
88 | "next Rockbox version. Install it to help testing.")); | ||
89 | voice = false; | ||
90 | break; | ||
91 | case PlayerBuildInfo::TypeDaily: | ||
92 | ui.selectedDescription->setText(tr("Daily updated development version.")); | ||
93 | voice = true; | ||
94 | break; | ||
95 | } | ||
96 | ui.voiceCheckbox->setEnabled(voice); | ||
97 | ui.voiceCombobox->setEnabled(voice); | ||
98 | ui.voiceLabel->setEnabled(voice); | ||
99 | ui.voiceCheckbox->setToolTip(voice ? "" : tr("Not available for the selected version")); | ||
100 | |||
101 | updateVoiceLangs(); | ||
102 | } | ||
103 | |||
104 | |||
105 | void SelectiveInstallWidget::updateVersion(void) | ||
106 | { | ||
107 | // get some configuration values globally | ||
108 | m_mountpoint = RbSettings::value(RbSettings::Mountpoint).toString(); | ||
109 | m_target = RbSettings::value(RbSettings::CurrentPlatform).toString(); | ||
110 | m_blmethod = PlayerBuildInfo::instance()->value( | ||
111 | PlayerBuildInfo::BootloaderMethod, m_target).toString(); | ||
112 | |||
113 | if(m_logger != nullptr) { | ||
114 | delete m_logger; | ||
115 | m_logger = nullptr; | ||
116 | } | ||
117 | |||
118 | // re-populate all version items | ||
119 | QMap<PlayerBuildInfo::BuildType, QString> types; | ||
120 | types[PlayerBuildInfo::TypeRelease] = tr("Stable Release (Version %1)"); | ||
121 | if (PlayerBuildInfo::instance()->value(PlayerBuildInfo::BuildStatus).toInt() != STATUS_RETIRED) { | ||
122 | types[PlayerBuildInfo::TypeCandidate] = tr("Release Candidate (Revison %1)"); | ||
123 | types[PlayerBuildInfo::TypeDaily] = tr("Daily Build (%1)"); | ||
124 | types[PlayerBuildInfo::TypeDevel] = tr("Development Version (Revison %1)"); | ||
125 | } | ||
126 | |||
127 | ui.selectedVersion->clear(); | ||
128 | for(auto i = types.begin(); i != types.end(); i++) { | ||
129 | QString version = PlayerBuildInfo::instance()->value( | ||
130 | PlayerBuildInfo::BuildVersion, i.key()).toString(); | ||
131 | if(!version.isEmpty()) | ||
132 | ui.selectedVersion->addItem(i.value().arg(version), i.key()); | ||
133 | } | ||
134 | |||
135 | // select previously selected version | ||
136 | int index = ui.selectedVersion->findData( | ||
137 | static_cast<PlayerBuildInfo::BuildType>(RbSettings::value(RbSettings::Build).toInt())); | ||
138 | if(index < 0) { | ||
139 | index = ui.selectedVersion->findData(PlayerBuildInfo::TypeRelease); | ||
140 | if(index < 0) { | ||
141 | index = ui.selectedVersion->findData(PlayerBuildInfo::TypeDevel); | ||
142 | } | ||
143 | } | ||
144 | ui.selectedVersion->setCurrentIndex(index); | ||
145 | // check if Rockbox is installed. If it is untick the bootloader option, as | ||
146 | // well as if the selected player doesn't need a bootloader. | ||
147 | if(m_blmethod == "none") { | ||
148 | ui.bootloaderCheckbox->setEnabled(false); | ||
149 | ui.bootloaderCheckbox->setChecked(false); | ||
150 | ui.bootloaderLabel->setEnabled(false); | ||
151 | ui.bootloaderLabel->setText(tr("The selected player doesn't need a bootloader.")); | ||
152 | } | ||
153 | else { | ||
154 | ui.bootloaderCheckbox->setEnabled(true); | ||
155 | ui.bootloaderLabel->setEnabled(true); | ||
156 | ui.bootloaderLabel->setText(tr("The bootloader is required for starting " | ||
157 | "Rockbox. Installation of the bootloader is only necessary " | ||
158 | "on first time installation.")); | ||
159 | // check if Rockbox is installed by looking after rockbox-info.txt. | ||
160 | // If installed uncheck bootloader installation. | ||
161 | RockboxInfo info(m_mountpoint); | ||
162 | ui.bootloaderCheckbox->setChecked(!info.success()); | ||
163 | } | ||
164 | |||
165 | updateVoiceLangs(); | ||
166 | } | ||
167 | |||
168 | void SelectiveInstallWidget::updateVoiceLangs() | ||
169 | { | ||
170 | // populate languages for voice file. | ||
171 | QVariant current = ui.voiceCombobox->currentData(); | ||
172 | QMap<QString, QVariant> langs = PlayerBuildInfo::instance()->value( | ||
173 | PlayerBuildInfo::LanguageList).toMap(); | ||
174 | QStringList voicelangs = PlayerBuildInfo::instance()->value( | ||
175 | PlayerBuildInfo::BuildVoiceLangs, m_buildtype).toStringList(); | ||
176 | ui.voiceCombobox->clear(); | ||
177 | for(auto it = langs.begin(); it != langs.end(); it++) { | ||
178 | if(voicelangs.contains(it.key())) { | ||
179 | ui.voiceCombobox->addItem(it.value().toString(), it.key()); | ||
180 | LOG_INFO() << "available voices: adding" << it.key(); | ||
181 | } | ||
182 | |||
183 | } | ||
184 | // try to select the previously selected one again (if still present) | ||
185 | // TODO: Fall back to system language if not found, or english. | ||
186 | int sel = ui.voiceCombobox->findData(current); | ||
187 | if(sel >= 0) | ||
188 | ui.voiceCombobox->setCurrentIndex(sel); | ||
189 | |||
190 | } | ||
191 | |||
192 | |||
193 | void SelectiveInstallWidget::saveSettings(void) | ||
194 | { | ||
195 | LOG_INFO() << "saving current settings"; | ||
196 | |||
197 | RbSettings::setValue(RbSettings::InstallRockbox, ui.rockboxCheckbox->isChecked()); | ||
198 | RbSettings::setValue(RbSettings::InstallFonts, ui.fontsCheckbox->isChecked()); | ||
199 | RbSettings::setValue(RbSettings::InstallThemes, ui.themesCheckbox->isChecked()); | ||
200 | RbSettings::setValue(RbSettings::InstallPluginData, ui.pluginDataCheckbox->isChecked()); | ||
201 | RbSettings::setValue(RbSettings::InstallVoice, ui.voiceCheckbox->isChecked()); | ||
202 | RbSettings::setValue(RbSettings::InstallManual, ui.manualCheckbox->isChecked()); | ||
203 | RbSettings::setValue(RbSettings::VoiceLanguage, ui.voiceCombobox->currentData().toString()); | ||
204 | } | ||
205 | |||
206 | |||
207 | void SelectiveInstallWidget::startInstall(void) | ||
208 | { | ||
209 | LOG_INFO() << "starting installation"; | ||
210 | saveSettings(); | ||
211 | |||
212 | m_installStage = 0; | ||
213 | if(m_logger != nullptr) delete m_logger; | ||
214 | m_logger = new ProgressLoggerGui(this); | ||
215 | QString warning = Utils::checkEnvironment(false); | ||
216 | if(!warning.isEmpty()) | ||
217 | { | ||
218 | warning += "<br/>" + tr("Continue with installation?"); | ||
219 | if(QMessageBox::warning(this, tr("Really continue?"), warning, | ||
220 | QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort) | ||
221 | == QMessageBox::Abort) | ||
222 | { | ||
223 | emit installSkipped(true); | ||
224 | return; | ||
225 | } | ||
226 | } | ||
227 | |||
228 | m_logger->show(); | ||
229 | if(!QFileInfo(m_mountpoint).isDir()) { | ||
230 | m_logger->addItem(tr("Mountpoint is wrong"), LOGERROR); | ||
231 | m_logger->setFinished(); | ||
232 | return; | ||
233 | } | ||
234 | // start installation. No errors until now. | ||
235 | continueInstall(false); | ||
236 | |||
237 | } | ||
238 | |||
239 | |||
240 | void SelectiveInstallWidget::continueInstall(bool error) | ||
241 | { | ||
242 | LOG_INFO() << "continuing install with stage" << m_installStage; | ||
243 | if(error) { | ||
244 | LOG_ERROR() << "Last part returned error."; | ||
245 | m_logger->setFinished(); | ||
246 | m_installStage = 9; | ||
247 | } | ||
248 | m_installStage++; | ||
249 | switch(m_installStage) { | ||
250 | case 0: LOG_ERROR() << "Something wrong!"; break; | ||
251 | case 1: installBootloader(); break; | ||
252 | case 2: installRockbox(); break; | ||
253 | case 3: installFonts(); break; | ||
254 | case 4: installThemes(); break; | ||
255 | case 5: installPluginData(); break; | ||
256 | case 6: installVoicefile(); break; | ||
257 | case 7: installManual(); break; | ||
258 | case 8: installBootloaderPost(); break; | ||
259 | default: break; | ||
260 | } | ||
261 | |||
262 | if(m_installStage > 8) { | ||
263 | LOG_INFO() << "All install stages done."; | ||
264 | m_logger->setFinished(); | ||
265 | if(m_blmethod != "none") { | ||
266 | // check if Rockbox is installed by looking after rockbox-info.txt. | ||
267 | // If installed uncheck bootloader installation. | ||
268 | RockboxInfo info(m_mountpoint); | ||
269 | ui.bootloaderCheckbox->setChecked(!info.success()); | ||
270 | } | ||
271 | } | ||
272 | } | ||
273 | |||
274 | |||
275 | void SelectiveInstallWidget::installBootloader(void) | ||
276 | { | ||
277 | if(ui.bootloaderCheckbox->isChecked()) { | ||
278 | LOG_INFO() << "installing bootloader"; | ||
279 | |||
280 | QString platform = RbSettings::value(RbSettings::Platform).toString(); | ||
281 | QString backupDestination = ""; | ||
282 | |||
283 | // create installer | ||
284 | BootloaderInstallBase *bl = | ||
285 | BootloaderInstallHelper::createBootloaderInstaller(this, | ||
286 | PlayerBuildInfo::instance()->value( | ||
287 | PlayerBuildInfo::BootloaderMethod).toString()); | ||
288 | if(bl == nullptr) { | ||
289 | m_logger->addItem(tr("No install method known."), LOGERROR); | ||
290 | m_logger->setFinished(); | ||
291 | return; | ||
292 | } | ||
293 | |||
294 | // the bootloader install class does NOT use any GUI stuff. | ||
295 | // All messages are passed via signals. | ||
296 | connect(bl, SIGNAL(done(bool)), m_logger, SLOT(setFinished())); | ||
297 | connect(bl, SIGNAL(done(bool)), this, SLOT(continueInstall(bool))); | ||
298 | connect(bl, SIGNAL(logItem(QString, int)), m_logger, SLOT(addItem(QString, int))); | ||
299 | connect(bl, SIGNAL(logProgress(int, int)), m_logger, SLOT(setProgress(int, int))); | ||
300 | // pass Abort button click signal to current installer | ||
301 | connect(m_logger, SIGNAL(aborted()), bl, SLOT(progressAborted())); | ||
302 | |||
303 | // set bootloader filename. Do this now as installed() needs it. | ||
304 | QStringList blfile = PlayerBuildInfo::instance()->value( | ||
305 | PlayerBuildInfo::BootloaderFile).toStringList(); | ||
306 | QStringList blfilepath; | ||
307 | for(int a = 0; a < blfile.size(); a++) { | ||
308 | blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString() | ||
309 | + blfile.at(a)); | ||
310 | } | ||
311 | bl->setBlFile(blfilepath); | ||
312 | QUrl url(PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderUrl).toString() | ||
313 | + PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderName).toString()); | ||
314 | bl->setBlUrl(url); | ||
315 | bl->setLogfile(RbSettings::value(RbSettings::Mountpoint).toString() | ||
316 | + "/.rockbox/rbutil.log"); | ||
317 | |||
318 | if(bl->installed() == BootloaderInstallBase::BootloaderRockbox) { | ||
319 | if(QMessageBox::question(this, tr("Bootloader detected"), | ||
320 | tr("Bootloader already installed. Do you want to reinstall the bootloader?"), | ||
321 | QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) { | ||
322 | // keep m_logger open for auto installs. | ||
323 | // don't consider abort as error in auto-mode. | ||
324 | m_logger->addItem(tr("Bootloader installation skipped"), LOGINFO); | ||
325 | delete bl; | ||
326 | emit installSkipped(true); | ||
327 | return; | ||
328 | } | ||
329 | } | ||
330 | else if(bl->installed() == BootloaderInstallBase::BootloaderOther | ||
331 | && bl->capabilities() & BootloaderInstallBase::Backup) | ||
332 | { | ||
333 | QString targetFolder = PlayerBuildInfo::instance()->value( | ||
334 | PlayerBuildInfo::DisplayName).toString() | ||
335 | + " Firmware Backup"; | ||
336 | // remove invalid character(s) | ||
337 | targetFolder.remove(QRegExp("[:/]")); | ||
338 | if(QMessageBox::question(this, tr("Create Bootloader backup"), | ||
339 | tr("You can create a backup of the original bootloader " | ||
340 | "file. Press \"Yes\" to select an output folder on your " | ||
341 | "computer to save the file to. The file will get placed " | ||
342 | "in a new folder \"%1\" created below the selected folder.\n" | ||
343 | "Press \"No\" to skip this step.").arg(targetFolder), | ||
344 | QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { | ||
345 | backupDestination = QFileDialog::getExistingDirectory(this, | ||
346 | tr("Browse backup folder"), QDir::homePath()); | ||
347 | if(!backupDestination.isEmpty()) | ||
348 | backupDestination += "/" + targetFolder; | ||
349 | |||
350 | LOG_INFO() << "backing up to" << backupDestination; | ||
351 | // backup needs to be done after the m_logger has been set up. | ||
352 | } | ||
353 | } | ||
354 | |||
355 | if(bl->capabilities() & BootloaderInstallBase::NeedsOf) | ||
356 | { | ||
357 | int ret; | ||
358 | ret = QMessageBox::information(this, tr("Prerequisites"), | ||
359 | bl->ofHint(),QMessageBox::Ok | QMessageBox::Abort); | ||
360 | if(ret != QMessageBox::Ok) { | ||
361 | // consider aborting an error to close window / abort automatic | ||
362 | // installation. | ||
363 | m_logger->addItem(tr("Bootloader installation aborted"), LOGINFO); | ||
364 | m_logger->setFinished(); | ||
365 | emit installSkipped(true); | ||
366 | return; | ||
367 | } | ||
368 | // open dialog to browse to of file | ||
369 | QString offile; | ||
370 | QString filter | ||
371 | = PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderFilter).toString(); | ||
372 | if(!filter.isEmpty()) { | ||
373 | filter = tr("Bootloader files (%1)").arg(filter) + ";;"; | ||
374 | } | ||
375 | filter += tr("All files (*)"); | ||
376 | offile = QFileDialog::getOpenFileName(this, | ||
377 | tr("Select firmware file"), QDir::homePath(), filter); | ||
378 | if(!QFileInfo(offile).isReadable()) { | ||
379 | m_logger->addItem(tr("Error opening firmware file"), LOGERROR); | ||
380 | m_logger->setFinished(); | ||
381 | emit installSkipped(true); | ||
382 | return; | ||
383 | } | ||
384 | if(!bl->setOfFile(offile, blfile)) { | ||
385 | m_logger->addItem(tr("Error reading firmware file"), LOGERROR); | ||
386 | m_logger->setFinished(); | ||
387 | emit installSkipped(true); | ||
388 | return; | ||
389 | } | ||
390 | } | ||
391 | |||
392 | // start install. | ||
393 | if(!backupDestination.isEmpty()) { | ||
394 | if(!bl->backup(backupDestination)) { | ||
395 | if(QMessageBox::warning(this, tr("Backup error"), | ||
396 | tr("Could not create backup file. Continue?"), | ||
397 | QMessageBox::No | QMessageBox::Yes) | ||
398 | == QMessageBox::No) { | ||
399 | m_logger->setFinished(); | ||
400 | return; | ||
401 | } | ||
402 | } | ||
403 | } | ||
404 | bl->install(); | ||
405 | |||
406 | } | ||
407 | else { | ||
408 | LOG_INFO() << "Bootloader install disabled."; | ||
409 | emit installSkipped(false); | ||
410 | } | ||
411 | } | ||
412 | |||
413 | void SelectiveInstallWidget::installBootloaderPost() | ||
414 | { | ||
415 | // don't do anything if no bootloader install has been done. | ||
416 | if(ui.bootloaderCheckbox->isChecked()) { | ||
417 | QString msg = BootloaderInstallHelper::postinstallHints( | ||
418 | RbSettings::value(RbSettings::Platform).toString()); | ||
419 | if(!msg.isEmpty()) { | ||
420 | QMessageBox::information(this, tr("Manual steps required"), msg); | ||
421 | } | ||
422 | } | ||
423 | emit installSkipped(false); | ||
424 | } | ||
425 | |||
426 | |||
427 | void SelectiveInstallWidget::installRockbox(void) | ||
428 | { | ||
429 | if(ui.rockboxCheckbox->isChecked()) { | ||
430 | LOG_INFO() << "installing Rockbox"; | ||
431 | QString url; | ||
432 | |||
433 | RbSettings::setValue(RbSettings::Build, m_buildtype); | ||
434 | RbSettings::sync(); | ||
435 | |||
436 | url = PlayerBuildInfo::instance()->value( | ||
437 | PlayerBuildInfo::BuildUrl, m_buildtype).toString(); | ||
438 | //! install build | ||
439 | if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater(); | ||
440 | m_zipinstaller = new ZipInstaller(this); | ||
441 | m_zipinstaller->setUrl(url); | ||
442 | m_zipinstaller->setLogSection("Rockbox (Base)"); | ||
443 | if(!RbSettings::value(RbSettings::CacheDisabled).toBool()) | ||
444 | m_zipinstaller->setCache(true); | ||
445 | m_zipinstaller->setLogVersion(PlayerBuildInfo::instance()->value( | ||
446 | PlayerBuildInfo::BuildVersion, m_buildtype).toString()); | ||
447 | m_zipinstaller->setMountPoint(m_mountpoint); | ||
448 | |||
449 | connect(m_zipinstaller, SIGNAL(done(bool)), this, SLOT(continueInstall(bool))); | ||
450 | |||
451 | connect(m_zipinstaller, SIGNAL(logItem(QString, int)), m_logger, SLOT(addItem(QString, int))); | ||
452 | connect(m_zipinstaller, SIGNAL(logProgress(int, int)), m_logger, SLOT(setProgress(int, int))); | ||
453 | connect(m_logger, SIGNAL(aborted()), m_zipinstaller, SLOT(abort())); | ||
454 | m_zipinstaller->install(); | ||
455 | |||
456 | } | ||
457 | else { | ||
458 | LOG_INFO() << "Rockbox install disabled."; | ||
459 | emit installSkipped(false); | ||
460 | } | ||
461 | } | ||
462 | |||
463 | |||
464 | void SelectiveInstallWidget::installFonts(void) | ||
465 | { | ||
466 | if(ui.fontsCheckbox->isChecked()) { | ||
467 | LOG_INFO() << "installing Fonts"; | ||
468 | |||
469 | RockboxInfo installInfo(m_mountpoint); | ||
470 | QString fontsurl; | ||
471 | QString logversion; | ||
472 | QString relversion = installInfo.release(); | ||
473 | if(!relversion.isEmpty()) { | ||
474 | // release is empty for non-release versions (i.e. daily / current) | ||
475 | logversion = installInfo.release(); | ||
476 | } | ||
477 | fontsurl = PlayerBuildInfo::instance()->value( | ||
478 | PlayerBuildInfo::BuildFontUrl, m_buildtype).toString(); | ||
479 | fontsurl.replace("%RELVERSION%", relversion); | ||
480 | |||
481 | // create new zip installer | ||
482 | if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater(); | ||
483 | m_zipinstaller = new ZipInstaller(this); | ||
484 | m_zipinstaller->setUrl(fontsurl); | ||
485 | m_zipinstaller->setLogSection("Fonts"); | ||
486 | m_zipinstaller->setLogVersion(logversion); | ||
487 | m_zipinstaller->setMountPoint(m_mountpoint); | ||
488 | if(!RbSettings::value(RbSettings::CacheDisabled).toBool()) | ||
489 | m_zipinstaller->setCache(true); | ||
490 | |||
491 | connect(m_zipinstaller, SIGNAL(done(bool)), this, SLOT(continueInstall(bool))); | ||
492 | connect(m_zipinstaller, SIGNAL(logItem(QString, int)), m_logger, SLOT(addItem(QString, int))); | ||
493 | connect(m_zipinstaller, SIGNAL(logProgress(int, int)), m_logger, SLOT(setProgress(int, int))); | ||
494 | connect(m_logger, SIGNAL(aborted()), m_zipinstaller, SLOT(abort())); | ||
495 | m_zipinstaller->install(); | ||
496 | } | ||
497 | else { | ||
498 | LOG_INFO() << "Fonts install disabled."; | ||
499 | emit installSkipped(false); | ||
500 | } | ||
501 | } | ||
502 | |||
503 | void SelectiveInstallWidget::installVoicefile(void) | ||
504 | { | ||
505 | if(ui.voiceCheckbox->isChecked() && ui.voiceCheckbox->isEnabled()) { | ||
506 | LOG_INFO() << "installing Voice file"; | ||
507 | QString lang = ui.voiceCombobox->currentData().toString(); | ||
508 | |||
509 | RockboxInfo installInfo(m_mountpoint); | ||
510 | QString voiceurl; | ||
511 | QString logversion; | ||
512 | QString relversion = installInfo.release(); | ||
513 | if(m_buildtype != PlayerBuildInfo::TypeRelease) { | ||
514 | // release is empty for non-release versions (i.e. daily / current) | ||
515 | logversion = installInfo.release(); | ||
516 | } | ||
517 | voiceurl = PlayerBuildInfo::instance()->value( | ||
518 | PlayerBuildInfo::BuildVoiceUrl, m_buildtype).toString(); | ||
519 | voiceurl.replace("%LANGUAGE%", lang); | ||
520 | |||
521 | // create new zip installer | ||
522 | if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater(); | ||
523 | m_zipinstaller = new ZipInstaller(this); | ||
524 | m_zipinstaller->setUrl(voiceurl); | ||
525 | m_zipinstaller->setLogSection("Prerendered Voice (" + lang + ")"); | ||
526 | m_zipinstaller->setLogVersion(logversion); | ||
527 | m_zipinstaller->setMountPoint(m_mountpoint); | ||
528 | if(!RbSettings::value(RbSettings::CacheDisabled).toBool()) | ||
529 | m_zipinstaller->setCache(true); | ||
530 | |||
531 | connect(m_zipinstaller, SIGNAL(done(bool)), this, SLOT(continueInstall(bool))); | ||
532 | connect(m_zipinstaller, SIGNAL(logItem(QString, int)), m_logger, SLOT(addItem(QString, int))); | ||
533 | connect(m_zipinstaller, SIGNAL(logProgress(int, int)), m_logger, SLOT(setProgress(int, int))); | ||
534 | connect(m_logger, SIGNAL(aborted()), m_zipinstaller, SLOT(abort())); | ||
535 | m_zipinstaller->install(); | ||
536 | } | ||
537 | else { | ||
538 | LOG_INFO() << "Voice install disabled."; | ||
539 | emit installSkipped(false); | ||
540 | } | ||
541 | } | ||
542 | |||
543 | void SelectiveInstallWidget::installManual(void) | ||
544 | { | ||
545 | if(ui.manualCheckbox->isChecked() && ui.manualCheckbox->isEnabled()) { | ||
546 | LOG_INFO() << "installing Manual"; | ||
547 | QString mantype = ui.manualCombobox->currentData().toString(); | ||
548 | |||
549 | RockboxInfo installInfo(m_mountpoint); | ||
550 | QString manualurl; | ||
551 | QString logversion; | ||
552 | QString relversion = installInfo.release(); | ||
553 | if(m_buildtype != PlayerBuildInfo::TypeRelease) { | ||
554 | // release is empty for non-release versions (i.e. daily / current) | ||
555 | logversion = installInfo.release(); | ||
556 | } | ||
557 | |||
558 | manualurl = PlayerBuildInfo::instance()->value( | ||
559 | PlayerBuildInfo::BuildManualUrl, m_buildtype).toString(); | ||
560 | if(mantype == "pdf") | ||
561 | manualurl.replace("%FORMAT%", ".pdf"); | ||
562 | else | ||
563 | manualurl.replace("%FORMAT%", "-html.zip"); | ||
564 | |||
565 | // create new zip installer | ||
566 | if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater(); | ||
567 | m_zipinstaller = new ZipInstaller(this); | ||
568 | m_zipinstaller->setUrl(manualurl); | ||
569 | m_zipinstaller->setLogSection("Manual (" + mantype + ")"); | ||
570 | m_zipinstaller->setLogVersion(logversion); | ||
571 | m_zipinstaller->setMountPoint(m_mountpoint); | ||
572 | if(!RbSettings::value(RbSettings::CacheDisabled).toBool()) | ||
573 | m_zipinstaller->setCache(true); | ||
574 | // if type is html extract it. | ||
575 | m_zipinstaller->setUnzip(mantype == "html"); | ||
576 | |||
577 | connect(m_zipinstaller, SIGNAL(done(bool)), this, SLOT(continueInstall(bool))); | ||
578 | connect(m_zipinstaller, SIGNAL(logItem(QString, int)), m_logger, SLOT(addItem(QString, int))); | ||
579 | connect(m_zipinstaller, SIGNAL(logProgress(int, int)), m_logger, SLOT(setProgress(int, int))); | ||
580 | connect(m_logger, SIGNAL(aborted()), m_zipinstaller, SLOT(abort())); | ||
581 | m_zipinstaller->install(); | ||
582 | } | ||
583 | else { | ||
584 | LOG_INFO() << "Manual install disabled."; | ||
585 | emit installSkipped(false); | ||
586 | } | ||
587 | } | ||
588 | |||
589 | void SelectiveInstallWidget::customizeThemes(void) | ||
590 | { | ||
591 | if(m_themesinstaller == nullptr) | ||
592 | m_themesinstaller = new ThemesInstallWindow(this); | ||
593 | |||
594 | m_themesinstaller->setSelectOnly(true); | ||
595 | m_themesinstaller->show(); | ||
596 | } | ||
597 | |||
598 | |||
599 | void SelectiveInstallWidget::installThemes(void) | ||
600 | { | ||
601 | if(ui.themesCheckbox->isChecked()) { | ||
602 | LOG_INFO() << "installing themes"; | ||
603 | if(m_themesinstaller == nullptr) | ||
604 | m_themesinstaller = new ThemesInstallWindow(this); | ||
605 | |||
606 | connect(m_themesinstaller, SIGNAL(done(bool)), this, SLOT(continueInstall(bool))); | ||
607 | m_themesinstaller->setLogger(m_logger); | ||
608 | m_themesinstaller->setModal(true); | ||
609 | m_themesinstaller->install(); | ||
610 | } | ||
611 | else { | ||
612 | LOG_INFO() << "Themes install disabled."; | ||
613 | emit installSkipped(false); | ||
614 | } | ||
615 | } | ||
616 | |||
617 | static const struct { | ||
618 | const char *name; // display name | ||
619 | const char *rockfile; // rock file to look for | ||
620 | PlayerBuildInfo::BuildInfo zipurl; // download url | ||
621 | } PluginDataFiles[] = { | ||
622 | { "Doom", "games/doom.rock", PlayerBuildInfo::DoomUrl }, | ||
623 | { "Duke3D", "games/duke3d.rock", PlayerBuildInfo::Duke3DUrl }, | ||
624 | { "Quake", "games/quake.rock", PlayerBuildInfo::QuakeUrl }, | ||
625 | { "Puzzles fonts", "games/sgt-blackbox.rock", PlayerBuildInfo::PuzzFontsUrl }, | ||
626 | { "Wolf3D", "games/wolf3d.rock", PlayerBuildInfo::Wolf3DUrl }, | ||
627 | { "XWorld", "games/xworld.rock", PlayerBuildInfo::XWorldUrl }, | ||
628 | { "MIDI Patchset", "viewers/midi.rock", PlayerBuildInfo::MidiPatchsetUrl }, | ||
629 | }; | ||
630 | |||
631 | void SelectiveInstallWidget::installPluginData(void) | ||
632 | { | ||
633 | if(ui.pluginDataCheckbox->isChecked()) { | ||
634 | // build a list of zip urls that we need, then install | ||
635 | QStringList dataUrls; | ||
636 | QStringList dataName; | ||
637 | |||
638 | for(size_t i = 0; i < sizeof(PluginDataFiles) / sizeof(PluginDataFiles[0]); i++) | ||
639 | { | ||
640 | // check if installed Rockbox has this plugin. | ||
641 | if(QFileInfo(m_mountpoint + "/.rockbox/rocks/" + PluginDataFiles[i].rockfile).exists()) { | ||
642 | dataName.append(PluginDataFiles[i].name); | ||
643 | // game URLs do not depend on the actual build type, but we need | ||
644 | // to pass it (simplifies the API, and will allow to make them | ||
645 | // type specific later if needed) | ||
646 | dataUrls.append(PlayerBuildInfo::instance()->value( | ||
647 | PluginDataFiles[i].zipurl, m_buildtype).toString()); | ||
648 | } | ||
649 | } | ||
650 | |||
651 | if(dataUrls.size() == 0) | ||
652 | { | ||
653 | m_logger->addItem( | ||
654 | tr("Your installation doesn't require any plugin data files, skipping."), | ||
655 | LOGINFO); | ||
656 | emit installSkipped(false); | ||
657 | return; | ||
658 | } | ||
659 | |||
660 | LOG_INFO() << "installing plugin data files"; | ||
661 | |||
662 | // create new zip installer | ||
663 | if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater(); | ||
664 | m_zipinstaller = new ZipInstaller(this); | ||
665 | |||
666 | m_zipinstaller->setUrl(dataUrls); | ||
667 | m_zipinstaller->setLogSection(dataName); | ||
668 | m_zipinstaller->setLogVersion(); | ||
669 | m_zipinstaller->setMountPoint(m_mountpoint); | ||
670 | if(!RbSettings::value(RbSettings::CacheDisabled).toBool()) | ||
671 | m_zipinstaller->setCache(true); | ||
672 | connect(m_zipinstaller, SIGNAL(done(bool)), this, SLOT(continueInstall(bool))); | ||
673 | connect(m_zipinstaller, SIGNAL(logItem(QString, int)), m_logger, SLOT(addItem(QString, int))); | ||
674 | connect(m_zipinstaller, SIGNAL(logProgress(int, int)), m_logger, SLOT(setProgress(int, int))); | ||
675 | connect(m_logger, SIGNAL(aborted()), m_zipinstaller, SLOT(abort())); | ||
676 | m_zipinstaller->install(); | ||
677 | } | ||
678 | else { | ||
679 | LOG_INFO() << "Gamefile install disabled."; | ||
680 | emit installSkipped(false); | ||
681 | } | ||
682 | } | ||
683 | |||
684 | void SelectiveInstallWidget::changeEvent(QEvent *e) | ||
685 | { | ||
686 | if(e->type() == QEvent::LanguageChange) { | ||
687 | ui.retranslateUi(this); | ||
688 | } else { | ||
689 | QWidget::changeEvent(e); | ||
690 | } | ||
691 | } | ||