latest changes from gta5sync
This commit is contained in:
parent
69777a0263
commit
0069bb0b95
128 changed files with 20971 additions and 15661 deletions
.gitattributes.travis.ymlAboutDialog.cppAppEnv.cppAppEnv.hCrewDatabase.cppCrewDatabase.hDatabaseThread.cppDatabaseThread.hExportThread.cppGlobalString.cppIconLoader.cppIconLoader.hImportDialog.cppImportDialog.hImportDialog.uiMapPreviewDialog.cppMapPreviewDialog.hMapPreviewDialog.uiOptionsDialog.cppOptionsDialog.uiPictureDialog.cppPictureDialog.hPictureDialog.uiPictureExport.cppProfileDatabase.cppProfileDatabase.hProfileInterface.cppProfileInterface.hProfileInterface.uiProfileLoader.cppProfileWidget.cppProfileWidget.hSavegameData.cppSavegameDialog.uiSavegameWidget.cppSavegameWidget.hSidebarGenerator.cppSnapmaticEditor.cppSnapmaticPicture.cppSnapmaticPicture.hSnapmaticWidget.cppSnapmaticWidget.hStringParser.cppTranslationClass.cppTranslationClass.hUserInterface.cppUserInterface.hUserInterface.uiconfig.hgta5view.pro
lang
main.cppres
27
.gitattributes
vendored
Normal file
27
.gitattributes
vendored
Normal 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
|
27
.travis.yml
27
.travis.yml
|
@ -4,7 +4,7 @@ sudo: required
|
|||
language: cpp
|
||||
|
||||
env:
|
||||
- PACKAGE_VERSION="1.4.0"
|
||||
- PACKAGE_VERSION="1.5.0"
|
||||
|
||||
before_install:
|
||||
- test -n $CC && unset CC
|
||||
|
@ -12,27 +12,42 @@ before_install:
|
|||
|
||||
install:
|
||||
- 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:
|
||||
- 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
|
||||
- echo "gta5view build version is $APPLICATION_VERSION"
|
||||
- mkdir build
|
||||
- mkdir package
|
||||
- chmod -x res/gta5sync_*.qm res/gta5view.desktop res/gta5view.png
|
||||
- cd build
|
||||
- mkdir qt4
|
||||
- cd qt4
|
||||
- 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:
|
||||
- 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
|
||||
- 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:
|
||||
provider: releases
|
||||
api_key:
|
||||
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
|
||||
on:
|
||||
tags: true
|
||||
|
|
|
@ -31,26 +31,30 @@ AboutDialog::AboutDialog(QWidget *parent) :
|
|||
|
||||
// Build Strings
|
||||
QString appVersion = qApp->applicationVersion();
|
||||
QString buildType = GTA5SYNC_BUILDTYPE;
|
||||
QString buildType = tr(GTA5SYNC_BUILDTYPE);
|
||||
buildType.replace("_", " ");
|
||||
QString projectBuild = GTA5SYNC_BUILDDATETIME;
|
||||
QString buildStr = GTA5SYNC_BUILDSTRING;
|
||||
|
||||
// Additional Content
|
||||
QString usingStr = tr("Using %1 %2", "Exp. Using libmyfuck");
|
||||
QString translatedByStr = tr("Translated by %1", "Exp. Translated by Syping");
|
||||
QString translatedByVal = tr("NAME_OF_TRANSLATOR", "Your Name (The person behind your screen looking at this text!)");
|
||||
QString translatorProfile = tr("TRANSLATOR_PROFILE", "mailto: http:// https:// Exp. https://github.com/Syping/");
|
||||
// Translator Comments
|
||||
//: Using specific library, example Using libmyfuck
|
||||
QString usingStr = tr("Using %1 %2");
|
||||
//: Translated by translator, example Translated by 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 = "";
|
||||
if (translatedByVal != "NAME_OF_TRANSLATOR")
|
||||
{
|
||||
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
|
||||
{
|
||||
additionalContent.append(translatedByStr.arg(translatedByVal));
|
||||
additionalContent += translatedByStr.arg(translatedByVal);
|
||||
}
|
||||
}
|
||||
#ifdef WITH_LIBJPEGTURBO // DONT USE IT FOR NOW
|
||||
|
@ -58,12 +62,12 @@ AboutDialog::AboutDialog(QWidget *parent) :
|
|||
if (!additionalContent.isEmpty())
|
||||
{
|
||||
additionalContentClip = true;
|
||||
additionalContent.append(" (");
|
||||
additionalContent += " (";
|
||||
}
|
||||
additionalContent.append(usingStr.arg("libjpegturbo", WITH_LIBJPEGTURBO));
|
||||
additionalContent += usingStr.arg("libjpegturbo", WITH_LIBJPEGTURBO);
|
||||
if (additionalContentClip)
|
||||
{
|
||||
additionalContent.append(")");
|
||||
additionalContent += ")";
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(usingStr)
|
||||
|
|
31
AppEnv.cpp
31
AppEnv.cpp
|
@ -21,6 +21,7 @@
|
|||
#include "StringParser.h"
|
||||
#include "StandardPaths.h"
|
||||
#include <QtGlobal>
|
||||
#include <QStringBuilder>
|
||||
#include <QDesktopWidget>
|
||||
#include <QApplication>
|
||||
#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;
|
||||
|
||||
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
|
||||
|
@ -108,14 +109,31 @@ bool AppEnv::setGameFolder(QString gameFolder)
|
|||
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()
|
||||
{
|
||||
return StringParser::convertBuildedString(QString::fromUtf8(GTA5SYNC_PLUG));
|
||||
return StringParser::convertBuildedString(GTA5SYNC_PLUG);
|
||||
}
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
QUrl AppEnv::getPlayerFetchingUrl(QString crewID, int pageNumber)
|
||||
{
|
||||
return getPlayerFetchingUrl(crewID, QString::number(pageNumber));
|
||||
}
|
||||
|
||||
qreal AppEnv::screenRatio()
|
||||
{
|
||||
#if QT_VERSION >= 0x050000
|
||||
|
|
4
AppEnv.h
4
AppEnv.h
|
@ -30,13 +30,15 @@ public:
|
|||
// Folder Stuff
|
||||
static QString getGameFolder(bool *ok = 0);
|
||||
static bool setGameFolder(QString gameFolder);
|
||||
static QString getLangFolder();
|
||||
static QString getExLangFolder();
|
||||
static QString getInLangFolder();
|
||||
static QString getPluginsFolder();
|
||||
|
||||
// Web Stuff
|
||||
static QByteArray getUserAgent();
|
||||
static QUrl getCrewFetchingUrl(QString crewID);
|
||||
static QUrl getPlayerFetchingUrl(QString crewID, QString pageNumber);
|
||||
static QUrl getPlayerFetchingUrl(QString crewID, int pageNumber);
|
||||
|
||||
// Screen Stuff
|
||||
static qreal screenRatio();
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
#include "StandardPaths.h"
|
||||
#include "CrewDatabase.h"
|
||||
#include "config.h"
|
||||
#include <QStringBuilder>
|
||||
#include <QMutexLocker>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
|
||||
|
@ -28,7 +31,7 @@ CrewDatabase::CrewDatabase(QObject *parent) : QObject(parent)
|
|||
dir.mkpath(StandardPaths::dataLocation());
|
||||
dir.setPath(StandardPaths::dataLocation());
|
||||
QString dirPath = dir.absolutePath();
|
||||
QString defaultConfPath = dirPath + QDir::separator() + "crews.ini";
|
||||
QString defaultConfPath = dirPath % QDir::separator() % "crews.ini";
|
||||
|
||||
QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
|
||||
confPathSettings.beginGroup("Database");
|
||||
|
@ -37,6 +40,8 @@ CrewDatabase::CrewDatabase(QObject *parent) : QObject(parent)
|
|||
|
||||
crewDB = new QSettings(confPathFile, QSettings::IniFormat);
|
||||
crewDB->beginGroup("Crews");
|
||||
|
||||
addProcess = false;
|
||||
}
|
||||
|
||||
CrewDatabase::~CrewDatabase()
|
||||
|
@ -47,19 +52,52 @@ CrewDatabase::~CrewDatabase()
|
|||
|
||||
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->beginGroup("CrewList");
|
||||
QStringList crewIDs = crewDB->value("IDs", QStringList()).toStringList();
|
||||
crewIDs.append(compatibleCrewList);
|
||||
crewIDs += compatibleCrewList;
|
||||
crewIDs.removeDuplicates();
|
||||
crewDB->endGroup();
|
||||
crewDB->beginGroup("Crews");
|
||||
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)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
#ifdef GTA5SYNC_DEBUG
|
||||
qDebug() << "getCrewName" << crewID;
|
||||
#endif
|
||||
QString crewStr = crewDB->value(QString::number(crewID), crewID).toString();
|
||||
if (crewID == 0) crewStr = tr("No Crew", "");
|
||||
return crewStr;
|
||||
|
@ -67,13 +105,21 @@ QString CrewDatabase::getCrewName(int crewID)
|
|||
|
||||
void CrewDatabase::setCrewName(int crewID, QString crewName)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
#ifdef GTA5SYNC_DEBUG
|
||||
qDebug() << "setCrewName" << crewID << crewName;
|
||||
#endif
|
||||
crewDB->setValue(QString::number(crewID), crewName);
|
||||
}
|
||||
|
||||
void CrewDatabase::addCrew(int crewID)
|
||||
{
|
||||
QStringList crews = getCrews();
|
||||
crews.append(QString::number(crewID));
|
||||
QMutexLocker locker(&mutex);
|
||||
#ifdef GTA5SYNC_DEBUG
|
||||
qDebug() << "addCrew" << crewID;
|
||||
#endif
|
||||
QStringList crews = getCrews_p();
|
||||
crews += QString::number(crewID);
|
||||
crews.removeDuplicates();
|
||||
crewDB->endGroup();
|
||||
crewDB->beginGroup("CrewList");
|
||||
|
@ -81,3 +127,39 @@ void CrewDatabase::addCrew(int crewID)
|
|||
crewDB->endGroup();
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <QSettings>
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
#include <QMap>
|
||||
|
||||
class CrewDatabase : public QObject
|
||||
|
@ -28,15 +29,24 @@ class CrewDatabase : public QObject
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit CrewDatabase(QObject *parent = 0);
|
||||
void setCrewName(int crewID, QString crewName);
|
||||
QString getCrewName(int crewID);
|
||||
QStringList getCompatibleCrews();
|
||||
QStringList getCrews();
|
||||
void setAddingCrews(bool addingCrews);
|
||||
bool isCompatibleCrew(QString crewNID);
|
||||
bool isCompatibleCrew(int crewID);
|
||||
bool isAddingCrews();
|
||||
~CrewDatabase();
|
||||
|
||||
private:
|
||||
mutable QMutex mutex;
|
||||
bool addProcess;
|
||||
QSettings *crewDB;
|
||||
QStringList getCrews_p();
|
||||
QStringList getCompatibleCrews_p();
|
||||
|
||||
public slots:
|
||||
void setCrewName(int crewID, QString crewName);
|
||||
void addCrew(int crewID);
|
||||
};
|
||||
|
||||
|
|
|
@ -31,46 +31,87 @@
|
|||
#include <QDebug>
|
||||
#include <QUrl>
|
||||
|
||||
#define crewMaxPages 83
|
||||
|
||||
DatabaseThread::DatabaseThread(CrewDatabase *crewDB, QObject *parent) : QThread(parent), crewDB(crewDB)
|
||||
{
|
||||
crewMaxPages = 83;
|
||||
threadRunning = true;
|
||||
}
|
||||
|
||||
void DatabaseThread::run()
|
||||
{
|
||||
QEventLoop threadLoop;
|
||||
|
||||
QStringList crewList;
|
||||
QStringList crewListR;
|
||||
|
||||
// Register thread loop end signal
|
||||
QObject::connect(this, SIGNAL(threadEndCommited()), &threadLoop, SLOT(quit()));
|
||||
|
||||
// Setup crewList for Quick time scan
|
||||
crewList = crewDB->getCrews();
|
||||
if (!crewList.isEmpty())
|
||||
{
|
||||
crewListR = deleteCompatibleCrews(crewList);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (crewList.isEmpty() && threadRunning)
|
||||
{
|
||||
QTimer::singleShot(1000, &threadLoop, SLOT(quit()));
|
||||
threadLoop.exec();
|
||||
if (!crewDB->isAddingCrews())
|
||||
{
|
||||
crewList = crewDB->getCrews();
|
||||
}
|
||||
}
|
||||
if (threadRunning)
|
||||
{
|
||||
crewListR = deleteCompatibleCrews(crewList);
|
||||
}
|
||||
}
|
||||
|
||||
// Only do QTS when Thread should be run
|
||||
if (threadRunning)
|
||||
{
|
||||
// Quick time scan
|
||||
#ifdef GTA5SYNC_DEBUG
|
||||
qDebug() << "Start QTS";
|
||||
#endif
|
||||
if (crewListR.length() <= 5)
|
||||
{
|
||||
scanCrewReference(crewListR, 2500);
|
||||
emit crewNameUpdated();
|
||||
}
|
||||
if (crewList.length() <= 3)
|
||||
{
|
||||
scanCrewReference(crewList, 2500);
|
||||
scanCrewMembersList(crewList, 3, 2500);
|
||||
emit playerNameUpdated();
|
||||
}
|
||||
else if (crewList.length() <= 5)
|
||||
{
|
||||
scanCrewReference(crewList, 2500);
|
||||
scanCrewMembersList(crewList, 2, 2500);
|
||||
emit playerNameUpdated();
|
||||
}
|
||||
|
||||
QEventLoop *waitingLoop = new QEventLoop();
|
||||
QTimer::singleShot(10000, waitingLoop, SLOT(quit()));
|
||||
QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
|
||||
waitingLoop->exec();
|
||||
delete waitingLoop;
|
||||
if (threadRunning)
|
||||
{
|
||||
QTimer::singleShot(10000, &threadLoop, SLOT(quit()));
|
||||
threadLoop.exec();
|
||||
}
|
||||
}
|
||||
|
||||
while (threadRunning)
|
||||
{
|
||||
crewList = crewDB->getCrews();
|
||||
crewListR = deleteCompatibleCrews(crewList);
|
||||
|
||||
// Long time scan
|
||||
scanCrewReference(crewList, 10000);
|
||||
#ifdef GTA5SYNC_DEBUG
|
||||
qDebug() << "Start LTS";
|
||||
#endif
|
||||
scanCrewReference(crewListR, 10000);
|
||||
emit crewNameUpdated();
|
||||
scanCrewMembersList(crewList, crewMaxPages, 10000);
|
||||
emit playerNameUpdated();
|
||||
|
||||
|
@ -82,81 +123,7 @@ void DatabaseThread::run()
|
|||
}
|
||||
}
|
||||
|
||||
// void DatabaseThread::scanCrewReference(QStringList crewList, 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)
|
||||
void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &requestDelay)
|
||||
{
|
||||
foreach (const QString &crewID, crewList)
|
||||
{
|
||||
|
@ -197,7 +164,7 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
|
|||
}
|
||||
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)
|
||||
{
|
||||
|
@ -227,7 +194,7 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
|
|||
{
|
||||
QNetworkAccessManager *netManager = new QNetworkAccessManager();
|
||||
|
||||
QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, QString::number(currentPage)));
|
||||
QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, currentPage));
|
||||
#if QT_VERSION >= 0x050600
|
||||
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||
#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()
|
||||
{
|
||||
threadRunning = false;
|
||||
|
|
|
@ -34,16 +34,18 @@ public slots:
|
|||
|
||||
private:
|
||||
CrewDatabase *crewDB;
|
||||
void scanCrewMembersList(QStringList crewList, int maxPages, int requestDelay);
|
||||
void scanCrewReference(QStringList crewList, int requestDelay);
|
||||
void scanCrewMembersList(const QStringList &crewList, const int &maxPages, const int &requestDelay);
|
||||
void scanCrewReference(const QStringList &crewList, const int &requestDelay);
|
||||
QStringList deleteCompatibleCrews(const QStringList &crewList);
|
||||
bool threadRunning;
|
||||
int crewMaxPages;
|
||||
int plyrPerReq;
|
||||
|
||||
protected:
|
||||
void run();
|
||||
|
||||
signals:
|
||||
void crewNameFound(int crewID, QString crewName);
|
||||
void crewNameUpdated();
|
||||
void playerNameFound(int playerID, QString playerName);
|
||||
void playerNameUpdated();
|
||||
void threadEndCommited();
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "ExportThread.h"
|
||||
#include "SavegameData.h"
|
||||
#include "config.h"
|
||||
#include <QStringBuilder>
|
||||
#include <QDesktopWidget>
|
||||
#include <QApplication>
|
||||
#include <QFileInfo>
|
||||
|
@ -81,7 +82,7 @@ void ExportThread::run()
|
|||
{
|
||||
if (widget->getWidgetType() == "SnapmaticWidget")
|
||||
{
|
||||
SnapmaticWidget *picWidget = (SnapmaticWidget*)widget;
|
||||
SnapmaticWidget *picWidget = qobject_cast<SnapmaticWidget*>(widget);
|
||||
SnapmaticPicture *picture = picWidget->getPicture();
|
||||
|
||||
if (pictureExportEnabled)
|
||||
|
@ -89,7 +90,7 @@ void ExportThread::run()
|
|||
QString exportFileName = PictureExport::getPictureFileName(picture);
|
||||
if (exportFileName.right(4) != ".jpg" && exportFileName.right(4) != ".png")
|
||||
{
|
||||
exportFileName.append(".jpg");
|
||||
exportFileName += ".jpg";
|
||||
}
|
||||
|
||||
intExportProgress++;
|
||||
|
@ -100,7 +101,7 @@ void ExportThread::run()
|
|||
QImage exportPicture = picture->getImage();
|
||||
if (sizeMode == "Desktop")
|
||||
{
|
||||
QRect desktopResolution = QApplication::desktop()->screenGeometry();
|
||||
QRect desktopResolution = qApp->desktop()->screenGeometry();
|
||||
exportPicture = exportPicture.scaled(desktopResolution.width(), desktopResolution.height(), aspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
else if (sizeMode == "Custom")
|
||||
|
@ -111,16 +112,16 @@ void ExportThread::run()
|
|||
bool isSaved;
|
||||
if (useCustomQuality)
|
||||
{
|
||||
isSaved = exportPicture.save(exportDirectory + "/" + exportFileName, "JPEG", customQuality);
|
||||
isSaved = exportPicture.save(exportDirectory % "/" % exportFileName, "JPEG", customQuality);
|
||||
}
|
||||
else
|
||||
{
|
||||
isSaved = exportPicture.save(exportDirectory + "/" + exportFileName, "JPEG", 100);
|
||||
isSaved = exportPicture.save(exportDirectory % "/" % exportFileName, "JPEG", 100);
|
||||
}
|
||||
|
||||
if (!isSaved)
|
||||
{
|
||||
failedExportPictures.append(exportFileName);
|
||||
failedExportPictures += exportFileName;
|
||||
}
|
||||
}
|
||||
if (pictureCopyEnabled)
|
||||
|
@ -128,24 +129,24 @@ void ExportThread::run()
|
|||
QString exportFileName = PictureExport::getPictureFileName(picture);
|
||||
if (exportFileName.right(4) != ".g5e")
|
||||
{
|
||||
exportFileName.append(".g5e");
|
||||
exportFileName += ".g5e";
|
||||
}
|
||||
|
||||
intExportProgress++;
|
||||
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
|
||||
emit exportProgressUpdate(intExportProgress);
|
||||
|
||||
QString exportFilePath = exportDirectory + "/" + exportFileName;
|
||||
QString exportFilePath = exportDirectory % "/" % exportFileName;
|
||||
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")
|
||||
{
|
||||
SavegameWidget *sgdWidget = (SavegameWidget*)widget;
|
||||
SavegameWidget *sgdWidget = qobject_cast<SavegameWidget*>(widget);
|
||||
SavegameData *savegame = sgdWidget->getSavegame();
|
||||
|
||||
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 exportProgressUpdate(intExportProgress);
|
||||
|
||||
QString exportFilePath = exportDirectory + "/" + exportFileName;
|
||||
QString exportFilePath = exportDirectory % "/" % exportFileName;
|
||||
if (QFile::exists(exportFilePath)) {QFile::remove(exportFilePath);}
|
||||
if (!QFile::copy(originalFileName, exportFilePath))
|
||||
{
|
||||
failedSavegames.append(exportFileName);
|
||||
failedSavegames += exportFileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,12 +16,15 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <QLocale>
|
||||
#include <QSettings>
|
||||
#include <QFileInfo>
|
||||
#include <QStringList>
|
||||
#include "TranslationClass.h"
|
||||
#include "GlobalString.h"
|
||||
#include "config.h"
|
||||
#include <QStringBuilder>
|
||||
#include <QStringList>
|
||||
#include <QFileInfo>
|
||||
#include <QSettings>
|
||||
#include <QLocale>
|
||||
#include <QDebug>
|
||||
|
||||
GlobalString::GlobalString()
|
||||
{
|
||||
|
@ -52,7 +55,7 @@ QString GlobalString::getString(QString valueStr, bool *ok)
|
|||
QStringList globalStrList = globalFile.childKeys();
|
||||
if (globalStrList.contains(valueStr))
|
||||
{
|
||||
if (ok != 0) *ok = true;
|
||||
if (ok != NULL) *ok = true;
|
||||
globalString = globalFile.value(valueStr, valueStr).toString();
|
||||
}
|
||||
globalFile.endGroup();
|
||||
|
@ -62,7 +65,7 @@ QString GlobalString::getString(QString valueStr, bool *ok)
|
|||
QString GlobalString::getLanguageFile()
|
||||
{
|
||||
QString language = getLanguage();
|
||||
QString languageFile = ":/global/global." + language + ".ini";
|
||||
QString languageFile = ":/global/global." % language % ".ini";
|
||||
if (!QFileInfo(languageFile).exists())
|
||||
{
|
||||
languageFile = ":/global/global.en.ini";
|
||||
|
@ -72,18 +75,11 @@ QString GlobalString::getLanguageFile()
|
|||
|
||||
QString GlobalString::getLanguage()
|
||||
{
|
||||
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
|
||||
settings.beginGroup("Interface");
|
||||
QString language = settings.value("Language","System").toString();
|
||||
settings.endGroup();
|
||||
if (language == "System" || language.trimmed() == "")
|
||||
{
|
||||
QString languageName = QLocale::system().name();
|
||||
QStringList langList = languageName.split("_");
|
||||
QString language = TCInstance->getCurrentLanguage();
|
||||
QStringList langList = QString(language).replace("-", "_").split("_");
|
||||
if (langList.length() >= 1)
|
||||
{
|
||||
language = langList.at(0);
|
||||
}
|
||||
}
|
||||
return language;
|
||||
}
|
||||
|
|
|
@ -38,3 +38,13 @@ QIcon IconLoader::loadingAppIcon()
|
|||
appIcon.addFile(":/img/5sync-256.png", QSize(256, 256));
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ class IconLoader
|
|||
public:
|
||||
IconLoader();
|
||||
static QIcon loadingAppIcon();
|
||||
static QIcon loadingPointmakerIcon();
|
||||
};
|
||||
|
||||
#endif // ICONLOADER_H
|
||||
|
|
|
@ -19,10 +19,13 @@
|
|||
#include "ImportDialog.h"
|
||||
#include "ui_ImportDialog.h"
|
||||
#include "AppEnv.h"
|
||||
#include <QColorDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QImage>
|
||||
#include <QDebug>
|
||||
#include <QRgb>
|
||||
|
||||
// IMAGES VALUES
|
||||
#define snapmaticResolutionW 960
|
||||
|
@ -36,8 +39,10 @@ ImportDialog::ImportDialog(QWidget *parent) :
|
|||
ui(new Ui::ImportDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
doImport = false;
|
||||
importAgreed = false;
|
||||
insideAvatarZone = false;
|
||||
avatarAreaImage = QImage(":/img/avatarareaimport.png");
|
||||
selectedColour = QColor::fromRgb(0, 0, 0, 255);
|
||||
|
||||
if (QIcon::hasThemeIcon("dialog-ok"))
|
||||
{
|
||||
|
@ -48,7 +53,8 @@ ImportDialog::ImportDialog(QWidget *parent) :
|
|||
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();
|
||||
snapmaticResolutionLW = 430 * screenRatio;
|
||||
|
@ -69,14 +75,14 @@ void ImportDialog::processImage()
|
|||
{
|
||||
QImage snapmaticImage = workImage;
|
||||
QPixmap snapmaticPixmap(snapmaticResolutionW, snapmaticResolutionH);
|
||||
snapmaticPixmap.fill(Qt::black);
|
||||
snapmaticPixmap.fill(selectedColour);
|
||||
QPainter snapmaticPainter(&snapmaticPixmap);
|
||||
if (ui->cbAvatar->isChecked())
|
||||
if (insideAvatarZone)
|
||||
{
|
||||
// Avatar mode
|
||||
int diffWidth = 0;
|
||||
int diffHeight = 0;
|
||||
if (ui->rbKeep->isChecked())
|
||||
if (!ui->cbIgnore->isChecked())
|
||||
{
|
||||
snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
if (snapmaticImage.width() > snapmaticImage.height())
|
||||
|
@ -102,7 +108,7 @@ void ImportDialog::processImage()
|
|||
// Picture mode
|
||||
int diffWidth = 0;
|
||||
int diffHeight = 0;
|
||||
if (ui->rbKeep->isChecked())
|
||||
if (!ui->cbIgnore->isChecked())
|
||||
{
|
||||
snapmaticImage = snapmaticImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
if (snapmaticImage.width() != snapmaticResolutionW)
|
||||
|
@ -138,14 +144,15 @@ void ImportDialog::setImage(const QImage &image_)
|
|||
workImage = image_;
|
||||
if (workImage.width() == workImage.height())
|
||||
{
|
||||
insideAvatarZone = true;
|
||||
ui->cbAvatar->setChecked(true);
|
||||
}
|
||||
processImage();
|
||||
}
|
||||
|
||||
bool ImportDialog::isDoImport()
|
||||
bool ImportDialog::isImportAgreed()
|
||||
{
|
||||
return doImport;
|
||||
return importAgreed;
|
||||
}
|
||||
|
||||
QString ImportDialog::getImageTitle()
|
||||
|
@ -153,18 +160,24 @@ QString ImportDialog::getImageTitle()
|
|||
return imageTitle;
|
||||
}
|
||||
|
||||
void ImportDialog::on_rbIgnore_clicked()
|
||||
void ImportDialog::on_cbIgnore_toggled(bool checked)
|
||||
{
|
||||
Q_UNUSED(checked)
|
||||
processImage();
|
||||
}
|
||||
|
||||
void ImportDialog::on_rbKeep_clicked()
|
||||
void ImportDialog::on_cbAvatar_toggled(bool checked)
|
||||
{
|
||||
processImage();
|
||||
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;
|
||||
}
|
||||
|
||||
void ImportDialog::on_cbAvatar_clicked()
|
||||
{
|
||||
}
|
||||
insideAvatarZone = ui->cbAvatar->isChecked();
|
||||
processImage();
|
||||
}
|
||||
|
||||
|
@ -175,16 +188,32 @@ void ImportDialog::on_cmdCancel_clicked()
|
|||
|
||||
void ImportDialog::on_cmdOK_clicked()
|
||||
{
|
||||
doImport = true;
|
||||
importAgreed = true;
|
||||
close();
|
||||
}
|
||||
|
||||
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);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,16 +35,16 @@ public:
|
|||
QImage image();
|
||||
QString getImageTitle();
|
||||
void setImage(const QImage &image);
|
||||
bool isDoImport();
|
||||
bool isImportAgreed();
|
||||
|
||||
private slots:
|
||||
void processImage();
|
||||
void on_rbIgnore_clicked();
|
||||
void on_rbKeep_clicked();
|
||||
void on_cbAvatar_clicked();
|
||||
void on_cbIgnore_toggled(bool checked);
|
||||
void on_cbAvatar_toggled(bool checked);
|
||||
void on_cmdCancel_clicked();
|
||||
void on_cmdOK_clicked();
|
||||
void on_labPicture_labelPainted();
|
||||
void on_cmdColourChange_clicked();
|
||||
|
||||
private:
|
||||
Ui::ImportDialog *ui;
|
||||
|
@ -52,7 +52,9 @@ private:
|
|||
QString imageTitle;
|
||||
QImage workImage;
|
||||
QImage newImage;
|
||||
bool doImport;
|
||||
QColor selectedColour;
|
||||
bool insideAvatarZone;
|
||||
bool importAgreed;
|
||||
int snapmaticResolutionLW;
|
||||
int snapmaticResolutionLH;
|
||||
};
|
||||
|
|
|
@ -89,28 +89,68 @@
|
|||
<property name="title">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gdSettings">
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="rbKeep">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="hlColor">
|
||||
<item>
|
||||
<widget class="QLabel" name="labColour">
|
||||
<property name="text">
|
||||
<string>&Keep Aspect Ratio</string>
|
||||
<string>Background Colour: <span style="color: %1">%1</span></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QRadioButton" name="rbIgnore">
|
||||
<item>
|
||||
<widget class="QToolButton" name="cmdColourChange">
|
||||
<property name="text">
|
||||
<string>&Ignore Aspect Ratio</string>
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<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>
|
||||
<layout class="QHBoxLayout" name="hlCheckboxes">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbAvatar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Avatar</string>
|
||||
<string>Avatar</string>
|
||||
</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>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -150,6 +190,9 @@
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Import picture</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
|
@ -163,6 +206,9 @@
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Discard picture</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
|
@ -179,7 +225,13 @@
|
|||
<customwidget>
|
||||
<class>UiModLabel</class>
|
||||
<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>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
|
76
MapPreviewDialog.cpp
Normal file
76
MapPreviewDialog.cpp
Normal 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
41
MapPreviewDialog.h
Normal 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
71
MapPreviewDialog.ui
Normal 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>
|
|
@ -18,10 +18,12 @@
|
|||
|
||||
#include "OptionsDialog.h"
|
||||
#include "ui_OptionsDialog.h"
|
||||
#include "TranslationClass.h"
|
||||
#include "StandardPaths.h"
|
||||
#include "UserInterface.h"
|
||||
#include "AppEnv.h"
|
||||
#include "config.h"
|
||||
#include <QStringBuilder>
|
||||
#include <QDesktopWidget>
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
|
@ -45,7 +47,7 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
|
|||
ui->tabWidget->setCurrentIndex(0);
|
||||
ui->labPicCustomRes->setVisible(false);
|
||||
|
||||
QRect desktopResolution = QApplication::desktop()->screenGeometry(parent);
|
||||
QRect desktopResolution = qApp->desktop()->screenGeometry(parent);
|
||||
int desktopSizeWidth = desktopResolution.width();
|
||||
int desktopSizeHeight = desktopResolution.height();
|
||||
aspectRatio = Qt::KeepAspectRatio;
|
||||
|
@ -115,7 +117,7 @@ void OptionsDialog::setupTreeWidget()
|
|||
|
||||
QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList);
|
||||
ui->twPlayers->addTopLevelItem(playerItem);
|
||||
playerItems.append(playerItem);
|
||||
playerItems += playerItem;
|
||||
}
|
||||
}
|
||||
ui->twPlayers->sortItems(1, Qt::AscendingOrder);
|
||||
|
@ -127,47 +129,25 @@ void OptionsDialog::setupLanguageBox()
|
|||
currentLanguage = settings->value("Language","System").toString();
|
||||
settings->endGroup();
|
||||
|
||||
QStringList langList = QLocale::system().name().split("_");
|
||||
if (langList.length() > 0)
|
||||
{
|
||||
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()));
|
||||
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",
|
||||
"System in context of System default"));
|
||||
ui->cbLanguage->addItem(cbSysStr, "System");
|
||||
}
|
||||
|
||||
QString cbEngStr = "English (English) [en]";
|
||||
ui->cbLanguage->addItem(QIcon::fromTheme("flag-us"), cbEngStr, "en");
|
||||
if (currentLanguage == "en")
|
||||
{
|
||||
#if QT_VERSION >= 0x050000
|
||||
ui->cbLanguage->setCurrentText(cbEngStr);
|
||||
#else
|
||||
int indexOfEnglish = ui->cbLanguage->findText(cbEngStr);
|
||||
ui->cbLanguage->setCurrentIndex(indexOfEnglish);
|
||||
QStringList availableLanguages;
|
||||
availableLanguages << QString("en_GB");
|
||||
#ifndef GTA5SYNC_QCONF
|
||||
availableLanguages << TCInstance->listTranslations(AppEnv::getExLangFolder());
|
||||
#endif
|
||||
}
|
||||
availableLanguages << TCInstance->listTranslations(AppEnv::getInLangFolder());
|
||||
availableLanguages.removeDuplicates();
|
||||
availableLanguages.sort();
|
||||
|
||||
QDir langDir;
|
||||
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)
|
||||
foreach(const QString &lang, availableLanguages)
|
||||
{
|
||||
QString lang = langFile;
|
||||
lang.remove("gta5sync_");
|
||||
lang.remove(".qm");
|
||||
|
||||
QLocale langLocale(lang);
|
||||
QString languageNameInternational = QLocale::languageToString(langLocale.language());
|
||||
QString languageNameNative = langLocale.nativeLanguageName();
|
||||
QString cbLangStr = langLocale.nativeLanguageName() % " (" % langLocale.nativeCountryName() % ") [" % lang % "]";
|
||||
|
||||
QString cbLangStr = languageNameNative + " (" + languageNameInternational + ") [" + lang + "]";
|
||||
QString langIconStr = "flag-" + lang;
|
||||
QString langIconStr = "flag-" % TranslationClass::getCountryCode(langLocale);
|
||||
|
||||
ui->cbLanguage->addItem(QIcon::fromTheme(langIconStr), cbLangStr, lang);
|
||||
if (currentLanguage == lang)
|
||||
|
@ -275,25 +255,27 @@ void OptionsDialog::applySettings()
|
|||
settings->setValue("force", forceCustomFolder);
|
||||
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
|
||||
emit settingsApplied(newContentMode, ui->cbLanguage->currentData().toString());
|
||||
#else
|
||||
emit settingsApplied(newContentMode, ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()).toString());
|
||||
#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))
|
||||
{
|
||||
QMessageBox::information(this, tr("%1", "%1").arg(GTA5SYNC_APPSTR), tr("The new Custom Folder will initialize 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));
|
||||
QMessageBox::information(this, tr("%1", "%1").arg(GTA5SYNC_APPSTR), tr("The new Custom Folder will initialise after you restart %1.").arg(GTA5SYNC_APPSTR));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -459,6 +459,9 @@
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Apply changes</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string extracomment="OK, Cancel, Apply">&OK</string>
|
||||
</property>
|
||||
|
@ -472,6 +475,9 @@
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Discard changes</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string extracomment="OK, Cancel, Apply">&Cancel</string>
|
||||
</property>
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "ProfileDatabase.h"
|
||||
#include "ui_PictureDialog.h"
|
||||
#include "SidebarGenerator.h"
|
||||
#include "MapPreviewDialog.h"
|
||||
#include "SnapmaticEditor.h"
|
||||
#include "StandardPaths.h"
|
||||
#include "PictureExport.h"
|
||||
#include "StringParser.h"
|
||||
|
@ -35,6 +37,7 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#include <QStringBuilder>
|
||||
#include <QDesktopWidget>
|
||||
#include <QJsonDocument>
|
||||
#include <QApplication>
|
||||
|
@ -98,22 +101,23 @@ void PictureDialog::setupPictureDialog(bool withDatabase_)
|
|||
ui->setupUi(this);
|
||||
windowTitleStr = this->windowTitle();
|
||||
jsonDrawString = ui->labJSON->text();
|
||||
ui->cmdExport->setEnabled(0);
|
||||
ui->cmdManage->setEnabled(false);
|
||||
plyrsList = QStringList();
|
||||
fullscreenWidget = 0;
|
||||
rqFullscreen = 0;
|
||||
previewMode = 0;
|
||||
naviEnabled = 0;
|
||||
indexed = 0;
|
||||
fullscreenWidget = nullptr;
|
||||
rqFullscreen = false;
|
||||
previewMode = false;
|
||||
naviEnabled = false;
|
||||
indexed = false;
|
||||
picArea = "";
|
||||
picTitl = "";
|
||||
picPath = "";
|
||||
created = "";
|
||||
crewStr = "";
|
||||
crewID = "";
|
||||
locX = "";
|
||||
locY = "";
|
||||
locZ = "";
|
||||
smpic = 0;
|
||||
smpic = nullptr;
|
||||
|
||||
// With datebase
|
||||
withDatabase = withDatabase_;
|
||||
|
@ -134,13 +138,17 @@ void PictureDialog::setupPictureDialog(bool withDatabase_)
|
|||
|
||||
// Overlay area
|
||||
renderOverlayPicture();
|
||||
overlayEnabled = 1;
|
||||
overlayEnabled = true;
|
||||
|
||||
// Export menu
|
||||
exportMenu = new QMenu(this);
|
||||
jpegExportAction = exportMenu->addAction(tr("Export as &JPG picture..."), this, SLOT(exportSnapmaticPicture()));
|
||||
pgtaExportAction = exportMenu->addAction(tr("Export as >A Snapmatic..."), this, SLOT(copySnapmaticPicture()));
|
||||
ui->cmdExport->setMenu(exportMenu);
|
||||
// Manage menu
|
||||
manageMenu = new QMenu(this);
|
||||
jpegExportAction = manageMenu->addAction(tr("Export as &Picture..."), this, SLOT(exportSnapmaticPicture()));
|
||||
pgtaExportAction = manageMenu->addAction(tr("Export as &Snapmatic..."), this, SLOT(copySnapmaticPicture()));
|
||||
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
|
||||
globalMap = GlobalString::getGlobalMap();
|
||||
|
@ -166,9 +174,12 @@ void PictureDialog::setupPictureDialog(bool withDatabase_)
|
|||
|
||||
PictureDialog::~PictureDialog()
|
||||
{
|
||||
delete propEditorAction;
|
||||
delete openViewerAction;
|
||||
delete jpegExportAction;
|
||||
delete pgtaExportAction;
|
||||
delete exportMenu;
|
||||
delete manageMenuSep1;
|
||||
delete manageMenu;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
@ -275,10 +286,6 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
|
|||
emit nextPictureRequested();
|
||||
returnValue = true;
|
||||
break;
|
||||
case Qt::Key_E: case Qt::Key_S: case Qt::Key_Save:
|
||||
ui->cmdExport->click();
|
||||
returnValue = true;
|
||||
break;
|
||||
case Qt::Key_1:
|
||||
if (previewMode)
|
||||
{
|
||||
|
@ -303,6 +310,10 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
|
|||
if (!previewMode) renderPicture();
|
||||
}
|
||||
break;
|
||||
case Qt::Key_M:
|
||||
openPreviewMap();
|
||||
returnValue = true;
|
||||
break;
|
||||
#if QT_VERSION >= 0x050300
|
||||
case Qt::Key_Exit:
|
||||
ui->cmdClose->click();
|
||||
|
@ -331,7 +342,7 @@ void PictureDialog::triggerFullscreenDoubeClick()
|
|||
void PictureDialog::exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen)
|
||||
{
|
||||
rqFullscreen = fullscreen;
|
||||
exportMenu->popup(pos);
|
||||
manageMenu->popup(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)
|
||||
{
|
||||
if (smpic != nullptr) smpic->disconnect(this, SLOT(updated()));
|
||||
snapmaticPicture = QImage();
|
||||
indexed = _indexed;
|
||||
index = _index;
|
||||
|
@ -425,7 +437,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
|
|||
{
|
||||
snapmaticPicture = picture->getImage();
|
||||
renderPicture();
|
||||
ui->cmdExport->setEnabled(true);
|
||||
ui->cmdManage->setEnabled(true);
|
||||
}
|
||||
if (picture->isJsonOk())
|
||||
{
|
||||
|
@ -434,11 +446,13 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
|
|||
locZ = QString::number(picture->getSnapmaticProperties().location.z);
|
||||
if (withDatabase)
|
||||
{
|
||||
crewID = crewDB->getCrewName(picture->getSnapmaticProperties().crewID);
|
||||
crewID = QString::number(picture->getSnapmaticProperties().crewID);
|
||||
crewStr = crewDB->getCrewName(picture->getSnapmaticProperties().crewID);
|
||||
}
|
||||
else
|
||||
{
|
||||
crewID = QString::number(picture->getSnapmaticProperties().crewID);
|
||||
crewStr = QString::number(picture->getSnapmaticProperties().crewID);
|
||||
}
|
||||
created = picture->getSnapmaticProperties().createdDateTime.toString(Qt::DefaultLocaleShortDate);
|
||||
plyrsList = picture->getSnapmaticProperties().playersList;
|
||||
|
@ -453,45 +467,15 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
|
|||
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()));
|
||||
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
|
||||
{
|
||||
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()));
|
||||
}
|
||||
QObject::connect(smpic, SIGNAL(updated()), this, SLOT(updated()));
|
||||
emit newPictureCommited(snapmaticPicture);
|
||||
}
|
||||
|
||||
|
@ -573,17 +557,43 @@ void PictureDialog::renderPicture()
|
|||
snapPainter.drawImage(0, 0, avatarAreaPicture);
|
||||
snapPainter.setPen(QColor::fromRgb(255, 255, 255, 255));
|
||||
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();
|
||||
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()
|
||||
{
|
||||
if (plyrsList.count() >= 1)
|
||||
{
|
||||
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)
|
||||
{
|
||||
QString playerName;
|
||||
|
@ -595,29 +605,20 @@ void PictureDialog::playerNameUpdated()
|
|||
{
|
||||
playerName = player;
|
||||
}
|
||||
plyrsStr.append(", <a href=\"https://socialclub.rockstargames.com/member/");
|
||||
if (playerName != player)
|
||||
{
|
||||
plyrsStr.append(playerName);
|
||||
plyrsStr += ", <a href=\"https://socialclub.rockstargames.com/member/" % playerName % "/" % player % "\">" % playerName % "</a>";
|
||||
}
|
||||
plyrsStr.remove(0,2);
|
||||
}
|
||||
else
|
||||
{
|
||||
plyrsStr.append("id");
|
||||
}
|
||||
plyrsStr.append("/");
|
||||
plyrsStr.append(player);
|
||||
plyrsStr.append("\">");
|
||||
plyrsStr.append(playerName);
|
||||
plyrsStr.append("</a>");
|
||||
}
|
||||
plyrsStr.remove(0,2);
|
||||
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, plyrsStr, crewID, picTitl, picAreaStr, created));
|
||||
plyrsStr = tr("No Players");
|
||||
}
|
||||
return plyrsStr;
|
||||
}
|
||||
|
||||
void PictureDialog::exportSnapmaticPicture()
|
||||
{
|
||||
if (rqFullscreen && fullscreenWidget)
|
||||
if (rqFullscreen && fullscreenWidget != nullptr)
|
||||
{
|
||||
PictureExport::exportAsPicture(fullscreenWidget, smpic);
|
||||
}
|
||||
|
@ -629,7 +630,7 @@ void PictureDialog::exportSnapmaticPicture()
|
|||
|
||||
void PictureDialog::copySnapmaticPicture()
|
||||
{
|
||||
if (rqFullscreen && fullscreenWidget)
|
||||
if (rqFullscreen && fullscreenWidget != nullptr)
|
||||
{
|
||||
PictureExport::exportAsSnapmatic(fullscreenWidget, smpic);
|
||||
}
|
||||
|
@ -668,7 +669,7 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button)
|
|||
pictureWidget->raise();
|
||||
pictureWidget->exec();
|
||||
|
||||
fullscreenWidget = 0; // Work!
|
||||
fullscreenWidget = nullptr; // Work!
|
||||
delete pictureWidget; // Work!
|
||||
}
|
||||
}
|
||||
|
@ -687,3 +688,57 @@ int PictureDialog::getIndex()
|
|||
{
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
~PictureDialog();
|
||||
|
||||
public slots:
|
||||
void crewNameUpdated();
|
||||
void playerNameUpdated();
|
||||
void dialogNextPictureRequested();
|
||||
void dialogPreviousPictureRequested();
|
||||
|
@ -67,8 +68,11 @@ private slots:
|
|||
void exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen);
|
||||
void nextPictureRequestedSlot();
|
||||
void previousPictureRequestedSlot();
|
||||
void editSnapmaticProperties();
|
||||
void renderOverlayPicture();
|
||||
void renderPicture();
|
||||
void openPreviewMap();
|
||||
void updated();
|
||||
|
||||
signals:
|
||||
void nextPictureRequested();
|
||||
|
@ -83,6 +87,8 @@ protected:
|
|||
bool event(QEvent *event);
|
||||
|
||||
private:
|
||||
QString generateCrewString();
|
||||
QString generatePlayersString();
|
||||
bool primaryWindow;
|
||||
ProfileDatabase *profileDB;
|
||||
CrewDatabase *crewDB;
|
||||
|
@ -92,6 +98,9 @@ private:
|
|||
QWidget *fullscreenWidget;
|
||||
QAction *jpegExportAction;
|
||||
QAction *pgtaExportAction;
|
||||
QAction *propEditorAction;
|
||||
QAction *openViewerAction;
|
||||
QAction *manageMenuSep1;
|
||||
QImage avatarAreaPicture;
|
||||
QImage snapmaticPicture;
|
||||
QImage overlayTempImage;
|
||||
|
@ -103,6 +112,7 @@ private:
|
|||
QString picTitl;
|
||||
QString picPath;
|
||||
QString created;
|
||||
QString crewStr;
|
||||
QString crewID;
|
||||
QString locX;
|
||||
QString locY;
|
||||
|
@ -117,7 +127,7 @@ private:
|
|||
int avatarLocX;
|
||||
int avatarLocY;
|
||||
int avatarSize;
|
||||
QMenu *exportMenu;
|
||||
QMenu *manageMenu;
|
||||
};
|
||||
|
||||
#endif // PICTUREDIALOG_H
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>960</width>
|
||||
<height>602</height>
|
||||
<height>618</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -163,7 +163,7 @@
|
|||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cmdExport">
|
||||
<widget class="QPushButton" name="cmdManage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -174,10 +174,10 @@
|
|||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Export picture</string>
|
||||
<string>Manage picture</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Export</string>
|
||||
<string>&Manage</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
|
@ -196,7 +196,7 @@
|
|||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Close</string>
|
||||
<string>Close viewer</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
|
|
|
@ -21,11 +21,13 @@
|
|||
#include "PictureDialog.h"
|
||||
#include "StandardPaths.h"
|
||||
#include "SidebarGenerator.h"
|
||||
#include <QStringBuilder>
|
||||
#include <QDesktopWidget>
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QSettings>
|
||||
#include <QRegExp>
|
||||
#include <QDebug>
|
||||
|
||||
PictureExport::PictureExport()
|
||||
|
@ -85,11 +87,11 @@ fileDialogPreSave: //Work?
|
|||
fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true);
|
||||
fileDialog.setDefaultSuffix("suffix");
|
||||
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"));
|
||||
|
||||
QStringList filters;
|
||||
filters << PictureDialog::tr("JPEG picture (*.jpg)");
|
||||
filters << PictureDialog::tr("JPEG Graphics (*.jpg *.jpeg)");
|
||||
filters << PictureDialog::tr("Portable Network Graphics (*.png)");
|
||||
fileDialog.setNameFilters(filters);
|
||||
|
||||
|
@ -97,9 +99,9 @@ fileDialogPreSave: //Work?
|
|||
|
||||
fileDialog.setSidebarUrls(sidebarUrls);
|
||||
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);
|
||||
|
||||
if (fileDialog.exec())
|
||||
|
@ -140,11 +142,11 @@ fileDialogPreSave: //Work?
|
|||
|
||||
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))
|
||||
{
|
||||
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?
|
||||
}
|
||||
}
|
||||
|
@ -178,18 +180,18 @@ fileDialogPreSave: //Work?
|
|||
|
||||
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?
|
||||
}
|
||||
}
|
||||
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?
|
||||
}
|
||||
}
|
||||
|
||||
settings.setValue(parent->objectName() + "+Geometry", fileDialog.saveGeometry());
|
||||
settings.setValue(parent->objectName() % "+Geometry", fileDialog.saveGeometry());
|
||||
settings.setValue("Directory", fileDialog.directory().absolutePath());
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
|
@ -217,7 +219,7 @@ fileDialogPreSave: //Work?
|
|||
fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true);
|
||||
fileDialog.setDefaultSuffix(".rem");
|
||||
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"));
|
||||
|
||||
QStringList filters;
|
||||
|
@ -230,8 +232,8 @@ fileDialogPreSave: //Work?
|
|||
|
||||
fileDialog.setSidebarUrls(sidebarUrls);
|
||||
fileDialog.setDirectory(settings.value("Directory", StandardPaths::documentsLocation()).toString());
|
||||
fileDialog.selectFile(QString(picture->getExportPictureFileName() + ".g5e"));
|
||||
fileDialog.restoreGeometry(settings.value(parent->objectName() + "+Geomtery", "").toByteArray());
|
||||
fileDialog.selectFile(QString(picture->getExportPictureFileName() % ".g5e"));
|
||||
fileDialog.restoreGeometry(settings.value(parent->objectName() % "+Geomtery", "").toByteArray());
|
||||
|
||||
|
||||
if (fileDialog.exec())
|
||||
|
@ -240,14 +242,26 @@ fileDialogPreSave: //Work?
|
|||
if (selectedFiles.length() == 1)
|
||||
{
|
||||
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 (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))
|
||||
{
|
||||
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?
|
||||
}
|
||||
}
|
||||
|
@ -259,47 +273,35 @@ fileDialogPreSave: //Work?
|
|||
|
||||
if (selectedFile.right(4) == ".g5e")
|
||||
{
|
||||
bool isExported = picture->exportPicture(selectedFile, "G5E");
|
||||
bool isExported = picture->exportPicture(selectedFile, SnapmaticFormat::G5E_Format);
|
||||
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?
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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(".rem");
|
||||
}
|
||||
bool isCopied = picture->exportPicture(selectedFile, "PGTA");
|
||||
bool isCopied = picture->exportPicture(selectedFile, SnapmaticFormat::PGTA_Format);
|
||||
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?
|
||||
}
|
||||
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
|
||||
{
|
||||
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?
|
||||
}
|
||||
}
|
||||
|
||||
settings.setValue(parent->objectName() + "+Geometry", fileDialog.saveGeometry());
|
||||
settings.setValue(parent->objectName() % "+Geometry", fileDialog.saveGeometry());
|
||||
settings.setValue("Directory", fileDialog.directory().absolutePath());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
#include "ProfileDatabase.h"
|
||||
#include "StandardPaths.h"
|
||||
#include "config.h"
|
||||
#include <QStringBuilder>
|
||||
#include <QMutexLocker>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
|
||||
|
@ -28,7 +31,7 @@ ProfileDatabase::ProfileDatabase(QObject *parent) : QObject(parent)
|
|||
dir.mkpath(StandardPaths::dataLocation());
|
||||
dir.setPath(StandardPaths::dataLocation());
|
||||
QString dirPath = dir.absolutePath();
|
||||
QString defaultConfPath = dirPath + QDir::separator() + "players.ini";
|
||||
QString defaultConfPath = dirPath % QDir::separator() % "players.ini";
|
||||
|
||||
QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
|
||||
confPathSettings.beginGroup("Database");
|
||||
|
@ -47,15 +50,27 @@ ProfileDatabase::~ProfileDatabase()
|
|||
|
||||
QStringList ProfileDatabase::getPlayers()
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
#ifdef GTA5SYNC_DEBUG
|
||||
qDebug() << "getPlayers";
|
||||
#endif
|
||||
return profileDB->childKeys();
|
||||
}
|
||||
|
||||
QString ProfileDatabase::getPlayerName(int playerID)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
#ifdef GTA5SYNC_DEBUG
|
||||
qDebug() << "getPlayerName" << playerID;
|
||||
#endif
|
||||
return profileDB->value(QString::number(playerID), playerID).toString();
|
||||
}
|
||||
|
||||
void ProfileDatabase::setPlayerName(int playerID, QString playerName)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
#ifdef GTA5SYNC_DEBUG
|
||||
qDebug() << "setPlayerName" << playerID << playerName;
|
||||
#endif
|
||||
profileDB->setValue(QString::number(playerID), playerName);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <QSettings>
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
#include <QMap>
|
||||
|
||||
class ProfileDatabase : public QObject
|
||||
|
@ -33,6 +34,7 @@ public:
|
|||
~ProfileDatabase();
|
||||
|
||||
private:
|
||||
mutable QMutex mutex;
|
||||
QSettings *profileDB;
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <QPushButton>
|
||||
#include <QSpacerItem>
|
||||
#include <QMessageBox>
|
||||
#include <QMouseEvent>
|
||||
#include <QFileDialog>
|
||||
#include <QEventLoop>
|
||||
#include <QScrollBar>
|
||||
|
@ -64,13 +65,14 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
|
|||
enabledPicStr = tr("Enabled pictures: %1 of %2");
|
||||
selectedWidgts = 0;
|
||||
profileFolder = "";
|
||||
profileLoader = 0;
|
||||
saSpacerItem = 0;
|
||||
contextMenuOpened = false;
|
||||
isProfileLoaded = false;
|
||||
previousWidget = nullptr;
|
||||
profileLoader = nullptr;
|
||||
saSpacerItem = nullptr;
|
||||
|
||||
QPalette palette;
|
||||
QColor baseColor = palette.base().color();
|
||||
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())));
|
||||
updatePalette();
|
||||
ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, GTA5SYNC_APPVER));
|
||||
ui->saProfileContent->setFilesMode(true);
|
||||
|
||||
if (QIcon::hasThemeIcon("dialog-close"))
|
||||
|
@ -87,6 +89,9 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
|
|||
ui->hlButtons->setSpacing(6 * screenRatio);
|
||||
ui->hlButtons->setContentsMargins(9 * screenRatio, 15 * screenRatio, 15 * screenRatio, 17 * screenRatio);
|
||||
#endif
|
||||
|
||||
setMouseTracking(true);
|
||||
installEventFilter(this);
|
||||
}
|
||||
|
||||
ProfileInterface::~ProfileInterface()
|
||||
|
@ -94,6 +99,8 @@ ProfileInterface::~ProfileInterface()
|
|||
foreach(ProfileWidget *widget, widgets.keys())
|
||||
{
|
||||
widgets.remove(widget);
|
||||
widget->removeEventFilter(this);
|
||||
widget->disconnect();
|
||||
delete widget;
|
||||
}
|
||||
foreach(SavegameData *savegame, savegames)
|
||||
|
@ -138,6 +145,8 @@ void ProfileInterface::savegameLoaded(SavegameData *savegame, QString savegamePa
|
|||
SavegameWidget *sgdWidget = new SavegameWidget(this);
|
||||
sgdWidget->setSavegameData(savegame, savegamePath);
|
||||
sgdWidget->setContentMode(contentMode);
|
||||
sgdWidget->setMouseTracking(true);
|
||||
sgdWidget->installEventFilter(this);
|
||||
widgets[sgdWidget] = "SGD" % QFileInfo(savegamePath).fileName();
|
||||
savegames += savegame;
|
||||
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);
|
||||
picWidget->setSnapmaticPicture(picture);
|
||||
picWidget->setContentMode(contentMode);
|
||||
picWidget->setMouseTracking(true);
|
||||
picWidget->installEventFilter(this);
|
||||
widgets[picWidget] = "PIC" % picture->getPictureSortStr();
|
||||
pictures += picture;
|
||||
if (selectedWidgts != 0 || contentMode == 2) { picWidget->setSelectionMode(true); }
|
||||
|
@ -183,7 +194,7 @@ void ProfileInterface::loadingProgress(int value, int maximum)
|
|||
|
||||
void ProfileInterface::insertSnapmaticIPI(QWidget *widget)
|
||||
{
|
||||
ProfileWidget *proWidget = (ProfileWidget*)widget;
|
||||
ProfileWidget *proWidget = qobject_cast<ProfileWidget*>(widget);
|
||||
if (widgets.contains(proWidget))
|
||||
{
|
||||
QString widgetKey = widgets[proWidget];
|
||||
|
@ -204,7 +215,7 @@ void ProfileInterface::insertSnapmaticIPI(QWidget *widget)
|
|||
|
||||
void ProfileInterface::insertSavegameIPI(QWidget *widget)
|
||||
{
|
||||
ProfileWidget *proWidget = (ProfileWidget*)widget;
|
||||
ProfileWidget *proWidget = qobject_cast<ProfileWidget*>(widget);
|
||||
if (widgets.contains(proWidget))
|
||||
{
|
||||
QString widgetKey = widgets[proWidget];
|
||||
|
@ -221,8 +232,8 @@ void ProfileInterface::insertSavegameIPI(QWidget *widget)
|
|||
|
||||
void ProfileInterface::dialogNextPictureRequested(QWidget *dialog)
|
||||
{
|
||||
PictureDialog *picDialog = (PictureDialog*)dialog;
|
||||
ProfileWidget *proWidget = (ProfileWidget*)sender();
|
||||
PictureDialog *picDialog = qobject_cast<PictureDialog*>(dialog);
|
||||
ProfileWidget *proWidget = qobject_cast<ProfileWidget*>(sender());
|
||||
if (widgets.contains(proWidget))
|
||||
{
|
||||
QString widgetKey = widgets[proWidget];
|
||||
|
@ -256,8 +267,8 @@ void ProfileInterface::dialogNextPictureRequested(QWidget *dialog)
|
|||
|
||||
void ProfileInterface::dialogPreviousPictureRequested(QWidget *dialog)
|
||||
{
|
||||
PictureDialog *picDialog = (PictureDialog*)dialog;
|
||||
ProfileWidget *proWidget = (ProfileWidget*)sender();
|
||||
PictureDialog *picDialog = qobject_cast<PictureDialog*>(dialog);
|
||||
ProfileWidget *proWidget = qobject_cast<ProfileWidget*>(sender());
|
||||
if (widgets.contains(proWidget))
|
||||
{
|
||||
QString widgetKey = widgets[proWidget];
|
||||
|
@ -324,12 +335,13 @@ void ProfileInterface::profileLoaded_p()
|
|||
ui->swProfile->setCurrentWidget(ui->pageProfile);
|
||||
ui->cmdCloseProfile->setEnabled(true);
|
||||
ui->cmdImport->setEnabled(true);
|
||||
isProfileLoaded = true;
|
||||
emit profileLoaded();
|
||||
}
|
||||
|
||||
void ProfileInterface::savegameDeleted_event()
|
||||
{
|
||||
savegameDeleted((SavegameWidget*)sender(), true);
|
||||
savegameDeleted(qobject_cast<SavegameWidget*>(sender()), true);
|
||||
}
|
||||
|
||||
void ProfileInterface::savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteEmited)
|
||||
|
@ -338,13 +350,21 @@ void ProfileInterface::savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteE
|
|||
if (sgdWidget->isSelected()) { sgdWidget->setSelected(false); }
|
||||
widgets.remove(sgdWidget);
|
||||
|
||||
sgdWidget->removeEventFilter(this);
|
||||
if (sgdWidget == previousWidget)
|
||||
{
|
||||
previousWidget = nullptr;
|
||||
}
|
||||
|
||||
// Deleting when the widget did send a event cause a crash
|
||||
if (isRemoteEmited)
|
||||
{
|
||||
sgdWidget->disconnect();
|
||||
sgdWidget->deleteLater();
|
||||
}
|
||||
else
|
||||
{
|
||||
sgdWidget->disconnect();
|
||||
delete sgdWidget;
|
||||
}
|
||||
|
||||
|
@ -354,7 +374,7 @@ void ProfileInterface::savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteE
|
|||
|
||||
void ProfileInterface::pictureDeleted_event()
|
||||
{
|
||||
pictureDeleted((SnapmaticWidget*)sender(), true);
|
||||
pictureDeleted(qobject_cast<SnapmaticWidget*>(sender()), true);
|
||||
}
|
||||
|
||||
void ProfileInterface::pictureDeleted(SnapmaticWidget *picWidget, bool isRemoteEmited)
|
||||
|
@ -363,13 +383,21 @@ void ProfileInterface::pictureDeleted(SnapmaticWidget *picWidget, bool isRemoteE
|
|||
if (picWidget->isSelected()) { picWidget->setSelected(false); }
|
||||
widgets.remove(picWidget);
|
||||
|
||||
picWidget->removeEventFilter(this);
|
||||
if (picWidget == previousWidget)
|
||||
{
|
||||
previousWidget = nullptr;
|
||||
}
|
||||
|
||||
// Deleting when the widget did send a event cause a crash
|
||||
if (isRemoteEmited)
|
||||
{
|
||||
picWidget->disconnect();
|
||||
picWidget->deleteLater();
|
||||
}
|
||||
else
|
||||
{
|
||||
picWidget->disconnect();
|
||||
delete picWidget;
|
||||
}
|
||||
|
||||
|
@ -398,12 +426,24 @@ fileDialogPreOpen: //Work?
|
|||
fileDialog.setWindowTitle(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;
|
||||
filters << tr("Importable files (*.g5e *.jpg *.png SGTA* PGTA*)");
|
||||
filters << tr("Importable files (%1)").arg(importableFormatsStr);
|
||||
filters << tr("GTA V Export (*.g5e)");
|
||||
filters << tr("Savegames files (SGTA*)");
|
||||
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 (**)");
|
||||
fileDialog.setNameFilters(filters);
|
||||
|
||||
|
@ -520,7 +560,7 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
else if(selectedFileName.right(4) == ".jpg" || selectedFileName.right(4) == ".png")
|
||||
else if(isSupportedImageFile(selectedFileName))
|
||||
{
|
||||
SnapmaticPicture *picture = new SnapmaticPicture(":/template/template.g5e");
|
||||
if (picture->readingPicture(true, false, true, false))
|
||||
|
@ -631,6 +671,7 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
|
|||
snapmaticImageReader.setDevice(&snapmaticFile);
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
@ -640,7 +681,7 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
|
|||
importDialog->setModal(true);
|
||||
importDialog->show();
|
||||
importDialog->exec();
|
||||
if (importDialog->isDoImport())
|
||||
if (importDialog->isImportAgreed())
|
||||
{
|
||||
if (picture->setImage(importDialog->image()))
|
||||
{
|
||||
|
@ -705,9 +746,13 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
|
|||
}
|
||||
else
|
||||
{
|
||||
delete savegame;
|
||||
#ifdef GTA5SYNC_DEBUG
|
||||
qDebug() << "ImportError SnapmaticPicture" << picture->getLastStep();
|
||||
qDebug() << "ImportError SavegameData" << savegame->getLastStep();
|
||||
#endif
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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"));
|
||||
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);
|
||||
pictureLoaded(picture, true);
|
||||
|
@ -914,8 +959,10 @@ void ProfileInterface::exportSelected()
|
|||
}
|
||||
else
|
||||
{
|
||||
pictureExportEnabled = true;
|
||||
pictureCopyEnabled = true;
|
||||
// Don't export anymore when any Cancel button got clicked
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -934,7 +981,7 @@ void ProfileInterface::exportSelected()
|
|||
QProgressDialog pbDialog(this);
|
||||
pbDialog.setWindowFlags(pbDialog.windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowCloseButtonHint);
|
||||
pbDialog.setWindowTitle(tr("Export selected..."));
|
||||
pbDialog.setLabelText(tr("Initializing export..."));
|
||||
pbDialog.setLabelText(tr("Initialising export..."));
|
||||
pbDialog.setRange(0, exportCount);
|
||||
|
||||
QList<QPushButton*> pbBtn = pbDialog.findChildren<QPushButton*>();
|
||||
|
@ -1003,7 +1050,7 @@ void ProfileInterface::deleteSelected()
|
|||
{
|
||||
if (widget->getWidgetType() == "SnapmaticWidget")
|
||||
{
|
||||
SnapmaticWidget *picWidget = (SnapmaticWidget*)widget;
|
||||
SnapmaticWidget *picWidget = qobject_cast<SnapmaticWidget*>(widget);
|
||||
if (picWidget->getPicture()->deletePicFile())
|
||||
{
|
||||
pictureDeleted(picWidget);
|
||||
|
@ -1011,7 +1058,7 @@ void ProfileInterface::deleteSelected()
|
|||
}
|
||||
else if (widget->getWidgetType() == "SavegameWidget")
|
||||
{
|
||||
SavegameWidget *sgdWidget = (SavegameWidget*)widget;
|
||||
SavegameWidget *sgdWidget = qobject_cast<SavegameWidget*>(widget);
|
||||
SavegameData *savegame = sgdWidget->getSavegame();
|
||||
QString fileName = savegame->getSavegameFileName();
|
||||
if (!QFile::exists(fileName) || QFile::remove(fileName))
|
||||
|
@ -1038,9 +1085,15 @@ void ProfileInterface::importFiles()
|
|||
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;
|
||||
|
||||
if (contentMode == 2)
|
||||
|
@ -1049,6 +1102,7 @@ void ProfileInterface::settingsApplied(int _contentMode, QString language)
|
|||
{
|
||||
widget->setSelectionMode(true);
|
||||
widget->setContentMode(contentMode);
|
||||
if (translationUpdated) widget->retranslate();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1060,6 +1114,7 @@ void ProfileInterface::settingsApplied(int _contentMode, QString language)
|
|||
widget->setSelectionMode(false);
|
||||
}
|
||||
widget->setContentMode(contentMode);
|
||||
if (translationUpdated) widget->retranslate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1073,7 +1128,7 @@ void ProfileInterface::enableSelected()
|
|||
{
|
||||
if (widget->getWidgetType() == "SnapmaticWidget")
|
||||
{
|
||||
SnapmaticWidget *snapmaticWidget = (SnapmaticWidget*)widget;
|
||||
SnapmaticWidget *snapmaticWidget = qobject_cast<SnapmaticWidget*>(widget);
|
||||
if (!snapmaticWidget->makePictureVisible())
|
||||
{
|
||||
fails++;
|
||||
|
@ -1092,7 +1147,7 @@ void ProfileInterface::disableSelected()
|
|||
{
|
||||
if (widget->getWidgetType() == "SnapmaticWidget")
|
||||
{
|
||||
SnapmaticWidget *snapmaticWidget = (SnapmaticWidget*)widget;
|
||||
SnapmaticWidget *snapmaticWidget = qobject_cast<SnapmaticWidget*>(widget);
|
||||
if (!snapmaticWidget->makePictureHidden())
|
||||
{
|
||||
fails++;
|
||||
|
@ -1109,7 +1164,16 @@ int ProfileInterface::selectedWidgets()
|
|||
|
||||
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 editMenu(SnapmaticWidget::tr("Edi&t"), picWidget);
|
||||
if (picWidget->isHidden())
|
||||
|
@ -1122,8 +1186,8 @@ void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev)
|
|||
}
|
||||
editMenu.addAction(SnapmaticWidget::tr("&Edit Properties..."), picWidget, SLOT(editSnapmaticProperties()));
|
||||
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 >A Snapmatic..."), picWidget, SLOT(on_cmdCopy_clicked()));
|
||||
exportMenu.addAction(SnapmaticWidget::tr("Export as &Picture..."), picWidget, SLOT(on_cmdExport_clicked()));
|
||||
exportMenu.addAction(SnapmaticWidget::tr("Export as &Snapmatic..."), picWidget, SLOT(on_cmdCopy_clicked()));
|
||||
contextMenu.addAction(SnapmaticWidget::tr("&View"), picWidget, SLOT(on_cmdView_clicked()));
|
||||
contextMenu.addMenu(&editMenu);
|
||||
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"));
|
||||
}
|
||||
contextMenuOpened = true;
|
||||
contextMenu.exec(ev->globalPos());
|
||||
contextMenuOpened = false;
|
||||
hoverProfileWidgetCheck();
|
||||
}
|
||||
|
||||
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);
|
||||
contextMenu.addAction(SavegameWidget::tr("&View"), sgdWidget, SLOT(on_cmdView_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"));
|
||||
}
|
||||
contextMenuOpened = true;
|
||||
contextMenu.exec(ev->globalPos());
|
||||
contextMenuOpened = false;
|
||||
hoverProfileWidgetCheck();
|
||||
}
|
||||
|
||||
void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
|
||||
|
@ -1187,3 +1266,200 @@ void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -50,15 +50,18 @@ public:
|
|||
void disableSelected();
|
||||
void enableSelected();
|
||||
int selectedWidgets();
|
||||
void retranslateUi();
|
||||
~ProfileInterface();
|
||||
|
||||
public slots:
|
||||
void contextMenuTriggeredPIC(QContextMenuEvent* ev);
|
||||
void contextMenuTriggeredSGD(QContextMenuEvent* ev);
|
||||
void hoverProfileWidgetCheck();
|
||||
void selectAllWidgets();
|
||||
void deselectAllWidgets();
|
||||
void exportSelected();
|
||||
void deleteSelected();
|
||||
void updatePalette();
|
||||
void importFiles();
|
||||
|
||||
private slots:
|
||||
|
@ -76,6 +79,9 @@ private slots:
|
|||
void dialogPreviousPictureRequested(QWidget *dialog);
|
||||
void on_saProfileContent_dropped(const QMimeData *mimeData);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
private:
|
||||
ProfileDatabase *profileDB;
|
||||
CrewDatabase *crewDB;
|
||||
|
@ -83,17 +89,24 @@ private:
|
|||
Ui::ProfileInterface *ui;
|
||||
|
||||
ProfileLoader *profileLoader;
|
||||
ProfileWidget *previousWidget;
|
||||
QList<SavegameData*> savegames;
|
||||
QList<SnapmaticPicture*> pictures;
|
||||
QMap<ProfileWidget*,QString> widgets;
|
||||
QSpacerItem *saSpacerItem;
|
||||
QColor highlightBackColor;
|
||||
QColor highlightTextColor;
|
||||
QString enabledPicStr;
|
||||
QString profileFolder;
|
||||
QString profileName;
|
||||
QString loadingStr;
|
||||
QString language;
|
||||
bool contextMenuOpened;
|
||||
bool isProfileLoaded;
|
||||
int selectedWidgts;
|
||||
int contentMode;
|
||||
|
||||
bool isSupportedImageFile(QString selectedFileName);
|
||||
bool importFile(QString selectedFile, bool notMultiple);
|
||||
void importFilesProgress(QStringList selectedFiles);
|
||||
bool importSnapmaticPicture(SnapmaticPicture *picture, bool warn = true);
|
||||
|
|
|
@ -195,7 +195,7 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Import exported file</string>
|
||||
<string>Import file</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Import...</string>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "SnapmaticPicture.h"
|
||||
#include "SavegameData.h"
|
||||
#include "CrewDatabase.h"
|
||||
#include <QStringBuilder>
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
|
@ -43,7 +44,7 @@ void ProfileLoader::run()
|
|||
QStringList BackupFiles = SavegameFiles.filter(".bak", Qt::CaseInsensitive);
|
||||
profileDir.setNameFilters(QStringList("PGTA*"));
|
||||
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();
|
||||
SnapmaticPics.removeDuplicates();
|
||||
|
@ -60,7 +61,7 @@ void ProfileLoader::run()
|
|||
foreach(const QString &SavegameFile, SavegameFiles)
|
||||
{
|
||||
emit loadingProgress(curFile, maximumV);
|
||||
QString sgdPath = profileFolder + QDir::separator() + SavegameFile;
|
||||
QString sgdPath = profileFolder % QDir::separator() % SavegameFile;
|
||||
SavegameData *savegame = new SavegameData(sgdPath);
|
||||
if (savegame->readingSavegame())
|
||||
{
|
||||
|
@ -71,7 +72,7 @@ void ProfileLoader::run()
|
|||
foreach(const QString &SnapmaticPic, SnapmaticPics)
|
||||
{
|
||||
emit loadingProgress(curFile, maximumV);
|
||||
QString picturePath = profileFolder + QDir::separator() + SnapmaticPic;
|
||||
QString picturePath = profileFolder % QDir::separator() % SnapmaticPic;
|
||||
SnapmaticPicture *picture = new SnapmaticPicture(picturePath);
|
||||
if (picture->readingPicture(true, true, true))
|
||||
{
|
||||
|
@ -79,17 +80,19 @@ void ProfileLoader::run()
|
|||
int crewNumber = picture->getSnapmaticProperties().crewID;
|
||||
if (!crewList.contains(crewNumber))
|
||||
{
|
||||
crewList.append(crewNumber);
|
||||
crewList += crewNumber;
|
||||
}
|
||||
}
|
||||
curFile++;
|
||||
}
|
||||
|
||||
// adding found crews
|
||||
crewDB->setAddingCrews(true);
|
||||
foreach(int crewID, crewList)
|
||||
{
|
||||
crewDB->addCrew(crewID);
|
||||
}
|
||||
crewDB->setAddingCrews(false);
|
||||
}
|
||||
|
||||
void ProfileLoader::preloaded()
|
||||
|
|
|
@ -28,6 +28,11 @@ ProfileWidget::~ProfileWidget()
|
|||
{
|
||||
}
|
||||
|
||||
void ProfileWidget::retranslate()
|
||||
{
|
||||
qDebug() << "ProfileWidget::retranslate got used without overwrite";
|
||||
}
|
||||
|
||||
bool ProfileWidget::isSelected()
|
||||
{
|
||||
qDebug() << "ProfileWidget::isSelected got used without overwrite";
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
virtual bool isSelected();
|
||||
virtual QString getWidgetType();
|
||||
virtual int getContentMode();
|
||||
virtual void retranslate();
|
||||
~ProfileWidget();
|
||||
|
||||
private:
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "StringParser.h"
|
||||
#include "SavegameData.h"
|
||||
#include <QStringBuilder>
|
||||
#include <QTextCodec>
|
||||
#include <QByteArray>
|
||||
#include <QDebug>
|
||||
|
@ -41,7 +42,7 @@ bool SavegameData::readingSavegame()
|
|||
QFile *saveFile = new QFile(savegameFileName);
|
||||
if (!saveFile->open(QFile::ReadOnly))
|
||||
{
|
||||
lastStep = "1;/1,OpenFile," + StringParser::convertDrawStringForLog(savegameFileName);
|
||||
lastStep = "1;/1,OpenFile," % StringParser::convertDrawStringForLog(savegameFileName);
|
||||
saveFile->deleteLater();
|
||||
delete saveFile;
|
||||
return false;
|
||||
|
@ -50,7 +51,7 @@ bool SavegameData::readingSavegame()
|
|||
// Reading Savegame Header
|
||||
if (!saveFile->isReadable())
|
||||
{
|
||||
lastStep = "2;/3,ReadingFile," + StringParser::convertDrawStringForLog(savegameFileName) + ",1,NOHEADER";
|
||||
lastStep = "2;/3,ReadingFile," % StringParser::convertDrawStringForLog(savegameFileName) % ",1,NOHEADER";
|
||||
saveFile->close();
|
||||
saveFile->deleteLater();
|
||||
delete saveFile;
|
||||
|
|
|
@ -19,12 +19,6 @@
|
|||
<layout class="QVBoxLayout" name="vlSavegameDialog">
|
||||
<item>
|
||||
<widget class="QLabel" name="labSavegameText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><span style=" font-weight:600;">Savegame</span><br><br>%1</string>
|
||||
</property>
|
||||
|
@ -36,6 +30,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<layout class="QHBoxLayout" name="hlButtons">
|
||||
<item>
|
||||
|
|
|
@ -57,18 +57,14 @@ SavegameWidget::SavegameWidget(QWidget *parent) :
|
|||
QString exportSavegameStr = tr("Export Savegame...");
|
||||
Q_UNUSED(exportSavegameStr)
|
||||
|
||||
QPalette palette;
|
||||
highlightBackColor = palette.highlight().color();
|
||||
highlightTextColor = palette.highlightedText().color();
|
||||
|
||||
labelAutosaveStr = tr("AUTOSAVE - %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()
|
||||
|
@ -76,32 +72,22 @@ SavegameWidget::~SavegameWidget()
|
|||
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)
|
||||
{
|
||||
// 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;
|
||||
QString savegameName = tr("WRONG FORMAT");
|
||||
QString savegameDate = tr("WRONG FORMAT");
|
||||
QString savegameString = savegame->getSavegameStr();
|
||||
QString fileName = QFileInfo(savegame->getSavegameFileName()).fileName();
|
||||
QStringList savegameNDL = QString(savegameString).split(" - ");
|
||||
if (savegameNDL.length() >= 2)
|
||||
{
|
||||
|
@ -124,9 +110,15 @@ void SavegameWidget::setSavegameData(SavegameData *savegame, QString savegamePat
|
|||
{
|
||||
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()
|
||||
|
@ -187,10 +179,21 @@ void SavegameWidget::mouseReleaseEvent(QMouseEvent *ev)
|
|||
else
|
||||
{
|
||||
if (getContentMode() == 0 && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SavegameWidget::mouseDoubleClickEvent(QMouseEvent *ev)
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
SavegameData* getSavegame();
|
||||
QString getWidgetType();
|
||||
bool isSelected();
|
||||
void retranslate();
|
||||
~SavegameWidget();
|
||||
|
||||
private slots:
|
||||
|
@ -53,7 +54,6 @@ private slots:
|
|||
void deselectAllWidgets();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
void mouseDoubleClickEvent(QMouseEvent *ev);
|
||||
void mouseReleaseEvent(QMouseEvent *ev);
|
||||
void mousePressEvent(QMouseEvent *ev);
|
||||
|
@ -62,13 +62,11 @@ protected:
|
|||
private:
|
||||
Ui::SavegameWidget *ui;
|
||||
SavegameData *sgdata;
|
||||
QColor highlightBackColor;
|
||||
QColor highlightTextColor;
|
||||
QString labelAutosaveStr;
|
||||
QString labelSaveStr;
|
||||
QString sgdPath;
|
||||
QString sgdStr;
|
||||
QWidget *snwgt;
|
||||
void renderString(const QString &savegameString, const QString &fileName);
|
||||
|
||||
signals:
|
||||
void savegameDeleted();
|
||||
|
|
|
@ -35,26 +35,26 @@ QList<QUrl> SidebarGenerator::generateSidebarUrls(QList<QUrl> sidebarUrls)
|
|||
dir.setPath(StandardPaths::picturesLocation());
|
||||
if (dir.exists())
|
||||
{
|
||||
sidebarUrls << QUrl::fromLocalFile(dir.absolutePath());
|
||||
sidebarUrls += QUrl::fromLocalFile(dir.absolutePath());
|
||||
}
|
||||
|
||||
dir.setPath(StandardPaths::documentsLocation());
|
||||
if (dir.exists())
|
||||
{
|
||||
sidebarUrls << QUrl::fromLocalFile(dir.absolutePath());
|
||||
sidebarUrls += QUrl::fromLocalFile(dir.absolutePath());
|
||||
}
|
||||
|
||||
bool gameFolderExists;
|
||||
QString gameFolder = AppEnv::getGameFolder(&gameFolderExists);
|
||||
if (gameFolderExists)
|
||||
{
|
||||
sidebarUrls << QUrl::fromLocalFile(gameFolder);
|
||||
sidebarUrls += QUrl::fromLocalFile(gameFolder);
|
||||
}
|
||||
|
||||
dir.setPath(StandardPaths::desktopLocation());
|
||||
if (dir.exists())
|
||||
{
|
||||
sidebarUrls << QUrl::fromLocalFile(dir.absolutePath());
|
||||
sidebarUrls += QUrl::fromLocalFile(dir.absolutePath());
|
||||
}
|
||||
|
||||
return sidebarUrls;
|
||||
|
|
|
@ -310,12 +310,12 @@ void SnapmaticEditor::on_labCrew_linkActivated(const QString &link)
|
|||
QStringList crewList = crewDB->getCrews();
|
||||
if (!crewList.contains(QLatin1String("0")))
|
||||
{
|
||||
crewList.append(QLatin1String("0"));
|
||||
crewList += QLatin1String("0");
|
||||
}
|
||||
crewList.sort();
|
||||
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)))
|
||||
{
|
||||
|
|
|
@ -68,25 +68,37 @@ SnapmaticPicture::~SnapmaticPicture()
|
|||
void SnapmaticPicture::reset()
|
||||
{
|
||||
// INIT PIC
|
||||
rawPicContent = "";
|
||||
rawPicContent.clear();
|
||||
rawPicContent.squeeze();
|
||||
cachePicture = QImage();
|
||||
picExportFileName = QString();
|
||||
pictureHead = QString();
|
||||
pictureStr = QString();
|
||||
lastStep = QString();
|
||||
sortStr = QString();
|
||||
titlStr = QString();
|
||||
descStr = QString();
|
||||
|
||||
// INIT PIC INTS
|
||||
jpegRawContentSizeE = 0;
|
||||
jpegRawContentSize = 0;
|
||||
picExportFileName = "";
|
||||
isCustomFormat = 0;
|
||||
isLoadedInRAM = 0;
|
||||
pictureHead = "";
|
||||
pictureStr = "";
|
||||
lowRamMode = 0;
|
||||
lastStep = "";
|
||||
sortStr = "";
|
||||
titlStr = "";
|
||||
descStr = "";
|
||||
picOk = 0;
|
||||
|
||||
// INIT PIC BOOLS
|
||||
isCustomFormat = false;
|
||||
isLoadedInRAM = false;
|
||||
lowRamMode = false;
|
||||
picOk = false;
|
||||
|
||||
// INIT JSON
|
||||
jsonOk = 0;
|
||||
jsonStr = "";
|
||||
jsonOk = false;
|
||||
jsonStr = QString();
|
||||
|
||||
// SNAPMATIC DEFAULTS
|
||||
#ifdef GTA5SYNC_CSDF
|
||||
careSnapDefault = false;
|
||||
#else
|
||||
careSnapDefault = true;
|
||||
#endif
|
||||
|
||||
// SNAPMATIC PROPERTIES
|
||||
localSpJson = {};
|
||||
|
@ -210,6 +222,13 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
|
|||
}
|
||||
QByteArray snapmaticHeaderLine = picStream->read(snapmaticHeaderLength);
|
||||
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
|
||||
if (!picStream->isReadable())
|
||||
|
@ -259,20 +278,31 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
|
|||
picOk = tempPicture.loadFromData(jpegRawContent, "JPEG");
|
||||
}
|
||||
else if (!fastLoad)
|
||||
{
|
||||
if (careSnapDefault)
|
||||
{
|
||||
QImage tempPicture = QImage(snapmaticResolution, QImage::Format_RGB888);
|
||||
QPainter tempPainter(&tempPicture);
|
||||
if (cachePicture.size() == snapmaticResolution)
|
||||
{
|
||||
tempPainter.drawImage(0, 0, cachePicture);
|
||||
}
|
||||
else
|
||||
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
|
||||
{
|
||||
QImage tempPicture = QImage(cachePicture.size(), QImage::Format_RGB888);
|
||||
QPainter tempPainter(&tempPicture);
|
||||
tempPainter.drawImage(0, 0, cachePicture);
|
||||
tempPainter.end();
|
||||
cachePicture = tempPicture;
|
||||
}
|
||||
}
|
||||
|
||||
// Read JSON Stream
|
||||
if (!picStream->isReadable())
|
||||
|
@ -341,19 +371,18 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bo
|
|||
|
||||
QString SnapmaticPicture::getSnapmaticHeaderString(const QByteArray &snapmaticHeader)
|
||||
{
|
||||
QByteArray snapmaticBytes = snapmaticHeader.left(snapmaticUsefulLength);
|
||||
QList<QByteArray> snapmaticBytesList = snapmaticBytes.split('\x01');
|
||||
snapmaticBytes = snapmaticBytesList.at(1);
|
||||
snapmaticBytesList.clear();
|
||||
QList<QByteArray> snapmaticBytesList = snapmaticHeader.left(snapmaticUsefulLength).split('\x01');
|
||||
if (snapmaticBytesList.length() < 2) { return QLatin1String("MALFORMED"); }
|
||||
QByteArray snapmaticBytes = snapmaticBytesList.at(1);
|
||||
return StringParser::parseTitleString(snapmaticBytes, snapmaticBytes.length());
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getSnapmaticJSONString(const QByteArray &jsonBytes)
|
||||
{
|
||||
QByteArray jsonUsefulBytes = jsonBytes;
|
||||
jsonUsefulBytes.replace('\x00', "");
|
||||
jsonUsefulBytes.replace('\x0c', "");
|
||||
return QString::fromUtf8(jsonUsefulBytes).trimmed();
|
||||
jsonUsefulBytes.replace('\x00', QString());
|
||||
jsonUsefulBytes.replace('\x0c', QString());
|
||||
return QString::fromUtf8(jsonUsefulBytes.trimmed());
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getSnapmaticTIDEString(const QByteArray &tideBytes)
|
||||
|
@ -361,7 +390,7 @@ QString SnapmaticPicture::getSnapmaticTIDEString(const QByteArray &tideBytes)
|
|||
QByteArray tideUsefulBytes = tideBytes;
|
||||
tideUsefulBytes.remove(0,4);
|
||||
QList<QByteArray> tideUsefulBytesList = tideUsefulBytes.split('\x00');
|
||||
return QString::fromUtf8(tideUsefulBytesList.at(0)).trimmed();
|
||||
return QString::fromUtf8(tideUsefulBytesList.at(0).trimmed());
|
||||
}
|
||||
|
||||
void SnapmaticPicture::updateStrings()
|
||||
|
@ -381,7 +410,8 @@ void SnapmaticPicture::updateStrings()
|
|||
cmpPicTitl.remove('.');
|
||||
pictureStr = tr("PHOTO - %1").arg(localSpJson.createdDateTime.toString("MM/dd/yy HH:mm:ss"));
|
||||
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_)
|
||||
|
@ -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)
|
||||
{
|
||||
QImage altPicture;
|
||||
bool useAltPicture = false;
|
||||
if (picture.size() != snapmaticResolution && careSnapDefault)
|
||||
{
|
||||
altPicture = picture.scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
useAltPicture = true;
|
||||
}
|
||||
QByteArray picByteArray;
|
||||
int comLvl = 100;
|
||||
bool saveSuccess = false;
|
||||
|
@ -409,7 +446,8 @@ bool SnapmaticPicture::setImage(const QImage &picture) // dirty method
|
|||
QByteArray picByteArrayT;
|
||||
QBuffer picStreamT(&picByteArrayT);
|
||||
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();
|
||||
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;
|
||||
}
|
||||
|
@ -548,7 +586,7 @@ QString SnapmaticPicture::getLastStep()
|
|||
return lastStep;
|
||||
}
|
||||
|
||||
QImage SnapmaticPicture::getImage()
|
||||
QImage SnapmaticPicture::getImage(bool fastLoad)
|
||||
{
|
||||
if (cacheEnabled)
|
||||
{
|
||||
|
@ -556,9 +594,16 @@ QImage SnapmaticPicture::getImage()
|
|||
}
|
||||
else if (writeEnabled)
|
||||
{
|
||||
bool returnOk = 0;
|
||||
bool fastLoadU = fastLoad;
|
||||
if (!careSnapDefault) { fastLoadU = true; }
|
||||
|
||||
bool returnOk = false;
|
||||
QImage tempPicture;
|
||||
QImage returnPicture(snapmaticResolution, QImage::Format_RGB888);
|
||||
QImage returnPicture;
|
||||
if (!fastLoadU)
|
||||
{
|
||||
returnPicture = QImage(snapmaticResolution, QImage::Format_RGB888);
|
||||
}
|
||||
|
||||
if (lowRamMode) { rawPicContent = qUncompress(rawPicContent); }
|
||||
QBuffer snapmaticStream(&rawPicContent);
|
||||
|
@ -573,23 +618,38 @@ QImage SnapmaticPicture::getImage()
|
|||
|
||||
if (returnOk)
|
||||
{
|
||||
QPainter returnPainter(&returnPicture);
|
||||
if (tempPicture.size() == snapmaticResolution)
|
||||
if (!fastLoadU)
|
||||
{
|
||||
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.scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||
returnPainter.drawImage(0, 0, tempPicture);
|
||||
}
|
||||
returnPainter.end();
|
||||
return returnPicture;
|
||||
}
|
||||
else
|
||||
{
|
||||
return tempPicture;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool returnOk = 0;
|
||||
bool fastLoadU = fastLoad;
|
||||
if (!careSnapDefault) { fastLoadU = true; }
|
||||
|
||||
bool returnOk = false;
|
||||
QImage tempPicture;
|
||||
QImage returnPicture;
|
||||
if (!fastLoadU)
|
||||
{
|
||||
returnPicture = QImage(snapmaticResolution, QImage::Format_RGB888);
|
||||
}
|
||||
QIODevice *picStream;
|
||||
|
||||
QFile *picFile = new QFile(picFilePath);
|
||||
|
@ -597,7 +657,7 @@ QImage SnapmaticPicture::getImage()
|
|||
{
|
||||
lastStep = "1;/1,OpenFile," % StringParser::convertDrawStringForLog(picFilePath);
|
||||
delete picFile;
|
||||
return QImage(0, 0, QImage::Format_RGB888);
|
||||
return QImage();
|
||||
}
|
||||
rawPicContent = picFile->read(snapmaticFileMaxSize);
|
||||
picFile->close();
|
||||
|
@ -608,17 +668,34 @@ QImage SnapmaticPicture::getImage()
|
|||
if (picStream->seek(jpegStreamEditorBegin))
|
||||
{
|
||||
QByteArray jpegRawContent = picStream->read(jpegPicStreamLength);
|
||||
returnOk = returnPicture.loadFromData(jpegRawContent, "JPEG");
|
||||
returnOk = tempPicture.loadFromData(jpegRawContent, "JPEG");
|
||||
}
|
||||
picStream->close();
|
||||
delete picStream;
|
||||
|
||||
if (returnOk)
|
||||
{
|
||||
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()
|
||||
|
@ -743,7 +820,16 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties newSpJson)
|
|||
|
||||
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 (writeEnabled)
|
||||
|
@ -765,7 +851,6 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties newSpJson)
|
|||
snapmaticStream.close();
|
||||
if (result != 0)
|
||||
{
|
||||
localSpJson = newSpJson;
|
||||
jsonStr = newJsonStr;
|
||||
if (lowRamMode) { rawPicContent = qCompress(rawPicContent, 9); }
|
||||
return true;
|
||||
|
@ -781,29 +866,38 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties newSpJson)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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);
|
||||
if (picFile->open(QIODevice::WriteOnly))
|
||||
{
|
||||
if (format == QLatin1String("G5E"))
|
||||
if (format == SnapmaticFormat::G5E_Format)
|
||||
{
|
||||
// Modern compressed export
|
||||
QByteArray stockFileNameUTF8 = picFileName.toUtf8();
|
||||
QByteArray numberLength = QByteArray::number(stockFileNameUTF8.length());
|
||||
if (numberLength.length() == 1)
|
||||
{
|
||||
numberLength.insert(0, "0");
|
||||
numberLength.insert(0, '0');
|
||||
}
|
||||
else if (numberLength.length() != 2)
|
||||
{
|
||||
|
@ -831,7 +925,7 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, const QString form
|
|||
picFile->close();
|
||||
delete picFile;
|
||||
}
|
||||
else if (format == QLatin1String("JPG"))
|
||||
else if (format == SnapmaticFormat::JPEG_Format)
|
||||
{
|
||||
// JPEG export
|
||||
QBuffer snapmaticStream(&rawPicContent);
|
||||
|
@ -944,6 +1038,18 @@ QSize SnapmaticPicture::getSnapmaticResolution()
|
|||
return snapmaticResolution;
|
||||
}
|
||||
|
||||
// SNAPMATIC DEFAULTS
|
||||
|
||||
bool SnapmaticPicture::isSnapmaticDefaultsEnforced()
|
||||
{
|
||||
return careSnapDefault;
|
||||
}
|
||||
|
||||
void SnapmaticPicture::setSnapmaticDefaultsEnforced(bool enforced)
|
||||
{
|
||||
careSnapDefault = enforced;
|
||||
}
|
||||
|
||||
// VERIFY CONTENT
|
||||
|
||||
bool SnapmaticPicture::verifyTitle(const QString &title)
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include <QImage>
|
||||
#include <QFile>
|
||||
|
||||
enum class SnapmaticFormat : int { Auto_Format = 0, PGTA_Format = 1, JPEG_Format = 2, G5E_Format = 3 };
|
||||
|
||||
struct SnapmaticProperties {
|
||||
struct SnapmaticLocation {
|
||||
QString area;
|
||||
|
@ -58,7 +60,7 @@ public:
|
|||
bool readingPicture(bool writeEnabled = true, bool cacheEnabled = false, bool fastLoad = true, bool lowRamMode = false);
|
||||
bool isPicOk();
|
||||
void clearCache();
|
||||
QImage getImage();
|
||||
QImage getImage(bool fastLoad = false);
|
||||
QString getLastStep();
|
||||
QString getPictureStr();
|
||||
QString getPictureHead();
|
||||
|
@ -76,7 +78,7 @@ public:
|
|||
void emitUpdate();
|
||||
|
||||
// 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 setPicFilePath(const QString &picFilePath);
|
||||
bool deletePicFile();
|
||||
|
@ -92,6 +94,7 @@ public:
|
|||
QString getJsonStr();
|
||||
SnapmaticProperties getSnapmaticProperties();
|
||||
bool setSnapmaticProperties(SnapmaticProperties newSpJson);
|
||||
bool setJsonStr(const QString &jsonStr);
|
||||
|
||||
// VISIBILITY
|
||||
bool isHidden();
|
||||
|
@ -101,6 +104,10 @@ public:
|
|||
// PREDEFINED PROPERTIES
|
||||
QSize getSnapmaticResolution();
|
||||
|
||||
// SNAPMATIC DEFAULTS
|
||||
bool isSnapmaticDefaultsEnforced();
|
||||
void setSnapmaticDefaultsEnforced(bool enforced);
|
||||
|
||||
// VERIFY CONTENT
|
||||
static bool verifyTitle(const QString &title);
|
||||
|
||||
|
@ -124,6 +131,7 @@ private:
|
|||
bool cacheEnabled;
|
||||
bool isLoadedInRAM;
|
||||
bool isCustomFormat;
|
||||
bool careSnapDefault;
|
||||
int jpegRawContentSize;
|
||||
int jpegRawContentSizeE;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "StringParser.h"
|
||||
#include "AppEnv.h"
|
||||
#include "config.h"
|
||||
#include <QStringBuilder>
|
||||
#include <QMessageBox>
|
||||
#include <QPixmap>
|
||||
#include <QTimer>
|
||||
|
@ -45,16 +46,14 @@ SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, CrewDatabase *crewD
|
|||
ui->cbSelected->setVisible(false);
|
||||
|
||||
QPalette palette;
|
||||
highlightBackColor = palette.highlight().color();
|
||||
highlightTextColor = palette.highlightedText().color();
|
||||
palette.setCurrentColorGroup(QPalette::Disabled);
|
||||
highlightHiddenColor = palette.text().color();
|
||||
|
||||
picPath = "";
|
||||
picStr = "";
|
||||
smpic = 0;
|
||||
|
||||
installEventFilter(this);
|
||||
ui->SnapmaticFrame->setMouseTracking(true);
|
||||
ui->labPicture->setMouseTracking(true);
|
||||
ui->labPicStr->setMouseTracking(true);
|
||||
ui->cbSelected->setMouseTracking(true);
|
||||
smpic = nullptr;
|
||||
}
|
||||
|
||||
SnapmaticWidget::~SnapmaticWidget()
|
||||
|
@ -62,37 +61,16 @@ SnapmaticWidget::~SnapmaticWidget()
|
|||
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)
|
||||
{
|
||||
smpic = picture;
|
||||
picPath = picture->getPictureFilePath();
|
||||
picTitl = picture->getPictureTitl();
|
||||
picStr = picture->getPictureStr();
|
||||
QObject::connect(picture, SIGNAL(updated()), this, SLOT(snapmaticUpdated()));
|
||||
|
||||
qreal screenRatio = AppEnv::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);
|
||||
ui->labPicStr->setText(picStr + "\n" + picTitl + "");
|
||||
ui->labPicStr->setText(smpic->getPictureStr() % "\n" % smpic->getPictureTitl() % "");
|
||||
ui->labPicture->setPixmap(SnapmaticPixmap);
|
||||
|
||||
picture->clearCache();
|
||||
|
@ -102,11 +80,13 @@ void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture)
|
|||
|
||||
void SnapmaticWidget::snapmaticUpdated()
|
||||
{
|
||||
// Current only strings get updated
|
||||
picPath = smpic->getPictureFilePath();
|
||||
picTitl = smpic->getPictureTitl();
|
||||
picStr = smpic->getPictureStr();
|
||||
ui->labPicStr->setText(picStr + "\n" + picTitl + "");
|
||||
ui->labPicStr->setText(smpic->getPictureStr() % "\n" % smpic->getPictureTitl() % "");
|
||||
}
|
||||
|
||||
void SnapmaticWidget::retranslate()
|
||||
{
|
||||
smpic->updateStrings();
|
||||
ui->labPicStr->setText(smpic->getPictureStr() % "\n" % smpic->getPictureTitl() % "");
|
||||
}
|
||||
|
||||
void SnapmaticWidget::on_cmdView_clicked()
|
||||
|
@ -120,7 +100,8 @@ void SnapmaticWidget::on_cmdView_clicked()
|
|||
picDialog->setSnapmaticPicture(smpic, 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(picDialog, SIGNAL(nextPictureRequested()), this, SLOT(dialogNextPictureRequested()));
|
||||
QObject::connect(picDialog, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested()));
|
||||
|
@ -160,7 +141,7 @@ void SnapmaticWidget::on_cmdDelete_clicked()
|
|||
|
||||
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 (smpic->deletePicFile())
|
||||
|
@ -169,7 +150,7 @@ bool SnapmaticWidget::deletePicture()
|
|||
}
|
||||
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;
|
||||
|
@ -193,10 +174,21 @@ void SnapmaticWidget::mouseReleaseEvent(QMouseEvent *ev)
|
|||
else
|
||||
{
|
||||
if (getContentMode() == 0 && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SnapmaticWidget::mouseDoubleClickEvent(QMouseEvent *ev)
|
||||
|
@ -262,7 +254,6 @@ bool SnapmaticWidget::makePictureHidden()
|
|||
{
|
||||
if (smpic->setPictureHidden())
|
||||
{
|
||||
picPath = smpic->getPictureFilePath();
|
||||
adjustTextColor();
|
||||
return true;
|
||||
}
|
||||
|
@ -273,7 +264,6 @@ bool SnapmaticWidget::makePictureVisible()
|
|||
{
|
||||
if (smpic->setPictureVisible())
|
||||
{
|
||||
picPath = smpic->getPictureFilePath();
|
||||
adjustTextColor();
|
||||
return true;
|
||||
}
|
||||
|
@ -307,11 +297,7 @@ bool SnapmaticWidget::isSelected()
|
|||
|
||||
bool SnapmaticWidget::isHidden()
|
||||
{
|
||||
if (picPath.right(7) == ".hidden")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return smpic->isHidden();
|
||||
}
|
||||
|
||||
void SnapmaticWidget::setSelectionMode(bool selectionMode)
|
||||
|
@ -336,7 +322,7 @@ SnapmaticPicture* SnapmaticWidget::getPicture()
|
|||
|
||||
QString SnapmaticWidget::getPicturePath()
|
||||
{
|
||||
return picPath;
|
||||
return smpic->getPictureFilePath();
|
||||
}
|
||||
|
||||
QString SnapmaticWidget::getWidgetType()
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
QString getWidgetType();
|
||||
bool isSelected();
|
||||
bool isHidden();
|
||||
void retranslate();
|
||||
~SnapmaticWidget();
|
||||
|
||||
private slots:
|
||||
|
@ -70,7 +71,6 @@ private slots:
|
|||
void snapmaticUpdated();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
void mouseDoubleClickEvent(QMouseEvent *ev);
|
||||
void mouseReleaseEvent(QMouseEvent *ev);
|
||||
void mousePressEvent(QMouseEvent *ev);
|
||||
|
@ -82,13 +82,7 @@ private:
|
|||
DatabaseThread *threadDB;
|
||||
Ui::SnapmaticWidget *ui;
|
||||
SnapmaticPicture *smpic;
|
||||
QColor highlightBackColor;
|
||||
QColor highlightTextColor;
|
||||
QColor highlightHiddenColor;
|
||||
QString picPath;
|
||||
QString picTitl;
|
||||
QString picStr;
|
||||
QWidget *snwgt;
|
||||
|
||||
signals:
|
||||
void pictureDeleted();
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "StringParser.h"
|
||||
#include "config.h"
|
||||
#include <QTextDocument>
|
||||
#include <QLibraryInfo>
|
||||
#ifndef GTA5VIEW_CMD
|
||||
#include <QApplication>
|
||||
#endif
|
||||
|
@ -59,9 +60,12 @@ QString StringParser::convertBuildedString(const QString &buildedStr)
|
|||
{
|
||||
QString outputStr = buildedStr;
|
||||
QByteArray sharePath = GTA5SYNC_SHARE;
|
||||
outputStr.replace("$SHAREDIR", QString::fromUtf8(sharePath));
|
||||
outputStr.replace("$RUNDIR", QFileInfo(qApp->applicationFilePath()).absoluteDir().absolutePath());
|
||||
outputStr.replace("$SEPARATOR", QDir::separator());
|
||||
outputStr.replace("APPNAME:", GTA5SYNC_APPSTR);
|
||||
outputStr.replace("SHAREDDIR:", QString::fromUtf8(sharePath));
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
|
543
TranslationClass.cpp
Normal file
543
TranslationClass.cpp
Normal 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
63
TranslationClass.h
Normal 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
|
|
@ -31,6 +31,7 @@
|
|||
#include "AppEnv.h"
|
||||
#include "config.h"
|
||||
#include <QtGlobal>
|
||||
#include <QStringBuilder>
|
||||
#include <QStyleFactory>
|
||||
#include <QFileDialog>
|
||||
#include <QHBoxLayout>
|
||||
|
@ -57,10 +58,11 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D
|
|||
ui->actionSelect_profile->setEnabled(false);
|
||||
ui->actionAbout_gta5sync->setIcon(IconLoader::loadingAppIcon());
|
||||
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);
|
||||
|
||||
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"))
|
||||
{
|
||||
|
@ -130,7 +132,7 @@ void UserInterface::setupDirEnv()
|
|||
if (folderExists)
|
||||
{
|
||||
QDir GTAV_ProfilesDir;
|
||||
GTAV_ProfilesFolder = GTAV_Folder + QDir::separator() + "Profiles";
|
||||
GTAV_ProfilesFolder = GTAV_Folder % QDir::separator() % "Profiles";
|
||||
GTAV_ProfilesDir.setPath(GTAV_ProfilesFolder);
|
||||
|
||||
GTAV_Profiles = GTAV_ProfilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::NoSort);
|
||||
|
@ -163,7 +165,7 @@ void UserInterface::setupProfileUi()
|
|||
changeDirBtn->setMinimumSize(0, 40 * screenRatio);
|
||||
changeDirBtn->setAutoDefault(true);
|
||||
ui->vlButtons->addWidget(changeDirBtn);
|
||||
profileBtns.append(changeDirBtn);
|
||||
profileBtns += changeDirBtn;
|
||||
|
||||
QObject::connect(changeDirBtn, SIGNAL(clicked(bool)), this, SLOT(changeFolder_clicked()));
|
||||
}
|
||||
|
@ -174,7 +176,7 @@ void UserInterface::setupProfileUi()
|
|||
profileBtn->setMinimumSize(0, 40 * screenRatio);
|
||||
profileBtn->setAutoDefault(true);
|
||||
ui->vlButtons->addWidget(profileBtn);
|
||||
profileBtns.append(profileBtn);
|
||||
profileBtns += profileBtn;
|
||||
|
||||
QObject::connect(profileBtn, SIGNAL(clicked(bool)), this, SLOT(profileButton_clicked()));
|
||||
}
|
||||
|
@ -203,13 +205,14 @@ void UserInterface::profileButton_clicked()
|
|||
openProfile(profileBtn->objectName());
|
||||
}
|
||||
|
||||
void UserInterface::openProfile(QString profileName)
|
||||
void UserInterface::openProfile(const QString &profileName_)
|
||||
{
|
||||
profileOpen = true;
|
||||
profileName = profileName_;
|
||||
profileUI = new ProfileInterface(profileDB, crewDB, threadDB);
|
||||
ui->swProfile->addWidget(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->setupProfileInterface();
|
||||
QObject::connect(profileUI, SIGNAL(profileClosed()), this, SLOT(closeProfile()));
|
||||
|
@ -222,6 +225,7 @@ void UserInterface::closeProfile()
|
|||
if (profileOpen)
|
||||
{
|
||||
profileOpen = false;
|
||||
profileName.clear();
|
||||
ui->menuProfile->setEnabled(false);
|
||||
ui->actionSelect_profile->setEnabled(false);
|
||||
ui->swProfile->removeWidget(profileUI);
|
||||
|
@ -461,7 +465,7 @@ void UserInterface::openSnapmaticFile(SnapmaticPicture *picture)
|
|||
int crewID = picture->getSnapmaticProperties().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()));
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
|
@ -492,7 +496,11 @@ void UserInterface::openSavegameFile(SavegameData *savegame)
|
|||
|
||||
void UserInterface::settingsApplied(int _contentMode, QString _language)
|
||||
{
|
||||
if (language != _language)
|
||||
{
|
||||
retranslateUi();
|
||||
language = _language;
|
||||
}
|
||||
contentMode = _contentMode;
|
||||
if (profileOpen)
|
||||
{
|
||||
|
@ -527,3 +535,18 @@ void UserInterface::on_action_Disable_In_game_triggered()
|
|||
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")));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "CrewDatabase.h"
|
||||
#include "SavegameData.h"
|
||||
#include <QMainWindow>
|
||||
#include <QMouseEvent>
|
||||
#include <QCloseEvent>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
|
@ -73,6 +74,7 @@ private:
|
|||
Ui::UserInterface *ui;
|
||||
ProfileInterface *profileUI;
|
||||
QList<QPushButton*> profileBtns;
|
||||
QString profileName;
|
||||
bool profileOpen;
|
||||
int contentMode;
|
||||
QString language;
|
||||
|
@ -81,8 +83,9 @@ private:
|
|||
QString GTAV_ProfilesFolder;
|
||||
QStringList GTAV_Profiles;
|
||||
void setupProfileUi();
|
||||
void openProfile(QString profileName);
|
||||
void openProfile(const QString &profileName);
|
||||
void openSelectProfile();
|
||||
void retranslateUi();
|
||||
|
||||
// Open File
|
||||
bool openFile(QString selectedFile, bool warn = true);
|
||||
|
|
|
@ -127,6 +127,9 @@
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reload profile overview</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Reload</string>
|
||||
</property>
|
||||
|
@ -143,6 +146,9 @@
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string extracomment="Close %1 <- (gta5view/gta5sync) - %1 will be replaced automatically">Close %1</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
|
|
74
config.h
74
config.h
|
@ -18,6 +18,7 @@
|
|||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
#include <QtGlobal>
|
||||
#include <QString>
|
||||
|
||||
#ifndef GTA5SYNC_APPVENDOR
|
||||
|
@ -50,9 +51,51 @@
|
|||
|
||||
#ifndef GTA5SYNC_APPVER
|
||||
#ifndef GTA5SYNC_DAILYB
|
||||
#define GTA5SYNC_APPVER "1.4.4"
|
||||
#define GTA5SYNC_APPVER "1.5.0-dev1"
|
||||
#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
|
||||
|
||||
|
@ -60,16 +103,33 @@
|
|||
#define GTA5SYNC_BUILDTYPE "Custom"
|
||||
#endif
|
||||
|
||||
#ifdef GTA5SYNC_QCONF
|
||||
#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
|
||||
|
||||
#ifndef GTA5SYNC_LANG
|
||||
#define GTA5SYNC_LANG "$SHAREDIR$SEPARATORlang"
|
||||
#define GTA5SYNC_LANG "SHAREDDIR:SEPARATOR:lang"
|
||||
#endif
|
||||
|
||||
#ifndef GTA5SYNC_PLUG
|
||||
#define GTA5SYNC_PLUG "$RUNDIR$SEPARATORplugins"
|
||||
#define GTA5SYNC_PLUG "RUNDIR:SEPARATOR:plugins"
|
||||
#endif
|
||||
|
||||
#ifdef GTA5SYNC_WINRT
|
||||
|
@ -91,11 +151,11 @@
|
|||
#endif
|
||||
|
||||
#ifndef GTA5SYNC_BUILDDATETIME
|
||||
#define GTA5SYNC_BUILDDATETIME QString("%1, %2").arg(__DATE__, __TIME__);
|
||||
#define GTA5SYNC_BUILDDATETIME QString("%1, %2").arg(__DATE__, __TIME__)
|
||||
#endif
|
||||
|
||||
#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 // CONFIG_H
|
||||
|
|
48
gta5view.pro
48
gta5view.pro
|
@ -27,6 +27,10 @@ DEPLOYMENT.display_name = gta5view
|
|||
TARGET = gta5view
|
||||
TEMPLATE = app
|
||||
|
||||
DEFINES += GTA5SYNC_CSDF # Not assisting at proper usage of SnapmaticPicture class
|
||||
HEADERS += config.h
|
||||
PRECOMPILED_HEADER += config.h
|
||||
|
||||
SOURCES += main.cpp \
|
||||
AboutDialog.cpp \
|
||||
AppEnv.cpp \
|
||||
|
@ -37,6 +41,7 @@ SOURCES += main.cpp \
|
|||
GlobalString.cpp \
|
||||
IconLoader.cpp \
|
||||
ImportDialog.cpp \
|
||||
MapPreviewDialog.cpp \
|
||||
OptionsDialog.cpp \
|
||||
PictureDialog.cpp \
|
||||
PictureExport.cpp \
|
||||
|
@ -55,6 +60,7 @@ SOURCES += main.cpp \
|
|||
SnapmaticWidget.cpp \
|
||||
StandardPaths.cpp \
|
||||
StringParser.cpp \
|
||||
TranslationClass.cpp \
|
||||
UserInterface.cpp \
|
||||
uimod/UiModLabel.cpp \
|
||||
uimod/UiModWidget.cpp
|
||||
|
@ -69,6 +75,7 @@ HEADERS += \
|
|||
GlobalString.h \
|
||||
IconLoader.h \
|
||||
ImportDialog.h \
|
||||
MapPreviewDialog.h \
|
||||
OptionsDialog.h \
|
||||
PictureDialog.h \
|
||||
PictureExport.h \
|
||||
|
@ -87,16 +94,16 @@ HEADERS += \
|
|||
SnapmaticWidget.h \
|
||||
StandardPaths.h \
|
||||
StringParser.h \
|
||||
TranslationClass.h \
|
||||
UserInterface.h \
|
||||
uimod/UiModLabel.h \
|
||||
uimod/UiModWidget.h
|
||||
|
||||
PRECOMPILED_HEADER += config.h
|
||||
|
||||
FORMS += \
|
||||
AboutDialog.ui \
|
||||
ExportDialog.ui \
|
||||
ImportDialog.ui \
|
||||
MapPreviewDialog.ui \
|
||||
OptionsDialog.ui \
|
||||
PictureDialog.ui \
|
||||
ProfileInterface.ui \
|
||||
|
@ -107,21 +114,24 @@ FORMS += \
|
|||
UserInterface.ui
|
||||
|
||||
TRANSLATIONS += \
|
||||
res/gta5sync_en_US.ts \
|
||||
res/gta5sync_de.ts \
|
||||
res/gta5sync_fr.ts \
|
||||
res/gta5sync_ru.ts
|
||||
res/gta5sync_ru.ts \
|
||||
lang/gta5sync_no.ts
|
||||
|
||||
RESOURCES += \
|
||||
res/tr_g5p.qrc \
|
||||
res/app.qrc
|
||||
|
||||
DISTFILES += res/app.rc \
|
||||
res/gta5sync.desktop \
|
||||
res/gta5view.desktop \
|
||||
res/gta5sync_de.ts \
|
||||
res/gta5sync_fr.ts \
|
||||
res/gta5sync_ru.ts \
|
||||
res/gta5view.exe.manifest \
|
||||
res/gta5view.png \
|
||||
lang/gta5sync_no.ts \
|
||||
lang/README.txt
|
||||
|
||||
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
|
||||
|
||||
# QT5 ONLY STUFF
|
||||
|
||||
isEqual(QT_MAJOR_VERSION, 5): RESOURCES += res/tr_qt5.qrc
|
||||
|
||||
# UNIX SYSTEM STUFF
|
||||
# PROJECT INSTALLATION
|
||||
|
||||
unix: !macx: appfiles.path = $$(INSTALL_PATH)/share/applications
|
||||
unix: !macx: appfiles.files = $$PWD/res/gta5view.desktop
|
||||
unix: !macx: pixmaps.path = $$(INSTALL_PATH)/share/pixmaps
|
||||
unix: !macx: pixmaps.files = $$PWD/res/gta5view.png
|
||||
unix: !macx: target.path = $$(INSTALL_PATH)/bin
|
||||
unix: !macx: INSTALLS += target pixmaps appfiles
|
||||
isEmpty(GTA5SYNC_PREFIX): GTA5SYNC_PREFIX = /usr/local
|
||||
|
||||
appfiles.path = $$GTA5SYNC_PREFIX/share/applications
|
||||
appfiles.files = $$PWD/res/gta5view.desktop
|
||||
pixmaps.path = $$GTA5SYNC_PREFIX/share/pixmaps
|
||||
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
BIN
lang/gta5sync_no.qm
Normal file
Binary file not shown.
1619
lang/gta5sync_no.ts
Normal file
1619
lang/gta5sync_no.ts
Normal file
File diff suppressed because it is too large
Load diff
306
main.cpp
306
main.cpp
|
@ -16,6 +16,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "TranslationClass.h"
|
||||
#include "SnapmaticPicture.h"
|
||||
#include "ProfileDatabase.h"
|
||||
#include "DatabaseThread.h"
|
||||
|
@ -27,20 +28,17 @@
|
|||
#include "IconLoader.h"
|
||||
#include "AppEnv.h"
|
||||
#include "config.h"
|
||||
#include <QDesktopWidget>
|
||||
#include <QStringBuilder>
|
||||
#include <QApplication>
|
||||
#include <QStringList>
|
||||
#include <QTranslator>
|
||||
#include <QMessageBox>
|
||||
#include <QFileInfo>
|
||||
#include <QSysInfo>
|
||||
#include <QRawFont>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <QFont>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
|
||||
#ifdef GTA5SYNC_WIN
|
||||
#include "windows.h"
|
||||
|
@ -65,7 +63,7 @@ int main(int argc, char *argv[])
|
|||
QString uiFontStr(QString::fromStdWString(std::wstring(uiFont.lfFaceName)));
|
||||
|
||||
#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
|
||||
|
||||
// Set Application Font
|
||||
|
@ -81,298 +79,8 @@ int main(int argc, char *argv[])
|
|||
a.addLibraryPath(pluginsDir);
|
||||
}
|
||||
|
||||
// Loading translation settings
|
||||
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
|
||||
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
|
||||
TCInstance->initUserLanguage();
|
||||
TCInstance->loadTranslation(&a);
|
||||
|
||||
QStringList applicationArgs = a.arguments();
|
||||
QString selectedAction;
|
||||
|
@ -440,6 +148,8 @@ int main(int argc, char *argv[])
|
|||
if (!readOk) { return 1; }
|
||||
|
||||
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(playerNameUpdated()), &picDialog, SLOT(playerNameUpdated()));
|
||||
QObject::connect(&threadDB, SIGNAL(finished()), &threadLoop, SLOT(quit()));
|
||||
|
@ -473,6 +183,7 @@ int main(int argc, char *argv[])
|
|||
DatabaseThread threadDB(&crewDB);
|
||||
|
||||
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(finished()), &threadLoop, SLOT(quit()));
|
||||
threadDB.start();
|
||||
|
@ -490,4 +201,3 @@ int main(int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
BIN
res/960x536.png
BIN
res/960x536.png
Binary file not shown.
Before ![]() (image error) Size: 47 KiB After ![]() (image error) Size: 19 KiB ![]() ![]() |
|
@ -16,6 +16,11 @@
|
|||
<file>empty1x16.png</file>
|
||||
<file>avatararea.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 prefix="/global">
|
||||
<file>global.de.ini</file>
|
||||
|
|
|
@ -7,8 +7,8 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gta5view.exe.manifest"
|
|||
#include <windows.h>
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1, 4, 4, 0
|
||||
PRODUCTVERSION 1, 4, 4, 0
|
||||
FILEVERSION 1, 5, 0, 0
|
||||
PRODUCTVERSION 1, 5, 0, 0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
FILEFLAGS 0
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
|
@ -25,12 +25,12 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "Syping"
|
||||
VALUE "FileDescription", "gta5view\0"
|
||||
VALUE "FileVersion", "1.4.4\0"
|
||||
VALUE "FileVersion", "1.5.0\0"
|
||||
VALUE "InternalName", "gta5view\0"
|
||||
VALUE "LegalCopyright", "Copyright © 2016-2017 Syping\0"
|
||||
VALUE "OriginalFilename", "gta5view.exe\0"
|
||||
VALUE "ProductName", "gta5view\0"
|
||||
VALUE "ProductVersion", "1.4.4\0"
|
||||
VALUE "ProductVersion", "1.5.0\0"
|
||||
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
BIN
res/gta5sync_en_US.qm
Normal file
Binary file not shown.
1619
res/gta5sync_en_US.ts
Normal file
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
BIN
res/mappreview.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 203 KiB |
BIN
res/pointmaker-16.png
Normal file
BIN
res/pointmaker-16.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 352 B |
BIN
res/pointmaker-24.png
Normal file
BIN
res/pointmaker-24.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 444 B |
BIN
res/pointmaker-32.png
Normal file
BIN
res/pointmaker-32.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 611 B |
BIN
res/pointmaker-8.png
Normal file
BIN
res/pointmaker-8.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 244 B |
BIN
res/qtbase_en_GB.qm
Normal file
BIN
res/qtbase_en_GB.qm
Normal file
Binary file not shown.
|
@ -1,5 +1,6 @@
|
|||
<RCC>
|
||||
<qresource prefix="/tr">
|
||||
<file>gta5sync_en_US.qm</file>
|
||||
<file>gta5sync_de.qm</file>
|
||||
<file>gta5sync_fr.qm</file>
|
||||
<file>gta5sync_ru.qm</file>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<RCC>
|
||||
<qresource prefix="/tr">
|
||||
<file>qtbase_en_GB.qm</file>
|
||||
<file>qtbase_de.qm</file>
|
||||
<file>qtbase_fr.qm</file>
|
||||
<file>qtbase_ru.qm</file>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue