add Area Location String to PictureDialog

This commit is contained in:
Rafael 2016-04-23 20:15:59 +02:00
parent 5dc3e72faf
commit 043c657119
9 changed files with 133 additions and 9 deletions

View file

@ -43,7 +43,7 @@ QString AppEnv::getGameFolder(bool *ok)
dir.setPath(GTAV_FOLDER); dir.setPath(GTAV_FOLDER);
if (dir.exists()) if (dir.exists())
{ {
*ok = true; if (ok != NULL) *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath(); return dir.absolutePath();
} }
@ -64,7 +64,7 @@ QString AppEnv::getGameFolder(bool *ok)
dir.setPath(GTAV_returnFolder); dir.setPath(GTAV_returnFolder);
if (dir.exists()) if (dir.exists())
{ {
*ok = true; if (ok != 0) *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath(); return dir.absolutePath();
} }
@ -72,12 +72,12 @@ QString AppEnv::getGameFolder(bool *ok)
dir.setPath(GTAV_defaultFolder); dir.setPath(GTAV_defaultFolder);
if (dir.exists()) if (dir.exists())
{ {
*ok = true; if (ok != 0) *ok = true;
qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8()); qputenv("GTAV_FOLDER", dir.absolutePath().toUtf8());
return dir.absolutePath(); return dir.absolutePath();
} }
*ok = false; if (ok != 0) *ok = false;
return ""; return "";
} }

74
GlobalString.cpp Executable file
View file

@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include <QLocale>
#include <QSettings>
#include <QFileInfo>
#include <QApplication>
#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;
}

33
GlobalString.h Executable file
View file

@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifndef GLOBALSTRING_H
#define GLOBALSTRING_H
#include <QString>
class GlobalString
{
public:
GlobalString();
static QString getString(QString valueStr, bool *ok = 0);
static QString getLanguageFile();
static QString getLanguage();
};
#endif // GLOBALSTRING_H

View file

@ -23,6 +23,7 @@
#include "SidebarGenerator.h" #include "SidebarGenerator.h"
#include "StandardPaths.h" #include "StandardPaths.h"
#include "PictureExport.h" #include "PictureExport.h"
#include "GlobalString.h"
#include "PictureCopy.h" #include "PictureCopy.h"
#include "UiModLabel.h" #include "UiModLabel.h"
@ -52,6 +53,7 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, QWidget *parent) :
ui->cmdExport->setEnabled(0); ui->cmdExport->setEnabled(0);
plyrsList = QStringList(); plyrsList = QStringList();
indexed = 0; indexed = 0;
picArea = "";
picTitl = ""; picTitl = "";
picPath = ""; picPath = "";
crewID = ""; crewID = "";
@ -155,6 +157,8 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString pictu
crewID = QString::number(picture->getCrewNumber()); crewID = QString::number(picture->getCrewNumber());
plyrsList = picture->getPlayers(); plyrsList = picture->getPlayers();
picTitl = picture->getPictureTitl(); picTitl = picture->getPictureTitl();
picArea = picture->getArea();
picAreaStr = GlobalString::getString(picArea);
QString plyrsStr; QString plyrsStr;
if (plyrsList.length() >= 1) if (plyrsList.length() >= 1)
@ -180,7 +184,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString pictu
if (crewID == "") { crewID = tr("No crew"); } if (crewID == "") { crewID = tr("No crew"); }
this->setWindowTitle(windowTitleStr.arg(picture->getPictureStr())); 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 else
{ {

View file

@ -73,6 +73,8 @@ private:
QString jsonDrawString; QString jsonDrawString;
QString windowTitleStr; QString windowTitleStr;
QStringList plyrsList; QStringList plyrsList;
QString picAreaStr;
QString picArea;
QString picTitl; QString picTitl;
QString picPath; QString picPath;
QString crewID; QString crewID;

View file

@ -75,10 +75,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;Title: &lt;/span&gt;%6&lt;br&gt; <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Title: &lt;/span&gt;%6&lt;br/&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Location: &lt;/span&gt;%7 (%1, %2, %3)&lt;br/&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Players: &lt;/span&gt;%4&lt;br/&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Crew ID: &lt;/span&gt;%5&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;span style=&quot; font-weight:600;&quot;&gt;Location: &lt;/span&gt;%1, %2, %3 &lt;br&gt;
&lt;span style=&quot; font-weight:600;&quot;&gt;Players: &lt;/span&gt;%4&lt;br&gt;
&lt;span style=&quot; font-weight:600;&quot;&gt;Crew ID: &lt;/span&gt;%5</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>

View file

@ -55,6 +55,7 @@ SnapmaticPicture::SnapmaticPicture(const QString &fileName, QObject *parent) : Q
jsonLocY = 0; jsonLocY = 0;
jsonLocZ = 0; jsonLocZ = 0;
jsonCrewID = 0; jsonCrewID = 0;
jsonArea = "";
jsonPlyrsList = QStringList(); jsonPlyrsList = QStringList();
} }
@ -333,6 +334,10 @@ void SnapmaticPicture::parseJsonContent()
if (locMap.contains("y")) { jsonLocY = locMap["y"].toDouble(); } if (locMap.contains("y")) { jsonLocY = locMap["y"].toDouble(); }
if (locMap.contains("z")) { jsonLocZ = locMap["z"].toDouble(); } if (locMap.contains("z")) { jsonLocZ = locMap["z"].toDouble(); }
} }
if (jsonMap.contains("area"))
{
jsonArea = jsonMap["area"].toString();
}
if (jsonMap.contains("crewid")) if (jsonMap.contains("crewid"))
{ {
jsonCrewID = jsonMap["crewid"].toInt(); jsonCrewID = jsonMap["crewid"].toInt();
@ -350,6 +355,11 @@ bool SnapmaticPicture::isJsonOk()
return jsonOk; return jsonOk;
} }
QString SnapmaticPicture::getArea()
{
return jsonArea;
}
QString SnapmaticPicture::getJsonStr() QString SnapmaticPicture::getJsonStr()
{ {
return jsonStr; return jsonStr;

View file

@ -46,6 +46,7 @@ public:
// JSON // JSON
bool isJsonOk(); bool isJsonOk();
QString getArea();
int getCrewNumber(); int getCrewNumber();
QString getJsonStr(); QString getJsonStr();
double getLocationX(); double getLocationX();
@ -85,6 +86,7 @@ private:
double jsonLocX; double jsonLocX;
double jsonLocY; double jsonLocY;
double jsonLocZ; double jsonLocZ;
QString jsonArea;
QStringList jsonPlyrsList; QStringList jsonPlyrsList;
signals: signals:

View file

@ -31,6 +31,7 @@ SOURCES += main.cpp \
DatabaseThread.cpp \ DatabaseThread.cpp \
ExportDialog.cpp \ ExportDialog.cpp \
ExportThread.cpp \ ExportThread.cpp \
GlobalString.cpp \
IconLoader.cpp \ IconLoader.cpp \
OptionsDialog.cpp \ OptionsDialog.cpp \
PictureCopy.cpp \ PictureCopy.cpp \
@ -61,6 +62,7 @@ HEADERS += \
DatabaseThread.h \ DatabaseThread.h \
ExportDialog.h \ ExportDialog.h \
ExportThread.h \ ExportThread.h \
GlobalString.h \
IconLoader.h \ IconLoader.h \
OptionsDialog.h \ OptionsDialog.h \
PictureCopy.h \ PictureCopy.h \