diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-11-28 20:47:28 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-12-03 22:25:12 +0100 |
commit | b064a6cbb58a0db1a70fbac2e82242ce0c7509b1 (patch) | |
tree | c9090d367d237cbd408afbd24d5809e55a1a2653 /rbutil/rbutilqt/rbutilqt.cpp | |
parent | 78a01db47cac5fa67aeee6f1c5134f89c3e4944a (diff) | |
download | rockbox-b064a6cbb58a0db1a70fbac2e82242ce0c7509b1.tar.gz rockbox-b064a6cbb58a0db1a70fbac2e82242ce0c7509b1.zip |
rbutil: Rework and merge player and build server info handling.
Handling the data for players from rbutil.ini and the build-info data
from the server is closely related. Splitting things up into different
classes only creates tightly coupling, which is unnecessary, and the
need to differentiate between them in the application.
Merge both classes into a single one and rework handling so the
application doesn't have to deal with two separate classes anymore.
Furthermore, change URL templates to use new values from build-info
instead of hard coding them.
Change-Id: Ica550973ce23d1559110782add52bc214eba552d
Diffstat (limited to 'rbutil/rbutilqt/rbutilqt.cpp')
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index 4953db3470..a5c5967862 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp | |||
@@ -35,7 +35,7 @@ | |||
35 | #include "system.h" | 35 | #include "system.h" |
36 | #include "systrace.h" | 36 | #include "systrace.h" |
37 | #include "rbsettings.h" | 37 | #include "rbsettings.h" |
38 | #include "serverinfo.h" | 38 | #include "playerbuildinfo.h" |
39 | #include "systeminfo.h" | 39 | #include "systeminfo.h" |
40 | #include "ziputil.h" | 40 | #include "ziputil.h" |
41 | #include "infowidget.h" | 41 | #include "infowidget.h" |
@@ -224,7 +224,7 @@ void RbUtilQt::downloadInfo() | |||
224 | ui.statusbar->showMessage(tr("Downloading build information, please wait ...")); | 224 | ui.statusbar->showMessage(tr("Downloading build information, please wait ...")); |
225 | LOG_INFO() << "downloading build info"; | 225 | LOG_INFO() << "downloading build info"; |
226 | daily->setFile(&buildInfo); | 226 | daily->setFile(&buildInfo); |
227 | daily->getFile(QUrl(SystemInfo::value(SystemInfo::BuildInfoUrl).toString())); | 227 | daily->getFile(QUrl(PlayerBuildInfo::instance()->value(PlayerBuildInfo::BuildInfoUrl).toString())); |
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||
@@ -241,9 +241,9 @@ void RbUtilQt::downloadDone(bool error) | |||
241 | } | 241 | } |
242 | LOG_INFO() << "network status:" << daily->errorString(); | 242 | LOG_INFO() << "network status:" << daily->errorString(); |
243 | 243 | ||
244 | // read info into ServerInfo object | 244 | // read info into PlayerBuildInfo object |
245 | buildInfo.open(); | 245 | buildInfo.open(); |
246 | ServerInfo::instance()->readBuildInfo(buildInfo.fileName()); | 246 | PlayerBuildInfo::instance()->setBuildInfo(buildInfo.fileName()); |
247 | buildInfo.close(); | 247 | buildInfo.close(); |
248 | 248 | ||
249 | ui.statusbar->showMessage(tr("Download build information finished."), 5000); | 249 | ui.statusbar->showMessage(tr("Download build information finished."), 5000); |
@@ -380,11 +380,11 @@ void RbUtilQt::updateDevice() | |||
380 | 380 | ||
381 | /* Enable bootloader installation, if possible */ | 381 | /* Enable bootloader installation, if possible */ |
382 | bool bootloaderInstallable = | 382 | bool bootloaderInstallable = |
383 | SystemInfo::platformValue(SystemInfo::BootloaderMethod) != "none"; | 383 | PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderMethod).toString() != "none"; |
384 | 384 | ||
385 | /* Enable bootloader uninstallation, if possible */ | 385 | /* Enable bootloader uninstallation, if possible */ |
386 | bool bootloaderUninstallable = bootloaderInstallable && | 386 | bool bootloaderUninstallable = bootloaderInstallable && |
387 | SystemInfo::platformValue(SystemInfo::BootloaderMethod) != "fwpatcher"; | 387 | PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderMethod) != "fwpatcher"; |
388 | ui.labelRemoveBootloader->setEnabled(bootloaderUninstallable); | 388 | ui.labelRemoveBootloader->setEnabled(bootloaderUninstallable); |
389 | ui.buttonRemoveBootloader->setEnabled(bootloaderUninstallable); | 389 | ui.buttonRemoveBootloader->setEnabled(bootloaderUninstallable); |
390 | ui.actionRemove_bootloader->setEnabled(bootloaderUninstallable); | 390 | ui.actionRemove_bootloader->setEnabled(bootloaderUninstallable); |
@@ -395,10 +395,11 @@ void RbUtilQt::updateDevice() | |||
395 | ui.menuA_ctions->setEnabled(configurationValid); | 395 | ui.menuA_ctions->setEnabled(configurationValid); |
396 | 396 | ||
397 | // displayed device info | 397 | // displayed device info |
398 | QString brand = SystemInfo::platformValue(SystemInfo::Brand).toString(); | 398 | QString brand = PlayerBuildInfo::instance()->value(PlayerBuildInfo::Brand).toString(); |
399 | QString name | 399 | QString name |
400 | = QString("%1 (%2)").arg(SystemInfo::platformValue(SystemInfo::Name).toString(), | 400 | = QString("%1 (%2)").arg( |
401 | ServerInfo::instance()->statusAsString()); | 401 | PlayerBuildInfo::instance()->value(PlayerBuildInfo::DisplayName).toString(), |
402 | PlayerBuildInfo::instance()->statusAsString()); | ||
402 | ui.labelDevice->setText(QString("<b>%1 %2</b>").arg(brand, name)); | 403 | ui.labelDevice->setText(QString("<b>%1 %2</b>").arg(brand, name)); |
403 | 404 | ||
404 | QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString(); | 405 | QString mountpoint = RbSettings::value(RbSettings::Mountpoint).toString(); |
@@ -413,7 +414,7 @@ void RbUtilQt::updateDevice() | |||
413 | } | 414 | } |
414 | 415 | ||
415 | QPixmap pm; | 416 | QPixmap pm; |
416 | QString m = SystemInfo::platformValue(SystemInfo::PlayerPicture).toString(); | 417 | QString m = PlayerBuildInfo::instance()->value(PlayerBuildInfo::PlayerPicture).toString(); |
417 | pm.load(":/icons/players/" + m + "-small.png"); | 418 | pm.load(":/icons/players/" + m + "-small.png"); |
418 | pm = pm.scaledToHeight(QFontMetrics(QApplication::font()).height() * 3); | 419 | pm = pm.scaledToHeight(QFontMetrics(QApplication::font()).height() * 3); |
419 | ui.labelPlayerPic->setPixmap(pm); | 420 | ui.labelPlayerPic->setPixmap(pm); |
@@ -478,14 +479,14 @@ void RbUtilQt::uninstallBootloader(void) | |||
478 | // create installer | 479 | // create installer |
479 | BootloaderInstallBase *bl | 480 | BootloaderInstallBase *bl |
480 | = BootloaderInstallHelper::createBootloaderInstaller(this, | 481 | = BootloaderInstallHelper::createBootloaderInstaller(this, |
481 | SystemInfo::platformValue(SystemInfo::BootloaderMethod).toString()); | 482 | PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderMethod).toString()); |
482 | 483 | ||
483 | if(bl == nullptr) { | 484 | if(bl == nullptr) { |
484 | logger->addItem(tr("No uninstall method for this target known."), LOGERROR); | 485 | logger->addItem(tr("No uninstall method for this target known."), LOGERROR); |
485 | logger->setFinished(); | 486 | logger->setFinished(); |
486 | return; | 487 | return; |
487 | } | 488 | } |
488 | QStringList blfile = SystemInfo::platformValue(SystemInfo::BootloaderFile).toStringList(); | 489 | QStringList blfile = PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderFile).toStringList(); |
489 | QStringList blfilepath; | 490 | QStringList blfilepath; |
490 | for(int a = 0; a < blfile.size(); a++) { | 491 | for(int a = 0; a < blfile.size(); a++) { |
491 | blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString() | 492 | blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString() |
@@ -610,8 +611,8 @@ bool RbUtilQt::chkConfig(QWidget *parent) | |||
610 | 611 | ||
611 | void RbUtilQt::checkUpdate(void) | 612 | void RbUtilQt::checkUpdate(void) |
612 | { | 613 | { |
613 | QString url = SystemInfo::value(SystemInfo::RbutilUrl).toString(); | 614 | QString url = PlayerBuildInfo::instance()->value(PlayerBuildInfo::RbutilUrl).toString(); |
614 | #if defined(Q_OS_WIN32) | 615 | #if defined(Q_OS_WIN32) |
615 | url += "win32/"; | 616 | url += "win32/"; |
616 | #elif defined(Q_OS_LINUX) | 617 | #elif defined(Q_OS_LINUX) |
617 | url += "linux/"; | 618 | url += "linux/"; |
@@ -678,8 +679,8 @@ void RbUtilQt::downloadUpdateDone(bool error) | |||
678 | // if we found something newer, display info | 679 | // if we found something newer, display info |
679 | if(foundVersion != "") | 680 | if(foundVersion != "") |
680 | { | 681 | { |
681 | QString url = SystemInfo::value(SystemInfo::RbutilUrl).toString(); | 682 | QString url = PlayerBuildInfo::instance()->value(PlayerBuildInfo::RbutilUrl).toString(); |
682 | #if defined(Q_OS_WIN32) | 683 | #if defined(Q_OS_WIN32) |
683 | url += "win32/"; | 684 | url += "win32/"; |
684 | #elif defined(Q_OS_LINUX) | 685 | #elif defined(Q_OS_LINUX) |
685 | url += "linux/"; | 686 | url += "linux/"; |
@@ -707,7 +708,7 @@ void RbUtilQt::changeEvent(QEvent *e) | |||
707 | if(e->type() == QEvent::LanguageChange) { | 708 | if(e->type() == QEvent::LanguageChange) { |
708 | ui.retranslateUi(this); | 709 | ui.retranslateUi(this); |
709 | buildInfo.open(); | 710 | buildInfo.open(); |
710 | ServerInfo::instance()->readBuildInfo(buildInfo.fileName()); | 711 | PlayerBuildInfo::instance()->setBuildInfo(buildInfo.fileName()); |
711 | buildInfo.close(); | 712 | buildInfo.close(); |
712 | updateDevice(); | 713 | updateDevice(); |
713 | } else { | 714 | } else { |