aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@users.noreply.github.com>2021-04-08 21:29:10 +0200
committerGitHub <noreply@github.com>2021-04-08 21:29:10 +0200
commit4ca481b2b34e711112eb7a257fc2385c0dce9dd2 (patch)
tree71de507b05d1a184031b4679fca25a288f87548a
parente5804b1279cd0588d9434f298675ccd89fe21fc8 (diff)
parent524fc5b6ecf9e5f193db1173164ae23c6e6702b1 (diff)
downloadPrismLauncher-4ca481b2b34e711112eb7a257fc2385c0dce9dd2.tar.gz
PrismLauncher-4ca481b2b34e711112eb7a257fc2385c0dce9dd2.tar.bz2
PrismLauncher-4ca481b2b34e711112eb7a257fc2385c0dce9dd2.zip
Merge pull request #3715 from jamierocks/atl-trycatch-json
NOISSUE Fedora build, ATL exceptions, and language tweaks
-rw-r--r--api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp12
-rw-r--r--api/logic/modplatform/modpacksch/FTBPackInstallTask.cpp2
-rw-r--r--api/logic/translations/TranslationsModel.cpp23
-rw-r--r--application/CMakeLists.txt5
-rw-r--r--application/KonamiCode.cpp2
-rw-r--r--application/pages/modplatform/atlauncher/AtlListModel.cpp (renamed from application/pages/modplatform/atlauncher/AtlModel.cpp)13
-rw-r--r--application/pages/modplatform/atlauncher/AtlListModel.h (renamed from application/pages/modplatform/atlauncher/AtlModel.h)0
-rw-r--r--application/pages/modplatform/atlauncher/AtlPage.h2
-rw-r--r--libraries/ganalytics/src/ganalytics_worker.cpp2
9 files changed, 38 insertions, 23 deletions
diff --git a/api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp b/api/logic/modplatform/atlauncher/ATLPackInstallTask.cpp
index 25c6d58d..12ceaccd 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 59546b00..068e3592 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/api/logic/translations/TranslationsModel.cpp b/api/logic/translations/TranslationsModel.cpp
index adb3fa98..401b64d4 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
diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt
index afd13574..fd49c267 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/KonamiCode.cpp b/application/KonamiCode.cpp
index 4c5af837..46a2a0b2 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<int>(konamiCode.size()))
{
m_progress = 0;
emit triggered();
diff --git a/application/pages/modplatform/atlauncher/AtlModel.cpp b/application/pages/modplatform/atlauncher/AtlListModel.cpp
index 4b1b1c8e..f3be6198 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 <BuildConfig.h>
#include <MultiMC.h>
#include <Env.h>
+#include <Json.h>
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
index 2d30a64e..2d30a64e 100644
--- a/application/pages/modplatform/atlauncher/AtlModel.h
+++ b/application/pages/modplatform/atlauncher/AtlListModel.h
diff --git a/application/pages/modplatform/atlauncher/AtlPage.h b/application/pages/modplatform/atlauncher/AtlPage.h
index 368de666..715cf5f4 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 <QWidget>
diff --git a/libraries/ganalytics/src/ganalytics_worker.cpp b/libraries/ganalytics/src/ganalytics_worker.cpp
index 5980d3bd..b0ae75a4 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();