latest changes from gta5sync

This commit is contained in:
Syping 2017-10-09 08:35:48 +02:00
parent 69777a0263
commit 0069bb0b95
128 changed files with 20971 additions and 15661 deletions

27
.gitattributes vendored Normal file
View File

@ -0,0 +1,27 @@
# Auto detect text files and perform LF normalization
* text=auto eol=lf
# Development files
*.cpp text eol=lf
*.h text eol=lf
*.ui text eol=lf
*.qrc text eol=lf
# Development resources
*.ini text eol=lf
# Linux development files
*.desktop text eol=lf
# Windows development files
*.rc text eol=crlf
*.exe.manifest text eol=crlf
# Binary files
*.png binary
*.jpg binary
*.qm binary
*.ico binary
*.icns binary
*.xcf binary
*.g5e binary

View File

@ -4,7 +4,7 @@ sudo: required
language: cpp language: cpp
env: env:
- PACKAGE_VERSION="1.4.0" - PACKAGE_VERSION="1.5.0"
before_install: before_install:
- test -n $CC && unset CC - test -n $CC && unset CC
@ -12,27 +12,42 @@ before_install:
install: install:
- sudo apt-get update -qq - sudo apt-get update -qq
- sudo apt-get install -qq checkinstall dpkg-dev g++ gcc qtbase5-dev qt5-qmake - sudo apt-get install -qq checkinstall dpkg-dev g++ gcc qtbase5-dev qt5-qmake qttranslations5-l10n libqt4-dev
before_script: before_script:
- export INSTALL_ROOT=/usr
- if [ `git name-rev --tags --name-only $(git rev-parse HEAD)` == "undefined" ]; then export APPLICATION_VERSION="$PACKAGE_VERSION.$TRAVIS_BUILD_NUMBER"; else export APPLICATION_VERSION=`git name-rev --tags --name-only $(git rev-parse HEAD)`; fi - if [ `git name-rev --tags --name-only $(git rev-parse HEAD)` == "undefined" ]; then export APPLICATION_VERSION="$PACKAGE_VERSION.$TRAVIS_BUILD_NUMBER"; else export APPLICATION_VERSION=`git name-rev --tags --name-only $(git rev-parse HEAD)`; fi
- echo "gta5view build version is $APPLICATION_VERSION" - echo "gta5view build version is $APPLICATION_VERSION"
- mkdir build - mkdir build
- mkdir package - mkdir package
- chmod -x res/gta5sync_*.qm res/gta5view.desktop res/gta5view.png
- cd build - cd build
- mkdir qt4
- cd qt4
- echo "Grand Theft Auto V Snapmatic and Savegame viewer" > ./description-pak - echo "Grand Theft Auto V Snapmatic and Savegame viewer" > ./description-pak
- cd ..
- mkdir qt5
- cd qt5
- echo "Grand Theft Auto V Snapmatic and Savegame viewer" > ./description-pak
- cd ..
script: script:
- qmake -qt=5 "DEFINES+=GTA5SYNC_BUILDTYPE=\\\\\\\"Release\\\\\\\"" "DEFINES+=GTA5SYNC_DAILYB=\\\\\\\"$APPLICATION_VERSION\\\\\\\"" ../gta5view.pro - cd qt5
- qmake -qt=5 GTA5SYNC_PREFIX=/usr QMAKE_CXXFLAGS+=-std=c++11 DEFINES+=GTA5SYNC_BUILDTYPE_DEV "DEFINES+=GTA5SYNC_APPVER=\\\\\\\"$APPLICATION_VERSION\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
- make -j 4 - make -j 4
- sudo checkinstall -D --default --nodoc --pkgname=gta5view --pkgversion=$APPLICATION_VERSION --pkgrelease=travis1 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --requires=libqt5core5a,libqt5gui5,libqt5network5,libqt5widgets5 --pakdir=../package - sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view --pkgversion=$APPLICATION_VERSION --pkgrelease=travis1 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --requires=libqt5core5a,libqt5gui5,libqt5network5,libqt5widgets5,qttranslations5-l10n --conflicts=gta5view-qt4 --replaces=gta5view-qt4 --pakdir=../../package
- cd ..
- cd qt4
- qmake -qt=4 GTA5SYNC_PREFIX=/usr QMAKE_CXXFLAGS+=-std=c++11 DEFINES+=GTA5SYNC_BUILDTYPE_DEV "DEFINES+=GTA5SYNC_APPVER=\\\\\\\"$APPLICATION_VERSION\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
- make -j 4
- sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt4 --pkgversion=$APPLICATION_VERSION --pkgrelease=travis1 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --requires=libqtcore4,libqtgui4,libqt4-network,qtcore4-l10n --conflicts=gta5view --replaces=gta5view --pakdir=../../package
- cd ..
deploy: deploy:
provider: releases provider: releases
api_key: api_key:
secure: "o7VneEz1aHfdVwZvOZLfopf6uJWNrFsZaBvunTmXFzpmNFhlNS1qwqgMUkIA2yBRbZ3wIzVs4vfwIHv7W9yE/PqK+AYL+R8+AwKGrwlgT4HqJNuk6VM/LNJ6GwT/qkQuaoOVw29bUjmzzgIRdHmw53SlJv6Hh1VE8HphlTT//aex6nCfcFhUZ0BETdZDWz5FSHwL3NalUoqfKfQrJeky5RXzCyCANQC2tKt0bV46GaWIgWrDo2KCTNqPtRWWf5GDmnkXE5IYRMQ3mXvO9iYh0v5Y2jo4PiXGUiFUU6Z3aAWFAiPdGclrBO697cf3lCTzDMhuCETR153qFYsLShUlFf61ITAmCeHAWETjZDri0lmPONo3GoNB6alGfYEA51qw14kXakrTpICtTJj7gw/gtUYOabW6hrzmieNzMBIy62RikDPjyakFnuwW2qNHRlD65e0jYv+6nCpb6E+OV16Ysh1zhV2vTfpfzVmSuyu2J+ELqXD3OZCXRSPpDIih9UQ8335p8FBji6jHORcgym/TRgdgRmENibh8tLzWp+UjpWHuWfcpvZgOskjfwU0iDMCayMJ7tDpOhXHcAhDRnd6XRIiOJ5YZCzflj2nEwmt3YUd7DwXS/AU+WHOmcNQBjXBxF/FJa35XXcy3HKJM5TTKqtph3medo30us5yXHeG6NNg=" secure: "o7VneEz1aHfdVwZvOZLfopf6uJWNrFsZaBvunTmXFzpmNFhlNS1qwqgMUkIA2yBRbZ3wIzVs4vfwIHv7W9yE/PqK+AYL+R8+AwKGrwlgT4HqJNuk6VM/LNJ6GwT/qkQuaoOVw29bUjmzzgIRdHmw53SlJv6Hh1VE8HphlTT//aex6nCfcFhUZ0BETdZDWz5FSHwL3NalUoqfKfQrJeky5RXzCyCANQC2tKt0bV46GaWIgWrDo2KCTNqPtRWWf5GDmnkXE5IYRMQ3mXvO9iYh0v5Y2jo4PiXGUiFUU6Z3aAWFAiPdGclrBO697cf3lCTzDMhuCETR153qFYsLShUlFf61ITAmCeHAWETjZDri0lmPONo3GoNB6alGfYEA51qw14kXakrTpICtTJj7gw/gtUYOabW6hrzmieNzMBIy62RikDPjyakFnuwW2qNHRlD65e0jYv+6nCpb6E+OV16Ysh1zhV2vTfpfzVmSuyu2J+ELqXD3OZCXRSPpDIih9UQ8335p8FBji6jHORcgym/TRgdgRmENibh8tLzWp+UjpWHuWfcpvZgOskjfwU0iDMCayMJ7tDpOhXHcAhDRnd6XRIiOJ5YZCzflj2nEwmt3YUd7DwXS/AU+WHOmcNQBjXBxF/FJa35XXcy3HKJM5TTKqtph3medo30us5yXHeG6NNg="
file: "../package/gta5view_$APPLICATION_VERSION-travis1_amd64.deb" file_glob: true
file: "../package/gta5view*.deb"
skip_cleanup: true skip_cleanup: true
on: on:
tags: true tags: true

View File

@ -31,26 +31,30 @@ AboutDialog::AboutDialog(QWidget *parent) :
// Build Strings // Build Strings
QString appVersion = qApp->applicationVersion(); QString appVersion = qApp->applicationVersion();
QString buildType = GTA5SYNC_BUILDTYPE; QString buildType = tr(GTA5SYNC_BUILDTYPE);
buildType.replace("_", " "); buildType.replace("_", " ");
QString projectBuild = GTA5SYNC_BUILDDATETIME; QString projectBuild = GTA5SYNC_BUILDDATETIME;
QString buildStr = GTA5SYNC_BUILDSTRING; QString buildStr = GTA5SYNC_BUILDSTRING;
// Additional Content // Translator Comments
QString usingStr = tr("Using %1 %2", "Exp. Using libmyfuck"); //: Using specific library, example Using libmyfuck
QString translatedByStr = tr("Translated by %1", "Exp. Translated by Syping"); QString usingStr = tr("Using %1 %2");
QString translatedByVal = tr("NAME_OF_TRANSLATOR", "Your Name (The person behind your screen looking at this text!)"); //: Translated by translator, example Translated by Syping
QString translatorProfile = tr("TRANSLATOR_PROFILE", "mailto: http:// https:// Exp. https://github.com/Syping/"); QString translatedByStr = tr("Translated by %1");
//: Enter your name there
QString translatedByVal = tr("NAME_OF_TRANSLATOR");
//: Enter your proilfe there, example a GitHub profile, E-Mail with "mailto: afucker@sumfuck.com" or a webpage
QString translatorProfile = tr("TRANSLATOR_PROFILE");
QString additionalContent = ""; QString additionalContent = "";
if (translatedByVal != "NAME_OF_TRANSLATOR") if (translatedByVal != "NAME_OF_TRANSLATOR")
{ {
if (translatorProfile != "TRANSLATOR_PROFILE") if (translatorProfile != "TRANSLATOR_PROFILE")
{ {
additionalContent.append(translatedByStr.arg(QString("<a href=\"%1\">%2</a>").arg(translatorProfile, translatedByVal))); additionalContent += translatedByStr.arg(QString("<a href=\"%1\">%2</a>").arg(translatorProfile, translatedByVal));
} }
else else
{ {
additionalContent.append(translatedByStr.arg(translatedByVal)); additionalContent += translatedByStr.arg(translatedByVal);
} }
} }
#ifdef WITH_LIBJPEGTURBO // DONT USE IT FOR NOW #ifdef WITH_LIBJPEGTURBO // DONT USE IT FOR NOW
@ -58,12 +62,12 @@ AboutDialog::AboutDialog(QWidget *parent) :
if (!additionalContent.isEmpty()) if (!additionalContent.isEmpty())
{ {
additionalContentClip = true; additionalContentClip = true;
additionalContent.append(" ("); additionalContent += " (";
} }
additionalContent.append(usingStr.arg("libjpegturbo", WITH_LIBJPEGTURBO)); additionalContent += usingStr.arg("libjpegturbo", WITH_LIBJPEGTURBO);
if (additionalContentClip) if (additionalContentClip)
{ {
additionalContent.append(")"); additionalContent += ")";
} }
#else #else
Q_UNUSED(usingStr) Q_UNUSED(usingStr)

View File

@ -21,6 +21,7 @@
#include "StringParser.h" #include "StringParser.h"
#include "StandardPaths.h" #include "StandardPaths.h"
#include <QtGlobal> #include <QtGlobal>
#include <QStringBuilder>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QApplication> #include <QApplication>
#include <QSettings> #include <QSettings>
@ -53,7 +54,7 @@ QString AppEnv::getGameFolder(bool *ok)
} }
} }
QString GTAV_defaultFolder = StandardPaths::documentsLocation() + QDir::separator() + "Rockstar Games" + QDir::separator() + "GTA V"; QString GTAV_defaultFolder = StandardPaths::documentsLocation() % QDir::separator() % "Rockstar Games" % QDir::separator() % "GTA V";
QString GTAV_returnFolder = GTAV_defaultFolder; QString GTAV_returnFolder = GTAV_defaultFolder;
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
@ -108,14 +109,31 @@ bool AppEnv::setGameFolder(QString gameFolder)
return false; return false;
} }
QString AppEnv::getLangFolder() QString AppEnv::getExLangFolder()
{ {
return StringParser::convertBuildedString(QString::fromUtf8(GTA5SYNC_LANG)); return StringParser::convertBuildedString(GTA5SYNC_LANG);
}
QString AppEnv::getInLangFolder()
{
#ifdef GTA5SYNC_QCONF
#ifdef GTA5SYNC_INLANG
return StringParser::convertBuildedString(GTA5SYNC_INLANG);
#else
return StringParser::convertBuildedString(GTA5SYNC_SHARE % QLatin1String("SEPARATOR:APPNAME:SEPARATOR:translations"));
#endif
#else
#ifdef GTA5SYNC_INLANG
return StringParser::convertBuildedString(GTA5SYNC_INLANG);
#else
return QString(":/tr");
#endif
#endif
} }
QString AppEnv::getPluginsFolder() QString AppEnv::getPluginsFolder()
{ {
return StringParser::convertBuildedString(QString::fromUtf8(GTA5SYNC_PLUG)); return StringParser::convertBuildedString(GTA5SYNC_PLUG);
} }
// Web Stuff // Web Stuff
@ -140,6 +158,11 @@ QUrl AppEnv::getPlayerFetchingUrl(QString crewID, QString pageNumber)
return QUrl(QString("https://socialclub.rockstargames.com/crewsapi/GetMembersList?crewId=%1&pageNumber=%2").arg(crewID, pageNumber)); return QUrl(QString("https://socialclub.rockstargames.com/crewsapi/GetMembersList?crewId=%1&pageNumber=%2").arg(crewID, pageNumber));
} }
QUrl AppEnv::getPlayerFetchingUrl(QString crewID, int pageNumber)
{
return getPlayerFetchingUrl(crewID, QString::number(pageNumber));
}
qreal AppEnv::screenRatio() qreal AppEnv::screenRatio()
{ {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000

View File

@ -30,13 +30,15 @@ public:
// Folder Stuff // Folder Stuff
static QString getGameFolder(bool *ok = 0); static QString getGameFolder(bool *ok = 0);
static bool setGameFolder(QString gameFolder); static bool setGameFolder(QString gameFolder);
static QString getLangFolder(); static QString getExLangFolder();
static QString getInLangFolder();
static QString getPluginsFolder(); static QString getPluginsFolder();
// Web Stuff // Web Stuff
static QByteArray getUserAgent(); static QByteArray getUserAgent();
static QUrl getCrewFetchingUrl(QString crewID); static QUrl getCrewFetchingUrl(QString crewID);
static QUrl getPlayerFetchingUrl(QString crewID, QString pageNumber); static QUrl getPlayerFetchingUrl(QString crewID, QString pageNumber);
static QUrl getPlayerFetchingUrl(QString crewID, int pageNumber);
// Screen Stuff // Screen Stuff
static qreal screenRatio(); static qreal screenRatio();

View File

@ -19,6 +19,9 @@
#include "StandardPaths.h" #include "StandardPaths.h"
#include "CrewDatabase.h" #include "CrewDatabase.h"
#include "config.h" #include "config.h"
#include <QStringBuilder>
#include <QMutexLocker>
#include <QDebug>
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
@ -28,7 +31,7 @@ CrewDatabase::CrewDatabase(QObject *parent) : QObject(parent)
dir.mkpath(StandardPaths::dataLocation()); dir.mkpath(StandardPaths::dataLocation());
dir.setPath(StandardPaths::dataLocation()); dir.setPath(StandardPaths::dataLocation());
QString dirPath = dir.absolutePath(); QString dirPath = dir.absolutePath();
QString defaultConfPath = dirPath + QDir::separator() + "crews.ini"; QString defaultConfPath = dirPath % QDir::separator() % "crews.ini";
QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
confPathSettings.beginGroup("Database"); confPathSettings.beginGroup("Database");
@ -37,6 +40,8 @@ CrewDatabase::CrewDatabase(QObject *parent) : QObject(parent)
crewDB = new QSettings(confPathFile, QSettings::IniFormat); crewDB = new QSettings(confPathFile, QSettings::IniFormat);
crewDB->beginGroup("Crews"); crewDB->beginGroup("Crews");
addProcess = false;
} }
CrewDatabase::~CrewDatabase() CrewDatabase::~CrewDatabase()
@ -47,19 +52,52 @@ CrewDatabase::~CrewDatabase()
QStringList CrewDatabase::getCrews() QStringList CrewDatabase::getCrews()
{ {
QStringList compatibleCrewList = crewDB->childKeys(); QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "getCrews";
#endif
return getCrews_p();
}
QStringList CrewDatabase::getCrews_p()
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "getCrews_p";
#endif
QStringList compatibleCrewList = getCompatibleCrews_p();
crewDB->endGroup(); crewDB->endGroup();
crewDB->beginGroup("CrewList"); crewDB->beginGroup("CrewList");
QStringList crewIDs = crewDB->value("IDs", QStringList()).toStringList(); QStringList crewIDs = crewDB->value("IDs", QStringList()).toStringList();
crewIDs.append(compatibleCrewList); crewIDs += compatibleCrewList;
crewIDs.removeDuplicates(); crewIDs.removeDuplicates();
crewDB->endGroup(); crewDB->endGroup();
crewDB->beginGroup("Crews"); crewDB->beginGroup("Crews");
return crewIDs; return crewIDs;
} }
QStringList CrewDatabase::getCompatibleCrews()
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "getCompatibleCrews";
#endif
return getCompatibleCrews_p();
}
QStringList CrewDatabase::getCompatibleCrews_p()
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "getCompatibleCrews_p";
#endif
return crewDB->childKeys();
}
QString CrewDatabase::getCrewName(int crewID) QString CrewDatabase::getCrewName(int crewID)
{ {
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "getCrewName" << crewID;
#endif
QString crewStr = crewDB->value(QString::number(crewID), crewID).toString(); QString crewStr = crewDB->value(QString::number(crewID), crewID).toString();
if (crewID == 0) crewStr = tr("No Crew", ""); if (crewID == 0) crewStr = tr("No Crew", "");
return crewStr; return crewStr;
@ -67,13 +105,21 @@ QString CrewDatabase::getCrewName(int crewID)
void CrewDatabase::setCrewName(int crewID, QString crewName) void CrewDatabase::setCrewName(int crewID, QString crewName)
{ {
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "setCrewName" << crewID << crewName;
#endif
crewDB->setValue(QString::number(crewID), crewName); crewDB->setValue(QString::number(crewID), crewName);
} }
void CrewDatabase::addCrew(int crewID) void CrewDatabase::addCrew(int crewID)
{ {
QStringList crews = getCrews(); QMutexLocker locker(&mutex);
crews.append(QString::number(crewID)); #ifdef GTA5SYNC_DEBUG
qDebug() << "addCrew" << crewID;
#endif
QStringList crews = getCrews_p();
crews += QString::number(crewID);
crews.removeDuplicates(); crews.removeDuplicates();
crewDB->endGroup(); crewDB->endGroup();
crewDB->beginGroup("CrewList"); crewDB->beginGroup("CrewList");
@ -81,3 +127,39 @@ void CrewDatabase::addCrew(int crewID)
crewDB->endGroup(); crewDB->endGroup();
crewDB->beginGroup("Crews"); crewDB->beginGroup("Crews");
} }
bool CrewDatabase::isCompatibleCrew(QString crewNID)
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "isCompatibleCrew" << crewNID;
#endif
return crewDB->contains(crewNID);
}
bool CrewDatabase::isCompatibleCrew(int crewID)
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "isCompatibleCrew" << crewID;
#endif
return crewDB->contains(QString::number(crewID));
}
void CrewDatabase::setAddingCrews(bool addingCrews)
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "setAddingCrews" << addingCrews;
#endif
addProcess = addingCrews;
}
bool CrewDatabase::isAddingCrews()
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "isAddingCrews";
#endif
return addProcess;
}

View File

@ -21,6 +21,7 @@
#include <QSettings> #include <QSettings>
#include <QObject> #include <QObject>
#include <QMutex>
#include <QMap> #include <QMap>
class CrewDatabase : public QObject class CrewDatabase : public QObject
@ -28,15 +29,24 @@ class CrewDatabase : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit CrewDatabase(QObject *parent = 0); explicit CrewDatabase(QObject *parent = 0);
void setCrewName(int crewID, QString crewName);
QString getCrewName(int crewID); QString getCrewName(int crewID);
QStringList getCompatibleCrews();
QStringList getCrews(); QStringList getCrews();
void setAddingCrews(bool addingCrews);
bool isCompatibleCrew(QString crewNID);
bool isCompatibleCrew(int crewID);
bool isAddingCrews();
~CrewDatabase(); ~CrewDatabase();
private: private:
mutable QMutex mutex;
bool addProcess;
QSettings *crewDB; QSettings *crewDB;
QStringList getCrews_p();
QStringList getCompatibleCrews_p();
public slots: public slots:
void setCrewName(int crewID, QString crewName);
void addCrew(int crewID); void addCrew(int crewID);
}; };

View File

@ -31,46 +31,87 @@
#include <QDebug> #include <QDebug>
#include <QUrl> #include <QUrl>
#define crewMaxPages 83
DatabaseThread::DatabaseThread(CrewDatabase *crewDB, QObject *parent) : QThread(parent), crewDB(crewDB) DatabaseThread::DatabaseThread(CrewDatabase *crewDB, QObject *parent) : QThread(parent), crewDB(crewDB)
{ {
crewMaxPages = 83;
threadRunning = true; threadRunning = true;
} }
void DatabaseThread::run() void DatabaseThread::run()
{ {
QEventLoop threadLoop; QEventLoop threadLoop;
QStringList crewList; QStringList crewList;
QStringList crewListR;
// Register thread loop end signal // Register thread loop end signal
QObject::connect(this, SIGNAL(threadEndCommited()), &threadLoop, SLOT(quit())); QObject::connect(this, SIGNAL(threadEndCommited()), &threadLoop, SLOT(quit()));
// Quick time scan // Setup crewList for Quick time scan
if (crewList.length() <= 3) crewList = crewDB->getCrews();
if (!crewList.isEmpty())
{ {
scanCrewReference(crewList, 2500); crewListR = deleteCompatibleCrews(crewList);
scanCrewMembersList(crewList, 3, 2500);
emit playerNameUpdated();
} }
else if (crewList.length() <= 5) else
{ {
scanCrewReference(crewList, 2500); while (crewList.isEmpty() && threadRunning)
scanCrewMembersList(crewList, 2, 2500); {
emit playerNameUpdated(); QTimer::singleShot(1000, &threadLoop, SLOT(quit()));
threadLoop.exec();
if (!crewDB->isAddingCrews())
{
crewList = crewDB->getCrews();
}
}
if (threadRunning)
{
crewListR = deleteCompatibleCrews(crewList);
}
} }
QEventLoop *waitingLoop = new QEventLoop(); // Only do QTS when Thread should be run
QTimer::singleShot(10000, waitingLoop, SLOT(quit())); if (threadRunning)
QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit())); {
waitingLoop->exec(); // Quick time scan
delete waitingLoop; #ifdef GTA5SYNC_DEBUG
qDebug() << "Start QTS";
#endif
if (crewListR.length() <= 5)
{
scanCrewReference(crewListR, 2500);
emit crewNameUpdated();
}
if (crewList.length() <= 3)
{
scanCrewMembersList(crewList, 3, 2500);
emit playerNameUpdated();
}
else if (crewList.length() <= 5)
{
scanCrewMembersList(crewList, 2, 2500);
emit playerNameUpdated();
}
if (threadRunning)
{
QTimer::singleShot(10000, &threadLoop, SLOT(quit()));
threadLoop.exec();
}
}
while (threadRunning) while (threadRunning)
{ {
crewList = crewDB->getCrews(); crewList = crewDB->getCrews();
crewListR = deleteCompatibleCrews(crewList);
// Long time scan // Long time scan
scanCrewReference(crewList, 10000); #ifdef GTA5SYNC_DEBUG
qDebug() << "Start LTS";
#endif
scanCrewReference(crewListR, 10000);
emit crewNameUpdated();
scanCrewMembersList(crewList, crewMaxPages, 10000); scanCrewMembersList(crewList, crewMaxPages, 10000);
emit playerNameUpdated(); emit playerNameUpdated();
@ -82,81 +123,7 @@ void DatabaseThread::run()
} }
} }
// void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay) void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &requestDelay)
// {
// foreach (const QString &crewID, crewList)
// {
// if (threadRunning && crewID != "0")
// {
// QNetworkAccessManager *netManager = new QNetworkAccessManager();
// QNetworkRequest netRequest(AppEnv::getCrewFetchingUrl(crewID));
// netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
// netRequest.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
// netRequest.setRawHeader("Accept-Language", "en-US;q=0.5,en;q=0.3");
// netRequest.setRawHeader("Connection", "keep-alive");
// QNetworkReply *netReply = netManager->get(netRequest);
// QEventLoop *downloadLoop = new QEventLoop();
// QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
// QObject::connect(this, SIGNAL(threadEndCommited()), downloadLoop, SLOT(quit()));
// QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
// downloadLoop->exec();
// delete downloadLoop;
// if (netReply->isFinished())
// {
// QByteArray crewJson = netReply->readAll();
// QJsonDocument crewDocument = QJsonDocument::fromJson(crewJson);
// QJsonObject crewObject = crewDocument.object();
// QVariantMap crewMap = crewObject.toVariantMap();
// QString crewName;
// bool isFound = false;
// if (crewMap.contains("activities"))
// {
// QList<QVariant> activitiesList = crewMap["activities"].toList();
// foreach (const QVariant &activitiesVariant, activitiesList)
// {
// QMap<QString, QVariant> activityRootMap = activitiesVariant.toMap();
// foreach(const QVariant &activityRootVariant, activityRootMap)
// {
// QMap<QString, QVariant> activityMap = activityRootVariant.toMap();
// foreach(const QVariant &activityVariant, activityMap)
// {
// QMap<QString, QVariant> activityFinalMap = activityVariant.toMap();
// if (activityFinalMap.contains("id") && activityFinalMap["id"] == crewID)
// {
// if (activityFinalMap.contains("name") && isFound == false)
// {
// isFound = true;
// crewName = activityFinalMap["name"].toString();
// }
// }
// }
// }
// }
// }
// if (!crewName.isNull())
// {
// crewDB->setCrewName(crewID.toInt(), crewName);
// }
// }
// QEventLoop *waitingLoop = new QEventLoop();
// QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
// QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
// waitingLoop->exec();
// delete waitingLoop;
// delete netReply;
// delete netManager;
// }
// }
// }
void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
{ {
foreach (const QString &crewID, crewList) foreach (const QString &crewID, crewList)
{ {
@ -197,7 +164,7 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
} }
if (!crewName.isEmpty()) if (!crewName.isEmpty())
{ {
crewDB->setCrewName(crewID.toInt(), crewName); emit crewNameFound(crewID.toInt(), crewName);
} }
} }
@ -213,7 +180,7 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
} }
} }
void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int requestDelay) void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int &maxPages, const int &requestDelay)
{ {
foreach (const QString &crewID, crewList) foreach (const QString &crewID, crewList)
{ {
@ -227,7 +194,7 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
{ {
QNetworkAccessManager *netManager = new QNetworkAccessManager(); QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, QString::number(currentPage))); QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, currentPage));
#if QT_VERSION >= 0x050600 #if QT_VERSION >= 0x050600
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif #endif
@ -289,6 +256,19 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
} }
} }
QStringList DatabaseThread::deleteCompatibleCrews(const QStringList &crewList)
{
QStringList crewListR = crewList;
foreach(const QString &crewNID, crewListR)
{
if (crewDB->isCompatibleCrew(crewNID))
{
crewListR.removeAll(crewNID);
}
}
return crewListR;
}
void DatabaseThread::doEndThread() void DatabaseThread::doEndThread()
{ {
threadRunning = false; threadRunning = false;

View File

@ -34,16 +34,18 @@ public slots:
private: private:
CrewDatabase *crewDB; CrewDatabase *crewDB;
void scanCrewMembersList(QStringList crewList, int maxPages, int requestDelay); void scanCrewMembersList(const QStringList &crewList, const int &maxPages, const int &requestDelay);
void scanCrewReference(QStringList crewList, int requestDelay); void scanCrewReference(const QStringList &crewList, const int &requestDelay);
QStringList deleteCompatibleCrews(const QStringList &crewList);
bool threadRunning; bool threadRunning;
int crewMaxPages;
int plyrPerReq; int plyrPerReq;
protected: protected:
void run(); void run();
signals: signals:
void crewNameFound(int crewID, QString crewName);
void crewNameUpdated();
void playerNameFound(int playerID, QString playerName); void playerNameFound(int playerID, QString playerName);
void playerNameUpdated(); void playerNameUpdated();
void threadEndCommited(); void threadEndCommited();

View File

@ -23,6 +23,7 @@
#include "ExportThread.h" #include "ExportThread.h"
#include "SavegameData.h" #include "SavegameData.h"
#include "config.h" #include "config.h"
#include <QStringBuilder>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QApplication> #include <QApplication>
#include <QFileInfo> #include <QFileInfo>
@ -81,7 +82,7 @@ void ExportThread::run()
{ {
if (widget->getWidgetType() == "SnapmaticWidget") if (widget->getWidgetType() == "SnapmaticWidget")
{ {
SnapmaticWidget *picWidget = (SnapmaticWidget*)widget; SnapmaticWidget *picWidget = qobject_cast<SnapmaticWidget*>(widget);
SnapmaticPicture *picture = picWidget->getPicture(); SnapmaticPicture *picture = picWidget->getPicture();
if (pictureExportEnabled) if (pictureExportEnabled)
@ -89,7 +90,7 @@ void ExportThread::run()
QString exportFileName = PictureExport::getPictureFileName(picture); QString exportFileName = PictureExport::getPictureFileName(picture);
if (exportFileName.right(4) != ".jpg" && exportFileName.right(4) != ".png") if (exportFileName.right(4) != ".jpg" && exportFileName.right(4) != ".png")
{ {
exportFileName.append(".jpg"); exportFileName += ".jpg";
} }
intExportProgress++; intExportProgress++;
@ -100,7 +101,7 @@ void ExportThread::run()
QImage exportPicture = picture->getImage(); QImage exportPicture = picture->getImage();
if (sizeMode == "Desktop") if (sizeMode == "Desktop")
{ {
QRect desktopResolution = QApplication::desktop()->screenGeometry(); QRect desktopResolution = qApp->desktop()->screenGeometry();
exportPicture = exportPicture.scaled(desktopResolution.width(), desktopResolution.height(), aspectRatio, Qt::SmoothTransformation); exportPicture = exportPicture.scaled(desktopResolution.width(), desktopResolution.height(), aspectRatio, Qt::SmoothTransformation);
} }
else if (sizeMode == "Custom") else if (sizeMode == "Custom")
@ -111,16 +112,16 @@ void ExportThread::run()
bool isSaved; bool isSaved;
if (useCustomQuality) if (useCustomQuality)
{ {
isSaved = exportPicture.save(exportDirectory + "/" + exportFileName, "JPEG", customQuality); isSaved = exportPicture.save(exportDirectory % "/" % exportFileName, "JPEG", customQuality);
} }
else else
{ {
isSaved = exportPicture.save(exportDirectory + "/" + exportFileName, "JPEG", 100); isSaved = exportPicture.save(exportDirectory % "/" % exportFileName, "JPEG", 100);
} }
if (!isSaved) if (!isSaved)
{ {
failedExportPictures.append(exportFileName); failedExportPictures += exportFileName;
} }
} }
if (pictureCopyEnabled) if (pictureCopyEnabled)
@ -128,24 +129,24 @@ void ExportThread::run()
QString exportFileName = PictureExport::getPictureFileName(picture); QString exportFileName = PictureExport::getPictureFileName(picture);
if (exportFileName.right(4) != ".g5e") if (exportFileName.right(4) != ".g5e")
{ {
exportFileName.append(".g5e"); exportFileName += ".g5e";
} }
intExportProgress++; intExportProgress++;
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount))); emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
emit exportProgressUpdate(intExportProgress); emit exportProgressUpdate(intExportProgress);
QString exportFilePath = exportDirectory + "/" + exportFileName; QString exportFilePath = exportDirectory % "/" % exportFileName;
if (QFile::exists(exportFilePath)) {QFile::remove(exportFilePath);} if (QFile::exists(exportFilePath)) {QFile::remove(exportFilePath);}
if (!picture->exportPicture(exportDirectory + "/" + exportFileName, "G5E")) if (!picture->exportPicture(exportDirectory % "/" % exportFileName, SnapmaticFormat::G5E_Format))
{ {
failedCopyPictures.append(exportFileName); failedCopyPictures += exportFileName;
} }
} }
} }
else if (widget->getWidgetType() == "SavegameWidget") else if (widget->getWidgetType() == "SavegameWidget")
{ {
SavegameWidget *sgdWidget = (SavegameWidget*)widget; SavegameWidget *sgdWidget = qobject_cast<SavegameWidget*>(widget);
SavegameData *savegame = sgdWidget->getSavegame(); SavegameData *savegame = sgdWidget->getSavegame();
QString originalFileName = savegame->getSavegameFileName(); QString originalFileName = savegame->getSavegameFileName();
@ -156,11 +157,11 @@ void ExportThread::run()
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount))); emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
emit exportProgressUpdate(intExportProgress); emit exportProgressUpdate(intExportProgress);
QString exportFilePath = exportDirectory + "/" + exportFileName; QString exportFilePath = exportDirectory % "/" % exportFileName;
if (QFile::exists(exportFilePath)) {QFile::remove(exportFilePath);} if (QFile::exists(exportFilePath)) {QFile::remove(exportFilePath);}
if (!QFile::copy(originalFileName, exportFilePath)) if (!QFile::copy(originalFileName, exportFilePath))
{ {
failedSavegames.append(exportFileName); failedSavegames += exportFileName;
} }
} }
} }

View File

@ -16,12 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#include <QLocale> #include "TranslationClass.h"
#include <QSettings>
#include <QFileInfo>
#include <QStringList>
#include "GlobalString.h" #include "GlobalString.h"
#include "config.h" #include "config.h"
#include <QStringBuilder>
#include <QStringList>
#include <QFileInfo>
#include <QSettings>
#include <QLocale>
#include <QDebug>
GlobalString::GlobalString() GlobalString::GlobalString()
{ {
@ -52,7 +55,7 @@ QString GlobalString::getString(QString valueStr, bool *ok)
QStringList globalStrList = globalFile.childKeys(); QStringList globalStrList = globalFile.childKeys();
if (globalStrList.contains(valueStr)) if (globalStrList.contains(valueStr))
{ {
if (ok != 0) *ok = true; if (ok != NULL) *ok = true;
globalString = globalFile.value(valueStr, valueStr).toString(); globalString = globalFile.value(valueStr, valueStr).toString();
} }
globalFile.endGroup(); globalFile.endGroup();
@ -62,7 +65,7 @@ QString GlobalString::getString(QString valueStr, bool *ok)
QString GlobalString::getLanguageFile() QString GlobalString::getLanguageFile()
{ {
QString language = getLanguage(); QString language = getLanguage();
QString languageFile = ":/global/global." + language + ".ini"; QString languageFile = ":/global/global." % language % ".ini";
if (!QFileInfo(languageFile).exists()) if (!QFileInfo(languageFile).exists())
{ {
languageFile = ":/global/global.en.ini"; languageFile = ":/global/global.en.ini";
@ -72,18 +75,11 @@ QString GlobalString::getLanguageFile()
QString GlobalString::getLanguage() QString GlobalString::getLanguage()
{ {
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QString language = TCInstance->getCurrentLanguage();
settings.beginGroup("Interface"); QStringList langList = QString(language).replace("-", "_").split("_");
QString language = settings.value("Language","System").toString(); if (langList.length() >= 1)
settings.endGroup();
if (language == "System" || language.trimmed() == "")
{ {
QString languageName = QLocale::system().name(); language = langList.at(0);
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
language = langList.at(0);
}
} }
return language; return language;
} }

View File

@ -38,3 +38,13 @@ QIcon IconLoader::loadingAppIcon()
appIcon.addFile(":/img/5sync-256.png", QSize(256, 256)); appIcon.addFile(":/img/5sync-256.png", QSize(256, 256));
return appIcon; return appIcon;
} }
QIcon IconLoader::loadingPointmakerIcon()
{
QIcon pointmakerIcon;
pointmakerIcon.addFile(":/img/pointmaker-8.png", QSize(8, 8));
pointmakerIcon.addFile(":/img/pointmaker-16.png", QSize(16, 16));
pointmakerIcon.addFile(":/img/pointmaker-24.png", QSize(24, 24));
pointmakerIcon.addFile(":/img/pointmaker-32.png", QSize(32, 32));
return pointmakerIcon;
}

View File

@ -26,6 +26,7 @@ class IconLoader
public: public:
IconLoader(); IconLoader();
static QIcon loadingAppIcon(); static QIcon loadingAppIcon();
static QIcon loadingPointmakerIcon();
}; };
#endif // ICONLOADER_H #endif // ICONLOADER_H

View File

@ -19,10 +19,13 @@
#include "ImportDialog.h" #include "ImportDialog.h"
#include "ui_ImportDialog.h" #include "ui_ImportDialog.h"
#include "AppEnv.h" #include "AppEnv.h"
#include <QColorDialog>
#include <QMessageBox>
#include <QPainter> #include <QPainter>
#include <QPixmap> #include <QPixmap>
#include <QImage> #include <QImage>
#include <QDebug> #include <QDebug>
#include <QRgb>
// IMAGES VALUES // IMAGES VALUES
#define snapmaticResolutionW 960 #define snapmaticResolutionW 960
@ -36,8 +39,10 @@ ImportDialog::ImportDialog(QWidget *parent) :
ui(new Ui::ImportDialog) ui(new Ui::ImportDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
doImport = false; importAgreed = false;
insideAvatarZone = false;
avatarAreaImage = QImage(":/img/avatarareaimport.png"); avatarAreaImage = QImage(":/img/avatarareaimport.png");
selectedColour = QColor::fromRgb(0, 0, 0, 255);
if (QIcon::hasThemeIcon("dialog-ok")) if (QIcon::hasThemeIcon("dialog-ok"))
{ {
@ -48,7 +53,8 @@ ImportDialog::ImportDialog(QWidget *parent) :
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel")); ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
} }
ui->rbKeep->setChecked(true); ui->cbIgnore->setChecked(false);
ui->labColour->setText(tr("Background Colour: <span style=\"color: %1\">%1</span>").arg(selectedColour.name()));
qreal screenRatio = AppEnv::screenRatio(); qreal screenRatio = AppEnv::screenRatio();
snapmaticResolutionLW = 430 * screenRatio; snapmaticResolutionLW = 430 * screenRatio;
@ -69,14 +75,14 @@ void ImportDialog::processImage()
{ {
QImage snapmaticImage = workImage; QImage snapmaticImage = workImage;
QPixmap snapmaticPixmap(snapmaticResolutionW, snapmaticResolutionH); QPixmap snapmaticPixmap(snapmaticResolutionW, snapmaticResolutionH);
snapmaticPixmap.fill(Qt::black); snapmaticPixmap.fill(selectedColour);
QPainter snapmaticPainter(&snapmaticPixmap); QPainter snapmaticPainter(&snapmaticPixmap);
if (ui->cbAvatar->isChecked()) if (insideAvatarZone)
{ {
// Avatar mode // Avatar mode
int diffWidth = 0; int diffWidth = 0;
int diffHeight = 0; int diffHeight = 0;
if (ui->rbKeep->isChecked()) if (!ui->cbIgnore->isChecked())
{ {
snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation); snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (snapmaticImage.width() > snapmaticImage.height()) if (snapmaticImage.width() > snapmaticImage.height())
@ -102,7 +108,7 @@ void ImportDialog::processImage()
// Picture mode // Picture mode
int diffWidth = 0; int diffWidth = 0;
int diffHeight = 0; int diffHeight = 0;
if (ui->rbKeep->isChecked()) if (!ui->cbIgnore->isChecked())
{ {
snapmaticImage = snapmaticImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::KeepAspectRatio, Qt::SmoothTransformation); snapmaticImage = snapmaticImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (snapmaticImage.width() != snapmaticResolutionW) if (snapmaticImage.width() != snapmaticResolutionW)
@ -138,14 +144,15 @@ void ImportDialog::setImage(const QImage &image_)
workImage = image_; workImage = image_;
if (workImage.width() == workImage.height()) if (workImage.width() == workImage.height())
{ {
insideAvatarZone = true;
ui->cbAvatar->setChecked(true); ui->cbAvatar->setChecked(true);
} }
processImage(); processImage();
} }
bool ImportDialog::isDoImport() bool ImportDialog::isImportAgreed()
{ {
return doImport; return importAgreed;
} }
QString ImportDialog::getImageTitle() QString ImportDialog::getImageTitle()
@ -153,18 +160,24 @@ QString ImportDialog::getImageTitle()
return imageTitle; return imageTitle;
} }
void ImportDialog::on_rbIgnore_clicked() void ImportDialog::on_cbIgnore_toggled(bool checked)
{ {
Q_UNUSED(checked)
processImage(); processImage();
} }
void ImportDialog::on_rbKeep_clicked() void ImportDialog::on_cbAvatar_toggled(bool checked)
{
processImage();
}
void ImportDialog::on_cbAvatar_clicked()
{ {
if (workImage.width() == workImage.height() && !checked)
{
if (QMessageBox::No == QMessageBox::warning(this, tr("Snapmatic Avatar Zone"), tr("Are you sure to use a square image outside of the Avatar Zone?\nWhen you want to use it as Avatar the image will be detached!"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
{
ui->cbAvatar->setChecked(true);
insideAvatarZone = true;
return;
}
}
insideAvatarZone = ui->cbAvatar->isChecked();
processImage(); processImage();
} }
@ -175,16 +188,32 @@ void ImportDialog::on_cmdCancel_clicked()
void ImportDialog::on_cmdOK_clicked() void ImportDialog::on_cmdOK_clicked()
{ {
doImport = true; importAgreed = true;
close(); close();
} }
void ImportDialog::on_labPicture_labelPainted() void ImportDialog::on_labPicture_labelPainted()
{ {
if (ui->cbAvatar->isChecked()) if (insideAvatarZone)
{ {
QImage avatarAreaFinalImage(avatarAreaImage);
if (selectedColour.lightness() > 127)
{
avatarAreaFinalImage.setColor(1, qRgb(0, 0, 0));
}
QPainter labelPainter(ui->labPicture); QPainter labelPainter(ui->labPicture);
labelPainter.drawImage(0, 0, avatarAreaImage.scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); labelPainter.drawImage(0, 0, avatarAreaFinalImage.scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
labelPainter.end(); labelPainter.end();
} }
} }
void ImportDialog::on_cmdColourChange_clicked()
{
QColor newSelectedColour = QColorDialog::getColor(selectedColour, this, tr("Select Colour..."));
if (newSelectedColour.isValid())
{
selectedColour = newSelectedColour;
ui->labColour->setText(tr("Background Colour: <span style=\"color: %1\">%1</span>").arg(selectedColour.name()));
processImage();
}
}

View File

@ -35,16 +35,16 @@ public:
QImage image(); QImage image();
QString getImageTitle(); QString getImageTitle();
void setImage(const QImage &image); void setImage(const QImage &image);
bool isDoImport(); bool isImportAgreed();
private slots: private slots:
void processImage(); void processImage();
void on_rbIgnore_clicked(); void on_cbIgnore_toggled(bool checked);
void on_rbKeep_clicked(); void on_cbAvatar_toggled(bool checked);
void on_cbAvatar_clicked();
void on_cmdCancel_clicked(); void on_cmdCancel_clicked();
void on_cmdOK_clicked(); void on_cmdOK_clicked();
void on_labPicture_labelPainted(); void on_labPicture_labelPainted();
void on_cmdColourChange_clicked();
private: private:
Ui::ImportDialog *ui; Ui::ImportDialog *ui;
@ -52,7 +52,9 @@ private:
QString imageTitle; QString imageTitle;
QImage workImage; QImage workImage;
QImage newImage; QImage newImage;
bool doImport; QColor selectedColour;
bool insideAvatarZone;
bool importAgreed;
int snapmaticResolutionLW; int snapmaticResolutionLW;
int snapmaticResolutionLH; int snapmaticResolutionLH;
}; };

View File

@ -89,27 +89,67 @@
<property name="title"> <property name="title">
<string>Settings</string> <string>Settings</string>
</property> </property>
<layout class="QGridLayout" name="gdSettings"> <layout class="QVBoxLayout" name="verticalLayout">
<item row="1" column="0"> <item>
<widget class="QRadioButton" name="rbKeep"> <layout class="QHBoxLayout" name="hlColor">
<property name="text"> <item>
<string>&amp;Keep Aspect Ratio</string> <widget class="QLabel" name="labColour">
</property> <property name="text">
</widget> <string>Background Colour: &lt;span style=&quot;color: %1&quot;&gt;%1&lt;/span&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="cmdColourChange">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<spacer name="hsColourSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item> </item>
<item row="1" column="1"> <item>
<widget class="QRadioButton" name="rbIgnore"> <layout class="QHBoxLayout" name="hlCheckboxes">
<property name="text"> <item>
<string>&amp;Ignore Aspect Ratio</string> <widget class="QCheckBox" name="cbAvatar">
</property> <property name="sizePolicy">
</widget> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
</item> <horstretch>0</horstretch>
<item row="0" column="0"> <verstretch>0</verstretch>
<widget class="QCheckBox" name="cbAvatar"> </sizepolicy>
<property name="text"> </property>
<string>&amp;Avatar</string> <property name="text">
</property> <string>Avatar</string>
</widget> </property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbIgnore">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ignore Aspect Ratio</string>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -150,6 +190,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>Import picture</string>
</property>
<property name="text"> <property name="text">
<string>&amp;OK</string> <string>&amp;OK</string>
</property> </property>
@ -163,6 +206,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>Discard picture</string>
</property>
<property name="text"> <property name="text">
<string>&amp;Cancel</string> <string>&amp;Cancel</string>
</property> </property>
@ -179,7 +225,13 @@
<customwidget> <customwidget>
<class>UiModLabel</class> <class>UiModLabel</class>
<extends>QLabel</extends> <extends>QLabel</extends>
<header>UiModLabel.h</header> <header>uimod/UiModLabel.h</header>
<slots>
<signal>mouseMoved()</signal>
<signal>mouseReleased()</signal>
<signal>mousePressed()</signal>
<signal>mouseDoubleClicked()</signal>
</slots>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>

76
MapPreviewDialog.cpp Normal file
View File

@ -0,0 +1,76 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2017 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 "MapPreviewDialog.h"
#include "ui_MapPreviewDialog.h"
#include "IconLoader.h"
#include "AppEnv.h"
#include <QPainter>
#include <QDebug>
#ifdef __MINGW32__
#include <cmath>
#endif
MapPreviewDialog::MapPreviewDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::MapPreviewDialog)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
ui->setupUi(this);
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
setMinimumSize(500 * screenRatio, 600 * screenRatio);
setMaximumSize(500 * screenRatio, 600 * screenRatio);
setFixedSize(500 * screenRatio, 600 * screenRatio);
}
MapPreviewDialog::~MapPreviewDialog()
{
delete ui;
}
void MapPreviewDialog::drawPointOnMap(double xpos_d, double ypos_d)
{
qreal screenRatio = AppEnv::screenRatio();
int pointMakerSize = 8 * screenRatio;
QPixmap pointMakerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMakerSize, pointMakerSize));
QSize mapPixelSize = size();
int pointMakerHalfSize = pointMakerSize / 2;
long xpos_ms = std::round(xpos_d);
long ypos_ms = std::round(ypos_d);
double xpos_ma = xpos_ms + 4000;
double ypos_ma = ypos_ms + 4000;
double xrat = (double)mapPixelSize.width() / 10000;
double yrat = (double)mapPixelSize.height() / 12000;
long xpos_mp = std::round(xpos_ma * xrat);
long ypos_mp = std::round(ypos_ma * yrat);
long xpos_pr = xpos_mp - pointMakerHalfSize;
long ypos_pr = ypos_mp + pointMakerHalfSize;
QPixmap mapPixmap(mapPixelSize);
QPainter mapPainter(&mapPixmap);
mapPainter.drawPixmap(0, 0, mapPixelSize.width(), mapPixelSize.height(), QPixmap(":/img/mappreview.jpg").scaled(mapPixelSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
mapPainter.drawPixmap(xpos_pr, mapPixelSize.height() - ypos_pr, pointMakerSize, pointMakerSize, pointMakerPixmap);
mapPainter.end();
ui->labPicture->setPixmap(mapPixmap);
}

41
MapPreviewDialog.h Normal file
View File

@ -0,0 +1,41 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2017 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 MAPPREVIEWDIALOG_H
#define MAPPREVIEWDIALOG_H
#include <QDialog>
namespace Ui {
class MapPreviewDialog;
}
class MapPreviewDialog : public QDialog
{
Q_OBJECT
public:
explicit MapPreviewDialog(QWidget *parent = 0);
void drawPointOnMap(double x, double y);
~MapPreviewDialog();
private:
Ui::MapPreviewDialog *ui;
};
#endif // MAPPREVIEWDIALOG_H

71
MapPreviewDialog.ui Normal file
View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MapPreviewDialog</class>
<widget class="QDialog" name="MapPreviewDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>600</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>600</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>600</height>
</size>
</property>
<property name="windowTitle">
<string>Snapmatic Map Viewer</string>
</property>
<layout class="QVBoxLayout" name="vlMapPreview">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="UiModLabel" name="labPicture">
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>UiModLabel</class>
<extends>QLabel</extends>
<header>uimod/UiModLabel.h</header>
<slots>
<signal>mouseMoved()</signal>
<signal>mouseReleased()</signal>
<signal>mousePressed()</signal>
<signal>mouseDoubleClicked()</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -18,10 +18,12 @@
#include "OptionsDialog.h" #include "OptionsDialog.h"
#include "ui_OptionsDialog.h" #include "ui_OptionsDialog.h"
#include "TranslationClass.h"
#include "StandardPaths.h" #include "StandardPaths.h"
#include "UserInterface.h" #include "UserInterface.h"
#include "AppEnv.h" #include "AppEnv.h"
#include "config.h" #include "config.h"
#include <QStringBuilder>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QApplication> #include <QApplication>
#include <QFileDialog> #include <QFileDialog>
@ -45,7 +47,7 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
ui->tabWidget->setCurrentIndex(0); ui->tabWidget->setCurrentIndex(0);
ui->labPicCustomRes->setVisible(false); ui->labPicCustomRes->setVisible(false);
QRect desktopResolution = QApplication::desktop()->screenGeometry(parent); QRect desktopResolution = qApp->desktop()->screenGeometry(parent);
int desktopSizeWidth = desktopResolution.width(); int desktopSizeWidth = desktopResolution.width();
int desktopSizeHeight = desktopResolution.height(); int desktopSizeHeight = desktopResolution.height();
aspectRatio = Qt::KeepAspectRatio; aspectRatio = Qt::KeepAspectRatio;
@ -115,7 +117,7 @@ void OptionsDialog::setupTreeWidget()
QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList); QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList);
ui->twPlayers->addTopLevelItem(playerItem); ui->twPlayers->addTopLevelItem(playerItem);
playerItems.append(playerItem); playerItems += playerItem;
} }
} }
ui->twPlayers->sortItems(1, Qt::AscendingOrder); ui->twPlayers->sortItems(1, Qt::AscendingOrder);
@ -127,47 +129,25 @@ void OptionsDialog::setupLanguageBox()
currentLanguage = settings->value("Language","System").toString(); currentLanguage = settings->value("Language","System").toString();
settings->endGroup(); settings->endGroup();
QStringList langList = QLocale::system().name().split("_"); QString cbSysStr = tr("%1 (Next Closest Language)", "First language a person can talk with a different person/application. \"Native\" or \"Not Native\".").arg(tr("System",
if (langList.length() > 0) "System in context of System default"));
{ ui->cbLanguage->addItem(cbSysStr, "System");
QString cbSysStr = tr("%1 (%2 if available)", "System like PC System = %1, System Language like Deutsch = %2").arg(tr("System",
"System like PC System"), QLocale::languageToString(QLocale(langList.at(0)).language()));
ui->cbLanguage->addItem(cbSysStr, "System");
}
QString cbEngStr = "English (English) [en]"; QStringList availableLanguages;
ui->cbLanguage->addItem(QIcon::fromTheme("flag-us"), cbEngStr, "en"); availableLanguages << QString("en_GB");
if (currentLanguage == "en") #ifndef GTA5SYNC_QCONF
{ availableLanguages << TCInstance->listTranslations(AppEnv::getExLangFolder());
#if QT_VERSION >= 0x050000
ui->cbLanguage->setCurrentText(cbEngStr);
#else
int indexOfEnglish = ui->cbLanguage->findText(cbEngStr);
ui->cbLanguage->setCurrentIndex(indexOfEnglish);
#endif #endif
} availableLanguages << TCInstance->listTranslations(AppEnv::getInLangFolder());
availableLanguages.removeDuplicates();
availableLanguages.sort();
QDir langDir; foreach(const QString &lang, availableLanguages)
langDir.setNameFilters(QStringList("gta5sync_*.qm"));
langDir.setPath(AppEnv::getLangFolder());
QStringList langFiles;
langFiles << langDir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::NoSort);
langDir.setPath(":/tr");
langFiles << langDir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::NoSort);
langFiles.removeDuplicates();
foreach(const QString &langFile, langFiles)
{ {
QString lang = langFile;
lang.remove("gta5sync_");
lang.remove(".qm");
QLocale langLocale(lang); QLocale langLocale(lang);
QString languageNameInternational = QLocale::languageToString(langLocale.language()); QString cbLangStr = langLocale.nativeLanguageName() % " (" % langLocale.nativeCountryName() % ") [" % lang % "]";
QString languageNameNative = langLocale.nativeLanguageName();
QString cbLangStr = languageNameNative + " (" + languageNameInternational + ") [" + lang + "]"; QString langIconStr = "flag-" % TranslationClass::getCountryCode(langLocale);
QString langIconStr = "flag-" + lang;
ui->cbLanguage->addItem(QIcon::fromTheme(langIconStr), cbLangStr, lang); ui->cbLanguage->addItem(QIcon::fromTheme(langIconStr), cbLangStr, lang);
if (currentLanguage == lang) if (currentLanguage == lang)
@ -275,25 +255,27 @@ void OptionsDialog::applySettings()
settings->setValue("force", forceCustomFolder); settings->setValue("force", forceCustomFolder);
settings->endGroup(); settings->endGroup();
#if QT_VERSION >= 0x050000
bool languageChanged = ui->cbLanguage->currentData().toString() != currentLanguage;
#else
bool languageChanged = ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()).toString() != currentLanguage;
#endif
if (languageChanged)
{
TCInstance->unloadTranslation(qApp);
TCInstance->initUserLanguage();
TCInstance->loadTranslation(qApp);
}
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
emit settingsApplied(newContentMode, ui->cbLanguage->currentData().toString()); emit settingsApplied(newContentMode, ui->cbLanguage->currentData().toString());
#else #else
emit settingsApplied(newContentMode, ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()).toString()); emit settingsApplied(newContentMode, ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()).toString());
#endif #endif
#if QT_VERSION >= 0x050000
bool languageChanged = ui->cbLanguage->currentData().toString() != currentLanguage;
#else
bool languageChanged = ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()).toString() != currentLanguage;
#endif
if ((forceCustomFolder && ui->txtFolder->text() != currentCFolder) || (forceCustomFolder != currentFFolder && forceCustomFolder)) if ((forceCustomFolder && ui->txtFolder->text() != currentCFolder) || (forceCustomFolder != currentFFolder && forceCustomFolder))
{ {
QMessageBox::information(this, tr("%1", "%1").arg(GTA5SYNC_APPSTR), tr("The new Custom Folder will initialize after you restart %1.").arg(GTA5SYNC_APPSTR)); QMessageBox::information(this, tr("%1", "%1").arg(GTA5SYNC_APPSTR), tr("The new Custom Folder will initialise after you restart %1.").arg(GTA5SYNC_APPSTR));
}
if (languageChanged)
{
QMessageBox::information(this, tr("%1", "%1").arg(GTA5SYNC_APPSTR), tr("The language change will take effect after you restart %1.").arg(GTA5SYNC_APPSTR));
} }
} }

View File

@ -459,6 +459,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>Apply changes</string>
</property>
<property name="text"> <property name="text">
<string extracomment="OK, Cancel, Apply">&amp;OK</string> <string extracomment="OK, Cancel, Apply">&amp;OK</string>
</property> </property>
@ -472,6 +475,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>Discard changes</string>
</property>
<property name="text"> <property name="text">
<string extracomment="OK, Cancel, Apply">&amp;Cancel</string> <string extracomment="OK, Cancel, Apply">&amp;Cancel</string>
</property> </property>

View File

@ -21,6 +21,8 @@
#include "ProfileDatabase.h" #include "ProfileDatabase.h"
#include "ui_PictureDialog.h" #include "ui_PictureDialog.h"
#include "SidebarGenerator.h" #include "SidebarGenerator.h"
#include "MapPreviewDialog.h"
#include "SnapmaticEditor.h"
#include "StandardPaths.h" #include "StandardPaths.h"
#include "PictureExport.h" #include "PictureExport.h"
#include "StringParser.h" #include "StringParser.h"
@ -35,6 +37,7 @@
#endif #endif
#endif #endif
#include <QStringBuilder>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QJsonDocument> #include <QJsonDocument>
#include <QApplication> #include <QApplication>
@ -98,22 +101,23 @@ void PictureDialog::setupPictureDialog(bool withDatabase_)
ui->setupUi(this); ui->setupUi(this);
windowTitleStr = this->windowTitle(); windowTitleStr = this->windowTitle();
jsonDrawString = ui->labJSON->text(); jsonDrawString = ui->labJSON->text();
ui->cmdExport->setEnabled(0); ui->cmdManage->setEnabled(false);
plyrsList = QStringList(); plyrsList = QStringList();
fullscreenWidget = 0; fullscreenWidget = nullptr;
rqFullscreen = 0; rqFullscreen = false;
previewMode = 0; previewMode = false;
naviEnabled = 0; naviEnabled = false;
indexed = 0; indexed = false;
picArea = ""; picArea = "";
picTitl = ""; picTitl = "";
picPath = ""; picPath = "";
created = ""; created = "";
crewStr = "";
crewID = ""; crewID = "";
locX = ""; locX = "";
locY = ""; locY = "";
locZ = ""; locZ = "";
smpic = 0; smpic = nullptr;
// With datebase // With datebase
withDatabase = withDatabase_; withDatabase = withDatabase_;
@ -134,13 +138,17 @@ void PictureDialog::setupPictureDialog(bool withDatabase_)
// Overlay area // Overlay area
renderOverlayPicture(); renderOverlayPicture();
overlayEnabled = 1; overlayEnabled = true;
// Export menu // Manage menu
exportMenu = new QMenu(this); manageMenu = new QMenu(this);
jpegExportAction = exportMenu->addAction(tr("Export as &JPG picture..."), this, SLOT(exportSnapmaticPicture())); jpegExportAction = manageMenu->addAction(tr("Export as &Picture..."), this, SLOT(exportSnapmaticPicture()));
pgtaExportAction = exportMenu->addAction(tr("Export as &GTA Snapmatic..."), this, SLOT(copySnapmaticPicture())); pgtaExportAction = manageMenu->addAction(tr("Export as &Snapmatic..."), this, SLOT(copySnapmaticPicture()));
ui->cmdExport->setMenu(exportMenu); manageMenuSep1 = manageMenu->addSeparator();
openViewerAction = manageMenu->addAction(tr("Open &Map View..."), this, SLOT(openPreviewMap()));
openViewerAction->setShortcut(Qt::Key_M);
propEditorAction = manageMenu->addAction(tr("&Edit Properties..."), this, SLOT(editSnapmaticProperties()));
ui->cmdManage->setMenu(manageMenu);
// Global map // Global map
globalMap = GlobalString::getGlobalMap(); globalMap = GlobalString::getGlobalMap();
@ -166,9 +174,12 @@ void PictureDialog::setupPictureDialog(bool withDatabase_)
PictureDialog::~PictureDialog() PictureDialog::~PictureDialog()
{ {
delete propEditorAction;
delete openViewerAction;
delete jpegExportAction; delete jpegExportAction;
delete pgtaExportAction; delete pgtaExportAction;
delete exportMenu; delete manageMenuSep1;
delete manageMenu;
delete ui; delete ui;
} }
@ -275,10 +286,6 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
emit nextPictureRequested(); emit nextPictureRequested();
returnValue = true; returnValue = true;
break; break;
case Qt::Key_E: case Qt::Key_S: case Qt::Key_Save:
ui->cmdExport->click();
returnValue = true;
break;
case Qt::Key_1: case Qt::Key_1:
if (previewMode) if (previewMode)
{ {
@ -303,6 +310,10 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
if (!previewMode) renderPicture(); if (!previewMode) renderPicture();
} }
break; break;
case Qt::Key_M:
openPreviewMap();
returnValue = true;
break;
#if QT_VERSION >= 0x050300 #if QT_VERSION >= 0x050300
case Qt::Key_Exit: case Qt::Key_Exit:
ui->cmdClose->click(); ui->cmdClose->click();
@ -331,7 +342,7 @@ void PictureDialog::triggerFullscreenDoubeClick()
void PictureDialog::exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen) void PictureDialog::exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen)
{ {
rqFullscreen = fullscreen; rqFullscreen = fullscreen;
exportMenu->popup(pos); manageMenu->popup(pos);
} }
void PictureDialog::exportCustomContextMenuRequested(const QPoint &pos) void PictureDialog::exportCustomContextMenuRequested(const QPoint &pos)
@ -411,6 +422,7 @@ void PictureDialog::renderOverlayPicture()
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, bool _indexed, int _index) void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, bool _indexed, int _index)
{ {
if (smpic != nullptr) smpic->disconnect(this, SLOT(updated()));
snapmaticPicture = QImage(); snapmaticPicture = QImage();
indexed = _indexed; indexed = _indexed;
index = _index; index = _index;
@ -425,7 +437,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
{ {
snapmaticPicture = picture->getImage(); snapmaticPicture = picture->getImage();
renderPicture(); renderPicture();
ui->cmdExport->setEnabled(true); ui->cmdManage->setEnabled(true);
} }
if (picture->isJsonOk()) if (picture->isJsonOk())
{ {
@ -434,11 +446,13 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
locZ = QString::number(picture->getSnapmaticProperties().location.z); locZ = QString::number(picture->getSnapmaticProperties().location.z);
if (withDatabase) if (withDatabase)
{ {
crewID = crewDB->getCrewName(picture->getSnapmaticProperties().crewID); crewID = QString::number(picture->getSnapmaticProperties().crewID);
crewStr = crewDB->getCrewName(picture->getSnapmaticProperties().crewID);
} }
else else
{ {
crewID = QString::number(picture->getSnapmaticProperties().crewID); crewID = QString::number(picture->getSnapmaticProperties().crewID);
crewStr = QString::number(picture->getSnapmaticProperties().crewID);
} }
created = picture->getSnapmaticProperties().createdDateTime.toString(Qt::DefaultLocaleShortDate); created = picture->getSnapmaticProperties().createdDateTime.toString(Qt::DefaultLocaleShortDate);
plyrsList = picture->getSnapmaticProperties().playersList; plyrsList = picture->getSnapmaticProperties().playersList;
@ -453,45 +467,15 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
picAreaStr = picArea; picAreaStr = picArea;
} }
QString plyrsStr;
if (plyrsList.length() >= 1)
{
foreach (const QString &player, plyrsList)
{
QString playerName;
if (withDatabase)
{
playerName = profileDB->getPlayerName(player.toInt());
}
else
{
playerName = player;
}
plyrsStr.append(", <a href=\"https://socialclub.rockstargames.com/member/");
plyrsStr.append(playerName);
plyrsStr.append("/");
plyrsStr.append(player);
plyrsStr.append("\">");
plyrsStr.append(playerName);
plyrsStr.append("</a>");
}
plyrsStr.remove(0,2);
}
else
{
plyrsStr = tr("No player");
}
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, picAreaStr, created)); ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created));
} }
else else
{ {
ui->labJSON->setText(jsonDrawString.arg("0.0", "0.0", "0.0", tr("No player"), tr("No crew"), tr("Unknown Location"))); ui->labJSON->setText(jsonDrawString.arg("0", "0", "0", tr("No Players"), tr("No Crew"), tr("Unknown Location")));
QMessageBox::warning(this,tr("Snapmatic Picture Viewer"),tr("Failed at %1").arg(picture->getLastStep())); QMessageBox::warning(this,tr("Snapmatic Picture Viewer"),tr("Failed at %1").arg(picture->getLastStep()));
} }
QObject::connect(smpic, SIGNAL(updated()), this, SLOT(updated()));
emit newPictureCommited(snapmaticPicture); emit newPictureCommited(snapmaticPicture);
} }
@ -573,17 +557,43 @@ void PictureDialog::renderPicture()
snapPainter.drawImage(0, 0, avatarAreaPicture); snapPainter.drawImage(0, 0, avatarAreaPicture);
snapPainter.setPen(QColor::fromRgb(255, 255, 255, 255)); snapPainter.setPen(QColor::fromRgb(255, 255, 255, 255));
snapPainter.setFont(snapPainterFont); snapPainter.setFont(snapPainterFont);
snapPainter.drawText(QRect(3 * screenRatio, 3 * screenRatio, 140 * screenRatio, 60 * screenRatio), Qt::AlignLeft | Qt::TextWordWrap, tr("Avatar Preview Mode\nPress 1 for Default View")); snapPainter.drawText(QRect(3 * screenRatio, 3 * screenRatio, 140 * screenRatio, 536 * screenRatio), Qt::AlignLeft | Qt::TextWordWrap, tr("Avatar Preview Mode\nPress 1 for Default View"));
snapPainter.end(); snapPainter.end();
ui->labPicture->setPixmap(avatarPixmap); ui->labPicture->setPixmap(avatarPixmap);
} }
} }
void PictureDialog::crewNameUpdated()
{
if (withDatabase && crewID == crewStr)
{
crewStr = crewDB->getCrewName(crewID.toInt());
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created));
}
}
void PictureDialog::playerNameUpdated() void PictureDialog::playerNameUpdated()
{ {
if (plyrsList.count() >= 1) if (plyrsList.count() >= 1)
{ {
QString plyrsStr; ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created));
}
}
QString PictureDialog::generateCrewString()
{
if (crewID != "0" && !crewID.isEmpty())
{
return QString("<a href=\"https://socialclub.rockstargames.com/crew/" % QString(crewStr).replace(" ", "_") % "/" % crewID % "\">" % crewStr % "</a>");
}
return tr("No Crew");
}
QString PictureDialog::generatePlayersString()
{
QString plyrsStr;
if (plyrsList.length() >= 1)
{
foreach (const QString &player, plyrsList) foreach (const QString &player, plyrsList)
{ {
QString playerName; QString playerName;
@ -595,29 +605,20 @@ void PictureDialog::playerNameUpdated()
{ {
playerName = player; playerName = player;
} }
plyrsStr.append(", <a href=\"https://socialclub.rockstargames.com/member/"); plyrsStr += ", <a href=\"https://socialclub.rockstargames.com/member/" % playerName % "/" % player % "\">" % playerName % "</a>";
if (playerName != player)
{
plyrsStr.append(playerName);
}
else
{
plyrsStr.append("id");
}
plyrsStr.append("/");
plyrsStr.append(player);
plyrsStr.append("\">");
plyrsStr.append(playerName);
plyrsStr.append("</a>");
} }
plyrsStr.remove(0,2); plyrsStr.remove(0,2);
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr, crewID, picTitl, picAreaStr, created));
} }
else
{
plyrsStr = tr("No Players");
}
return plyrsStr;
} }
void PictureDialog::exportSnapmaticPicture() void PictureDialog::exportSnapmaticPicture()
{ {
if (rqFullscreen && fullscreenWidget) if (rqFullscreen && fullscreenWidget != nullptr)
{ {
PictureExport::exportAsPicture(fullscreenWidget, smpic); PictureExport::exportAsPicture(fullscreenWidget, smpic);
} }
@ -629,7 +630,7 @@ void PictureDialog::exportSnapmaticPicture()
void PictureDialog::copySnapmaticPicture() void PictureDialog::copySnapmaticPicture()
{ {
if (rqFullscreen && fullscreenWidget) if (rqFullscreen && fullscreenWidget != nullptr)
{ {
PictureExport::exportAsSnapmatic(fullscreenWidget, smpic); PictureExport::exportAsSnapmatic(fullscreenWidget, smpic);
} }
@ -668,7 +669,7 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button)
pictureWidget->raise(); pictureWidget->raise();
pictureWidget->exec(); pictureWidget->exec();
fullscreenWidget = 0; // Work! fullscreenWidget = nullptr; // Work!
delete pictureWidget; // Work! delete pictureWidget; // Work!
} }
} }
@ -687,3 +688,57 @@ int PictureDialog::getIndex()
{ {
return index; return index;
} }
void PictureDialog::openPreviewMap()
{
MapPreviewDialog *mapPreviewDialog;
if (rqFullscreen && fullscreenWidget != nullptr)
{
mapPreviewDialog = new MapPreviewDialog(fullscreenWidget);
}
else
{
mapPreviewDialog = new MapPreviewDialog(this);
}
mapPreviewDialog->setWindowIcon(windowIcon());
mapPreviewDialog->setModal(true);
mapPreviewDialog->drawPointOnMap(smpic->getSnapmaticProperties().location.x, smpic->getSnapmaticProperties().location.y);
mapPreviewDialog->show();
mapPreviewDialog->exec();
delete mapPreviewDialog;
}
void PictureDialog::editSnapmaticProperties()
{
SnapmaticEditor *snapmaticEditor;
if (rqFullscreen && fullscreenWidget != nullptr)
{
snapmaticEditor = new SnapmaticEditor(crewDB, fullscreenWidget);
}
else
{
snapmaticEditor = new SnapmaticEditor(crewDB, this);
}
snapmaticEditor->setWindowFlags(snapmaticEditor->windowFlags()^Qt::WindowContextHelpButtonHint);
snapmaticEditor->setWindowIcon(windowIcon());
snapmaticEditor->setSnapmaticPicture(smpic);
snapmaticEditor->setModal(true);
snapmaticEditor->exec();
delete snapmaticEditor;
}
void PictureDialog::updated()
{
if (withDatabase)
{
crewID = QString::number(smpic->getSnapmaticProperties().crewID);
crewStr = crewDB->getCrewName(smpic->getSnapmaticProperties().crewID);
}
else
{
crewID = QString::number(smpic->getSnapmaticProperties().crewID);
crewStr = QString::number(smpic->getSnapmaticProperties().crewID);
}
picTitl = StringParser::escapeString(smpic->getPictureTitle());
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created));
}

View File

@ -52,6 +52,7 @@ public:
~PictureDialog(); ~PictureDialog();
public slots: public slots:
void crewNameUpdated();
void playerNameUpdated(); void playerNameUpdated();
void dialogNextPictureRequested(); void dialogNextPictureRequested();
void dialogPreviousPictureRequested(); void dialogPreviousPictureRequested();
@ -67,8 +68,11 @@ private slots:
void exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen); void exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen);
void nextPictureRequestedSlot(); void nextPictureRequestedSlot();
void previousPictureRequestedSlot(); void previousPictureRequestedSlot();
void editSnapmaticProperties();
void renderOverlayPicture(); void renderOverlayPicture();
void renderPicture(); void renderPicture();
void openPreviewMap();
void updated();
signals: signals:
void nextPictureRequested(); void nextPictureRequested();
@ -83,6 +87,8 @@ protected:
bool event(QEvent *event); bool event(QEvent *event);
private: private:
QString generateCrewString();
QString generatePlayersString();
bool primaryWindow; bool primaryWindow;
ProfileDatabase *profileDB; ProfileDatabase *profileDB;
CrewDatabase *crewDB; CrewDatabase *crewDB;
@ -92,6 +98,9 @@ private:
QWidget *fullscreenWidget; QWidget *fullscreenWidget;
QAction *jpegExportAction; QAction *jpegExportAction;
QAction *pgtaExportAction; QAction *pgtaExportAction;
QAction *propEditorAction;
QAction *openViewerAction;
QAction *manageMenuSep1;
QImage avatarAreaPicture; QImage avatarAreaPicture;
QImage snapmaticPicture; QImage snapmaticPicture;
QImage overlayTempImage; QImage overlayTempImage;
@ -103,6 +112,7 @@ private:
QString picTitl; QString picTitl;
QString picPath; QString picPath;
QString created; QString created;
QString crewStr;
QString crewID; QString crewID;
QString locX; QString locX;
QString locY; QString locY;
@ -117,7 +127,7 @@ private:
int avatarLocX; int avatarLocX;
int avatarLocY; int avatarLocY;
int avatarSize; int avatarSize;
QMenu *exportMenu; QMenu *manageMenu;
}; };
#endif // PICTUREDIALOG_H #endif // PICTUREDIALOG_H

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>960</width> <width>960</width>
<height>602</height> <height>618</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -163,7 +163,7 @@
<number>6</number> <number>6</number>
</property> </property>
<item> <item>
<widget class="QPushButton" name="cmdExport"> <widget class="QPushButton" name="cmdManage">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum"> <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -174,10 +174,10 @@
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Export picture</string> <string>Manage picture</string>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Export</string> <string>&amp;Manage</string>
</property> </property>
<property name="autoDefault"> <property name="autoDefault">
<bool>false</bool> <bool>false</bool>
@ -196,7 +196,7 @@
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Close</string> <string>Close viewer</string>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Close</string> <string>&amp;Close</string>

View File

@ -21,11 +21,13 @@
#include "PictureDialog.h" #include "PictureDialog.h"
#include "StandardPaths.h" #include "StandardPaths.h"
#include "SidebarGenerator.h" #include "SidebarGenerator.h"
#include <QStringBuilder>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QApplication> #include <QApplication>
#include <QMessageBox> #include <QMessageBox>
#include <QFileDialog> #include <QFileDialog>
#include <QSettings> #include <QSettings>
#include <QRegExp>
#include <QDebug> #include <QDebug>
PictureExport::PictureExport() PictureExport::PictureExport()
@ -85,11 +87,11 @@ fileDialogPreSave: //Work?
fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true); fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true);
fileDialog.setDefaultSuffix("suffix"); fileDialog.setDefaultSuffix("suffix");
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint); fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(PictureDialog::tr("Export as JPG picture...")); fileDialog.setWindowTitle(PictureDialog::tr("Export as Picture..."));
fileDialog.setLabelText(QFileDialog::Accept, PictureDialog::tr("Export")); fileDialog.setLabelText(QFileDialog::Accept, PictureDialog::tr("Export"));
QStringList filters; QStringList filters;
filters << PictureDialog::tr("JPEG picture (*.jpg)"); filters << PictureDialog::tr("JPEG Graphics (*.jpg *.jpeg)");
filters << PictureDialog::tr("Portable Network Graphics (*.png)"); filters << PictureDialog::tr("Portable Network Graphics (*.png)");
fileDialog.setNameFilters(filters); fileDialog.setNameFilters(filters);
@ -97,9 +99,9 @@ fileDialogPreSave: //Work?
fileDialog.setSidebarUrls(sidebarUrls); fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.setDirectory(settings.value("Directory", StandardPaths::picturesLocation()).toString()); fileDialog.setDirectory(settings.value("Directory", StandardPaths::picturesLocation()).toString());
fileDialog.restoreGeometry(settings.value(parent->objectName() + "+Geomtery", "").toByteArray()); fileDialog.restoreGeometry(settings.value(parent->objectName() % "+Geomtery", "").toByteArray());
QString newPictureFileName = getPictureFileName(picture) + defaultExportFormat; QString newPictureFileName = getPictureFileName(picture) % defaultExportFormat;
fileDialog.selectFile(newPictureFileName); fileDialog.selectFile(newPictureFileName);
if (fileDialog.exec()) if (fileDialog.exec())
@ -140,11 +142,11 @@ fileDialogPreSave: //Work?
if (QFile::exists(selectedFile)) if (QFile::exists(selectedFile))
{ {
if (QMessageBox::Yes == QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)) if (QMessageBox::Yes == QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))
{ {
if (!QFile::remove(selectedFile)) if (!QFile::remove(selectedFile))
{ {
QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("Failed to overwrite %1 with current Snapmatic picture").arg("\""+selectedFile+"\"")); QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to overwrite %1 with current Snapmatic picture").arg("\""+selectedFile+"\""));
goto fileDialogPreSave; //Work? goto fileDialogPreSave; //Work?
} }
} }
@ -178,18 +180,18 @@ fileDialogPreSave: //Work?
if (!isSaved) if (!isSaved)
{ {
QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("Failed to export current Snapmatic picture")); QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave; //Work? goto fileDialogPreSave; //Work?
} }
} }
else else
{ {
QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("No valid file is selected")); QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("No valid file is selected"));
goto fileDialogPreSave; //Work? goto fileDialogPreSave; //Work?
} }
} }
settings.setValue(parent->objectName() + "+Geometry", fileDialog.saveGeometry()); settings.setValue(parent->objectName() % "+Geometry", fileDialog.saveGeometry());
settings.setValue("Directory", fileDialog.directory().absolutePath()); settings.setValue("Directory", fileDialog.directory().absolutePath());
settings.endGroup(); settings.endGroup();
settings.endGroup(); settings.endGroup();
@ -217,7 +219,7 @@ fileDialogPreSave: //Work?
fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true); fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true);
fileDialog.setDefaultSuffix(".rem"); fileDialog.setDefaultSuffix(".rem");
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint); fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(PictureDialog::tr("Export as GTA Snapmatic...")); fileDialog.setWindowTitle(PictureDialog::tr("Export as Snapmatic..."));
fileDialog.setLabelText(QFileDialog::Accept, PictureDialog::tr("Export")); fileDialog.setLabelText(QFileDialog::Accept, PictureDialog::tr("Export"));
QStringList filters; QStringList filters;
@ -230,8 +232,8 @@ fileDialogPreSave: //Work?
fileDialog.setSidebarUrls(sidebarUrls); fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.setDirectory(settings.value("Directory", StandardPaths::documentsLocation()).toString()); fileDialog.setDirectory(settings.value("Directory", StandardPaths::documentsLocation()).toString());
fileDialog.selectFile(QString(picture->getExportPictureFileName() + ".g5e")); fileDialog.selectFile(QString(picture->getExportPictureFileName() % ".g5e"));
fileDialog.restoreGeometry(settings.value(parent->objectName() + "+Geomtery", "").toByteArray()); fileDialog.restoreGeometry(settings.value(parent->objectName() % "+Geomtery", "").toByteArray());
if (fileDialog.exec()) if (fileDialog.exec())
@ -240,14 +242,26 @@ fileDialogPreSave: //Work?
if (selectedFiles.length() == 1) if (selectedFiles.length() == 1)
{ {
QString selectedFile = selectedFiles.at(0); QString selectedFile = selectedFiles.at(0);
bool isAutoExt = false;
if (selectedFile.right(5) == ".auto")
{
isAutoExt = true;
QString dirPath = QFileInfo(selectedFile).dir().path();
QString stockFileName = sgdFileInfo.fileName();
selectedFile = dirPath % "/" % stockFileName;
}
else if (selectedFile.right(4) == ".rem")
{
selectedFile.remove(selectedFile.length() - 4, 4);
}
if (QFile::exists(selectedFile)) if (QFile::exists(selectedFile))
{ {
if (QMessageBox::Yes == QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)) if (QMessageBox::Yes == QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))
{ {
if (!QFile::remove(selectedFile)) if (!QFile::remove(selectedFile))
{ {
QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Failed to overwrite %1 with current Snapmatic picture").arg("\""+selectedFile+"\"")); QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Failed to overwrite %1 with current Snapmatic picture").arg("\""+selectedFile+"\""));
goto fileDialogPreSave; //Work? goto fileDialogPreSave; //Work?
} }
} }
@ -259,47 +273,35 @@ fileDialogPreSave: //Work?
if (selectedFile.right(4) == ".g5e") if (selectedFile.right(4) == ".g5e")
{ {
bool isExported = picture->exportPicture(selectedFile, "G5E"); bool isExported = picture->exportPicture(selectedFile, SnapmaticFormat::G5E_Format);
if (!isExported) if (!isExported)
{ {
QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture")); QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave; //Work? goto fileDialogPreSave; //Work?
} }
} }
else else
{ {
bool isAutoExt = false; bool isCopied = picture->exportPicture(selectedFile, SnapmaticFormat::PGTA_Format);
if (selectedFile.right(5) == ".auto")
{
isAutoExt = true;
QString dirPath = QFileInfo(selectedFile).dir().path();
QString stockFileName = sgdFileInfo.fileName();
selectedFile = dirPath + "/" + stockFileName;
}
else if (selectedFile.right(4) == ".rem")
{
selectedFile.remove(".rem");
}
bool isCopied = picture->exportPicture(selectedFile, "PGTA");
if (!isCopied) if (!isCopied)
{ {
QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture")); QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave; //Work? goto fileDialogPreSave; //Work?
} }
else else
{ {
if (isAutoExt) QMessageBox::information(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Exported Snapmatic to \"%1\" because of using the .auto extension.").arg(selectedFile)); if (isAutoExt) QMessageBox::information(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Exported Snapmatic to \"%1\" because of using the .auto extension.").arg(selectedFile));
} }
} }
} }
else else
{ {
QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("No valid file is selected")); QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("No valid file is selected"));
goto fileDialogPreSave; //Work? goto fileDialogPreSave; //Work?
} }
} }
settings.setValue(parent->objectName() + "+Geometry", fileDialog.saveGeometry()); settings.setValue(parent->objectName() % "+Geometry", fileDialog.saveGeometry());
settings.setValue("Directory", fileDialog.directory().absolutePath()); settings.setValue("Directory", fileDialog.directory().absolutePath());
settings.endGroup(); settings.endGroup();
} }

View File

@ -19,6 +19,9 @@
#include "ProfileDatabase.h" #include "ProfileDatabase.h"
#include "StandardPaths.h" #include "StandardPaths.h"
#include "config.h" #include "config.h"
#include <QStringBuilder>
#include <QMutexLocker>
#include <QDebug>
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
@ -28,7 +31,7 @@ ProfileDatabase::ProfileDatabase(QObject *parent) : QObject(parent)
dir.mkpath(StandardPaths::dataLocation()); dir.mkpath(StandardPaths::dataLocation());
dir.setPath(StandardPaths::dataLocation()); dir.setPath(StandardPaths::dataLocation());
QString dirPath = dir.absolutePath(); QString dirPath = dir.absolutePath();
QString defaultConfPath = dirPath + QDir::separator() + "players.ini"; QString defaultConfPath = dirPath % QDir::separator() % "players.ini";
QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
confPathSettings.beginGroup("Database"); confPathSettings.beginGroup("Database");
@ -47,15 +50,27 @@ ProfileDatabase::~ProfileDatabase()
QStringList ProfileDatabase::getPlayers() QStringList ProfileDatabase::getPlayers()
{ {
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "getPlayers";
#endif
return profileDB->childKeys(); return profileDB->childKeys();
} }
QString ProfileDatabase::getPlayerName(int playerID) QString ProfileDatabase::getPlayerName(int playerID)
{ {
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "getPlayerName" << playerID;
#endif
return profileDB->value(QString::number(playerID), playerID).toString(); return profileDB->value(QString::number(playerID), playerID).toString();
} }
void ProfileDatabase::setPlayerName(int playerID, QString playerName) void ProfileDatabase::setPlayerName(int playerID, QString playerName)
{ {
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "setPlayerName" << playerID << playerName;
#endif
profileDB->setValue(QString::number(playerID), playerName); profileDB->setValue(QString::number(playerID), playerName);
} }

View File

@ -21,6 +21,7 @@
#include <QSettings> #include <QSettings>
#include <QObject> #include <QObject>
#include <QMutex>
#include <QMap> #include <QMap>
class ProfileDatabase : public QObject class ProfileDatabase : public QObject
@ -33,6 +34,7 @@ public:
~ProfileDatabase(); ~ProfileDatabase();
private: private:
mutable QMutex mutex;
QSettings *profileDB; QSettings *profileDB;
public slots: public slots:

View File

@ -38,6 +38,7 @@
#include <QPushButton> #include <QPushButton>
#include <QSpacerItem> #include <QSpacerItem>
#include <QMessageBox> #include <QMessageBox>
#include <QMouseEvent>
#include <QFileDialog> #include <QFileDialog>
#include <QEventLoop> #include <QEventLoop>
#include <QScrollBar> #include <QScrollBar>
@ -64,13 +65,14 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
enabledPicStr = tr("Enabled pictures: %1 of %2"); enabledPicStr = tr("Enabled pictures: %1 of %2");
selectedWidgts = 0; selectedWidgts = 0;
profileFolder = ""; profileFolder = "";
profileLoader = 0; contextMenuOpened = false;
saSpacerItem = 0; isProfileLoaded = false;
previousWidget = nullptr;
profileLoader = nullptr;
saSpacerItem = nullptr;
QPalette palette; updatePalette();
QColor baseColor = palette.base().color(); ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER));
ui->labVersion->setText(ui->labVersion->text().arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER));
ui->saProfile->setStyleSheet(QString("QWidget#saProfileContent{background-color: rgb(%1, %2, %3)}").arg(QString::number(baseColor.red()),QString::number(baseColor.green()),QString::number(baseColor.blue())));
ui->saProfileContent->setFilesMode(true); ui->saProfileContent->setFilesMode(true);
if (QIcon::hasThemeIcon("dialog-close")) if (QIcon::hasThemeIcon("dialog-close"))
@ -87,6 +89,9 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
ui->hlButtons->setSpacing(6 * screenRatio); ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 15 * screenRatio, 15 * screenRatio, 17 * screenRatio); ui->hlButtons->setContentsMargins(9 * screenRatio, 15 * screenRatio, 15 * screenRatio, 17 * screenRatio);
#endif #endif
setMouseTracking(true);
installEventFilter(this);
} }
ProfileInterface::~ProfileInterface() ProfileInterface::~ProfileInterface()
@ -94,6 +99,8 @@ ProfileInterface::~ProfileInterface()
foreach(ProfileWidget *widget, widgets.keys()) foreach(ProfileWidget *widget, widgets.keys())
{ {
widgets.remove(widget); widgets.remove(widget);
widget->removeEventFilter(this);
widget->disconnect();
delete widget; delete widget;
} }
foreach(SavegameData *savegame, savegames) foreach(SavegameData *savegame, savegames)
@ -138,6 +145,8 @@ void ProfileInterface::savegameLoaded(SavegameData *savegame, QString savegamePa
SavegameWidget *sgdWidget = new SavegameWidget(this); SavegameWidget *sgdWidget = new SavegameWidget(this);
sgdWidget->setSavegameData(savegame, savegamePath); sgdWidget->setSavegameData(savegame, savegamePath);
sgdWidget->setContentMode(contentMode); sgdWidget->setContentMode(contentMode);
sgdWidget->setMouseTracking(true);
sgdWidget->installEventFilter(this);
widgets[sgdWidget] = "SGD" % QFileInfo(savegamePath).fileName(); widgets[sgdWidget] = "SGD" % QFileInfo(savegamePath).fileName();
savegames += savegame; savegames += savegame;
if (selectedWidgts != 0 || contentMode == 2) { sgdWidget->setSelectionMode(true); } if (selectedWidgts != 0 || contentMode == 2) { sgdWidget->setSelectionMode(true); }
@ -160,6 +169,8 @@ void ProfileInterface::pictureLoaded(SnapmaticPicture *picture, bool inserted)
SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, crewDB, threadDB, this); SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, crewDB, threadDB, this);
picWidget->setSnapmaticPicture(picture); picWidget->setSnapmaticPicture(picture);
picWidget->setContentMode(contentMode); picWidget->setContentMode(contentMode);
picWidget->setMouseTracking(true);
picWidget->installEventFilter(this);
widgets[picWidget] = "PIC" % picture->getPictureSortStr(); widgets[picWidget] = "PIC" % picture->getPictureSortStr();
pictures += picture; pictures += picture;
if (selectedWidgts != 0 || contentMode == 2) { picWidget->setSelectionMode(true); } if (selectedWidgts != 0 || contentMode == 2) { picWidget->setSelectionMode(true); }
@ -183,7 +194,7 @@ void ProfileInterface::loadingProgress(int value, int maximum)
void ProfileInterface::insertSnapmaticIPI(QWidget *widget) void ProfileInterface::insertSnapmaticIPI(QWidget *widget)
{ {
ProfileWidget *proWidget = (ProfileWidget*)widget; ProfileWidget *proWidget = qobject_cast<ProfileWidget*>(widget);
if (widgets.contains(proWidget)) if (widgets.contains(proWidget))
{ {
QString widgetKey = widgets[proWidget]; QString widgetKey = widgets[proWidget];
@ -204,7 +215,7 @@ void ProfileInterface::insertSnapmaticIPI(QWidget *widget)
void ProfileInterface::insertSavegameIPI(QWidget *widget) void ProfileInterface::insertSavegameIPI(QWidget *widget)
{ {
ProfileWidget *proWidget = (ProfileWidget*)widget; ProfileWidget *proWidget = qobject_cast<ProfileWidget*>(widget);
if (widgets.contains(proWidget)) if (widgets.contains(proWidget))
{ {
QString widgetKey = widgets[proWidget]; QString widgetKey = widgets[proWidget];
@ -221,8 +232,8 @@ void ProfileInterface::insertSavegameIPI(QWidget *widget)
void ProfileInterface::dialogNextPictureRequested(QWidget *dialog) void ProfileInterface::dialogNextPictureRequested(QWidget *dialog)
{ {
PictureDialog *picDialog = (PictureDialog*)dialog; PictureDialog *picDialog = qobject_cast<PictureDialog*>(dialog);
ProfileWidget *proWidget = (ProfileWidget*)sender(); ProfileWidget *proWidget = qobject_cast<ProfileWidget*>(sender());
if (widgets.contains(proWidget)) if (widgets.contains(proWidget))
{ {
QString widgetKey = widgets[proWidget]; QString widgetKey = widgets[proWidget];
@ -256,8 +267,8 @@ void ProfileInterface::dialogNextPictureRequested(QWidget *dialog)
void ProfileInterface::dialogPreviousPictureRequested(QWidget *dialog) void ProfileInterface::dialogPreviousPictureRequested(QWidget *dialog)
{ {
PictureDialog *picDialog = (PictureDialog*)dialog; PictureDialog *picDialog = qobject_cast<PictureDialog*>(dialog);
ProfileWidget *proWidget = (ProfileWidget*)sender(); ProfileWidget *proWidget = qobject_cast<ProfileWidget*>(sender());
if (widgets.contains(proWidget)) if (widgets.contains(proWidget))
{ {
QString widgetKey = widgets[proWidget]; QString widgetKey = widgets[proWidget];
@ -324,12 +335,13 @@ void ProfileInterface::profileLoaded_p()
ui->swProfile->setCurrentWidget(ui->pageProfile); ui->swProfile->setCurrentWidget(ui->pageProfile);
ui->cmdCloseProfile->setEnabled(true); ui->cmdCloseProfile->setEnabled(true);
ui->cmdImport->setEnabled(true); ui->cmdImport->setEnabled(true);
isProfileLoaded = true;
emit profileLoaded(); emit profileLoaded();
} }
void ProfileInterface::savegameDeleted_event() void ProfileInterface::savegameDeleted_event()
{ {
savegameDeleted((SavegameWidget*)sender(), true); savegameDeleted(qobject_cast<SavegameWidget*>(sender()), true);
} }
void ProfileInterface::savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteEmited) void ProfileInterface::savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteEmited)
@ -338,13 +350,21 @@ void ProfileInterface::savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteE
if (sgdWidget->isSelected()) { sgdWidget->setSelected(false); } if (sgdWidget->isSelected()) { sgdWidget->setSelected(false); }
widgets.remove(sgdWidget); widgets.remove(sgdWidget);
sgdWidget->removeEventFilter(this);
if (sgdWidget == previousWidget)
{
previousWidget = nullptr;
}
// Deleting when the widget did send a event cause a crash // Deleting when the widget did send a event cause a crash
if (isRemoteEmited) if (isRemoteEmited)
{ {
sgdWidget->disconnect();
sgdWidget->deleteLater(); sgdWidget->deleteLater();
} }
else else
{ {
sgdWidget->disconnect();
delete sgdWidget; delete sgdWidget;
} }
@ -354,7 +374,7 @@ void ProfileInterface::savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteE
void ProfileInterface::pictureDeleted_event() void ProfileInterface::pictureDeleted_event()
{ {
pictureDeleted((SnapmaticWidget*)sender(), true); pictureDeleted(qobject_cast<SnapmaticWidget*>(sender()), true);
} }
void ProfileInterface::pictureDeleted(SnapmaticWidget *picWidget, bool isRemoteEmited) void ProfileInterface::pictureDeleted(SnapmaticWidget *picWidget, bool isRemoteEmited)
@ -363,13 +383,21 @@ void ProfileInterface::pictureDeleted(SnapmaticWidget *picWidget, bool isRemoteE
if (picWidget->isSelected()) { picWidget->setSelected(false); } if (picWidget->isSelected()) { picWidget->setSelected(false); }
widgets.remove(picWidget); widgets.remove(picWidget);
picWidget->removeEventFilter(this);
if (picWidget == previousWidget)
{
previousWidget = nullptr;
}
// Deleting when the widget did send a event cause a crash // Deleting when the widget did send a event cause a crash
if (isRemoteEmited) if (isRemoteEmited)
{ {
picWidget->disconnect();
picWidget->deleteLater(); picWidget->deleteLater();
} }
else else
{ {
picWidget->disconnect();
delete picWidget; delete picWidget;
} }
@ -398,12 +426,24 @@ fileDialogPreOpen: //Work?
fileDialog.setWindowTitle(tr("Import...")); fileDialog.setWindowTitle(tr("Import..."));
fileDialog.setLabelText(QFileDialog::Accept, tr("Import")); fileDialog.setLabelText(QFileDialog::Accept, tr("Import"));
// Getting readable Image formats
QString imageFormatsStr = " ";
foreach(const QByteArray &imageFormat, QImageReader::supportedImageFormats())
{
imageFormatsStr += QString("*.") % QString::fromUtf8(imageFormat).toLower() % " ";
}
QString importableFormatsStr = QString("*.g5e SGTA* PGTA*");
if (!imageFormatsStr.trimmed().isEmpty())
{
importableFormatsStr = QString("*.g5e%1SGTA* PGTA*").arg(imageFormatsStr);
}
QStringList filters; QStringList filters;
filters << tr("Importable files (*.g5e *.jpg *.png SGTA* PGTA*)"); filters << tr("Importable files (%1)").arg(importableFormatsStr);
filters << tr("GTA V Export (*.g5e)"); filters << tr("GTA V Export (*.g5e)");
filters << tr("Savegames files (SGTA*)"); filters << tr("Savegames files (SGTA*)");
filters << tr("Snapmatic pictures (PGTA*)"); filters << tr("Snapmatic pictures (PGTA*)");
filters << tr("All image files (*.jpg *.png)"); filters << tr("All image files (%1)").arg(imageFormatsStr.trimmed());
filters << tr("All files (**)"); filters << tr("All files (**)");
fileDialog.setNameFilters(filters); fileDialog.setNameFilters(filters);
@ -520,7 +560,7 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
return false; return false;
} }
} }
else if(selectedFileName.right(4) == ".jpg" || selectedFileName.right(4) == ".png") else if(isSupportedImageFile(selectedFileName))
{ {
SnapmaticPicture *picture = new SnapmaticPicture(":/template/template.g5e"); SnapmaticPicture *picture = new SnapmaticPicture(":/template/template.g5e");
if (picture->readingPicture(true, false, true, false)) if (picture->readingPicture(true, false, true, false))
@ -631,6 +671,7 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
snapmaticImageReader.setDevice(&snapmaticFile); snapmaticImageReader.setDevice(&snapmaticFile);
if (!snapmaticImageReader.read(&snapmaticImage)) if (!snapmaticImageReader.read(&snapmaticImage))
{ {
QMessageBox::warning(this, tr("Import"), tr("Can't import %1 because file can't be parsed properly").arg("\""+selectedFileName+"\""));
delete picture; delete picture;
return false; return false;
} }
@ -640,7 +681,7 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
importDialog->setModal(true); importDialog->setModal(true);
importDialog->show(); importDialog->show();
importDialog->exec(); importDialog->exec();
if (importDialog->isDoImport()) if (importDialog->isImportAgreed())
{ {
if (picture->setImage(importDialog->image())) if (picture->setImage(importDialog->image()))
{ {
@ -705,9 +746,13 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
} }
else else
{ {
delete savegame; #ifdef GTA5SYNC_DEBUG
qDebug() << "ImportError SnapmaticPicture" << picture->getLastStep();
qDebug() << "ImportError SavegameData" << savegame->getLastStep();
#endif
delete picture; delete picture;
if (notMultiple) QMessageBox::warning(this, tr("Import"), tr("Can't import %1 because of not valid file format").arg("\""+selectedFileName+"\"")); delete savegame;
if (notMultiple) QMessageBox::warning(this, tr("Import"), tr("Can't import %1 because file format can't be detected").arg("\""+selectedFileName+"\""));
return false; return false;
} }
} }
@ -738,7 +783,7 @@ bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, bool wa
if (warn) QMessageBox::warning(this, tr("Import"), tr("Failed to import the Snapmatic picture, the picture is already in the game")); if (warn) QMessageBox::warning(this, tr("Import"), tr("Failed to import the Snapmatic picture, the picture is already in the game"));
return false; return false;
} }
else if (picture->exportPicture(profileFolder % QDir::separator() % adjustedFileName, "PGTA")) else if (picture->exportPicture(profileFolder % QDir::separator() % adjustedFileName, SnapmaticFormat::PGTA_Format))
{ {
picture->setPicFilePath(profileFolder % QDir::separator() % adjustedFileName); picture->setPicFilePath(profileFolder % QDir::separator() % adjustedFileName);
pictureLoaded(picture, true); pictureLoaded(picture, true);
@ -914,8 +959,10 @@ void ProfileInterface::exportSelected()
} }
else else
{ {
pictureExportEnabled = true; // Don't export anymore when any Cancel button got clicked
pictureCopyEnabled = true; settings.endGroup();
settings.endGroup();
return;
} }
} }
@ -934,7 +981,7 @@ void ProfileInterface::exportSelected()
QProgressDialog pbDialog(this); QProgressDialog pbDialog(this);
pbDialog.setWindowFlags(pbDialog.windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowCloseButtonHint); pbDialog.setWindowFlags(pbDialog.windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowCloseButtonHint);
pbDialog.setWindowTitle(tr("Export selected...")); pbDialog.setWindowTitle(tr("Export selected..."));
pbDialog.setLabelText(tr("Initializing export...")); pbDialog.setLabelText(tr("Initialising export..."));
pbDialog.setRange(0, exportCount); pbDialog.setRange(0, exportCount);
QList<QPushButton*> pbBtn = pbDialog.findChildren<QPushButton*>(); QList<QPushButton*> pbBtn = pbDialog.findChildren<QPushButton*>();
@ -1003,7 +1050,7 @@ void ProfileInterface::deleteSelected()
{ {
if (widget->getWidgetType() == "SnapmaticWidget") if (widget->getWidgetType() == "SnapmaticWidget")
{ {
SnapmaticWidget *picWidget = (SnapmaticWidget*)widget; SnapmaticWidget *picWidget = qobject_cast<SnapmaticWidget*>(widget);
if (picWidget->getPicture()->deletePicFile()) if (picWidget->getPicture()->deletePicFile())
{ {
pictureDeleted(picWidget); pictureDeleted(picWidget);
@ -1011,7 +1058,7 @@ void ProfileInterface::deleteSelected()
} }
else if (widget->getWidgetType() == "SavegameWidget") else if (widget->getWidgetType() == "SavegameWidget")
{ {
SavegameWidget *sgdWidget = (SavegameWidget*)widget; SavegameWidget *sgdWidget = qobject_cast<SavegameWidget*>(widget);
SavegameData *savegame = sgdWidget->getSavegame(); SavegameData *savegame = sgdWidget->getSavegame();
QString fileName = savegame->getSavegameFileName(); QString fileName = savegame->getSavegameFileName();
if (!QFile::exists(fileName) || QFile::remove(fileName)) if (!QFile::exists(fileName) || QFile::remove(fileName))
@ -1038,9 +1085,15 @@ void ProfileInterface::importFiles()
on_cmdImport_clicked(); on_cmdImport_clicked();
} }
void ProfileInterface::settingsApplied(int _contentMode, QString language) void ProfileInterface::settingsApplied(int _contentMode, QString _language)
{ {
Q_UNUSED(language) bool translationUpdated = false;
if (language != _language)
{
retranslateUi();
language = _language;
translationUpdated = true;
}
contentMode = _contentMode; contentMode = _contentMode;
if (contentMode == 2) if (contentMode == 2)
@ -1049,6 +1102,7 @@ void ProfileInterface::settingsApplied(int _contentMode, QString language)
{ {
widget->setSelectionMode(true); widget->setSelectionMode(true);
widget->setContentMode(contentMode); widget->setContentMode(contentMode);
if (translationUpdated) widget->retranslate();
} }
} }
else else
@ -1060,6 +1114,7 @@ void ProfileInterface::settingsApplied(int _contentMode, QString language)
widget->setSelectionMode(false); widget->setSelectionMode(false);
} }
widget->setContentMode(contentMode); widget->setContentMode(contentMode);
if (translationUpdated) widget->retranslate();
} }
} }
} }
@ -1073,7 +1128,7 @@ void ProfileInterface::enableSelected()
{ {
if (widget->getWidgetType() == "SnapmaticWidget") if (widget->getWidgetType() == "SnapmaticWidget")
{ {
SnapmaticWidget *snapmaticWidget = (SnapmaticWidget*)widget; SnapmaticWidget *snapmaticWidget = qobject_cast<SnapmaticWidget*>(widget);
if (!snapmaticWidget->makePictureVisible()) if (!snapmaticWidget->makePictureVisible())
{ {
fails++; fails++;
@ -1092,7 +1147,7 @@ void ProfileInterface::disableSelected()
{ {
if (widget->getWidgetType() == "SnapmaticWidget") if (widget->getWidgetType() == "SnapmaticWidget")
{ {
SnapmaticWidget *snapmaticWidget = (SnapmaticWidget*)widget; SnapmaticWidget *snapmaticWidget = qobject_cast<SnapmaticWidget*>(widget);
if (!snapmaticWidget->makePictureHidden()) if (!snapmaticWidget->makePictureHidden())
{ {
fails++; fails++;
@ -1109,7 +1164,16 @@ int ProfileInterface::selectedWidgets()
void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev) void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev)
{ {
SnapmaticWidget *picWidget = (SnapmaticWidget*)sender(); SnapmaticWidget *picWidget = qobject_cast<SnapmaticWidget*>(sender());
if (picWidget != previousWidget)
{
if (previousWidget != nullptr)
{
previousWidget->setStyleSheet(QLatin1String(""));
}
picWidget->setStyleSheet(QString("QFrame#SnapmaticFrame{background-color: rgb(%1, %2, %3)}QLabel#labPicStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
previousWidget = picWidget;
}
QMenu contextMenu(picWidget); QMenu contextMenu(picWidget);
QMenu editMenu(SnapmaticWidget::tr("Edi&t"), picWidget); QMenu editMenu(SnapmaticWidget::tr("Edi&t"), picWidget);
if (picWidget->isHidden()) if (picWidget->isHidden())
@ -1122,8 +1186,8 @@ void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev)
} }
editMenu.addAction(SnapmaticWidget::tr("&Edit Properties..."), picWidget, SLOT(editSnapmaticProperties())); editMenu.addAction(SnapmaticWidget::tr("&Edit Properties..."), picWidget, SLOT(editSnapmaticProperties()));
QMenu exportMenu(SnapmaticWidget::tr("&Export"), this); QMenu exportMenu(SnapmaticWidget::tr("&Export"), this);
exportMenu.addAction(SnapmaticWidget::tr("Export as &JPG picture..."), picWidget, SLOT(on_cmdExport_clicked())); exportMenu.addAction(SnapmaticWidget::tr("Export as &Picture..."), picWidget, SLOT(on_cmdExport_clicked()));
exportMenu.addAction(SnapmaticWidget::tr("Export as &GTA Snapmatic..."), picWidget, SLOT(on_cmdCopy_clicked())); exportMenu.addAction(SnapmaticWidget::tr("Export as &Snapmatic..."), picWidget, SLOT(on_cmdCopy_clicked()));
contextMenu.addAction(SnapmaticWidget::tr("&View"), picWidget, SLOT(on_cmdView_clicked())); contextMenu.addAction(SnapmaticWidget::tr("&View"), picWidget, SLOT(on_cmdView_clicked()));
contextMenu.addMenu(&editMenu); contextMenu.addMenu(&editMenu);
contextMenu.addMenu(&exportMenu); contextMenu.addMenu(&exportMenu);
@ -1139,12 +1203,24 @@ void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev)
{ {
contextMenu.addAction(SnapmaticWidget::tr("&Deselect All"), picWidget, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); contextMenu.addAction(SnapmaticWidget::tr("&Deselect All"), picWidget, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D"));
} }
contextMenuOpened = true;
contextMenu.exec(ev->globalPos()); contextMenu.exec(ev->globalPos());
contextMenuOpened = false;
hoverProfileWidgetCheck();
} }
void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev) void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev)
{ {
SavegameWidget *sgdWidget = (SavegameWidget*)sender(); SavegameWidget *sgdWidget = qobject_cast<SavegameWidget*>(sender());
if (sgdWidget != previousWidget)
{
if (previousWidget != nullptr)
{
previousWidget->setStyleSheet(QLatin1String(""));
}
sgdWidget->setStyleSheet(QString("QFrame#SavegameFrame{background-color: rgb(%1, %2, %3)}QLabel#labSavegameStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
previousWidget = sgdWidget;
}
QMenu contextMenu(sgdWidget); QMenu contextMenu(sgdWidget);
contextMenu.addAction(SavegameWidget::tr("&View"), sgdWidget, SLOT(on_cmdView_clicked())); contextMenu.addAction(SavegameWidget::tr("&View"), sgdWidget, SLOT(on_cmdView_clicked()));
contextMenu.addAction(SavegameWidget::tr("&Export"), sgdWidget, SLOT(on_cmdCopy_clicked())); contextMenu.addAction(SavegameWidget::tr("&Export"), sgdWidget, SLOT(on_cmdCopy_clicked()));
@ -1160,7 +1236,10 @@ void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev)
{ {
contextMenu.addAction(SavegameWidget::tr("&Deselect All"), sgdWidget, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); contextMenu.addAction(SavegameWidget::tr("&Deselect All"), sgdWidget, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D"));
} }
contextMenuOpened = true;
contextMenu.exec(ev->globalPos()); contextMenu.exec(ev->globalPos());
contextMenuOpened = false;
hoverProfileWidgetCheck();
} }
void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData) void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
@ -1187,3 +1266,200 @@ void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
importFilesProgress(pathList); importFilesProgress(pathList);
} }
} }
void ProfileInterface::retranslateUi()
{
ui->retranslateUi(this);
ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER));
}
bool ProfileInterface::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::MouseMove)
{
if ((watched->objectName() == "SavegameWidget" || watched->objectName() == "SnapmaticWidget") && isProfileLoaded)
{
ProfileWidget *pWidget = qobject_cast<ProfileWidget*>(watched);
if (pWidget->underMouse())
{
bool styleSheetChanged = false;
if (pWidget->getWidgetType() == "SnapmaticWidget")
{
if (pWidget != previousWidget)
{
pWidget->setStyleSheet(QString("QFrame#SnapmaticFrame{background-color: rgb(%1, %2, %3)}QLabel#labPicStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
styleSheetChanged = true;
}
}
else if (pWidget->getWidgetType() == "SavegameWidget")
{
if (pWidget != previousWidget)
{
pWidget->setStyleSheet(QString("QFrame#SavegameFrame{background-color: rgb(%1, %2, %3)}QLabel#labSavegameStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
styleSheetChanged = true;
}
}
if (styleSheetChanged)
{
if (previousWidget != nullptr)
{
previousWidget->setStyleSheet(QLatin1String(""));
}
previousWidget = pWidget;
}
}
return true;
}
}
else if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::WindowActivate)
{
if ((watched->objectName() == "SavegameWidget" || watched->objectName() == "SnapmaticWidget") && isProfileLoaded)
{
ProfileWidget *pWidget = nullptr;
foreach(ProfileWidget *widget, widgets.keys())
{
QPoint mousePos = widget->mapFromGlobal(QCursor::pos());
if (widget->rect().contains(mousePos))
{
pWidget = widget;
break;
}
}
if (pWidget != nullptr)
{
bool styleSheetChanged = false;
if (pWidget->getWidgetType() == "SnapmaticWidget")
{
if (pWidget != previousWidget)
{
pWidget->setStyleSheet(QString("QFrame#SnapmaticFrame{background-color: rgb(%1, %2, %3)}QLabel#labPicStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
styleSheetChanged = true;
}
}
else if (pWidget->getWidgetType() == "SavegameWidget")
{
if (pWidget != previousWidget)
{
pWidget->setStyleSheet(QString("QFrame#SavegameFrame{background-color: rgb(%1, %2, %3)}QLabel#labSavegameStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
styleSheetChanged = true;
}
}
if (styleSheetChanged)
{
if (previousWidget != nullptr)
{
previousWidget->setStyleSheet(QLatin1String(""));
}
previousWidget = pWidget;
}
}
}
}
else if (event->type() == QEvent::WindowDeactivate && isProfileLoaded)
{
if (previousWidget != nullptr)
{
previousWidget->setStyleSheet(QLatin1String(""));
previousWidget = nullptr;
}
}
else if (event->type() == QEvent::Leave && isProfileLoaded && !contextMenuOpened)
{
if (watched->objectName() == "SavegameWidget" || watched->objectName() == "SnapmaticWidget")
{
ProfileWidget *pWidget = qobject_cast<ProfileWidget*>(watched);
QPoint mousePos = pWidget->mapFromGlobal(QCursor::pos());
if (!pWidget->geometry().contains(mousePos))
{
if (previousWidget != nullptr)
{
previousWidget->setStyleSheet(QLatin1String(""));
previousWidget = nullptr;
}
}
}
}
return false;
}
void ProfileInterface::hoverProfileWidgetCheck()
{
ProfileWidget *pWidget = nullptr;
foreach(ProfileWidget *widget, widgets.keys())
{
if (widget->underMouse())
{
pWidget = widget;
break;
}
}
if (pWidget != nullptr)
{
bool styleSheetChanged = false;
if (pWidget->getWidgetType() == "SnapmaticWidget")
{
if (pWidget != previousWidget)
{
pWidget->setStyleSheet(QString("QFrame#SnapmaticFrame{background-color: rgb(%1, %2, %3)}QLabel#labPicStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
styleSheetChanged = true;
}
}
else if (pWidget->getWidgetType() == "SavegameWidget")
{
if (pWidget != previousWidget)
{
pWidget->setStyleSheet(QString("QFrame#SavegameFrame{background-color: rgb(%1, %2, %3)}QLabel#labSavegameStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
styleSheetChanged = true;
}
}
if (styleSheetChanged)
{
if (previousWidget != nullptr)
{
previousWidget->setStyleSheet(QLatin1String(""));
}
previousWidget = pWidget;
}
}
else
{
if (previousWidget != nullptr)
{
previousWidget->setStyleSheet(QLatin1String(""));
previousWidget = nullptr;
}
}
}
void ProfileInterface::updatePalette()
{
QPalette palette;
QColor baseColor = palette.base().color();
highlightBackColor = palette.highlight().color();
highlightTextColor = palette.highlightedText().color();
ui->saProfile->setStyleSheet(QString("QWidget#saProfileContent{background-color: rgb(%1, %2, %3)}").arg(QString::number(baseColor.red()), QString::number(baseColor.green()), QString::number(baseColor.blue())));
if (previousWidget != nullptr)
{
if (previousWidget->getWidgetType() == "SnapmaticWidget")
{
previousWidget->setStyleSheet(QString("QFrame#SnapmaticFrame{background-color: rgb(%1, %2, %3)}QLabel#labPicStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
}
else if (previousWidget->getWidgetType() == "SavegameWidget")
{
previousWidget->setStyleSheet(QString("QFrame#SavegameFrame{background-color: rgb(%1, %2, %3)}QLabel#labSavegameStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
}
}
}
bool ProfileInterface::isSupportedImageFile(QString selectedFileName)
{
foreach(const QByteArray &imageFormat, QImageReader::supportedImageFormats())
{
QString imageFormatStr = QString(".") % QString::fromUtf8(imageFormat).toLower();
if (selectedFileName.length() >= imageFormatStr.length() && selectedFileName.toLower().right(imageFormatStr.length()) == imageFormatStr)
{
return true;
}
}
return false;
}

View File

@ -50,15 +50,18 @@ public:
void disableSelected(); void disableSelected();
void enableSelected(); void enableSelected();
int selectedWidgets(); int selectedWidgets();
void retranslateUi();
~ProfileInterface(); ~ProfileInterface();
public slots: public slots:
void contextMenuTriggeredPIC(QContextMenuEvent* ev); void contextMenuTriggeredPIC(QContextMenuEvent* ev);
void contextMenuTriggeredSGD(QContextMenuEvent* ev); void contextMenuTriggeredSGD(QContextMenuEvent* ev);
void hoverProfileWidgetCheck();
void selectAllWidgets(); void selectAllWidgets();
void deselectAllWidgets(); void deselectAllWidgets();
void exportSelected(); void exportSelected();
void deleteSelected(); void deleteSelected();
void updatePalette();
void importFiles(); void importFiles();
private slots: private slots:
@ -76,6 +79,9 @@ private slots:
void dialogPreviousPictureRequested(QWidget *dialog); void dialogPreviousPictureRequested(QWidget *dialog);
void on_saProfileContent_dropped(const QMimeData *mimeData); void on_saProfileContent_dropped(const QMimeData *mimeData);
protected:
bool eventFilter(QObject *watched, QEvent *event);
private: private:
ProfileDatabase *profileDB; ProfileDatabase *profileDB;
CrewDatabase *crewDB; CrewDatabase *crewDB;
@ -83,17 +89,24 @@ private:
Ui::ProfileInterface *ui; Ui::ProfileInterface *ui;
ProfileLoader *profileLoader; ProfileLoader *profileLoader;
ProfileWidget *previousWidget;
QList<SavegameData*> savegames; QList<SavegameData*> savegames;
QList<SnapmaticPicture*> pictures; QList<SnapmaticPicture*> pictures;
QMap<ProfileWidget*,QString> widgets; QMap<ProfileWidget*,QString> widgets;
QSpacerItem *saSpacerItem; QSpacerItem *saSpacerItem;
QColor highlightBackColor;
QColor highlightTextColor;
QString enabledPicStr; QString enabledPicStr;
QString profileFolder; QString profileFolder;
QString profileName; QString profileName;
QString loadingStr; QString loadingStr;
QString language;
bool contextMenuOpened;
bool isProfileLoaded;
int selectedWidgts; int selectedWidgts;
int contentMode; int contentMode;
bool isSupportedImageFile(QString selectedFileName);
bool importFile(QString selectedFile, bool notMultiple); bool importFile(QString selectedFile, bool notMultiple);
void importFilesProgress(QStringList selectedFiles); void importFilesProgress(QStringList selectedFiles);
bool importSnapmaticPicture(SnapmaticPicture *picture, bool warn = true); bool importSnapmaticPicture(SnapmaticPicture *picture, bool warn = true);

View File

@ -195,7 +195,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Import exported file</string> <string>Import file</string>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Import...</string> <string>&amp;Import...</string>

View File

@ -20,6 +20,7 @@
#include "SnapmaticPicture.h" #include "SnapmaticPicture.h"
#include "SavegameData.h" #include "SavegameData.h"
#include "CrewDatabase.h" #include "CrewDatabase.h"
#include <QStringBuilder>
#include <QStringList> #include <QStringList>
#include <QString> #include <QString>
#include <QFile> #include <QFile>
@ -43,7 +44,7 @@ void ProfileLoader::run()
QStringList BackupFiles = SavegameFiles.filter(".bak", Qt::CaseInsensitive); QStringList BackupFiles = SavegameFiles.filter(".bak", Qt::CaseInsensitive);
profileDir.setNameFilters(QStringList("PGTA*")); profileDir.setNameFilters(QStringList("PGTA*"));
QStringList SnapmaticPics = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort); QStringList SnapmaticPics = profileDir.entryList(QDir::Files | QDir::NoDot, QDir::NoSort);
BackupFiles.append(SnapmaticPics.filter(".bak", Qt::CaseInsensitive)); BackupFiles += SnapmaticPics.filter(".bak", Qt::CaseInsensitive);
SavegameFiles.removeDuplicates(); SavegameFiles.removeDuplicates();
SnapmaticPics.removeDuplicates(); SnapmaticPics.removeDuplicates();
@ -60,7 +61,7 @@ void ProfileLoader::run()
foreach(const QString &SavegameFile, SavegameFiles) foreach(const QString &SavegameFile, SavegameFiles)
{ {
emit loadingProgress(curFile, maximumV); emit loadingProgress(curFile, maximumV);
QString sgdPath = profileFolder + QDir::separator() + SavegameFile; QString sgdPath = profileFolder % QDir::separator() % SavegameFile;
SavegameData *savegame = new SavegameData(sgdPath); SavegameData *savegame = new SavegameData(sgdPath);
if (savegame->readingSavegame()) if (savegame->readingSavegame())
{ {
@ -71,7 +72,7 @@ void ProfileLoader::run()
foreach(const QString &SnapmaticPic, SnapmaticPics) foreach(const QString &SnapmaticPic, SnapmaticPics)
{ {
emit loadingProgress(curFile, maximumV); emit loadingProgress(curFile, maximumV);
QString picturePath = profileFolder + QDir::separator() + SnapmaticPic; QString picturePath = profileFolder % QDir::separator() % SnapmaticPic;
SnapmaticPicture *picture = new SnapmaticPicture(picturePath); SnapmaticPicture *picture = new SnapmaticPicture(picturePath);
if (picture->readingPicture(true, true, true)) if (picture->readingPicture(true, true, true))
{ {
@ -79,17 +80,19 @@ void ProfileLoader::run()
int crewNumber = picture->getSnapmaticProperties().crewID; int crewNumber = picture->getSnapmaticProperties().crewID;
if (!crewList.contains(crewNumber)) if (!crewList.contains(crewNumber))
{ {
crewList.append(crewNumber); crewList += crewNumber;
} }
} }
curFile++; curFile++;
} }
// adding found crews // adding found crews
crewDB->setAddingCrews(true);
foreach(int crewID, crewList) foreach(int crewID, crewList)
{ {
crewDB->addCrew(crewID); crewDB->addCrew(crewID);
} }
crewDB->setAddingCrews(false);
} }
void ProfileLoader::preloaded() void ProfileLoader::preloaded()

View File

@ -28,6 +28,11 @@ ProfileWidget::~ProfileWidget()
{ {
} }
void ProfileWidget::retranslate()
{
qDebug() << "ProfileWidget::retranslate got used without overwrite";
}
bool ProfileWidget::isSelected() bool ProfileWidget::isSelected()
{ {
qDebug() << "ProfileWidget::isSelected got used without overwrite"; qDebug() << "ProfileWidget::isSelected got used without overwrite";

View File

@ -32,6 +32,7 @@ public:
virtual bool isSelected(); virtual bool isSelected();
virtual QString getWidgetType(); virtual QString getWidgetType();
virtual int getContentMode(); virtual int getContentMode();
virtual void retranslate();
~ProfileWidget(); ~ProfileWidget();
private: private:

View File

@ -18,6 +18,7 @@
#include "StringParser.h" #include "StringParser.h"
#include "SavegameData.h" #include "SavegameData.h"
#include <QStringBuilder>
#include <QTextCodec> #include <QTextCodec>
#include <QByteArray> #include <QByteArray>
#include <QDebug> #include <QDebug>
@ -41,7 +42,7 @@ bool SavegameData::readingSavegame()
QFile *saveFile = new QFile(savegameFileName); QFile *saveFile = new QFile(savegameFileName);
if (!saveFile->open(QFile::ReadOnly)) if (!saveFile->open(QFile::ReadOnly))
{ {
lastStep = "1;/1,OpenFile," + StringParser::convertDrawStringForLog(savegameFileName); lastStep = "1;/1,OpenFile," % StringParser::convertDrawStringForLog(savegameFileName);
saveFile->deleteLater(); saveFile->deleteLater();
delete saveFile; delete saveFile;
return false; return false;
@ -50,7 +51,7 @@ bool SavegameData::readingSavegame()
// Reading Savegame Header // Reading Savegame Header
if (!saveFile->isReadable()) if (!saveFile->isReadable())
{ {
lastStep = "2;/3,ReadingFile," + StringParser::convertDrawStringForLog(savegameFileName) + ",1,NOHEADER"; lastStep = "2;/3,ReadingFile," % StringParser::convertDrawStringForLog(savegameFileName) % ",1,NOHEADER";
saveFile->close(); saveFile->close();
saveFile->deleteLater(); saveFile->deleteLater();
delete saveFile; delete saveFile;

View File

@ -19,12 +19,6 @@
<layout class="QVBoxLayout" name="vlSavegameDialog"> <layout class="QVBoxLayout" name="vlSavegameDialog">
<item> <item>
<widget class="QLabel" name="labSavegameText"> <widget class="QLabel" name="labSavegameText">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;Savegame&lt;/span&gt;&lt;br&gt;&lt;br&gt;%1</string> <string>&lt;span style=&quot; font-weight:600;&quot;&gt;Savegame&lt;/span&gt;&lt;br&gt;&lt;br&gt;%1</string>
</property> </property>
@ -36,6 +30,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="vsSavegame">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<layout class="QHBoxLayout" name="hlButtons"> <layout class="QHBoxLayout" name="hlButtons">
<item> <item>

View File

@ -57,18 +57,14 @@ SavegameWidget::SavegameWidget(QWidget *parent) :
QString exportSavegameStr = tr("Export Savegame..."); QString exportSavegameStr = tr("Export Savegame...");
Q_UNUSED(exportSavegameStr) Q_UNUSED(exportSavegameStr)
QPalette palette;
highlightBackColor = palette.highlight().color();
highlightTextColor = palette.highlightedText().color();
labelAutosaveStr = tr("AUTOSAVE - %1\n%2"); labelAutosaveStr = tr("AUTOSAVE - %1\n%2");
labelSaveStr = tr("SAVE %3 - %1\n%2"); labelSaveStr = tr("SAVE %3 - %1\n%2");
snwgt = parent;
sgdPath = "";
sgdStr = "";
sgdata = 0;
installEventFilter(this); ui->SavegameFrame->setMouseTracking(true);
ui->labSavegamePic->setMouseTracking(true);
ui->labSavegameStr->setMouseTracking(true);
ui->cbSelected->setMouseTracking(true);
sgdata = nullptr;
} }
SavegameWidget::~SavegameWidget() SavegameWidget::~SavegameWidget()
@ -76,32 +72,22 @@ SavegameWidget::~SavegameWidget()
delete ui; delete ui;
} }
bool SavegameWidget::eventFilter(QObject *obj, QEvent *ev)
{
if (obj == this)
{
if (ev->type() == QEvent::Enter)
{
setStyleSheet(QString("QFrame#SavegameFrame{background-color: rgb(%1, %2, %3)}QLabel#labSavegameStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
return true;
}
else if(ev->type() == QEvent::Leave)
{
setStyleSheet("");
return true;
}
}
return false;
}
void SavegameWidget::setSavegameData(SavegameData *savegame, QString savegamePath) void SavegameWidget::setSavegameData(SavegameData *savegame, QString savegamePath)
{ {
// BETA CODE // BETA CODE
QString savegameString = savegame->getSavegameStr();
QString fileName = QFileInfo(savegame->getSavegameFileName()).fileName();
renderString(savegameString, fileName);
sgdStr = savegameString;
sgdPath = savegamePath;
sgdata = savegame;
}
void SavegameWidget::renderString(const QString &savegameString, const QString &fileName)
{
bool validNumber; bool validNumber;
QString savegameName = tr("WRONG FORMAT"); QString savegameName = tr("WRONG FORMAT");
QString savegameDate = tr("WRONG FORMAT"); QString savegameDate = tr("WRONG FORMAT");
QString savegameString = savegame->getSavegameStr();
QString fileName = QFileInfo(savegame->getSavegameFileName()).fileName();
QStringList savegameNDL = QString(savegameString).split(" - "); QStringList savegameNDL = QString(savegameString).split(" - ");
if (savegameNDL.length() >= 2) if (savegameNDL.length() >= 2)
{ {
@ -124,9 +110,15 @@ void SavegameWidget::setSavegameData(SavegameData *savegame, QString savegamePat
{ {
ui->labSavegameStr->setText(labelSaveStr.arg(savegameDate, savegameName, tr("UNKNOWN"))); ui->labSavegameStr->setText(labelSaveStr.arg(savegameDate, savegameName, tr("UNKNOWN")));
} }
sgdStr = savegameString; }
sgdPath = savegamePath;
sgdata = savegame; void SavegameWidget::retranslate()
{
labelAutosaveStr = tr("AUTOSAVE - %1\n%2");
labelSaveStr = tr("SAVE %3 - %1\n%2");
QString fileName = QFileInfo(sgdata->getSavegameFileName()).fileName();
renderString(sgdStr, fileName);
} }
void SavegameWidget::on_cmdCopy_clicked() void SavegameWidget::on_cmdCopy_clicked()
@ -188,7 +180,18 @@ void SavegameWidget::mouseReleaseEvent(QMouseEvent *ev)
{ {
if (getContentMode() == 0 && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) if (getContentMode() == 0 && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{ {
on_cmdView_clicked(); if (ev->modifiers().testFlag(Qt::ShiftModifier))
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
}
else
{
on_cmdView_clicked();
}
}
else if (!ui->cbSelected->isVisible() && getContentMode() == 1 && ev->button() == Qt::LeftButton && ev->modifiers().testFlag(Qt::ShiftModifier))
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
} }
} }
} }

View File

@ -41,6 +41,7 @@ public:
SavegameData* getSavegame(); SavegameData* getSavegame();
QString getWidgetType(); QString getWidgetType();
bool isSelected(); bool isSelected();
void retranslate();
~SavegameWidget(); ~SavegameWidget();
private slots: private slots:
@ -53,7 +54,6 @@ private slots:
void deselectAllWidgets(); void deselectAllWidgets();
protected: protected:
bool eventFilter(QObject *obj, QEvent *ev);
void mouseDoubleClickEvent(QMouseEvent *ev); void mouseDoubleClickEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev); void mouseReleaseEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev); void mousePressEvent(QMouseEvent *ev);
@ -62,13 +62,11 @@ protected:
private: private:
Ui::SavegameWidget *ui; Ui::SavegameWidget *ui;
SavegameData *sgdata; SavegameData *sgdata;
QColor highlightBackColor;
QColor highlightTextColor;
QString labelAutosaveStr; QString labelAutosaveStr;
QString labelSaveStr; QString labelSaveStr;
QString sgdPath; QString sgdPath;
QString sgdStr; QString sgdStr;
QWidget *snwgt; void renderString(const QString &savegameString, const QString &fileName);
signals: signals:
void savegameDeleted(); void savegameDeleted();

View File

@ -35,26 +35,26 @@ QList<QUrl> SidebarGenerator::generateSidebarUrls(QList<QUrl> sidebarUrls)
dir.setPath(StandardPaths::picturesLocation()); dir.setPath(StandardPaths::picturesLocation());
if (dir.exists()) if (dir.exists())
{ {
sidebarUrls << QUrl::fromLocalFile(dir.absolutePath()); sidebarUrls += QUrl::fromLocalFile(dir.absolutePath());
} }
dir.setPath(StandardPaths::documentsLocation()); dir.setPath(StandardPaths::documentsLocation());
if (dir.exists()) if (dir.exists())
{ {
sidebarUrls << QUrl::fromLocalFile(dir.absolutePath()); sidebarUrls += QUrl::fromLocalFile(dir.absolutePath());
} }
bool gameFolderExists; bool gameFolderExists;
QString gameFolder = AppEnv::getGameFolder(&gameFolderExists); QString gameFolder = AppEnv::getGameFolder(&gameFolderExists);
if (gameFolderExists) if (gameFolderExists)
{ {
sidebarUrls << QUrl::fromLocalFile(gameFolder); sidebarUrls += QUrl::fromLocalFile(gameFolder);
} }
dir.setPath(StandardPaths::desktopLocation()); dir.setPath(StandardPaths::desktopLocation());
if (dir.exists()) if (dir.exists())
{ {
sidebarUrls << QUrl::fromLocalFile(dir.absolutePath()); sidebarUrls += QUrl::fromLocalFile(dir.absolutePath());
} }
return sidebarUrls; return sidebarUrls;

View File

@ -310,12 +310,12 @@ void SnapmaticEditor::on_labCrew_linkActivated(const QString &link)
QStringList crewList = crewDB->getCrews(); QStringList crewList = crewDB->getCrews();
if (!crewList.contains(QLatin1String("0"))) if (!crewList.contains(QLatin1String("0")))
{ {
crewList.append(QLatin1String("0")); crewList += QLatin1String("0");
} }
crewList.sort(); crewList.sort();
foreach(const QString &crew, crewList) foreach(const QString &crew, crewList)
{ {
itemList.append(QString("%1 (%2)").arg(crew, returnCrewName(crew.toInt()))); itemList += QString("%1 (%2)").arg(crew, returnCrewName(crew.toInt()));
} }
if (crewList.contains(QString::number(crewID))) if (crewList.contains(QString::number(crewID)))
{ {

View File

@ -68,25 +68,37 @@ SnapmaticPicture::~SnapmaticPicture()
void SnapmaticPicture::reset() void SnapmaticPicture::reset()
{ {
// INIT PIC // INIT PIC
rawPicContent = ""; rawPicContent.clear();
rawPicContent.squeeze();
cachePicture = QImage(); cachePicture = QImage();
picExportFileName = QString();
pictureHead = QString();
pictureStr = QString();
lastStep = QString();
sortStr = QString();
titlStr = QString();
descStr = QString();
// INIT PIC INTS
jpegRawContentSizeE = 0; jpegRawContentSizeE = 0;
jpegRawContentSize = 0; jpegRawContentSize = 0;
picExportFileName = "";
isCustomFormat = 0; // INIT PIC BOOLS
isLoadedInRAM = 0; isCustomFormat = false;
pictureHead = ""; isLoadedInRAM = false;
pictureStr = ""; lowRamMode = false;
lowRamMode = 0; picOk = false;
lastStep = "";
sortStr = "";
titlStr = "";
descStr = "";
picOk = 0;
// INIT JSON // INIT JSON
jsonOk = 0; jsonOk = false;
jsonStr = ""; jsonStr = QString();
// SNAPMATIC DEFAULTS
#ifdef GTA5SYNC_CSDF
careSnapDefault = false;
#else
careSnapDefault = true;
#endif
// SNAPMATIC PROPERTIES // SNAPMATIC PROPERTIES
localSpJson = {}; localSpJson = {};
@ -210,6 +222,13 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
} }
QByteArray snapmaticHeaderLine = picStream->read(snapmaticHeaderLength); QByteArray snapmaticHeaderLine = picStream->read(snapmaticHeaderLength);
pictureHead = getSnapmaticHeaderString(snapmaticHeaderLine); pictureHead = getSnapmaticHeaderString(snapmaticHeaderLine);
if (pictureHead == QLatin1String("MALFORMED"))
{
lastStep = "2;/3,ReadingFile," % StringParser::convertDrawStringForLog(picFilePath) % ",1,MALFORMEDHEADER";
picStream->close();
delete picStream;
return false;
}
// Reading JPEG Header Line // Reading JPEG Header Line
if (!picStream->isReadable()) if (!picStream->isReadable())
@ -260,18 +279,29 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
} }
else if (!fastLoad) else if (!fastLoad)
{ {
QImage tempPicture = QImage(snapmaticResolution, QImage::Format_RGB888); if (careSnapDefault)
QPainter tempPainter(&tempPicture);
if (cachePicture.size() == snapmaticResolution)
{ {
tempPainter.drawImage(0, 0, cachePicture); QImage tempPicture = QImage(snapmaticResolution, QImage::Format_RGB888);
QPainter tempPainter(&tempPicture);
if (cachePicture.size() != snapmaticResolution)
{
tempPainter.drawImage(0, 0, cachePicture.scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
else
{
tempPainter.drawImage(0, 0, cachePicture);
}
tempPainter.end();
cachePicture = tempPicture;
} }
else else
{ {
tempPainter.drawImage(0, 0, cachePicture.scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); QImage tempPicture = QImage(cachePicture.size(), QImage::Format_RGB888);
QPainter tempPainter(&tempPicture);
tempPainter.drawImage(0, 0, cachePicture);
tempPainter.end();
cachePicture = tempPicture;
} }
tempPainter.end();
cachePicture = tempPicture;
} }
// Read JSON Stream // Read JSON Stream
@ -341,19 +371,18 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
QString SnapmaticPicture::getSnapmaticHeaderString(const QByteArray &snapmaticHeader) QString SnapmaticPicture::getSnapmaticHeaderString(const QByteArray &snapmaticHeader)
{ {
QByteArray snapmaticBytes = snapmaticHeader.left(snapmaticUsefulLength); QList<QByteArray> snapmaticBytesList = snapmaticHeader.left(snapmaticUsefulLength).split('\x01');
QList<QByteArray> snapmaticBytesList = snapmaticBytes.split('\x01'); if (snapmaticBytesList.length() < 2) { return QLatin1String("MALFORMED"); }
snapmaticBytes = snapmaticBytesList.at(1); QByteArray snapmaticBytes = snapmaticBytesList.at(1);
snapmaticBytesList.clear();
return StringParser::parseTitleString(snapmaticBytes, snapmaticBytes.length()); return StringParser::parseTitleString(snapmaticBytes, snapmaticBytes.length());
} }
QString SnapmaticPicture::getSnapmaticJSONString(const QByteArray &jsonBytes) QString SnapmaticPicture::getSnapmaticJSONString(const QByteArray &jsonBytes)
{ {
QByteArray jsonUsefulBytes = jsonBytes; QByteArray jsonUsefulBytes = jsonBytes;
jsonUsefulBytes.replace('\x00', ""); jsonUsefulBytes.replace('\x00', QString());
jsonUsefulBytes.replace('\x0c', ""); jsonUsefulBytes.replace('\x0c', QString());
return QString::fromUtf8(jsonUsefulBytes).trimmed(); return QString::fromUtf8(jsonUsefulBytes.trimmed());
} }
QString SnapmaticPicture::getSnapmaticTIDEString(const QByteArray &tideBytes) QString SnapmaticPicture::getSnapmaticTIDEString(const QByteArray &tideBytes)
@ -361,7 +390,7 @@ QString SnapmaticPicture::getSnapmaticTIDEString(const QByteArray &tideBytes)
QByteArray tideUsefulBytes = tideBytes; QByteArray tideUsefulBytes = tideBytes;
tideUsefulBytes.remove(0,4); tideUsefulBytes.remove(0,4);
QList<QByteArray> tideUsefulBytesList = tideUsefulBytes.split('\x00'); QList<QByteArray> tideUsefulBytesList = tideUsefulBytes.split('\x00');
return QString::fromUtf8(tideUsefulBytesList.at(0)).trimmed(); return QString::fromUtf8(tideUsefulBytesList.at(0).trimmed());
} }
void SnapmaticPicture::updateStrings() void SnapmaticPicture::updateStrings()
@ -381,7 +410,8 @@ void SnapmaticPicture::updateStrings()
cmpPicTitl.remove('.'); cmpPicTitl.remove('.');
pictureStr = tr("PHOTO - %1").arg(localSpJson.createdDateTime.toString("MM/dd/yy HH:mm:ss")); pictureStr = tr("PHOTO - %1").arg(localSpJson.createdDateTime.toString("MM/dd/yy HH:mm:ss"));
sortStr = localSpJson.createdDateTime.toString("yyMMddHHmmss") % QString::number(localSpJson.uid); sortStr = localSpJson.createdDateTime.toString("yyMMddHHmmss") % QString::number(localSpJson.uid);
picExportFileName = sortStr % "_" % cmpPicTitl; QString exportStr = localSpJson.createdDateTime.toString("yyyyMMdd") % "-" % QString::number(localSpJson.uid);
picExportFileName = exportStr % "_" % cmpPicTitl;
} }
bool SnapmaticPicture::readingPictureFromFile(const QString &fileName, bool writeEnabled_, bool cacheEnabled_, bool fastLoad, bool lowRamMode_) bool SnapmaticPicture::readingPictureFromFile(const QString &fileName, bool writeEnabled_, bool cacheEnabled_, bool fastLoad, bool lowRamMode_)
@ -397,10 +427,17 @@ bool SnapmaticPicture::readingPictureFromFile(const QString &fileName, bool writ
} }
} }
bool SnapmaticPicture::setImage(const QImage &picture) // dirty method bool SnapmaticPicture::setImage(const QImage &picture)
{ {
if (writeEnabled) if (writeEnabled)
{ {
QImage altPicture;
bool useAltPicture = false;
if (picture.size() != snapmaticResolution && careSnapDefault)
{
altPicture = picture.scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
useAltPicture = true;
}
QByteArray picByteArray; QByteArray picByteArray;
int comLvl = 100; int comLvl = 100;
bool saveSuccess = false; bool saveSuccess = false;
@ -409,7 +446,8 @@ bool SnapmaticPicture::setImage(const QImage &picture) // dirty method
QByteArray picByteArrayT; QByteArray picByteArrayT;
QBuffer picStreamT(&picByteArrayT); QBuffer picStreamT(&picByteArrayT);
picStreamT.open(QIODevice::WriteOnly); picStreamT.open(QIODevice::WriteOnly);
saveSuccess = picture.save(&picStreamT, "JPEG", comLvl); if (useAltPicture) { saveSuccess = altPicture.save(&picStreamT, "JPEG", comLvl); }
else { saveSuccess = picture.save(&picStreamT, "JPEG", comLvl); }
picStreamT.close(); picStreamT.close();
if (saveSuccess) if (saveSuccess)
{ {
@ -424,7 +462,7 @@ bool SnapmaticPicture::setImage(const QImage &picture) // dirty method
} }
} }
} }
if (saveSuccess) return setPictureStream(picByteArray); if (saveSuccess) { return setPictureStream(picByteArray); }
} }
return false; return false;
} }
@ -548,7 +586,7 @@ QString SnapmaticPicture::getLastStep()
return lastStep; return lastStep;
} }
QImage SnapmaticPicture::getImage() QImage SnapmaticPicture::getImage(bool fastLoad)
{ {
if (cacheEnabled) if (cacheEnabled)
{ {
@ -556,9 +594,16 @@ QImage SnapmaticPicture::getImage()
} }
else if (writeEnabled) else if (writeEnabled)
{ {
bool returnOk = 0; bool fastLoadU = fastLoad;
if (!careSnapDefault) { fastLoadU = true; }
bool returnOk = false;
QImage tempPicture; QImage tempPicture;
QImage returnPicture(snapmaticResolution, QImage::Format_RGB888); QImage returnPicture;
if (!fastLoadU)
{
returnPicture = QImage(snapmaticResolution, QImage::Format_RGB888);
}
if (lowRamMode) { rawPicContent = qUncompress(rawPicContent); } if (lowRamMode) { rawPicContent = qUncompress(rawPicContent); }
QBuffer snapmaticStream(&rawPicContent); QBuffer snapmaticStream(&rawPicContent);
@ -573,23 +618,38 @@ QImage SnapmaticPicture::getImage()
if (returnOk) if (returnOk)
{ {
QPainter returnPainter(&returnPicture); if (!fastLoadU)
if (tempPicture.size() == snapmaticResolution)
{ {
returnPainter.drawImage(0, 0, tempPicture); QPainter returnPainter(&returnPicture);
if (tempPicture.size() != snapmaticResolution)
{
returnPainter.drawImage(0, 0, tempPicture.scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
else
{
returnPainter.drawImage(0, 0, tempPicture);
}
returnPainter.end();
return returnPicture;
} }
else else
{ {
returnPainter.drawImage(0, 0, tempPicture.scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); return tempPicture;
} }
returnPainter.end();
return returnPicture;
} }
} }
else else
{ {
bool returnOk = 0; bool fastLoadU = fastLoad;
if (!careSnapDefault) { fastLoadU = true; }
bool returnOk = false;
QImage tempPicture;
QImage returnPicture; QImage returnPicture;
if (!fastLoadU)
{
returnPicture = QImage(snapmaticResolution, QImage::Format_RGB888);
}
QIODevice *picStream; QIODevice *picStream;
QFile *picFile = new QFile(picFilePath); QFile *picFile = new QFile(picFilePath);
@ -597,7 +657,7 @@ QImage SnapmaticPicture::getImage()
{ {
lastStep = "1;/1,OpenFile," % StringParser::convertDrawStringForLog(picFilePath); lastStep = "1;/1,OpenFile," % StringParser::convertDrawStringForLog(picFilePath);
delete picFile; delete picFile;
return QImage(0, 0, QImage::Format_RGB888); return QImage();
} }
rawPicContent = picFile->read(snapmaticFileMaxSize); rawPicContent = picFile->read(snapmaticFileMaxSize);
picFile->close(); picFile->close();
@ -608,17 +668,34 @@ QImage SnapmaticPicture::getImage()
if (picStream->seek(jpegStreamEditorBegin)) if (picStream->seek(jpegStreamEditorBegin))
{ {
QByteArray jpegRawContent = picStream->read(jpegPicStreamLength); QByteArray jpegRawContent = picStream->read(jpegPicStreamLength);
returnOk = returnPicture.loadFromData(jpegRawContent, "JPEG"); returnOk = tempPicture.loadFromData(jpegRawContent, "JPEG");
} }
picStream->close(); picStream->close();
delete picStream; delete picStream;
if (returnOk) if (returnOk)
{ {
return returnPicture; if (!fastLoadU)
{
QPainter returnPainter(&returnPicture);
if (tempPicture.size() != snapmaticResolution)
{
returnPainter.drawImage(0, 0, tempPicture.scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
else
{
returnPainter.drawImage(0, 0, tempPicture);
}
returnPainter.end();
return returnPicture;
}
else
{
return tempPicture;
}
} }
} }
return QImage(0, 0, QImage::Format_RGB888); return QImage();
} }
int SnapmaticPicture::getContentMaxLength() int SnapmaticPicture::getContentMaxLength()
@ -743,7 +820,16 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties newSpJson)
jsonDocument.setObject(jsonObject); jsonDocument.setObject(jsonObject);
QString newJsonStr = QString::fromUtf8(jsonDocument.toJson(QJsonDocument::Compact)); if (setJsonStr(QString::fromUtf8(jsonDocument.toJson(QJsonDocument::Compact))))
{
localSpJson = newSpJson;
return true;
}
return false;
}
bool SnapmaticPicture::setJsonStr(const QString &newJsonStr)
{
if (newJsonStr.length() < jsonStreamEditorLength) if (newJsonStr.length() < jsonStreamEditorLength)
{ {
if (writeEnabled) if (writeEnabled)
@ -765,7 +851,6 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties newSpJson)
snapmaticStream.close(); snapmaticStream.close();
if (result != 0) if (result != 0)
{ {
localSpJson = newSpJson;
jsonStr = newJsonStr; jsonStr = newJsonStr;
if (lowRamMode) { rawPicContent = qCompress(rawPicContent, 9); } if (lowRamMode) { rawPicContent = qCompress(rawPicContent, 9); }
return true; return true;
@ -781,29 +866,38 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties newSpJson)
return false; return false;
} }
} }
else return false;
{
return false;
}
return true;
} }
// FILE MANAGEMENT // FILE MANAGEMENT
bool SnapmaticPicture::exportPicture(const QString &fileName, const QString format) bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat format_)
{ {
// Keep current format when Auto_Format is used
SnapmaticFormat format = format_;
if (format_ == SnapmaticFormat::Auto_Format)
{
if (isCustomFormat)
{
format = SnapmaticFormat::G5E_Format;
}
else
{
format = SnapmaticFormat::PGTA_Format;
}
}
QFile *picFile = new QFile(fileName); QFile *picFile = new QFile(fileName);
if (picFile->open(QIODevice::WriteOnly)) if (picFile->open(QIODevice::WriteOnly))
{ {
if (format == QLatin1String("G5E")) if (format == SnapmaticFormat::G5E_Format)
{ {
// Modern compressed export // Modern compressed export
QByteArray stockFileNameUTF8 = picFileName.toUtf8(); QByteArray stockFileNameUTF8 = picFileName.toUtf8();
QByteArray numberLength = QByteArray::number(stockFileNameUTF8.length()); QByteArray numberLength = QByteArray::number(stockFileNameUTF8.length());
if (numberLength.length() == 1) if (numberLength.length() == 1)
{ {
numberLength.insert(0, "0"); numberLength.insert(0, '0');
} }
else if (numberLength.length() != 2) else if (numberLength.length() != 2)
{ {
@ -831,7 +925,7 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, const QString form
picFile->close(); picFile->close();
delete picFile; delete picFile;
} }
else if (format == QLatin1String("JPG")) else if (format == SnapmaticFormat::JPEG_Format)
{ {
// JPEG export // JPEG export
QBuffer snapmaticStream(&rawPicContent); QBuffer snapmaticStream(&rawPicContent);
@ -944,6 +1038,18 @@ QSize SnapmaticPicture::getSnapmaticResolution()
return snapmaticResolution; return snapmaticResolution;
} }
// SNAPMATIC DEFAULTS
bool SnapmaticPicture::isSnapmaticDefaultsEnforced()
{
return careSnapDefault;
}
void SnapmaticPicture::setSnapmaticDefaultsEnforced(bool enforced)
{
careSnapDefault = enforced;
}
// VERIFY CONTENT // VERIFY CONTENT
bool SnapmaticPicture::verifyTitle(const QString &title) bool SnapmaticPicture::verifyTitle(const QString &title)

View File

@ -26,6 +26,8 @@
#include <QImage> #include <QImage>
#include <QFile> #include <QFile>
enum class SnapmaticFormat : int { Auto_Format = 0, PGTA_Format = 1, JPEG_Format = 2, G5E_Format = 3 };
struct SnapmaticProperties { struct SnapmaticProperties {
struct SnapmaticLocation { struct SnapmaticLocation {
QString area; QString area;
@ -58,7 +60,7 @@ public:
bool readingPicture(bool writeEnabled = true, bool cacheEnabled = false, bool fastLoad = true, bool lowRamMode = false); bool readingPicture(bool writeEnabled = true, bool cacheEnabled = false, bool fastLoad = true, bool lowRamMode = false);
bool isPicOk(); bool isPicOk();
void clearCache(); void clearCache();
QImage getImage(); QImage getImage(bool fastLoad = false);
QString getLastStep(); QString getLastStep();
QString getPictureStr(); QString getPictureStr();
QString getPictureHead(); QString getPictureHead();
@ -76,7 +78,7 @@ public:
void emitUpdate(); void emitUpdate();
// FILE MANAGEMENT // FILE MANAGEMENT
bool exportPicture(const QString &fileName, const QString format = "PGTA"); bool exportPicture(const QString &fileName, SnapmaticFormat format = SnapmaticFormat::Auto_Format);
void setPicFileName(const QString &picFileName); void setPicFileName(const QString &picFileName);
void setPicFilePath(const QString &picFilePath); void setPicFilePath(const QString &picFilePath);
bool deletePicFile(); bool deletePicFile();
@ -92,6 +94,7 @@ public:
QString getJsonStr(); QString getJsonStr();
SnapmaticProperties getSnapmaticProperties(); SnapmaticProperties getSnapmaticProperties();
bool setSnapmaticProperties(SnapmaticProperties newSpJson); bool setSnapmaticProperties(SnapmaticProperties newSpJson);
bool setJsonStr(const QString &jsonStr);
// VISIBILITY // VISIBILITY
bool isHidden(); bool isHidden();
@ -101,6 +104,10 @@ public:
// PREDEFINED PROPERTIES // PREDEFINED PROPERTIES
QSize getSnapmaticResolution(); QSize getSnapmaticResolution();
// SNAPMATIC DEFAULTS
bool isSnapmaticDefaultsEnforced();
void setSnapmaticDefaultsEnforced(bool enforced);
// VERIFY CONTENT // VERIFY CONTENT
static bool verifyTitle(const QString &title); static bool verifyTitle(const QString &title);
@ -124,6 +131,7 @@ private:
bool cacheEnabled; bool cacheEnabled;
bool isLoadedInRAM; bool isLoadedInRAM;
bool isCustomFormat; bool isCustomFormat;
bool careSnapDefault;
int jpegRawContentSize; int jpegRawContentSize;
int jpegRawContentSizeE; int jpegRawContentSizeE;

View File

@ -26,6 +26,7 @@
#include "StringParser.h" #include "StringParser.h"
#include "AppEnv.h" #include "AppEnv.h"
#include "config.h" #include "config.h"
#include <QStringBuilder>
#include <QMessageBox> #include <QMessageBox>
#include <QPixmap> #include <QPixmap>
#include <QTimer> #include <QTimer>
@ -45,16 +46,14 @@ SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, CrewDatabase *crewD
ui->cbSelected->setVisible(false); ui->cbSelected->setVisible(false);
QPalette palette; QPalette palette;
highlightBackColor = palette.highlight().color();
highlightTextColor = palette.highlightedText().color();
palette.setCurrentColorGroup(QPalette::Disabled); palette.setCurrentColorGroup(QPalette::Disabled);
highlightHiddenColor = palette.text().color(); highlightHiddenColor = palette.text().color();
picPath = ""; ui->SnapmaticFrame->setMouseTracking(true);
picStr = ""; ui->labPicture->setMouseTracking(true);
smpic = 0; ui->labPicStr->setMouseTracking(true);
ui->cbSelected->setMouseTracking(true);
installEventFilter(this); smpic = nullptr;
} }
SnapmaticWidget::~SnapmaticWidget() SnapmaticWidget::~SnapmaticWidget()
@ -62,37 +61,16 @@ SnapmaticWidget::~SnapmaticWidget()
delete ui; delete ui;
} }
bool SnapmaticWidget::eventFilter(QObject *obj, QEvent *ev)
{
if (obj == this)
{
if (ev->type() == QEvent::Enter)
{
setStyleSheet(QString("QFrame#SnapmaticFrame{background-color: rgb(%1, %2, %3)}QLabel#labPicStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue())));
return true;
}
else if(ev->type() == QEvent::Leave)
{
setStyleSheet("");
return true;
}
}
return false;
}
void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture) void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture)
{ {
smpic = picture; smpic = picture;
picPath = picture->getPictureFilePath();
picTitl = picture->getPictureTitl();
picStr = picture->getPictureStr();
QObject::connect(picture, SIGNAL(updated()), this, SLOT(snapmaticUpdated())); QObject::connect(picture, SIGNAL(updated()), this, SLOT(snapmaticUpdated()));
qreal screenRatio = AppEnv::screenRatio(); qreal screenRatio = AppEnv::screenRatio();
ui->labPicture->setFixedSize(48 * screenRatio, 27 * screenRatio); ui->labPicture->setFixedSize(48 * screenRatio, 27 * screenRatio);
QPixmap SnapmaticPixmap = QPixmap::fromImage(picture->getImage().scaled(ui->labPicture->width(), ui->labPicture->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::AutoColor); QPixmap SnapmaticPixmap = QPixmap::fromImage(picture->getImage().scaled(ui->labPicture->width(), ui->labPicture->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::AutoColor);
ui->labPicStr->setText(picStr + "\n" + picTitl + ""); ui->labPicStr->setText(smpic->getPictureStr() % "\n" % smpic->getPictureTitl() % "");
ui->labPicture->setPixmap(SnapmaticPixmap); ui->labPicture->setPixmap(SnapmaticPixmap);
picture->clearCache(); picture->clearCache();
@ -102,11 +80,13 @@ void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture)
void SnapmaticWidget::snapmaticUpdated() void SnapmaticWidget::snapmaticUpdated()
{ {
// Current only strings get updated ui->labPicStr->setText(smpic->getPictureStr() % "\n" % smpic->getPictureTitl() % "");
picPath = smpic->getPictureFilePath(); }
picTitl = smpic->getPictureTitl();
picStr = smpic->getPictureStr(); void SnapmaticWidget::retranslate()
ui->labPicStr->setText(picStr + "\n" + picTitl + ""); {
smpic->updateStrings();
ui->labPicStr->setText(smpic->getPictureStr() % "\n" % smpic->getPictureTitl() % "");
} }
void SnapmaticWidget::on_cmdView_clicked() void SnapmaticWidget::on_cmdView_clicked()
@ -120,7 +100,8 @@ void SnapmaticWidget::on_cmdView_clicked()
picDialog->setSnapmaticPicture(smpic, true); picDialog->setSnapmaticPicture(smpic, true);
picDialog->setModal(true); picDialog->setModal(true);
// be ready for playerName updated // be ready for crewName and playerName updated
QObject::connect(threadDB, SIGNAL(crewNameUpdated()), picDialog, SLOT(crewNameUpdated()));
QObject::connect(threadDB, SIGNAL(playerNameUpdated()), picDialog, SLOT(playerNameUpdated())); QObject::connect(threadDB, SIGNAL(playerNameUpdated()), picDialog, SLOT(playerNameUpdated()));
QObject::connect(picDialog, SIGNAL(nextPictureRequested()), this, SLOT(dialogNextPictureRequested())); QObject::connect(picDialog, SIGNAL(nextPictureRequested()), this, SLOT(dialogNextPictureRequested()));
QObject::connect(picDialog, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested())); QObject::connect(picDialog, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested()));
@ -160,7 +141,7 @@ void SnapmaticWidget::on_cmdDelete_clicked()
bool SnapmaticWidget::deletePicture() bool SnapmaticWidget::deletePicture()
{ {
int uchoice = QMessageBox::question(this, tr("Delete picture"), tr("Are you sure to delete %1 from your Snapmatic pictures?").arg("\""+picStr+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); int uchoice = QMessageBox::question(this, tr("Delete picture"), tr("Are you sure to delete %1 from your Snapmatic pictures?").arg("\""+smpic->getPictureStr()+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (uchoice == QMessageBox::Yes) if (uchoice == QMessageBox::Yes)
{ {
if (smpic->deletePicFile()) if (smpic->deletePicFile())
@ -169,7 +150,7 @@ bool SnapmaticWidget::deletePicture()
} }
else else
{ {
QMessageBox::warning(this, tr("Delete picture"), tr("Failed at deleting %1 from your Snapmatic pictures").arg("\""+picStr+"\"")); QMessageBox::warning(this, tr("Delete picture"), tr("Failed at deleting %1 from your Snapmatic pictures").arg("\""+smpic->getPictureStr()+"\""));
} }
} }
return false; return false;
@ -194,7 +175,18 @@ void SnapmaticWidget::mouseReleaseEvent(QMouseEvent *ev)
{ {
if (getContentMode() == 0 && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) if (getContentMode() == 0 && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{ {
on_cmdView_clicked(); if (ev->modifiers().testFlag(Qt::ShiftModifier))
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
}
else
{
on_cmdView_clicked();
}
}
else if (!ui->cbSelected->isVisible() && getContentMode() == 1 && ev->button() == Qt::LeftButton && ev->modifiers().testFlag(Qt::ShiftModifier))
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
} }
} }
} }
@ -262,7 +254,6 @@ bool SnapmaticWidget::makePictureHidden()
{ {
if (smpic->setPictureHidden()) if (smpic->setPictureHidden())
{ {
picPath = smpic->getPictureFilePath();
adjustTextColor(); adjustTextColor();
return true; return true;
} }
@ -273,7 +264,6 @@ bool SnapmaticWidget::makePictureVisible()
{ {
if (smpic->setPictureVisible()) if (smpic->setPictureVisible())
{ {
picPath = smpic->getPictureFilePath();
adjustTextColor(); adjustTextColor();
return true; return true;
} }
@ -307,11 +297,7 @@ bool SnapmaticWidget::isSelected()
bool SnapmaticWidget::isHidden() bool SnapmaticWidget::isHidden()
{ {
if (picPath.right(7) == ".hidden") return smpic->isHidden();
{
return true;
}
return false;
} }
void SnapmaticWidget::setSelectionMode(bool selectionMode) void SnapmaticWidget::setSelectionMode(bool selectionMode)
@ -336,7 +322,7 @@ SnapmaticPicture* SnapmaticWidget::getPicture()
QString SnapmaticWidget::getPicturePath() QString SnapmaticWidget::getPicturePath()
{ {
return picPath; return smpic->getPictureFilePath();
} }
QString SnapmaticWidget::getWidgetType() QString SnapmaticWidget::getWidgetType()

View File

@ -50,6 +50,7 @@ public:
QString getWidgetType(); QString getWidgetType();
bool isSelected(); bool isSelected();
bool isHidden(); bool isHidden();
void retranslate();
~SnapmaticWidget(); ~SnapmaticWidget();
private slots: private slots:
@ -70,7 +71,6 @@ private slots:
void snapmaticUpdated(); void snapmaticUpdated();
protected: protected:
bool eventFilter(QObject *obj, QEvent *ev);
void mouseDoubleClickEvent(QMouseEvent *ev); void mouseDoubleClickEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev); void mouseReleaseEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev); void mousePressEvent(QMouseEvent *ev);
@ -82,13 +82,7 @@ private:
DatabaseThread *threadDB; DatabaseThread *threadDB;
Ui::SnapmaticWidget *ui; Ui::SnapmaticWidget *ui;
SnapmaticPicture *smpic; SnapmaticPicture *smpic;
QColor highlightBackColor;
QColor highlightTextColor;
QColor highlightHiddenColor; QColor highlightHiddenColor;
QString picPath;
QString picTitl;
QString picStr;
QWidget *snwgt;
signals: signals:
void pictureDeleted(); void pictureDeleted();

View File

@ -19,6 +19,7 @@
#include "StringParser.h" #include "StringParser.h"
#include "config.h" #include "config.h"
#include <QTextDocument> #include <QTextDocument>
#include <QLibraryInfo>
#ifndef GTA5VIEW_CMD #ifndef GTA5VIEW_CMD
#include <QApplication> #include <QApplication>
#endif #endif
@ -59,9 +60,12 @@ QString StringParser::convertBuildedString(const QString &buildedStr)
{ {
QString outputStr = buildedStr; QString outputStr = buildedStr;
QByteArray sharePath = GTA5SYNC_SHARE; QByteArray sharePath = GTA5SYNC_SHARE;
outputStr.replace("$SHAREDIR", QString::fromUtf8(sharePath)); outputStr.replace("APPNAME:", GTA5SYNC_APPSTR);
outputStr.replace("$RUNDIR", QFileInfo(qApp->applicationFilePath()).absoluteDir().absolutePath()); outputStr.replace("SHAREDDIR:", QString::fromUtf8(sharePath));
outputStr.replace("$SEPARATOR", QDir::separator()); outputStr.replace("RUNDIR:", QFileInfo(qApp->applicationFilePath()).absoluteDir().absolutePath());
outputStr.replace("QCONFLANG:", QLibraryInfo::location(QLibraryInfo::TranslationsPath));
outputStr.replace("QCONFPLUG:", QLibraryInfo::location(QLibraryInfo::PluginsPath));
outputStr.replace("SEPARATOR:", QDir::separator());
return outputStr; return outputStr;
} }
#endif #endif

543
TranslationClass.cpp Normal file
View File

@ -0,0 +1,543 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2017 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 "TranslationClass.h"
#include "AppEnv.h"
#include "config.h"
#include <QStringBuilder>
#include <QApplication>
#include <QStringList>
#include <QTranslator>
#include <QSettings>
#include <QLocale>
#include <QDebug>
#include <QFile>
#include <QDir>
#if QT_VERSION >= 0x050000
#define QtBaseTranslationFormat "qtbase_"
#else
#define QtBaseTranslationFormat "qt_"
#endif
TranslationClass TranslationClass::translationClassInstance;
void TranslationClass::initUserLanguage()
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Interface");
userLanguage = settings.value("Language", "System").toString();
settings.endGroup();
}
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")
{
currentLanguage = "en_GB";
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
app->installTranslator(&inQtTranslator);
}
QLocale::setDefault(currentLanguage);
isLangLoaded = true;
return;
}
#ifndef GTA5SYNC_QCONF // Classic modable loading method
QString externalLanguageStr;
bool externalLanguageReady = false;
bool loadInternalLang = false;
bool trLoadSuccess = false;
if (isUserLanguageSystem_p())
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadExSystemLanguage";
#endif
trLoadSuccess = loadSystemTranslation_p(exLangPath, &exAppTranslator);
}
else
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadExUserLanguage";
#endif
trLoadSuccess = loadUserTranslation_p(exLangPath, &exAppTranslator);
if (!trLoadSuccess)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadInUserLanguage";
#endif
trLoadSuccess = loadUserTranslation_p(inLangPath, &inAppTranslator);
if (!trLoadSuccess)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadUserLanguageFailed";
#endif
}
else
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadUserLanguageSuccess";
#endif
loadInternalLang = true;
isLangLoaded = true;
}
}
else
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadUserLanguageSuccess";
#endif
isLangLoaded = true;
}
}
if (trLoadSuccess)
{
if (currentLangIndex != 0) // Don't install the language until we know we not have a better language for the user
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "externalLanguageReady" << currentLanguage;
#endif
externalLanguageStr = currentLanguage;
externalLanguageReady = true;
}
else
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "installTranslation";
#endif
if (loadInternalLang)
{
app->installTranslator(&inAppTranslator);
}
else
{
app->installTranslator(&exAppTranslator);
}
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
app->installTranslator(&inQtTranslator);
}
QLocale::setDefault(currentLanguage);
isLangLoaded = true;
}
}
if (externalLanguageReady)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadInSystemLanguage";
#endif
int externalLangIndex = currentLangIndex;
trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator);
#ifdef GTA5SYNC_DEBUG
qDebug() << "externalLangIndex" << externalLangIndex << "internalLangIndex" << currentLangIndex;
#endif
if (trLoadSuccess && externalLangIndex > currentLangIndex)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "installInternalTranslation";
#endif
app->installTranslator(&inAppTranslator);
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
app->installTranslator(&inQtTranslator);
}
QLocale::setDefault(currentLanguage);
isLangLoaded = true;
}
else
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "installExternalTranslation";
#endif
currentLanguage = externalLanguageStr;
app->installTranslator(&exAppTranslator);
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
app->installTranslator(&inQtTranslator);
}
QLocale::setDefault(currentLanguage);
isLangLoaded = true;
}
}
else if (!isLangLoaded)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadInSystemLanguage";
#endif
trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator);
if (trLoadSuccess)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "installInternalTranslation";
#endif
app->installTranslator(&inAppTranslator);
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
app->installTranslator(&inQtTranslator);
}
QLocale::setDefault(currentLanguage);
isLangLoaded = true;
}
else if (!trLoadSuccess)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "fallbackToDefaultApplicationLanguage";
#endif
currentLanguage = "en_GB";
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
app->installTranslator(&inQtTranslator);
}
QLocale::setDefault(currentLanguage);
isLangLoaded = true;
}
}
#else // New qconf loading method
bool trLoadSuccess;
if (isUserLanguageSystem_p())
{
trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator);
}
else
{
trLoadSuccess = loadUserTranslation_p(inLangPath, &inAppTranslator);
}
if (!trLoadSuccess && !isUserLanguageSystem_p())
{
trLoadSuccess = loadSystemTranslation_p(inLangPath, &inAppTranslator);
}
if (trLoadSuccess)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "installTranslation" << currentLanguage;
#endif
app->installTranslator(&inAppTranslator);
if (loadQtTranslation_p(exLangPath, &exQtTranslator))
{
app->installTranslator(&exQtTranslator);
}
else if (loadQtTranslation_p(inLangPath, &inQtTranslator))
{
app->installTranslator(&inQtTranslator);
}
QLocale::setDefault(currentLanguage);
isLangLoaded = true;
}
#endif
}
QStringList TranslationClass::listTranslations(const QString &langPath)
{
QDir langDir;
langDir.setNameFilters(QStringList("gta5sync_*.qm"));
langDir.setPath(langPath);
QStringList availableLanguages;
foreach(const QString &lang, langDir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::NoSort))
{
availableLanguages << QString(lang).remove("gta5sync_").remove(".qm");
}
return availableLanguages;
}
bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTranslator *appTranslator)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadSystemTranslation_p";
#endif
int currentLangCounter = 0;
foreach(const QString &languageName, QLocale::system().uiLanguages())
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguage" << languageName;
#endif
QStringList langList = QString(languageName).replace("-","_").split("_");
if (langList.length() == 2)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
if (appTranslator->load(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
currentLanguage = languageName;
currentLangIndex = currentLangCounter;
return true;
}
}
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
{
if (appTranslator->load(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
#endif
currentLanguage = languageName;
currentLangIndex = currentLangCounter;
return true;
}
}
if (langList.at(0) == "en")
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "languageEnglishMode index" << currentLangCounter;
#endif
currentLanguage = languageName;
currentLangIndex = currentLangCounter;
return true;
}
}
else if (langList.length() == 1)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
{
if (appTranslator->load(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
#endif
currentLanguage = languageName;
return true;
}
}
}
#ifdef GTA5SYNC_DEBUG
qDebug() << "currentLangCounter bump";
#endif
currentLangCounter++;
}
return false;
}
bool TranslationClass::loadUserTranslation_p(const QString &langPath, QTranslator *appTranslator)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadUserTranslation_p";
#endif
QString languageName = userLanguage;
QStringList langList = QString(languageName).replace("-","_").split("_");
if (langList.length() == 2)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
if (appTranslator->load(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
currentLanguage = languageName;
return true;
}
}
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
{
if (appTranslator->load(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
#endif
currentLanguage = languageName;
return true;
}
}
}
else if (langList.length() == 1)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
{
if (appTranslator->load(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
#endif
currentLanguage = languageName;
return true;
}
}
}
return false;
}
bool TranslationClass::loadQtTranslation_p(const QString &langPath, QTranslator *qtTranslator)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadQtTranslation_p" << currentLanguage;
#endif
QString languageName = currentLanguage;
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"))
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
return true;
}
}
#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"))
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm");
#endif
return true;
}
}
}
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"))
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % QtBaseTranslationFormat % langList.at(0) % ".qm");
#endif
return true;
}
}
}
return false;
}
bool TranslationClass::isUserLanguageSystem_p()
{
return (userLanguage == "System" || userLanguage.trimmed().isEmpty());
}
QString TranslationClass::getCurrentLanguage()
{
return currentLanguage;
}
bool TranslationClass::isLanguageLoaded()
{
return isLangLoaded;
}
void TranslationClass::unloadTranslation(QApplication *app)
{
if (isLangLoaded)
{
#ifndef GTA5SYNC_QCONF
app->removeTranslator(&exAppTranslator);
app->removeTranslator(&exQtTranslator);
app->removeTranslator(&inAppTranslator);
app->removeTranslator(&inQtTranslator);
#else
app->removeTranslator(&inAppTranslator);
app->removeTranslator(&exQtTranslator);
#endif
currentLangIndex = 0;
currentLanguage = QString();
QLocale::setDefault(QLocale::c());
isLangLoaded = false;
}
#ifdef _MSC_VER // Fix dumb Microsoft compiler warning
Q_UNUSED(app)
#endif
}
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();
}
}
QString TranslationClass::getCountryCode(QLocale locale)
{
QStringList localeStrList = locale.name().split("_");
if (localeStrList.length() <= 2)
{
return localeStrList.at(1).toLower();
}
else
{
return QString();
}
}

63
TranslationClass.h Normal file
View File

@ -0,0 +1,63 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2017 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 TRANSLATIONCLASS_H
#define TRANSLATIONCLASS_H
#include <QApplication>
#include <QTranslator>
#include <QStringList>
#include <QString>
#include <QObject>
#include <QLocale>
class TranslationClass : public QObject
{
Q_OBJECT
public:
static TranslationClass* getInstance() { return &translationClassInstance; }
static QString getCountryCode(QLocale::Country country);
static QString getCountryCode(QLocale locale);
void initUserLanguage();
void loadTranslation(QApplication *app);
void unloadTranslation(QApplication *app);
QStringList listTranslations(const QString &langPath);
QString getCurrentLanguage();
bool isLanguageLoaded();
private:
static TranslationClass translationClassInstance;
bool loadSystemTranslation_p(const QString &langPath, QTranslator *appTranslator);
bool loadUserTranslation_p(const QString &langPath, QTranslator *appTranslator);
bool loadQtTranslation_p(const QString &langPath, QTranslator *qtTranslator);
bool isUserLanguageSystem_p();
QTranslator exAppTranslator;
QTranslator exQtTranslator;
QTranslator inAppTranslator;
QTranslator inQtTranslator;
QString currentLanguage;
QString userLanguage;
int currentLangIndex;
bool isLangLoaded;
};
extern TranslationClass translationClass;
#define TCInstance TranslationClass::getInstance()
#endif // TRANSLATIONCLASS_H

