From 3a1abb555b844c79a80615727b11019403767ce7 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Mon, 5 Apr 2021 21:10:37 +0100 Subject: [PATCH 1/4] GH-3575 Fix build on Fedora 34 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Presumably this is caused by the bump to GCC 11 in Fedora 34. See the error that did occur below... ./MultiMC5/application/KonamiCode.cpp: In member function ‘void KonamiCode::input(QEvent*)’: ./MultiMC5/application/KonamiCode.cpp:38:23: error: comparison of integer expressions of different signedness: ‘int’ and ‘std::array::size_type’ {aka ‘long unsigned int’} [-Werror=sign-compare] 38 | if(m_progress == konamiCode.size()) | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ --- application/KonamiCode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/KonamiCode.cpp b/application/KonamiCode.cpp index 4c5af8371..46a2a0b2e 100644 --- a/application/KonamiCode.cpp +++ b/application/KonamiCode.cpp @@ -35,7 +35,7 @@ void KonamiCode::input(QEvent* event) { m_progress = 0; } - if(m_progress == konamiCode.size()) + if(m_progress == static_cast(konamiCode.size())) { m_progress = 0; emit triggered(); From d6dc22d57c33497b5908abaf53770cde1773c0a7 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Mon, 5 Apr 2021 21:19:05 +0100 Subject: [PATCH 2/4] NOISSUE Handle JSON exceptions in ATLauncher support Thanks to phit for pointing this out :) --- application/CMakeLists.txt | 5 ++--- .../atlauncher/{AtlModel.cpp => AtlListModel.cpp} | 13 +++++++++++-- .../atlauncher/{AtlModel.h => AtlListModel.h} | 0 application/pages/modplatform/atlauncher/AtlPage.h | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) rename application/pages/modplatform/atlauncher/{AtlModel.cpp => AtlListModel.cpp} (93%) rename application/pages/modplatform/atlauncher/{AtlModel.h => AtlListModel.h} (100%) diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index afd13574f..fd49c2673 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -125,13 +125,12 @@ SET(MULTIMC_SOURCES pages/modplatform/VanillaPage.cpp pages/modplatform/VanillaPage.h - pages/modplatform/atlauncher/AtlModel.cpp - pages/modplatform/atlauncher/AtlModel.h pages/modplatform/atlauncher/AtlFilterModel.cpp pages/modplatform/atlauncher/AtlFilterModel.h + pages/modplatform/atlauncher/AtlListModel.cpp + pages/modplatform/atlauncher/AtlListModel.h pages/modplatform/atlauncher/AtlPage.cpp pages/modplatform/atlauncher/AtlPage.h - pages/modplatform/atlauncher/AtlPage.h pages/modplatform/ftb/FtbFilterModel.cpp pages/modplatform/ftb/FtbFilterModel.h diff --git a/application/pages/modplatform/atlauncher/AtlModel.cpp b/application/pages/modplatform/atlauncher/AtlListModel.cpp similarity index 93% rename from application/pages/modplatform/atlauncher/AtlModel.cpp rename to application/pages/modplatform/atlauncher/AtlListModel.cpp index 4b1b1c8e0..f3be61989 100644 --- a/application/pages/modplatform/atlauncher/AtlModel.cpp +++ b/application/pages/modplatform/atlauncher/AtlListModel.cpp @@ -1,8 +1,9 @@ -#include "AtlModel.h" +#include "AtlListModel.h" #include #include #include +#include namespace Atl { @@ -99,7 +100,15 @@ void ListModel::requestFinished() auto packObj = packRaw.toObject(); ATLauncher::IndexedPack pack; - ATLauncher::loadIndexedPack(pack, packObj); + + try { + ATLauncher::loadIndexedPack(pack, packObj); + } + catch (const JSONValidationError &e) { + qDebug() << QString::fromUtf8(response); + qWarning() << "Error while reading pack manifest from ATLauncher: " << e.cause(); + return; + } // ignore packs without a published version if(pack.versions.length() == 0) continue; diff --git a/application/pages/modplatform/atlauncher/AtlModel.h b/application/pages/modplatform/atlauncher/AtlListModel.h similarity index 100% rename from application/pages/modplatform/atlauncher/AtlModel.h rename to application/pages/modplatform/atlauncher/AtlListModel.h diff --git a/application/pages/modplatform/atlauncher/AtlPage.h b/application/pages/modplatform/atlauncher/AtlPage.h index 368de666f..715cf5f47 100644 --- a/application/pages/modplatform/atlauncher/AtlPage.h +++ b/application/pages/modplatform/atlauncher/AtlPage.h @@ -16,7 +16,7 @@ #pragma once #include "AtlFilterModel.h" -#include "AtlModel.h" +#include "AtlListModel.h" #include From 64617201b029c0df72974e91d3314b5ee0e80971 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Thu, 8 Apr 2021 18:05:44 +0100 Subject: [PATCH 3/4] GH-3334 Show English variants correctly This will no longer show 'American English' with the statistics of 'British English', yet show the correct translations - and will now display 'British English'. --- api/logic/translations/TranslationsModel.cpp | 23 +++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/api/logic/translations/TranslationsModel.cpp b/api/logic/translations/TranslationsModel.cpp index adb3fa98d..401b64d4c 100644 --- a/api/logic/translations/TranslationsModel.cpp +++ b/api/logic/translations/TranslationsModel.cpp @@ -15,7 +15,19 @@ #include "POTranslator.h" -const static QLatin1Literal defaultLangCode("en"); +const static QLatin1Literal defaultLangCode("en_US"); + +static QLocale getLocaleFromKey(const QString &key) { + if(key == "pt") { + return QLocale("pt_PT"); + } + else if (key == "en") { + return QLocale("en_GB"); + } + else { + return QLocale(key); + } +} enum class FileType { @@ -33,12 +45,7 @@ struct Language Language(const QString & _key) { key = _key; - if(key == "pt") { - locale = QLocale("pt_PT"); - } - else { - locale = QLocale(key); - } + locale = getLocaleFromKey(key); updated = (key == defaultLangCode); } @@ -452,7 +459,7 @@ bool TranslationsModel::selectLanguage(QString key) * In a multithreaded application, the default locale should be set at application startup, before any non-GUI threads are created. * This function is not reentrant. */ - QLocale locale(langCode); + QLocale locale = getLocaleFromKey(langCode); QLocale::setDefault(locale); // if it's the default UI language, finish From 524fc5b6ecf9e5f193db1173164ae23c6e6702b1 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Thu, 8 Apr 2021 18:46:22 +0100 Subject: [PATCH 4/4] NOISSUE Fix string formatting issues This allows translations to have more control over the output :) --- .../modplatform/atlauncher/ATLPackInstallTask.cpp | 12 ++++++------ .../modplatform/modpacksch/FTBPackInstallTask.cpp | 2 +- libraries/ganalytics/src/ganalytics_worker.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp b/api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp index 25c6d58d8..12ceaccd2 100644 --- a/api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp +++ b/api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp @@ -73,13 +73,13 @@ void PackInstallTask::onDownloadSucceeded() auto vlist = ENV.metadataIndex()->get("net.minecraft"); if(!vlist) { - emitFailed(tr("Failed to get local metadata index for ") + "net.minecraft"); + emitFailed(tr("Failed to get local metadata index for %1").arg("net.minecraft")); return; } auto ver = vlist->getVersion(m_version.minecraft); if (!ver) { - emitFailed(tr("Failed to get local metadata index for ") + "net.minecraft" + " " + m_version.minecraft); + emitFailed(tr("Failed to get local metadata index for '%1' v%2").arg("net.minecraft").arg(m_version.minecraft)); return; } ver->load(Net::Mode::Online); @@ -141,7 +141,7 @@ QString PackInstallTask::getDirForModType(ModType type, QString raw) qWarning() << "Unsupported mod type: " + raw; return Q_NULLPTR; case ModType::Unknown: - emitFailed(tr("Unknown mod type: ") + raw); + emitFailed(tr("Unknown mod type: %1").arg(raw)); return Q_NULLPTR; } @@ -271,7 +271,7 @@ bool PackInstallTask::createLibrariesComponent(QString instanceRoot, std::shared break; case DownloadType::Browser: case DownloadType::Unknown: - emitFailed(tr("Unknown or unsupported download type: ") + lib.download_raw); + emitFailed(tr("Unknown or unsupported download type: %1").arg(lib.download_raw)); return false; } @@ -437,13 +437,13 @@ void PackInstallTask::downloadMods() url = BuildConfig.ATL_DOWNLOAD_SERVER_URL + mod.url; break; case DownloadType::Browser: - emitFailed(tr("Unsupported download type: ") + mod.download_raw); + emitFailed(tr("Unsupported download type: %1").arg(mod.download_raw)); return; case DownloadType::Direct: url = mod.url; break; case DownloadType::Unknown: - emitFailed(tr("Unknown download type: ") + mod.download_raw); + emitFailed(tr("Unknown download type: %1").arg(mod.download_raw)); return; } diff --git a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp index 59546b00e..068e35927 100644 --- a/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp +++ b/api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp @@ -35,7 +35,7 @@ void PackInstallTask::executeTask() } if(!found) { - emitFailed("failed to find pack version " + m_version_name); + emitFailed(tr("Failed to find pack version %1").arg(m_version_name)); return; } diff --git a/libraries/ganalytics/src/ganalytics_worker.cpp b/libraries/ganalytics/src/ganalytics_worker.cpp index 5980d3bd9..b0ae75a40 100644 --- a/libraries/ganalytics/src/ganalytics_worker.cpp +++ b/libraries/ganalytics/src/ganalytics_worker.cpp @@ -237,7 +237,7 @@ void GAnalyticsWorker::postMessageFinished() int httpStausCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (httpStausCode < 200 || httpStausCode > 299) { - logMessage(GAnalytics::Error, QString("Error posting message: %s").arg(reply->errorString())); + logMessage(GAnalytics::Error, QString("Error posting message: %1").arg(reply->errorString())); // An error ocurred. Try sending later. m_timer.start();