Aspect Ratio fixes, HiDPI fullscreen fix
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Syping 2020-11-25 00:36:12 +01:00
parent 0fcd4615cd
commit 9adc8d9650
18 changed files with 2233 additions and 2315 deletions

View file

@ -49,7 +49,7 @@ void ExportThread::run()
// Quality Settings
settings.beginGroup("Pictures");
int defaultQuality = 100;
QSize defExportSize = QSize(960, 536);
QSize defExportSize = SnapmaticPicture::getSnapmaticResolution();
int customQuality = settings.value("CustomQuality", defaultQuality).toInt();
if (customQuality < 1 || customQuality > 100)
{

View file

@ -75,7 +75,7 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
int desktopSizeHeight = desktopResolution.height();
#endif
aspectRatio = Qt::KeepAspectRatio;
defExportSize = QSize(960, 536);
defExportSize = SnapmaticPicture::getSnapmaticResolution();
cusExportSize = defExportSize;
defaultQuality = 100;
customQuality = 100;
@ -298,6 +298,9 @@ void OptionsDialog::setupRadioButtons()
break;
case 10:
ui->rbClassic->setChecked(true);
#if QT_VERSION >= 0x050800
Q_FALLTHROUGH();
#endif
case 11:
ui->cbDoubleclick->setChecked(true);
}

View file

@ -285,11 +285,7 @@ void PictureDialog::addPreviousNextButtons()
void PictureDialog::adaptNewDialogSize(QSize newLabelSize)
{
Q_UNUSED(newLabelSize)
#if QT_VERSION >= 0x050F00
int newDialogHeight = SnapmaticPicture::getSnapmaticResolution().height();
#else
int newDialogHeight = (ui->labPicture->pixmap()->height() / AppEnv::screenRatioPR());
#endif
int newDialogHeight = SnapmaticPicture::getSnapmaticResolution().height() * AppEnv::screenRatio();
newDialogHeight = newDialogHeight + ui->jsonFrame->height();
if (naviEnabled) newDialogHeight = newDialogHeight + layout()->menuBar()->height();
setMaximumSize(width(), newDialogHeight);
@ -304,19 +300,17 @@ void PictureDialog::styliseDialog()
{
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
if (QtWin::isCompositionEnabled())
{
if (QtWin::isCompositionEnabled()) {
QPalette palette;
QtWin::extendFrameIntoClientArea(this, 0, qRound(layout()->menuBar()->height() * AppEnv::screenRatioPR()), 0, 0);
ui->jsonFrame->setStyleSheet(QString("QFrame { background: %1; }").arg(palette.window().color().name()));
setStyleSheet("PictureDialog { background: transparent; }");
ui->jsonFrame->setStyleSheet(QString("QFrame{background:%1;}").arg(palette.window().color().name()));
setStyleSheet("PictureDialog{background:transparent;}");
}
else
{
else {
QPalette palette;
QtWin::resetExtendedFrame(this);
ui->jsonFrame->setStyleSheet(QString("QFrame { background: %1; }").arg(palette.window().color().name()));
setStyleSheet(QString("PictureDialog { background: %1; }").arg(QtWin::realColorizationColor().name()));
ui->jsonFrame->setStyleSheet(QString("QFrame{background:%1;}").arg(palette.window().color().name()));
setStyleSheet(QString("PictureDialog{background:%1;}").arg(QtWin::realColorizationColor().name()));
}
#endif
#endif
@ -326,10 +320,8 @@ bool PictureDialog::event(QEvent *event)
{
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
if (naviEnabled)
{
if (event->type() == QWinEvent::CompositionChange || event->type() == QWinEvent::ColorizationChange)
{
if (naviEnabled) {
if (event->type() == QWinEvent::CompositionChange || event->type() == QWinEvent::ColorizationChange) {
styliseDialog();
}
}
@ -543,8 +535,7 @@ void PictureDialog::renderOverlayPicture()
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, bool _indexed, int _index)
{
if (smpic != nullptr)
{
if (smpic != nullptr) {
QObject::disconnect(smpic, SIGNAL(updated()), this, SLOT(updated()));
QObject::disconnect(smpic, SIGNAL(customSignal(QString)), this, SLOT(customSignal(QString)));
}
@ -552,35 +543,29 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
indexed = _indexed;
index = _index;
smpic = picture;
if (!readOk)
{
if (!readOk) {
QMessageBox::warning(this, tr("Snapmatic Picture Viewer"), tr("Failed at %1").arg(picture->getLastStep()));
return;
}
if (picture->isPicOk())
{
if (picture->isPicOk()) {
snapmaticPicture = picture->getImage();
renderPicture();
ui->cmdManage->setEnabled(true);
}
if (picture->isJsonOk())
{
if (picture->isJsonOk()) {
crewStr = crewDB->getCrewName(crewID);
if (globalMap.contains(picArea))
{
picAreaStr = globalMap[picArea];
if (globalMap.contains(picArea)) {
picAreaStr = globalMap.value(picArea);
}
else
{
else {
picAreaStr = picArea;
}
setWindowTitle(windowTitleStr.arg(picTitl));
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created));
}
else
{
else {
ui->labJSON->setText(jsonDrawString.arg("0", "0", "0", tr("No Players"), tr("No Crew"), tr("Unknown Location")));
QMessageBox::warning(this,tr("Snapmatic Picture Viewer"),tr("Failed at %1").arg(picture->getLastStep()));
// QMessageBox::warning(this, tr("Snapmatic Picture Viewer"), tr("Failed at %1").arg(picture->getLastStep()));
}
QObject::connect(smpic, SIGNAL(updated()), this, SLOT(updated()));
QObject::connect(smpic, SIGNAL(customSignal(QString)), this, SLOT(customSignal(QString)));
@ -609,57 +594,39 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture)
void PictureDialog::renderPicture()
{
qreal screenRatio = AppEnv::screenRatio();
qreal screenRatioPR = AppEnv::screenRatioPR();
if (!previewMode)
{
if (overlayEnabled)
{
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
QPixmap shownImagePixmap(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR);
shownImagePixmap.fill(Qt::transparent);
const qreal screenRatio = AppEnv::screenRatio();
const qreal screenRatioPR = AppEnv::screenRatioPR();
const QSize snapmaticResolution(SnapmaticPicture::getSnapmaticResolution());
const QSize renderResolution(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR);
QPixmap shownImagePixmap(renderResolution);
shownImagePixmap.fill(Qt::black);
QPainter shownImagePainter(&shownImagePixmap);
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
shownImagePainter.drawImage(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, overlayTempImage);
const QImage renderImage = snapmaticPicture.scaled(renderResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (renderImage.width() < renderResolution.width()) {
shownImagePainter.drawImage((renderResolution.width() - renderImage.width()) / 2, 0, renderImage, Qt::AutoColor);
}
else if (renderImage.height() < renderResolution.height()) {
shownImagePainter.drawImage(0, (renderResolution.height() - renderImage.height()) / 2, renderImage, Qt::AutoColor);
}
else {
shownImagePainter.drawImage(0, 0, renderImage, Qt::AutoColor);
}
if (previewMode) {
QFont shownImagePainterFont;
shownImagePainterFont.setPixelSize(12 * screenRatio * screenRatioPR);
shownImagePainter.drawImage(0, 0, avatarAreaPicture);
shownImagePainter.setPen(QColor::fromRgb(255, 255, 255, 255));
shownImagePainter.setFont(shownImagePainterFont);
shownImagePainter.drawText(QRect(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, 140 * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR), Qt::AlignLeft | Qt::TextWordWrap, tr("Avatar Preview Mode\nPress 1 for Default View"));
}
else if (overlayEnabled) {
shownImagePainter.drawImage(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, overlayTempImage, Qt::AutoColor);
}
shownImagePainter.end();
#if QT_VERSION >= 0x050600
shownImagePixmap.setDevicePixelRatio(screenRatioPR);
#endif
ui->labPicture->setPixmap(shownImagePixmap);
}
else
{
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
QPixmap shownImagePixmap(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR);
shownImagePixmap.fill(Qt::transparent);
QPainter shownImagePainter(&shownImagePixmap);
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
shownImagePainter.end();
#if QT_VERSION >= 0x050600
shownImagePixmap.setDevicePixelRatio(screenRatioPR);
#endif
ui->labPicture->setPixmap(shownImagePixmap);
}
}
else
{
// Generating Avatar Preview
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
QPixmap avatarPixmap(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR);
QPainter snapPainter(&avatarPixmap);
QFont snapPainterFont;
snapPainterFont.setPixelSize(12 * screenRatio * screenRatioPR);
snapPainter.drawImage(0, 0, snapmaticPicture.scaled(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
snapPainter.drawImage(0, 0, avatarAreaPicture);
snapPainter.setPen(QColor::fromRgb(255, 255, 255, 255));
snapPainter.setFont(snapPainterFont);
snapPainter.drawText(QRect(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, 140 * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR), Qt::AlignLeft | Qt::TextWordWrap, tr("Avatar Preview Mode\nPress 1 for Default View"));
snapPainter.end();
#if QT_VERSION >= 0x050600
avatarPixmap.setDevicePixelRatio(screenRatioPR);
#endif
ui->labPicture->setPixmap(avatarPixmap);
}
}
void PictureDialog::crewNameUpdated()
@ -703,10 +670,8 @@ QString PictureDialog::generatePlayersString()
SnapmaticPicture *picture = smpic; // used by macro
const QStringList playersList = plyrsList; // save operation time
QString plyrsStr;
if (playersList.length() >= 1)
{
for (const QString &player : playersList)
{
if (playersList.length() >= 1) {
for (const QString &player : playersList) {
const QString playerName = profileDB->getPlayerName(player);
if (player != playerName) {
plyrsStr += ", <a href=\"https://socialclub.rockstargames.com/member/" % playerName % "/" % player % "\">" % playerName % "</a>";
@ -717,8 +682,7 @@ QString PictureDialog::generatePlayersString()
}
plyrsStr.remove(0, 2);
}
else
{
else {
plyrsStr = tr("No Players");
}
return plyrsStr;
@ -726,32 +690,27 @@ QString PictureDialog::generatePlayersString()
void PictureDialog::exportSnapmaticPicture()
{
if (rqFullscreen && fullscreenWidget != nullptr)
{
if (rqFullscreen && fullscreenWidget != nullptr) {
PictureExport::exportAsPicture(fullscreenWidget, smpic);
}
else
{
else {
PictureExport::exportAsPicture(this, smpic);
}
}
void PictureDialog::copySnapmaticPicture()
{
if (rqFullscreen && fullscreenWidget != nullptr)
{
if (rqFullscreen && fullscreenWidget != nullptr) {
PictureExport::exportAsSnapmatic(fullscreenWidget, smpic);
}
else
{
else {
PictureExport::exportAsSnapmatic(this, smpic);
}
}
void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button)
{
if (button == Qt::LeftButton)
{
if (button == Qt::LeftButton) {
#if QT_VERSION >= 0x060000
QRect desktopRect = QApplication::screenAt(pos())->geometry();
#else
@ -765,8 +724,8 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button)
pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint);
#endif
pictureWidget->setWindowTitle(windowTitle());
pictureWidget->setStyleSheet("QLabel#pictureLabel{background-color: black;}");
pictureWidget->setImage(snapmaticPicture, desktopRect);
pictureWidget->setStyleSheet("QLabel#pictureLabel{background-color:black;}");
pictureWidget->setImage(smpic->getImage(), desktopRect);
pictureWidget->setModal(true);
fullscreenWidget = pictureWidget;

View file

@ -40,7 +40,6 @@
PictureExport::PictureExport()
{
}
void PictureExport::exportAsPicture(QWidget *parent, SnapmaticPicture *picture)
@ -51,30 +50,25 @@ void PictureExport::exportAsPicture(QWidget *parent, SnapmaticPicture *picture)
// Quality Settings
settings.beginGroup("Pictures");
int defaultQuality = 100;
QSize defExportSize = QSize(960, 536);
QSize defExportSize = SnapmaticPicture::getSnapmaticResolution();
int customQuality = settings.value("CustomQuality", defaultQuality).toInt();
if (customQuality < 1 || customQuality > 100)
{
if (customQuality < 1 || customQuality > 100) {
customQuality = 100;
}
bool useCustomQuality = settings.value("CustomQualityEnabled", false).toBool();
// Size Settings
QSize cusExportSize = settings.value("CustomSize", defExportSize).toSize();
if (cusExportSize.width() > 3840)
{
if (cusExportSize.width() > 3840) {
cusExportSize.setWidth(3840);
}
else if (cusExportSize.height() > 2160)
{
else if (cusExportSize.height() > 2160) {
cusExportSize.setHeight(2160);
}
if (cusExportSize.width() < 1)
{
if (cusExportSize.width() < 1) {
cusExportSize.setWidth(1);
}
else if (cusExportSize.height() < 1)
{
else if (cusExportSize.height() < 1) {
cusExportSize.setHeight(1);
}
QString sizeMode = settings.value("ExportSizeMode", "Default").toString();
@ -113,54 +107,42 @@ fileDialogPreSave: //Work?
QString newPictureFileName = getPictureFileName(picture) % defaultExportFormat;
fileDialog.selectFile(newPictureFileName);
if (fileDialog.exec())
{
if (fileDialog.exec()) {
QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1)
{
if (selectedFiles.length() == 1) {
QString saveFileFormat;
QString selectedFile = selectedFiles.at(0);
if (selectedFile.right(4) == ".jpg")
{
if (selectedFile.right(4) == ".jpg") {
saveFileFormat = "JPEG";
}
else if (selectedFile.right(4) == ".jpeg")
{
else if (selectedFile.right(4) == ".jpeg") {
saveFileFormat = "JPEG";
}
else if (selectedFile.right(4) == ".png")
{
else if (selectedFile.right(4) == ".png") {
saveFileFormat = "PNG";
}
else if (selectedFile.right(7) == ".suffix")
{
if (fileDialog.selectedNameFilter() == "JPEG picture (*.jpg)")
{
else if (selectedFile.right(7) == ".suffix") {
if (fileDialog.selectedNameFilter() == "JPEG picture (*.jpg)") {
selectedFile.replace(".suffix", ".jpg");
}
else if (fileDialog.selectedNameFilter() == "Portable Network Graphics (*.png)")
{
else if (fileDialog.selectedNameFilter() == "Portable Network Graphics (*.png)") {
selectedFile.replace(".suffix", ".png");
}
else
{
else {
selectedFile.replace(".suffix", ".jpg");
}
}
if (QFile::exists(selectedFile))
{
if (QMessageBox::No == QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))
{
if (QFile::exists(selectedFile)) {
if (QMessageBox::No == QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)) {
goto fileDialogPreSave; //Work?
}
}
// Scale Picture
QImage exportPicture = picture->getImage();
if (sizeMode == "Desktop")
{
if (sizeMode == "Desktop") {
#if QT_VERSION >= 0x050000
qreal screenRatioPR = AppEnv::screenRatioPR();
QRect desktopResolution = QApplication::primaryScreen()->geometry();
@ -173,8 +155,7 @@ fileDialogPreSave: //Work?
#endif
exportPicture = exportPicture.scaled(desktopSizeWidth, desktopSizeHeight, aspectRatio, Qt::SmoothTransformation);
}
else if (sizeMode == "Custom")
{
else if (sizeMode == "Custom") {
exportPicture = exportPicture.scaled(cusExportSize, aspectRatio, Qt::SmoothTransformation);
}
@ -185,32 +166,26 @@ fileDialogPreSave: //Work?
#else
QFile *picFile = new QFile(selectedFile);
#endif
if (picFile->open(QIODevice::WriteOnly))
{
if (picFile->open(QIODevice::WriteOnly)) {
isSaved = exportPicture.save(picFile, saveFileFormat.toStdString().c_str(), useCustomQuality ? customQuality : defaultQuality);
#if QT_VERSION >= 0x050000
if (isSaved)
{
if (isSaved) {
isSaved = picFile->commit();
}
else
{
else {
errorId = 1;
}
#else
picFile->close();
#endif
}
else
{
else {
errorId = 2;
}
delete picFile;
if (!isSaved)
{
switch (errorId)
{
if (!isSaved) {
switch (errorId) {
case 0:
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("Failed to export the picture because the system occurred a write failure"));
break;
@ -226,8 +201,7 @@ fileDialogPreSave: //Work?
goto fileDialogPreSave; //Work?
}
}
else
{
else {
QMessageBox::warning(parent, PictureDialog::tr("Export as Picture"), PictureDialog::tr("No valid file is selected"));
goto fileDialogPreSave; //Work?
}
@ -263,7 +237,9 @@ fileDialogPreSave: //Work?
QStringList filters;
filters << PictureDialog::tr("GTA V Export (*.g5e)");
#ifndef GTA5SYNC_FLATPAK
filters << PictureDialog::tr("GTA V Raw Export (*.auto)");
#endif
filters << PictureDialog::tr("Snapmatic pictures (PGTA*)");
fileDialog.setNameFilters(filters);
@ -274,58 +250,48 @@ fileDialogPreSave: //Work?
fileDialog.restoreGeometry(settings.value(parent->objectName() % "+Geometry", "").toByteArray());
fileDialog.selectFile(QString(picture->getExportPictureFileName() % ".g5e"));
if (fileDialog.exec())
{
if (fileDialog.exec()) {
QStringList selectedFiles = fileDialog.selectedFiles();
if (selectedFiles.length() == 1)
{
if (selectedFiles.length() == 1) {
QString selectedFile = selectedFiles.at(0);
bool isAutoExt = false;
if (selectedFile.right(5) == ".auto")
{
#ifndef GTA5SYNC_FLATPAK
if (selectedFile.right(5) == ".auto") {
isAutoExt = true;
QString dirPath = QFileInfo(selectedFile).dir().path();
QString stockFileName = sgdFileInfo.fileName();
selectedFile = dirPath % "/" % stockFileName;
}
else if (selectedFile.right(4) == ".rem")
{
#endif
if (selectedFile.right(4) == ".rem") {
selectedFile.remove(selectedFile.length() - 4, 4);
}
if (QFile::exists(selectedFile))
{
if (QMessageBox::No == QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))
{
if (QFile::exists(selectedFile)) {
if (QMessageBox::No == QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)) {
goto fileDialogPreSave; //Work?
}
}
if (selectedFile.right(4) == ".g5e")
{
if (selectedFile.right(4) == ".g5e") {
bool isExported = picture->exportPicture(selectedFile, SnapmaticFormat::G5E_Format);
if (!isExported)
{
if (!isExported) {
QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave; //Work?
}
}
else
{
else {
bool isCopied = picture->exportPicture(selectedFile, SnapmaticFormat::PGTA_Format);
if (!isCopied)
{
if (!isCopied) {
QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave; //Work?
}
else
{
else {
if (isAutoExt) QMessageBox::information(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Exported Snapmatic to \"%1\" because of using the .auto extension.").arg(selectedFile));
}
}
}
else
{
else {
QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("No valid file is selected"));
goto fileDialogPreSave; //Work?
}

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping
* Copyright (C) 2016-2020 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
@ -19,13 +19,12 @@
#include "PictureDialog.h"
#include "PictureWidget.h"
#include "UiModLabel.h"
#include "AppEnv.h"
#include <QApplication>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QPixmap>
#include <QEvent>
#include <QDebug>
#if QT_VERSION < 0x060000
#include <QDesktopWidget>
#endif
@ -63,12 +62,10 @@ PictureWidget::~PictureWidget()
bool PictureWidget::eventFilter(QObject *obj, QEvent *ev)
{
if (obj == this)
{
if (ev->type() == QEvent::KeyPress)
{
if (obj == this) {
if (ev->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = (QKeyEvent*)ev;
switch (keyEvent->key()){
switch (keyEvent->key()) {
case Qt::Key_Left:
emit previousPictureRequested();
break;
@ -83,36 +80,49 @@ bool PictureWidget::eventFilter(QObject *obj, QEvent *ev)
void PictureWidget::pictureDoubleClicked(Qt::MouseButton button)
{
if (button == Qt::LeftButton)
{
if (button == Qt::LeftButton) {
close();
}
}
void PictureWidget::setImage(QImage image_, QRect rec)
{
const qreal screenRatioPR = AppEnv::screenRatioPR();
image = image_;
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(rec.width(), rec.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
QPixmap pixmap = QPixmap::fromImage(image.scaled(rec.width() * screenRatioPR, rec.height() * screenRatioPR, Qt::KeepAspectRatio, Qt::SmoothTransformation));
#if QT_VERSION >= 0x050600
pixmap.setDevicePixelRatio(AppEnv::screenRatioPR());
#endif
pictureLabel->setPixmap(pixmap);
}
void PictureWidget::setImage(QImage image_)
{
const qreal screenRatioPR = AppEnv::screenRatioPR();
image = image_;
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(geometry().width(), geometry().height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
QPixmap pixmap = QPixmap::fromImage(image.scaled(geometry().width() * screenRatioPR, geometry().height() * screenRatioPR, Qt::KeepAspectRatio, Qt::SmoothTransformation));
#if QT_VERSION >= 0x050600
pixmap.setDevicePixelRatio(screenRatioPR);
#endif
pictureLabel->setPixmap(pixmap);
}
void PictureWidget::updateWindowSize(int screenID)
{
#if QT_VERSION >= 0x060000
Q_UNUSED(screenID)
const qreal screenRatioPR = AppEnv::screenRatioPR();
QRect desktopRect = QApplication::screenAt(pos())->geometry();
move(desktopRect.x(), desktopRect.y());
resize(desktopRect.width(), desktopRect.height());
showFullScreen();
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(desktopRect.width(), desktopRect.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
QPixmap pixmap = QPixmap::fromImage(image.scaled(geometry().width() * screenRatioPR, geometry().height() * screenRatioPR, Qt::KeepAspectRatio, Qt::SmoothTransformation));
#if QT_VERSION >= 0x050600
pixmap.setDevicePixelRatio(screenRatioPR);
#endif
pictureLabel->setPixmap(pixmap);
#else
if (screenID == QApplication::desktop()->screenNumber(this))
{
if (screenID == QApplication::desktop()->screenNumber(this)) {
QRect desktopRect = QApplication::desktop()->screenGeometry(this);
move(desktopRect.x(), desktopRect.y());
resize(desktopRect.width(), desktopRect.height());

View file

@ -262,8 +262,7 @@ void ProfileInterface::loadingProgress(int value, int maximum)
void ProfileInterface::insertSnapmaticIPI(QWidget *widget)
{
ProfileWidget *proWidget = qobject_cast<ProfileWidget*>(widget);
if (widgets.contains(proWidget))
{
if (widgets.contains(proWidget)) {
QString widgetKey = widgets[proWidget];
QStringList widgetsKeyList = widgets.values();
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
@ -283,8 +282,7 @@ void ProfileInterface::insertSnapmaticIPI(QWidget *widget)
void ProfileInterface::insertSavegameIPI(QWidget *widget)
{
ProfileWidget *proWidget = qobject_cast<ProfileWidget*>(widget);
if (widgets.contains(proWidget))
{
if (widgets.contains(proWidget)) {
QString widgetKey = widgets[proWidget];
QStringList widgetsKeyList = widgets.values();
QStringList savegameKeyList = widgetsKeyList.filter("SGD", Qt::CaseSensitive);
@ -305,8 +303,7 @@ void ProfileInterface::dialogNextPictureRequested(QWidget *dialog)
{
PictureDialog *picDialog = qobject_cast<PictureDialog*>(dialog);
ProfileWidget *proWidget = qobject_cast<ProfileWidget*>(sender());
if (widgets.contains(proWidget))
{
if (widgets.contains(proWidget)) {
QString widgetKey = widgets[proWidget];
QStringList widgetsKeyList = widgets.values();
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
@ -1358,10 +1355,10 @@ void ProfileInterface::exportSelected()
QString ExportPreSpan;
QString ExportPostSpan;
#ifdef Q_OS_WIN
ExportPreSpan = "<span style=\"color: #003399; font-size: 12pt\">";
ExportPreSpan = "<span style=\"color:#003399;font-size:12pt\">";
ExportPostSpan = "</span>";
#else
ExportPreSpan = "<span style=\"font-weight: bold\">";
ExportPreSpan = "<span style=\"font-weight:bold\">";
ExportPostSpan = "</span>";
#endif

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping
* Copyright (C) 2016-2020 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
@ -30,7 +30,6 @@
ProfileLoader::ProfileLoader(QString profileFolder, CrewDatabase *crewDB, QObject *parent) : QThread(parent), profileFolder(profileFolder), crewDB(crewDB)
{
}
void ProfileLoader::run()
@ -50,8 +49,7 @@ void ProfileLoader::run()
SavegameFiles.removeDuplicates();
SnapmaticPics.removeDuplicates();
for (QString BackupFile : BackupFiles)
{
for (const QString &BackupFile : BackupFiles) {
SavegameFiles.removeAll(BackupFile);
SnapmaticPics.removeAll(BackupFile);
}
@ -60,36 +58,29 @@ void ProfileLoader::run()
// Loading pictures and savegames
emit loadingProgress(curFile, maximumV);
for (QString SavegameFile : SavegameFiles)
{
for (const QString &SavegameFile : SavegameFiles) {
emit loadingProgress(curFile, maximumV);
QString sgdPath = profileFolder % "/" % SavegameFile;
const QString sgdPath = profileFolder % "/" % SavegameFile;
SavegameData *savegame = new SavegameData(sgdPath);
if (savegame->readingSavegame())
{
if (savegame->readingSavegame()) {
emit savegameLoaded(savegame, sgdPath);
}
curFile++;
}
for (QString SnapmaticPic : SnapmaticPics)
{
for (const QString &SnapmaticPic : SnapmaticPics) {
emit loadingProgress(curFile, maximumV);
QString picturePath = profileFolder % "/" % SnapmaticPic;
const QString picturePath = profileFolder % "/" % SnapmaticPic;
SnapmaticPicture *picture = new SnapmaticPicture(picturePath);
if (picture->readingPicture(true))
{
if (picture->isFormatSwitched())
{
if (picture->readingPicture(true)) {
if (picture->isFormatSwitched()) {
picture->setSnapmaticFormat(SnapmaticFormat::PGTA_Format);
if (picture->exportPicture(picturePath, SnapmaticFormat::PGTA_Format))
{
if (picture->exportPicture(picturePath, SnapmaticFormat::PGTA_Format)) {
emit pictureFixed(picture);
}
}
emit pictureLoaded(picture);
int crewNumber = picture->getSnapmaticProperties().crewID;
if (!crewList.contains(crewNumber))
{
if (!crewList.contains(crewNumber)) {
crewList += crewNumber;
}
}
@ -98,8 +89,7 @@ void ProfileLoader::run()
// adding found crews
crewDB->setAddingCrews(true);
for (int crewID : crewList)
{
for (int crewID : crewList) {
crewDB->addCrew(crewID);
}
crewDB->setAddingCrews(false);
@ -107,10 +97,9 @@ void ProfileLoader::run()
void ProfileLoader::preloaded()
{
}
void ProfileLoader::loaded()
{
}

View file

@ -376,15 +376,12 @@ QString SnapmaticPicture::getLastStep(bool readable)
}
QImage SnapmaticPicture::getImage(bool fastLoad)
QImage SnapmaticPicture::getImage()
{
Q_UNUSED(fastLoad)
if (cacheEnabled)
{
if (cacheEnabled) {
return cachePicture;
}
else
{
else {
return QImage::fromData(p_ragePhoto.photoData(), "JPEG");
}
return QImage();

View file

@ -62,7 +62,7 @@ public:
bool readingPicture(bool cacheEnabled = false);
bool isPicOk(); // Please use isPictureOk instead
void clearCache();
QImage getImage(bool fastLoad = false);
QImage getImage();
QByteArray getPictureStream();
QString getLastStep(bool readable = true);
QString getPictureStr();

View file

@ -31,9 +31,9 @@
#include "config.h"
#include <QStringBuilder>
#include <QMessageBox>
#include <QPainter>
#include <QPixmap>
#include <QTimer>
#include <QDebug>
#include <QMenu>
#include <QFile>
@ -76,19 +76,32 @@ void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture)
QObject::connect(picture, SIGNAL(updated()), this, SLOT(snapmaticUpdated()));
QObject::connect(picture, SIGNAL(customSignal(QString)), this, SLOT(customSignal(QString)));
qreal screenRatio = AppEnv::screenRatio();
qreal screenRatioPR = AppEnv::screenRatioPR();
const qreal screenRatio = AppEnv::screenRatio();
const qreal screenRatioPR = AppEnv::screenRatioPR();
const QSize renderResolution(48 * screenRatio * screenRatioPR, 27 * screenRatio * screenRatioPR);
ui->labPicture->setFixedSize(48 * screenRatio, 27 * screenRatio);
ui->labPicture->setScaledContents(true);
QPixmap SnapmaticPixmap = QPixmap::fromImage(picture->getImage().scaled(ui->labPicture->width() * screenRatioPR, ui->labPicture->height() * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::AutoColor);
QPixmap renderPixmap(renderResolution);
renderPixmap.fill(Qt::transparent);
QPainter renderPainter(&renderPixmap);
const QImage renderImage = picture->getImage().scaled(renderResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (renderImage.width() < renderResolution.width()) {
renderPainter.drawImage((renderResolution.width() - renderImage.width()) / 2, 0, renderImage, Qt::AutoColor);
}
else if (renderImage.height() < renderResolution.height()) {
renderPainter.drawImage(0, (renderResolution.height() - renderImage.height()) / 2, renderImage, Qt::AutoColor);
}
else {
renderPainter.drawImage(0, 0, renderImage, Qt::AutoColor);
}
renderPainter.end();
#if QT_VERSION >= 0x050600
SnapmaticPixmap.setDevicePixelRatio(screenRatioPR);
renderPixmap.setDevicePixelRatio(screenRatioPR);
#endif
ui->labPicStr->setText(smpic->getPictureStr() % "\n" % smpic->getPictureTitl());
ui->labPicture->setPixmap(SnapmaticPixmap);
ui->labPicture->setPixmap(renderPixmap);
picture->clearCache();

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff