Merge pull request #3715 from jamierocks/atl-trycatch-json

NOISSUE Fedora build, ATL exceptions, and language tweaks
This commit is contained in:
Petr Mrázek 2021-04-08 21:29:10 +02:00 committed by GitHub
commit 4ca481b2b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 23 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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;

View File

@ -16,7 +16,7 @@
#pragma once
#include "AtlFilterModel.h"
#include "AtlModel.h"
#include "AtlListModel.h"
#include <QWidget>

View File

@ -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();