don't try to import to same file when the same id is disabled

This commit is contained in:
Syping 2017-09-05 03:36:01 +02:00
parent 048979c4b7
commit dc0a007774
3 changed files with 35 additions and 30 deletions

View file

@ -31,6 +31,7 @@
#include "AppEnv.h" #include "AppEnv.h"
#include "config.h" #include "config.h"
#include <QProgressDialog> #include <QProgressDialog>
#include <QStringBuilder>
#include <QProgressBar> #include <QProgressBar>
#include <QInputDialog> #include <QInputDialog>
#include <QPushButton> #include <QPushButton>
@ -136,8 +137,8 @@ void ProfileInterface::savegameLoaded(SavegameData *savegame, QString savegamePa
SavegameWidget *sgdWidget = new SavegameWidget(this); SavegameWidget *sgdWidget = new SavegameWidget(this);
sgdWidget->setSavegameData(savegame, savegamePath); sgdWidget->setSavegameData(savegame, savegamePath);
sgdWidget->setContentMode(contentMode); sgdWidget->setContentMode(contentMode);
widgets[sgdWidget] = "SGD" + QFileInfo(savegamePath).fileName(); widgets[sgdWidget] = "SGD" % QFileInfo(savegamePath).fileName();
savegames.append(savegame); savegames += savegame;
if (selectedWidgts != 0 || contentMode == 2) { sgdWidget->setSelectionMode(true); } if (selectedWidgts != 0 || contentMode == 2) { sgdWidget->setSelectionMode(true); }
QObject::connect(sgdWidget, SIGNAL(savegameDeleted()), this, SLOT(savegameDeleted_event())); QObject::connect(sgdWidget, SIGNAL(savegameDeleted()), this, SLOT(savegameDeleted_event()));
QObject::connect(sgdWidget, SIGNAL(widgetSelected()), this, SLOT(profileWidgetSelected())); QObject::connect(sgdWidget, SIGNAL(widgetSelected()), this, SLOT(profileWidgetSelected()));
@ -158,8 +159,8 @@ void ProfileInterface::pictureLoaded(SnapmaticPicture *picture, bool inserted)
SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, crewDB, threadDB, this); SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, crewDB, threadDB, this);
picWidget->setSnapmaticPicture(picture); picWidget->setSnapmaticPicture(picture);
picWidget->setContentMode(contentMode); picWidget->setContentMode(contentMode);
widgets[picWidget] = "PIC" + picture->getPictureSortStr(); widgets[picWidget] = "PIC" % picture->getPictureSortStr();
pictures.append(picture); pictures += picture;
if (selectedWidgts != 0 || contentMode == 2) { picWidget->setSelectionMode(true); } if (selectedWidgts != 0 || contentMode == 2) { picWidget->setSelectionMode(true); }
QObject::connect(picWidget, SIGNAL(pictureDeleted()), this, SLOT(pictureDeleted_event())); QObject::connect(picWidget, SIGNAL(pictureDeleted()), this, SLOT(pictureDeleted_event()));
QObject::connect(picWidget, SIGNAL(widgetSelected()), this, SLOT(profileWidgetSelected())); QObject::connect(picWidget, SIGNAL(widgetSelected()), this, SLOT(profileWidgetSelected()));
@ -408,8 +409,8 @@ fileDialogPreOpen: //Work?
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls()); QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls); fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.setDirectory(settings.value(profileName + "+Directory", StandardPaths::documentsLocation()).toString()); fileDialog.setDirectory(settings.value(profileName % "+Directory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value(profileName + "+Geometry", "").toByteArray()); fileDialog.restoreGeometry(settings.value(profileName % "+Geometry", "").toByteArray());
if (fileDialog.exec()) if (fileDialog.exec())
{ {
@ -430,8 +431,8 @@ fileDialogPreOpen: //Work?
} }
} }
settings.setValue(profileName + "+Geometry", fileDialog.saveGeometry()); settings.setValue(profileName % "+Geometry", fileDialog.saveGeometry());
settings.setValue(profileName + "+Directory", fileDialog.directory().absolutePath()); settings.setValue(profileName % "+Directory", fileDialog.directory().absolutePath());
settings.endGroup(); settings.endGroup();
settings.endGroup(); settings.endGroup();
} }
@ -472,7 +473,7 @@ void ProfileInterface::importFilesProgress(QStringList selectedFiles)
pbDialog.close(); pbDialog.close();
foreach (const QString &curErrorStr, failedFiles) foreach (const QString &curErrorStr, failedFiles)
{ {
errorStr.append(", " + curErrorStr); errorStr += ", " % curErrorStr;
} }
if (errorStr != "") if (errorStr != "")
{ {
@ -583,14 +584,16 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
SnapmaticProperties spJson = picture->getSnapmaticProperties(); SnapmaticProperties spJson = picture->getSnapmaticProperties();
spJson.uid = QString(currentTime + spJson.uid = QString(currentTime +
QString::number(QDate::currentDate().dayOfYear())).toInt(); 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; int cEnough = 0;
while (fExists && cEnough < 5000) while ((fExists || fExistsHidden) && cEnough < 5000)
{ {
currentTime = QString::number(currentTime.toInt() - 1); currentTime = QString::number(currentTime.toInt() - 1);
spJson.uid = QString(currentTime + spJson.uid = QString(currentTime +
QString::number(QDate::currentDate().dayOfYear())).toInt(); 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++; cEnough++;
} }
spJson.createdDateTime = QDateTime::currentDateTime(); spJson.createdDateTime = QDateTime::currentDateTime();
@ -626,14 +629,16 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
SnapmaticProperties spJson = picture->getSnapmaticProperties(); SnapmaticProperties spJson = picture->getSnapmaticProperties();
spJson.uid = QString(currentTime + spJson.uid = QString(currentTime +
QString::number(QDate::currentDate().dayOfYear())).toInt(); 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; int cEnough = 0;
while (fExists && cEnough < 25) while ((fExists || fExistsHidden) && cEnough < 25)
{ {
currentTime = QString::number(currentTime.toInt() - 1); currentTime = QString::number(currentTime.toInt() - 1);
spJson.uid = QString(currentTime + spJson.uid = QString(currentTime +
QString::number(QDate::currentDate().dayOfYear())).toInt(); 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++; cEnough++;
} }
spJson.createdDateTime = QDateTime::currentDateTime(); spJson.createdDateTime = QDateTime::currentDateTime();
@ -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")); 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; 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")); if (warn) QMessageBox::warning(this, tr("Import"), tr("Failed to import the Snapmatic picture, the picture is already in the game"));
return false; return false;
} }
else if (picture->exportPicture(profileFolder + QDir::separator() + adjustedFileName, "PGTA")) else if (picture->exportPicture(profileFolder % QDir::separator() % adjustedFileName, "PGTA"))
{ {
picture->setPicFilePath(profileFolder + QDir::separator() + adjustedFileName); picture->setPicFilePath(profileFolder % QDir::separator() % adjustedFileName);
pictureLoaded(picture, true); pictureLoaded(picture, true);
return true; return true;
} }
@ -740,9 +745,9 @@ bool ProfileInterface::importSavegameData(SavegameData *savegame, QString sgdPat
{ {
sgdNumber.insert(0, "0"); 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; foundFree = true;
} }
@ -751,10 +756,10 @@ bool ProfileInterface::importSavegameData(SavegameData *savegame, QString sgdPat
if (foundFree) if (foundFree)
{ {
if (QFile::copy(sgdPath, profileFolder + QDir::separator() + sgdFileName)) if (QFile::copy(sgdPath, profileFolder % QDir::separator() % sgdFileName))
{ {
savegame->setSavegameFileName(profileFolder + QDir::separator() + sgdFileName); savegame->setSavegameFileName(profileFolder % QDir::separator() % sgdFileName);
savegameLoaded(savegame, profileFolder + QDir::separator() + sgdFileName, true); savegameLoaded(savegame, profileFolder % QDir::separator() % sgdFileName, true);
return true; return true;
} }
else else
@ -938,7 +943,7 @@ void ProfileInterface::exportSelected()
foreach (const QString &curErrorStr, errorList) foreach (const QString &curErrorStr, errorList)
{ {
errorStr.append(", " + curErrorStr); errorStr += ", " % curErrorStr;
} }
if (errorStr != "") if (errorStr != "")
{ {
@ -1149,7 +1154,7 @@ void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
{ {
if (currentUrl.isLocalFile()) if (currentUrl.isLocalFile())
{ {
pathList.append(currentUrl.toLocalFile()); pathList += currentUrl.toLocalFile();
} }
} }

View file

@ -50,7 +50,7 @@
#ifndef GTA5SYNC_APPVER #ifndef GTA5SYNC_APPVER
#ifndef GTA5SYNC_DAILYB #ifndef GTA5SYNC_DAILYB
#define GTA5SYNC_APPVER "1.4.1" #define GTA5SYNC_APPVER "1.4.2"
#else #else
#define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB) #define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB)
#endif #endif

View file

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