more work towards supporting RDR 2, some export changes
This commit is contained in:
parent
d6968792aa
commit
e7721404b6
10 changed files with 302 additions and 610 deletions
|
@ -26,6 +26,7 @@
|
|||
#include "config.h"
|
||||
#include <QStringBuilder>
|
||||
#include <QApplication>
|
||||
#include <QSaveFile>
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
|
||||
|
@ -38,122 +39,50 @@
|
|||
ExportThread::ExportThread(QMap<ProfileWidget*,QString> profileMap, QString exportDirectory, bool pictureCopyEnabled, bool pictureExportEnabled, int exportCount, QObject *parent) : QThread(parent),
|
||||
profileMap(profileMap), exportDirectory(exportDirectory), pictureCopyEnabled(pictureCopyEnabled), pictureExportEnabled(pictureExportEnabled), exportCount(exportCount)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ExportThread::run()
|
||||
{
|
||||
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
|
||||
|
||||
// Picture Settings
|
||||
// Quality Settings
|
||||
settings.beginGroup("Pictures");
|
||||
int defaultQuality = 100;
|
||||
int customQuality = settings.value("CustomQuality", defaultQuality).toInt();
|
||||
if (customQuality < 1 || customQuality > 100)
|
||||
customQuality = 100;
|
||||
bool useCustomQuality = settings.value("CustomQualityEnabled", false).toBool();
|
||||
|
||||
// Size Settings
|
||||
const QSize defExportSize = QSize(960, 536);
|
||||
QSize cusExportSize = settings.value("CustomSize", defExportSize).toSize();
|
||||
if (cusExportSize.width() > 7680) {
|
||||
cusExportSize.setWidth(7680);
|
||||
}
|
||||
else if (cusExportSize.height() > 4320) {
|
||||
cusExportSize.setHeight(4320);
|
||||
}
|
||||
if (cusExportSize.width() < 1) {
|
||||
cusExportSize.setWidth(1);
|
||||
}
|
||||
else if (cusExportSize.height() < 1) {
|
||||
cusExportSize.setHeight(1);
|
||||
}
|
||||
QString sizeMode = settings.value("ExportSizeMode", "Default").toString();
|
||||
Qt::AspectRatioMode aspectRatio = (Qt::AspectRatioMode)settings.value("AspectRatio", Qt::KeepAspectRatio).toInt();
|
||||
settings.endGroup();
|
||||
// End Picture Settings
|
||||
|
||||
int intExportProgress = 0;
|
||||
for (ProfileWidget *widget : profileMap.keys())
|
||||
{
|
||||
if (widget->isSelected())
|
||||
{
|
||||
if (widget->getWidgetType() == "SnapmaticWidget")
|
||||
{
|
||||
size_t intExportProgress = 0;
|
||||
for (ProfileWidget *widget : profileMap.keys()) {
|
||||
if (widget->isSelected()) {
|
||||
if (widget->getWidgetType() == "SnapmaticWidget") {
|
||||
SnapmaticWidget *picWidget = qobject_cast<SnapmaticWidget*>(widget);
|
||||
SnapmaticPicture *picture = picWidget->getPicture();
|
||||
|
||||
if (pictureExportEnabled)
|
||||
{
|
||||
if (pictureExportEnabled) {
|
||||
QString exportFileName = PictureExport::getPictureFileName(picture);
|
||||
if (exportFileName.right(4) != ".jpg" && exportFileName.right(4) != ".png")
|
||||
{
|
||||
if (!exportFileName.endsWith(".jpg"))
|
||||
exportFileName += ".jpg";
|
||||
}
|
||||
|
||||
intExportProgress++;
|
||||
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
|
||||
emit exportProgressUpdate(intExportProgress);
|
||||
|
||||
// Scale Picture
|
||||
QImage exportPicture = picture->getImage();
|
||||
if (sizeMode == "Desktop")
|
||||
{
|
||||
#if QT_VERSION >= 0x050000
|
||||
qreal screenRatioPR = AppEnv::screenRatioPR();
|
||||
QRect desktopResolution = QApplication::primaryScreen()->geometry();
|
||||
int desktopSizeWidth = qRound((double)desktopResolution.width() * screenRatioPR);
|
||||
int desktopSizeHeight = qRound((double)desktopResolution.height() * screenRatioPR);
|
||||
#else
|
||||
QRect desktopResolution = QApplication::desktop()->screenGeometry();
|
||||
int desktopSizeWidth = desktopResolution.width();
|
||||
int desktopSizeHeight = desktopResolution.height();
|
||||
#endif
|
||||
exportPicture = exportPicture.scaled(desktopSizeWidth, desktopSizeHeight, aspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
else if (sizeMode == "Custom")
|
||||
{
|
||||
exportPicture = exportPicture.scaled(cusExportSize, aspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
bool isSaved;
|
||||
if (useCustomQuality)
|
||||
{
|
||||
isSaved = exportPicture.save(exportDirectory % "/" % exportFileName, "JPEG", customQuality);
|
||||
}
|
||||
else
|
||||
{
|
||||
isSaved = exportPicture.save(exportDirectory % "/" % exportFileName, "JPEG", 100);
|
||||
}
|
||||
QSaveFile exportFile(exportDirectory % "/" % exportFileName);
|
||||
exportFile.write(picture->getPictureStream());
|
||||
bool isSaved = exportFile.commit();
|
||||
|
||||
if (!isSaved)
|
||||
{
|
||||
failedExportPictures += exportFileName;
|
||||
}
|
||||
}
|
||||
if (pictureCopyEnabled)
|
||||
{
|
||||
if (pictureCopyEnabled) {
|
||||
QString exportFileName = PictureExport::getPictureFileName(picture);
|
||||
if (exportFileName.right(4) != ".g5e")
|
||||
{
|
||||
if (!exportFileName.endsWith(".g5e"))
|
||||
exportFileName += ".g5e";
|
||||
}
|
||||
|
||||
intExportProgress++;
|
||||
emit exportStringUpdate(ProfileInterface::tr("Export file %1 of %2 files").arg(QString::number(intExportProgress), QString::number(exportCount)));
|
||||
emit exportProgressUpdate(intExportProgress);
|
||||
|
||||
QString exportFilePath = exportDirectory % "/" % exportFileName;
|
||||
if (QFile::exists(exportFilePath)) {QFile::remove(exportFilePath);}
|
||||
if (QFile::exists(exportFilePath))
|
||||
QFile::remove(exportFilePath);
|
||||
if (!picture->exportPicture(exportDirectory % "/" % exportFileName, SnapmaticFormat::G5E_Format))
|
||||
{
|
||||
failedCopyPictures += exportFileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (widget->getWidgetType() == "SavegameWidget")
|
||||
{
|
||||
else if (widget->getWidgetType() == "SavegameWidget") {
|
||||
SavegameWidget *sgdWidget = qobject_cast<SavegameWidget*>(widget);
|
||||
SavegameData *savegame = sgdWidget->getSavegame();
|
||||
|
||||
|
@ -166,11 +95,10 @@ void ExportThread::run()
|
|||
emit exportProgressUpdate(intExportProgress);
|
||||
|
||||
QString exportFilePath = exportDirectory % "/" % exportFileName;
|
||||
if (QFile::exists(exportFilePath)) {QFile::remove(exportFilePath);}
|
||||
if (QFile::exists(exportFilePath))
|
||||
QFile::remove(exportFilePath);
|
||||
if (!QFile::copy(originalFileName, exportFilePath))
|
||||
{
|
||||
failedSavegames += exportFileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue