code cleanup, remove first start prompt
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Syping 2021-01-29 19:46:01 +01:00
parent fd5006e70f
commit 929d341826
20 changed files with 279 additions and 512 deletions

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2020 Syping
* Copyright (C) 2016-2021 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -33,12 +33,8 @@
#include <QDesktopWidget>
#endif
#include <iostream>
using namespace std;
AppEnv::AppEnv()
{
}
// Build Stuff
@ -59,12 +55,11 @@ QString AppEnv::getGameFolder(bool *ok)
{
QDir dir;
QString GTAV_FOLDER = QString::fromUtf8(qgetenv("GTAV_FOLDER"));
if (GTAV_FOLDER != "")
{
if (GTAV_FOLDER != "") {
dir.setPath(GTAV_FOLDER);
if (dir.exists())
{
if (ok != NULL) *ok = true;
if (dir.exists()) {
if (ok != NULL)
*ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
}
@ -79,46 +74,44 @@ QString AppEnv::getGameFolder(bool *ok)
GTAV_returnFolder = settings.value("dir", GTAV_defaultFolder).toString();
settings.endGroup();
if (forceDir)
{
if (forceDir) {
dir.setPath(GTAV_returnFolder);
if (dir.exists())
{
if (ok != 0) *ok = true;
if (dir.exists()) {
if (ok != 0)
*ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
}
}
dir.setPath(GTAV_defaultFolder);
if (dir.exists())
{
if (ok != 0) *ok = true;
if (dir.exists()) {
if (ok != 0)
*ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
}
if (!forceDir)
{
if (!forceDir) {
dir.setPath(GTAV_returnFolder);
if (dir.exists())
{
if (ok != 0) *ok = true;
if (dir.exists()) {
if (ok != 0)
*ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath();
}
}
if (ok != 0) *ok = false;
return "";
if (ok != 0)
*ok = false;
return QString();
}
bool AppEnv::setGameFolder(QString gameFolder)
{
QDir dir;
dir.setPath(gameFolder);
if (dir.exists())
{
if (dir.exists()) {
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return true;
}
@ -160,24 +153,19 @@ QByteArray AppEnv::getUserAgent()
#ifdef Q_OS_WIN
QString kernelVersion = QSysInfo::kernelVersion();
const QStringList &kernelVersionList = kernelVersion.split(".");
if (kernelVersionList.length() > 2)
{
if (kernelVersionList.length() > 2) {
kernelVersion = kernelVersionList.at(0) % "." % kernelVersionList.at(1);
}
QString runArch = QSysInfo::buildCpuArchitecture();
if (runArch == "x86_64")
{
if (runArch == "x86_64") {
runArch = "Win64; x64";
}
else if (runArch == "i686")
{
else if (runArch == "i686") {
const QString &curArch = QSysInfo::currentCpuArchitecture();
if (curArch == "x86_64")
{
if (curArch == "x86_64") {
runArch = "WOW64";
}
else if (curArch == "i686")
{
else if (curArch == "i686") {
runArch = "Win32; x86";
}
}
@ -190,11 +178,6 @@ QByteArray AppEnv::getUserAgent()
#endif
}
// QUrl AppEnv::getCrewFetchingUrl(QString crewID)
// {
// return QUrl(QString("https://socialclub.rockstargames.com/reference/crewfeed/%1").arg(crewID));
// }
QUrl AppEnv::getCrewFetchingUrl(QString crewID)
{
return QUrl(QString("https://socialclub.rockstargames.com/crew/%1/%1").arg(crewID));
@ -223,8 +206,7 @@ GameVersion AppEnv::getGameVersion()
QString installFolderSc = registrySettingsSc.value("InstallFolder", "").toString();
QDir installFolderScDir(installFolderSc);
bool scVersionInstalled = false;
if (!installFolderSc.isEmpty() && installFolderScDir.exists())
{
if (!installFolderSc.isEmpty() && installFolderScDir.exists()) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "gameVersionFoundSocialClubVersion";
#endif
@ -233,34 +215,28 @@ GameVersion AppEnv::getGameVersion()
QSettings registrySettingsSteam(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\GTAV").arg(argumentValue), QSettings::NativeFormat);
QString installFolderSteam = registrySettingsSteam.value("installfoldersteam", "").toString();
if (installFolderSteam.right(5) == "\\GTAV")
{
if (installFolderSteam.right(5) == "\\GTAV") {
installFolderSteam = installFolderSteam.remove(installFolderSteam.length() - 5, 5);
}
QDir installFolderSteamDir(installFolderSteam);
bool steamVersionInstalled = false;
if (!installFolderSteam.isEmpty() && installFolderSteamDir.exists())
{
if (!installFolderSteam.isEmpty() && installFolderSteamDir.exists()) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "gameVersionFoundSteamVersion";
#endif
steamVersionInstalled = true;
}
if (scVersionInstalled && steamVersionInstalled)
{
if (scVersionInstalled && steamVersionInstalled) {
return GameVersion::BothVersions;
}
else if (scVersionInstalled)
{
else if (scVersionInstalled) {
return GameVersion::SocialClubVersion;
}
else if (steamVersionInstalled)
{
else if (steamVersionInstalled) {
return GameVersion::SteamVersion;
}
else
{
else {
return GameVersion::NoVersion;
}
#else
@ -270,8 +246,7 @@ GameVersion AppEnv::getGameVersion()
GameLanguage AppEnv::getGameLanguage(GameVersion gameVersion)
{
if (gameVersion == GameVersion::SocialClubVersion)
{
if (gameVersion == GameVersion::SocialClubVersion) {
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
@ -284,8 +259,7 @@ GameLanguage AppEnv::getGameLanguage(GameVersion gameVersion)
return GameLanguage::Undefined;
#endif
}
else if (gameVersion == GameVersion::SteamVersion)
{
else if (gameVersion == GameVersion::SteamVersion) {
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
@ -298,128 +272,81 @@ GameLanguage AppEnv::getGameLanguage(GameVersion gameVersion)
return GameLanguage::Undefined;
#endif
}
else
{
return GameLanguage::Undefined;
}
return GameLanguage::Undefined;
}
GameLanguage AppEnv::gameLanguageFromString(QString gameLanguage)
{
if (gameLanguage == "en-US")
{
if (gameLanguage == "en-US") {
return GameLanguage::English;
}
else if (gameLanguage == "fr-FR")
{
else if (gameLanguage == "fr-FR") {
return GameLanguage::French;
}
else if (gameLanguage == "it-IT")
{
else if (gameLanguage == "it-IT") {
return GameLanguage::Italian;
}
else if (gameLanguage == "de-DE")
{
else if (gameLanguage == "de-DE") {
return GameLanguage::German;
}
else if (gameLanguage == "es-ES")
{
else if (gameLanguage == "es-ES") {
return GameLanguage::Spanish;
}
else if (gameLanguage == "es-MX")
{
else if (gameLanguage == "es-MX") {
return GameLanguage::Mexican;
}
else if (gameLanguage == "pt-BR")
{
else if (gameLanguage == "pt-BR") {
return GameLanguage::Brasilian;
}
else if (gameLanguage == "ru-RU")
{
else if (gameLanguage == "ru-RU") {
return GameLanguage::Russian;
}
else if (gameLanguage == "pl-PL")
{
else if (gameLanguage == "pl-PL") {
return GameLanguage::Polish;
}
else if (gameLanguage == "ja-JP")
{
else if (gameLanguage == "ja-JP") {
return GameLanguage::Japanese;
}
else if (gameLanguage == "zh-CHS")
{
else if (gameLanguage == "zh-CHS") {
return GameLanguage::SChinese;
}
else if (gameLanguage == "zh-CHT")
{
else if (gameLanguage == "zh-CHT") {
return GameLanguage::TChinese;
}
else if (gameLanguage == "ko-KR")
{
return GameLanguage::Koreana;
}
else
{
return GameLanguage::Undefined;
else if (gameLanguage == "ko-KR") {
return GameLanguage::Korean;
}
return GameLanguage::Undefined;
}
QString AppEnv::gameLanguageToString(GameLanguage gameLanguage)
{
if (gameLanguage == GameLanguage::English)
{
switch (gameLanguage) {
case GameLanguage::English:
return "en-US";
}
else if (gameLanguage == GameLanguage::French)
{
case GameLanguage::French:
return "fr-FR";
}
else if (gameLanguage == GameLanguage::Italian)
{
case GameLanguage::Italian:
return "it-IT";
}
else if (gameLanguage == GameLanguage::German)
{
case GameLanguage::German:
return "de-DE";
}
else if (gameLanguage == GameLanguage::Spanish)
{
case GameLanguage::Spanish:
return "es-ES";
}
else if (gameLanguage == GameLanguage::Mexican)
{
case GameLanguage::Mexican:
return "es-MX";
}
else if (gameLanguage == GameLanguage::Brasilian)
{
case GameLanguage::Brasilian:
return "pt-BR";
}
else if (gameLanguage == GameLanguage::Russian)
{
return "ru-RU";
}
else if (gameLanguage == GameLanguage::Polish)
{
case GameLanguage::Polish:
return "pl-PL";
}
else if (gameLanguage == GameLanguage::Japanese)
{
case GameLanguage::Japanese:
return "ja-JP";
}
else if (gameLanguage == GameLanguage::SChinese)
{
case GameLanguage::SChinese:
return "zh-CHS";
}
else if (gameLanguage == GameLanguage::TChinese)
{
case GameLanguage::TChinese:
return "zh-CHT";
}
else if (gameLanguage == GameLanguage::Koreana)
{
case GameLanguage::Korean:
return "ko-KR";
}
else
{
default:
return "Undefinied";
}
}
@ -428,67 +355,55 @@ bool AppEnv::setGameLanguage(GameVersion gameVersion, GameLanguage gameLanguage)
{
bool socialClubVersion = false;
bool steamVersion = false;
if (gameVersion == GameVersion::SocialClubVersion)
{
if (gameVersion == GameVersion::SocialClubVersion) {
socialClubVersion = true;
}
else if (gameVersion == GameVersion::SteamVersion)
{
else if (gameVersion == GameVersion::SteamVersion) {
steamVersion = true;
}
else if (gameVersion == GameVersion::BothVersions)
{
else if (gameVersion == GameVersion::BothVersions) {
socialClubVersion = true;
steamVersion = true;
}
else
{
else {
return false;
}
if (socialClubVersion)
{
if (socialClubVersion) {
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
argumentValue = "\\WOW6432Node";
#endif
QSettings registrySettingsSc(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\Grand Theft Auto V").arg(argumentValue), QSettings::NativeFormat);
if (gameLanguage != GameLanguage::Undefined)
{
if (gameLanguage != GameLanguage::Undefined) {
registrySettingsSc.setValue("Language", gameLanguageToString(gameLanguage));
}
else
{
else {
registrySettingsSc.remove("Language");
}
registrySettingsSc.sync();
if (registrySettingsSc.status() != QSettings::NoError)
{
if (registrySettingsSc.status() != QSettings::NoError) {
return false;
}
#else
Q_UNUSED(gameLanguage)
#endif
}
if (steamVersion)
{
if (steamVersion) {
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
argumentValue = "\\WOW6432Node";
#endif
QSettings registrySettingsSteam(QString("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\Rockstar Games\\Grand Theft Auto V Steam").arg(argumentValue), QSettings::NativeFormat);
if (gameLanguage != GameLanguage::Undefined)
{
if (gameLanguage != GameLanguage::Undefined) {
registrySettingsSteam.setValue("Language", gameLanguageToString(gameLanguage));
}
else
{
else {
registrySettingsSteam.remove("Language");
}
registrySettingsSteam.sync();
if (registrySettingsSteam.status() != QSettings::NoError)
{
if (registrySettingsSteam.status() != QSettings::NoError) {
return false;
}
#else

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2018 Syping
* Copyright (C) 2016-2021 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,7 +23,7 @@
#include <QUrl>
enum class GameVersion : int { NoVersion = 0, SocialClubVersion = 1, SteamVersion = 2, BothVersions = 3 };
enum class GameLanguage : int { Undefined = 0, English = 1, French = 2, Italian = 3, German = 4, Spanish = 5, Mexican = 6, Brasilian = 7, Russian = 8, Polish = 9, Japanese = 10, SChinese = 11, TChinese = 12, Koreana = 13 };
enum class GameLanguage : int { Undefined = 0, English = 1, French = 2, Italian = 3, German = 4, Spanish = 5, Mexican = 6, Brasilian = 7, Russian = 8, Polish = 9, Japanese = 10, SChinese = 11, TChinese = 12, Korean = 13 };
class AppEnv
{

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2020 Syping
* Copyright (C) 2016-2021 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -46,8 +46,7 @@ void DatabaseThread::run()
QObject::connect(this, SIGNAL(threadTerminated()), &threadLoop, SLOT(quit()));
while (threadRunning)
{
while (threadRunning) {
QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
threadLoop.exec();
}
@ -55,10 +54,8 @@ void DatabaseThread::run()
void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &requestDelay)
{
for (QString crewID : crewList)
{
if (threadRunning && crewID != QLatin1String("0"))
{
for (const QString &crewID : crewList) {
if (threadRunning && crewID != QLatin1String("0")) {
QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(AppEnv::getCrewFetchingUrl(crewID));
#if QT_VERSION >= 0x050600
@ -76,40 +73,36 @@ void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &r
QEventLoop *downloadLoop = new QEventLoop();
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), downloadLoop, SLOT(quit())); }
if (!continueLastCrew)
QObject::connect(this, SIGNAL(threadTerminated()), downloadLoop, SLOT(quit()));
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
downloadLoop->exec();
downloadLoop->disconnect();
delete downloadLoop;
if (netReply->isFinished())
{
if (netReply->isFinished()) {
QString crewName;
QByteArray crewHtml = netReply->readAll();
QStringList crewHtmlSplit1 = QString::fromUtf8(crewHtml).split("<title>Rockstar Games Social Club - Crew : ");
if (crewHtmlSplit1.length() >= 2)
{
if (crewHtmlSplit1.length() >= 2) {
QStringList crewHtmlSplit2 = QString(crewHtmlSplit1.at(1)).split("</title>");
if (crewHtmlSplit2.length() >= 1)
{
if (crewHtmlSplit2.length() >= 1) {
crewName = crewHtmlSplit2.at(0);
}
}
if (!crewName.isEmpty())
{
if (!crewName.isEmpty()) {
emit crewNameFound(crewID.toInt(), crewName);
}
}
else
{
else {
netReply->abort();
}
if (threadRunning)
{
if (threadRunning) {
QEventLoop *waitingLoop = new QEventLoop();
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), waitingLoop, SLOT(quit())); }
if (!continueLastCrew)
QObject::connect(this, SIGNAL(threadTerminated()), waitingLoop, SLOT(quit()));
waitingLoop->exec();
waitingLoop->disconnect();
delete waitingLoop;
@ -123,17 +116,14 @@ void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &r
void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int &maxPages, const int &requestDelay)
{
for (QString crewID : crewList)
{
if (threadRunning && crewID != QLatin1String("0"))
{
for (const QString &crewID : crewList) {
if (threadRunning && crewID != QLatin1String("0")) {
int currentFail = 0;
int currentPage = 0;
int foundPlayers = 0;
int totalPlayers = 1000;
while(foundPlayers < totalPlayers && currentPage < maxPages && (continueLastCrew ? true : threadRunning))
{
while(foundPlayers < totalPlayers && currentPage < maxPages && (continueLastCrew ? true : threadRunning)) {
QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, currentPage));
#if QT_VERSION >= 0x050600
@ -151,14 +141,14 @@ void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int
QEventLoop *downloadLoop = new QEventLoop();
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), downloadLoop, SLOT(quit())); }
if (!continueLastCrew)
QObject::connect(this, SIGNAL(threadTerminated()), downloadLoop, SLOT(quit()));
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
downloadLoop->exec();
downloadLoop->disconnect();
delete downloadLoop;
if (netReply->isFinished())
{
if (netReply->isFinished()) {
QByteArray crewJson = netReply->readAll();
QJsonDocument crewDocument = QJsonDocument::fromJson(crewJson);
QJsonObject crewObject = crewDocument.object();
@ -166,32 +156,25 @@ void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int
if (crewMap.contains("Total")) { totalPlayers = crewMap["Total"].toInt(); }
if (crewMap.contains("Members"))
{
if (crewMap.contains("Members")) {
const QList<QVariant> memberList = crewMap["Members"].toList();
for (QVariant memberVariant : memberList)
{
for (const QVariant &memberVariant : memberList) {
QMap<QString, QVariant> memberMap = memberVariant.toMap();
if (memberMap.contains("RockstarId") && memberMap.contains("Name"))
{
if (memberMap.contains("RockstarId") && memberMap.contains("Name")) {
int RockstarId = memberMap["RockstarId"].toInt();
QString memberName = memberMap["Name"].toString();
if (!memberName.isEmpty() && RockstarId != 0)
{
if (!memberName.isEmpty() && RockstarId != 0) {
foundPlayers++;
emit playerNameFound(RockstarId, memberName);
}
}
}
}
currentPage++;
}
else
{
else {
currentFail++;
if (currentFail == maxLoadFails)
{
if (currentFail == maxLoadFails) {
currentFail = 0;
currentPage++;
}
@ -200,8 +183,7 @@ void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int
delete netReply;
delete netManager;
if (foundPlayers < totalPlayers && currentPage < maxPages && (continueLastCrew ? true : threadRunning))
{
if (foundPlayers < totalPlayers && currentPage < maxPages && (continueLastCrew ? true : threadRunning)) {
QEventLoop *waitingLoop = new QEventLoop();
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), waitingLoop, SLOT(quit())); }
@ -216,10 +198,8 @@ void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int
void DatabaseThread::deleteCompatibleCrews(QStringList *crewList)
{
for (QString crewNID : *crewList)
{
if (crewDB->isCompatibleCrew(crewNID))
{
for (const QString &crewNID : *crewList) {
if (crewDB->isCompatibleCrew(crewNID)) {
crewList->removeAll(crewNID);
}
}
@ -228,10 +208,8 @@ void DatabaseThread::deleteCompatibleCrews(QStringList *crewList)
QStringList DatabaseThread::deleteCompatibleCrews(const QStringList &crewList)
{
QStringList crewListR = crewList;
for (QString crewNID : crewListR)
{
if (crewDB->isCompatibleCrew(crewNID))
{
for (const QString &crewNID : crewListR) {
if (crewDB->isCompatibleCrew(crewNID)) {
crewListR.removeAll(crewNID);
}
}

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2020 Syping
* Copyright (C) 2016-2021 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,7 +28,6 @@
GlobalString::GlobalString()
{
}
QMap<QString, QString> GlobalString::getGlobalMap()
@ -39,8 +38,7 @@ QMap<QString, QString> GlobalString::getGlobalMap()
globalFile.setIniCodec("UTF-8");
#endif
globalFile.beginGroup("Global");
for (const QString &globalStr : globalFile.childKeys())
{
for (const QString &globalStr : globalFile.childKeys()) {
globalMap[globalStr] = globalFile.value(globalStr, globalStr).toString();
}
globalFile.endGroup();
@ -56,9 +54,9 @@ QString GlobalString::getString(QString valueStr, bool *ok)
#endif
globalFile.beginGroup("Global");
QStringList globalStrList = globalFile.childKeys();
if (globalStrList.contains(valueStr))
{
if (ok != nullptr) *ok = true;
if (globalStrList.contains(valueStr)) {
if (ok != nullptr)
*ok = true;
globalString = globalFile.value(valueStr, valueStr).toString();
}
globalFile.endGroup();
@ -69,8 +67,7 @@ QString GlobalString::getLanguageFile()
{
QString language = getLanguage();
QString languageFile = ":/global/global." % language % ".ini";
if (!QFileInfo(languageFile).exists())
{
if (!QFileInfo::exists(languageFile)) {
languageFile = ":/global/global.en.ini";
}
return languageFile;

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017 Syping
* Copyright (C) 2017-2021 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -48,19 +48,20 @@ void TranslationClass::initUserLanguage()
void TranslationClass::loadTranslation(QApplication *app)
{
if (isLangLoaded) { unloadTranslation(app); }
else { currentLangIndex = 0; }
QString exLangPath = AppEnv::getExLangFolder();
QString inLangPath = AppEnv::getInLangFolder();
if (userLanguage == "en" || userLanguage == "en_GB")
{
if (isLangLoaded) {
unloadTranslation(app);
}
else {
currentLangIndex = 0;
}
const QString exLangPath = AppEnv::getExLangFolder();
const QString inLangPath = AppEnv::getInLangFolder();
if (userLanguage == "en" || userLanguage == "en_GB") {
currentLanguage = "en_GB";
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
app->installTranslator(&inQtTranslator);
}
#if QT_VERSION >= 0x060000
@ -77,33 +78,28 @@ void TranslationClass::loadTranslation(QApplication *app)
bool externalEnglishMode = false;
bool loadInternalLang = false;
bool trLoadSuccess = false;
if (isUserLanguageSystem_p())
{
if (isUserLanguageSystem_p()) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadExSystemLanguage";
#endif
trLoadSuccess = loadSystemTranslation_p(exLangPath, &exAppTranslator);
}
else
{
else {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadExUserLanguage";
#endif
trLoadSuccess = loadUserTranslation_p(exLangPath, &exAppTranslator);
if (!trLoadSuccess)
{
if (!trLoadSuccess) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadInUserLanguage";
#endif
trLoadSuccess = loadUserTranslation_p(inLangPath, &inAppTranslator);
if (!trLoadSuccess)
{
if (!trLoadSuccess) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadUserLanguageFailed";
#endif
}
else
{
else {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadUserLanguageSuccess";
#endif
@ -111,18 +107,16 @@ void TranslationClass::loadTranslation(QApplication *app)
isLangLoaded = true;
}
}
else
{
else {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadUserLanguageSuccess";
#endif
isLangLoaded = true;
}
}
if (trLoadSuccess)
{
if (currentLangIndex != 0 || isEnglishMode) // Don't install the language until we know we not have a better language for the user
{
if (trLoadSuccess) {
// Don't install the language until we know we not have a better language for the user
if (currentLangIndex != 0 || isEnglishMode) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "externalLanguageReady" << currentLanguage;
#endif
@ -130,25 +124,20 @@ void TranslationClass::loadTranslation(QApplication *app)
externalLanguageStr = currentLanguage;
externalLanguageReady = true;
}
else
{
else {
#ifdef GTA5SYNC_DEBUG
qDebug() << "installTranslation";
#endif
if (loadInternalLang)
{
if (loadInternalLang) {
app->installTranslator(&inAppTranslator);
}
else
{
else {
app->installTranslator(&exAppTranslator);
}
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
app->installTranslator(&inQtTranslator);
}
#if QT_VERSION >= 0x060000
@ -159,8 +148,7 @@ void TranslationClass::loadTranslation(QApplication *app)
isLangLoaded = true;
}
}
if (externalLanguageReady)
{
if (externalLanguageReady) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadInSystemLanguage";
#endif
@ -170,18 +158,15 @@ void TranslationClass::loadTranslation(QApplication *app)
qDebug() << "externalLangIndex" << externalLangIndex << "internalLangIndex" << currentLangIndex;
qDebug() << "externalEnglishMode" << externalEnglishMode << "internalEnglishMode" << isEnglishMode;
#endif
if ((trLoadSuccess && externalLangIndex > currentLangIndex) || (trLoadSuccess && externalEnglishMode && !isEnglishMode))
{
if ((trLoadSuccess && externalLangIndex > currentLangIndex) || (trLoadSuccess && externalEnglishMode && !isEnglishMode)) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "installInternalTranslation";
#endif
app->installTranslator(&inAppTranslator);
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
app->installTranslator(&inQtTranslator);
}
#if QT_VERSION >= 0x060000
@ -191,20 +176,17 @@ void TranslationClass::loadTranslation(QApplication *app)
#endif
isLangLoaded = true;
}
else
{
else {
#ifdef GTA5SYNC_DEBUG
qDebug() << "installExternalTranslation";
#endif
isEnglishMode = externalEnglishMode;
currentLanguage = externalLanguageStr;
app->installTranslator(&exAppTranslator);
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
app->installTranslator(&inQtTranslator);
}
#if QT_VERSION >= 0x060000
@ -215,24 +197,20 @@ void TranslationClass::loadTranslation(QApplication *app)
isLangLoaded = true;
}
}
else if (!isLangLoaded)
{
else if (!isLangLoaded) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadInSystemLanguage";
#endif
trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator);
if (trLoadSuccess)
{
if (trLoadSuccess) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "installInternalTranslation";
#endif
app->installTranslator(&inAppTranslator);
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
app->installTranslator(&inQtTranslator);
}
#if QT_VERSION >= 0x060000
@ -242,18 +220,15 @@ void TranslationClass::loadTranslation(QApplication *app)
#endif
isLangLoaded = true;
}
else if (!trLoadSuccess)
{
else if (!trLoadSuccess) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "fallbackToDefaultApplicationLanguage";
#endif
currentLanguage = "en_GB";
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
app->installTranslator(&inQtTranslator);
}
#if QT_VERSION >= 0x060000
@ -266,30 +241,24 @@ void TranslationClass::loadTranslation(QApplication *app)
}
#else // New qconf loading method
bool trLoadSuccess;
if (isUserLanguageSystem_p())
{
if (isUserLanguageSystem_p()) {
trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator);
}
else
{
else {
trLoadSuccess = loadUserTranslation_p(inLangPath, &inAppTranslator);
}
if (!trLoadSuccess && !isUserLanguageSystem_p())
{
if (!trLoadSuccess && !isUserLanguageSystem_p()) {
trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator);
}
if (trLoadSuccess)
{
if (trLoadSuccess) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "installTranslation" << currentLanguage;
#endif
app->installTranslator(&inAppTranslator);
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
if (loadQtTranslation_p(exLangPath, &exQtTranslator)) {
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
else if (loadQtTranslation_p(inLangPath, &inQtTranslator)) {
app->installTranslator(&inQtTranslator);
}
#if QT_VERSION >= 0x060000
@ -332,21 +301,17 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla
qDebug() << "loadSystemTranslation_p";
#endif
int currentLangCounter = 0;
for (QString languageName : QLocale::system().uiLanguages())
{
for (const QString &languageName : QLocale::system().uiLanguages()) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguage" << languageName;
#endif
QStringList langList = QString(languageName).replace("-","_").split("_");
if (langList.length() == 2)
{
const QStringList langList = QString(languageName).replace("-","_").split("_");
if (langList.length() == 2) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm")) {
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm")) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
@ -359,10 +324,8 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
@ -371,8 +334,7 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla
currentLangIndex = currentLangCounter;
return true;
}
else if (langList.at(0) == "en")
{
else if (langList.at(0) == "en") {
#ifdef GTA5SYNC_DEBUG
qDebug() << "languageEnglishMode index" << currentLangCounter;
#endif
@ -382,8 +344,7 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla
return true;
}
}
else if (langList.at(0) == "en")
{
else if (langList.at(0) == "en") {
#ifdef GTA5SYNC_DEBUG
qDebug() << "languageEnglishMode index" << currentLangCounter;
#endif
@ -393,15 +354,12 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla
return true;
}
}
else if (langList.length() == 1)
{
else if (langList.length() == 1) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
@ -425,17 +383,14 @@ bool TranslationClass::loadUserTranslation_p(const QString &langPath, QTranslato
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadUserTranslation_p";
#endif
QString languageName = userLanguage;
QStringList langList = QString(languageName).replace("-","_").split("_");
if (langList.length() == 2)
{
const QString languageName = userLanguage;
const QStringList langList = QString(languageName).replace("-","_").split("_");
if (langList.length() == 2) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm")) {
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm")) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
@ -446,10 +401,8 @@ bool TranslationClass::loadUserTranslation_p(const QString &langPath, QTranslato
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
@ -458,15 +411,12 @@ bool TranslationClass::loadUserTranslation_p(const QString &langPath, QTranslato
}
}
}
else if (langList.length() == 1)
{
else if (langList.length() == 1) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm")) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
@ -483,17 +433,14 @@ bool TranslationClass::loadQtTranslation_p(const QString &langPath, QTranslator
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadQtTranslation_p" << currentLanguage;
#endif
QString languageName = currentLanguage;
QStringList langList = QString(languageName).replace("-","_").split("_");
if (langList.length() == 2)
{
const QString languageName = currentLanguage;
const QStringList langList = QString(languageName).replace("-","_").split("_");
if (langList.length() == 2) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
if (qtTranslator->load(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
if (QFile::exists(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm")) {
if (qtTranslator->load(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm")) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
@ -503,10 +450,8 @@ bool TranslationClass::loadQtTranslation_p(const QString &langPath, QTranslator
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm"))
{
if (qtTranslator->load(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm"))
{
if (QFile::exists(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm")) {
if (qtTranslator->load(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm")) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm");
#endif
@ -514,15 +459,12 @@ bool TranslationClass::loadQtTranslation_p(const QString &langPath, QTranslator
}
}
}
else if (langList.length() == 1)
{
else if (langList.length() == 1) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm"))
{
if (qtTranslator->load(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm"))
{
if (QFile::exists(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm")) {
if (qtTranslator->load(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm")) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm");
#endif
@ -541,49 +483,44 @@ bool TranslationClass::isUserLanguageSystem_p()
QString TranslationClass::getCurrentAreaLanguage()
{
const QStringList areaTranslations = listAreaTranslations();
if (userAreaLanguage == "Auto" || userAreaLanguage.trimmed().isEmpty())
{
GameLanguage gameLanguage = AppEnv::getGameLanguage(AppEnv::getGameVersion());
if (gameLanguage == GameLanguage::Undefined)
{
if (userAreaLanguage == "Auto" || userAreaLanguage.trimmed().isEmpty()) {
const GameLanguage gameLanguage = AppEnv::getGameLanguage(AppEnv::getGameVersion());
if (gameLanguage == GameLanguage::Undefined) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "autoAreaLanguageModeInterface";
#endif
QString langCode = QString(currentLanguage).replace("-", "_");
if (areaTranslations.contains(langCode))
{
if (areaTranslations.contains(langCode)) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "autoAreaLanguageSelected" << langCode;
#endif
return langCode;
}
else if (langCode.contains("_"))
{
else if (langCode.contains("_")) {
langCode = langCode.split("_").at(0);
if (!areaTranslations.contains(langCode)) goto outputDefaultLanguage;
if (!areaTranslations.contains(langCode))
goto outputDefaultLanguage;
#ifdef GTA5SYNC_DEBUG
qDebug() << "autoAreaLanguageSelected" << langCode;
#endif
return langCode;
}
}
else
{
else {
#ifdef GTA5SYNC_DEBUG
qDebug() << "autoAreaLanguageModeGame";
#endif
QString langCode = AppEnv::gameLanguageToString(gameLanguage).replace("-", "_");
if (areaTranslations.contains(langCode))
{
if (areaTranslations.contains(langCode)) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "autoAreaLanguageSelected" << langCode;
#endif
return langCode;
}
else if (langCode.contains("_"))
{
else if (langCode.contains("_")) {
langCode = langCode.split("_").at(0);
if (!areaTranslations.contains(langCode)) goto outputDefaultLanguage;
if (!areaTranslations.contains(langCode))
goto outputDefaultLanguage;
#ifdef GTA5SYNC_DEBUG
qDebug() << "autoAreaLanguageSelected" << langCode;
#endif
@ -591,17 +528,16 @@ QString TranslationClass::getCurrentAreaLanguage()
}
}
}
else if (areaTranslations.contains(userAreaLanguage))
{
else if (areaTranslations.contains(userAreaLanguage)) {
#ifdef GTA5SYNC_DEBUG
qDebug() << "userAreaLanguageSelected" << userAreaLanguage;
#endif
return userAreaLanguage;
}
else if (userAreaLanguage.contains("_"))
{
QString langCode = QString(userAreaLanguage).replace("-", "_").split("_").at(0);
if (!areaTranslations.contains(langCode)) goto outputDefaultLanguage;
else if (userAreaLanguage.contains("_")) {
const QString langCode = QString(userAreaLanguage).replace("-", "_").split("_").at(0);
if (!areaTranslations.contains(langCode))
goto outputDefaultLanguage;
#ifdef GTA5SYNC_DEBUG
qDebug() << "userAreaLanguageSelected" << langCode;
#endif
@ -626,8 +562,7 @@ bool TranslationClass::isLanguageLoaded()
void TranslationClass::unloadTranslation(QApplication *app)
{
if (isLangLoaded)
{
if (isLangLoaded) {
#ifndef GTA5SYNC_QCONF
app->removeTranslator(&exAppTranslator);
app->removeTranslator(&exQtTranslator);
@ -650,30 +585,21 @@ void TranslationClass::unloadTranslation(QApplication *app)
QString TranslationClass::getCountryCode(QLocale::Country country)
{
QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage,
QLocale::AnyScript,
country);
if (locales.isEmpty()) return QString();
QStringList localeStrList = locales.at(0).name().split("_");
if (localeStrList.length() >= 2)
{
return localeStrList.at(1).toLower();
}
else
{
return QString();
const QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, country);
if (!locales.isEmpty()) {
const QStringList localeStrList = locales.at(0).name().split("_");
if (localeStrList.length() >= 2) {
return localeStrList.at(1).toLower();
}
}
return QString();
}
QString TranslationClass::getCountryCode(QLocale locale)
{
QStringList localeStrList = locale.name().split("_");
if (localeStrList.length() >= 2)
{
if (localeStrList.length() >= 2) {
return localeStrList.at(1).toLower();
}
else
{
return QString();
}
return QString();
}

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2019 Syping
* Copyright (C) 2016-2021 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -94,7 +94,6 @@ int main(int argc, char *argv[])
settings.sync();
#endif
bool isFirstStart = settings.value("IsFirstStart", true).toBool();
bool customStyle = settings.value("CustomStyle", false).toBool();
if (customStyle) {
const QString appStyle = settings.value("AppStyle", "Default").toString();
@ -130,28 +129,10 @@ int main(int argc, char *argv[])
Telemetry->work();
#endif
if (!applicationArgs.contains("--skip-firststart"))
{
if (isFirstStart)
{
QMessageBox::StandardButton button = QMessageBox::information(nullptr, QString("%1 %2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER), QApplication::tr("<h4>Welcome to %1!</h4>You want to configure %1 before you start using it?").arg(GTA5SYNC_APPSTR), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (button == QMessageBox::Yes)
{
ProfileDatabase profileDB;
OptionsDialog optionsDialog(&profileDB);
optionsDialog.setWindowIcon(IconLoader::loadingAppIcon());
optionsDialog.show();
optionsDialog.exec();
}
settings.setValue("IsFirstStart", false);
}
}
#ifdef GTA5SYNC_TELEMETRY
bool telemetryWindowLaunched = settings.value("PersonalUsageDataWindowLaunched", false).toBool();
bool pushUsageData = settings.value("PushUsageData", false).toBool();
if (!telemetryWindowLaunched && !pushUsageData)
{
if (!telemetryWindowLaunched && !pushUsageData) {
QDialog *telemetryDialog = new QDialog();
telemetryDialog->setObjectName(QStringLiteral("TelemetryDialog"));
telemetryDialog->setWindowTitle(QString("%1 %2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER));
@ -183,8 +164,7 @@ int main(int argc, char *argv[])
telemetryDialog->setFixedSize(telemetryDialog->sizeHint());
telemetryDialog->exec();
QObject::disconnect(telemetryButton, SIGNAL(clicked(bool)), telemetryDialog, SLOT(close()));
if (telemetryCheckBox->isChecked())
{
if (telemetryCheckBox->isChecked()) {
QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
telemetrySettings.beginGroup("Telemetry");
telemetrySettings.setValue("PushUsageData", true);
@ -200,43 +180,35 @@ int main(int argc, char *argv[])
#endif
settings.endGroup();
for (QString currentArg : applicationArgs)
{
for (const QString &currentArg : applicationArgs) {
QString reworkedArg;
if (currentArg.left(9) == "-showpic=" && selectedAction == "")
{
reworkedArg = currentArg.remove(0,9);
if (currentArg.left(9) == "-showpic=" && selectedAction == "") {
reworkedArg = QString(currentArg).remove(0,9);
arg1 = reworkedArg;
selectedAction = "showpic";
}
else if (currentArg.left(9) == "-showsgd=" && selectedAction == "")
{
reworkedArg = currentArg.remove(0,9);
else if (currentArg.left(9) == "-showsgd=" && selectedAction == "") {
reworkedArg = QString(currentArg).remove(0,9);
arg1 = reworkedArg;
selectedAction = "showsgd";
}
else if (selectedAction == "")
{
else if (selectedAction == "") {
QFile argumentFile(currentArg);
QFileInfo argumentFileInfo(argumentFile);
if (argumentFile.exists())
{
if (argumentFile.exists()) {
QString argumentFileName = argumentFileInfo.fileName();
QString argumentFileType = argumentFileName.left(4);
QString argumentFileExt = argumentFileName.right(4);
if (argumentFileType == "PGTA" || argumentFileExt == ".g5e")
{
if (argumentFileType == "PGTA" || argumentFileExt == ".g5e") {
arg1 = currentArg;
selectedAction = "showpic";
}
else if (argumentFileType == "SGTA")
{
else if (argumentFileType == "SGTA") {
arg1 = currentArg;
selectedAction = "showsgd";
}
else if (argumentFileType == "MISR")
{
else if (argumentFileType == "MISR") {
arg1 = currentArg;
selectedAction = "showsgd";
}
@ -244,8 +216,7 @@ int main(int argc, char *argv[])
}
}
if (selectedAction == "showpic")
{
if (selectedAction == "showpic") {
CrewDatabase crewDB;
ProfileDatabase profileDB;
DatabaseThread threadDB(&crewDB);
@ -258,8 +229,10 @@ int main(int argc, char *argv[])
picDialog.setWindowFlags(picDialog.windowFlags()^Qt::Dialog^Qt::Window);
int crewID = picture.getSnapmaticProperties().crewID;
if (crewID != 0) { crewDB.addCrew(crewID); }
if (!readOk) { return 1; }
if (crewID != 0)
crewDB.addCrew(crewID);
if (!readOk)
return 1;
QObject::connect(&threadDB, SIGNAL(crewNameFound(int, QString)), &crewDB, SLOT(setCrewName(int, QString)));
QObject::connect(&threadDB, SIGNAL(crewNameUpdated()), &picDialog, SLOT(crewNameUpdated()));
@ -273,8 +246,7 @@ int main(int argc, char *argv[])
return a.exec();
}
else if (selectedAction == "showsgd")
{
else if (selectedAction == "showsgd") {
SavegameDialog savegameDialog;
SavegameData savegame;
@ -283,7 +255,8 @@ int main(int argc, char *argv[])
savegameDialog.setSavegameData(&savegame, arg1, readOk);
savegameDialog.setWindowFlags(savegameDialog.windowFlags()^Qt::Dialog^Qt::Window);
if (!readOk) { return 1; }
if (!readOk)
return 1;
a.setQuitOnLastWindowClosed(true);
savegameDialog.show();

View file

@ -1639,14 +1639,6 @@ Press 1 for Default View</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QApplication</name>
<message>
<location filename="../main.cpp" line="137"/>
<source>&lt;h4&gt;Welcome to %1!&lt;/h4&gt;You want to configure %1 before you start using it?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SavegameDialog</name>
<message>
@ -2237,22 +2229,22 @@ Press 1 for Default View</source>
<context>
<name>TelemetryDialog</name>
<message>
<location filename="../main.cpp" line="166"/>
<location filename="../main.cpp" line="147"/>
<source>You want help %1 to improve in the future by including personal usage data in your submission?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../main.cpp" line="167"/>
<location filename="../main.cpp" line="148"/>
<source>%1 User Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../main.cpp" line="171"/>
<location filename="../main.cpp" line="152"/>
<source>Yes, I want include personal usage data.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../main.cpp" line="180"/>
<location filename="../main.cpp" line="161"/>
<source>&amp;OK</source>
<translation type="unfinished"></translation>
</message>

Binary file not shown.

View file

@ -1685,9 +1685,8 @@ Drücke 1 für Standardmodus</translation>
<context>
<name>QApplication</name>
<message>
<location filename="../main.cpp" line="137"/>
<source>&lt;h4&gt;Welcome to %1!&lt;/h4&gt;You want to configure %1 before you start using it?</source>
<translation>&lt;h4&gt;Willkommen zu %1!&lt;/h4&gt;Möchtest du %1 einstellen bevor du es nutzt?</translation>
<translation type="vanished">&lt;h4&gt;Willkommen zu %1!&lt;/h4&gt;Möchtest du %1 einstellen bevor du es nutzt?</translation>
</message>
</context>
<context>
@ -2282,22 +2281,22 @@ Drücke 1 für Standardmodus</translation>
<context>
<name>TelemetryDialog</name>
<message>
<location filename="../main.cpp" line="167"/>
<location filename="../main.cpp" line="148"/>
<source>%1 User Statistics</source>
<translation>%1 Benutzerstatistik</translation>
</message>
<message>
<location filename="../main.cpp" line="166"/>
<location filename="../main.cpp" line="147"/>
<source>You want help %1 to improve in the future by including personal usage data in your submission?</source>
<translation>Sollen bei Einreichungen Persönliche Nutzungsdaten einbezogen werden um %1 in der Zukunft zu unterstützen?</translation>
</message>
<message>
<location filename="../main.cpp" line="171"/>
<location filename="../main.cpp" line="152"/>
<source>Yes, I want include personal usage data.</source>
<translation>Ja, ich möchte Persönliche Nutzungsdaten einbeziehen.</translation>
</message>
<message>
<location filename="../main.cpp" line="180"/>
<location filename="../main.cpp" line="161"/>
<source>&amp;OK</source>
<translation>&amp;OK</translation>
</message>

View file

@ -1639,14 +1639,6 @@ Press 1 for Default View</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QApplication</name>
<message>
<location filename="../main.cpp" line="137"/>
<source>&lt;h4&gt;Welcome to %1!&lt;/h4&gt;You want to configure %1 before you start using it?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SavegameDialog</name>
<message>
@ -2237,22 +2229,22 @@ Press 1 for Default View</source>
<context>
<name>TelemetryDialog</name>
<message>
<location filename="../main.cpp" line="166"/>
<location filename="../main.cpp" line="147"/>
<source>You want help %1 to improve in the future by including personal usage data in your submission?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../main.cpp" line="167"/>
<location filename="../main.cpp" line="148"/>
<source>%1 User Statistics</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../main.cpp" line="171"/>
<location filename="../main.cpp" line="152"/>
<source>Yes, I want include personal usage data.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../main.cpp" line="180"/>
<location filename="../main.cpp" line="161"/>
<source>&amp;OK</source>
<translation type="unfinished"></translation>
</message>

Binary file not shown.

View file

@ -1695,9 +1695,8 @@ Appuyer sur 1 pour le mode par défaut</translation>
<translation type="obsolete">Police sélectionnée : %1</translation>
</message>
<message>
<location filename="../main.cpp" line="137"/>
<source>&lt;h4&gt;Welcome to %1!&lt;/h4&gt;You want to configure %1 before you start using it?</source>
<translation>&lt;h4&gt;Bienvenue sur %1!&lt;/h4&gt;Voulez-vous configurer %1 avant de l&apos;utiliser t?</translation>
<translation type="vanished">&lt;h4&gt;Bienvenue sur %1!&lt;/h4&gt;Voulez-vous configurer %1 avant de l&apos;utiliser t?</translation>
</message>
</context>
<context>
@ -2294,22 +2293,22 @@ Appuyer sur 1 pour le mode par défaut</translation>
<context>
<name>TelemetryDialog</name>
<message>
<location filename="../main.cpp" line="166"/>
<location filename="../main.cpp" line="147"/>
<source>You want help %1 to improve in the future by including personal usage data in your submission?</source>
<translation>Voulez-vous aider au développement de %1 en transmettant vos données d&apos;utilisation ?</translation>
</message>
<message>
<location filename="../main.cpp" line="167"/>
<location filename="../main.cpp" line="148"/>
<source>%1 User Statistics</source>
<translation>Statistiques utilisateurs %1</translation>
</message>
<message>
<location filename="../main.cpp" line="171"/>
<location filename="../main.cpp" line="152"/>
<source>Yes, I want include personal usage data.</source>
<translation>Oui, je veux partager mes données d&apos;utilisation.</translation>
</message>
<message>
<location filename="../main.cpp" line="180"/>
<location filename="../main.cpp" line="161"/>
<source>&amp;OK</source>
<translation>&amp;OK</translation>
</message>

Binary file not shown.

View file

@ -1713,9 +1713,8 @@ Press 1 for Default View</source>
<translation type="obsolete"> : %1</translation>
</message>
<message>
<location filename="../main.cpp" line="137"/>
<source>&lt;h4&gt;Welcome to %1!&lt;/h4&gt;You want to configure %1 before you start using it?</source>
<translation>&lt;h4&gt;%1 !&lt;/h4&gt;%1 ?</translation>
<translation type="vanished">&lt;h4&gt;%1 !&lt;/h4&gt;%1 ?</translation>
</message>
</context>
<context>
@ -2315,22 +2314,22 @@ Press 1 for Default View</source>
<context>
<name>TelemetryDialog</name>
<message>
<location filename="../main.cpp" line="166"/>
<location filename="../main.cpp" line="147"/>
<source>You want help %1 to improve in the future by including personal usage data in your submission?</source>
<translation> %1() ?</translation>
</message>
<message>
<location filename="../main.cpp" line="167"/>
<location filename="../main.cpp" line="148"/>
<source>%1 User Statistics</source>
<translation>%1 </translation>
</message>
<message>
<location filename="../main.cpp" line="171"/>
<location filename="../main.cpp" line="152"/>
<source>Yes, I want include personal usage data.</source>
<translation>, .</translation>
</message>
<message>
<location filename="../main.cpp" line="180"/>
<location filename="../main.cpp" line="161"/>
<source>&amp;OK</source>
<translation>(&amp;O)</translation>
</message>

Binary file not shown.

View file

@ -1700,9 +1700,8 @@ Press 1 for Default View</source>
<context>
<name>QApplication</name>
<message>
<location filename="../main.cpp" line="137"/>
<source>&lt;h4&gt;Welcome to %1!&lt;/h4&gt;You want to configure %1 before you start using it?</source>
<translation>&lt;h4&gt;Добро пожаловать в %1!&lt;/h4&gt;Хочешь изменить настройки %1 перед использованием?</translation>
<translation type="vanished">&lt;h4&gt;Добро пожаловать в %1!&lt;/h4&gt;Хочешь изменить настройки %1 перед использованием?</translation>
</message>
</context>
<context>
@ -2297,22 +2296,22 @@ Press 1 for Default View</source>
<context>
<name>TelemetryDialog</name>
<message>
<location filename="../main.cpp" line="166"/>
<location filename="../main.cpp" line="147"/>
<source>You want help %1 to improve in the future by including personal usage data in your submission?</source>
<translation>Разрешишь нам собирать статистику о пользовании тобой %1? Это поможет нам в разработке.</translation>
</message>
<message>
<location filename="../main.cpp" line="167"/>
<location filename="../main.cpp" line="148"/>
<source>%1 User Statistics</source>
<translation>%1 Пользовательская статистика</translation>
</message>
<message>
<location filename="../main.cpp" line="171"/>
<location filename="../main.cpp" line="152"/>
<source>Yes, I want include personal usage data.</source>
<translation>Да, передавать данные о пользовании программой.</translation>
</message>
<message>
<location filename="../main.cpp" line="180"/>
<location filename="../main.cpp" line="161"/>
<source>&amp;OK</source>
<translation>&amp;ОК</translation>
</message>

Binary file not shown.

View file

@ -1698,9 +1698,8 @@ Press 1 for Default View</source>
<translation type="obsolete">Вибраний шрифт:%1</translation>
</message>
<message>
<location filename="../main.cpp" line="137"/>
<source>&lt;h4&gt;Welcome to %1!&lt;/h4&gt;You want to configure %1 before you start using it?</source>
<translation>&lt;h4&gt;Ласкаво просимо до %1!&lt;/h4&gt;Ви хочете налаштувати %1 перед використанням?</translation>
<translation type="vanished">&lt;h4&gt;Ласкаво просимо до %1!&lt;/h4&gt;Ви хочете налаштувати %1 перед використанням?</translation>
</message>
</context>
<context>
@ -2295,22 +2294,22 @@ Press 1 for Default View</source>
<context>
<name>TelemetryDialog</name>
<message>
<location filename="../main.cpp" line="166"/>
<location filename="../main.cpp" line="147"/>
<source>You want help %1 to improve in the future by including personal usage data in your submission?</source>
<translation>Ви хочете допомогти %1 покращитись у майбутньому, включивши дані особистого користування?</translation>
</message>
<message>
<location filename="../main.cpp" line="167"/>
<location filename="../main.cpp" line="148"/>
<source>%1 User Statistics</source>
<translation>%1 Статистика користувачів</translation>
</message>
<message>
<location filename="../main.cpp" line="171"/>
<location filename="../main.cpp" line="152"/>
<source>Yes, I want include personal usage data.</source>
<translation>Так, я хочу включити дані особистого користування.</translation>
</message>
<message>
<location filename="../main.cpp" line="180"/>
<location filename="../main.cpp" line="161"/>
<source>&amp;OK</source>
<translatorcomment>&amp;OK</translatorcomment>
<translation>&amp;OK</translation>

Binary file not shown.

View file

@ -1680,9 +1680,8 @@ Press 1 for Default View</source>
<context>
<name>QApplication</name>
<message>
<location filename="../main.cpp" line="137"/>
<source>&lt;h4&gt;Welcome to %1!&lt;/h4&gt;You want to configure %1 before you start using it?</source>
<translation>&lt;h4&gt;使 %1!&lt;/h4&gt; %1 ?</translation>
<translation type="vanished">&lt;h4&gt;使 %1!&lt;/h4&gt; %1 ?</translation>
</message>
</context>
<context>
@ -2277,22 +2276,22 @@ Press 1 for Default View</source>
<context>
<name>TelemetryDialog</name>
<message>
<location filename="../main.cpp" line="166"/>
<location filename="../main.cpp" line="147"/>
<source>You want help %1 to improve in the future by including personal usage data in your submission?</source>
<translation> %1 ?</translation>
</message>
<message>
<location filename="../main.cpp" line="167"/>
<location filename="../main.cpp" line="148"/>
<source>%1 User Statistics</source>
<translation>%1 使</translation>
</message>
<message>
<location filename="../main.cpp" line="171"/>
<location filename="../main.cpp" line="152"/>
<source>Yes, I want include personal usage data.</source>
<translation>.</translation>
</message>
<message>
<location filename="../main.cpp" line="180"/>
<location filename="../main.cpp" line="161"/>
<source>&amp;OK</source>
<translation>(&amp;O)</translation>
</message>