summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2020-11-21 19:51:09 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2020-11-22 14:43:01 +0100
commit0d2257d1f79e6c863e77dd93d8abae7d627062ad (patch)
tree811c1aabaf47bcd1efa85343709f568bbc502136 /rbutil/rbutilqt
parentc2dacf6736dfcde92a4ed947f06fd85c6b2087d4 (diff)
downloadrockbox-0d2257d1f79e6c863e77dd93d8abae7d627062ad.tar.gz
rockbox-0d2257d1f79e6c863e77dd93d8abae7d627062ad.zip
rbutil: Replace stringly types build type handling with enum.
Avoid having to repeat the same strings for lookup again and again and use an enum instead, which is also less error prone. Change-Id: I6ee8393948dbce97cb53850a6d8bdc4de12b4167
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/gui/selectiveinstallwidget.cpp78
-rw-r--r--rbutil/rbutilqt/gui/selectiveinstallwidget.h5
2 files changed, 46 insertions, 37 deletions
diff --git a/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp b/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
index 8a83c6ebc5..4dc6b37eab 100644
--- a/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
+++ b/rbutil/rbutilqt/gui/selectiveinstallwidget.cpp
@@ -63,23 +63,29 @@ SelectiveInstallWidget::SelectiveInstallWidget(QWidget* parent) : QWidget(parent
63 63
64void SelectiveInstallWidget::selectedVersionChanged(int index) 64void SelectiveInstallWidget::selectedVersionChanged(int index)
65{ 65{
66 m_buildtype = ui.selectedVersion->itemData(index).toString(); 66 m_buildtype = static_cast<SystemInfo::BuildType>(ui.selectedVersion->itemData(index).toInt());
67 bool voice = true; 67 bool voice = true;
68 if(m_buildtype == "release") { 68 switch(m_buildtype) {
69 case SystemInfo::BuildRelease:
69 ui.selectedDescription->setText(tr("This is the latest stable " 70 ui.selectedDescription->setText(tr("This is the latest stable "
70 "release available.")); 71 "release available."));
71 voice = true; 72 voice = true;
72 } 73 break;
73 if(m_buildtype == "development") { 74 case SystemInfo::BuildCurrent:
74 ui.selectedDescription->setText(tr("The development version is " 75 ui.selectedDescription->setText(tr("The development version is "
75 "updated on every code change. Last update was on %1").arg( 76 "updated on every code change. Last update was on %1").arg(
76 ServerInfo::instance()->platformValue(ServerInfo::BleedingDate).toString())); 77 ServerInfo::instance()->platformValue(ServerInfo::BleedingDate).toString()));
77 voice = false; 78 voice = false;
78 } 79 break;
79 if(m_buildtype == "rc") { 80 case SystemInfo::BuildCandidate:
80 ui.selectedDescription->setText(tr("This will eventually become the " 81 ui.selectedDescription->setText(tr("This will eventually become the "
81 "next Rockbox version. Install it to help testing.")); 82 "next Rockbox version. Install it to help testing."));
82 voice = false; 83 voice = false;
84 break;
85 case SystemInfo::BuildDaily:
86 ui.selectedDescription->setText(tr("Daily updated development version."));
87 voice = true;
88 break;
83 } 89 }
84 ui.voiceCheckbox->setEnabled(voice); 90 ui.voiceCheckbox->setEnabled(voice);
85 ui.voiceCombobox->setEnabled(voice); 91 ui.voiceCombobox->setEnabled(voice);
@@ -102,25 +108,28 @@ void SelectiveInstallWidget::updateVersion(void)
102 108
103 // re-populate all version items 109 // re-populate all version items
104 m_versions.clear(); 110 m_versions.clear();
105 m_versions.insert("release", ServerInfo::instance()->platformValue(ServerInfo::CurReleaseVersion).toString()); 111 m_versions.insert(SystemInfo::BuildRelease, ServerInfo::instance()->platformValue(
112 ServerInfo::CurReleaseVersion).toString());
106 // Don't populate RC or development selections if target has been retired. 113 // Don't populate RC or development selections if target has been retired.
107 if (ServerInfo::instance()->platformValue(ServerInfo::CurStatus).toInt() != STATUS_RETIRED) { 114 if (ServerInfo::instance()->platformValue(ServerInfo::CurStatus).toInt() != STATUS_RETIRED) {
108 m_versions.insert("development", ServerInfo::instance()->platformValue(ServerInfo::BleedingRevision).toString()); 115 m_versions.insert(SystemInfo::BuildCurrent, ServerInfo::instance()->platformValue(
109 m_versions.insert("rc", ServerInfo::instance()->platformValue(ServerInfo::RelCandidateVersion).toString()); 116 ServerInfo::BleedingRevision).toString());
117 m_versions.insert(SystemInfo::BuildCandidate, ServerInfo::instance()->platformValue(
118 ServerInfo::RelCandidateVersion).toString());
110 } 119 }
111 120
112 ui.selectedVersion->clear(); 121 ui.selectedVersion->clear();
113 if(!m_versions["release"].isEmpty()) { 122 if(!m_versions[SystemInfo::BuildRelease].isEmpty()) {
114 ui.selectedVersion->addItem(tr("Stable Release (Version %1)").arg( 123 ui.selectedVersion->addItem(tr("Stable Release (Version %1)").arg(
115 m_versions["release"]), "release"); 124 m_versions[SystemInfo::BuildRelease]), SystemInfo::BuildRelease);
116 } 125 }
117 if(!m_versions["development"].isEmpty()) { 126 if(!m_versions[SystemInfo::BuildCurrent].isEmpty()) {
118 ui.selectedVersion->addItem(tr("Development Version (Revison %1)").arg( 127 ui.selectedVersion->addItem(tr("Development Version (Revison %1)").arg(
119 m_versions["development"]), "development"); 128 m_versions[SystemInfo::BuildCurrent]), SystemInfo::BuildCurrent);
120 } 129 }
121 if(!m_versions["rc"].isEmpty()) { 130 if(!m_versions[SystemInfo::BuildCandidate].isEmpty()) {
122 ui.selectedVersion->addItem(tr("Release Candidate (Revison %1)").arg( 131 ui.selectedVersion->addItem(tr("Release Candidate (Revison %1)").arg(
123 m_versions["rc"]), "rc"); 132 m_versions[SystemInfo::BuildCandidate]), SystemInfo::BuildCandidate);
124 } 133 }
125 134
126 // select previously selected version 135 // select previously selected version
@@ -128,7 +137,7 @@ void SelectiveInstallWidget::updateVersion(void)
128 if(index != -1) { 137 if(index != -1) {
129 ui.selectedVersion->setCurrentIndex(index); 138 ui.selectedVersion->setCurrentIndex(index);
130 } 139 }
131 else if(!m_versions["release"].isEmpty()) { 140 else if(!m_versions[SystemInfo::BuildRelease].isEmpty()) {
132 index = ui.selectedVersion->findData("release"); 141 index = ui.selectedVersion->findData("release");
133 ui.selectedVersion->setCurrentIndex(index); 142 ui.selectedVersion->setCurrentIndex(index);
134 } 143 }
@@ -418,13 +427,20 @@ void SelectiveInstallWidget::installRockbox(void)
418 RbSettings::setValue(RbSettings::Build, m_buildtype); 427 RbSettings::setValue(RbSettings::Build, m_buildtype);
419 RbSettings::sync(); 428 RbSettings::sync();
420 429
421 if(m_buildtype == "release") url = ServerInfo::instance()->platformValue( 430 switch(m_buildtype) {
422 ServerInfo::CurReleaseUrl, m_target).toString(); 431 case SystemInfo::BuildRelease:
423 else if(m_buildtype == "development") url = ServerInfo::instance()->platformValue( 432 url = ServerInfo::instance()->platformValue(
424 ServerInfo::CurDevelUrl, m_target).toString(); 433 ServerInfo::CurReleaseUrl, m_target).toString();
425 else if(m_buildtype == "rc") url = ServerInfo::instance()->platformValue( 434 break;
426 ServerInfo::RelCandidateUrl, m_target).toString(); 435 case SystemInfo::BuildCurrent:
427 436 url = ServerInfo::instance()->platformValue(
437 ServerInfo::CurDevelUrl, m_target).toString();
438 break;
439 case SystemInfo::BuildCandidate:
440 url = ServerInfo::instance()->platformValue(
441 ServerInfo::RelCandidateUrl, m_target).toString();
442 break;
443 }
428 //! install build 444 //! install build
429 if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater(); 445 if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater();
430 m_zipinstaller = new ZipInstaller(this); 446 m_zipinstaller = new ZipInstaller(this);
@@ -459,14 +475,11 @@ void SelectiveInstallWidget::installFonts(void)
459 QString fontsurl; 475 QString fontsurl;
460 QString logversion; 476 QString logversion;
461 QString relversion = installInfo.release(); 477 QString relversion = installInfo.release();
462 if(relversion.isEmpty()) { 478 if(!relversion.isEmpty()) {
463 // release is empty for non-release versions (i.e. daily / current) 479 // release is empty for non-release versions (i.e. daily / current)
464 fontsurl = SystemInfo::value(SystemInfo::FontUrl, SystemInfo::BuildDaily).toString();
465 }
466 else {
467 fontsurl = SystemInfo::value(SystemInfo::FontUrl, SystemInfo::BuildRelease).toString();
468 logversion = installInfo.release(); 480 logversion = installInfo.release();
469 } 481 }
482 fontsurl = SystemInfo::value(SystemInfo::FontUrl, m_buildtype).toString();
470 fontsurl.replace("%RELEASEVER%", relversion); 483 fontsurl.replace("%RELEASEVER%", relversion);
471 484
472 // create new zip installer 485 // create new zip installer
@@ -501,20 +514,15 @@ void SelectiveInstallWidget::installVoicefile(void)
501 QString voiceurl; 514 QString voiceurl;
502 QString logversion; 515 QString logversion;
503 QString relversion = installInfo.release(); 516 QString relversion = installInfo.release();
504 if(m_buildtype == "release") { 517 if(m_buildtype != SystemInfo::BuildRelease) {
505 // release is empty for non-release versions (i.e. daily / current) 518 // release is empty for non-release versions (i.e. daily / current)
506 voiceurl = SystemInfo::value(SystemInfo::VoiceUrl, SystemInfo::BuildRelease).toString();
507 }
508 else {
509 voiceurl = SystemInfo::value(SystemInfo::VoiceUrl, SystemInfo::BuildDaily).toString();
510 logversion = installInfo.release(); 519 logversion = installInfo.release();
511 } 520 }
521 voiceurl = SystemInfo::value(SystemInfo::VoiceUrl, m_buildtype).toString();
512 voiceurl.replace("%RELVERSION%", m_versions[m_buildtype]); 522 voiceurl.replace("%RELVERSION%", m_versions[m_buildtype]);
513 voiceurl.replace("%MODEL%", m_target); 523 voiceurl.replace("%MODEL%", m_target);
514 voiceurl.replace("%LANGUAGE%", lang); 524 voiceurl.replace("%LANGUAGE%", lang);
515 525
516 LOG_INFO() << "voicurl" << voiceurl;
517
518 // create new zip installer 526 // create new zip installer
519 if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater(); 527 if(m_zipinstaller != nullptr) m_zipinstaller->deleteLater();
520 m_zipinstaller = new ZipInstaller(this); 528 m_zipinstaller = new ZipInstaller(this);
diff --git a/rbutil/rbutilqt/gui/selectiveinstallwidget.h b/rbutil/rbutilqt/gui/selectiveinstallwidget.h
index ac07e24ab8..38cce78a46 100644
--- a/rbutil/rbutilqt/gui/selectiveinstallwidget.h
+++ b/rbutil/rbutilqt/gui/selectiveinstallwidget.h
@@ -24,6 +24,7 @@
24#include "progressloggergui.h" 24#include "progressloggergui.h"
25#include "zipinstaller.h" 25#include "zipinstaller.h"
26#include "themesinstallwindow.h" 26#include "themesinstallwindow.h"
27#include "systeminfo.h"
27 28
28class SelectiveInstallWidget : public QWidget 29class SelectiveInstallWidget : public QWidget
29{ 30{
@@ -61,9 +62,9 @@ class SelectiveInstallWidget : public QWidget
61 ProgressLoggerGui *m_logger; 62 ProgressLoggerGui *m_logger;
62 int m_installStage; 63 int m_installStage;
63 ZipInstaller *m_zipinstaller; 64 ZipInstaller *m_zipinstaller;
64 QMap<QString, QString> m_versions; 65 QMap<SystemInfo::BuildType, QString> m_versions;
65 ThemesInstallWindow *m_themesinstaller; 66 ThemesInstallWindow *m_themesinstaller;
66 QString m_buildtype; 67 SystemInfo::BuildType m_buildtype;
67}; 68};
68 69
69#endif 70#endif