View File

@ -31,6 +31,7 @@
#include "AppEnv.h" #include "AppEnv.h"
#include "config.h" #include "config.h"
#include <QtGlobal> #include <QtGlobal>
#include <QStringBuilder>
#include <QStyleFactory> #include <QStyleFactory>
#include <QFileDialog> #include <QFileDialog>
#include <QHBoxLayout> #include <QHBoxLayout>
@ -57,10 +58,11 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D
ui->actionSelect_profile->setEnabled(false); ui->actionSelect_profile->setEnabled(false);
ui->actionAbout_gta5sync->setIcon(IconLoader::loadingAppIcon()); ui->actionAbout_gta5sync->setIcon(IconLoader::loadingAppIcon());
ui->actionAbout_gta5sync->setText(tr("&About %1").arg(GTA5SYNC_APPSTR)); ui->actionAbout_gta5sync->setText(tr("&About %1").arg(GTA5SYNC_APPSTR));
ui->cmdClose->setToolTip(ui->cmdClose->toolTip().arg(GTA5SYNC_APPSTR));
defaultWindowTitle = tr("%2 - %1").arg("%1", GTA5SYNC_APPSTR); defaultWindowTitle = tr("%2 - %1").arg("%1", GTA5SYNC_APPSTR);
this->setWindowTitle(defaultWindowTitle.arg(tr("Select Profile"))); this->setWindowTitle(defaultWindowTitle.arg(tr("Select Profile")));
ui->labVersion->setText(ui->labVersion->text().arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER)); ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER));
if (QIcon::hasThemeIcon("dialog-close")) if (QIcon::hasThemeIcon("dialog-close"))
{ {
@ -130,7 +132,7 @@ void UserInterface::setupDirEnv()
if (folderExists) if (folderExists)
{ {
QDir GTAV_ProfilesDir; QDir GTAV_ProfilesDir;
GTAV_ProfilesFolder = GTAV_Folder + QDir::separator() + "Profiles"; GTAV_ProfilesFolder = GTAV_Folder % QDir::separator() % "Profiles";
GTAV_ProfilesDir.setPath(GTAV_ProfilesFolder); GTAV_ProfilesDir.setPath(GTAV_ProfilesFolder);
GTAV_Profiles = GTAV_ProfilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::NoSort); GTAV_Profiles = GTAV_ProfilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::NoSort);
@ -163,7 +165,7 @@ void UserInterface::setupProfileUi()
changeDirBtn->setMinimumSize(0, 40 * screenRatio); changeDirBtn->setMinimumSize(0, 40 * screenRatio);
changeDirBtn->setAutoDefault(true); changeDirBtn->setAutoDefault(true);
ui->vlButtons->addWidget(changeDirBtn); ui->vlButtons->addWidget(changeDirBtn);
profileBtns.append(changeDirBtn); profileBtns += changeDirBtn;
QObject::connect(changeDirBtn, SIGNAL(clicked(bool)), this, SLOT(changeFolder_clicked())); QObject::connect(changeDirBtn, SIGNAL(clicked(bool)), this, SLOT(changeFolder_clicked()));
} }
@ -174,7 +176,7 @@ void UserInterface::setupProfileUi()
profileBtn->setMinimumSize(0, 40 * screenRatio); profileBtn->setMinimumSize(0, 40 * screenRatio);
profileBtn->setAutoDefault(true); profileBtn->setAutoDefault(true);
ui->vlButtons->addWidget(profileBtn); ui->vlButtons->addWidget(profileBtn);
profileBtns.append(profileBtn); profileBtns += profileBtn;
QObject::connect(profileBtn, SIGNAL(clicked(bool)), this, SLOT(profileButton_clicked())); QObject::connect(profileBtn, SIGNAL(clicked(bool)), this, SLOT(profileButton_clicked()));
} }
@ -203,13 +205,14 @@ void UserInterface::profileButton_clicked()
openProfile(profileBtn->objectName()); openProfile(profileBtn->objectName());
} }
void UserInterface::openProfile(QString profileName) void UserInterface::openProfile(const QString &profileName_)
{ {
profileOpen = true; profileOpen = true;
profileName = profileName_;
profileUI = new ProfileInterface(profileDB, crewDB, threadDB); profileUI = new ProfileInterface(profileDB, crewDB, threadDB);
ui->swProfile->addWidget(profileUI); ui->swProfile->addWidget(profileUI);
ui->swProfile->setCurrentWidget(profileUI); ui->swProfile->setCurrentWidget(profileUI);
profileUI->setProfileFolder(GTAV_ProfilesFolder + QDir::separator() + profileName, profileName); profileUI->setProfileFolder(GTAV_ProfilesFolder % QDir::separator() % profileName, profileName);
profileUI->settingsApplied(contentMode, language); profileUI->settingsApplied(contentMode, language);
profileUI->setupProfileInterface(); profileUI->setupProfileInterface();
QObject::connect(profileUI, SIGNAL(profileClosed()), this, SLOT(closeProfile())); QObject::connect(profileUI, SIGNAL(profileClosed()), this, SLOT(closeProfile()));
@ -222,6 +225,7 @@ void UserInterface::closeProfile()
if (profileOpen) if (profileOpen)
{ {
profileOpen = false; profileOpen = false;
profileName.clear();
ui->menuProfile->setEnabled(false); ui->menuProfile->setEnabled(false);
ui->actionSelect_profile->setEnabled(false); ui->actionSelect_profile->setEnabled(false);
ui->swProfile->removeWidget(profileUI); ui->swProfile->removeWidget(profileUI);
@ -461,7 +465,7 @@ void UserInterface::openSnapmaticFile(SnapmaticPicture *picture)
int crewID = picture->getSnapmaticProperties().crewID; int crewID = picture->getSnapmaticProperties().crewID;
if (crewID != 0) { crewDB->addCrew(crewID); } if (crewID != 0) { crewDB->addCrew(crewID); }
QObject::connect(threadDB, SIGNAL(playerNameFound(int, QString)), profileDB, SLOT(setPlayerName(int, QString))); QObject::connect(threadDB, SIGNAL(crewNameUpdated()), &picDialog, SLOT(crewNameUpdated()));
QObject::connect(threadDB, SIGNAL(playerNameUpdated()), &picDialog, SLOT(playerNameUpdated())); QObject::connect(threadDB, SIGNAL(playerNameUpdated()), &picDialog, SLOT(playerNameUpdated()));
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
@ -492,7 +496,11 @@ void UserInterface::openSavegameFile(SavegameData *savegame)
void UserInterface::settingsApplied(int _contentMode, QString _language) void UserInterface::settingsApplied(int _contentMode, QString _language)
{ {
language = _language; if (language != _language)
{
retranslateUi();
language = _language;
}
contentMode = _contentMode; contentMode = _contentMode;
if (profileOpen) if (profileOpen)
{ {
@ -527,3 +535,18 @@ void UserInterface::on_action_Disable_In_game_triggered()
profileUI->disableSelected(); profileUI->disableSelected();
} }
} }
void UserInterface::retranslateUi()
{
ui->retranslateUi(this);
ui->actionAbout_gta5sync->setText(tr("&About %1").arg(GTA5SYNC_APPSTR));
ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER));
if (profileOpen)
{
this->setWindowTitle(defaultWindowTitle.arg(profileName));
}
else
{
this->setWindowTitle(defaultWindowTitle.arg(tr("Select Profile")));
}
}

View File

@ -26,6 +26,7 @@
#include "CrewDatabase.h" #include "CrewDatabase.h"
#include "SavegameData.h" #include "SavegameData.h"
#include <QMainWindow> #include <QMainWindow>
#include <QMouseEvent>
#include <QCloseEvent> #include <QCloseEvent>
#include <QString> #include <QString>
#include <QMap> #include <QMap>
@ -73,6 +74,7 @@ private:
Ui::UserInterface *ui; Ui::UserInterface *ui;
ProfileInterface *profileUI; ProfileInterface *profileUI;
QList<QPushButton*> profileBtns; QList<QPushButton*> profileBtns;
QString profileName;
bool profileOpen; bool profileOpen;
int contentMode; int contentMode;
QString language; QString language;
@ -81,8 +83,9 @@ private:
QString GTAV_ProfilesFolder; QString GTAV_ProfilesFolder;
QStringList GTAV_Profiles; QStringList GTAV_Profiles;
void setupProfileUi(); void setupProfileUi();
void openProfile(QString profileName); void openProfile(const QString &profileName);
void openSelectProfile(); void openSelectProfile();
void retranslateUi();
// Open File // Open File
bool openFile(QString selectedFile, bool warn = true); bool openFile(QString selectedFile, bool warn = true);

View File

@ -127,6 +127,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>Reload profile overview</string>
</property>
<property name="text"> <property name="text">
<string>&amp;Reload</string> <string>&amp;Reload</string>
</property> </property>
@ -143,6 +146,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string extracomment="Close %1 &lt;- (gta5view/gta5sync) - %1 will be replaced automatically">Close %1</string>
</property>
<property name="text"> <property name="text">
<string>&amp;Close</string> <string>&amp;Close</string>
</property> </property>

View File

@ -18,6 +18,7 @@
#ifndef CONFIG_H #ifndef CONFIG_H
#define CONFIG_H #define CONFIG_H
#include <QtGlobal>
#include <QString> #include <QString>
#ifndef GTA5SYNC_APPVENDOR #ifndef GTA5SYNC_APPVENDOR
@ -50,9 +51,51 @@
#ifndef GTA5SYNC_APPVER #ifndef GTA5SYNC_APPVER
#ifndef GTA5SYNC_DAILYB #ifndef GTA5SYNC_DAILYB
#define GTA5SYNC_APPVER "1.4.4" #define GTA5SYNC_APPVER "1.5.0-dev1"
#else #else
#define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB) #define GTA5SYNC_APPVER GTA5SYNC_DAILYB
#endif
#endif
#ifdef GTA5SYNC_BUILDTYPE_REL
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Release")
#endif
#endif
#ifdef GTA5SYNC_BUILDTYPE_RC
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Release Candidate")
#endif
#endif
#ifdef GTA5SYNC_BUILDTYPE_DAILY
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Daily Build")
#endif
#endif
#ifdef GTA5SYNC_BUILDTYPE_DEV
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Developer")
#endif
#endif
#ifdef GTA5SYNC_BUILDTYPE_BETA
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Beta")
#endif
#endif
#ifdef GTA5SYNC_BUILDTYPE_ALPHA
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Alpha")
#endif
#endif
#ifdef GTA5SYNC_DAILYB
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE "Daily Build"
#endif #endif
#endif #endif
@ -60,16 +103,33 @@
#define GTA5SYNC_BUILDTYPE "Custom" #define GTA5SYNC_BUILDTYPE "Custom"
#endif #endif
#ifdef GTA5SYNC_QCONF
#ifndef GTA5SYNC_SHARE #ifndef GTA5SYNC_SHARE
#define GTA5SYNC_SHARE "$RUNDIR" #define GTA5SYNC_SHARE "RUNDIR:SEPARATOR:..SEPARATOR:share"
#endif
#ifndef GTA5SYNC_LANG
#define GTA5SYNC_LANG "QCONFLANG:"
#endif
#ifndef GTA5SYNC_PLUG
#define GTA5SYNC_PLUG "QCONFPLUG:"
#endif
#ifdef GTA5SYNC_QCONF_IN
#ifndef GTA5SYNC_INLANG
#define GTA5SYNC_INLANG ":/tr"
#endif
#endif
#endif
#ifndef GTA5SYNC_SHARE
#define GTA5SYNC_SHARE "RUNDIR:"
#endif #endif
#ifndef GTA5SYNC_LANG #ifndef GTA5SYNC_LANG
#define GTA5SYNC_LANG "$SHAREDIR$SEPARATORlang" #define GTA5SYNC_LANG "SHAREDDIR:SEPARATOR:lang"
#endif #endif
#ifndef GTA5SYNC_PLUG #ifndef GTA5SYNC_PLUG
#define GTA5SYNC_PLUG "$RUNDIR$SEPARATORplugins" #define GTA5SYNC_PLUG "RUNDIR:SEPARATOR:plugins"
#endif #endif
#ifdef GTA5SYNC_WINRT #ifdef GTA5SYNC_WINRT
@ -91,11 +151,11 @@
#endif #endif
#ifndef GTA5SYNC_BUILDDATETIME #ifndef GTA5SYNC_BUILDDATETIME
#define GTA5SYNC_BUILDDATETIME QString("%1, %2").arg(__DATE__, __TIME__); #define GTA5SYNC_BUILDDATETIME QString("%1, %2").arg(__DATE__, __TIME__)
#endif #endif
#ifndef GTA5SYNC_BUILDSTRING #ifndef GTA5SYNC_BUILDSTRING
#define GTA5SYNC_BUILDSTRING QString("%1, %2").arg(QT_VERSION_STR, GTA5SYNC_COMPILER); #define GTA5SYNC_BUILDSTRING QString("%1, %2").arg(QT_VERSION_STR, GTA5SYNC_COMPILER)
#endif #endif
#endif // CONFIG_H #endif // CONFIG_H

View File

@ -27,6 +27,10 @@ DEPLOYMENT.display_name = gta5view
TARGET = gta5view TARGET = gta5view
TEMPLATE = app TEMPLATE = app
DEFINES += GTA5SYNC_CSDF # Not assisting at proper usage of SnapmaticPicture class
HEADERS += config.h
PRECOMPILED_HEADER += config.h
SOURCES += main.cpp \ SOURCES += main.cpp \
AboutDialog.cpp \ AboutDialog.cpp \
AppEnv.cpp \ AppEnv.cpp \
@ -37,6 +41,7 @@ SOURCES += main.cpp \
GlobalString.cpp \ GlobalString.cpp \
IconLoader.cpp \ IconLoader.cpp \
ImportDialog.cpp \ ImportDialog.cpp \
MapPreviewDialog.cpp \
OptionsDialog.cpp \ OptionsDialog.cpp \
PictureDialog.cpp \ PictureDialog.cpp \
PictureExport.cpp \ PictureExport.cpp \
@ -55,6 +60,7 @@ SOURCES += main.cpp \
SnapmaticWidget.cpp \ SnapmaticWidget.cpp \
StandardPaths.cpp \ StandardPaths.cpp \
StringParser.cpp \ StringParser.cpp \
TranslationClass.cpp \
UserInterface.cpp \ UserInterface.cpp \
uimod/UiModLabel.cpp \ uimod/UiModLabel.cpp \
uimod/UiModWidget.cpp uimod/UiModWidget.cpp
@ -69,6 +75,7 @@ HEADERS += \
GlobalString.h \ GlobalString.h \
IconLoader.h \ IconLoader.h \
ImportDialog.h \ ImportDialog.h \
MapPreviewDialog.h \
OptionsDialog.h \ OptionsDialog.h \
PictureDialog.h \ PictureDialog.h \
PictureExport.h \ PictureExport.h \
@ -87,16 +94,16 @@ HEADERS += \
SnapmaticWidget.h \ SnapmaticWidget.h \
StandardPaths.h \ StandardPaths.h \
StringParser.h \ StringParser.h \
TranslationClass.h \
UserInterface.h \ UserInterface.h \
uimod/UiModLabel.h \ uimod/UiModLabel.h \
uimod/UiModWidget.h uimod/UiModWidget.h
PRECOMPILED_HEADER += config.h
FORMS += \ FORMS += \
AboutDialog.ui \ AboutDialog.ui \
ExportDialog.ui \ ExportDialog.ui \
ImportDialog.ui \ ImportDialog.ui \
MapPreviewDialog.ui \
OptionsDialog.ui \ OptionsDialog.ui \
PictureDialog.ui \ PictureDialog.ui \
ProfileInterface.ui \ ProfileInterface.ui \
@ -107,21 +114,24 @@ FORMS += \
UserInterface.ui UserInterface.ui
TRANSLATIONS += \ TRANSLATIONS += \
res/gta5sync_en_US.ts \
res/gta5sync_de.ts \ res/gta5sync_de.ts \
res/gta5sync_fr.ts \ res/gta5sync_fr.ts \
res/gta5sync_ru.ts res/gta5sync_ru.ts \
lang/gta5sync_no.ts
RESOURCES += \ RESOURCES += \
res/tr_g5p.qrc \ res/tr_g5p.qrc \
res/app.qrc res/app.qrc
DISTFILES += res/app.rc \ DISTFILES += res/app.rc \
res/gta5sync.desktop \ res/gta5view.desktop \
res/gta5sync_de.ts \ res/gta5sync_de.ts \
res/gta5sync_fr.ts \ res/gta5sync_fr.ts \
res/gta5sync_ru.ts \ res/gta5sync_ru.ts \
res/gta5view.exe.manifest \ res/gta5view.exe.manifest \
res/gta5view.png \ res/gta5view.png \
lang/gta5sync_no.ts \
lang/README.txt lang/README.txt
INCLUDEPATH += ./uimod INCLUDEPATH += ./uimod
@ -159,14 +169,28 @@ isEqual(QT_MAJOR_VERSION, 4): SOURCES += qjson4/QJsonArray.cpp \
isEqual(QT_MAJOR_VERSION, 4): RESOURCES += res/tr_qt4.qrc isEqual(QT_MAJOR_VERSION, 4): RESOURCES += res/tr_qt4.qrc
# QT5 ONLY STUFF # QT5 ONLY STUFF
isEqual(QT_MAJOR_VERSION, 5): RESOURCES += res/tr_qt5.qrc isEqual(QT_MAJOR_VERSION, 5): RESOURCES += res/tr_qt5.qrc
# UNIX SYSTEM STUFF # PROJECT INSTALLATION
unix: !macx: appfiles.path = $$(INSTALL_PATH)/share/applications isEmpty(GTA5SYNC_PREFIX): GTA5SYNC_PREFIX = /usr/local
unix: !macx: appfiles.files = $$PWD/res/gta5view.desktop
unix: !macx: pixmaps.path = $$(INSTALL_PATH)/share/pixmaps appfiles.path = $$GTA5SYNC_PREFIX/share/applications
unix: !macx: pixmaps.files = $$PWD/res/gta5view.png appfiles.files = $$PWD/res/gta5view.desktop
unix: !macx: target.path = $$(INSTALL_PATH)/bin pixmaps.path = $$GTA5SYNC_PREFIX/share/pixmaps
unix: !macx: INSTALLS += target pixmaps appfiles pixmaps.files = $$PWD/res/gta5view.png
target.path = $$GTA5SYNC_PREFIX/bin
INSTALLS += target pixmaps appfiles
# QCONF BASED BUILD STUFF
contains(DEFINES, GTA5SYNC_QCONF){
isEqual(QT_MAJOR_VERSION, 4): RESOURCES -= res/tr_qt4.qrc
isEqual(QT_MAJOR_VERSION, 5): RESOURCES -= res/tr_qt5.qrc
!contains(DEFINES, GTA5SYNC_QCONF_IN){
RESOURCES -= res/tr_g5p.qrc
langfiles.path = $$GTA5SYNC_PREFIX/share/gta5view/translations
langfiles.files = $$PWD/res/gta5sync_en_US.qm $$PWD/res/gta5sync_de.qm $$PWD/res/gta5sync_fr.qm $$PWD/res/gta5sync_ru.qm $$PWD/res/qtbase_en_GB.qm
INSTALLS += langfiles
}
}

BIN
lang/gta5sync_no.qm Normal file

Binary file not shown.

1619
lang/gta5sync_no.ts Normal file

File diff suppressed because it is too large Load Diff

306
main.cpp
View File

@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#include "TranslationClass.h"
#include "SnapmaticPicture.h" #include "SnapmaticPicture.h"
#include "ProfileDatabase.h" #include "ProfileDatabase.h"
#include "DatabaseThread.h" #include "DatabaseThread.h"
@ -27,20 +28,17 @@
#include "IconLoader.h" #include "IconLoader.h"
#include "AppEnv.h" #include "AppEnv.h"
#include "config.h" #include "config.h"
#include <QDesktopWidget> #include <QStringBuilder>
#include <QApplication> #include <QApplication>
#include <QStringList> #include <QStringList>
#include <QTranslator> #include <QTranslator>
#include <QMessageBox>
#include <QFileInfo> #include <QFileInfo>
#include <QSysInfo> #include <QSysInfo>
#include <QRawFont>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QDebug> #include <QDebug>
#include <QFont> #include <QFont>
#include <QFile> #include <QFile>
#include <QDir>
#ifdef GTA5SYNC_WIN #ifdef GTA5SYNC_WIN
#include "windows.h" #include "windows.h"
@ -65,7 +63,7 @@ int main(int argc, char *argv[])
QString uiFontStr(QString::fromStdWString(std::wstring(uiFont.lfFaceName))); QString uiFontStr(QString::fromStdWString(std::wstring(uiFont.lfFaceName)));
#ifdef GTA5SYNC_DEBUG #ifdef GTA5SYNC_DEBUG
QMessageBox::information(a.desktop(), QApplication::tr("Font"), QApplication::tr("Selected Font: %1").arg(uiFontStr)); qDebug() << QApplication::tr("Font") << QApplication::tr("Selected Font: %1").arg(uiFontStr);
#endif #endif
// Set Application Font // Set Application Font
@ -81,298 +79,8 @@ int main(int argc, char *argv[])
a.addLibraryPath(pluginsDir); a.addLibraryPath(pluginsDir);
} }
// Loading translation settings TCInstance->initUserLanguage();
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); TCInstance->loadTranslation(&a);
settings.beginGroup("Interface");
QString language = settings.value("Language","System").toString();
settings.endGroup();
// Start external translate loading
QString langpath = AppEnv::getLangFolder();
bool trsf = false;
bool svlp = false;
QTranslator EappTranslator;
if (language == "System" || language.trimmed() == "")
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(langpath + QDir::separator() + "gta5sync_" + langList.at(0) + ".qm"))
{
EappTranslator.load(langpath + QDir::separator() + "/gta5sync_" + langList.at(0) + ".qm");
QLocale::setDefault(QLocale::system());
}
}
}
else
{
QString languageName = language;
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(langpath + QDir::separator() + "gta5sync_" + langList.at(0) + ".qm"))
{
if (!EappTranslator.load(langpath + QDir::separator() + "gta5sync_" + langList.at(0) + ".qm"))
{
if (langList.at(0) != "en")
{
trsf = true;
}
}
else
{
QLocale::setDefault(QLocale(langList.at(0)));
svlp = true;
}
}
else
{
if (langList.at(0) != "en")
{
trsf = true;
}
}
}
}
if (trsf)
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(langpath + QDir::separator() + "gta5sync_" + langList.at(0) + ".qm"))
{
EappTranslator.load(langpath + QDir::separator() + "gta5sync_" + langList.at(0) + ".qm");
QLocale::setDefault(QLocale(langList.at(0)));
}
}
}
a.installTranslator(&EappTranslator);
#if QT_VERSION >= 0x050000
QTranslator EqtTranslator1;
if (language == "System" || language.trimmed() == "")
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(langpath + QDir::separator() + "qtbase_" + langList.at(0) + ".qm"))
{
EqtTranslator1.load(langpath + QDir::separator() + "qtbase_" + langList.at(0) + ".qm");
}
}
}
else
{
QString languageName = language;
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(langpath + QDir::separator() + "qtbase_" + langList.at(0) + ".qm"))
{
EqtTranslator1.load(langpath + QDir::separator() + "qtbase_" + langList.at(0) + ".qm");
}
}
}
if (trsf)
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(langpath + QDir::separator() + "qtbase_" + langList.at(0) + ".qm"))
{
EqtTranslator1.load(langpath + QDir::separator() + "qtbase_" + langList.at(0) + ".qm");
}
}
}
a.installTranslator(&EqtTranslator1);
#else
QTranslator EqtTranslator;
if (language == "System" || language.trimmed() == "")
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(langpath + QDir::separator() + "qt_" + langList.at(0) + ".qm"))
{
EqtTranslator.load(langpath + QDir::separator() + "qt_" + langList.at(0) + ".qm");
}
}
}
else
{
QString languageName = language;
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(langpath + QDir::separator() + "qt_" + langList.at(0) + ".qm"))
{
EqtTranslator.load(langpath + QDir::separator() + "qt_" + langList.at(0) + ".qm");
}
}
}
if (trsf)
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(langpath + QDir::separator() + "qt_" + langList.at(0) + ".qm"))
{
EqtTranslator.load(langpath + QDir::separator() + "qt_" + langList.at(0) + ".qm");
}
}
}
a.installTranslator(&EqtTranslator);
#endif
// End external translate loading
// Start internal translate loading
QTranslator appTranslator;
trsf = false;
if (language == "System" || language.trimmed() == "")
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/gta5sync_" + langList.at(0) + ".qm"))
{
if (!appTranslator.load(":/tr/gta5sync_" + langList.at(0) + ".qm"))
{
if (langList.at(0) != "en")
{
if (svlp) { trsf = true; }
}
}
else
{
QLocale::setDefault(QLocale(langList.at(0)));
}
}
else
{
if (langList.at(0) != "en")
{
if (svlp) { trsf = true; }
}
}
}
}
else if (language == "en" || language == "English")
{
QLocale::setDefault(QLocale(QLocale::English, QLocale::AnyCountry));
}
else
{
QString languageName = language;
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/gta5sync_" + langList.at(0) + ".qm"))
{
appTranslator.load(":/tr/gta5sync_" + langList.at(0) + ".qm");
QLocale::setDefault(QLocale(langList.at(0)));
}
}
}
if (trsf)
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/gta5sync_" + langList.at(0) + ".qm"))
{
appTranslator.load(":/tr/gta5sync_" + langList.at(0) + ".qm");
QLocale::setDefault(QLocale(langList.at(0)));
}
}
}
a.installTranslator(&appTranslator);
#if QT_VERSION >= 0x050000
QTranslator qtTranslator1;
if (language == "System" || language.trimmed() == "")
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/qtbase_" + langList.at(0) + ".qm"))
{
qtTranslator1.load(":/tr/qtbase_" + langList.at(0) + ".qm");
}
}
}
else
{
QString languageName = language;
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/qtbase_" + langList.at(0) + ".qm"))
{
qtTranslator1.load(":/tr/qtbase_" + langList.at(0) + ".qm");
}
}
}
if (trsf)
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/qtbase_" + langList.at(0) + ".qm"))
{
qtTranslator1.load(":/tr/qtbase_" + langList.at(0) + ".qm");
}
}
}
a.installTranslator(&qtTranslator1);
#else
QTranslator qtTranslator1;
if (language == "System" || language.trimmed() == "")
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/qt_" + langList.at(0) + ".qm"))
{
qtTranslator1.load(":/tr/qt_" + langList.at(0) + ".qm");
}
}
}
else
{
QString languageName = language;
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/qt_" + langList.at(0) + ".qm"))
{
qtTranslator1.load(":/tr/qt_" + langList.at(0) + ".qm");
}
}
}
if (trsf)
{
QString languageName = QLocale::system().name();
QStringList langList = languageName.split("_");
if (langList.length() >= 1)
{
if (QFile::exists(":/tr/qt_" + langList.at(0) + ".qm"))
{
qtTranslator1.load(":/tr/qt_" + langList.at(0) + ".qm");
}
}
}
a.installTranslator(&qtTranslator1);
#endif
// End internal translate loading
QStringList applicationArgs = a.arguments(); QStringList applicationArgs = a.arguments();
QString selectedAction; QString selectedAction;
@ -440,6 +148,8 @@ int main(int argc, char *argv[])
if (!readOk) { return 1; } if (!readOk) { return 1; }
QEventLoop threadLoop; QEventLoop threadLoop;
QObject::connect(&threadDB, SIGNAL(crewNameFound(int, QString)), &crewDB, SLOT(setCrewName(int, QString)));
QObject::connect(&threadDB, SIGNAL(crewNameUpdated()), &picDialog, SLOT(crewNameUpdated()));
QObject::connect(&threadDB, SIGNAL(playerNameFound(int, QString)), &profileDB, SLOT(setPlayerName(int, QString))); QObject::connect(&threadDB, SIGNAL(playerNameFound(int, QString)), &profileDB, SLOT(setPlayerName(int, QString)));
QObject::connect(&threadDB, SIGNAL(playerNameUpdated()), &picDialog, SLOT(playerNameUpdated())); QObject::connect(&threadDB, SIGNAL(playerNameUpdated()), &picDialog, SLOT(playerNameUpdated()));
QObject::connect(&threadDB, SIGNAL(finished()), &threadLoop, SLOT(quit())); QObject::connect(&threadDB, SIGNAL(finished()), &threadLoop, SLOT(quit()));
@ -473,6 +183,7 @@ int main(int argc, char *argv[])
DatabaseThread threadDB(&crewDB); DatabaseThread threadDB(&crewDB);
QEventLoop threadLoop; QEventLoop threadLoop;
QObject::connect(&threadDB, SIGNAL(crewNameFound(int,QString)), &crewDB, SLOT(setCrewName(int, QString)));
QObject::connect(&threadDB, SIGNAL(playerNameFound(int, QString)), &profileDB, SLOT(setPlayerName(int, QString))); QObject::connect(&threadDB, SIGNAL(playerNameFound(int, QString)), &profileDB, SLOT(setPlayerName(int, QString)));
QObject::connect(&threadDB, SIGNAL(finished()), &threadLoop, SLOT(quit())); QObject::connect(&threadDB, SIGNAL(finished()), &threadLoop, SLOT(quit()));
threadDB.start(); threadDB.start();
@ -490,4 +201,3 @@ int main(int argc, char *argv[])
return 0; return 0;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -16,6 +16,11 @@
<file>empty1x16.png</file> <file>empty1x16.png</file>
<file>avatararea.png</file> <file>avatararea.png</file>
<file>avatarareaimport.png</file> <file>avatarareaimport.png</file>
<file>mappreview.jpg</file>
<file>pointmaker-8.png</file>
<file>pointmaker-16.png</file>
<file>pointmaker-24.png</file>
<file>pointmaker-32.png</file>
</qresource> </qresource>
<qresource prefix="/global"> <qresource prefix="/global">
<file>global.de.ini</file> <file>global.de.ini</file>

