merged with gta5view 1.8

This commit is contained in:
Syping 2020-05-21 14:50:37 +02:00
parent 2630cb826f
commit 181e18503c
29 changed files with 1720 additions and 2248 deletions

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* rdr2view Red Dead Redemption 2 Profile Viewer * rdr2view Red Dead Redemption 2 Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2020 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
@ -499,9 +499,9 @@ bool AppEnv::setGameLanguage(GameVersion gameVersion, GameLanguage gameLanguage)
qreal AppEnv::screenRatio() qreal AppEnv::screenRatio()
{ {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
qreal dpi = QGuiApplication::primaryScreen()->logicalDotsPerInch(); qreal dpi = QApplication::primaryScreen()->logicalDotsPerInch();
#else #else
qreal dpi = qApp->desktop()->logicalDpiX(); qreal dpi = QApplication::desktop()->logicalDpiX();
#endif #endif
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
return (dpi / 72); return (dpi / 72);
@ -513,7 +513,7 @@ qreal AppEnv::screenRatio()
qreal AppEnv::screenRatioPR() qreal AppEnv::screenRatioPR()
{ {
#if QT_VERSION >= 0x050600 #if QT_VERSION >= 0x050600
return QGuiApplication::primaryScreen()->devicePixelRatio(); return QApplication::primaryScreen()->devicePixelRatio();
#else #else
return 1; return 1;
#endif #endif

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* rdr2view Red Dead Redemption 2 Profile Viewer * rdr2view Red Dead Redemption 2 Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2020 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
@ -22,14 +22,19 @@
#include "ProfileWidget.h" #include "ProfileWidget.h"
#include "ExportThread.h" #include "ExportThread.h"
#include "SavegameData.h" #include "SavegameData.h"
#include "AppEnv.h"
#include "config.h" #include "config.h"
#include <QStringBuilder> #include <QStringBuilder>
#include <QDesktopWidget>
#include <QApplication> #include <QApplication>
#include <QFileInfo> #include <QFileInfo>
#include <QDebug>
#include <QFile> #include <QFile>
#if QT_VERSION >= 0x050000
#include <QScreen>
#else
#include <QDesktopWidget>
#endif
ExportThread::ExportThread(QMap<ProfileWidget*,QString> profileMap, QString exportDirectory, bool pictureCopyEnabled, bool pictureExportEnabled, int exportCount, QObject *parent) : QThread(parent), 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) profileMap(profileMap), exportDirectory(exportDirectory), pictureCopyEnabled(pictureCopyEnabled), pictureExportEnabled(pictureExportEnabled), exportCount(exportCount)
{ {
@ -101,8 +106,17 @@ void ExportThread::run()
QImage exportPicture = picture->getImage(); QImage exportPicture = picture->getImage();
if (sizeMode == "Desktop") if (sizeMode == "Desktop")
{ {
QRect desktopResolution = qApp->desktop()->screenGeometry(); #if QT_VERSION >= 0x050000
exportPicture = exportPicture.scaled(desktopResolution.width(), desktopResolution.height(), aspectRatio, Qt::SmoothTransformation); 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") else if (sizeMode == "Custom")
{ {

View file

@ -1,205 +0,0 @@
/*****************************************************************************
* rdr2view Red Dead Redemption 2 Profile Viewer
* Copyright (C) 2017-2018 Syping
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "ImageEditorDialog.h"
#include "ui_ImageEditorDialog.h"
#include "ProfileInterface.h"
#include "SidebarGenerator.h"
#include "StandardPaths.h"
#include "ImportDialog.h"
#include "AppEnv.h"
#include "config.h"
#include <QStringBuilder>
#include <QImageReader>
#include <QFileDialog>
#include <QMessageBox>
ImageEditorDialog::ImageEditorDialog(SnapmaticPicture *picture, QString profileName, QWidget *parent) :
QDialog(parent), smpic(picture), profileName(profileName),
ui(new Ui::ImageEditorDialog)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
ui->setupUi(this);
ui->cmdClose->setDefault(true);
ui->cmdClose->setFocus();
// Set Icon for Close Button
if (QIcon::hasThemeIcon("dialog-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
}
else if (QIcon::hasThemeIcon("gtk-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close"));
}
// Set Icon for Import Button
if (QIcon::hasThemeIcon("document-import"))
{
ui->cmdReplace->setIcon(QIcon::fromTheme("document-import"));
}
// Set Icon for Overwrite Button
if (QIcon::hasThemeIcon("document-save"))
{
ui->cmdSave->setIcon(QIcon::fromTheme("document-save"));
}
else if (QIcon::hasThemeIcon("gtk-save"))
{
ui->cmdSave->setIcon(QIcon::fromTheme("gtk-save"));
}
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
snapmaticResolutionLW = 516 * screenRatio; // 430
snapmaticResolutionLH = 288 * screenRatio; // 240
ui->labPicture->setMinimumSize(snapmaticResolutionLW, snapmaticResolutionLH);
imageIsChanged = false;
pictureCache = picture->getImage();
ui->labPicture->setPixmap(QPixmap::fromImage(pictureCache).scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
setMaximumSize(sizeHint());
setMinimumSize(sizeHint());
setFixedSize(sizeHint());
}
ImageEditorDialog::~ImageEditorDialog()
{
delete ui;
}
void ImageEditorDialog::on_cmdClose_clicked()
{
close();
}
void ImageEditorDialog::on_cmdReplace_clicked()
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
bool dontUseNativeDialog = settings.value("DontUseNativeDialog", false).toBool();
settings.beginGroup("ImportReplace");
fileDialogPreOpen: //Work?
QFileDialog fileDialog(this);
fileDialog.setFileMode(QFileDialog::ExistingFile);
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, dontUseNativeDialog);
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(ProfileInterface::tr("Import..."));
fileDialog.setLabelText(QFileDialog::Accept, ProfileInterface::tr("Import"));
// Getting readable Image formats
QString imageFormatsStr = " ";
for (QByteArray imageFormat : QImageReader::supportedImageFormats())
{
imageFormatsStr += QString("*.") % QString::fromUtf8(imageFormat).toLower() % " ";
}
QStringList filters;
filters << ProfileInterface::tr("All image files (%1)").arg(imageFormatsStr.trimmed());
filters << ProfileInterface::tr("All files (**)");
fileDialog.setNameFilters(filters);
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());
if (fileDialog.exec())
{
QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1)
{
QString selectedFile = selectedFiles.at(0);
QString selectedFileName = QFileInfo(selectedFile).fileName();
QFile snapmaticFile(selectedFile);
if (!snapmaticFile.open(QFile::ReadOnly))
{
QMessageBox::warning(this, ProfileInterface::tr("Import"), ProfileInterface::tr("Can't import %1 because file can't be open").arg("\""+selectedFileName+"\""));
goto fileDialogPreOpen;
}
QImage *importImage = new QImage();
QImageReader snapmaticImageReader;
snapmaticImageReader.setDecideFormatFromContent(true);
snapmaticImageReader.setDevice(&snapmaticFile);
if (!snapmaticImageReader.read(importImage))
{
QMessageBox::warning(this, ProfileInterface::tr("Import"), ProfileInterface::tr("Can't import %1 because file can't be parsed properly").arg("\""+selectedFileName+"\""));
delete importImage;
goto fileDialogPreOpen;
}
ImportDialog *importDialog = new ImportDialog(profileName, this);
importDialog->setImage(importImage);
importDialog->setModal(true);
importDialog->show();
importDialog->exec();
if (importDialog->isImportAgreed())
{
pictureCache = importDialog->image();
ui->labPicture->setPixmap(QPixmap::fromImage(pictureCache).scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::KeepAspectRatio, Qt::SmoothTransformation));
imageIsChanged = true;
}
delete importDialog;
}
}
settings.setValue(profileName % "+Geometry", fileDialog.saveGeometry());
settings.setValue(profileName % "+Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup();
}
void ImageEditorDialog::on_cmdSave_clicked()
{
if (imageIsChanged)
{
const QByteArray previousPicture = smpic->getPictureStream();
bool success = smpic->setImage(pictureCache);
if (success)
{
QString currentFilePath = smpic->getPictureFilePath();
QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName))
{
QFile::copy(currentFilePath, backupFileName);
}
if (!smpic->exportPicture(currentFilePath))
{
smpic->setPictureStream(previousPicture);
QMessageBox::warning(this, tr("Snapmatic Image Editor"), tr("Patching of Snapmatic Image failed because of I/O Error"));
return;
}
smpic->emitCustomSignal("PictureUpdated");
}
else
{
QMessageBox::warning(this, tr("Snapmatic Image Editor"), tr("Patching of Snapmatic Image failed because of Image Error"));
return;
}
}
close();
}

View file

@ -1,52 +0,0 @@
/*****************************************************************************
* rdr2view Red Dead Redemption 2 Profile Viewer
* Copyright (C) 2016-2017 Syping
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifndef IMAGEEDITORDIALOG_H
#define IMAGEEDITORDIALOG_H
#include "SnapmaticPicture.h"
#include <QDialog>
namespace Ui {
class ImageEditorDialog;
}
class ImageEditorDialog : public QDialog
{
Q_OBJECT
public:
explicit ImageEditorDialog(SnapmaticPicture *picture, QString profileName, QWidget *parent = 0);
~ImageEditorDialog();
private slots:
void on_cmdClose_clicked();
void on_cmdReplace_clicked();
void on_cmdSave_clicked();
private:
SnapmaticPicture *smpic;
QString profileName;
Ui::ImageEditorDialog *ui;
int snapmaticResolutionLW;
int snapmaticResolutionLH;
bool imageIsChanged;
QImage pictureCache;
};
#endif // IMAGEEDITORDIALOG_H

View file

@ -1,108 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImageEditorDialog</class>
<widget class="QDialog" name="ImageEditorDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>516</width>
<height>337</height>
</rect>
</property>
<property name="windowTitle">
<string>Overwrite Image...</string>
</property>
<layout class="QVBoxLayout" name="vlInterface">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labPicture">
<property name="minimumSize">
<size>
<width>516</width>
<height>288</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="buttomFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="vlButtons">
<item>
<layout class="QHBoxLayout" name="hlButtons">
<item>
<widget class="QPushButton" name="cmdReplace">
<property name="toolTip">
<string>Import picture</string>
</property>
<property name="text">
<string>&amp;Import...</string>
</property>
</widget>
</item>
<item>
<spacer name="hsButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cmdSave">
<property name="toolTip">
<string>Apply changes</string>
</property>
<property name="text">
<string>&amp;Overwrite</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdClose">
<property name="toolTip">
<string>Discard changes</string>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* rdr2view Red Dead Redemption 2 Profile Viewer * rdr2view Red Dead Redemption 2 Profile Viewer
* Copyright (C) 2017-2019 Syping * Copyright (C) 2017-2020 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
@ -374,7 +374,7 @@ void ImportDialog::cropPicture()
#endif #endif
imageCropper.setBackgroundColor(Qt::black); imageCropper.setBackgroundColor(Qt::black);
imageCropper.setCroppingRectBorderColor(QColor(255, 255, 255, 127)); imageCropper.setCroppingRectBorderColor(QColor(255, 255, 255, 127));
imageCropper.setImage(QPixmap::fromImage(workImage, Qt::AutoColor)); imageCropper.setImage(QPixmap::fromImage(origImage, Qt::AutoColor));
imageCropper.setProportion(QSize(1, 1)); imageCropper.setProportion(QSize(1, 1));
imageCropper.setFixedSize(workImage.size()); imageCropper.setFixedSize(workImage.size());
cropLayout.addWidget(&imageCropper); cropLayout.addWidget(&imageCropper);
@ -575,6 +575,7 @@ QImage ImportDialog::image()
void ImportDialog::setImage(QImage *image_) void ImportDialog::setImage(QImage *image_)
{ {
origImage = *image_;
workImage = QImage(); workImage = QImage();
if (image_->width() == image_->height()) if (image_->width() == image_->height())
{ {

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* rdr2view Red Dead Redemption 2 Profile Viewer * rdr2view Red Dead Redemption 2 Profile Viewer
* Copyright (C) 2017 Syping * Copyright (C) 2017-2020 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
@ -67,6 +67,7 @@ private:
QString imageTitle; QString imageTitle;
QImage backImage; QImage backImage;
QImage workImage; QImage workImage;
QImage origImage;
QImage newImage; QImage newImage;
QColor selectedColour; QColor selectedColour;
QMenu *optionsMenu; QMenu *optionsMenu;

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* rdr2view Red Dead Redemption 2 Profile Viewer * rdr2view Red Dead Redemption 2 Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2020 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
@ -24,7 +24,6 @@
#include "AppEnv.h" #include "AppEnv.h"
#include "config.h" #include "config.h"
#include <QStringBuilder> #include <QStringBuilder>
#include <QDesktopWidget>
#include <QJsonDocument> #include <QJsonDocument>
#include <QStyleFactory> #include <QStyleFactory>
#include <QApplication> #include <QApplication>
@ -40,6 +39,12 @@
#include <QList> #include <QList>
#include <QDir> #include <QDir>
#if QT_VERSION >= 0x050000
#include <QScreen>
#else
#include <QDesktopWidget>
#endif
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
#include "TelemetryClass.h" #include "TelemetryClass.h"
#endif #endif
@ -58,9 +63,16 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
ui->cmdCancel->setDefault(true); ui->cmdCancel->setDefault(true);
ui->cmdCancel->setFocus(); ui->cmdCancel->setFocus();
#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(this); QRect desktopResolution = QApplication::desktop()->screenGeometry(this);
int desktopSizeWidth = desktopResolution.width(); int desktopSizeWidth = desktopResolution.width();
int desktopSizeHeight = desktopResolution.height(); int desktopSizeHeight = desktopResolution.height();
#endif
aspectRatio = Qt::KeepAspectRatio; aspectRatio = Qt::KeepAspectRatio;
defExportSize = QSize(960, 536); defExportSize = QSize(960, 536);
cusExportSize = defExportSize; cusExportSize = defExportSize;

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* rdr2view Red Dead Redemption 2 Profile Viewer * rdr2view Red Dead Redemption 2 Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2020 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
@ -22,7 +22,6 @@
#include "ui_PictureDialog.h" #include "ui_PictureDialog.h"
#include "SidebarGenerator.h" #include "SidebarGenerator.h"
#include "MapLocationDialog.h" #include "MapLocationDialog.h"
#include "ImageEditorDialog.h"
#include "JsonEditorDialog.h" #include "JsonEditorDialog.h"
#include "SnapmaticEditor.h" #include "SnapmaticEditor.h"
#include "StandardPaths.h" #include "StandardPaths.h"

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* rdr2view Red Dead Redemption 2 Profile Viewer * rdr2view Red Dead Redemption 2 Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2020 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
@ -17,6 +17,7 @@
*****************************************************************************/ *****************************************************************************/
#include "config.h" #include "config.h"
#include "AppEnv.h"
#include "PictureExport.h" #include "PictureExport.h"
#include "PictureDialog.h" #include "PictureDialog.h"
#include "StandardPaths.h" #include "StandardPaths.h"
@ -32,6 +33,9 @@
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
#include <QSaveFile> #include <QSaveFile>
#include <QScreen>
#else
#include <QDesktopWidget>
#endif #endif
PictureExport::PictureExport() PictureExport::PictureExport()
@ -157,8 +161,17 @@ fileDialogPreSave: //Work?
QImage exportPicture = picture->getImage(); QImage exportPicture = picture->getImage();
if (sizeMode == "Desktop") 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(); QRect desktopResolution = QApplication::desktop()->screenGeometry();
exportPicture = exportPicture.scaled(desktopResolution.width(), desktopResolution.height(), aspectRatio, Qt::SmoothTransformation); int desktopSizeWidth = desktopResolution.width();
int desktopSizeHeight = desktopResolution.height();
#endif
exportPicture = exportPicture.scaled(desktopSizeWidth, desktopSizeHeight, aspectRatio, Qt::SmoothTransformation);
} }
else if (sizeMode == "Custom") else if (sizeMode == "Custom")
{ {

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* rdr2view Red Dead Redemption 2 Profile Viewer * rdr2view Red Dead Redemption 2 Profile Viewer
* Copyright (C) 2016-2019 Syping * Copyright (C) 2016-2020 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
@ -18,7 +18,6 @@
#include "SnapmaticWidget.h" #include "SnapmaticWidget.h"
#include "ui_SnapmaticWidget.h" #include "ui_SnapmaticWidget.h"
#include "ImageEditorDialog.h"
#include "MapLocationDialog.h" #include "MapLocationDialog.h"
#include "JsonEditorDialog.h" #include "JsonEditorDialog.h"
#include "SnapmaticPicture.h" #include "SnapmaticPicture.h"

View file

@ -1,6 +1,7 @@
/***************************************************************************** /*****************************************************************************
* ImageCropper Qt Widget for cropping images * ImageCropper Qt Widget for cropping images
* Copyright (C) 2013 Dimka Novikov, to@dimkanovikov.pro * Copyright (C) 2013 Dimka Novikov, to@dimkanovikov.pro
* Copyright (C) 2020 Syping
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -17,6 +18,7 @@
*****************************************************************************/ *****************************************************************************/
#include "imagecropper.h" #include "imagecropper.h"
#include "AppEnv.h"
#include <QMouseEvent> #include <QMouseEvent>
#include <QPainter> #include <QPainter>
@ -112,16 +114,16 @@ const QPixmap ImageCropper::cropImage()
// Получим размер отображаемого изображения // Получим размер отображаемого изображения
QSize scaledImageSize = QSize scaledImageSize =
pimpl->imageForCropping.scaled( pimpl->imageForCropping.scaled(
this->size(), Qt::KeepAspectRatio, Qt::FastTransformation size(), Qt::KeepAspectRatio, Qt::SmoothTransformation
).size(); ).size();
// Определим расстояние от левого и верхнего краёв // Определим расстояние от левого и верхнего краёв
float leftDelta = 0; float leftDelta = 0;
float topDelta = 0; float topDelta = 0;
const float HALF_COUNT = 2; const float HALF_COUNT = 2;
if (this->size().height() == scaledImageSize.height()) { if (size().height() == scaledImageSize.height()) {
leftDelta = (this->width() - scaledImageSize.width()) / HALF_COUNT; leftDelta = (width() - scaledImageSize.width()) / HALF_COUNT;
} else { } else {
topDelta = (this->height() - scaledImageSize.height()) / HALF_COUNT; topDelta = (height() - scaledImageSize.height()) / HALF_COUNT;
} }
// Определим пропорцию области обрезки по отношению к исходному изображению // Определим пропорцию области обрезки по отношению к исходному изображению
float xScale = (float)pimpl->imageForCropping.width() / scaledImageSize.width(); float xScale = (float)pimpl->imageForCropping.width() / scaledImageSize.width();
@ -150,34 +152,49 @@ void ImageCropper::paintEvent(QPaintEvent* _event)
QPainter widgetPainter(this); QPainter widgetPainter(this);
// Рисуем изображение по центру виджета // Рисуем изображение по центру виджета
{ {
#if QT_VERSION >= 0x050600
qreal screenRatioPR = AppEnv::screenRatioPR();
// ... подгоним изображение для отображения по размеру виджета // ... подгоним изображение для отображения по размеру виджета
QPixmap scaledImage = QPixmap scaledImage =
pimpl->imageForCropping.scaled(this->size(), Qt::KeepAspectRatio, Qt::FastTransformation); pimpl->imageForCropping.scaled(qRound((double)width() * screenRatioPR), qRound((double)height() * screenRatioPR), Qt::KeepAspectRatio, Qt::SmoothTransformation);
scaledImage.setDevicePixelRatio(screenRatioPR);
#else
QPixmap scaledImage =
pimpl->imageForCropping.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
#endif
// ... заливаем фон // ... заливаем фон
widgetPainter.fillRect( this->rect(), pimpl->backgroundColor ); widgetPainter.fillRect(rect(), pimpl->backgroundColor);
// ... рисуем изображение по центру виджета // ... рисуем изображение по центру виджета
if ( this->size().height() == scaledImage.height() ) { #if QT_VERSION >= 0x050600
widgetPainter.drawPixmap( ( this->width() - scaledImage.width() ) / 2, 0, scaledImage ); if (qRound((double)height() * screenRatioPR) == scaledImage.height()) {
widgetPainter.drawPixmap( ( qRound((double)width() * screenRatioPR) - scaledImage.width() ) / 2, 0, scaledImage );
} else { } else {
widgetPainter.drawPixmap( 0, ( this->height() - scaledImage.height() ) / 2, scaledImage ); widgetPainter.drawPixmap( 0, ( qRound((double)height() * screenRatioPR) - scaledImage.height() ) / 2, scaledImage );
} }
#else
if (height() == scaledImage.height()) {
widgetPainter.drawPixmap( ( width()- scaledImage.width() ) / 2, 0, scaledImage );
} else {
widgetPainter.drawPixmap( 0, ( height() - scaledImage.height() ) / 2, scaledImage );
}
#endif
} }
// Рисуем область обрезки // Рисуем область обрезки
{ {
// ... если это первое отображение после инициилизации, то центруем областо обрезки // ... если это первое отображение после инициилизации, то центруем областо обрезки
if (pimpl->croppingRect.isNull()) { if (pimpl->croppingRect.isNull()) {
const int width = WIDGET_MINIMUM_SIZE.width()/2; const int cwidth = WIDGET_MINIMUM_SIZE.width()/2;
const int height = WIDGET_MINIMUM_SIZE.height()/2; const int cheight = WIDGET_MINIMUM_SIZE.height()/2;
pimpl->croppingRect.setSize(QSize(width, height)); pimpl->croppingRect.setSize(QSize(cwidth, cheight));
float x = (this->width() - pimpl->croppingRect.width())/2; float x = (width() - pimpl->croppingRect.width())/2;
float y = (this->height() - pimpl->croppingRect.height())/2; float y = (height() - pimpl->croppingRect.height())/2;
pimpl->croppingRect.moveTo(x, y); pimpl->croppingRect.moveTo(x, y);
} }
// ... рисуем затемненную область // ... рисуем затемненную область
QPainterPath p; QPainterPath p;
p.addRect(pimpl->croppingRect); p.addRect(pimpl->croppingRect);
p.addRect(this->rect()); p.addRect(rect());
widgetPainter.setBrush(QBrush(QColor(0,0,0,120))); widgetPainter.setBrush(QBrush(QColor(0,0,0,120)));
widgetPainter.setPen(Qt::transparent); widgetPainter.setPen(Qt::transparent);
widgetPainter.drawPath(p); widgetPainter.drawPath(p);

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* rdr2view Red Dead Redemption 2 Profile Viewer * rdr2view Red Dead Redemption 2 Profile Viewer
* Copyright (C) 2016-2018 Syping * Copyright (C) 2016-2020 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
@ -40,11 +40,11 @@
#endif #endif
#ifndef GTA5SYNC_COPYRIGHT #ifndef GTA5SYNC_COPYRIGHT
#define GTA5SYNC_COPYRIGHT "2016-2019" #define GTA5SYNC_COPYRIGHT "2016-2020"
#endif #endif
#ifndef GTA5SYNC_APPVER #ifndef GTA5SYNC_APPVER
#define GTA5SYNC_APPVER "0.1.0" #define GTA5SYNC_APPVER "0.2.0"
#endif #endif
#if __cplusplus #if __cplusplus

View file

@ -1,6 +1,6 @@
#/***************************************************************************** #/*****************************************************************************
#* rdr2view Red Dead Redemption 2 Profile Viewer #* rdr2view Red Dead Redemption 2 Profile Viewer
#* Copyright (C) 2015-2019 Syping #* Copyright (C) 2015-2020 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
@ -37,7 +37,6 @@ SOURCES += main.cpp \
ExportThread.cpp \ ExportThread.cpp \
GlobalString.cpp \ GlobalString.cpp \
IconLoader.cpp \ IconLoader.cpp \
ImageEditorDialog.cpp \
ImportDialog.cpp \ ImportDialog.cpp \
JsonEditorDialog.cpp \ JsonEditorDialog.cpp \
MapLocationDialog.cpp \ MapLocationDialog.cpp \
@ -79,7 +78,6 @@ HEADERS += \
ExportThread.h \ ExportThread.h \
GlobalString.h \ GlobalString.h \
IconLoader.h \ IconLoader.h \
ImageEditorDialog.h \
ImportDialog.h \ ImportDialog.h \
JsonEditorDialog.h \ JsonEditorDialog.h \
MapLocationDialog.h \ MapLocationDialog.h \
@ -117,7 +115,6 @@ HEADERS += \
FORMS += \ FORMS += \
AboutDialog.ui \ AboutDialog.ui \
ExportDialog.ui \ ExportDialog.ui \
ImageEditorDialog.ui \
ImportDialog.ui \ ImportDialog.ui \
JsonEditorDialog.ui \ JsonEditorDialog.ui \
MapLocationDialog.ui \ MapLocationDialog.ui \

View file

@ -7,8 +7,8 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "rdr2view.exe.manifest"
#include <windows.h> #include <windows.h>
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0, 1, 0, 0 FILEVERSION 0, 2, 0, 0
PRODUCTVERSION 0, 1, 0, 0 PRODUCTVERSION 0, 2, 0, 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", "rdr2view" VALUE "FileDescription", "rdr2view"
VALUE "FileVersion", "0.1.0" VALUE "FileVersion", "0.2.0"
VALUE "InternalName", "rdr2view" VALUE "InternalName", "rdr2view"
VALUE "LegalCopyright", "Copyright © 2016-2019 Syping" VALUE "LegalCopyright", "Copyright © 2016-2020 Syping"
VALUE "OriginalFilename", "rdr2view.exe" VALUE "OriginalFilename", "rdr2view.exe"
VALUE "ProductName", "rdr2view" VALUE "ProductName", "rdr2view"
VALUE "ProductVersion", "0.1.0" VALUE "ProductVersion", "0.2.0"
END END
END END
END END

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff