1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Riebeling
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
24 #include "ui_rbutilqtfrm.h"
25 #include "ui_aboutbox.h"
26 #include "configure.h"
28 #include "installtalkwindow.h"
29 #include "createvoicewindow.h"
31 #include "installbootloader.h"
32 #include "installthemes.h"
33 #include "uninstallwindow.h"
37 #if defined(Q_OS_LINUX)
40 #if defined(Q_OS_WIN32)
49 RbUtilQt::RbUtilQt(QWidget
*parent
) : QMainWindow(parent
)
51 absolutePath
= qApp
->applicationDirPath();
55 settings
= new RbSettings();
61 ui
.radioPdf
->setChecked(true);
64 ui
.treeInfo
->setAlternatingRowColors(true);
65 ui
.treeInfo
->setHeaderLabels(QStringList() << tr("File") << tr("Version"));
66 ui
.treeInfo
->expandAll();
67 ui
.treeInfo
->setColumnCount(2);
69 connect(ui
.tabWidget
, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
70 connect(ui
.actionAbout_Qt
, SIGNAL(triggered()), qApp
, SLOT(aboutQt()));
71 connect(ui
.action_About
, SIGNAL(triggered()), this, SLOT(about()));
72 connect(ui
.action_Help
, SIGNAL(triggered()), this, SLOT(help()));
73 connect(ui
.action_Configure
, SIGNAL(triggered()), this, SLOT(configDialog()));
74 connect(ui
.buttonChangeDevice
, SIGNAL(clicked()), this, SLOT(configDialog()));
75 connect(ui
.buttonRockbox
, SIGNAL(clicked()), this, SLOT(installBtn()));
76 connect(ui
.buttonBootloader
, SIGNAL(clicked()), this, SLOT(installBootloaderBtn()));
77 connect(ui
.buttonFonts
, SIGNAL(clicked()), this, SLOT(installFontsBtn()));
78 connect(ui
.buttonGames
, SIGNAL(clicked()), this, SLOT(installDoomBtn()));
79 connect(ui
.buttonTalk
, SIGNAL(clicked()), this, SLOT(createTalkFiles()));
80 connect(ui
.buttonCreateVoice
, SIGNAL(clicked()), this, SLOT(createVoiceFile()));
81 connect(ui
.buttonVoice
, SIGNAL(clicked()), this, SLOT(installVoice()));
82 connect(ui
.buttonThemes
, SIGNAL(clicked()), this, SLOT(installThemes()));
83 connect(ui
.buttonRemoveRockbox
, SIGNAL(clicked()), this, SLOT(uninstall()));
84 connect(ui
.buttonRemoveBootloader
, SIGNAL(clicked()), this, SLOT(uninstallBootloader()));
85 connect(ui
.buttonDownloadManual
, SIGNAL(clicked()), this, SLOT(downloadManual()));
86 connect(ui
.buttonSmall
, SIGNAL(clicked()), this, SLOT(smallInstall()));
87 connect(ui
.buttonComplete
, SIGNAL(clicked()), this, SLOT(completeInstall()));
89 // actions accessible from the menu
90 connect(ui
.actionComplete_Installation
, SIGNAL(triggered()), this, SLOT(completeInstall()));
91 connect(ui
.actionSmall_Installation
, SIGNAL(triggered()), this, SLOT(smallInstall()));
92 connect(ui
.actionInstall_Bootloader
, SIGNAL(triggered()), this, SLOT(installBootloaderBtn()));
93 connect(ui
.actionInstall_Rockbox
, SIGNAL(triggered()), this, SLOT(installBtn()));
94 connect(ui
.actionFonts_Package
, SIGNAL(triggered()), this, SLOT(installFontsBtn()));
95 connect(ui
.actionInstall_Themes
, SIGNAL(triggered()), this, SLOT(installThemes()));
96 connect(ui
.actionInstall_Game_Files
, SIGNAL(triggered()), this, SLOT(installDoomBtn()));
97 connect(ui
.actionInstall_Voice_File
, SIGNAL(triggered()), this, SLOT(installVoice()));
98 connect(ui
.actionCreate_Voice_File
, SIGNAL(triggered()), this, SLOT(createVoiceFile()));
99 connect(ui
.actionCreate_Talk_Files
, SIGNAL(triggered()), this, SLOT(createTalkFiles()));
100 connect(ui
.actionRemove_bootloader
, SIGNAL(triggered()), this, SLOT(uninstallBootloader()));
101 connect(ui
.actionUninstall_Rockbox
, SIGNAL(triggered()), this, SLOT(uninstall()));
104 ui
.actionInstall_Rockbox_Utility_on_player
->setEnabled(false);
106 connect(ui
.actionInstall_Rockbox_Utility_on_player
, SIGNAL(triggered()), this, SLOT(installPortable()));
116 void RbUtilQt::updateTabs(int count
)
128 void RbUtilQt::downloadInfo()
130 // try to get the current build information
131 daily
= new HttpGet(this);
132 connect(daily
, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
133 connect(daily
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
134 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
135 daily
->setProxy(proxy());
136 if(settings
->cacheOffline())
137 daily
->setCache(settings
->cachePath());
138 qDebug() << "downloading build info";
139 daily
->setFile(&buildInfo
);
140 daily
->getFile(QUrl(settings
->serverConfUrl()));
144 void RbUtilQt::downloadDone(bool error
)
147 qDebug() << "network error:" << daily
->error();
150 qDebug() << "network status:" << daily
->error();
153 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
155 versmap
.insert("arch_rev", info
.value("dailies/rev").toString());
156 versmap
.insert("arch_date", info
.value("dailies/date").toString());
158 bleeding
= new HttpGet(this);
159 connect(bleeding
, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool)));
160 connect(bleeding
, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool)));
161 connect(qApp
, SIGNAL(lastWindowClosed()), daily
, SLOT(abort()));
162 bleeding
->setProxy(proxy());
163 if(settings
->cacheOffline())
164 bleeding
->setCache(settings
->cachePath());
165 bleeding
->setFile(&bleedingInfo
);
166 bleeding
->getFile(QUrl(settings
->bleedingInfo()));
168 if(chkConfig(false)) {
169 QApplication::processEvents();
170 QMessageBox::critical(this, tr("Configuration error"),
171 tr("Your configuration is invalid. This is most likely due "
172 "to a new installation of Rockbox Utility or a changed device "
173 "path. The configuation dialog will now open to allow you "
174 "correcting the problem."));
180 void RbUtilQt::downloadBleedingDone(bool error
)
182 if(error
) qDebug() << "network error:" << bleeding
->error();
185 QSettings
info(bleedingInfo
.fileName(), QSettings::IniFormat
, this);
186 bleedingInfo
.close();
187 versmap
.insert("bleed_rev", info
.value("bleeding/rev").toString());
188 versmap
.insert("bleed_date", info
.value("bleeding/timestamp").toString());
189 qDebug() << "versmap =" << versmap
;
193 void RbUtilQt::downloadDone(int id
, bool error
)
196 errorString
= tr("Network error: %1. Please check your network and proxy settings.")
197 .arg(daily
->errorString());
199 QMessageBox::about(this, "Network Error", errorString
);
201 qDebug() << "downloadDone:" << id
<< error
;
205 void RbUtilQt::about()
207 QDialog
*window
= new QDialog(this);
209 about
.setupUi(window
);
210 window
->setModal(true);
212 QFile
licence(":/docs/gpl-2.0.html");
213 licence
.open(QIODevice::ReadOnly
);
214 QTextStream
c(&licence
);
215 QString cline
= c
.readAll();
216 about
.browserLicense
->insertHtml(cline
);
217 about
.browserLicense
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
218 QFile
credits(":/docs/CREDITS");
219 credits
.open(QIODevice::ReadOnly
);
220 QTextStream
r(&credits
);
221 QString rline
= r
.readAll();
222 about
.browserCredits
->insertPlainText(rline
);
223 about
.browserCredits
->moveCursor(QTextCursor::Start
, QTextCursor::MoveAnchor
);
224 QString title
= QString("<b>The Rockbox Utility</b><br/>Version %1").arg(VERSION
);
225 about
.labelTitle
->setText(title
);
226 about
.labelHomepage
->setText("<a href='http://www.rockbox.org'>http://www.rockbox.org</a>");
233 void RbUtilQt::help()
235 QUrl
helpurl("http://www.rockbox.org/wiki/RockboxUtility");
236 QDesktopServices::openUrl(helpurl
);
240 void RbUtilQt::configDialog()
242 Config
*cw
= new Config(this);
243 cw
->setSettings(settings
);
245 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
246 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
250 void RbUtilQt::updateSettings()
252 qDebug() << "updateSettings()";
258 void RbUtilQt::updateDevice()
260 if(!settings
->curNeedsBootloader() ) {
261 ui
.buttonBootloader
->setEnabled(false);
262 ui
.buttonRemoveBootloader
->setEnabled(false);
263 ui
.labelBootloader
->setEnabled(false);
264 ui
.labelRemoveBootloader
->setEnabled(false);
267 ui
.buttonBootloader
->setEnabled(true);
268 ui
.labelBootloader
->setEnabled(true);
269 if(settings
->curBootloaderMethod() == "fwpatcher") {
270 ui
.labelRemoveBootloader
->setEnabled(false);
271 ui
.buttonRemoveBootloader
->setEnabled(false);
274 ui
.labelRemoveBootloader
->setEnabled(true);
275 ui
.buttonRemoveBootloader
->setEnabled(true);
279 // displayed device info
280 QString mountpoint
= settings
->mountpoint();
281 QString brand
= settings
->curBrand();
282 QString name
= settings
->curName();
283 if(name
.isEmpty()) name
= "<none>";
284 if(mountpoint
.isEmpty()) mountpoint
= "<invalid>";
285 ui
.labelDevice
->setText(tr("<b>%1 %2</b> at <b>%3</b>")
286 .arg(brand
, name
, QDir::toNativeSeparators(mountpoint
)));
290 void RbUtilQt::updateManual()
292 if(settings
->curPlatform() != "")
294 QString manual
= settings
->curManual();
297 manual
= "rockbox-" + settings
->curPlatform();
299 pdfmanual
= settings
->manualUrl() + "/" + manual
+ ".pdf";
301 htmlmanual
= settings
->manualUrl() + "/" + manual
+ "/rockbox-build.html";
302 ui
.labelPdfManual
->setText(tr("<a href='%1'>PDF Manual</a>")
304 ui
.labelHtmlManual
->setText(tr("<a href='%1'>HTML Manual (opens in browser)</a>")
308 ui
.labelPdfManual
->setText(tr("Select a device for a link to the correct manual"));
309 ui
.labelHtmlManual
->setText(tr("<a href='%1'>Manual Overview</a>")
310 .arg("http://www.rockbox.org/manual.shtml"));
315 void RbUtilQt::completeInstall()
317 if(chkConfig(true)) return;
318 if(QMessageBox::question(this, tr("Confirm Installation"),
319 tr("Do you really want to make a complete Installation?"),
320 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
323 logger
= new ProgressLoggerGui(this);
326 if(smallInstallInner())
332 if(!installFontsAuto())
336 // wait for installation finished
338 QApplication::processEvents();
348 if(!installDoomAuto())
352 // wait for installation finished
354 QApplication::processEvents();
361 // it has its own logger window,so close our.
367 void RbUtilQt::smallInstall()
369 if(chkConfig(true)) return;
370 if(QMessageBox::question(this, tr("Confirm Installation"),
371 tr("Do you really want to make a small Installation?"),
372 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
375 logger
= new ProgressLoggerGui(this);
381 bool RbUtilQt::smallInstallInner()
383 QString mountpoint
= settings
->mountpoint();
384 // show dialog with error if mount point is wrong
385 if(!QFileInfo(mountpoint
).isDir()) {
386 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
391 if(settings
->curNeedsBootloader())
395 if(!installBootloaderAuto())
399 // wait for boot loader installation finished
401 QApplication::processEvents();
403 if(m_error
) return true;
414 // wait for installation finished
416 QApplication::processEvents();
422 void RbUtilQt::installdone(bool error
)
424 qDebug() << "install done";
429 void RbUtilQt::installBtn()
431 if(chkConfig(true)) return;
435 bool RbUtilQt::installAuto()
437 QString file
= QString("%1%2/rockbox.zip")
438 .arg(settings
->bleedingUrl(), settings
->curPlatform());
441 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
444 if(settings
->curReleased()) {
445 // only set the keys if needed -- querying will yield an empty string
447 versmap
.insert("rel_rev", settings
->lastRelease());
448 versmap
.insert("rel_date", ""); // FIXME: provide the release timestamp
451 QString myversion
= "r" + versmap
.value("bleed_rev");
453 ZipInstaller
* installer
= new ZipInstaller(this);
454 installer
->setUrl(file
);
455 installer
->setProxy(proxy());
456 installer
->setLogSection("Rockbox (Base)");
457 installer
->setLogVersion(myversion
);
458 if(!settings
->cacheDisabled())
459 installer
->setCache(settings
->cachePath());
460 installer
->setMountPoint(settings
->mountpoint());
461 installer
->install(logger
);
463 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
468 void RbUtilQt::install()
470 Install
*installWindow
= new Install(this);
471 installWindow
->setSettings(settings
);
472 installWindow
->setProxy(proxy());
475 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
478 if(settings
->curReleased()) {
479 // only set the keys if needed -- querying will yield an empty string
481 versmap
.insert("rel_rev", settings
->lastRelease());
482 versmap
.insert("rel_date", ""); // FIXME: provide the release timestamp
484 installWindow
->setVersionStrings(versmap
);
486 installWindow
->show();
489 bool RbUtilQt::installBootloaderAuto()
492 connect(blinstaller
,SIGNAL(done(bool)),this,SLOT(installdone(bool)));
496 void RbUtilQt::installBootloaderBtn()
498 if(chkConfig(true)) return;
499 if(QMessageBox::question(this, tr("Confirm Installation"),
500 tr("Do you really want to install the Bootloader?"),
501 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
504 logger
= new ProgressLoggerGui(this);
510 void RbUtilQt::installBootloader()
512 QString platform
= settings
->curPlatform();
515 blinstaller
= new BootloaderInstaller(this);
517 blinstaller
->setMountPoint(settings
->mountpoint());
519 blinstaller
->setProxy(proxy());
520 blinstaller
->setDevice(platform
);
521 blinstaller
->setBootloaderMethod(settings
->curBootloaderMethod());
522 blinstaller
->setBootloaderName(settings
->curBootloaderName());
523 blinstaller
->setBootloaderBaseUrl(settings
->bootloaderUrl());
524 blinstaller
->setBootloaderInfoUrl(settings
->bootloaderInfoUrl());
525 if(!blinstaller
->downloadInfo())
527 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
533 if(blinstaller
->uptodate())
535 int ret
= QMessageBox::question(this, tr("Bootloader Installation"),
536 tr("The bootloader is already installed and up to date.\n"
537 "Do want to replace the current bootloader?"),
538 QMessageBox::Yes
| QMessageBox::No
, QMessageBox::No
);
539 if(ret
== QMessageBox::No
)
541 logger
->addItem(tr("Bootloader installation skipped!"), LOGINFO
);
548 // if fwpatcher , ask for extra file
550 if(settings
->curBootloaderMethod() == "fwpatcher")
552 BrowseOF
ofbrowser(this);
553 ofbrowser
.setFile(settings
->ofPath());
554 if(ofbrowser
.exec() == QDialog::Accepted
)
556 offirmware
= ofbrowser
.getFile();
557 qDebug() << offirmware
;
558 if(!QFileInfo(offirmware
).exists())
560 logger
->addItem(tr("Original Firmware Path is wrong!"),LOGERROR
);
567 settings
->setOfPath(offirmware
);
573 logger
->addItem(tr("Original Firmware selection Canceled!"),LOGERROR
);
579 blinstaller
->setOrigFirmwarePath(offirmware
);
581 blinstaller
->install(logger
);
584 void RbUtilQt::installFontsBtn()
586 if(chkConfig(true)) return;
587 if(QMessageBox::question(this, tr("Confirm Installation"),
588 tr("Do you really want to install the fonts package?"),
589 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
591 logger
= new ProgressLoggerGui(this);
596 bool RbUtilQt::installFontsAuto()
599 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
603 void RbUtilQt::installFonts()
605 // create zip installer
606 installer
= new ZipInstaller(this);
608 installer
->setUrl(settings
->fontUrl());
609 installer
->setProxy(proxy());
610 installer
->setLogSection("Fonts");
611 installer
->setLogVersion(versmap
.value("arch_date"));
612 installer
->setMountPoint(settings
->mountpoint());
613 if(!settings
->cacheDisabled())
614 installer
->setCache(settings
->cachePath());
615 installer
->install(logger
);
619 void RbUtilQt::installVoice()
621 if(chkConfig(true)) return;
622 if(QMessageBox::question(this, tr("Confirm Installation"),
623 tr("Do you really want to install the voice file?"),
624 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
626 logger
= new ProgressLoggerGui(this);
629 // create zip installer
630 installer
= new ZipInstaller(this);
631 installer
->setUnzip(false);
633 QString voiceurl
= settings
->voiceUrl() + "/" ;
635 voiceurl
+= settings
->curVoiceName() + "-" +
636 versmap
.value("arch_date") + "-english.voice";
637 qDebug() << voiceurl
;
639 installer
->setProxy(proxy());
640 installer
->setUrl(voiceurl
);
641 installer
->setLogSection("Voice");
642 installer
->setLogVersion(versmap
.value("arch_date"));
643 installer
->setMountPoint(settings
->mountpoint());
644 installer
->setTarget("/.rockbox/langs/english.voice");
645 if(!settings
->cacheDisabled())
646 installer
->setCache(settings
->cachePath());
647 installer
->install(logger
);
651 void RbUtilQt::installDoomBtn()
653 if(chkConfig(true)) return;
655 QMessageBox::critical(this, tr("Error"), tr("Your device doesn't have a doom plugin. Aborting."));
659 if(QMessageBox::question(this, tr("Confirm Installation"),
660 tr("Do you really want to install the game addon files?"),
661 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
663 logger
= new ProgressLoggerGui(this);
668 bool RbUtilQt::installDoomAuto()
671 connect(installer
, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
675 bool RbUtilQt::hasDoom()
677 QFile
doomrock(settings
->mountpoint() +"/.rockbox/rocks/games/doom.rock");
678 return doomrock
.exists();
681 void RbUtilQt::installDoom()
683 // create zip installer
684 installer
= new ZipInstaller(this);
686 installer
->setUrl(settings
->doomUrl());
687 installer
->setProxy(proxy());
688 installer
->setLogSection("Game Addons");
689 installer
->setLogVersion(versmap
.value("arch_date"));
690 installer
->setMountPoint(settings
->mountpoint());
691 if(!settings
->cacheDisabled())
692 installer
->setCache(settings
->cachePath());
693 installer
->install(logger
);
697 void RbUtilQt::installThemes()
699 if(chkConfig(true)) return;
700 ThemesInstallWindow
* tw
= new ThemesInstallWindow(this);
701 tw
->setSettings(settings
);
702 tw
->setProxy(proxy());
707 void RbUtilQt::createTalkFiles(void)
709 if(chkConfig(true)) return;
710 InstallTalkWindow
*installWindow
= new InstallTalkWindow(this);
711 installWindow
->setSettings(settings
);
712 installWindow
->show();
713 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
714 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
718 void RbUtilQt::createVoiceFile(void)
720 if(chkConfig(true)) return;
721 CreateVoiceWindow
*installWindow
= new CreateVoiceWindow(this);
722 installWindow
->setSettings(settings
);
723 installWindow
->setProxy(proxy());
725 installWindow
->show();
726 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo()));
727 connect(installWindow
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
730 void RbUtilQt::uninstall(void)
732 if(chkConfig(true)) return;
733 UninstallWindow
*uninstallWindow
= new UninstallWindow(this);
734 uninstallWindow
->setSettings(settings
);
735 uninstallWindow
->show();
739 void RbUtilQt::uninstallBootloader(void)
741 if(chkConfig(true)) return;
742 if(QMessageBox::question(this, tr("Confirm Uninstallation"),
743 tr("Do you really want to uninstall the Bootloader?"),
744 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
) return;
746 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
749 BootloaderInstaller
blinstaller(this);
750 blinstaller
.setProxy(proxy());
751 blinstaller
.setMountPoint(settings
->mountpoint());
752 blinstaller
.setDevice(settings
->curPlatform());
753 blinstaller
.setBootloaderMethod(settings
->curBootloaderMethod());
754 blinstaller
.setBootloaderName(settings
->curBootloaderName());
755 blinstaller
.setBootloaderBaseUrl(settings
->bootloaderUrl());
756 blinstaller
.setBootloaderInfoUrl(settings
->bootloaderInfoUrl());
757 if(!blinstaller
.downloadInfo())
759 logger
->addItem(tr("Could not get the bootloader info file!"),LOGERROR
);
764 blinstaller
.uninstall(logger
);
769 void RbUtilQt::downloadManual(void)
771 if(chkConfig(true)) return;
772 if(QMessageBox::question(this, tr("Confirm download"),
773 tr("Do you really want to download the manual? The manual will be saved "
774 "to the root folder of your player."),
775 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
779 QSettings
info(buildInfo
.fileName(), QSettings::IniFormat
, this);
782 QString manual
= settings
->curManual();
784 QString date
= (info
.value("dailies/date").toString());
789 if(ui
.radioPdf
->isChecked()) {
790 target
= "/" + manual
+ ".pdf";
791 section
= "Manual (PDF)";
794 target
= "/" + manual
+ "-" + date
+ "-html.zip";
795 section
= "Manual (HTML)";
797 manualurl
= settings
->manualUrl() + "/" + target
;
798 qDebug() << "manualurl =" << manualurl
;
800 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
802 installer
= new ZipInstaller(this);
803 installer
->setMountPoint(settings
->mountpoint());
804 if(!settings
->cacheDisabled())
805 installer
->setCache(settings
->cachePath());
806 installer
->setProxy(proxy());
807 installer
->setLogSection(section
);
808 installer
->setLogVersion(date
);
809 installer
->setUrl(manualurl
);
810 installer
->setUnzip(false);
811 installer
->setTarget(target
);
812 installer
->install(logger
);
816 void RbUtilQt::installPortable(void)
818 if(QMessageBox::question(this, tr("Confirm installation"),
819 tr("Do you really want to install Rockbox Utility to your player? "
820 "After installation you can run it from the players hard drive."),
821 QMessageBox::Yes
| QMessageBox::No
) != QMessageBox::Yes
)
824 ProgressLoggerGui
* logger
= new ProgressLoggerGui(this);
825 logger
->setProgressMax(0);
826 logger
->setProgressValue(0);
828 logger
->addItem(tr("Installing Rockbox Utility"), LOGINFO
);
831 if(!QFileInfo(settings
->mountpoint()).isDir()) {
832 logger
->addItem(tr("Mount point is wrong!"),LOGERROR
);
837 // remove old files first.
838 QFile::remove(settings
->mountpoint() + "/RockboxUtility.exe");
839 QFile::remove(settings
->mountpoint() + "/RockboxUtility.ini");
840 // copy currently running binary and currently used settings file
841 if(!QFile::copy(qApp
->applicationFilePath(), settings
->mountpoint() + "/RockboxUtility.exe")) {
842 logger
->addItem(tr("Error installing Rockbox Utility"), LOGERROR
);
846 logger
->addItem(tr("Installing user configuration"), LOGINFO
);
847 if(!QFile::copy(settings
->userSettingFilename(), settings
->mountpoint() + "/RockboxUtility.ini")) {
848 logger
->addItem(tr("Error installing user configuration"), LOGERROR
);
852 logger
->addItem(tr("Successfully installed Rockbox Utility."), LOGOK
);
854 logger
->setProgressMax(1);
855 logger
->setProgressValue(1);
860 void RbUtilQt::updateInfo()
862 qDebug() << "RbUtilQt::updateInfo()";
864 QSettings
log(settings
->mountpoint() + "/.rockbox/rbutil.log", QSettings::IniFormat
, this);
865 QStringList groups
= log
.childGroups();
866 QList
<QTreeWidgetItem
*> items
;
867 QTreeWidgetItem
*w
, *w2
;
871 // remove old list entries (if any)
872 int l
= ui
.treeInfo
->topLevelItemCount();
875 m
= ui
.treeInfo
->takeTopLevelItem(l
);
876 // delete childs (single level deep, no recursion here)
877 int n
= m
->childCount();
881 // get and populate new items
882 for(int a
= 0; a
< groups
.size(); a
++) {
883 log
.beginGroup(groups
.at(a
));
884 QStringList keys
= log
.allKeys();
885 w
= new QTreeWidgetItem
;
886 w
->setFlags(Qt::ItemIsEnabled
);
887 w
->setText(0, groups
.at(a
));
889 // get minimum and maximum version information so we can hilight old files
890 min
= max
= log
.value(keys
.at(0)).toString();
891 for(int b
= 0; b
< keys
.size(); b
++) {
892 if(log
.value(keys
.at(b
)).toString() > max
)
893 max
= log
.value(keys
.at(b
)).toString();
894 if(log
.value(keys
.at(b
)).toString() < min
)
895 min
= log
.value(keys
.at(b
)).toString();
898 for(int b
= 0; b
< keys
.size(); b
++) {
900 file
= settings
->mountpoint() + "/" + keys
.at(b
);
901 if(QFileInfo(file
).isDir())
903 w2
= new QTreeWidgetItem(w
, QStringList() << "/"
904 + keys
.at(b
) << log
.value(keys
.at(b
)).toString());
905 if(log
.value(keys
.at(b
)).toString() != max
) {
906 w2
->setForeground(0, QBrush(QColor(255, 0, 0)));
907 w2
->setForeground(1, QBrush(QColor(255, 0, 0)));
914 w
->setData(1, Qt::DisplayRole
, QString("%1 / %2").arg(min
, max
));
916 w
->setData(1, Qt::DisplayRole
, max
);
918 ui
.treeInfo
->insertTopLevelItems(0, items
);
919 ui
.treeInfo
->resizeColumnToContents(0);
923 QUrl
RbUtilQt::proxy()
925 if(settings
->proxyType() == "manual")
926 return QUrl(settings
->proxy());
927 else if(settings
->proxy() == "system")
929 return systemProxy();
935 bool RbUtilQt::chkConfig(bool warn
)
938 if(settings
->curPlatform().isEmpty()
939 || settings
->mountpoint().isEmpty()
940 || !QFileInfo(settings
->mountpoint()).isWritable()) {
943 if(warn
) QMessageBox::critical(this, tr("Configuration error"),
944 tr("Your configuration is invalid. Please go to the configuration "
945 "dialog and make sure the selected values are correct."));