Skip to content

Commit

Permalink
don't try to import to same file when the same id is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Syping committed Sep 5, 2017
1 parent 048979c commit dc0a007
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 30 deletions.
55 changes: 30 additions & 25 deletions ProfileInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "AppEnv.h"
#include "config.h"
#include <QProgressDialog>
#include <QStringBuilder>
#include <QProgressBar>
#include <QInputDialog>
#include <QPushButton>
Expand Down Expand Up @@ -136,8 +137,8 @@ void ProfileInterface::savegameLoaded(SavegameData *savegame, QString savegamePa
SavegameWidget *sgdWidget = new SavegameWidget(this);
sgdWidget->setSavegameData(savegame, savegamePath);
sgdWidget->setContentMode(contentMode);
widgets[sgdWidget] = "SGD" + QFileInfo(savegamePath).fileName();
savegames.append(savegame);
widgets[sgdWidget] = "SGD" % QFileInfo(savegamePath).fileName();
savegames += savegame;
if (selectedWidgts != 0 || contentMode == 2) { sgdWidget->setSelectionMode(true); }
QObject::connect(sgdWidget, SIGNAL(savegameDeleted()), this, SLOT(savegameDeleted_event()));
QObject::connect(sgdWidget, SIGNAL(widgetSelected()), this, SLOT(profileWidgetSelected()));
Expand All @@ -158,8 +159,8 @@ void ProfileInterface::pictureLoaded(SnapmaticPicture *picture, bool inserted)
SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, crewDB, threadDB, this);
picWidget->setSnapmaticPicture(picture);
picWidget->setContentMode(contentMode);
widgets[picWidget] = "PIC" + picture->getPictureSortStr();
pictures.append(picture);
widgets[picWidget] = "PIC" % picture->getPictureSortStr();
pictures += picture;
if (selectedWidgts != 0 || contentMode == 2) { picWidget->setSelectionMode(true); }
QObject::connect(picWidget, SIGNAL(pictureDeleted()), this, SLOT(pictureDeleted_event()));
QObject::connect(picWidget, SIGNAL(widgetSelected()), this, SLOT(profileWidgetSelected()));
Expand Down Expand Up @@ -408,8 +409,8 @@ void ProfileInterface::on_cmdImport_clicked()
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());

fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.setDirectory(settings.value(profileName + "+Directory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value(profileName + "+Geometry", "").toByteArray());
fileDialog.setDirectory(settings.value(profileName % "+Directory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value(profileName % "+Geometry", "").toByteArray());

if (fileDialog.exec())
{
Expand All @@ -430,8 +431,8 @@ void ProfileInterface::on_cmdImport_clicked()
}
}

settings.setValue(profileName + "+Geometry", fileDialog.saveGeometry());
settings.setValue(profileName + "+Directory", fileDialog.directory().absolutePath());
settings.setValue(profileName % "+Geometry", fileDialog.saveGeometry());
settings.setValue(profileName % "+Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup();
}
Expand Down Expand Up @@ -472,7 +473,7 @@ void ProfileInterface::importFilesProgress(QStringList selectedFiles)
pbDialog.close();
foreach (const QString &curErrorStr, failedFiles)
{
errorStr.append(", " + curErrorStr);
errorStr += ", " % curErrorStr;
}
if (errorStr != "")
{
Expand Down Expand Up @@ -583,14 +584,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(QString(profileFolder + QDir::separator() + "PGTA5" + QString::number(spJson.uid)));
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");
int cEnough = 0;
while (fExists && cEnough < 5000)
while ((fExists || fExistsHidden) && cEnough < 5000)
{
currentTime = QString::number(currentTime.toInt() - 1);
spJson.uid = QString(currentTime +
QString::number(QDate::currentDate().dayOfYear())).toInt();
fExists = QFile::exists(QString(profileFolder + QDir::separator() + "PGTA5" + QString::number(spJson.uid)));
fExists = QFile::exists(profileFolder % QDir::separator() % "PGTA5" % QString::number(spJson.uid));
fExistsHidden = QFile::exists(profileFolder % QDir::separator() % "PGTA5" % QString::number(spJson.uid) % ".hidden");
cEnough++;
}
spJson.createdDateTime = QDateTime::currentDateTime();
Expand Down Expand Up @@ -626,14 +629,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(QString( profileFolder + QDir::separator() + "PGTA5" + QString::number(spJson.uid) ));
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");
int cEnough = 0;
while (fExists && cEnough < 25)
while ((fExists || fExistsHidden) && cEnough < 25)
{
currentTime = QString::number(currentTime.toInt() - 1);
spJson.uid = QString(currentTime +
QString::number(QDate::currentDate().dayOfYear())).toInt();
fExists = QFile::exists(QString(profileFolder + QDir::separator() + "PGTA5" + QString::number(spJson.uid)));
fExists = QFile::exists(profileFolder % QDir::separator() % "PGTA5" % QString::number(spJson.uid));
fExistsHidden = QFile::exists(profileFolder % QDir::separator() % "PGTA5" % QString::number(spJson.uid) % ".hidden");
cEnough++;
}
spJson.createdDateTime = QDateTime::currentDateTime();
Expand Down Expand Up @@ -709,14 +714,14 @@ bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, bool wa
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 % QDir::separator() % adjustedFileName) || QFile::exists(profileFolder % QDir::separator() % 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, "PGTA"))
else if (picture->exportPicture(profileFolder % QDir::separator() % adjustedFileName, "PGTA"))
{
picture->setPicFilePath(profileFolder + QDir::separator() + adjustedFileName);
picture->setPicFilePath(profileFolder % QDir::separator() % adjustedFileName);
pictureLoaded(picture, true);
return true;
}
Expand All @@ -740,9 +745,9 @@ bool ProfileInterface::importSavegameData(SavegameData *savegame, QString sgdPat
{
sgdNumber.insert(0, "0");
}
sgdFileName = "SGTA500" + sgdNumber;
sgdFileName = "SGTA500" % sgdNumber;

if (!QFile::exists(profileFolder + QDir::separator() + sgdFileName))
if (!QFile::exists(profileFolder % QDir::separator() % sgdFileName))
{
foundFree = true;
}
Expand All @@ -751,10 +756,10 @@ bool ProfileInterface::importSavegameData(SavegameData *savegame, QString sgdPat

if (foundFree)
{
if (QFile::copy(sgdPath, profileFolder + QDir::separator() + sgdFileName))
if (QFile::copy(sgdPath, profileFolder % QDir::separator() % sgdFileName))
{
savegame->setSavegameFileName(profileFolder + QDir::separator() + sgdFileName);
savegameLoaded(savegame, profileFolder + QDir::separator() + sgdFileName, true);
savegame->setSavegameFileName(profileFolder % QDir::separator() % sgdFileName);
savegameLoaded(savegame, profileFolder % QDir::separator() % sgdFileName, true);
return true;
}
else
Expand Down Expand Up @@ -938,7 +943,7 @@ void ProfileInterface::exportSelected()

foreach (const QString &curErrorStr, errorList)
{
errorStr.append(", " + curErrorStr);
errorStr += ", " % curErrorStr;
}
if (errorStr != "")
{
Expand Down Expand Up @@ -1149,7 +1154,7 @@ void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
{
if (currentUrl.isLocalFile())
{
pathList.append(currentUrl.toLocalFile());
pathList += currentUrl.toLocalFile();
}
}

Expand Down
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

#ifndef GTA5SYNC_APPVER
#ifndef GTA5SYNC_DAILYB
#define GTA5SYNC_APPVER "1.4.1"
#define GTA5SYNC_APPVER "1.4.2"
#else
#define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB)
#endif
Expand Down
8 changes: 4 additions & 4 deletions res/app.rc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gta5view.exe.manifest"
#include <windows.h>

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1, 4, 1, 0
PRODUCTVERSION 1, 4, 1, 0
FILEVERSION 1, 4, 2, 0
PRODUCTVERSION 1, 4, 2, 0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0
FILEOS VOS_NT_WINDOWS32
Expand All @@ -25,12 +25,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Syping"
VALUE "FileDescription", "gta5view\0"
VALUE "FileVersion", "1.4.1\0"
VALUE "FileVersion", "1.4.2\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.1\0"
VALUE "ProductVersion", "1.4.2\0"
END
END
END

0 comments on commit dc0a007

Please sign in to comment.