diff --git a/AppEnv.cpp b/AppEnv.cpp index 06cf329..6dbe091 100755 --- a/AppEnv.cpp +++ b/AppEnv.cpp @@ -43,7 +43,7 @@ QString AppEnv::getGameFolder(bool *ok) dir.setPath(GTAV_FOLDER); if (dir.exists()) { - *ok = true; + if (ok != NULL) *ok = true; qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); return dir.absolutePath(); } @@ -64,7 +64,7 @@ QString AppEnv::getGameFolder(bool *ok) dir.setPath(GTAV_returnFolder); if (dir.exists()) { - *ok = true; + if (ok != 0) *ok = true; qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); return dir.absolutePath(); } @@ -72,12 +72,12 @@ QString AppEnv::getGameFolder(bool *ok) dir.setPath(GTAV_defaultFolder); if (dir.exists()) { - *ok = true; + if (ok != 0) *ok = true; qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); return dir.absolutePath(); } - *ok = false; + if (ok != 0) *ok = false; return ""; } diff --git a/GlobalString.cpp b/GlobalString.cpp new file mode 100755 index 0000000..e060dc0 --- /dev/null +++ b/GlobalString.cpp @@ -0,0 +1,74 @@ +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 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 +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include +#include +#include +#include +#include "GlobalString.h" +#include "config.h" + +GlobalString::GlobalString() +{ + +} + + +QString GlobalString::getString(QString valueStr, bool *ok) +{ + QString globalString = valueStr; + QSettings globalFile(getLanguageFile(), QSettings::IniFormat); + globalFile.beginGroup("Global"); + QStringList globalStrList = globalFile.childKeys(); + if (globalStrList.contains(valueStr)) + { + if (ok != 0) *ok = true; + globalString = globalFile.value(valueStr, valueStr).toString(); + } + globalFile.endGroup(); + return globalString; +} + +QString GlobalString::getLanguageFile() +{ + QString language = getLanguage(); + QString languageFile = ":/global/global." + language + ".ini"; + if (!QFileInfo(languageFile).exists()) + { + languageFile = ":/global/global.en.ini"; + } + return languageFile; +} + +QString GlobalString::getLanguage() +{ + QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); + settings.beginGroup("Interface"); + QString language = settings.value("Language","System").toString(); + settings.endGroup(); + if (language == "System" || language.trimmed() == "") + { + QString languageName = QLocale::system().name(); + QStringList langList = languageName.split("_"); + if (langList.length() >= 1) + { + language = langList.at(0); + } + } + return language; +} diff --git a/GlobalString.h b/GlobalString.h new file mode 100755 index 0000000..fb8fc50 --- /dev/null +++ b/GlobalString.h @@ -0,0 +1,33 @@ +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 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 +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#ifndef GLOBALSTRING_H +#define GLOBALSTRING_H + +#include + +class GlobalString +{ +public: + GlobalString(); + static QString getString(QString valueStr, bool *ok = 0); + static QString getLanguageFile(); + static QString getLanguage(); +}; + +#endif // GLOBALSTRING_H diff --git a/PictureDialog.cpp b/PictureDialog.cpp index c59d964..5e956f4 100755 --- a/PictureDialog.cpp +++ b/PictureDialog.cpp @@ -23,6 +23,7 @@ #include "SidebarGenerator.h" #include "StandardPaths.h" #include "PictureExport.h" +#include "GlobalString.h" #include "PictureCopy.h" #include "UiModLabel.h" @@ -52,6 +53,7 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, QWidget *parent) : ui->cmdExport->setEnabled(0); plyrsList = QStringList(); indexed = 0; + picArea = ""; picTitl = ""; picPath = ""; crewID = ""; @@ -155,6 +157,8 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString pictu crewID = QString::number(picture->getCrewNumber()); plyrsList = picture->getPlayers(); picTitl = picture->getPictureTitl(); + picArea = picture->getArea(); + picAreaStr = GlobalString::getString(picArea); QString plyrsStr; if (plyrsList.length() >= 1) @@ -180,7 +184,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString pictu if (crewID == "") { crewID = tr("No crew"); } this->setWindowTitle(windowTitleStr.arg(picture->getPictureStr())); - ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr, crewID, picTitl)); + ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr, crewID, picTitl, picAreaStr)); } else { diff --git a/PictureDialog.h b/PictureDialog.h index 2fe93e3..20a4d99 100755 --- a/PictureDialog.h +++ b/PictureDialog.h @@ -73,6 +73,8 @@ private: QString jsonDrawString; QString windowTitleStr; QStringList plyrsList; + QString picAreaStr; + QString picArea; QString picTitl; QString picPath; QString crewID; diff --git a/PictureDialog.ui b/PictureDialog.ui index 7759b0b..3fca2f6 100755 --- a/PictureDialog.ui +++ b/PictureDialog.ui @@ -75,10 +75,7 @@ - <span style=" font-weight:600;">Title: </span>%6<br> -<span style=" font-weight:600;">Location: </span>%1, %2, %3 <br> -<span style=" font-weight:600;">Players: </span>%4<br> -<span style=" font-weight:600;">Crew ID: </span>%5 + <html><head/><body><p><span style=" font-weight:600;">Title: </span>%6<br/><span style=" font-weight:600;">Location: </span>%7 (%1, %2, %3)<br/><span style=" font-weight:600;">Players: </span>%4<br/><span style=" font-weight:600;">Crew ID: </span>%5</p></body></html> true diff --git a/SnapmaticPicture.cpp b/SnapmaticPicture.cpp index 742e56c..2d482e6 100755 --- a/SnapmaticPicture.cpp +++ b/SnapmaticPicture.cpp @@ -55,6 +55,7 @@ SnapmaticPicture::SnapmaticPicture(const QString &fileName, QObject *parent) : Q jsonLocY = 0; jsonLocZ = 0; jsonCrewID = 0; + jsonArea = ""; jsonPlyrsList = QStringList(); } @@ -333,6 +334,10 @@ void SnapmaticPicture::parseJsonContent() if (locMap.contains("y")) { jsonLocY = locMap["y"].toDouble(); } if (locMap.contains("z")) { jsonLocZ = locMap["z"].toDouble(); } } + if (jsonMap.contains("area")) + { + jsonArea = jsonMap["area"].toString(); + } if (jsonMap.contains("crewid")) { jsonCrewID = jsonMap["crewid"].toInt(); @@ -350,6 +355,11 @@ bool SnapmaticPicture::isJsonOk() return jsonOk; } +QString SnapmaticPicture::getArea() +{ + return jsonArea; +} + QString SnapmaticPicture::getJsonStr() { return jsonStr; diff --git a/SnapmaticPicture.h b/SnapmaticPicture.h index 7506fe2..b62f835 100755 --- a/SnapmaticPicture.h +++ b/SnapmaticPicture.h @@ -46,6 +46,7 @@ public: // JSON bool isJsonOk(); + QString getArea(); int getCrewNumber(); QString getJsonStr(); double getLocationX(); @@ -85,6 +86,7 @@ private: double jsonLocX; double jsonLocY; double jsonLocZ; + QString jsonArea; QStringList jsonPlyrsList; signals: diff --git a/gta5sync.pro b/gta5sync.pro index f07fd11..5ada0f7 100755 --- a/gta5sync.pro +++ b/gta5sync.pro @@ -31,6 +31,7 @@ SOURCES += main.cpp \ DatabaseThread.cpp \ ExportDialog.cpp \ ExportThread.cpp \ + GlobalString.cpp \ IconLoader.cpp \ OptionsDialog.cpp \ PictureCopy.cpp \ @@ -61,6 +62,7 @@ HEADERS += \ DatabaseThread.h \ ExportDialog.h \ ExportThread.h \ + GlobalString.h \ IconLoader.h \ OptionsDialog.h \ PictureCopy.h \