latest changes from gta5sync

1.5.x
Syping 5 years ago
parent cfdc36d207
commit 4169e86f31
  1. 2
      CrewDatabase.cpp
  2. 20
      OptionsDialog.cpp
  3. 2
      OptionsDialog.h
  4. 83
      PictureExport.cpp
  5. 2
      ProfileDatabase.cpp
  6. 65
      ProfileInterface.cpp
  7. 2
      ProfileInterface.h
  8. 6
      ProfileLoader.cpp
  9. 14
      SavegameCopy.cpp
  10. 4
      SavegameWidget.cpp
  11. 14
      SnapmaticEditor.cpp
  12. 100
      SnapmaticPicture.cpp
  13. 2
      SnapmaticPicture.h
  14. 33
      StringParser.cpp
  15. 4
      StringParser.h
  16. 48
      TranslationClass.cpp
  17. 13
      UserInterface.cpp
  18. 2
      UserInterface.h
  19. 7
      config.h
  20. 9
      gta5view.pro
  21. BIN
      res/gta5sync_de.qm
  22. 326
      res/gta5sync_de.ts
  23. BIN
      res/gta5sync_en_US.qm
  24. 322
      res/gta5sync_en_US.ts
  25. BIN
      res/gta5sync_fr.qm
  26. 318
      res/gta5sync_fr.ts
  27. BIN
      res/gta5sync_ru.qm
  28. 318
      res/gta5sync_ru.ts

@ -31,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 % "/crews.ini";
QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
confPathSettings.beginGroup("Database");

@ -171,17 +171,17 @@ void OptionsDialog::setupRadioButtons()
if (contentModeOk)
{
if (contentMode == 0)
switch (contentMode)
{
case 0:
ui->rbOpenWithSC->setChecked(true);
}
else if (contentMode == 1)
{
break;
case 1:
ui->rbOpenWithDC->setChecked(true);
}
else if (contentMode == 2)
{
break;
case 2:
ui->rbSelectWithSC->setChecked(true);
break;
}
}
}
@ -267,11 +267,7 @@ void OptionsDialog::applySettings()
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
emit settingsApplied(newContentMode, languageChanged);
if ((forceCustomFolder && ui->txtFolder->text() != currentCFolder) || (forceCustomFolder != currentFFolder && forceCustomFolder))
{

@ -48,7 +48,7 @@ private slots:
void on_cmdExploreFolder_clicked();
signals:
void settingsApplied(int contentMode, QString language);
void settingsApplied(int contentMode, bool languageChanged);
private:
ProfileDatabase *profileDB;

@ -30,6 +30,10 @@
#include <QRegExp>
#include <QDebug>
#if QT_VERSION >= 0x050000
#include <QSaveFile>
#endif
PictureExport::PictureExport()
{
@ -76,6 +80,7 @@ void PictureExport::exportAsPicture(QWidget *parent, SnapmaticPicture *picture)
// End Picture Settings
settings.beginGroup("FileDialogs");
bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("ExportAsPicture");
fileDialogPreSave: //Work?
@ -83,7 +88,7 @@ fileDialogPreSave: //Work?
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, dontUseNativeDialog);
fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true);
fileDialog.setDefaultSuffix("suffix");
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
@ -99,7 +104,7 @@ 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() % "+Geometry", "").toByteArray());
QString newPictureFileName = getPictureFileName(picture) % defaultExportFormat;
fileDialog.selectFile(newPictureFileName);
@ -142,15 +147,7 @@ fileDialogPreSave: //Work?
if (QFile::exists(selectedFile))
{
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 Picture"), PictureDialog::tr("Failed to overwrite %1 with current Snapmatic picture").arg("\""+selectedFile+"\""));
goto fileDialogPreSave; //Work?
}
}
else
if (QMessageBox::No == QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))
{
goto fileDialogPreSave; //Work?
}
@ -168,19 +165,51 @@ fileDialogPreSave: //Work?
exportPicture = exportPicture.scaled(cusExportSize, aspectRatio, Qt::SmoothTransformation);
}
bool isSaved;
if (useCustomQuality)
int errorId = 0;
bool isSaved = false;
#if QT_VERSION >= 0x050000
QSaveFile *picFile = new QSaveFile(selectedFile);
#else
QFile *picFile = new QFile(selectedFile);
#endif
if (picFile->open(QIODevice::WriteOnly))
{
isSaved = exportPicture.save(selectedFile, saveFileFormat.toStdString().c_str(), customQuality);
isSaved = exportPicture.save(picFile, saveFileFormat.toStdString().c_str(), useCustomQuality ? customQuality : defaultQuality);
#if QT_VERSION >= 0x050000
if (isSaved)
{
isSaved = picFile->commit();
}
else
{
errorId = 1;
}
#else
picFile->close();
#endif
}
else
{
isSaved = exportPicture.save(selectedFile, saveFileFormat.toStdString().c_str(), 100);
errorId = 2;
}
delete picFile;
if (!isSaved)
{
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to export current Snapmatic picture"));
switch (errorId)
{
case 0:
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to export the picture because the system occurred a write failure"));
break;
case 1:
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to export the picture because the format detection failures"));
break;
case 2:
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to export the picture because the file can't be written"));
break;
default:
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to export the picture because of an unknown reason"));
}
goto fileDialogPreSave; //Work?
}
}
@ -201,13 +230,10 @@ void PictureExport::exportAsSnapmatic(QWidget *parent, SnapmaticPicture *picture
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("ExportAsSnapmatic");
QString adjustedPicPath = picture->getPictureFileName();
if (adjustedPicPath.right(7) == ".hidden") // for the hidden file system
{
adjustedPicPath.remove(adjustedPicPath.length() - 7, 7);
}
QString adjustedPicPath = picture->getOriginalPictureFileName();
fileDialogPreSave: //Work?
QFileInfo sgdFileInfo(adjustedPicPath);
@ -215,7 +241,7 @@ fileDialogPreSave: //Work?
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, dontUseNativeDialog);
fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true);
fileDialog.setDefaultSuffix(".rem");
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
@ -232,9 +258,8 @@ fileDialogPreSave: //Work?
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.setDirectory(settings.value("Directory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value(parent->objectName() % "+Geometry", "").toByteArray());
fileDialog.selectFile(QString(picture->getExportPictureFileName() % ".g5e"));
fileDialog.restoreGeometry(settings.value(parent->objectName() % "+Geomtery", "").toByteArray());
if (fileDialog.exec())
{
@ -257,15 +282,7 @@ fileDialogPreSave: //Work?
if (QFile::exists(selectedFile))
{
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 Snapmatic"), PictureDialog::tr("Failed to overwrite %1 with current Snapmatic picture").arg("\""+selectedFile+"\""));
goto fileDialogPreSave; //Work?
}
}
else
if (QMessageBox::No == QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))
{
goto fileDialogPreSave; //Work?
}

@ -31,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 % "/players.ini";
QSettings confPathSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
confPathSettings.beginGroup("Database");

@ -414,6 +414,7 @@ void ProfileInterface::on_cmdImport_clicked()
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("ImportCopy");
fileDialogPreOpen: //Work?
@ -421,7 +422,7 @@ fileDialogPreOpen: //Work?
fileDialog.setFileMode(QFileDialog::ExistingFiles);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, dontUseNativeDialog);
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(tr("Import..."));
fileDialog.setLabelText(QFileDialog::Accept, tr("Import"));
@ -634,16 +635,16 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
SnapmaticProperties spJson = picture->getSnapmaticProperties();
spJson.uid = QString(currentTime +
QString::number(QDate::currentDate().dayOfYear())).toInt();
bool fExists = QFile::exists(profileFolder % QDir::separator() % "PGTA5" % QString::number(spJson.uid));
bool fExistsHidden = QFile::exists(profileFolder % QDir::separator() % "PGTA5" % QString::number(spJson.uid) % ".hidden");
bool fExists = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid));
bool fExistsHidden = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid) % ".hidden");
int cEnough = 0;
while ((fExists || fExistsHidden) && cEnough < 5000)
{
currentTime = QString::number(currentTime.toInt() - 1);
spJson.uid = QString(currentTime +
QString::number(QDate::currentDate().dayOfYear())).toInt();
fExists = QFile::exists(profileFolder % QDir::separator() % "PGTA5" % QString::number(spJson.uid));
fExistsHidden = QFile::exists(profileFolder % QDir::separator() % "PGTA5" % QString::number(spJson.uid) % ".hidden");
fExists = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid));
fExistsHidden = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid) % ".hidden");
cEnough++;
}
spJson.createdDateTime = QDateTime::currentDateTime();
@ -689,16 +690,16 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
SnapmaticProperties spJson = picture->getSnapmaticProperties();
spJson.uid = QString(currentTime +
QString::number(QDate::currentDate().dayOfYear())).toInt();
bool fExists = QFile::exists(profileFolder % QDir::separator() % "PGTA5" % QString::number(spJson.uid));
bool fExistsHidden = QFile::exists(profileFolder % QDir::separator() % "PGTA5" % QString::number(spJson.uid) % ".hidden");
bool fExists = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid));
bool fExistsHidden = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid) % ".hidden");
int cEnough = 0;
while ((fExists || fExistsHidden) && cEnough < 25)
{
currentTime = QString::number(currentTime.toInt() - 1);
spJson.uid = QString(currentTime +
QString::number(QDate::currentDate().dayOfYear())).toInt();
fExists = QFile::exists(profileFolder % QDir::separator() % "PGTA5" % QString::number(spJson.uid));
fExistsHidden = QFile::exists(profileFolder % QDir::separator() % "PGTA5" % QString::number(spJson.uid) % ".hidden");
fExists = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid));
fExistsHidden = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid) % ".hidden");
cEnough++;
}
spJson.createdDateTime = QDateTime::currentDateTime();
@ -764,28 +765,20 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, bool warn)
{
QString picFileName = picture->getPictureFileName();
QString adjustedFileName = picFileName;
if (adjustedFileName.right(7) == ".hidden") // for the hidden file system
{
adjustedFileName.remove(adjustedFileName.length() - 7, 7);
}
if (adjustedFileName.right(4) == ".bak") // for the backup file system
{
adjustedFileName.remove(adjustedFileName.length() - 4, 4);
}
QString adjustedFileName = picture->getOriginalPictureFileName();
if (picFileName.left(4) != "PGTA")
{
if (warn) QMessageBox::warning(this, tr("Import"), tr("Failed to import the Snapmatic picture, file not begin with PGTA or end with .g5e"));
return false;
}
else if (QFile::exists(profileFolder % QDir::separator() % adjustedFileName) || QFile::exists(profileFolder % QDir::separator() % adjustedFileName % ".hidden"))
else if (QFile::exists(profileFolder % "/" % adjustedFileName) || QFile::exists(profileFolder % "/" % adjustedFileName % ".hidden"))
{
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, SnapmaticFormat::PGTA_Format))
else if (picture->exportPicture(profileFolder % "/" % adjustedFileName, SnapmaticFormat::PGTA_Format))
{
picture->setPicFilePath(profileFolder % QDir::separator() % adjustedFileName);
picture->setPicFilePath(profileFolder % "/" % adjustedFileName);
pictureLoaded(picture, true);
return true;
}
@ -811,7 +804,7 @@ bool ProfileInterface::importSavegameData(SavegameData *savegame, QString sgdPat
}
sgdFileName = "SGTA500" % sgdNumber;
if (!QFile::exists(profileFolder % QDir::separator() % sgdFileName))
if (!QFile::exists(profileFolder % "/" % sgdFileName))
{
foundFree = true;
}
@ -820,10 +813,10 @@ bool ProfileInterface::importSavegameData(SavegameData *savegame, QString sgdPat
if (foundFree)
{
if (QFile::copy(sgdPath, profileFolder % QDir::separator() % sgdFileName))
if (QFile::copy(sgdPath, profileFolder % "/" % sgdFileName))
{
savegame->setSavegameFileName(profileFolder % QDir::separator() % sgdFileName);
savegameLoaded(savegame, profileFolder % QDir::separator() % sgdFileName, true);
savegame->setSavegameFileName(profileFolder % "/" % sgdFileName);
savegameLoaded(savegame, profileFolder % "/" % sgdFileName, true);
return true;
}
else
@ -896,6 +889,7 @@ void ProfileInterface::exportSelected()
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
//bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("ExportDirectory");
QString exportDirectory = QFileDialog::getExistingDirectory(this, tr("Export selected"), settings.value(profileName, profileFolder).toString());
if (exportDirectory != "")
@ -1085,24 +1079,17 @@ void ProfileInterface::importFiles()
on_cmdImport_clicked();
}
void ProfileInterface::settingsApplied(int _contentMode, QString _language)
void ProfileInterface::settingsApplied(int _contentMode, bool languageChanged)
{
bool translationUpdated = false;
if (language != _language)
{
retranslateUi();
language = _language;
translationUpdated = true;
}
if (languageChanged) retranslateUi();
contentMode = _contentMode;
if (contentMode == 2)
{
foreach(ProfileWidget *widget, widgets.keys())
{
widget->setSelectionMode(true);
widget->setContentMode(contentMode);
if (translationUpdated) widget->retranslate();
if (languageChanged) widget->retranslate();
}
}
else
@ -1114,7 +1101,7 @@ void ProfileInterface::settingsApplied(int _contentMode, QString _language)
widget->setSelectionMode(false);
}
widget->setContentMode(contentMode);
if (translationUpdated) widget->retranslate();
if (languageChanged) widget->retranslate();
}
}
}
@ -1184,10 +1171,10 @@ void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev)
{
editMenu.addAction(SnapmaticWidget::tr("Hide &In-game"), picWidget, SLOT(makePictureHiddenSlot()));
}
editMenu.addAction(SnapmaticWidget::tr("&Edit Properties..."), picWidget, SLOT(editSnapmaticProperties()));
editMenu.addAction(PictureDialog::tr("&Edit Properties..."), picWidget, SLOT(editSnapmaticProperties()));
QMenu exportMenu(SnapmaticWidget::tr("&Export"), this);
exportMenu.addAction(SnapmaticWidget::tr("Export as &Picture..."), picWidget, SLOT(on_cmdExport_clicked()));
exportMenu.addAction(SnapmaticWidget::tr("Export as &Snapmatic..."), picWidget, SLOT(on_cmdCopy_clicked()));
exportMenu.addAction(PictureDialog::tr("Export as &Picture..."), picWidget, SLOT(on_cmdExport_clicked()));
exportMenu.addAction(PictureDialog::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);

