import and export open dialog bug fix
This commit is contained in:
parent
6506f56d00
commit
4c1e407cf3
3 changed files with 351 additions and 320 deletions
|
@ -149,6 +149,7 @@ void PictureDialog::on_cmdExport_clicked()
|
||||||
QSettings settings("Syping", "gta5sync");
|
QSettings settings("Syping", "gta5sync");
|
||||||
settings.beginGroup("FileDialogs");
|
settings.beginGroup("FileDialogs");
|
||||||
|
|
||||||
|
fileDialogPreSave:
|
||||||
QFileDialog fileDialog(this);
|
QFileDialog fileDialog(this);
|
||||||
fileDialog.setFileMode(QFileDialog::AnyFile);
|
fileDialog.setFileMode(QFileDialog::AnyFile);
|
||||||
fileDialog.setViewMode(QFileDialog::Detail);
|
fileDialog.setViewMode(QFileDialog::Detail);
|
||||||
|
@ -192,7 +193,6 @@ void PictureDialog::on_cmdExport_clicked()
|
||||||
fileDialog.setSidebarUrls(sidebarUrls);
|
fileDialog.setSidebarUrls(sidebarUrls);
|
||||||
fileDialog.restoreState(settings.value("ExportPicture","").toByteArray());
|
fileDialog.restoreState(settings.value("ExportPicture","").toByteArray());
|
||||||
|
|
||||||
fileDialogPreSave:
|
|
||||||
if (fileDialog.exec())
|
if (fileDialog.exec())
|
||||||
{
|
{
|
||||||
QStringList selectedFiles = fileDialog.selectedFiles();
|
QStringList selectedFiles = fileDialog.selectedFiles();
|
||||||
|
|
|
@ -1,317 +1,347 @@
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* gta5sync GRAND THEFT AUTO V SYNC
|
* gta5sync GRAND THEFT AUTO V SYNC
|
||||||
* Copyright (C) 2016 Syping
|
* Copyright (C) 2016 Syping
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "ProfileInterface.h"
|
#include "ProfileInterface.h"
|
||||||
#include "ui_ProfileInterface.h"
|
#include "ui_ProfileInterface.h"
|
||||||
#include "SnapmaticWidget.h"
|
#include "SnapmaticWidget.h"
|
||||||
#include "DatabaseThread.h"
|
#include "DatabaseThread.h"
|
||||||
#include "SavegameWidget.h"
|
#include "SavegameWidget.h"
|
||||||
#include "StandardPaths.h"
|
#include "StandardPaths.h"
|
||||||
#include "ProfileLoader.h"
|
#include "ProfileLoader.h"
|
||||||
#include <QSpacerItem>
|
#include <QSpacerItem>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent) :
|
ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent) :
|
||||||
QWidget(parent), profileDB(profileDB), crewDB(crewDB), threadDB(threadDB),
|
QWidget(parent), profileDB(profileDB), crewDB(crewDB), threadDB(threadDB),
|
||||||
ui(new Ui::ProfileInterface)
|
ui(new Ui::ProfileInterface)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->cmdImport->setEnabled(false);
|
ui->cmdImport->setEnabled(false);
|
||||||
ui->cmdCloseProfile->setEnabled(false);
|
ui->cmdCloseProfile->setEnabled(false);
|
||||||
loadingStr = ui->labProfileLoading->text();
|
loadingStr = ui->labProfileLoading->text();
|
||||||
profileFolder = "";
|
profileFolder = "";
|
||||||
profileLoader = 0;
|
profileLoader = 0;
|
||||||
saSpacerItem = 0;
|
saSpacerItem = 0;
|
||||||
|
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
QColor baseColor = palette.base().color();
|
QColor baseColor = palette.base().color();
|
||||||
ui->saProfile->setStyleSheet("QWidget#saProfileContent{background-color: rgb(" + QString::number(baseColor.red()) + "," + QString::number(baseColor.green()) + "," + QString::number(baseColor.blue()) + ")}");
|
ui->saProfile->setStyleSheet("QWidget#saProfileContent{background-color: rgb(" + QString::number(baseColor.red()) + "," + QString::number(baseColor.green()) + "," + QString::number(baseColor.blue()) + ")}");
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileInterface::~ProfileInterface()
|
ProfileInterface::~ProfileInterface()
|
||||||
{
|
{
|
||||||
foreach(SavegameData *savegame, savegames)
|
foreach(SavegameData *savegame, savegames)
|
||||||
{
|
{
|
||||||
savegame->deleteLater();
|
savegame->deleteLater();
|
||||||
delete savegame;
|
delete savegame;
|
||||||
}
|
}
|
||||||
foreach(SnapmaticPicture *picture, pictures)
|
foreach(SnapmaticPicture *picture, pictures)
|
||||||
{
|
{
|
||||||
pictures.removeAll(picture);
|
pictures.removeAll(picture);
|
||||||
picture->deleteLater();
|
picture->deleteLater();
|
||||||
delete picture;
|
delete picture;
|
||||||
}
|
}
|
||||||
foreach(QWidget *widget, widgets)
|
foreach(QWidget *widget, widgets)
|
||||||
{
|
{
|
||||||
widgets.removeAll(widget);
|
widgets.removeAll(widget);
|
||||||
widget->deleteLater();
|
widget->deleteLater();
|
||||||
delete widget;
|
delete widget;
|
||||||
}
|
}
|
||||||
profileLoader->deleteLater();
|
profileLoader->deleteLater();
|
||||||
delete profileLoader;
|
delete profileLoader;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileInterface::setProfileFolder(QString folder, QString profile)
|
void ProfileInterface::setProfileFolder(QString folder, QString profile)
|
||||||
{
|
{
|
||||||
profileFolder = folder;
|
profileFolder = folder;
|
||||||
profileName = profile;
|
profileName = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileInterface::setupProfileInterface()
|
void ProfileInterface::setupProfileInterface()
|
||||||
{
|
{
|
||||||
ui->labProfileLoading->setText(tr("Loading..."));
|
ui->labProfileLoading->setText(tr("Loading..."));
|
||||||
profileLoader = new ProfileLoader(profileFolder, crewDB);
|
profileLoader = new ProfileLoader(profileFolder, crewDB);
|
||||||
QObject::connect(profileLoader, SIGNAL(savegameLoaded(SavegameData*, QString)), this, SLOT(on_savegameLoaded(SavegameData*, QString)));
|
QObject::connect(profileLoader, SIGNAL(savegameLoaded(SavegameData*, QString)), this, SLOT(on_savegameLoaded(SavegameData*, QString)));
|
||||||
QObject::connect(profileLoader, SIGNAL(pictureLoaded(SnapmaticPicture*, QString)), this, SLOT(on_pictureLoaded(SnapmaticPicture*, QString)));
|
QObject::connect(profileLoader, SIGNAL(pictureLoaded(SnapmaticPicture*, QString)), this, SLOT(on_pictureLoaded(SnapmaticPicture*, QString)));
|
||||||
QObject::connect(profileLoader, SIGNAL(loadingProgress(int,int)), this, SLOT(on_loadingProgress(int,int)));
|
QObject::connect(profileLoader, SIGNAL(loadingProgress(int,int)), this, SLOT(on_loadingProgress(int,int)));
|
||||||
QObject::connect(profileLoader, SIGNAL(finished()), this, SLOT(on_profileLoaded()));
|
QObject::connect(profileLoader, SIGNAL(finished()), this, SLOT(on_profileLoaded()));
|
||||||
profileLoader->start();
|
profileLoader->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileInterface::on_savegameLoaded(SavegameData *savegame, QString savegamePath)
|
void ProfileInterface::on_savegameLoaded(SavegameData *savegame, QString savegamePath)
|
||||||
{
|
{
|
||||||
SavegameWidget *sgdWidget = new SavegameWidget();
|
SavegameWidget *sgdWidget = new SavegameWidget();
|
||||||
sgdWidget->setSavegameData(savegame, savegamePath);
|
sgdWidget->setSavegameData(savegame, savegamePath);
|
||||||
ui->vlSavegame->addWidget(sgdWidget);
|
ui->vlSavegame->addWidget(sgdWidget);
|
||||||
widgets.append(sgdWidget);
|
widgets.append(sgdWidget);
|
||||||
savegames.append(savegame);
|
savegames.append(savegame);
|
||||||
QObject::connect(sgdWidget, SIGNAL(savegameDeleted()), this, SLOT(on_savegameDeleted()));
|
QObject::connect(sgdWidget, SIGNAL(savegameDeleted()), this, SLOT(on_savegameDeleted()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileInterface::on_pictureLoaded(SnapmaticPicture *picture, QString picturePath)
|
void ProfileInterface::on_pictureLoaded(SnapmaticPicture *picture, QString picturePath)
|
||||||
{
|
{
|
||||||
SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, threadDB);
|
SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, threadDB);
|
||||||
picWidget->setSnapmaticPicture(picture, picturePath);
|
picWidget->setSnapmaticPicture(picture, picturePath);
|
||||||
ui->vlSnapmatic->addWidget(picWidget);
|
ui->vlSnapmatic->addWidget(picWidget);
|
||||||
widgets.append(picWidget);
|
widgets.append(picWidget);
|
||||||
pictures.append(picture);
|
pictures.append(picture);
|
||||||
QObject::connect(picWidget, SIGNAL(pictureDeleted()), this, SLOT(on_pictureDeleted()));
|
QObject::connect(picWidget, SIGNAL(pictureDeleted()), this, SLOT(on_pictureDeleted()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileInterface::on_loadingProgress(int value, int maximum)
|
void ProfileInterface::on_loadingProgress(int value, int maximum)
|
||||||
{
|
{
|
||||||
ui->pbPictureLoading->setMaximum(maximum);
|
ui->pbPictureLoading->setMaximum(maximum);
|
||||||
ui->pbPictureLoading->setValue(value);
|
ui->pbPictureLoading->setValue(value);
|
||||||
ui->labProfileLoading->setText(loadingStr.arg(QString::number(value), QString::number(maximum)));
|
ui->labProfileLoading->setText(loadingStr.arg(QString::number(value), QString::number(maximum)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileInterface::on_profileLoaded()
|
void ProfileInterface::on_profileLoaded()
|
||||||
{
|
{
|
||||||
saSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
saSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||||
ui->saProfileContent->layout()->addItem(saSpacerItem);
|
ui->saProfileContent->layout()->addItem(saSpacerItem);
|
||||||
ui->swProfile->setCurrentWidget(ui->pageProfile);
|
ui->swProfile->setCurrentWidget(ui->pageProfile);
|
||||||
ui->cmdCloseProfile->setEnabled(true);
|
ui->cmdCloseProfile->setEnabled(true);
|
||||||
ui->cmdImport->setEnabled(true);
|
ui->cmdImport->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileInterface::on_savegameDeleted()
|
void ProfileInterface::on_savegameDeleted()
|
||||||
{
|
{
|
||||||
SavegameWidget *sgdWidget = (SavegameWidget*)sender();
|
SavegameWidget *sgdWidget = (SavegameWidget*)sender();
|
||||||
widgets.removeAll(sgdWidget);
|
widgets.removeAll(sgdWidget);
|
||||||
sgdWidget->deleteLater();
|
sgdWidget->deleteLater();
|
||||||
delete sgdWidget;
|
delete sgdWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileInterface::on_pictureDeleted()
|
void ProfileInterface::on_pictureDeleted()
|
||||||
{
|
{
|
||||||
SnapmaticWidget *picWidget = (SnapmaticWidget*)sender();
|
SnapmaticWidget *picWidget = (SnapmaticWidget*)sender();
|
||||||
widgets.removeAll(picWidget);
|
widgets.removeAll(picWidget);
|
||||||
picWidget->deleteLater();
|
picWidget->deleteLater();
|
||||||
delete picWidget;
|
delete picWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileInterface::on_cmdCloseProfile_clicked()
|
void ProfileInterface::on_cmdCloseProfile_clicked()
|
||||||
{
|
{
|
||||||
emit profileClosed();
|
emit profileClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileInterface::on_cmdImport_clicked()
|
void ProfileInterface::on_cmdImport_clicked()
|
||||||
{
|
{
|
||||||
QSettings settings("Syping", "gta5sync");
|
QSettings settings("Syping", "gta5sync");
|
||||||
settings.beginGroup("FileDialogs");
|
settings.beginGroup("FileDialogs");
|
||||||
|
|
||||||
QFileDialog fileDialog(this);
|
fileDialogPreOpen:
|
||||||
fileDialog.setFileMode(QFileDialog::AnyFile);
|
QFileDialog fileDialog(this);
|
||||||
fileDialog.setViewMode(QFileDialog::Detail);
|
fileDialog.setFileMode(QFileDialog::AnyFile);
|
||||||
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
|
fileDialog.setViewMode(QFileDialog::Detail);
|
||||||
fileDialog.setOption(QFileDialog::DontUseNativeDialog, true);
|
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
|
||||||
fileDialog.setWindowTitle(tr("Import copy"));
|
fileDialog.setOption(QFileDialog::DontUseNativeDialog, true);
|
||||||
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
|
fileDialog.setWindowTitle(tr("Import copy"));
|
||||||
|
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
|
||||||
QStringList filters;
|
|
||||||
filters << tr("All profile files (SGTA* PGTA*)");
|
QStringList filters;
|
||||||
filters << tr("Savegames files (SGTA*)");
|
filters << tr("All profile files (SGTA* PGTA*)");
|
||||||
filters << tr("Snapmatic pictures (PGTA*)");
|
filters << tr("Savegames files (SGTA*)");
|
||||||
filters << tr("All files (**)");
|
filters << tr("Snapmatic pictures (PGTA*)");
|
||||||
fileDialog.setNameFilters(filters);
|
filters << tr("All files (**)");
|
||||||
|
fileDialog.setNameFilters(filters);
|
||||||
QList<QUrl> sidebarUrls = fileDialog.sidebarUrls();
|
|
||||||
QDir dir;
|
QList<QUrl> sidebarUrls = fileDialog.sidebarUrls();
|
||||||
|
QDir dir;
|
||||||
// Get Documents + Desktop Location
|
|
||||||
QString documentsLocation = StandardPaths::documentsLocation();
|
// Get Documents + Desktop Location
|
||||||
QString desktopLocation = StandardPaths::desktopLocation();
|
QString documentsLocation = StandardPaths::documentsLocation();
|
||||||
|
QString desktopLocation = StandardPaths::desktopLocation();
|
||||||
// Add Desktop Location to Sidebar
|
|
||||||
dir.setPath(desktopLocation);
|
// Add Desktop Location to Sidebar
|
||||||
if (dir.exists())
|
dir.setPath(desktopLocation);
|
||||||
{
|
if (dir.exists())
|
||||||
sidebarUrls.append(QUrl::fromLocalFile(dir.absolutePath()));
|
{
|
||||||
}
|
sidebarUrls.append(QUrl::fromLocalFile(dir.absolutePath()));
|
||||||
|
}
|
||||||
// Add Documents + GTA V Location to Sidebar
|
|
||||||
dir.setPath(documentsLocation);
|
// Add Documents + GTA V Location to Sidebar
|
||||||
if (dir.exists())
|
dir.setPath(documentsLocation);
|
||||||
{
|
if (dir.exists())
|
||||||
sidebarUrls.append(QUrl::fromLocalFile(dir.absolutePath()));
|
{
|
||||||
if (dir.cd("Rockstar Games/GTA V"))
|
sidebarUrls.append(QUrl::fromLocalFile(dir.absolutePath()));
|
||||||
{
|
if (dir.cd("Rockstar Games/GTA V"))
|
||||||
sidebarUrls.append(QUrl::fromLocalFile(dir.absolutePath()));
|
{
|
||||||
}
|
sidebarUrls.append(QUrl::fromLocalFile(dir.absolutePath()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fileDialog.setSidebarUrls(sidebarUrls);
|
|
||||||
fileDialog.restoreState(settings.value("ImportCopy","").toByteArray());
|
fileDialog.setSidebarUrls(sidebarUrls);
|
||||||
|
fileDialog.restoreState(settings.value("ImportCopy","").toByteArray());
|
||||||
fileDialogPreOpen:
|
|
||||||
if (fileDialog.exec())
|
if (fileDialog.exec())
|
||||||
{
|
{
|
||||||
QStringList selectedFiles = fileDialog.selectedFiles();
|
QStringList selectedFiles = fileDialog.selectedFiles();
|
||||||
if (selectedFiles.length() == 1)
|
if (selectedFiles.length() == 1)
|
||||||
{
|
{
|
||||||
QString selectedFile = selectedFiles.at(0);
|
QString selectedFile = selectedFiles.at(0);
|
||||||
QFileInfo selectedFileInfo(selectedFile);
|
QFileInfo selectedFileInfo(selectedFile);
|
||||||
QString selectedFileName = selectedFileInfo.fileName();
|
QString selectedFileName = selectedFileInfo.fileName();
|
||||||
if (QFile::exists(selectedFile))
|
if (QFile::exists(selectedFile))
|
||||||
{
|
{
|
||||||
if (selectedFileName.left(4) == "PGTA")
|
if (selectedFileName.left(4) == "PGTA")
|
||||||
{
|
{
|
||||||
SnapmaticPicture *picture = new SnapmaticPicture(selectedFile);
|
SnapmaticPicture *picture = new SnapmaticPicture(selectedFile);
|
||||||
if (picture->readingPicture())
|
if (picture->readingPicture())
|
||||||
{
|
{
|
||||||
importSnapmaticPicture(picture, selectedFile);
|
importSnapmaticPicture(picture, selectedFile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, tr("Import copy"), tr("Failed to read Snapmatic picture"));
|
QMessageBox::warning(this, tr("Import copy"), tr("Failed to read Snapmatic picture"));
|
||||||
goto fileDialogPreOpen;
|
picture->deleteLater();
|
||||||
}
|
delete picture;
|
||||||
}
|
goto fileDialogPreOpen;
|
||||||
else if (selectedFileName.left(4) == "SGTA")
|
}
|
||||||
{
|
}
|
||||||
SavegameData *savegame = new SavegameData(selectedFile);
|
else if (selectedFileName.left(4) == "SGTA")
|
||||||
if (savegame->readingSavegame())
|
{
|
||||||
{
|
SavegameData *savegame = new SavegameData(selectedFile);
|
||||||
importSavegameData(savegame, selectedFile);
|
if (savegame->readingSavegame())
|
||||||
}
|
{
|
||||||
else
|
importSavegameData(savegame, selectedFile);
|
||||||
{
|
}
|
||||||
QMessageBox::warning(this, tr("Import copy"), tr("Failed to read Savegame file"));
|
else
|
||||||
goto fileDialogPreOpen;
|
{
|
||||||
}
|
QMessageBox::warning(this, tr("Import copy"), tr("Failed to read Savegame file"));
|
||||||
}
|
savegame->deleteLater();
|
||||||
}
|
delete savegame;
|
||||||
else
|
goto fileDialogPreOpen;
|
||||||
{
|
}
|
||||||
QMessageBox::warning(this, tr("Import copy"), tr("No valid file is selected"));
|
}
|
||||||
goto fileDialogPreOpen;
|
else
|
||||||
}
|
{
|
||||||
}
|
SnapmaticPicture *picture = new SnapmaticPicture(selectedFile);
|
||||||
else
|
SavegameData *savegame = new SavegameData(selectedFile);
|
||||||
{
|
if (picture->readingPicture())
|
||||||
QMessageBox::warning(this, tr("Import copy"), tr("No valid file is selected"));
|
{
|
||||||
goto fileDialogPreOpen;
|
importSnapmaticPicture(picture, selectedFile);
|
||||||
}
|
savegame->deleteLater();
|
||||||
}
|
delete savegame;
|
||||||
|
}
|
||||||
settings.setValue("ImportCopy", fileDialog.saveState());
|
else if (savegame->readingSavegame())
|
||||||
settings.endGroup();
|
{
|
||||||
}
|
importSavegameData(savegame, selectedFile);
|
||||||
|
picture->deleteLater();
|
||||||
bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, QString picPath)
|
delete picture;
|
||||||
{
|
}
|
||||||
QFileInfo picFileInfo(picPath);
|
else
|
||||||
QString picFileName = picFileInfo.fileName();
|
{
|
||||||
if (picFileName.left(4) != "PGTA")
|
savegame->deleteLater();
|
||||||
{
|
picture->deleteLater();
|
||||||
QMessageBox::warning(this, tr("Import copy"), tr("Failed to import copy of Snapmatic picture because the file not begin with PGTA"));
|
delete savegame;
|
||||||
return false;
|
delete picture;
|
||||||
}
|
QMessageBox::warning(this, tr("Import copy"), tr("Can't import %1 because of not valid file format").arg("\""+selectedFileName+"\""));
|
||||||
else if (QFile::copy(picPath, profileFolder + "/" + picFileName))
|
goto fileDialogPreOpen;
|
||||||
{
|
}
|
||||||
on_pictureLoaded(picture, profileFolder + "/" + picFileName);
|
}
|
||||||
return true;
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
QMessageBox::warning(this, tr("Import copy"), tr("No valid file is selected"));
|
||||||
QMessageBox::warning(this, tr("Import copy"), tr("Failed to import copy of Snapmatic picture because the copy failed"));
|
goto fileDialogPreOpen;
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
bool ProfileInterface::importSavegameData(SavegameData *savegame, QString sgdPath)
|
QMessageBox::warning(this, tr("Import copy"), tr("No valid file is selected"));
|
||||||
{
|
goto fileDialogPreOpen;
|
||||||
QString sgdFileName;
|
}
|
||||||
bool foundFree = 0;
|
}
|
||||||
int currentSgd = 0;
|
|
||||||
|
settings.setValue("ImportCopy", fileDialog.saveState());
|
||||||
while (currentSgd < 15 && !foundFree)
|
settings.endGroup();
|
||||||
{
|
}
|
||||||
QString sgdNumber = QString::number(currentSgd);
|
|
||||||
if (sgdNumber.length() == 1)
|
bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, QString picPath)
|
||||||
{
|
{
|
||||||
sgdNumber.insert(0, "0");
|
QFileInfo picFileInfo(picPath);
|
||||||
}
|
QString picFileName = picFileInfo.fileName();
|
||||||
sgdFileName = "SGTA00" + sgdNumber;
|
if (picFileName.left(4) != "PGTA")
|
||||||
|
{
|
||||||
if (!QFile::exists(profileFolder + "/" + sgdFileName))
|
QMessageBox::warning(this, tr("Import copy"), tr("Failed to import copy of Snapmatic picture because the file not begin with PGTA"));
|
||||||
{
|
return false;
|
||||||
foundFree = true;
|
}
|
||||||
}
|
else if (QFile::copy(picPath, profileFolder + "/" + picFileName))
|
||||||
currentSgd++;
|
{
|
||||||
}
|
on_pictureLoaded(picture, profileFolder + "/" + picFileName);
|
||||||
|
return true;
|
||||||
if (foundFree)
|
}
|
||||||
{
|
else
|
||||||
if (QFile::copy(sgdPath, profileFolder + "/" + sgdFileName))
|
{
|
||||||
{
|
QMessageBox::warning(this, tr("Import copy"), tr("Failed to import copy of Snapmatic picture because the copy failed"));
|
||||||
on_savegameLoaded(savegame, profileFolder + "/" + sgdFileName);
|
return false;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
bool ProfileInterface::importSavegameData(SavegameData *savegame, QString sgdPath)
|
||||||
QMessageBox::warning(this, tr("Import copy"), tr("Failed to import copy of Savegame file because the copy failed"));
|
{
|
||||||
return false;
|
QString sgdFileName;
|
||||||
}
|
bool foundFree = 0;
|
||||||
}
|
int currentSgd = 0;
|
||||||
else
|
|
||||||
{
|
while (currentSgd < 15 && !foundFree)
|
||||||
QMessageBox::warning(this, tr("Import copy"), tr("Failed to import copy of Savegame file because no free Savegame slot left"));
|
{
|
||||||
return false;
|
QString sgdNumber = QString::number(currentSgd);
|
||||||
}
|
if (sgdNumber.length() == 1)
|
||||||
}
|
{
|
||||||
|
sgdNumber.insert(0, "0");
|
||||||
|
}
|
||||||
|
sgdFileName = "SGTA500" + sgdNumber;
|
||||||
|
|
||||||
|
if (!QFile::exists(profileFolder + "/" + sgdFileName))
|
||||||
|
{
|
||||||
|
foundFree = true;
|
||||||
|
}
|
||||||
|
currentSgd++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundFree)
|
||||||
|
{
|
||||||
|
if (QFile::copy(sgdPath, profileFolder + "/" + sgdFileName))
|
||||||
|
{
|
||||||
|
on_savegameLoaded(savegame, profileFolder + "/" + sgdFileName);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, tr("Import copy"), tr("Failed to import copy of Savegame file because the copy failed"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, tr("Import copy"), tr("Failed to import copy of Savegame file because no free Savegame slot left"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -75,7 +75,8 @@ void SavegameWidget::on_cmdCopy_clicked()
|
||||||
QSettings settings("Syping", "gta5sync");
|
QSettings settings("Syping", "gta5sync");
|
||||||
settings.beginGroup("FileDialogs");
|
settings.beginGroup("FileDialogs");
|
||||||
|
|
||||||
QFileInfo fileInfo(sgdPath);
|
fileDialogPreSave:
|
||||||
|
QFileInfo sgdFileInfo(sgdPath);
|
||||||
QFileDialog fileDialog(this);
|
QFileDialog fileDialog(this);
|
||||||
fileDialog.setFileMode(QFileDialog::AnyFile);
|
fileDialog.setFileMode(QFileDialog::AnyFile);
|
||||||
fileDialog.setViewMode(QFileDialog::Detail);
|
fileDialog.setViewMode(QFileDialog::Detail);
|
||||||
|
@ -118,8 +119,8 @@ void SavegameWidget::on_cmdCopy_clicked()
|
||||||
|
|
||||||
fileDialog.setSidebarUrls(sidebarUrls);
|
fileDialog.setSidebarUrls(sidebarUrls);
|
||||||
fileDialog.restoreState(settings.value("CopySavegame","").toByteArray());
|
fileDialog.restoreState(settings.value("CopySavegame","").toByteArray());
|
||||||
|
fileDialog.selectFile(sgdFileInfo.fileName());
|
||||||
|
|
||||||
fileDialogPreSave:
|
|
||||||
if (fileDialog.exec())
|
if (fileDialog.exec())
|
||||||
{
|
{
|
||||||
QStringList selectedFiles = fileDialog.selectedFiles();
|
QStringList selectedFiles = fileDialog.selectedFiles();
|
||||||
|
|
Loading…
Reference in a new issue