From dcb95f5c778e2608d195d260e3d754531610e277 Mon Sep 17 00:00:00 2001 From: Rafael Date: Thu, 14 Apr 2016 01:27:29 +0200 Subject: [PATCH] added language change, translation files updated --- AppEnv.cpp | 26 ++++ AppEnv.h | 9 ++ CrewDatabase.cpp | 3 +- DatabaseThread.cpp | 23 ++-- OptionsDialog.cpp | 108 +++++++++++++++- OptionsDialog.h | 16 ++- OptionsDialog.ui | 57 +++++++-- PictureExport.cpp | 3 +- ProfileDatabase.cpp | 3 +- ProfileInterface.cpp | 3 +- SavegameCopy.cpp | 3 +- StringParser.cpp | 13 ++ StringParser.h | 1 + UserInterface.cpp | 7 +- UserInterface.ui | 4 +- config.h | 50 ++++++++ gta5sync.pro | 293 ++++++++++++++++++++++--------------------- lang/gta5sync_ru.ts | 216 +++++++++++++++++-------------- main.cpp | 20 ++- res/gta5sync_de.ts | 220 ++++++++++++++++++-------------- 20 files changed, 703 insertions(+), 375 deletions(-) create mode 100755 config.h diff --git a/AppEnv.cpp b/AppEnv.cpp index 4fb138d..e003552 100755 --- a/AppEnv.cpp +++ b/AppEnv.cpp @@ -17,7 +17,9 @@ *****************************************************************************/ #define _CRT_SECURE_NO_WARNINGS +#include "config.h" #include "AppEnv.h" +#include "StringParser.h" #include "StandardPaths.h" #include #include @@ -30,6 +32,8 @@ AppEnv::AppEnv() } +// Folder Stuff + QString AppEnv::getGameFolder(bool *ok) { QDir dir; @@ -104,3 +108,25 @@ bool AppEnv::setGameFolder(QString gameFolder) } return false; } + +QString AppEnv::getLangFolder() +{ + return StringParser::convertBuildedString(QString::fromUtf8(GTA5SYNC_LANG)); +} + +QString AppEnv::getPluginsFolder() +{ + return StringParser::convertBuildedString(QString::fromUtf8(GTA5SYNC_PLUG)); +} + +// Web Stuff + +QByteArray AppEnv::getUserAgent() +{ + return QString("Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 gta5sync/1.0").toUtf8(); +} + +QUrl AppEnv::getPlayerFetchingUrl(QString crewID, QString pageNumber) +{ + return QUrl(QString("https://socialclub.rockstargames.com/crewsapi/GetMembersList?crewId=%1&pageNumber=%2").arg(crewID, pageNumber)); +} diff --git a/AppEnv.h b/AppEnv.h index 39c6ad9..cc04915 100755 --- a/AppEnv.h +++ b/AppEnv.h @@ -20,13 +20,22 @@ #define APPENV_H #include +#include class AppEnv { public: AppEnv(); + + // Folder Stuff static QString getGameFolder(bool *ok = 0); static bool setGameFolder(QString gameFolder); + static QString getLangFolder(); + static QString getPluginsFolder(); + + // Web Stuff + static QByteArray getUserAgent(); + static QUrl getPlayerFetchingUrl(QString crewID, QString pageNumber); }; #endif // APPENV_H diff --git a/CrewDatabase.cpp b/CrewDatabase.cpp index 3cb5370..aae5683 100755 --- a/CrewDatabase.cpp +++ b/CrewDatabase.cpp @@ -18,6 +18,7 @@ #include "StandardPaths.h" #include "CrewDatabase.h" +#include "config.h" #include #include @@ -29,7 +30,7 @@ CrewDatabase::CrewDatabase(QObject *parent) : QObject(parent) QString dirPath = dir.absolutePath(); QString defaultConfPath = dirPath + QDir::separator() + "crews.ini"; - QSettings confPathSettings("Syping","gta5sync"); + QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); confPathSettings.beginGroup("Database"); QString confPathFile = confPathSettings.value("Crews", defaultConfPath).toString(); confPathSettings.endGroup(); diff --git a/DatabaseThread.cpp b/DatabaseThread.cpp index 08e4ffa..02eec2e 100755 --- a/DatabaseThread.cpp +++ b/DatabaseThread.cpp @@ -18,6 +18,7 @@ #include "DatabaseThread.h" #include "CrewDatabase.h" +#include "AppEnv.h" #include #include #include @@ -85,20 +86,19 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int { QNetworkAccessManager *netManager = new QNetworkAccessManager(); - QString memberListUrl = "https://socialclub.rockstargames.com/crewsapi/GetMembersList?crewId=" + crewID + "&pageNumber=" + QString::number(currentPage); - - QNetworkRequest netRequest(memberListUrl); - netRequest.setRawHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 gta5sync/1.0"); + QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, QString::number(currentPage))); + 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; - QObject::connect(netReply, SIGNAL(finished()), &downloadLoop, SLOT(quit())); - QTimer::singleShot(30000, &downloadLoop, SLOT(quit())); - downloadLoop.exec(); + QEventLoop *downloadLoop = new QEventLoop(); + QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit())); + QTimer::singleShot(30000, downloadLoop, SLOT(quit())); + downloadLoop->exec(); + delete downloadLoop; if (netReply->isFinished()) { @@ -128,9 +128,10 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int } } - QEventLoop waitingLoop; - QTimer::singleShot(requestDelay, &waitingLoop, SLOT(quit())); - waitingLoop.exec(); + QEventLoop *waitingLoop = new QEventLoop(); + QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit())); + waitingLoop->exec(); + delete waitingLoop; currentPage++; } diff --git a/OptionsDialog.cpp b/OptionsDialog.cpp index 0d5eeb2..bde5f52 100755 --- a/OptionsDialog.cpp +++ b/OptionsDialog.cpp @@ -18,15 +18,119 @@ #include "OptionsDialog.h" #include "ui_OptionsDialog.h" +#include "AppEnv.h" +#include "config.h" +#include +#include +#include +#include +#include +#include +#include -OptionsDialog::OptionsDialog(QWidget *parent) : - QDialog(parent), +OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) : + QDialog(parent), profileDB(profileDB), ui(new Ui::OptionsDialog) { ui->setupUi(this); + setupTreeWidget(); + setupLanguageBox(); } OptionsDialog::~OptionsDialog() { + foreach(QTreeWidgetItem *playerItem, playerItems) + { + delete playerItem; + } delete ui; } + +void OptionsDialog::setupTreeWidget() +{ + foreach(const QString &playerIDStr, profileDB->getPlayers()) + { + bool ok; + int playerID = playerIDStr.toInt(&ok); + if (ok) + { + QString playerName = profileDB->getPlayerName(playerID); + + QStringList playerTreeViewList; + playerTreeViewList << playerIDStr; + playerTreeViewList << playerName; + + QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList); + ui->twPlayers->addTopLevelItem(playerItem); + playerItems.append(playerItem); + } + } + ui->twPlayers->sortItems(1, Qt::AscendingOrder); +} + +void OptionsDialog::setupLanguageBox() +{ + QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); + settings.beginGroup("Interface"); + currentLanguage = settings.value("Language","System").toString(); + settings.endGroup(); + + QString cbSysStr = tr("%1 (%2 if available) [sys]", "System like PC System = %1, System Language like Deutsch = %2").arg(tr("System", + "System like PC System"), QLocale::system().nativeLanguageName()); + ui->cbLanguage->addItem(cbSysStr, "System"); + + QString cbEngStr = "English (English) [en]"; + ui->cbLanguage->addItem(QIcon::fromTheme("flag-us"), cbEngStr, "en"); + if (currentLanguage == "en") + { + ui->cbLanguage->setCurrentText(cbEngStr); + } + + 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) + { + QString lang = langFile; + lang.remove("gta5sync_"); + lang.remove(".qm"); + + QLocale langLocale(lang); + QString languageNameInternational = QLocale::languageToString(langLocale.language()); + QString languageNameNative = langLocale.nativeLanguageName(); + + QString cbLangStr = languageNameNative + " (" + languageNameInternational + ") [" + lang + "]"; + QString langIconStr = "flag-" + lang; + + ui->cbLanguage->addItem(QIcon::fromTheme(langIconStr), cbLangStr, lang); + if (currentLanguage == lang) + { + ui->cbLanguage->setCurrentText(cbLangStr); + } + } +} + +void OptionsDialog::on_cmdOK_clicked() +{ + applySettings(); + close(); +} + +void OptionsDialog::applySettings() +{ + QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); + settings.beginGroup("Interface"); + settings.setValue("Language", ui->cbLanguage->currentData()); + settings.endGroup(); + + if (ui->cbLanguage->currentData().toString() != currentLanguage) + { + QMessageBox::information(this, tr("%1", "%1").arg(GTA5SYNC_APPSTR), tr("The language change will take effect after you restart %1.").arg(GTA5SYNC_APPSTR)); + } +} diff --git a/OptionsDialog.h b/OptionsDialog.h index f9b363a..5cebad3 100755 --- a/OptionsDialog.h +++ b/OptionsDialog.h @@ -1,4 +1,4 @@ -/***************************************************************************** +/****************************************************************************** * gta5sync GRAND THEFT AUTO V SYNC * Copyright (C) 2016 Syping * @@ -19,7 +19,10 @@ #ifndef OPTIONSDIALOG_H #define OPTIONSDIALOG_H +#include #include +#include +#include "ProfileDatabase.h" namespace Ui { class OptionsDialog; @@ -30,11 +33,20 @@ class OptionsDialog : public QDialog Q_OBJECT public: - explicit OptionsDialog(QWidget *parent = 0); + explicit OptionsDialog(ProfileDatabase *profileDB, QWidget *parent = 0); ~OptionsDialog(); +private slots: + void on_cmdOK_clicked(); + private: + ProfileDatabase *profileDB; Ui::OptionsDialog *ui; + QList playerItems; + QString currentLanguage; + void setupTreeWidget(); + void setupLanguageBox(); + void applySettings(); }; #endif // OPTIONSDIALOG_H diff --git a/OptionsDialog.ui b/OptionsDialog.ui index c9297f3..e0522fb 100755 --- a/OptionsDialog.ui +++ b/OptionsDialog.ui @@ -11,7 +11,7 @@ - gta5sync - Options + gta5sync - Settings true @@ -75,9 +75,54 @@ + + + Players + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::ScrollPerPixel + + + true + + + true + + + + ID + + + + + Name + + + + + + - Localization + Language @@ -87,13 +132,7 @@ - - - - System - - - + diff --git a/PictureExport.cpp b/PictureExport.cpp index 4b3689e..aae549a 100755 --- a/PictureExport.cpp +++ b/PictureExport.cpp @@ -19,6 +19,7 @@ #include "PictureExport.h" #include "PictureDialog.h" #include "SidebarGenerator.h" +#include "config.h" #include #include #include @@ -30,7 +31,7 @@ PictureExport::PictureExport() void PictureExport::exportPicture(QWidget *parent, SnapmaticPicture *picture) { - QSettings settings("Syping", "gta5sync"); + QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); settings.beginGroup("FileDialogs"); fileDialogPreSave: diff --git a/ProfileDatabase.cpp b/ProfileDatabase.cpp index 8aa6124..a809c82 100755 --- a/ProfileDatabase.cpp +++ b/ProfileDatabase.cpp @@ -18,6 +18,7 @@ #include "ProfileDatabase.h" #include "StandardPaths.h" +#include "config.h" #include #include @@ -29,7 +30,7 @@ ProfileDatabase::ProfileDatabase(QObject *parent) : QObject(parent) QString dirPath = dir.absolutePath(); QString defaultConfPath = dirPath + QDir::separator() + "players.ini"; - QSettings confPathSettings("Syping","gta5sync"); + QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); confPathSettings.beginGroup("Database"); QString confPathFile = confPathSettings.value("Players", defaultConfPath).toString(); confPathSettings.endGroup(); diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index 9aafd0a..8324213 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -27,6 +27,7 @@ #include "StandardPaths.h" #include "ProfileLoader.h" #include "ExportThread.h" +#include "config.h" #include #include #include @@ -339,7 +340,7 @@ void ProfileInterface::on_cmdCloseProfile_clicked() void ProfileInterface::on_cmdImport_clicked() { - QSettings settings("Syping", "gta5sync"); + QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); settings.beginGroup("FileDialogs"); fileDialogPreOpen: diff --git a/SavegameCopy.cpp b/SavegameCopy.cpp index 2e9e510..89c73b8 100755 --- a/SavegameCopy.cpp +++ b/SavegameCopy.cpp @@ -19,6 +19,7 @@ #include "SidebarGenerator.h" #include "SavegameWidget.h" #include "SavegameCopy.h" +#include "config.h" #include #include #include @@ -30,7 +31,7 @@ SavegameCopy::SavegameCopy() void SavegameCopy::copySavegame(QWidget *parent, QString sgdPath) { - QSettings settings("Syping", "gta5sync"); + QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); settings.beginGroup("FileDialogs"); fileDialogPreSave: diff --git a/StringParser.cpp b/StringParser.cpp index 033a114..04a2684 100755 --- a/StringParser.cpp +++ b/StringParser.cpp @@ -17,10 +17,14 @@ *****************************************************************************/ #include "StringParser.h" +#include "config.h" +#include #include #include +#include #include #include +#include StringParser::StringParser() { @@ -46,3 +50,12 @@ QString StringParser::convertLogStringForDraw(const QString &inputStr) QString outputStr = inputStr; return outputStr.replace("&c;",",").replace("&u;","&"); } + +QString StringParser::convertBuildedString(const QString &buildedStr) +{ + QString outputStr = buildedStr; + outputStr.replace("$SEPARATOR", QDir::separator()); + outputStr.replace("$SHAREDIR", QString::fromUtf8(GTA5SYNC_SHARE)); + outputStr.replace("$RUNDIR", QFileInfo(qApp->applicationFilePath()).absoluteDir().absolutePath()); + return outputStr; +} diff --git a/StringParser.h b/StringParser.h index 4578ece..44346b6 100755 --- a/StringParser.h +++ b/StringParser.h @@ -29,6 +29,7 @@ public: static QString parseTitleString(const QByteArray &commitBytes, int maxLength); static QString convertDrawStringForLog(const QString &inputStr); static QString convertLogStringForDraw(const QString &inputStr); + static QString convertBuildedString(const QString &buildedStr); }; #endif // STRINGPARSER_H diff --git a/UserInterface.cpp b/UserInterface.cpp index 34e0c61..0b51dbe 100755 --- a/UserInterface.cpp +++ b/UserInterface.cpp @@ -24,6 +24,7 @@ #include "AboutDialog.h" #include "IconLoader.h" #include "AppEnv.h" +#include "config.h" #include #include #include @@ -45,7 +46,7 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D profileOpen = 0; profileUI = 0; ui->menuProfile->setEnabled(false); - defaultWindowTitle = this->windowTitle(); + defaultWindowTitle = tr("gta5sync - %1"); this->setWindowTitle(defaultWindowTitle.arg(tr("Select Profile"))); } @@ -70,7 +71,7 @@ void UserInterface::setupDirEnv() } // profiles init - QSettings SyncSettings("Syping", "gta5sync"); + QSettings SyncSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); SyncSettings.beginGroup("Profile"); QString defaultProfile = SyncSettings.value("Default", "").toString(); @@ -242,7 +243,7 @@ void UserInterface::on_actionDelete_selected_triggered() void UserInterface::on_actionOptions_triggered() { - OptionsDialog *optionsDialog = new OptionsDialog(this); + OptionsDialog *optionsDialog = new OptionsDialog(profileDB, this); optionsDialog->setWindowFlags(optionsDialog->windowFlags()^Qt::WindowContextHelpButtonHint); optionsDialog->setModal(true); optionsDialog->show(); diff --git a/UserInterface.ui b/UserInterface.ui index 1a2cef4..70f7062 100755 --- a/UserInterface.ui +++ b/UserInterface.ui @@ -128,7 +128,7 @@ 0 0 625 - 25 + 21 @@ -192,7 +192,7 @@ - &Options + &Settings Ctrl+O diff --git a/config.h b/config.h new file mode 100755 index 0000000..f6e87f1 --- /dev/null +++ b/config.h @@ -0,0 +1,50 @@ +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#ifndef CONFIG_H +#define CONFIG_H + +#ifndef GTA5SYNC_APPVENDOR +#define GTA5SYNC_APPVENDOR "Syping" +#endif + +#ifndef GTA5SYNC_APPSTR +#define GTA5SYNC_APPSTR "gta5sync" +#endif + +#ifndef GTA5SYNC_APPVER +#define GTA5SYNC_APPVER "1.0.0" +#endif + +#ifndef GTA5SYNC_BUILDTYPE +#define GTA5SYNC_BUILDTYPE "Custom" +#endif + +#ifndef GTA5SYNC_SHARE +#define GTA5SYNC_SHARE "$RUNDIR" +#endif + +#ifndef GTA5SYNC_LANG +#define GTA5SYNC_LANG "$SHAREDIR$SEPARATORlang" +#endif + +#ifndef GTA5SYNC_PLUG +#define GTA5SYNC_PLUG "$RUNDIR$SEPARATORplugins" +#endif + +#endif // CONFIG_H diff --git a/gta5sync.pro b/gta5sync.pro index b0df3a0..ac15dda 100755 --- a/gta5sync.pro +++ b/gta5sync.pro @@ -1,146 +1,147 @@ -#/***************************************************************************** -#* gta5sync GRAND THEFT AUTO V SYNC -#* Copyright (C) 2015-2016 Syping -#* -#* This program is free software: you can redistribute it and/or modify -#* it under the terms of the GNU General Public License as published by -#* the Free Software Foundation, either version 3 of the License, or -#* (at your option) any later version. -#* -#* This program is distributed in the hope that it will be useful, -#* but WITHOUT ANY WARRANTY; without even the implied warranty of -#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#* GNU General Public License for more details. -#* -#* You should have received a copy of the GNU General Public License -#* along with this program. If not, see . -#*****************************************************************************/ - -QT += core gui network - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = gta5sync -TEMPLATE = app - -SOURCES += main.cpp \ - AboutDialog.cpp \ - AppEnv.cpp \ - CrewDatabase.cpp \ - DatabaseThread.cpp \ - ExportThread.cpp \ - IconLoader.cpp \ - OptionsDialog.cpp \ - PictureCopy.cpp \ - PictureDialog.cpp \ - PictureExport.cpp \ - PictureWidget.cpp \ - ProfileDatabase.cpp \ - ProfileInterface.cpp \ - ProfileLoader.cpp \ - ProfileWidget.cpp \ - SavegameCopy.cpp \ - SavegameData.cpp \ - SavegameDialog.cpp \ - SavegameWidget.cpp \ - SidebarGenerator.cpp \ - SnapmaticPicture.cpp \ - SnapmaticWidget.cpp \ - StandardPaths.cpp \ - StringParser.cpp \ - UserInterface.cpp \ - uimod/UiModLabel.cpp - -HEADERS += \ - AboutDialog.h \ - AppEnv.h \ - CrewDatabase.h \ - DatabaseThread.h \ - ExportThread.h \ - IconLoader.h \ - OptionsDialog.h \ - PictureCopy.h \ - PictureDialog.h \ - PictureExport.h \ - PictureWidget.h \ - ProfileDatabase.h \ - ProfileInterface.h \ - ProfileLoader.h \ - ProfileWidget.h \ - SavegameCopy.h \ - SavegameData.h \ - SavegameDialog.h \ - SavegameWidget.h \ - SidebarGenerator.h \ - SnapmaticPicture.h \ - SnapmaticWidget.h \ - StandardPaths.h \ - StringParser.h \ - UserInterface.h \ - uimod/UiModLabel.h - -FORMS += \ - AboutDialog.ui \ - OptionsDialog.ui \ - PictureDialog.ui \ - ProfileInterface.ui \ - SavegameDialog.ui \ - SavegameWidget.ui \ - SnapmaticWidget.ui \ - UserInterface.ui - -TRANSLATIONS += \ - res/gta5sync_de.ts \ - lang/gta5sync_ru.ts - -RESOURCES += \ - res/app.qrc - -DISTFILES += res/app.rc \ - res/gta5sync.desktop \ - res/gta5sync_de.ts \ - lang/gta5sync_ru.qm \ - lang/qtbase_ru.qm \ - lang/README.txt \ - lang/gta5sync_ru.ts \ - lang/qt_ru.qm - -INCLUDEPATH += ./uimod - -# WINDOWS ONLY - -win32: DEFINES += GTA5SYNC_WIN -win32: RC_FILE += res/app.rc -win32: LIBS += -luser32 - -# QT4 ONLY STUFF - -isEqual(QT_MAJOR_VERSION, 4): INCLUDEPATH += ./qjson4 -isEqual(QT_MAJOR_VERSION, 4): HEADERS += qjson4/QJsonArray.h \ - qjson4/QJsonDocument.h \ - qjson4/QJsonObject.h \ - qjson4/QJsonParseError.h \ - qjson4/QJsonValue.h \ - qjson4/QJsonValueRef.h \ - qjson4/QJsonParser.h \ - qjson4/QJsonRoot.h - -isEqual(QT_MAJOR_VERSION, 4): SOURCES += qjson4/QJsonArray.cpp \ - qjson4/QJsonDocument.cpp \ - qjson4/QJsonObject.cpp \ - qjson4/QJsonParseError.cpp \ - qjson4/QJsonValue.cpp \ - qjson4/QJsonValueRef.cpp \ - qjson4/QJsonParser.cpp - -# UNIX SYSTEM STUFF - -unix: !macx: appfiles.path = $$(INSTALL_PATH)/share/applications -unix: !macx: appfiles.files = $$PWD/res/gta5sync.desktop -unix: !macx: pixmaps.path = $$(INSTALL_PATH)/share/pixmaps -unix: !macx: pixmaps.files = $$PWD/res/gta5sync.xpm -unix: !macx: target.path = $$(INSTALL_PATH)/bin -unix: !macx: INSTALLS += target pixmaps appfiles - -# STATIC BUILD STUFF -static: isEqual(QT_MAJOR_VERSION, 4): QTPLUGIN += qjpcodecs +#/***************************************************************************** +#* gta5sync GRAND THEFT AUTO V SYNC +#* Copyright (C) 2015-2016 Syping +#* +#* This program is free software: you can redistribute it and/or modify +#* it under the terms of the GNU General Public License as published by +#* the Free Software Foundation, either version 3 of the License, or +#* (at your option) any later version. +#* +#* This program is distributed in the hope that it will be useful, +#* but WITHOUT ANY WARRANTY; without even the implied warranty of +#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#* GNU General Public License for more details. +#* +#* You should have received a copy of the GNU General Public License +#* along with this program. If not, see . +#*****************************************************************************/ + +QT += core gui network + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = gta5sync +TEMPLATE = app + +SOURCES += main.cpp \ + AboutDialog.cpp \ + AppEnv.cpp \ + CrewDatabase.cpp \ + DatabaseThread.cpp \ + ExportThread.cpp \ + IconLoader.cpp \ + OptionsDialog.cpp \ + PictureCopy.cpp \ + PictureDialog.cpp \ + PictureExport.cpp \ + PictureWidget.cpp \ + ProfileDatabase.cpp \ + ProfileInterface.cpp \ + ProfileLoader.cpp \ + ProfileWidget.cpp \ + SavegameCopy.cpp \ + SavegameData.cpp \ + SavegameDialog.cpp \ + SavegameWidget.cpp \ + SidebarGenerator.cpp \ + SnapmaticPicture.cpp \ + SnapmaticWidget.cpp \ + StandardPaths.cpp \ + StringParser.cpp \ + UserInterface.cpp \ + uimod/UiModLabel.cpp + +HEADERS += \ + AboutDialog.h \ + AppEnv.h \ + config.h \ + CrewDatabase.h \ + DatabaseThread.h \ + ExportThread.h \ + IconLoader.h \ + OptionsDialog.h \ + PictureCopy.h \ + PictureDialog.h \ + PictureExport.h \ + PictureWidget.h \ + ProfileDatabase.h \ + ProfileInterface.h \ + ProfileLoader.h \ + ProfileWidget.h \ + SavegameCopy.h \ + SavegameData.h \ + SavegameDialog.h \ + SavegameWidget.h \ + SidebarGenerator.h \ + SnapmaticPicture.h \ + SnapmaticWidget.h \ + StandardPaths.h \ + StringParser.h \ + UserInterface.h \ + uimod/UiModLabel.h + +FORMS += \ + AboutDialog.ui \ + OptionsDialog.ui \ + PictureDialog.ui \ + ProfileInterface.ui \ + SavegameDialog.ui \ + SavegameWidget.ui \ + SnapmaticWidget.ui \ + UserInterface.ui + +TRANSLATIONS += \ + res/gta5sync_de.ts \ + lang/gta5sync_ru.ts + +RESOURCES += \ + res/app.qrc + +DISTFILES += res/app.rc \ + res/gta5sync.desktop \ + res/gta5sync_de.ts \ + lang/gta5sync_ru.qm \ + lang/qtbase_ru.qm \ + lang/README.txt \ + lang/gta5sync_ru.ts \ + lang/qt_ru.qm + +INCLUDEPATH += ./uimod + +# WINDOWS ONLY + +win32: DEFINES += GTA5SYNC_WIN +win32: RC_FILE += res/app.rc +win32: LIBS += -luser32 + +# QT4 ONLY STUFF + +isEqual(QT_MAJOR_VERSION, 4): INCLUDEPATH += ./qjson4 +isEqual(QT_MAJOR_VERSION, 4): HEADERS += qjson4/QJsonArray.h \ + qjson4/QJsonDocument.h \ + qjson4/QJsonObject.h \ + qjson4/QJsonParseError.h \ + qjson4/QJsonValue.h \ + qjson4/QJsonValueRef.h \ + qjson4/QJsonParser.h \ + qjson4/QJsonRoot.h + +isEqual(QT_MAJOR_VERSION, 4): SOURCES += qjson4/QJsonArray.cpp \ + qjson4/QJsonDocument.cpp \ + qjson4/QJsonObject.cpp \ + qjson4/QJsonParseError.cpp \ + qjson4/QJsonValue.cpp \ + qjson4/QJsonValueRef.cpp \ + qjson4/QJsonParser.cpp + +# UNIX SYSTEM STUFF + +unix: !macx: appfiles.path = $$(INSTALL_PATH)/share/applications +unix: !macx: appfiles.files = $$PWD/res/gta5sync.desktop +unix: !macx: pixmaps.path = $$(INSTALL_PATH)/share/pixmaps +unix: !macx: pixmaps.files = $$PWD/res/gta5sync.xpm +unix: !macx: target.path = $$(INSTALL_PATH)/bin +unix: !macx: INSTALLS += target pixmaps appfiles + +# STATIC BUILD STUFF +static: isEqual(QT_MAJOR_VERSION, 4): QTPLUGIN += qjpcodecs diff --git a/lang/gta5sync_ru.ts b/lang/gta5sync_ru.ts index 0426d1b..815fc87 100755 --- a/lang/gta5sync_ru.ts +++ b/lang/gta5sync_ru.ts @@ -31,7 +31,7 @@ OptionsDialog - gta5sync - Options + gta5sync - Settings @@ -61,41 +61,70 @@ - Localization + Players - + + ID + + + + + Name + + + + + Language - - System - - - - + Sync - + Sync is not implemented at current time - + &OK OK, Cancel, Apply - + &Cancel OK, Cancel, Apply + + + %1 (%2 if available) [sys] + System like PC System = %1, System Language like Deutsch = %2 + + + + + System + System like PC System + + + + + %1 + %1 + + + + + The language change will take effect after you restart %1. + + PictureDialog @@ -123,7 +152,7 @@ - + &Export @@ -180,31 +209,31 @@ Без группы - + Export as JPG picture... - + JPEG picture (*.jpg) Картинка JPEG (*.jpg) - + Portable Network Graphics (*.png) Картинка Portable Network Graphics (*.png) - - - - + + + + Export as JPG picture - + Overwrite %1 with current Snapmatic picture? Перезаписать %1 текущей картинкой Snapmatic? @@ -218,18 +247,18 @@ - + Failed to overwrite %1 with current Snapmatic picture Не удалось перезаписать %1 картинкой Snapmatic - + Failed to export current Snapmatic picture Не удалось экспортировать текущую картинку Snapmatic - + No valid file is selected Выбранный файл неверен @@ -299,136 +328,136 @@ Закрыть профиль - + Loading... Загрузка... - + Import... - - - - - - - - - - - + + + + + + + + + + + Import - + All profile files (SGTA* PGTA*) Все файлы профиля (SGTA* PGTA*) - + Savegames files (SGTA*) Файлы сохранения (SGTA*) - + Snapmatic pictures (PGTA*) Картинка Snapmatic (PGTA*) - + All files (**) Все файлы (**) - + Import failed with... %1 - + Failed to read Snapmatic picture Не удалось загрузить картинку Snapmatic - + Failed to read Savegame file Не удалось загрузить файл сохранения - + Can't import %1 because of not valid file format Не получилось импортировать %1 из-за неправильного формата файла - - + + No valid file is selected Выбранный файл неверен - + Failed to import the Snapmatic picture, file not begin with PGTA - + Failed to import the Snapmatic picture, can't copy the file into profile - + Failed to import the Savegame, can't copy the file into profile - + Failed to import the Savegame, no Savegame slot is left - - + + JPG pictures and GTA Snapmatic - - + + JPG pictures only - - + + GTA Snapmatic only - - + + No Snapmatic pictures or Savegames files are selected - - - + + + Remove selected - + You really want remove the selected Snapmatic picutres and Savegame files? - + Failed at remove the complete selected Snapmatic pictures and/or Savegame files @@ -449,30 +478,30 @@ Не получилось имортировать копию сохранения, потому что не осталось свободных под них слотов - - - - + + + + Export selected - + %1Export Snapmatic pictures%2<br><br>JPG pictures make it possible to open the picture with a Image Viewer<br>GTA Snapmatic make it possible to import the picture into the game<br><br>Export as: - + Export selected... - + Initializing export... - + Export failed with... %1 @@ -615,41 +644,41 @@ Копировать сохранение - + &Export - + Savegame files (SGTA*) Файлы сохранений (SGTA*) - + All files (**) Все файлы (**) - - - - + + + + Export Savegame - + Overwrite %1 with current Savegame? - + Failed to overwrite %1 with current Savegame - + Failed to export current Savegame @@ -666,7 +695,7 @@ Не удалось скопировать текущее сохранение - + No valid file is selected Выбранный файл неверен @@ -787,6 +816,7 @@ UserInterface + gta5sync - %1 gta5sync - %1 @@ -820,6 +850,11 @@ &About gta5sync + + + &Settings + + &Import files... @@ -836,11 +871,6 @@ &Close - - - &Options - - Select &All @@ -923,19 +953,19 @@ - - + + Select Profile - - + + Select GTA V Folder... - + Select GTA V &Folder... diff --git a/main.cpp b/main.cpp index d8b0607..bfc8f80 100755 --- a/main.cpp +++ b/main.cpp @@ -25,6 +25,8 @@ #include "CrewDatabase.h" #include "SavegameData.h" #include "IconLoader.h" +#include "AppEnv.h" +#include "config.h" #include #include #include @@ -46,8 +48,8 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - a.setApplicationName("gta5sync"); - a.setApplicationVersion("1.0.0"); + a.setApplicationName(GTA5SYNC_APPSTR); + a.setApplicationVersion(GTA5SYNC_APPVER); #ifdef GTA5SYNC_WIN // Get Windows Font @@ -65,24 +67,20 @@ int main(int argc, char *argv[]) a.setFont(appFont); #endif - QDir appDir = QFileInfo(a.applicationFilePath()).absoluteDir(); - if (appDir.cd("plugins")) + QString pluginsDir = AppEnv::getPluginsFolder(); + if (QFileInfo(pluginsDir).exists()) { - a.addLibraryPath(appDir.path()); - appDir.cdUp(); + a.addLibraryPath(pluginsDir); } - appDir.mkdir("lang"); - appDir.cd("lang"); // Loading translation settings - QSettings settings("Syping", "gta5sync"); + QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); settings.beginGroup("Interface"); QString language = settings.value("Language","System").toString(); settings.endGroup(); // Start external translate loading - QString langpath = a.applicationFilePath(); - langpath = appDir.absolutePath(); + QString langpath = AppEnv::getLangFolder(); bool trsf = false; bool svlp = false; QTranslator EappTranslator; diff --git a/res/gta5sync_de.ts b/res/gta5sync_de.ts index 7947da9..9708142 100755 --- a/res/gta5sync_de.ts +++ b/res/gta5sync_de.ts @@ -38,9 +38,13 @@ Optionen - gta5sync - Options - gta5sync - Optionen + gta5sync - Optionen + + + + gta5sync - Settings + @@ -69,41 +73,70 @@ - Localization + Players - + + ID + + + + + Name + + + + + Language - - System - - - - + Sync - + Sync is not implemented at current time - + &OK OK, Cancel, Apply &OK - + &Cancel OK, Cancel, Apply Abbre&chen + + + %1 (%2 if available) [sys] + System like PC System = %1, System Language like Deutsch = %2 + + + + + System + System like PC System + + + + + %1 + %1 + + + + + The language change will take effect after you restart %1. + + PictureDialog @@ -115,7 +148,7 @@ - + &Export &Exportieren @@ -201,31 +234,31 @@ Exportiere Bild... - + Export as JPG picture... Exportiere als JPG Bild... - + JPEG picture (*.jpg) JPEG Bild (*.jpg) - + Portable Network Graphics (*.png) Portable Network Graphics (*.png) - - - - + + + + Export as JPG picture Exportiere als JPG Bild - + Overwrite %1 with current Snapmatic picture? Überschreibe %1 mit aktuellen Snapmatic Bild? @@ -239,12 +272,12 @@ - + Failed to overwrite %1 with current Snapmatic picture Fehlgeschlagen beim Überschreiben von %1 mit aktuellen Snapmatic Bild - + Failed to export current Snapmatic picture Fehlgeschlagen beim Exportieren vom aktuellen Snapmatic Bild @@ -299,7 +332,7 @@ - + No valid file is selected Keine gültige Datei wurde ausgewählt @@ -354,52 +387,52 @@ Profil schließen - + Loading... Lade... - + Import... Importieren... - - - - - - - - - - - + + + + + + + + + + + Import Importieren - + All profile files (SGTA* PGTA*) Alle Profildateien (SGTA* PGTA*) - + Savegames files (SGTA*) Spielstanddateien (SGTA*) - + Snapmatic pictures (PGTA*) Snapmatic Bilder (PGTA*) - + All files (**) Alle Dateien (**) - + Import failed with... %1 @@ -408,66 +441,66 @@ %1 - + Failed to read Snapmatic picture Fehler beim Lesen vom Snapmatic Bild - + Failed to read Savegame file Fehler beim Lesen von Spielstanddatei - + Can't import %1 because of not valid file format Kann %1 nicht importieren weil das Dateiformat nicht gültig ist - + %1Export Snapmatic pictures%2<br><br>JPG pictures make it possible to open the picture with a Image Viewer<br>GTA Snapmatic make it possible to import the picture into the game<br><br>Export as: %1Exportiere Snapmatic Bilder%2<br><br>JPG Bilder machen es möglich sie mit ein Bildansicht Programm zu öffnen<br>Das GTA Snapmatic Format macht es möglich sie wieder ins Game zu importieren<br><br>Exportieren als: - - + + No valid file is selected Keine gültige Datei wurde ausgewählt - + Failed to import the Snapmatic picture, file not begin with PGTA Fehlgeschlagen beim Importieren vom Snapmatic Bild, Datei beginnt nicht mit PGTA - + Failed to import the Snapmatic picture, can't copy the file into profile Fehlgeschlagen beim Importieren vom Snapmatic Bild, kann Snapmatic Bild nicht ins Profil kopieren - + Failed to import the Savegame, can't copy the file into profile Fehlgeschlagen beim Importieren vom Spielstand, kann Spielstanddatei nicht ins Profil kopieren - + Failed to import the Savegame, no Savegame slot is left Fehlgeschlagen beim Importieren vom Spielstand, kein Spielstandslot mehr frei - - + + JPG pictures and GTA Snapmatic JPG Bilder und GTA Snapmatic - - + + JPG pictures only Nur JPG Bilder - - + + GTA Snapmatic only Nur GTA Snapmatic @@ -486,25 +519,25 @@ Das GTA Snapmatic Format macht es möglich sie wieder ins Game zu importieren Exportieren als: - - + + No Snapmatic pictures or Savegames files are selected Keine Snapmatic Bilder oder Spielstände ausgewählt - - - + + + Remove selected Auswahl löschen - + You really want remove the selected Snapmatic picutres and Savegame files? Möchtest du wirklich die ausgewählten Snapmatic Bilder und Spielstanddateien löschen? - + Failed at remove the complete selected Snapmatic pictures and/or Savegame files Fehlgeschlagen beim kompletten entfernen der ausgewählten Snapmatic Bilder und/oder der Spielstanddateien @@ -525,10 +558,10 @@ Exportieren als: Fehlgeschlagenen beim Import vom Spielstand weil kein Spielstandslot mehr übrig ist - - - - + + + + Export selected Auswahl exportieren @@ -549,12 +582,12 @@ Exportieren als: Wie sollen wir mit den Snapmatic Bilder umgehen? - + Export selected... Auswahl exportieren... - + Initializing export... Initialisiere Export... @@ -563,7 +596,7 @@ Exportieren als: Initialisierung... - + Export failed with... %1 @@ -746,41 +779,41 @@ Exportieren als: Spielstand kopieren - + &Export &Exportieren - + Savegame files (SGTA*) Spielstanddateien (SGTA*) - + All files (**) Alle Dateien (**) - - - - + + + + Export Savegame Spielstand exportieren - + Overwrite %1 with current Savegame? Überschreibe %1 mit aktuellen Spielstand? - + Failed to overwrite %1 with current Savegame Fehlgeschlagen beim Überschrieben von %1 mit aktuellen Spielstand - + Failed to export current Savegame Fehlgeschlagen beim Exportieren vom aktuellen Spielstand @@ -805,7 +838,7 @@ Exportieren als: Beim Kopieren vom Spielstand ist ein Fehler aufgetreten - + No valid file is selected Keine gültige Datei wurde ausgewählt @@ -978,6 +1011,7 @@ Exportieren als: + gta5sync - %1 gta5sync - %1 @@ -1110,9 +1144,13 @@ Exportieren als: Strg+P - &Options - &Optionen + &Optionen + + + + &Settings + @@ -1154,19 +1192,19 @@ Exportieren als: GTA V Ordner nicht gefunden! - - + + Select Profile Profil auswählen - - + + Select GTA V Folder... Wähle GTA V Ordner... - + Select GTA V &Folder... Wähle GTA V &Ordner...