@ -45,7 +45,7 @@ class ProfileInterface : public QWidget
public:
explicit ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent = 0);
void setProfileFolder(QString folder, QString profile);
void settingsApplied(int contentMode, QString language);
void settingsApplied(int contentMode, bool languageChanged);
void setupProfileInterface();
void disableSelected();
void enableSelected();

@ -23,6 +23,8 @@
#include <QStringBuilder>
#include <QStringList>
#include <QString>
#include <QThread>
#include <QList>
#include <QFile>
#include <QDir>
@ -61,7 +63,7 @@ void ProfileLoader::run()
foreach(const QString &SavegameFile, SavegameFiles)
{
emit loadingProgress(curFile, maximumV);
QString sgdPath = profileFolder % QDir::separator() % SavegameFile;
QString sgdPath = profileFolder % "/" % SavegameFile;
SavegameData *savegame = new SavegameData(sgdPath);
if (savegame->readingSavegame())
{
@ -72,7 +74,7 @@ void ProfileLoader::run()
foreach(const QString &SnapmaticPic, SnapmaticPics)
{
emit loadingProgress(curFile, maximumV);
QString picturePath = profileFolder % QDir::separator() % SnapmaticPic;
QString picturePath = profileFolder % "/" % SnapmaticPic;
SnapmaticPicture *picture = new SnapmaticPicture(picturePath);
if (picture->readingPicture(true, true, true))
{

@ -18,8 +18,10 @@
#include "SidebarGenerator.h"
#include "SavegameWidget.h"
#include "StandardPaths.h"
#include "SavegameCopy.h"
#include "config.h"
#include <QStringBuilder>
#include <QMessageBox>
#include <QFileDialog>
#include <QSettings>
@ -32,7 +34,10 @@ SavegameCopy::SavegameCopy()
void SavegameCopy::copySavegame(QWidget *parent, QString sgdPath)
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("SavegameCopy");
fileDialogPreSave: //Work?
QFileInfo sgdFileInfo(sgdPath);
@ -40,7 +45,7 @@ fileDialogPreSave: //Work?
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, dontUseNativeDialog);
fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true);
fileDialog.setDefaultSuffix("");
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
@ -55,7 +60,8 @@ fileDialogPreSave: //Work?
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.restoreState(settings.value("CopySavegame","").toByteArray());
fileDialog.setDirectory(settings.value("Directory", StandardPaths::picturesLocation()).toString());
fileDialog.restoreGeometry(settings.value(parent->objectName() % "+Geometry", "").toByteArray());
fileDialog.selectFile(sgdFileInfo.fileName());
if (fileDialog.exec())
@ -95,6 +101,8 @@ fileDialogPreSave: //Work?
}
}
settings.setValue("CopySavegame", fileDialog.saveState());
settings.setValue(parent->objectName() % "+Geometry", fileDialog.saveGeometry());
settings.setValue("Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup();
}

@ -128,7 +128,7 @@ void SavegameWidget::on_cmdCopy_clicked()
void SavegameWidget::on_cmdDelete_clicked()
{
int uchoice = QMessageBox::question(this, tr("Delete savegame"), tr("Are you sure to delete %1 from your savegames?").arg("\""+sgdStr+"\""), QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
int uchoice = QMessageBox::question(this, tr("Delete Savegame"), tr("Are you sure to delete %1 from your savegames?").arg("\""+sgdStr+"\""), QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
if (uchoice == QMessageBox::Yes)
{
if (!QFile::exists(sgdPath))
@ -141,7 +141,7 @@ void SavegameWidget::on_cmdDelete_clicked()
}
else
{
QMessageBox::warning(this, tr("Delete savegame"), tr("Failed at deleting %1 from your savegames").arg("\""+sgdStr+"\""));
QMessageBox::warning(this, tr("Delete Savegame"), tr("Failed at deleting %1 from your savegames").arg("\""+sgdStr+"\""));
}
}
}

@ -225,22 +225,18 @@ void SnapmaticEditor::on_cmdApply_clicked()
localSpJson.isMeme = ui->cbMeme->isChecked();
if (smpic)
{
QString originalFileName = smpic->getPictureFilePath();
QString adjustedFileName = originalFileName;
if (adjustedFileName.right(7) == ".hidden") // for the hidden file system
{
adjustedFileName.remove(adjustedFileName.length() - 7, 7);
}
QString backupFileName = adjustedFileName % ".bak";
QString currentFilePath = smpic->getPictureFilePath();
QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName))
{
QFile::copy(adjustedFileName, backupFileName);
QFile::copy(currentFilePath, backupFileName);
}
SnapmaticProperties fallbackProperties = smpic->getSnapmaticProperties();
QString fallbackTitle = smpic->getPictureTitle();
smpic->setSnapmaticProperties(localSpJson);
smpic->setPictureTitle(snapmaticTitle);
if (!smpic->exportPicture(originalFileName))
if (!smpic->exportPicture(currentFilePath))
{
QMessageBox::warning(this, tr("Snapmatic Properties"), tr("Patching of Snapmatic Properties failed because of I/O Error"));
smpic->setSnapmaticProperties(fallbackProperties);

@ -33,6 +33,12 @@
#include <QSize>
#include <QFile>
#if QT_VERSION >= 0x050000
#include <QSaveFile>
#else
#include "StandardPaths.h"
#endif
// PARSER ALLOCATIONS
#define snapmaticHeaderLength 278
#define snapmaticUsefulLength 260
@ -546,6 +552,34 @@ QString SnapmaticPicture::getExportPictureFileName()
return picExportFileName;
}
QString SnapmaticPicture::getOriginalPictureFileName()
{
QString newPicFileName = picFileName;
if (picFileName.right(4) == ".bak")
{
newPicFileName = QString(picFileName).remove(picFileName.length() - 4, 4);
}
if (picFileName.right(7) == ".hidden")
{
newPicFileName = QString(picFileName).remove(picFileName.length() - 7, 7);
}
return newPicFileName;
}
QString SnapmaticPicture::getOriginalPictureFilePath()
{
QString newPicFilePath = picFilePath;
if (picFilePath.right(4) == ".bak")
{
newPicFilePath = QString(picFilePath).remove(picFilePath.length() - 4, 4);
}
if (picFilePath.right(7) == ".hidden")
{
newPicFilePath = QString(picFilePath).remove(picFilePath.length() - 7, 7);
}
return newPicFilePath;
}
QString SnapmaticPicture::getPictureFileName()
{
return picFileName;
@ -887,7 +921,13 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
}
}
QFile *picFile = new QFile(fileName);
bool saveSuccess = false;
bool writeFailure = false;
#if QT_VERSION >= 0x050000
QSaveFile *picFile = new QSaveFile(fileName);
#else
QFile *picFile = new QFile(StandardPaths::tempLocation() % "/" % QFileInfo(fileName).fileName() % ".tmp");
#endif
if (picFile->open(QIODevice::WriteOnly))
{
if (format == SnapmaticFormat::G5E_Format)
@ -913,16 +953,22 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
g5eHeader += QByteArray("FIL"); // Before File Name
g5eHeader += stockFileNameUTF8; // File Name
g5eHeader += QByteArray("COM"); // Before Compressed
picFile->write(g5eHeader);
if (picFile->write(g5eHeader) == -1) { writeFailure = true; }
if (!lowRamMode)
{
picFile->write(qCompress(rawPicContent, 9)); // Compressed Snapmatic
if (picFile->write(qCompress(rawPicContent, 9)) == -1) { writeFailure = true; } // Compressed Snapmatic
}
else
{
picFile->write(rawPicContent);
if (picFile->write(rawPicContent) == -1) { writeFailure = true; }
}
#if QT_VERSION >= 0x050000
if (writeFailure) { picFile->cancelWriting(); }
else { saveSuccess = picFile->commit(); }
#else
if (!writeFailure) { saveSuccess = true; }
picFile->close();
#endif
delete picFile;
}
else if (format == SnapmaticFormat::JPEG_Format)
@ -937,9 +983,15 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
{
jpegRawContent = jpegRawContent.left(jpegRawContentSizeE);
}
picFile->write(jpegRawContent);
if (picFile->write(jpegRawContent) == -1) { writeFailure = true; }
#if QT_VERSION >= 0x050000
if (writeFailure) { picFile->cancelWriting(); }
else { saveSuccess = picFile->commit(); }
#else
if (!writeFailure) { saveSuccess = true; }
picFile->close();
#endif
}
picFile->close();
delete picFile;
}
else
@ -947,21 +999,49 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
// Classic straight export
if (!lowRamMode)
{
picFile->write(rawPicContent);
if (picFile->write(rawPicContent) == -1) { writeFailure = true; }
}
else
{
picFile->write(qUncompress(rawPicContent));
if (picFile->write(qUncompress(rawPicContent)) == -1) { writeFailure = true; }
}
#if QT_VERSION >= 0x050000
if (writeFailure) { picFile->cancelWriting(); }
else { saveSuccess = picFile->commit(); }
#else
if (!writeFailure) { saveSuccess = true; }
picFile->close();
#endif
delete picFile;
}
return true;
#if QT_VERSION <= 0x050000
if (saveSuccess)
{
bool tempBakCreated = false;
if (QFile::exists(fileName))
{
if (!QFile::rename(fileName, fileName % ".tmp"))
{
QFile::remove(StandardPaths::tempLocation() % "/" % QFileInfo(fileName).fileName() % ".tmp");
return false;
}
tempBakCreated = true;
}
if (!QFile::rename(StandardPaths::tempLocation() % "/" % QFileInfo(fileName).fileName() % ".tmp", fileName))
{
QFile::remove(StandardPaths::tempLocation() % "/" % QFileInfo(fileName).fileName() % ".tmp");
if (tempBakCreated) { QFile::rename(fileName % ".tmp", fileName); }
return false;
}
if (tempBakCreated) { QFile::remove(fileName % ".tmp"); }
}
#endif
return saveSuccess;
}
else
{
delete picFile;
return false;
return saveSuccess;
}
}

