Prevent user to import a hidden Snapmatic twice

This commit is contained in:
Rafael 2016-10-27 07:19:51 +02:00
parent 7d59566f80
commit 40012b1b46

View file

@ -487,11 +487,21 @@ bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, QString
{
QFileInfo picFileInfo(picPath);
QString picFileName = picFileInfo.fileName();
QString adjustedFileName = picFileName;
if (adjustedFileName.right(7) == ".hidden") // for the hidden file system
{
adjustedFileName.remove(adjustedFileName.length() - 7, 7);
}
if (picFileName.left(4) != "PGTA")
{
if (warn) QMessageBox::warning(this, tr("Import"), tr("Failed to import the Snapmatic picture, file not begin with PGTA"));
return false;
}
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 (QFile::copy(picPath, profileFolder + QDir::separator() + picFileName))
{
picture->setPicFileName(profileFolder + QDir::separator() + picFileName);