View File

@ -7,8 +7,8 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gta5view.exe.manifest"
#include <windows.h> #include <windows.h>
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1, 4, 4, 0 FILEVERSION 1, 5, 0, 0
PRODUCTVERSION 1, 4, 4, 0 PRODUCTVERSION 1, 5, 0, 0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
FILEFLAGS 0 FILEFLAGS 0
FILEOS VOS_NT_WINDOWS32 FILEOS VOS_NT_WINDOWS32
@ -25,12 +25,12 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Syping" VALUE "CompanyName", "Syping"
VALUE "FileDescription", "gta5view\0" VALUE "FileDescription", "gta5view\0"
VALUE "FileVersion", "1.4.4\0" VALUE "FileVersion", "1.5.0\0"
VALUE "InternalName", "gta5view\0" VALUE "InternalName", "gta5view\0"
VALUE "LegalCopyright", "Copyright © 2016-2017 Syping\0" VALUE "LegalCopyright", "Copyright © 2016-2017 Syping\0"
VALUE "OriginalFilename", "gta5view.exe\0" VALUE "OriginalFilename", "gta5view.exe\0"
VALUE "ProductName", "gta5view\0" VALUE "ProductName", "gta5view\0"
VALUE "ProductVersion", "1.4.4\0" VALUE "ProductVersion", "1.5.0\0"
END END
END END
END END

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
res/gta5sync_en_US.qm Normal file

Binary file not shown.

1619
res/gta5sync_en_US.ts Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
res/mappreview.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

BIN
res/pointmaker-16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

BIN
res/pointmaker-24.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

BIN
res/pointmaker-32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

BIN
res/pointmaker-8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

BIN
res/qtbase_en_GB.qm Normal file

Binary file not shown.

View File

@ -1,5 +1,6 @@
<RCC> <RCC>
<qresource prefix="/tr"> <qresource prefix="/tr">
<file>gta5sync_en_US.qm</file>
<file>gta5sync_de.qm</file> <file>gta5sync_de.qm</file>
<file>gta5sync_fr.qm</file> <file>gta5sync_fr.qm</file>
<file>gta5sync_ru.qm</file> <file>gta5sync_ru.qm</file>

View File

@ -1,5 +1,6 @@
<RCC> <RCC>
<qresource prefix="/tr"> <qresource prefix="/tr">
<file>qtbase_en_GB.qm</file>
<file>qtbase_de.qm</file> <file>qtbase_de.qm</file>
<file>qtbase_fr.qm</file> <file>qtbase_fr.qm</file>
<file>qtbase_ru.qm</file> <file>qtbase_ru.qm</file>