@ -70,6 +70,8 @@ public:
QString getPictureFileName();
QString getPictureFilePath();
QString getExportPictureFileName();
QString getOriginalPictureFileName();
QString getOriginalPictureFilePath();
int getContentMaxLength();
bool setImage(const QImage &picture);
bool setPictureTitl(const QString &newTitle);

@ -17,12 +17,8 @@
*****************************************************************************/
#include "StringParser.h"
#include "config.h"
#include <QTextDocument>
#include <QLibraryInfo>
#ifndef GTA5VIEW_CMD
#include <QApplication>
#endif
#include <QTextCodec>
#include <QByteArray>
#include <QFileInfo>
@ -30,6 +26,11 @@
#include <QList>
#include <QDir>
#ifdef GTA5SYNC_PROJECT
#include <QApplication>
#include "config.h"
#endif
StringParser::StringParser()
{
@ -46,16 +47,25 @@ QString StringParser::parseTitleString(const QByteArray &commitBytes, int maxLen
QString StringParser::convertDrawStringForLog(const QString &inputStr)
{
QString outputStr = inputStr;
return outputStr.replace("&","&u;").replace(",","&c;");
return outputStr.replace("&","&u;").replace(",", "&c;");
}
QString StringParser::convertLogStringForDraw(const QString &inputStr)
{
QString outputStr = inputStr;
return outputStr.replace("&c;",",").replace("&u;","&");
return outputStr.replace("&c;",",").replace("&u;", "&");
}
#ifndef GTA5VIEW_CMD
QString StringParser::escapeString(const QString &toEscape)
{
#if QT_VERSION >= 0x050000
return toEscape.toHtmlEscaped();
#else
return Qt::escape(toEscape);
#endif
}
#ifdef GTA5SYNC_PROJECT
QString StringParser::convertBuildedString(const QString &buildedStr)
{
QString outputStr = buildedStr;
@ -69,12 +79,3 @@ QString StringParser::convertBuildedString(const QString &buildedStr)
return outputStr;
}
#endif
QString StringParser::escapeString(const QString &toEscape)
{
#if QT_VERSION >= 0x050000
return toEscape.toHtmlEscaped();
#else
return Qt::escape(toEscape);
#endif
}

@ -29,10 +29,10 @@ public:
static QString parseTitleString(const QByteArray &commitBytes, int maxLength);
static QString convertDrawStringForLog(const QString &inputStr);
static QString convertLogStringForDraw(const QString &inputStr);
#ifndef GTA5VIEW_CMD
static QString escapeString(const QString &toEscape);
#ifdef GTA5SYNC_PROJECT
static QString convertBuildedString(const QString &buildedStr);
#endif
static QString escapeString(const QString &toEscape);
};
#endif // STRINGPARSER_H

@ -301,14 +301,14 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla
if (langList.length() == 2)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
if (appTranslator->load(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
if (appTranslator->load(langPath % "/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");
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
isEnglishMode = false;
currentLanguage = languageName;
@ -317,14 +317,14 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla
}
}
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
if (appTranslator->load(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
isEnglishMode = false;
currentLanguage = languageName;
@ -356,14 +356,14 @@ bool TranslationClass::loadSystemTranslation_p(const QString &langPath, QTransla
else if (langList.length() == 1)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
if (appTranslator->load(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
isEnglishMode = false;
currentLanguage = languageName;
@ -390,28 +390,28 @@ bool TranslationClass::loadUserTranslation_p(const QString &langPath, QTranslato
if (langList.length() == 2)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
{
if (appTranslator->load(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % "_" % langList.at(1) % ".qm"))
if (appTranslator->load(langPath % "/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");
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/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");
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
if (appTranslator->load(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
currentLanguage = languageName;
return true;
@ -421,14 +421,14 @@ bool TranslationClass::loadUserTranslation_p(const QString &langPath, QTranslato
else if (langList.length() == 1)
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFile" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
qDebug() << "loadLanguageFile" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
if (QFile::exists(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
if (QFile::exists(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
if (appTranslator->load(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm"))
if (appTranslator->load(langPath % "/gta5sync_" % langList.at(0) % ".qm"))
{
#ifdef GTA5SYNC_DEBUG
qDebug() << "loadLanguageFileSuccess" << QString(langPath % QDir::separator() % "gta5sync_" % langList.at(0) % ".qm");
qDebug() << "loadLanguageFileSuccess" << QString(langPath % "/gta5sync_" % langList.at(0) % ".qm");
#endif
currentLanguage = languageName;
return true;

@ -132,7 +132,7 @@ void UserInterface::setupDirEnv()
if (folderExists)
{
QDir GTAV_ProfilesDir;
GTAV_ProfilesFolder = GTAV_Folder % QDir::separator() % "Profiles";
GTAV_ProfilesFolder = GTAV_Folder % "/Profiles";
GTAV_ProfilesDir.setPath(GTAV_ProfilesFolder);
GTAV_Profiles = GTAV_ProfilesDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::NoSort);
@ -213,7 +213,7 @@ void UserInterface::openProfile(const QString &profileName_)
ui->swProfile->addWidget(profileUI);
ui->swProfile->setCurrentWidget(profileUI);
profileUI->setProfileFolder(GTAV_ProfilesFolder % QDir::separator() % profileName, profileName);
profileUI->settingsApplied(contentMode, language);
profileUI->settingsApplied(contentMode, false);
profileUI->setupProfileInterface();
QObject::connect(profileUI, SIGNAL(profileClosed()), this, SLOT(closeProfile()));
QObject::connect(profileUI, SIGNAL(profileLoaded()), this, SLOT(profileLoaded()));
@ -323,7 +323,7 @@ void UserInterface::on_actionOptions_triggered()
OptionsDialog *optionsDialog = new OptionsDialog(profileDB, this);
optionsDialog->setWindowIcon(windowIcon());
optionsDialog->commitProfiles(GTAV_Profiles);
QObject::connect(optionsDialog, SIGNAL(settingsApplied(int, QString)), this, SLOT(settingsApplied(int, QString)));
QObject::connect(optionsDialog, SIGNAL(settingsApplied(int, bool)), this, SLOT(settingsApplied(int, bool)));
optionsDialog->setModal(true);
#ifdef Q_OS_ANDROID
@ -494,17 +494,16 @@ void UserInterface::openSavegameFile(SavegameData *savegame)
sgdDialog.exec();
}
void UserInterface::settingsApplied(int _contentMode, QString _language)
void UserInterface::settingsApplied(int _contentMode, bool languageChanged)
{
if (language != _language)
if (languageChanged)
{
retranslateUi();
language = _language;
}
contentMode = _contentMode;
if (profileOpen)
{
profileUI->settingsApplied(contentMode, language);
profileUI->settingsApplied(contentMode, languageChanged);
}
}

@ -62,7 +62,7 @@ private slots:
void on_actionSelect_GTA_Folder_triggered();
void on_action_Enable_In_game_triggered();
void on_action_Disable_In_game_triggered();
void settingsApplied(int contentMode, QString language);
void settingsApplied(int contentMode, bool languageChanged);
protected:
void closeEvent(QCloseEvent *ev);

@ -1,5 +1,5 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2016-2017 Syping
*
* This program is free software: you can redistribute it and/or modify
@ -18,7 +18,6 @@
#ifndef CONFIG_H
#define CONFIG_H
#include <QtGlobal>
#include <QString>
#ifndef GTA5SYNC_APPVENDOR
@ -95,12 +94,12 @@
#ifdef GTA5SYNC_DAILYB
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE "Daily Build"
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Daily Build")
#endif
#endif
#ifndef GTA5SYNC_BUILDTYPE
#define GTA5SYNC_BUILDTYPE "Custom"
#define GTA5SYNC_BUILDTYPE QT_TRANSLATE_NOOP("AboutDialog", "Custom")
#endif
#ifdef GTA5SYNC_QCONF

@ -21,13 +21,10 @@ QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
greaterThan(QT_MAJOR_VERSION, 4): greaterThan(QT_MINOR_VERSION, 1): win32: QT += winextras
DEFINES += GTA5SYNC_DISABLED
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
@ -136,6 +133,12 @@ DISTFILES += res/app.rc \
INCLUDEPATH += ./uimod
# GTA5SYNC/GTA5VIEW ONLY
DEFINES += GTA5SYNC_DISABLED
DEFINES += GTA5SYNC_PROJECT # Enable exclusive gta5sync/gta5view functions
DEFINES += GTA5SYNC_CSDF # Not assisting at proper usage of SnapmaticPicture class
# WINDOWS ONLY
win32: DEFINES += GTA5SYNC_WIN

Binary file not shown.

@ -219,35 +219,41 @@ Pictures and Savegames</source>
Grand Theft Auto V Snapmatic Bilder und Spielständen</translation>
</message>
<message>
<location filename="../config.h" line="62"/>
<location filename="../config.h" line="61"/>
<source>Release</source>
<translation>Release</translation>
</message>
<message>
<location filename="../config.h" line="68"/>
<location filename="../config.h" line="67"/>
<source>Release Candidate</source>
<translation>Release Candidate</translation>
</message>
<message>
<location filename="../config.h" line="74"/>
<location filename="../config.h" line="73"/>
<location filename="../config.h" line="97"/>
<source>Daily Build</source>
<translation>Daily Build</translation>