Add Cayo Perico Map, optimisations
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Syping 2021-02-15 23:12:44 +01:00
parent 3ed26d4f9d
commit 0686b9a65d
30 changed files with 2215 additions and 2367 deletions

View File

@ -29,7 +29,11 @@ AboutDialog::AboutDialog(QWidget *parent) :
ui(new Ui::AboutDialog) ui(new Ui::AboutDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
// Build Strings // Build Strings
QString appVersion = QApplication::applicationVersion(); QString appVersion = QApplication::applicationVersion();

View File

@ -47,7 +47,6 @@ endif()
list(APPEND GTA5VIEW_DEFINES list(APPEND GTA5VIEW_DEFINES
-DGTA5SYNC_CMAKE -DGTA5SYNC_CMAKE
-DGTA5SYNC_PROJECT -DGTA5SYNC_PROJECT
-DSNAPMATIC_NODEFAULT
) )
set(GTA5VIEW_SOURCES set(GTA5VIEW_SOURCES

View File

@ -49,7 +49,11 @@ ImportDialog::ImportDialog(QString profileName, QWidget *parent) :
ui(new Ui::ImportDialog) ui(new Ui::ImportDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
ui->setupUi(this); ui->setupUi(this);
ui->cmdOK->setDefault(true); ui->cmdOK->setDefault(true);

View File

@ -28,7 +28,6 @@
#if QT_VERSION >= 0x050200 #if QT_VERSION >= 0x050200
#include <QFontDatabase> #include <QFontDatabase>
#include <QDebug>
#endif #endif
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
@ -40,29 +39,30 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
ui(new Ui::JsonEditorDialog) ui(new Ui::JsonEditorDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
setWindowFlag(Qt::WindowMinMaxButtonsHint, true);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowMinMaxButtonsHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowMinMaxButtonsHint);
#endif
ui->setupUi(this); ui->setupUi(this);
ui->cmdClose->setDefault(true); ui->cmdClose->setDefault(true);
ui->cmdClose->setFocus(); ui->cmdClose->setFocus();
// Set Icon for Close Button // Set Icon for Close Button
if (QIcon::hasThemeIcon("dialog-close")) if (QIcon::hasThemeIcon("dialog-close")) {
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close")); ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
} }
else if (QIcon::hasThemeIcon("gtk-close")) else if (QIcon::hasThemeIcon("gtk-close")) {
{
ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close")); ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close"));
} }
// Set Icon for Save Button // Set Icon for Save Button
if (QIcon::hasThemeIcon("document-save")) if (QIcon::hasThemeIcon("document-save")) {
{
ui->cmdSave->setIcon(QIcon::fromTheme("document-save")); ui->cmdSave->setIcon(QIcon::fromTheme("document-save"));
} }
else if (QIcon::hasThemeIcon("gtk-save")) else if (QIcon::hasThemeIcon("gtk-save")) {
{
ui->cmdSave->setIcon(QIcon::fromTheme("gtk-save")); ui->cmdSave->setIcon(QIcon::fromTheme("gtk-save"));
} }
@ -99,8 +99,7 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
ui->hlButtons->setContentsMargins(9 * screenRatio, 0, 9 * screenRatio, 0); ui->hlButtons->setContentsMargins(9 * screenRatio, 0, 9 * screenRatio, 0);
ui->vlInterface->setContentsMargins(0, 0, 0, 9 * screenRatio); ui->vlInterface->setContentsMargins(0, 0, 0, 9 * screenRatio);
#endif #endif
if (screenRatio > 1) if (screenRatio > 1) {
{
ui->lineJSON->setMinimumHeight(qRound(1 * screenRatio)); ui->lineJSON->setMinimumHeight(qRound(1 * screenRatio));
ui->lineJSON->setMaximumHeight(qRound(1 * screenRatio)); ui->lineJSON->setMaximumHeight(qRound(1 * screenRatio));
ui->lineJSON->setLineWidth(qRound(1 * screenRatio)); ui->lineJSON->setLineWidth(qRound(1 * screenRatio));
@ -121,28 +120,22 @@ void JsonEditorDialog::closeEvent(QCloseEvent *ev)
QJsonDocument jsonOriginal = QJsonDocument::fromJson(jsonCode.toUtf8()); QJsonDocument jsonOriginal = QJsonDocument::fromJson(jsonCode.toUtf8());
QString originalCode = QString::fromUtf8(jsonOriginal.toJson(QJsonDocument::Compact)); QString originalCode = QString::fromUtf8(jsonOriginal.toJson(QJsonDocument::Compact));
QString newCode = QString::fromUtf8(jsonNew.toJson(QJsonDocument::Compact)); QString newCode = QString::fromUtf8(jsonNew.toJson(QJsonDocument::Compact));
if (newCode != originalCode) if (newCode != originalCode) {
{
QMessageBox::StandardButton button = QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("<h4>Unsaved changes detected</h4>You want to save the JSON content before you quit?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Cancel); QMessageBox::StandardButton button = QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("<h4>Unsaved changes detected</h4>You want to save the JSON content before you quit?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Cancel);
if (button == QMessageBox::Yes) if (button == QMessageBox::Yes) {
{ if (saveJsonContent()) {
if (saveJsonContent())
{
ev->accept(); ev->accept();
} }
else else {
{
ev->ignore(); ev->ignore();
} }
return; return;
} }
else if (button == QMessageBox::No) else if (button == QMessageBox::No) {
{
ev->accept(); ev->accept();
return; return;
} }
else else {
{
ev->ignore(); ev->ignore();
return; return;
} }
@ -153,47 +146,38 @@ bool JsonEditorDialog::saveJsonContent()
{ {
QString jsonPatched = QString(ui->txtJSON->toPlainText()).replace("\t", " "); QString jsonPatched = QString(ui->txtJSON->toPlainText()).replace("\t", " ");
QJsonDocument jsonNew = QJsonDocument::fromJson(jsonPatched.toUtf8()); QJsonDocument jsonNew = QJsonDocument::fromJson(jsonPatched.toUtf8());
if (!jsonNew.isEmpty()) if (!jsonNew.isEmpty()) {
{
QJsonDocument jsonOriginal = QJsonDocument::fromJson(jsonCode.toUtf8()); QJsonDocument jsonOriginal = QJsonDocument::fromJson(jsonCode.toUtf8());
QString originalCode = QString::fromUtf8(jsonOriginal.toJson(QJsonDocument::Compact)); QString originalCode = QString::fromUtf8(jsonOriginal.toJson(QJsonDocument::Compact));
QString newCode = QString::fromUtf8(jsonNew.toJson(QJsonDocument::Compact)); QString newCode = QString::fromUtf8(jsonNew.toJson(QJsonDocument::Compact));
if (newCode != originalCode) if (newCode != originalCode) {
{
QString currentFilePath = smpic->getPictureFilePath(); QString currentFilePath = smpic->getPictureFilePath();
QString originalFilePath = smpic->getOriginalPictureFilePath(); QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak"; QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName)) if (!QFile::exists(backupFileName)) {
{
QFile::copy(currentFilePath, backupFileName); QFile::copy(currentFilePath, backupFileName);
} }
smpic->setJsonStr(newCode, true); smpic->setJsonStr(newCode, true);
if (!smpic->isJsonOk()) if (!smpic->isJsonOk()) {
{
QString lastStep = smpic->getLastStep(false); QString lastStep = smpic->getLastStep(false);
QString readableError; QString readableError;
if (lastStep.contains("JSONINCOMPLETE") && lastStep.contains("JSONERROR")) if (lastStep.contains("JSONINCOMPLETE") && lastStep.contains("JSONERROR")) {
{
readableError = SnapmaticPicture::tr("JSON is incomplete and malformed"); readableError = SnapmaticPicture::tr("JSON is incomplete and malformed");
} }
else if (lastStep.contains("JSONINCOMPLETE")) else if (lastStep.contains("JSONINCOMPLETE")) {
{
readableError = SnapmaticPicture::tr("JSON is incomplete"); readableError = SnapmaticPicture::tr("JSON is incomplete");
} }
else if (lastStep.contains("JSONERROR")) else if (lastStep.contains("JSONERROR")) {
{
readableError = SnapmaticPicture::tr("JSON is malformed"); readableError = SnapmaticPicture::tr("JSON is malformed");
} }
else else {
{
readableError = tr("JSON Error"); readableError = tr("JSON Error");
} }
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of %1").arg(readableError)); QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of %1").arg(readableError));
smpic->setJsonStr(originalCode, true); smpic->setJsonStr(originalCode, true);
return false; return false;
} }
if (!smpic->exportPicture(currentFilePath)) if (!smpic->exportPicture(currentFilePath)) {
{
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of I/O Error")); QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of I/O Error"));
smpic->setJsonStr(originalCode, true); smpic->setJsonStr(originalCode, true);
return false; return false;
@ -206,8 +190,7 @@ bool JsonEditorDialog::saveJsonContent()
telemetrySettings.beginGroup("Telemetry"); telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool(); bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup(); telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush()) if (pushUsageData && Telemetry->canPush()) {
{
QJsonDocument jsonDocument; QJsonDocument jsonDocument;
QJsonObject jsonObject; QJsonObject jsonObject;
jsonObject["Type"] = "JSONEdited"; jsonObject["Type"] = "JSONEdited";
@ -225,8 +208,7 @@ bool JsonEditorDialog::saveJsonContent()
} }
return true; return true;
} }
else else {
{
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of JSON Error")); QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of JSON Error"));
return false; return false;
} }
@ -240,7 +222,5 @@ void JsonEditorDialog::on_cmdClose_clicked()
void JsonEditorDialog::on_cmdSave_clicked() void JsonEditorDialog::on_cmdSave_clicked()
{ {
if (saveJsonContent()) if (saveJsonContent())
{
close(); close();
}
} }

View File

@ -29,7 +29,11 @@ MapLocationDialog::MapLocationDialog(double x, double y, QWidget *parent) :
ui(new Ui::MapLocationDialog) ui(new Ui::MapLocationDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
ui->setupUi(this); ui->setupUi(this);
ui->cmdDone->setVisible(false); ui->cmdDone->setVisible(false);
@ -45,12 +49,10 @@ MapLocationDialog::MapLocationDialog(double x, double y, QWidget *parent) :
ui->vlMapDialog->setSpacing(widgetMargin); ui->vlMapDialog->setSpacing(widgetMargin);
setMinimumSize(500 * screenRatio, 600 * screenRatio); setMinimumSize(500 * screenRatio, 600 * screenRatio);
setMaximumSize(500 * screenRatio, 600 * screenRatio); setMaximumSize(500 * screenRatio, 600 * screenRatio);
setFixedSize(500 * screenRatio, 600 * screenRatio);
setMouseTracking(true); setMouseTracking(true);
changeMode = false; changeMode = false;
propUpdate = false; propUpdate = false;
drawPointOnMap(xpos_old, ypos_old);
} }
MapLocationDialog::~MapLocationDialog() MapLocationDialog::~MapLocationDialog()
@ -66,6 +68,22 @@ void MapLocationDialog::drawPointOnMap(double xpos_d, double ypos_d)
repaint(); repaint();
} }
void MapLocationDialog::setCayoPerico(bool isCayoPerico)
{
qreal screenRatio = AppEnv::screenRatio();
p_isCayoPerico = isCayoPerico;
if (isCayoPerico) {
setMinimumSize(500 * screenRatio, 500 * screenRatio);
setMaximumSize(500 * screenRatio, 500 * screenRatio);
ui->hlMapDialog->removeItem(ui->vlMapDialog);
ui->hlMapDialog->insertLayout(0, ui->vlMapDialog);
ui->hlMapDialog->removeItem(ui->vlPosLayout);
ui->hlMapDialog->addLayout(ui->vlPosLayout);
ui->labPos->setAlignment(Qt::AlignRight);
}
drawPointOnMap(xpos_old, ypos_old);
}
void MapLocationDialog::on_cmdChange_clicked() void MapLocationDialog::on_cmdChange_clicked()
{ {
qreal screenRatio = AppEnv::screenRatio(); qreal screenRatio = AppEnv::screenRatio();
@ -85,45 +103,34 @@ void MapLocationDialog::on_cmdDone_clicked()
{ {
ui->cmdDone->setVisible(false); ui->cmdDone->setVisible(false);
ui->cmdChange->setVisible(true); ui->cmdChange->setVisible(true);
if (xpos_new != xpos_old || ypos_new != ypos_old) if (xpos_new != xpos_old || ypos_new != ypos_old) {
{
ui->cmdApply->setVisible(true); ui->cmdApply->setVisible(true);
ui->cmdRevert->setVisible(true); ui->cmdRevert->setVisible(true);
} }
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
changeMode = false; changeMode = false;
} }
#if QT_VERSION >= 0x060000
void MapLocationDialog::updatePosFromEvent(double x, double y) void MapLocationDialog::updatePosFromEvent(double x, double y)
{ {
QSize mapPixelSize = size(); QSize mapPixelSize = size();
double xpos_ad = x; double x_per = x / mapPixelSize.width(); // get X %
double ypos_ad = mapPixelSize.height() - y; double y_per = y / mapPixelSize.height(); // get Y %
double xrat = 10000 / (double)mapPixelSize.width(); double x_pos, y_pos;
double yrat = 12000 / (double)mapPixelSize.height(); if (p_isCayoPerico) {
double xpos_rv = xrat * xpos_ad; x_pos = x_per * 2340; // 2340 is 100% for X (Cayo Perico)
double ypos_rv = yrat * ypos_ad; y_pos = y_per * -2340; // -2340 is 100% for Y (Cayo Perico)
double xpos_fp = xpos_rv - 4000; x_pos = x_pos + 3560; // +3560 gets corrected for X (Cayo Perico)
double ypos_fp = ypos_rv - 4000; y_pos = y_pos - 3980; // -4000 gets corrected for Y (Cayo Perico)
drawPointOnMap(xpos_fp, ypos_fp); }
else {
x_pos = x_per * 10000; // 10000 is 100% for X (Los Santos)
y_pos = y_per * -12000; // -12000 is 100% for Y (Los Santos)
x_pos = x_pos - 4000; // -4000 gets corrected for X (Los Santos)
y_pos = y_pos + 8000; // +8000 gets corrected for Y (Los Santos)
}
drawPointOnMap(x_pos, y_pos);
} }
#else
void MapLocationDialog::updatePosFromEvent(int x, int y)
{
QSize mapPixelSize = size();
int xpos_ad = x;
int ypos_ad = mapPixelSize.height() - y;
double xrat = 10000 / (double)mapPixelSize.width();
double yrat = 12000 / (double)mapPixelSize.height();
double xpos_rv = xrat * xpos_ad;
double ypos_rv = yrat * ypos_ad;
double xpos_fp = xpos_rv - 4000;
double ypos_fp = ypos_rv - 4000;
drawPointOnMap(xpos_fp, ypos_fp);
}
#endif
void MapLocationDialog::paintEvent(QPaintEvent *ev) void MapLocationDialog::paintEvent(QPaintEvent *ev)
{ {
@ -132,73 +139,110 @@ void MapLocationDialog::paintEvent(QPaintEvent *ev)
qreal screenRatioPR = AppEnv::screenRatioPR(); qreal screenRatioPR = AppEnv::screenRatioPR();
// Paint Map // Paint Map
QSize mapPixelSize = QSize(width() * screenRatioPR, height() * screenRatioPR); QImage mapImage;
painter.drawPixmap(0, 0, width(), height(), QPixmap(":/img/mappreview.jpg").scaled(mapPixelSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); if (p_isCayoPerico) {
mapImage = QImage(":/img/mapcayoperico.jpg");
}
else {
mapImage = QImage(":/img/mappreview.jpg");
}
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
painter.drawImage(QRect(QPoint(0, 0), size()), mapImage);
// Paint Marker // Paint Marker
QSize mapPixelSize = size();
int pointMarkerSize = 8 * screenRatio; int pointMarkerSize = 8 * screenRatio;
int pointMarkerHalfSize = pointMarkerSize / 2; int pointMarkerHalfSize = pointMarkerSize / 2;
long xpos_ms = qRound(xpos_new); double xpos_mp, ypos_mp;
long ypos_ms = qRound(ypos_new); if (p_isCayoPerico) {
double xpos_ma = xpos_ms + 4000; double xpos_per = xpos_new - 3560; // correct X in reserve
double ypos_ma = ypos_ms + 4000; double ypos_per = ypos_new + 3980; // correct y in reserve
double xrat = (double)width() / 10000; xpos_per = xpos_per / 2340; // divide 100% for X
double yrat = (double)height() / 12000; ypos_per = ypos_per / -2340; // divide 100% for Y
long xpos_mp = qRound(xpos_ma * xrat); xpos_mp = xpos_per * mapPixelSize.width(); // locate window width pos
long ypos_mp = qRound(ypos_ma * yrat); ypos_mp = ypos_per * mapPixelSize.height(); // locate window height pos
long xpos_pr; }
long ypos_pr; else {
double xpos_per = xpos_new + 4000; // correct X in reserve
double ypos_per = ypos_new - 8000; // correct y in reserve
xpos_per = xpos_per / 10000; // divide 100% for X
ypos_per = ypos_per / -12000; // divide 100% for Y
xpos_mp = xpos_per * mapPixelSize.width(); // locate window width pos
ypos_mp = ypos_per * mapPixelSize.height(); // locate window height pos
}
long xpos_pr, ypos_pr;
if (screenRatioPR != 1) { if (screenRatioPR != 1) {
#ifdef Q_OS_WIN
xpos_pr = xpos_mp - pointMarkerHalfSize;
ypos_pr = ypos_mp + pointMarkerHalfSize;
#else
xpos_pr = xpos_mp - pointMarkerHalfSize + screenRatioPR; xpos_pr = xpos_mp - pointMarkerHalfSize + screenRatioPR;
ypos_pr = ypos_mp + pointMarkerHalfSize - screenRatioPR; ypos_pr = ypos_mp - pointMarkerHalfSize + screenRatioPR;
#endif
} }
else { else {
xpos_pr = xpos_mp - pointMarkerHalfSize; xpos_pr = xpos_mp - pointMarkerHalfSize;
ypos_pr = ypos_mp + pointMarkerHalfSize; ypos_pr = ypos_mp - pointMarkerHalfSize;
} }
QPixmap mapMarkerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMarkerSize, pointMarkerSize)); QPixmap mapMarkerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMarkerSize, pointMarkerSize));
painter.drawPixmap(xpos_pr, height() - ypos_pr, pointMarkerSize, pointMarkerSize, mapMarkerPixmap); painter.drawPixmap(xpos_pr, ypos_pr, pointMarkerSize, pointMarkerSize, mapMarkerPixmap);
QDialog::paintEvent(ev); QDialog::paintEvent(ev);
} }
void MapLocationDialog::mouseMoveEvent(QMouseEvent *ev) void MapLocationDialog::mouseMoveEvent(QMouseEvent *ev)
{ {
if (!changeMode) { ev->ignore(); } if (!changeMode) {
else if (ev->buttons() & Qt::LeftButton) ev->ignore();
{ }
else if (ev->buttons() & Qt::LeftButton) {
#if QT_VERSION >= 0x060000 #if QT_VERSION >= 0x060000
updatePosFromEvent(ev->position().x(), ev->position().y()); const QPointF localPos = ev->position();
#elif QT_VERSION >= 0x050000
const QPointF localPos = ev->localPos();
#else #else
updatePosFromEvent(ev->x(), ev->y()); const QPoint localPos = ev->pos();
#endif
#ifdef Q_OS_WIN
qreal screenRatioPR = AppEnv::screenRatioPR();
if (screenRatioPR != 1) {
updatePosFromEvent(localPos.x() - screenRatioPR, localPos.y() - screenRatioPR);
}
else {
updatePosFromEvent(localPos.x(), localPos.y());
}
#else
updatePosFromEvent(localPos.x(), localPos.y());
#endif #endif
ev->accept(); ev->accept();
} }
else else {
{
ev->ignore(); ev->ignore();
} }
} }
void MapLocationDialog::mouseReleaseEvent(QMouseEvent *ev) void MapLocationDialog::mouseReleaseEvent(QMouseEvent *ev)
{ {
if (!changeMode) { ev->ignore(); } if (!changeMode) {
else if (ev->button() == Qt::LeftButton) ev->ignore();
{ }
else if (ev->button() == Qt::LeftButton) {
#if QT_VERSION >= 0x060000 #if QT_VERSION >= 0x060000
updatePosFromEvent(ev->position().x(), ev->position().y()); const QPointF localPos = ev->position();
#elif QT_VERSION >= 0x050000
const QPointF localPos = ev->localPos();
#else #else
updatePosFromEvent(ev->x(), ev->y()); const QPointF localPos = ev->posF();
#endif
#ifdef Q_OS_WIN
qreal screenRatioPR = AppEnv::screenRatioPR();
if (screenRatioPR != 1) {
updatePosFromEvent(localPos.x() - screenRatioPR, localPos.y() - screenRatioPR);
}
else {
updatePosFromEvent(localPos.x(), localPos.y());
}
#else
updatePosFromEvent(localPos.x(), localPos.y());
#endif #endif
ev->accept(); ev->accept();
} }
else else {
{
ev->ignore(); ev->ignore();
} }
} }

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017 Syping * Copyright (C) 2017-2021 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
@ -33,6 +33,7 @@ class MapLocationDialog : public QDialog
public: public:
explicit MapLocationDialog(double x, double y, QWidget *parent = 0); explicit MapLocationDialog(double x, double y, QWidget *parent = 0);
void drawPointOnMap(double x, double y); void drawPointOnMap(double x, double y);
void setCayoPerico(bool isCayoPerico);
bool propUpdated(); bool propUpdated();
double getXpos(); double getXpos();
double getYpos(); double getYpos();
@ -48,11 +49,7 @@ private slots:
void on_cmdApply_clicked(); void on_cmdApply_clicked();
void on_cmdChange_clicked(); void on_cmdChange_clicked();
void on_cmdRevert_clicked(); void on_cmdRevert_clicked();
#if QT_VERSION >= 0x060000
void updatePosFromEvent(double x, double y); void updatePosFromEvent(double x, double y);
#else
void updatePosFromEvent(int x, int y);
#endif
void on_cmdClose_clicked(); void on_cmdClose_clicked();
private: private:
@ -62,6 +59,7 @@ private:
double ypos_new; double ypos_new;
bool propUpdate; bool propUpdate;
bool changeMode; bool changeMode;
bool p_isCayoPerico;
Ui::MapLocationDialog *ui; Ui::MapLocationDialog *ui;
}; };

View File

@ -55,7 +55,11 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
ui(new Ui::OptionsDialog) ui(new Ui::OptionsDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
// Setup User Interface // Setup User Interface
ui->setupUi(this); ui->setupUi(this);

View File

@ -127,10 +127,20 @@ PictureDialog::PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, Cre
void PictureDialog::setupPictureDialog() void PictureDialog::setupPictureDialog()
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
setWindowFlag(Qt::CustomizeWindowHint, true);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint^Qt::CustomizeWindowHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint^Qt::CustomizeWindowHint);
#endif
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered) // for stupid Window Manager like GNOME
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::Dialog, false);
setWindowFlag(Qt::Window, true);
#else
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window); setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
#endif #endif
// Setup User Interface // Setup User Interface
@ -684,7 +694,10 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button)
#endif #endif
PictureWidget *pictureWidget = new PictureWidget(this); // Work! PictureWidget *pictureWidget = new PictureWidget(this); // Work!
pictureWidget->setObjectName("PictureWidget"); pictureWidget->setObjectName("PictureWidget");
#if QT_VERSION >= 0x050600 #if QT_VERSION >= 0x050900
pictureWidget->setWindowFlag(Qt::FramelessWindowHint, true);
pictureWidget->setWindowFlag(Qt::MaximizeUsingFullscreenGeometryHint, true);
#elif QT_VERSION >= 0x050600
pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint^Qt::MaximizeUsingFullscreenGeometryHint); pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint^Qt::MaximizeUsingFullscreenGeometryHint);
#else #else
pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint); pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint);
@ -729,13 +742,15 @@ int PictureDialog::getIndex()
void PictureDialog::openPreviewMap() void PictureDialog::openPreviewMap()
{ {
SnapmaticPicture *picture = smpic; SnapmaticPicture *picture = smpic;
SnapmaticProperties currentProperties = picture->getSnapmaticProperties();
MapLocationDialog *mapLocDialog; MapLocationDialog *mapLocDialog;
if (rqFullscreen && fullscreenWidget != nullptr) { if (rqFullscreen && fullscreenWidget != nullptr) {
mapLocDialog = new MapLocationDialog(picture->getSnapmaticProperties().location.x, picture->getSnapmaticProperties().location.y, fullscreenWidget); mapLocDialog = new MapLocationDialog(currentProperties.location.x, currentProperties.location.y, fullscreenWidget);
} }
else { else {
mapLocDialog = new MapLocationDialog(picture->getSnapmaticProperties().location.x, picture->getSnapmaticProperties().location.y, this); mapLocDialog = new MapLocationDialog(currentProperties.location.x, currentProperties.location.y, this);
} }
mapLocDialog->setCayoPerico(currentProperties.location.isCayoPerico);
mapLocDialog->setWindowIcon(windowIcon()); mapLocDialog->setWindowIcon(windowIcon());
mapLocDialog->setModal(true); mapLocDialog->setModal(true);
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
@ -746,10 +761,9 @@ void PictureDialog::openPreviewMap()
mapLocDialog->exec(); mapLocDialog->exec();
if (mapLocDialog->propUpdated()) { if (mapLocDialog->propUpdated()) {
// Update Snapmatic Properties // Update Snapmatic Properties
SnapmaticProperties localSpJson = picture->getSnapmaticProperties(); currentProperties.location.x = mapLocDialog->getXpos();
localSpJson.location.x = mapLocDialog->getXpos(); currentProperties.location.y = mapLocDialog->getYpos();
localSpJson.location.y = mapLocDialog->getYpos(); currentProperties.location.z = 0;
localSpJson.location.z = 0;
// Update Snapmatic Picture // Update Snapmatic Picture
QString currentFilePath = picture->getPictureFilePath(); QString currentFilePath = picture->getPictureFilePath();
@ -759,7 +773,7 @@ void PictureDialog::openPreviewMap()
QFile::copy(currentFilePath, backupFileName); QFile::copy(currentFilePath, backupFileName);
} }
SnapmaticProperties fallbackProperties = picture->getSnapmaticProperties(); SnapmaticProperties fallbackProperties = picture->getSnapmaticProperties();
picture->setSnapmaticProperties(localSpJson); picture->setSnapmaticProperties(currentProperties);
if (!picture->exportPicture(currentFilePath)) { if (!picture->exportPicture(currentFilePath)) {
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of I/O Error")); QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of I/O Error"));
picture->setSnapmaticProperties(fallbackProperties); picture->setSnapmaticProperties(fallbackProperties);

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2020 Syping * Copyright (C) 2016-2021 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
@ -31,7 +31,11 @@ PlayerListDialog::PlayerListDialog(QStringList players, ProfileDatabase *profile
ui(new Ui::PlayerListDialog) ui(new Ui::PlayerListDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
listUpdated = false; listUpdated = false;
ui->setupUi(this); ui->setupUi(this);
@ -39,40 +43,32 @@ PlayerListDialog::PlayerListDialog(QStringList players, ProfileDatabase *profile
ui->cmdCancel->setFocus(); ui->cmdCancel->setFocus();
// Set Icon for Apply Button // Set Icon for Apply Button
if (QIcon::hasThemeIcon("dialog-ok-apply")) if (QIcon::hasThemeIcon("dialog-ok-apply")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok-apply")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok-apply"));
} }
else if (QIcon::hasThemeIcon("dialog-apply")) else if (QIcon::hasThemeIcon("dialog-apply")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-apply")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-apply"));
} }
else if (QIcon::hasThemeIcon("gtk-apply")) else if (QIcon::hasThemeIcon("gtk-apply")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("gtk-apply")); ui->cmdApply->setIcon(QIcon::fromTheme("gtk-apply"));
} }
else if (QIcon::hasThemeIcon("dialog-ok")) else if (QIcon::hasThemeIcon("dialog-ok")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
} }
else if (QIcon::hasThemeIcon("gtk-ok")) else if (QIcon::hasThemeIcon("gtk-ok")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
} }
// Set Icon for Cancel Button // Set Icon for Cancel Button
if (QIcon::hasThemeIcon("dialog-cancel")) if (QIcon::hasThemeIcon("dialog-cancel")) {
{
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel")); ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
} }
else if (QIcon::hasThemeIcon("gtk-cancel")) else if (QIcon::hasThemeIcon("gtk-cancel")) {
{
ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel")); ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel"));
} }
// Set Icon for Manage Buttons // Set Icon for Manage Buttons
if (QIcon::hasThemeIcon("go-previous") && QIcon::hasThemeIcon("go-next") && QIcon::hasThemeIcon("list-add")) if (QIcon::hasThemeIcon("go-previous") && QIcon::hasThemeIcon("go-next") && QIcon::hasThemeIcon("list-add")) {
{
#if QT_VERSION < 0x050600 #if QT_VERSION < 0x050600
qreal screenRatio = AppEnv::screenRatio(); qreal screenRatio = AppEnv::screenRatio();
if (screenRatio != 1) { if (screenRatio != 1) {
@ -87,8 +83,7 @@ PlayerListDialog::PlayerListDialog(QStringList players, ProfileDatabase *profile
ui->cmdMakeSe->setIcon(QIcon::fromTheme("go-next")); ui->cmdMakeSe->setIcon(QIcon::fromTheme("go-next"));
ui->cmdMakeAd->setIcon(QIcon::fromTheme("list-add")); ui->cmdMakeAd->setIcon(QIcon::fromTheme("list-add"));
} }
else else {
{
#if QT_VERSION < 0x050600 #if QT_VERSION < 0x050600
qreal screenRatio = AppEnv::screenRatio(); qreal screenRatio = AppEnv::screenRatio();
if (screenRatio != 1) { if (screenRatio != 1) {
@ -112,12 +107,10 @@ PlayerListDialog::PlayerListDialog(QStringList players, ProfileDatabase *profile
PlayerListDialog::~PlayerListDialog() PlayerListDialog::~PlayerListDialog()
{ {
for (QObject *object : ui->listAvPlayers->children()) for (QObject *object : ui->listAvPlayers->children()) {
{
delete object; delete object;
} }
for (QObject *object : ui->listSePlayers->children()) for (QObject *object : ui->listSePlayers->children()) {
{
delete object; delete object;
} }
delete ui; delete ui;
@ -131,16 +124,13 @@ void PlayerListDialog::on_cmdCancel_clicked()
void PlayerListDialog::buildInterface() void PlayerListDialog::buildInterface()
{ {
const QStringList dbPlayers = profileDB->getPlayers(); const QStringList dbPlayers = profileDB->getPlayers();
for (QString sePlayer : players) for (const QString &sePlayer : players) {
{
QListWidgetItem *playerItem = new QListWidgetItem(profileDB->getPlayerName(sePlayer)); QListWidgetItem *playerItem = new QListWidgetItem(profileDB->getPlayerName(sePlayer));
playerItem->setData(Qt::UserRole, sePlayer); playerItem->setData(Qt::UserRole, sePlayer);
ui->listSePlayers->addItem(playerItem); ui->listSePlayers->addItem(playerItem);
} }
for (QString dbPlayer : dbPlayers) for (const QString &dbPlayer : dbPlayers) {
{ if (!players.contains(dbPlayer)) {
if (!players.contains(dbPlayer))
{
QListWidgetItem *playerItem = new QListWidgetItem(profileDB->getPlayerName(dbPlayer)); QListWidgetItem *playerItem = new QListWidgetItem(profileDB->getPlayerName(dbPlayer));
playerItem->setData(Qt::UserRole, dbPlayer); playerItem->setData(Qt::UserRole, dbPlayer);
ui->listAvPlayers->addItem(playerItem); ui->listAvPlayers->addItem(playerItem);
@ -151,8 +141,7 @@ void PlayerListDialog::buildInterface()
void PlayerListDialog::on_cmdMakeAv_clicked() void PlayerListDialog::on_cmdMakeAv_clicked()
{ {
for (QListWidgetItem *item : ui->listSePlayers->selectedItems()) for (QListWidgetItem *item : ui->listSePlayers->selectedItems()) {
{
QString playerName = item->text(); QString playerName = item->text();
int playerID = item->data(Qt::UserRole).toInt(); int playerID = item->data(Qt::UserRole).toInt();
delete item; delete item;
@ -166,13 +155,11 @@ void PlayerListDialog::on_cmdMakeAv_clicked()
void PlayerListDialog::on_cmdMakeSe_clicked() void PlayerListDialog::on_cmdMakeSe_clicked()
{ {
int maxPlayers = 30; int maxPlayers = 30;
if (maxPlayers < ui->listSePlayers->count() + ui->listAvPlayers->selectedItems().count()) if (maxPlayers < ui->listSePlayers->count() + ui->listAvPlayers->selectedItems().count()) {
{
QMessageBox::warning(this, tr("Add Players..."), tr("Failed to add more Players because the limit of Players are %1!").arg(QString::number(maxPlayers))); QMessageBox::warning(this, tr("Add Players..."), tr("Failed to add more Players because the limit of Players are %1!").arg(QString::number(maxPlayers)));
return; return;
} }
for (QListWidgetItem *item : ui->listAvPlayers->selectedItems()) for (QListWidgetItem *item : ui->listAvPlayers->selectedItems()) {
{
QString playerName = item->text(); QString playerName = item->text();
int playerID = item->data(Qt::UserRole).toInt(); int playerID = item->data(Qt::UserRole).toInt();
delete item; delete item;
@ -186,15 +173,12 @@ void PlayerListDialog::on_cmdMakeAd_clicked()
{ {
bool playerOk; bool playerOk;
int playerID = QInputDialog::getInt(this, tr("Add Player..."), tr("Enter Social Club Player ID"), 1, 1, 214783647, 1, &playerOk, windowFlags()); int playerID = QInputDialog::getInt(this, tr("Add Player..."), tr("Enter Social Club Player ID"), 1, 1, 214783647, 1, &playerOk, windowFlags());
if (playerOk) if (playerOk) {
{ for (int i = 0; i < ui->listAvPlayers->count(); ++i) {
for (int i = 0; i < ui->listAvPlayers->count(); ++i)
{
QListWidgetItem *item = ui->listAvPlayers->item(i); QListWidgetItem *item = ui->listAvPlayers->item(i);
QString itemPlayerName = item->text(); QString itemPlayerName = item->text();
int itemPlayerID = item->data(Qt::UserRole).toInt(); int itemPlayerID = item->data(Qt::UserRole).toInt();
if (itemPlayerID == playerID) if (itemPlayerID == playerID) {
{
delete item; delete item;
QListWidgetItem *playerItem = new QListWidgetItem(itemPlayerName); QListWidgetItem *playerItem = new QListWidgetItem(itemPlayerName);
playerItem->setData(Qt::UserRole, playerID); playerItem->setData(Qt::UserRole, playerID);
@ -202,8 +186,7 @@ void PlayerListDialog::on_cmdMakeAd_clicked()
return; return;
} }
} }
for (int i = 0; i < ui->listSePlayers->count(); ++i) for (int i = 0; i < ui->listSePlayers->count(); ++i) {
{
QListWidgetItem *item = ui->listSePlayers->item(i); QListWidgetItem *item = ui->listSePlayers->item(i);
int itemPlayerID = item->data(Qt::UserRole).toInt(); int itemPlayerID = item->data(Qt::UserRole).toInt();
if (itemPlayerID == playerID) if (itemPlayerID == playerID)
@ -221,8 +204,7 @@ void PlayerListDialog::on_cmdMakeAd_clicked()
void PlayerListDialog::on_cmdApply_clicked() void PlayerListDialog::on_cmdApply_clicked()
{ {
players.clear(); players.clear();
for (int i = 0; i < ui->listSePlayers->count(); ++i) for (int i = 0; i < ui->listSePlayers->count(); ++i) {
{
players += ui->listSePlayers->item(i)->data(Qt::UserRole).toString(); players += ui->listSePlayers->item(i)->data(Qt::UserRole).toString();
} }
emit playerListUpdated(players); emit playerListUpdated(players);

View File

@ -28,7 +28,11 @@ SavegameDialog::SavegameDialog(QWidget *parent) :
ui(new Ui::SavegameDialog) ui(new Ui::SavegameDialog)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
// Setup User Interface // Setup User Interface
ui->setupUi(this); ui->setupUi(this);

View File

@ -41,41 +41,38 @@ SnapmaticEditor::SnapmaticEditor(CrewDatabase *crewDB, ProfileDatabase *profileD
ui(new Ui::SnapmaticEditor) ui(new Ui::SnapmaticEditor)
{ {
// Set Window Flags // Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
ui->setupUi(this); ui->setupUi(this);
ui->cmdCancel->setDefault(true); ui->cmdCancel->setDefault(true);
ui->cmdCancel->setFocus(); ui->cmdCancel->setFocus();
// Set Icon for Apply Button // Set Icon for Apply Button
if (QIcon::hasThemeIcon("dialog-ok-apply")) if (QIcon::hasThemeIcon("dialog-ok-apply")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok-apply")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok-apply"));
} }
else if (QIcon::hasThemeIcon("dialog-apply")) else if (QIcon::hasThemeIcon("dialog-apply")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-apply")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-apply"));
} }
else if (QIcon::hasThemeIcon("gtk-apply")) else if (QIcon::hasThemeIcon("gtk-apply")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("gtk-apply")); ui->cmdApply->setIcon(QIcon::fromTheme("gtk-apply"));
} }
else if (QIcon::hasThemeIcon("dialog-ok")) else if (QIcon::hasThemeIcon("dialog-ok")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
} }
else if (QIcon::hasThemeIcon("gtk-ok")) else if (QIcon::hasThemeIcon("gtk-ok")) {
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok")); ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
} }
// Set Icon for Cancel Button // Set Icon for Cancel Button
if (QIcon::hasThemeIcon("dialog-cancel")) if (QIcon::hasThemeIcon("dialog-cancel")) {
{
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel")); ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
} }
else if (QIcon::hasThemeIcon("gtk-cancel")) else if (QIcon::hasThemeIcon("gtk-cancel")) {
{
ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel")); ui->cmdCancel->setIcon(QIcon::fromTheme("gtk-cancel"));
} }
@ -96,27 +93,18 @@ SnapmaticEditor::~SnapmaticEditor()
void SnapmaticEditor::selfie_toggled(bool checked) void SnapmaticEditor::selfie_toggled(bool checked)
{ {
if (checked) isSelfie = checked;
{
isSelfie = true;
}
else
{
isSelfie = false;
}
} }
void SnapmaticEditor::mugshot_toggled(bool checked) void SnapmaticEditor::mugshot_toggled(bool checked)
{ {
if (checked) if (checked) {
{
isMugshot = true; isMugshot = true;
ui->cbDirector->setEnabled(false); ui->cbDirector->setEnabled(false);
ui->cbDirector->setChecked(false); ui->cbDirector->setChecked(false);
} }
else else {
{
isMugshot = false; isMugshot = false;
ui->cbDirector->setEnabled(true); ui->cbDirector->setEnabled(true);
} }
@ -124,14 +112,12 @@ void SnapmaticEditor::mugshot_toggled(bool checked)
void SnapmaticEditor::editor_toggled(bool checked) void SnapmaticEditor::editor_toggled(bool checked)
{ {
if (checked) if (checked) {
{
isEditor = true; isEditor = true;
ui->cbDirector->setEnabled(false); ui->cbDirector->setEnabled(false);
ui->cbDirector->setChecked(false); ui->cbDirector->setChecked(false);
} }
else else {
{
isEditor = false; isEditor = false;
ui->cbDirector->setEnabled(true); ui->cbDirector->setEnabled(true);
} }
@ -139,8 +125,7 @@ void SnapmaticEditor::editor_toggled(bool checked)
void SnapmaticEditor::on_rbSelfie_toggled(bool checked) void SnapmaticEditor::on_rbSelfie_toggled(bool checked)
{ {
if (checked) if (checked) {
{
mugshot_toggled(false); mugshot_toggled(false);
editor_toggled(false); editor_toggled(false);
selfie_toggled(true); selfie_toggled(true);
@ -149,8 +134,7 @@ void SnapmaticEditor::on_rbSelfie_toggled(bool checked)
void SnapmaticEditor::on_rbMugshot_toggled(bool checked) void SnapmaticEditor::on_rbMugshot_toggled(bool checked)
{ {
if (checked) if (checked) {
{
selfie_toggled(false); selfie_toggled(false);
editor_toggled(false); editor_toggled(false);
mugshot_toggled(true); mugshot_toggled(true);
@ -159,8 +143,7 @@ void SnapmaticEditor::on_rbMugshot_toggled(bool checked)
void SnapmaticEditor::on_rbEditor_toggled(bool checked) void SnapmaticEditor::on_rbEditor_toggled(bool checked)
{ {
if (checked) if (checked) {
{
selfie_toggled(false); selfie_toggled(false);
mugshot_toggled(false); mugshot_toggled(false);
editor_toggled(true); editor_toggled(true);
@ -169,8 +152,7 @@ void SnapmaticEditor::on_rbEditor_toggled(bool checked)
void SnapmaticEditor::on_rbCustom_toggled(bool checked) void SnapmaticEditor::on_rbCustom_toggled(bool checked)
{ {
if (checked) if (checked) {
{
selfie_toggled(false); selfie_toggled(false);
mugshot_toggled(false); mugshot_toggled(false);
editor_toggled(false); editor_toggled(false);
@ -189,20 +171,16 @@ void SnapmaticEditor::setSnapmaticPicture(SnapmaticPicture *picture)
playersList = snapmaticProperties.playersList; playersList = snapmaticProperties.playersList;
ui->cbDirector->setChecked(snapmaticProperties.isFromDirector); ui->cbDirector->setChecked(snapmaticProperties.isFromDirector);
ui->cbMeme->setChecked(snapmaticProperties.isMeme); ui->cbMeme->setChecked(snapmaticProperties.isMeme);
if (isSelfie) if (isSelfie) {
{
ui->rbSelfie->setChecked(true); ui->rbSelfie->setChecked(true);
} }
else if (isMugshot) else if (isMugshot) {
{
ui->rbMugshot->setChecked(true); ui->rbMugshot->setChecked(true);
} }
else if (isEditor) else if (isEditor) {
{
ui->rbEditor->setChecked(true); ui->rbEditor->setChecked(true);
} }
else else {
{
ui->rbCustom->setChecked(true); ui->rbCustom->setChecked(true);
} }
setSnapmaticCrew(returnCrewName(crewID)); setSnapmaticCrew(returnCrewName(crewID));
@ -212,8 +190,7 @@ void SnapmaticEditor::setSnapmaticPicture(SnapmaticPicture *picture)
void SnapmaticEditor::insertPlayerNames(QStringList *players) void SnapmaticEditor::insertPlayerNames(QStringList *players)
{ {
for (int i = 0; i < players->size(); ++i) for (int i = 0; i < players->size(); ++i) {
{
players->replace(i, profileDB->getPlayerName(players->at(i))); players->replace(i, profileDB->getPlayerName(players->at(i)));
} }
} }
@ -229,54 +206,48 @@ void SnapmaticEditor::setSnapmaticPlayers(const QStringList &players)
{ {
QString editStr = QString("<a href=\"g5e://editplayers\" style=\"text-decoration: none;\">%1</a>").arg(tr("Edit")); QString editStr = QString("<a href=\"g5e://editplayers\" style=\"text-decoration: none;\">%1</a>").arg(tr("Edit"));
QString playersStr; QString playersStr;
if (players.length() != 1) if (players.length() != 1) {
{
playersStr = tr("Players: %1 (%2)", "Multiple Player are inserted here"); playersStr = tr("Players: %1 (%2)", "Multiple Player are inserted here");
} }
else else {
{
playersStr = tr("Player: %1 (%2)", "One Player is inserted here"); playersStr = tr("Player: %1 (%2)", "One Player is inserted here");
} }
if (players.length() != 0) if (players.length() != 0) {
{
ui->labPlayers->setText(playersStr.arg(players.join(", "), editStr)); ui->labPlayers->setText(playersStr.arg(players.join(", "), editStr));
} }
else else {
{
ui->labPlayers->setText(playersStr.arg(QApplication::translate("PictureDialog", "No Players"), editStr)); ui->labPlayers->setText(playersStr.arg(QApplication::translate("PictureDialog", "No Players"), editStr));
} }
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width())); ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width()));
ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width())); ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width()));
if (heightForWidth(width()) > height()) { resize(width(), heightForWidth(width())); } if (heightForWidth(width()) > height())
resize(width(), heightForWidth(width()));
#endif #endif
} }
void SnapmaticEditor::setSnapmaticTitle(const QString &title) void SnapmaticEditor::setSnapmaticTitle(const QString &title)
{ {
if (title.length() > 39) if (title.length() > 39) {
{
snapmaticTitle = title.left(39); snapmaticTitle = title.left(39);
} }
else else {
{
snapmaticTitle = title; snapmaticTitle = title;
} }
QString editStr = QString("<a href=\"g5e://edittitle\" style=\"text-decoration: none;\">%1</a>").arg(tr("Edit")); QString editStr = QString("<a href=\"g5e://edittitle\" style=\"text-decoration: none;\">%1</a>").arg(tr("Edit"));
QString titleStr = tr("Title: %1 (%2)").arg(StringParser::escapeString(snapmaticTitle), editStr); QString titleStr = tr("Title: %1 (%2)").arg(StringParser::escapeString(snapmaticTitle), editStr);
ui->labTitle->setText(titleStr); ui->labTitle->setText(titleStr);
if (SnapmaticPicture::verifyTitle(snapmaticTitle)) if (SnapmaticPicture::verifyTitle(snapmaticTitle)) {
{
ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes", "Yes, should work fine")))); ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("<span style=\"color: green\">%1</span>").arg(tr("Yes", "Yes, should work fine"))));
} }
else else {
{
ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("<span style=\"color: red\">%1</span>").arg(tr("No", "No, could lead to issues")))); ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("<span style=\"color: red\">%1</span>").arg(tr("No", "No, could lead to issues"))));
} }
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width())); ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width()));
ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width())); ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width()));
if (heightForWidth(width()) > height()) { resize(width(), heightForWidth(width())); } if (heightForWidth(width()) > height())
resize(width(), heightForWidth(width()));
#endif #endif
} }
@ -288,7 +259,8 @@ void SnapmaticEditor::setSnapmaticCrew(const QString &crew)
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width())); ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width()));
ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width())); ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width()));
if (heightForWidth(width()) > height()) { resize(width(), heightForWidth(width())); } if (heightForWidth(width()) > height())
resize(width(), heightForWidth(width()));
#endif #endif
} }
@ -304,8 +276,7 @@ void SnapmaticEditor::on_cmdCancel_clicked()
void SnapmaticEditor::on_cmdApply_clicked() void SnapmaticEditor::on_cmdApply_clicked()
{ {
if (ui->cbQualify->isChecked()) if (ui->cbQualify->isChecked()) {
{
qualifyAvatar(); qualifyAvatar();
} }
snapmaticProperties.crewID = crewID; snapmaticProperties.crewID = crewID;
@ -315,27 +286,23 @@ void SnapmaticEditor::on_cmdApply_clicked()
snapmaticProperties.isFromDirector = ui->cbDirector->isChecked(); snapmaticProperties.isFromDirector = ui->cbDirector->isChecked();
snapmaticProperties.isMeme = ui->cbMeme->isChecked(); snapmaticProperties.isMeme = ui->cbMeme->isChecked();
snapmaticProperties.playersList = playersList; snapmaticProperties.playersList = playersList;
if (smpic) if (smpic) {
{
QString currentFilePath = smpic->getPictureFilePath(); QString currentFilePath = smpic->getPictureFilePath();
QString originalFilePath = smpic->getOriginalPictureFilePath(); QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak"; QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName)) if (!QFile::exists(backupFileName)) {
{
QFile::copy(currentFilePath, backupFileName); QFile::copy(currentFilePath, backupFileName);
} }
SnapmaticProperties fallbackProperties = smpic->getSnapmaticProperties(); SnapmaticProperties fallbackProperties = smpic->getSnapmaticProperties();
QString fallbackTitle = smpic->getPictureTitle(); QString fallbackTitle = smpic->getPictureTitle();
smpic->setSnapmaticProperties(snapmaticProperties); smpic->setSnapmaticProperties(snapmaticProperties);
smpic->setPictureTitle(snapmaticTitle); smpic->setPictureTitle(snapmaticTitle);
if (!smpic->exportPicture(currentFilePath)) if (!smpic->exportPicture(currentFilePath)) {
{
QMessageBox::warning(this, tr("Snapmatic Properties"), tr("Patching of Snapmatic Properties failed because of I/O Error")); QMessageBox::warning(this, tr("Snapmatic Properties"), tr("Patching of Snapmatic Properties failed because of I/O Error"));
smpic->setSnapmaticProperties(fallbackProperties); smpic->setSnapmaticProperties(fallbackProperties);
smpic->setPictureTitle(fallbackTitle); smpic->setPictureTitle(fallbackTitle);
} }
else else {
{
smpic->updateStrings(); smpic->updateStrings();
smpic->emitUpdate(); smpic->emitUpdate();
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
@ -343,8 +310,7 @@ void SnapmaticEditor::on_cmdApply_clicked()
telemetrySettings.beginGroup("Telemetry"); telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool(); bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup(); telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush()) if (pushUsageData && Telemetry->canPush()) {
{
QJsonDocument jsonDocument; QJsonDocument jsonDocument;
QJsonObject jsonObject; QJsonObject jsonObject;
jsonObject["Type"] = "PropertyEdited"; jsonObject["Type"] = "PropertyEdited";
@ -373,8 +339,7 @@ void SnapmaticEditor::qualifyAvatar()
void SnapmaticEditor::on_cbQualify_toggled(bool checked) void SnapmaticEditor::on_cbQualify_toggled(bool checked)
{ {
if (checked) if (checked) {
{
ui->cbMeme->setEnabled(false); ui->cbMeme->setEnabled(false);
ui->cbDirector->setEnabled(false); ui->cbDirector->setEnabled(false);
ui->rbCustom->setEnabled(false); ui->rbCustom->setEnabled(false);
@ -382,15 +347,13 @@ void SnapmaticEditor::on_cbQualify_toggled(bool checked)
ui->rbEditor->setEnabled(false); ui->rbEditor->setEnabled(false);
ui->rbMugshot->setEnabled(false); ui->rbMugshot->setEnabled(false);
} }
else else {
{
ui->cbMeme->setEnabled(true); ui->cbMeme->setEnabled(true);
ui->rbCustom->setEnabled(true); ui->rbCustom->setEnabled(true);
ui->rbSelfie->setEnabled(true); ui->rbSelfie->setEnabled(true);
ui->rbEditor->setEnabled(true); ui->rbEditor->setEnabled(true);
ui->rbMugshot->setEnabled(true); ui->rbMugshot->setEnabled(true);
if (ui->rbSelfie->isChecked() || ui->rbCustom->isChecked()) if (ui->rbSelfie->isChecked() || ui->rbCustom->isChecked()) {
{
ui->cbDirector->setEnabled(true); ui->cbDirector->setEnabled(true);
} }
} }
@ -398,8 +361,7 @@ void SnapmaticEditor::on_cbQualify_toggled(bool checked)
void SnapmaticEditor::on_labPlayers_linkActivated(const QString &link) void SnapmaticEditor::on_labPlayers_linkActivated(const QString &link)
{ {
if (link == "g5e://editplayers") if (link == "g5e://editplayers") {
{
PlayerListDialog *playerListDialog = new PlayerListDialog(playersList, profileDB, this); PlayerListDialog *playerListDialog = new PlayerListDialog(playersList, profileDB, this);
connect(playerListDialog, SIGNAL(playerListUpdated(QStringList)), this, SLOT(playerListUpdated(QStringList))); connect(playerListDialog, SIGNAL(playerListUpdated(QStringList)), this, SLOT(playerListUpdated(QStringList)));
playerListDialog->setModal(true); playerListDialog->setModal(true);
@ -411,12 +373,10 @@ void SnapmaticEditor::on_labPlayers_linkActivated(const QString &link)
void SnapmaticEditor::on_labTitle_linkActivated(const QString &link) void SnapmaticEditor::on_labTitle_linkActivated(const QString &link)
{ {
if (link == "g5e://edittitle") if (link == "g5e://edittitle") {
{
bool ok; bool ok;
QString newTitle = QInputDialog::getText(this, tr("Snapmatic Title"), tr("New Snapmatic title:"), QLineEdit::Normal, snapmaticTitle, &ok, windowFlags()); QString newTitle = QInputDialog::getText(this, tr("Snapmatic Title"), tr("New Snapmatic title:"), QLineEdit::Normal, snapmaticTitle, &ok, windowFlags());
if (ok && !newTitle.isEmpty()) if (ok && !newTitle.isEmpty()) {
{
setSnapmaticTitle(newTitle); setSnapmaticTitle(newTitle);
} }
} }
@ -424,39 +384,33 @@ void SnapmaticEditor::on_labTitle_linkActivated(const QString &link)
void SnapmaticEditor::on_labCrew_linkActivated(const QString &link) void SnapmaticEditor::on_labCrew_linkActivated(const QString &link)
{ {
if (link == "g5e://editcrew") if (link == "g5e://editcrew") {
{
bool ok; bool ok;
int indexNum = 0; int indexNum = 0;
QStringList itemList; QStringList itemList;
QStringList crewList = crewDB->getCrews(); QStringList crewList = crewDB->getCrews();
if (!crewList.contains(QLatin1String("0"))) if (!crewList.contains(QLatin1String("0"))) {
{
crewList += QLatin1String("0"); crewList += QLatin1String("0");
} }
crewList.sort(); crewList.sort();
for (QString crew : crewList) for (const QString &crew : crewList) {
{
itemList += QString("%1 (%2)").arg(crew, returnCrewName(crew.toInt())); itemList += QString("%1 (%2)").arg(crew, returnCrewName(crew.toInt()));
} }
if (crewList.contains(QString::number(crewID))) if (crewList.contains(QString::number(crewID))) {
{
indexNum = crewList.indexOf(QString::number(crewID)); indexNum = crewList.indexOf(QString::number(crewID));
} }
QString newCrew = QInputDialog::getItem(this, tr("Snapmatic Crew"), tr("New Snapmatic crew:"), itemList, indexNum, true, &ok, windowFlags()); QString newCrew = QInputDialog::getItem(this, tr("Snapmatic Crew"), tr("New Snapmatic crew:"), itemList, indexNum, true, &ok, windowFlags());
if (ok && !newCrew.isEmpty()) if (ok && !newCrew.isEmpty()) {
{ if (newCrew.contains(" "))
if (newCrew.contains(" ")) newCrew = newCrew.split(" ").at(0); newCrew = newCrew.split(" ").at(0);
if (newCrew.length() > 10) return; if (newCrew.length() > 10)
for (QChar crewChar : newCrew) return;
{ for (const QChar &crewChar : newCrew) {
if (!crewChar.isNumber()) if (!crewChar.isNumber()) {
{
return; return;
} }
} }
if (!crewList.contains(newCrew)) if (!crewList.contains(newCrew)) {
{
crewDB->addCrew(crewID); crewDB->addCrew(crewID);
} }
crewID = newCrew.toInt(); crewID = newCrew.toInt();

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5spv Grand Theft Auto Snapmatic Picture Viewer * gta5spv Grand Theft Auto Snapmatic Picture Viewer
* Copyright (C) 2016-2020 Syping * Copyright (C) 2016-2021 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
@ -84,8 +84,7 @@ bool SnapmaticPicture::preloadFile()
isFormatSwitch = false; isFormatSwitch = false;
if (!picFile->open(QFile::ReadOnly)) if (!picFile->open(QFile::ReadOnly)) {
{
lastStep = "1;/1,OpenFile," % convertDrawStringForLog(picFilePath); lastStep = "1;/1,OpenFile," % convertDrawStringForLog(picFilePath);
delete picFile; delete picFile;
return false; return false;
@ -98,8 +97,7 @@ bool SnapmaticPicture::preloadFile()
if (!ok) if (!ok)
return false; return false;
if (picFilePath.right(4) != QLatin1String(".g5e")) if (picFilePath.right(4) != QLatin1String(".g5e")) {
{
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX) if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX)
isFormatSwitch = true; isFormatSwitch = true;
} }
@ -122,9 +120,9 @@ bool SnapmaticPicture::readingPicture(bool cacheEnabled_)
if (!ok) if (!ok)
return false; return false;
if (cacheEnabled) picOk = cachePicture.loadFromData(p_ragePhoto.photoData(), "JPEG"); if (cacheEnabled)
if (!cacheEnabled) picOk = cachePicture.loadFromData(p_ragePhoto.photoData(), "JPEG");
{ if (!cacheEnabled) {
QImage tempPicture; QImage tempPicture;
picOk = tempPicture.loadFromData(p_ragePhoto.photoData(), "JPEG"); picOk = tempPicture.loadFromData(p_ragePhoto.photoData(), "JPEG");
} }
@ -154,19 +152,18 @@ void SnapmaticPicture::updateStrings()
pictureStr = tr("PHOTO - %1").arg(localProperties.createdDateTime.toString("MM/dd/yy HH:mm:ss")); pictureStr = tr("PHOTO - %1").arg(localProperties.createdDateTime.toString("MM/dd/yy HH:mm:ss"));
sortStr = localProperties.createdDateTime.toString("yyMMddHHmmss") % QString::number(localProperties.uid); sortStr = localProperties.createdDateTime.toString("yyMMddHHmmss") % QString::number(localProperties.uid);
QString exportStr = localProperties.createdDateTime.toString("yyyyMMdd") % "-" % QString::number(localProperties.uid); QString exportStr = localProperties.createdDateTime.toString("yyyyMMdd") % "-" % QString::number(localProperties.uid);
if (getSnapmaticFormat() == SnapmaticFormat::G5E_Format) picFileName = "PGTA5" % QString::number(localProperties.uid); if (getSnapmaticFormat() == SnapmaticFormat::G5E_Format)
picFileName = "PGTA5" % QString::number(localProperties.uid);
picExportFileName = exportStr % "_" % cmpPicTitl; picExportFileName = exportStr % "_" % cmpPicTitl;
} }
bool SnapmaticPicture::readingPictureFromFile(const QString &fileName, bool cacheEnabled_) bool SnapmaticPicture::readingPictureFromFile(const QString &fileName, bool cacheEnabled_)
{ {
if (!fileName.isEmpty()) if (!fileName.isEmpty()) {
{
picFilePath = fileName; picFilePath = fileName;
return readingPicture(cacheEnabled_); return readingPicture(cacheEnabled_);
} }
else else {
{
return false; return false;
} }
} }
@ -244,12 +241,10 @@ QString SnapmaticPicture::getExportPictureFileName()
QString SnapmaticPicture::getOriginalPictureFileName() QString SnapmaticPicture::getOriginalPictureFileName()
{ {
QString newPicFileName = picFileName; QString newPicFileName = picFileName;
if (picFileName.right(4) == ".bak") if (picFileName.right(4) == ".bak") {
{
newPicFileName = QString(picFileName).remove(picFileName.length() - 4, 4); newPicFileName = QString(picFileName).remove(picFileName.length() - 4, 4);
} }
if (picFileName.right(7) == ".hidden") if (picFileName.right(7) == ".hidden") {
{
newPicFileName = QString(picFileName).remove(picFileName.length() - 7, 7); newPicFileName = QString(picFileName).remove(picFileName.length() - 7, 7);
} }
return newPicFileName; return newPicFileName;
@ -258,12 +253,10 @@ QString SnapmaticPicture::getOriginalPictureFileName()
QString SnapmaticPicture::getOriginalPictureFilePath() QString SnapmaticPicture::getOriginalPictureFilePath()
{ {
QString newPicFilePath = picFilePath; QString newPicFilePath = picFilePath;
if (picFilePath.right(4) == ".bak") if (picFilePath.right(4) == ".bak") {
{
newPicFilePath = QString(picFilePath).remove(picFilePath.length() - 4, 4); newPicFilePath = QString(picFilePath).remove(picFilePath.length() - 4, 4);
} }
if (picFilePath.right(7) == ".hidden") if (picFilePath.right(7) == ".hidden") {
{
newPicFilePath = QString(picFilePath).remove(picFilePath.length() - 7, 7); newPicFilePath = QString(picFilePath).remove(picFilePath.length() - 7, 7);
} }
return newPicFilePath; return newPicFilePath;
@ -296,79 +289,65 @@ QString SnapmaticPicture::getPictureStr()
QString SnapmaticPicture::getLastStep(bool readable) QString SnapmaticPicture::getLastStep(bool readable)
{ {
if (readable) if (readable) {
{
QStringList lastStepList = lastStep.split(";/"); QStringList lastStepList = lastStep.split(";/");
if (lastStepList.length() < 2) { return lastStep; } if (lastStepList.length() < 2)
return lastStep;
bool intOk; bool intOk;
QStringList descStepList = lastStepList.at(1).split(","); QStringList descStepList = lastStepList.at(1).split(",");
if (descStepList.length() < 1) { return lastStep; } if (descStepList.length() < 1)
return lastStep;
int argsCount = descStepList.at(0).toInt(&intOk); int argsCount = descStepList.at(0).toInt(&intOk);
if (!intOk) { return lastStep; } if (!intOk) { return lastStep; }
if (argsCount == 1) if (argsCount == 1) {
{
QString currentAction = descStepList.at(1); QString currentAction = descStepList.at(1);
QString actionFile = descStepList.at(2); QString actionFile = descStepList.at(2);
if (currentAction == "OpenFile") if (currentAction == "OpenFile") {
{
return tr("open file %1").arg(actionFile); return tr("open file %1").arg(actionFile);
} }
} }
else if (argsCount == 3 || argsCount == 4) else if (argsCount == 3 || argsCount == 4) {
{
QString currentAction = descStepList.at(1); QString currentAction = descStepList.at(1);
QString actionFile = descStepList.at(2); QString actionFile = descStepList.at(2);
QString actionError = descStepList.at(4); QString actionError = descStepList.at(4);
QString actionError2; QString actionError2;
if (argsCount == 4) { actionError2 = descStepList.at(5); } if (argsCount == 4) { actionError2 = descStepList.at(5); }
if (currentAction == "ReadingFile") if (currentAction == "ReadingFile") {
{
QString readableError = actionError; QString readableError = actionError;
if (actionError == "NOHEADER") if (actionError == "NOHEADER") {
{
readableError = tr("header not exists"); readableError = tr("header not exists");
} }
else if (actionError == "MALFORMEDHEADER") else if (actionError == "MALFORMEDHEADER") {
{
readableError = tr("header is malformed"); readableError = tr("header is malformed");
} }
else if (actionError == "NOJPEG" || actionError == "NOPIC") else if (actionError == "NOJPEG" || actionError == "NOPIC") {
{
readableError = tr("picture not exists (%1)").arg(actionError); readableError = tr("picture not exists (%1)").arg(actionError);
} }
else if (actionError == "NOJSON" || actionError == "CTJSON") else if (actionError == "NOJSON" || actionError == "CTJSON") {
{
readableError = tr("JSON not exists (%1)").arg(actionError); readableError = tr("JSON not exists (%1)").arg(actionError);
} }
else if (actionError == "NOTITL" || actionError == "CTTITL") else if (actionError == "NOTITL" || actionError == "CTTITL") {
{
readableError = tr("title not exists (%1)").arg(actionError); readableError = tr("title not exists (%1)").arg(actionError);
} }
else if (actionError == "NODESC" || actionError == "CTDESC") else if (actionError == "NODESC" || actionError == "CTDESC") {
{
readableError = tr("description not exists (%1)").arg(actionError); readableError = tr("description not exists (%1)").arg(actionError);
} }
else if (actionError == "JSONINCOMPLETE" && actionError2 == "JSONERROR") else if (actionError == "JSONINCOMPLETE" && actionError2 == "JSONERROR") {
{
readableError = tr("JSON is incomplete and malformed"); readableError = tr("JSON is incomplete and malformed");
} }
else if (actionError == "JSONINCOMPLETE") else if (actionError == "JSONINCOMPLETE") {
{
readableError = tr("JSON is incomplete"); readableError = tr("JSON is incomplete");
} }
else if (actionError == "JSONERROR") else if (actionError == "JSONERROR") {
{
readableError = tr("JSON is malformed"); readableError = tr("JSON is malformed");
} }
return tr("reading file %1 because of %2", "Example for %2: JSON is malformed error").arg(actionFile, readableError); return tr("reading file %1 because of %2", "Example for %2: JSON is malformed error").arg(actionFile, readableError);
} }
else else {
{
return lastStep; return lastStep;
} }
} }
else else {
{
return lastStep; return lastStep;
} }
} }
@ -437,25 +416,20 @@ void SnapmaticPicture::parseJsonContent()
bool jsonIncomplete = false; bool jsonIncomplete = false;
bool jsonError = false; bool jsonError = false;
if (jsonObject.contains("loc")) if (jsonObject.contains("loc")) {
{ if (jsonObject["loc"].isObject()) {
if (jsonObject["loc"].isObject())
{
QJsonObject locObject = jsonObject["loc"].toObject(); QJsonObject locObject = jsonObject["loc"].toObject();
if (locObject.contains("x")) if (locObject.contains("x")) {
{
if (locObject["x"].isDouble()) { localProperties.location.x = locObject["x"].toDouble(); } if (locObject["x"].isDouble()) { localProperties.location.x = locObject["x"].toDouble(); }
else { jsonError = true; } else { jsonError = true; }
} }
else { jsonIncomplete = true; } else { jsonIncomplete = true; }
if (locObject.contains("y")) if (locObject.contains("y")) {
{
if (locObject["y"].isDouble()) { localProperties.location.y = locObject["y"].toDouble(); } if (locObject["y"].isDouble()) { localProperties.location.y = locObject["y"].toDouble(); }
else { jsonError = true; } else { jsonError = true; }
} }
else { jsonIncomplete = true; } else { jsonIncomplete = true; }
if (locObject.contains("z")) if (locObject.contains("z")) {
{
if (locObject["z"].isDouble()) { localProperties.location.z = locObject["z"].toDouble(); } if (locObject["z"].isDouble()) { localProperties.location.z = locObject["z"].toDouble(); }
else { jsonError = true; } else { jsonError = true; }
} }
@ -464,35 +438,30 @@ void SnapmaticPicture::parseJsonContent()
else { jsonError = true; } else { jsonError = true; }
} }
else { jsonIncomplete = true; } else { jsonIncomplete = true; }
if (jsonObject.contains("uid")) if (jsonObject.contains("uid")) {
{
bool uidOk; bool uidOk;
localProperties.uid = jsonMap["uid"].toInt(&uidOk); localProperties.uid = jsonMap["uid"].toInt(&uidOk);
if (!uidOk) { jsonError = true; } if (!uidOk) { jsonError = true; }
} }
else { jsonIncomplete = true; } else { jsonIncomplete = true; }
if (jsonObject.contains("area")) if (jsonObject.contains("area")) {
{
if (jsonObject["area"].isString()) { localProperties.location.area = jsonObject["area"].toString(); } if (jsonObject["area"].isString()) { localProperties.location.area = jsonObject["area"].toString(); }
else { jsonError = true; } else { jsonError = true; }
} }
else { jsonIncomplete = true; } else { jsonIncomplete = true; }
if (jsonObject.contains("crewid")) if (jsonObject.contains("crewid")) {
{
bool crewIDOk; bool crewIDOk;
localProperties.crewID = jsonMap["crewid"].toInt(&crewIDOk); localProperties.crewID = jsonMap["crewid"].toInt(&crewIDOk);
if (!crewIDOk) { jsonError = true; } if (!crewIDOk) { jsonError = true; }
} }
else { jsonIncomplete = true; } else { jsonIncomplete = true; }
if (jsonObject.contains("street")) if (jsonObject.contains("street")) {
{
bool streetIDOk; bool streetIDOk;
localProperties.streetID = jsonMap["street"].toInt(&streetIDOk); localProperties.streetID = jsonMap["street"].toInt(&streetIDOk);
if (!streetIDOk) { jsonError = true; } if (!streetIDOk) { jsonError = true; }
} }
else { jsonIncomplete = true; } else { jsonIncomplete = true; }
if (jsonObject.contains("creat")) if (jsonObject.contains("creat")) {
{
bool timestampOk; bool timestampOk;
QDateTime createdTimestamp; QDateTime createdTimestamp;
localProperties.createdTimestamp = jsonMap["creat"].toUInt(&timestampOk); localProperties.createdTimestamp = jsonMap["creat"].toUInt(&timestampOk);
@ -505,59 +474,53 @@ void SnapmaticPicture::parseJsonContent()
if (!timestampOk) { jsonError = true; } if (!timestampOk) { jsonError = true; }
} }
else { jsonIncomplete = true; } else { jsonIncomplete = true; }
if (jsonObject.contains("plyrs")) if (jsonObject.contains("plyrs")) {
{
if (jsonObject["plyrs"].isArray()) { localProperties.playersList = jsonMap["plyrs"].toStringList(); } if (jsonObject["plyrs"].isArray()) { localProperties.playersList = jsonMap["plyrs"].toStringList(); }
else { jsonError = true; } else { jsonError = true; }
} }
// else { jsonIncomplete = true; } // 2016 Snapmatic pictures left out plyrs when none are captured, so don't force exists on that one // else { jsonIncomplete = true; } // 2016 Snapmatic pictures left out plyrs when none are captured, so don't force exists on that one
if (jsonObject.contains("meme")) if (jsonObject.contains("meme")) {
{
if (jsonObject["meme"].isBool()) { localProperties.isMeme = jsonObject["meme"].toBool(); } if (jsonObject["meme"].isBool()) { localProperties.isMeme = jsonObject["meme"].toBool(); }
else { jsonError = true; } else { jsonError = true; }
} }
else { jsonIncomplete = true; } else { jsonIncomplete = true; }
if (jsonObject.contains("mug")) if (jsonObject.contains("mug")) {
{
if (jsonObject["mug"].isBool()) { localProperties.isMug = jsonObject["mug"].toBool(); } if (jsonObject["mug"].isBool()) { localProperties.isMug = jsonObject["mug"].toBool(); }
else { jsonError = true; } else { jsonError = true; }
} }
else { jsonIncomplete = true; } else { jsonIncomplete = true; }
if (jsonObject.contains("slf")) if (jsonObject.contains("slf")) {
{
if (jsonObject["slf"].isBool()) { localProperties.isSelfie = jsonObject["slf"].toBool(); } if (jsonObject["slf"].isBool()) { localProperties.isSelfie = jsonObject["slf"].toBool(); }
else { jsonError = true; } else { jsonError = true; }
} }
else { jsonIncomplete = true; } else { jsonIncomplete = true; }
if (jsonObject.contains("drctr")) if (jsonObject.contains("drctr")) {
{
if (jsonObject["drctr"].isBool()) { localProperties.isFromDirector = jsonObject["drctr"].toBool(); } if (jsonObject["drctr"].isBool()) { localProperties.isFromDirector = jsonObject["drctr"].toBool(); }
else { jsonError = true; } else { jsonError = true; }
} }
else { jsonIncomplete = true; } else { jsonIncomplete = true; }
if (jsonObject.contains("rsedtr")) if (jsonObject.contains("rsedtr")) {
{
if (jsonObject["rsedtr"].isBool()) { localProperties.isFromRSEditor = jsonObject["rsedtr"].toBool(); } if (jsonObject["rsedtr"].isBool()) { localProperties.isFromRSEditor = jsonObject["rsedtr"].toBool(); }
else { jsonError = true; } else { jsonError = true; }
} }
// else { jsonIncomplete = true; } // Game release Snapmatic pictures prior May 2015 left out rsedtr, so don't force exists on that one else { localProperties.isFromRSEditor = false; }
if (jsonObject.contains("onislandx")) {
if (jsonObject["onislandx"].isBool()) { localProperties.location.isCayoPerico = jsonObject["onislandx"].toBool(); }
else { jsonError = true; }
}
else { localProperties.location.isCayoPerico = false; }
if (!jsonIncomplete && !jsonError) if (!jsonIncomplete && !jsonError) {
{
jsonOk = true; jsonOk = true;
} }
else else {
{ if (jsonIncomplete && jsonError) {
if (jsonIncomplete && jsonError)
{
lastStep = "2;/4,ReadingFile," % convertDrawStringForLog(picFilePath) % ",3,JSONINCOMPLETE,JSONERROR"; lastStep = "2;/4,ReadingFile," % convertDrawStringForLog(picFilePath) % ",3,JSONINCOMPLETE,JSONERROR";
} }
else if (jsonIncomplete) else if (jsonIncomplete) {
{
lastStep = "2;/3,ReadingFile," % convertDrawStringForLog(picFilePath) % ",3,JSONINCOMPLETE"; lastStep = "2;/3,ReadingFile," % convertDrawStringForLog(picFilePath) % ",3,JSONINCOMPLETE";
} }
else if (jsonError) else if (jsonError) {
{
lastStep = "2;/3,ReadingFile," % convertDrawStringForLog(picFilePath) % ",3,JSONERROR"; lastStep = "2;/3,ReadingFile," % convertDrawStringForLog(picFilePath) % ",3,JSONERROR";
} }
jsonOk = false; jsonOk = false;
@ -585,10 +548,10 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties properties)
jsonObject["slf"] = properties.isSelfie; jsonObject["slf"] = properties.isSelfie;
jsonObject["drctr"] = properties.isFromDirector; jsonObject["drctr"] = properties.isFromDirector;
jsonObject["rsedtr"] = properties.isFromRSEditor; jsonObject["rsedtr"] = properties.isFromRSEditor;
jsonObject["onislandx"] = properties.location.isCayoPerico;
QJsonDocument jsonDocument(jsonObject); QJsonDocument jsonDocument(jsonObject);
if (setJsonStr(QString::fromUtf8(jsonDocument.toJson(QJsonDocument::Compact)))) if (setJsonStr(QString::fromUtf8(jsonDocument.toJson(QJsonDocument::Compact)))) {
{
localProperties = properties; localProperties = properties;
return true; return true;
} }
@ -613,14 +576,11 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
{ {
// Keep current format when Auto_Format is used // Keep current format when Auto_Format is used
SnapmaticFormat format = format_; SnapmaticFormat format = format_;
if (format_ == SnapmaticFormat::Auto_Format) if (format_ == SnapmaticFormat::Auto_Format) {
{ if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX) {
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX)
{
format = SnapmaticFormat::G5E_Format; format = SnapmaticFormat::G5E_Format;
} }
else else {
{
format = SnapmaticFormat::PGTA_Format; format = SnapmaticFormat::PGTA_Format;
} }
} }
@ -631,10 +591,8 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
#else #else
QFile *picFile = new QFile(StandardPaths::tempLocation() % "/" % QFileInfo(fileName).fileName() % ".tmp"); QFile *picFile = new QFile(StandardPaths::tempLocation() % "/" % QFileInfo(fileName).fileName() % ".tmp");
#endif #endif
if (picFile->open(QIODevice::WriteOnly)) if (picFile->open(QIODevice::WriteOnly)) {
{ if (format == SnapmaticFormat::G5E_Format) {
if (format == SnapmaticFormat::G5E_Format)
{
p_ragePhoto.save(picFile, RagePhoto::PhotoFormat::G5EX); p_ragePhoto.save(picFile, RagePhoto::PhotoFormat::G5EX);
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
saveSuccess = picFile->commit(); saveSuccess = picFile->commit();
@ -644,8 +602,7 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
#endif #endif
delete picFile; delete picFile;
} }
else if (format == SnapmaticFormat::JPEG_Format) else if (format == SnapmaticFormat::JPEG_Format) {
{
picFile->write(p_ragePhoto.photoData()); picFile->write(p_ragePhoto.photoData());
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
saveSuccess = picFile->commit(); saveSuccess = picFile->commit();
@ -655,8 +612,7 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
#endif #endif
delete picFile; delete picFile;
} }
else else {
{
p_ragePhoto.save(picFile, RagePhoto::PhotoFormat::GTA5); p_ragePhoto.save(picFile, RagePhoto::PhotoFormat::GTA5);
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
saveSuccess = picFile->commit(); saveSuccess = picFile->commit();
@ -688,8 +644,7 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
#endif #endif
return saveSuccess; return saveSuccess;
} }
else else {
{
delete picFile; delete picFile;
return saveSuccess; return saveSuccess;
} }
@ -708,16 +663,13 @@ void SnapmaticPicture::setPicFilePath(const QString &picFilePath_)
bool SnapmaticPicture::deletePicFile() bool SnapmaticPicture::deletePicFile()
{ {
bool success = false; bool success = false;
if (!QFile::exists(picFilePath)) if (!QFile::exists(picFilePath)) {
{
success = true; success = true;
} }
else if (QFile::remove(picFilePath)) else if (QFile::remove(picFilePath)) {
{
success = true; success = true;
} }
if (isHidden()) if (isHidden()) {
{
const QString picBakPath = QString(picFilePath).remove(picFilePath.length() - 7, 7) % ".bak"; const QString picBakPath = QString(picFilePath).remove(picFilePath.length() - 7, 7) % ".bak";
if (QFile::exists(picBakPath)) QFile::remove(picBakPath); if (QFile::exists(picBakPath)) QFile::remove(picBakPath);
} }
@ -732,8 +684,7 @@ bool SnapmaticPicture::deletePicFile()
bool SnapmaticPicture::isHidden() bool SnapmaticPicture::isHidden()
{ {
if (picFilePath.right(7) == QLatin1String(".hidden")) if (picFilePath.right(7) == QLatin1String(".hidden")) {
{
return true; return true;
} }
return false; return false;
@ -741,8 +692,7 @@ bool SnapmaticPicture::isHidden()
bool SnapmaticPicture::isVisible() bool SnapmaticPicture::isVisible()
{ {
if (picFilePath.right(7) == QLatin1String(".hidden")) if (picFilePath.right(7) == QLatin1String(".hidden")) {
{
return false; return false;
} }
return true; return true;
@ -750,15 +700,12 @@ bool SnapmaticPicture::isVisible()
bool SnapmaticPicture::setPictureHidden() bool SnapmaticPicture::setPictureHidden()
{ {
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX) if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX) {
{
return false; return false;
} }
if (!isHidden()) if (!isHidden()) {
{
QString newPicFilePath = QString(picFilePath % ".hidden"); QString newPicFilePath = QString(picFilePath % ".hidden");
if (QFile::rename(picFilePath, newPicFilePath)) if (QFile::rename(picFilePath, newPicFilePath)) {
{
picFilePath = newPicFilePath; picFilePath = newPicFilePath;
return true; return true;
} }
@ -769,15 +716,12 @@ bool SnapmaticPicture::setPictureHidden()
bool SnapmaticPicture::setPictureVisible() bool SnapmaticPicture::setPictureVisible()
{ {
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX) if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX) {
{
return false; return false;
} }
if (isHidden()) if (isHidden()) {
{
QString newPicFilePath = QString(picFilePath).remove(picFilePath.length() - 7, 7); QString newPicFilePath = QString(picFilePath).remove(picFilePath.length() - 7, 7);
if (QFile::rename(picFilePath, newPicFilePath)) if (QFile::rename(picFilePath, newPicFilePath)) {
{
picFilePath = newPicFilePath; picFilePath = newPicFilePath;
return true; return true;
} }
@ -797,8 +741,7 @@ QSize SnapmaticPicture::getSnapmaticResolution()
SnapmaticFormat SnapmaticPicture::getSnapmaticFormat() SnapmaticFormat SnapmaticPicture::getSnapmaticFormat()
{ {
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX) if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX) {
{
return SnapmaticFormat::G5E_Format; return SnapmaticFormat::G5E_Format;
} }
return SnapmaticFormat::PGTA_Format; return SnapmaticFormat::PGTA_Format;
@ -806,13 +749,11 @@ SnapmaticFormat SnapmaticPicture::getSnapmaticFormat()
void SnapmaticPicture::setSnapmaticFormat(SnapmaticFormat format) void SnapmaticPicture::setSnapmaticFormat(SnapmaticFormat format)
{ {
if (format == SnapmaticFormat::G5E_Format) if (format == SnapmaticFormat::G5E_Format) {
{
p_ragePhoto.setPhotoFormat(RagePhoto::PhotoFormat::G5EX); p_ragePhoto.setPhotoFormat(RagePhoto::PhotoFormat::G5EX);
return; return;
} }
else if (format == SnapmaticFormat::PGTA_Format) else if (format == SnapmaticFormat::PGTA_Format) {
{
p_ragePhoto.setPhotoFormat(RagePhoto::PhotoFormat::GTA5); p_ragePhoto.setPhotoFormat(RagePhoto::PhotoFormat::GTA5);
return; return;
} }
@ -829,10 +770,8 @@ bool SnapmaticPicture::isFormatSwitched()
bool SnapmaticPicture::verifyTitle(const QString &title) bool SnapmaticPicture::verifyTitle(const QString &title)
{ {
// VERIFY TITLE FOR BE A VALID SNAPMATIC TITLE // VERIFY TITLE FOR BE A VALID SNAPMATIC TITLE
if (title.length() <= 39 && title.length() > 0) if (title.length() <= 39 && title.length() > 0) {
{ for (const QChar &titleChar : title) {
for (const QChar &titleChar : title)
{
if (!verifyTitleChar(titleChar)) return false; if (!verifyTitleChar(titleChar)) return false;
} }
return true; return true;
@ -843,8 +782,7 @@ bool SnapmaticPicture::verifyTitle(const QString &title)
bool SnapmaticPicture::verifyTitleChar(const QChar &titleChar) bool SnapmaticPicture::verifyTitleChar(const QChar &titleChar)
{ {
// VERIFY CHAR FOR BE A VALID SNAPMATIC CHARACTER // VERIFY CHAR FOR BE A VALID SNAPMATIC CHARACTER
if (titleChar.isLetterOrNumber() || titleChar.isPrint()) if (titleChar.isLetterOrNumber() || titleChar.isPrint()) {
{
if (titleChar == '<' || titleChar == '>' || titleChar == '\\') return false; if (titleChar == '<' || titleChar == '>' || titleChar == '\\') return false;
return true; return true;
} }

View File

@ -35,6 +35,7 @@ struct SnapmaticProperties {
double x; double x;
double y; double y;
double z; double z;
bool isCayoPerico;
}; };
int uid; int uid;
int crewID; int crewID;

View File

@ -85,7 +85,8 @@ void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture)
QPixmap renderPixmap(renderResolution); QPixmap renderPixmap(renderResolution);
renderPixmap.fill(Qt::transparent); renderPixmap.fill(Qt::transparent);
QPainter renderPainter(&renderPixmap); QPainter renderPainter(&renderPixmap);
const QImage renderImage = picture->getImage().scaled(renderResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation); const QImage originalImage = picture->getImage();
const QImage renderImage = originalImage.scaled(renderResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation); // Stack smash
if (renderImage.width() < renderResolution.width()) { if (renderImage.width() < renderResolution.width()) {
renderPainter.drawImage((renderResolution.width() - renderImage.width()) / 2, 0, renderImage, Qt::AutoColor); renderPainter.drawImage((renderResolution.width() - renderImage.width()) / 2, 0, renderImage, Qt::AutoColor);
} }
@ -115,8 +116,7 @@ void SnapmaticWidget::snapmaticUpdated()
void SnapmaticWidget::customSignal(QString signal) void SnapmaticWidget::customSignal(QString signal)
{ {
if (signal == "PictureUpdated") if (signal == "PictureUpdated") {
{
QPixmap SnapmaticPixmap = QPixmap::fromImage(smpic->getImage().scaled(ui->labPicture->width(), ui->labPicture->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::AutoColor); QPixmap SnapmaticPixmap = QPixmap::fromImage(smpic->getImage().scaled(ui->labPicture->width(), ui->labPicture->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::AutoColor);
ui->labPicture->setPixmap(SnapmaticPixmap); ui->labPicture->setPixmap(SnapmaticPixmap);
} }
@ -146,7 +146,8 @@ void SnapmaticWidget::on_cmdView_clicked()
QObject::connect(picDialog, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested())); QObject::connect(picDialog, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested()));
// add previous next buttons // add previous next buttons
if (navigationBar) picDialog->addPreviousNextButtons(); if (navigationBar)
picDialog->addPreviousNextButtons();
// show picture dialog // show picture dialog
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
@ -175,23 +176,21 @@ void SnapmaticWidget::on_cmdExport_clicked()
void SnapmaticWidget::on_cmdDelete_clicked() void SnapmaticWidget::on_cmdDelete_clicked()
{ {
if (deletePicture()) emit pictureDeleted(); if (deletePicture())
emit pictureDeleted();
} }
bool SnapmaticWidget::deletePicture() bool SnapmaticWidget::deletePicture()
{ {
int uchoice = QMessageBox::question(this, tr("Delete picture"), tr("Are you sure to delete %1 from your Snapmatic pictures?").arg("\""+smpic->getPictureTitle()+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); int uchoice = QMessageBox::question(this, tr("Delete picture"), tr("Are you sure to delete %1 from your Snapmatic pictures?").arg("\""+smpic->getPictureTitle()+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (uchoice == QMessageBox::Yes) if (uchoice == QMessageBox::Yes) {
{ if (smpic->deletePictureFile()) {
if (smpic->deletePictureFile())
{
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
telemetrySettings.beginGroup("Telemetry"); telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool(); bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup(); telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush()) if (pushUsageData && Telemetry->canPush()) {
{
QJsonDocument jsonDocument; QJsonDocument jsonDocument;
QJsonObject jsonObject; QJsonObject jsonObject;
jsonObject["Type"] = "DeleteSuccess"; jsonObject["Type"] = "DeleteSuccess";
@ -208,8 +207,7 @@ bool SnapmaticWidget::deletePicture()
#endif #endif
return true; return true;
} }
else else {
{
QMessageBox::warning(this, tr("Delete picture"), tr("Failed at deleting %1 from your Snapmatic pictures").arg("\""+smpic->getPictureTitle()+"\"")); QMessageBox::warning(this, tr("Delete picture"), tr("Failed at deleting %1 from your Snapmatic pictures").arg("\""+smpic->getPictureTitle()+"\""));
} }
} }
@ -224,29 +222,22 @@ void SnapmaticWidget::mousePressEvent(QMouseEvent *ev)
void SnapmaticWidget::mouseReleaseEvent(QMouseEvent *ev) void SnapmaticWidget::mouseReleaseEvent(QMouseEvent *ev)
{ {
ProfileWidget::mouseReleaseEvent(ev); ProfileWidget::mouseReleaseEvent(ev);
if (ui->cbSelected->isVisible()) if (ui->cbSelected->isVisible()) {
{ if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) {
if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked()); ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
} }
} }
else else {
{
const int contentMode = getContentMode(); const int contentMode = getContentMode();
if ((contentMode == 0 || contentMode == 10 || contentMode == 20) && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) if ((contentMode == 0 || contentMode == 10 || contentMode == 20) && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) {
{ if (ev->modifiers().testFlag(Qt::ShiftModifier)) {
if (ev->modifiers().testFlag(Qt::ShiftModifier))
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked()); ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
} }
else else {
{
on_cmdView_clicked(); on_cmdView_clicked();
} }
} }
else if (!ui->cbSelected->isVisible() && (contentMode == 1 || contentMode == 11 || contentMode == 21) && ev->button() == Qt::LeftButton && ev->modifiers().testFlag(Qt::ShiftModifier)) else if (!ui->cbSelected->isVisible() && (contentMode == 1 || contentMode == 11 || contentMode == 21) && ev->button() == Qt::LeftButton && ev->modifiers().testFlag(Qt::ShiftModifier)) {
{
ui->cbSelected->setChecked(!ui->cbSelected->isChecked()); ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
} }
} }
@ -257,8 +248,7 @@ void SnapmaticWidget::mouseDoubleClickEvent(QMouseEvent *ev)
ProfileWidget::mouseDoubleClickEvent(ev); ProfileWidget::mouseDoubleClickEvent(ev);
const int contentMode = getContentMode(); const int contentMode = getContentMode();
if (!ui->cbSelected->isVisible() && (contentMode == 1 || contentMode == 11 || contentMode == 21) && ev->button() == Qt::LeftButton) if (!ui->cbSelected->isVisible() && (contentMode == 1 || contentMode == 11 || contentMode == 21) && ev->button() == Qt::LeftButton) {
{
on_cmdView_clicked(); on_cmdView_clicked();
} }
} }
@ -290,32 +280,27 @@ void SnapmaticWidget::dialogPreviousPictureRequested()
void SnapmaticWidget::on_cbSelected_stateChanged(int arg1) void SnapmaticWidget::on_cbSelected_stateChanged(int arg1)
{ {
if (arg1 == Qt::Checked) if (arg1 == Qt::Checked) {
{
emit widgetSelected(); emit widgetSelected();
} }
else if (arg1 == Qt::Unchecked) else if (arg1 == Qt::Unchecked) {
{
emit widgetDeselected(); emit widgetDeselected();
} }
} }
void SnapmaticWidget::adjustTextColor() void SnapmaticWidget::adjustTextColor()
{ {
if (isHidden()) if (isHidden()) {
{
ui->labPicStr->setStyleSheet(QString("QLabel{color: rgb(%1, %2, %3);}").arg(QString::number(highlightHiddenColor.red()), QString::number(highlightHiddenColor.green()), QString::number(highlightHiddenColor.blue()))); ui->labPicStr->setStyleSheet(QString("QLabel{color: rgb(%1, %2, %3);}").arg(QString::number(highlightHiddenColor.red()), QString::number(highlightHiddenColor.green()), QString::number(highlightHiddenColor.blue())));
} }
else else {
{
ui->labPicStr->setStyleSheet(""); ui->labPicStr->setStyleSheet("");
} }
} }
bool SnapmaticWidget::makePictureHidden() bool SnapmaticWidget::makePictureHidden()
{ {
if (smpic->setPictureHidden()) if (smpic->setPictureHidden()) {
{
adjustTextColor(); adjustTextColor();
return true; return true;
} }
@ -324,8 +309,7 @@ bool SnapmaticWidget::makePictureHidden()
bool SnapmaticWidget::makePictureVisible() bool SnapmaticWidget::makePictureVisible()
{ {
if (smpic->setPictureVisible()) if (smpic->setPictureVisible()) {
{
adjustTextColor(); adjustTextColor();
return true; return true;
} }
@ -335,17 +319,13 @@ bool SnapmaticWidget::makePictureVisible()
void SnapmaticWidget::makePictureHiddenSlot() void SnapmaticWidget::makePictureHiddenSlot()
{ {
if (!makePictureHidden()) if (!makePictureHidden())
{
QMessageBox::warning(this, QApplication::translate("UserInterface", "Hide In-game"), QApplication::translate("SnapmaticWidget", "Failed to hide %1 In-game from your Snapmatic pictures").arg("\""+smpic->getPictureTitle()+"\"")); QMessageBox::warning(this, QApplication::translate("UserInterface", "Hide In-game"), QApplication::translate("SnapmaticWidget", "Failed to hide %1 In-game from your Snapmatic pictures").arg("\""+smpic->getPictureTitle()+"\""));
}
} }
void SnapmaticWidget::makePictureVisibleSlot() void SnapmaticWidget::makePictureVisibleSlot()
{ {
if (!makePictureVisible()) if (!makePictureVisible())
{
QMessageBox::warning(this, QApplication::translate("UserInterface", "Show In-game"), QApplication::translate("SnapmaticWidget", "Failed to show %1 In-game from your Snapmatic pictures").arg("\""+smpic->getPictureTitle()+"\"")); QMessageBox::warning(this, QApplication::translate("UserInterface", "Show In-game"), QApplication::translate("SnapmaticWidget", "Failed to show %1 In-game from your Snapmatic pictures").arg("\""+smpic->getPictureTitle()+"\""));
}
} }
void SnapmaticWidget::editSnapmaticProperties() void SnapmaticWidget::editSnapmaticProperties()
@ -375,21 +355,17 @@ void SnapmaticWidget::editSnapmaticImage()
importDialog->enableOverwriteMode(); importDialog->enableOverwriteMode();
importDialog->setModal(true); importDialog->setModal(true);
importDialog->exec(); importDialog->exec();
if (importDialog->isImportAgreed()) if (importDialog->isImportAgreed()) {
{
const QByteArray previousPicture = smpic->getPictureStream(); const QByteArray previousPicture = smpic->getPictureStream();
bool success = smpic->setImage(importDialog->image()); bool success = smpic->setImage(importDialog->image());
if (success) if (success) {
{
QString currentFilePath = smpic->getPictureFilePath(); QString currentFilePath = smpic->getPictureFilePath();
QString originalFilePath = smpic->getOriginalPictureFilePath(); QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak"; QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName)) if (!QFile::exists(backupFileName)) {
{
QFile::copy(currentFilePath, backupFileName); QFile::copy(currentFilePath, backupFileName);
} }
if (!smpic->exportPicture(currentFilePath)) if (!smpic->exportPicture(currentFilePath)) {
{
smpic->setPictureStream(previousPicture); smpic->setPictureStream(previousPicture);
QMessageBox::warning(this, QApplication::translate("ImageEditorDialog", "Snapmatic Image Editor"), QApplication::translate("ImageEditorDialog", "Patching of Snapmatic Image failed because of I/O Error")); QMessageBox::warning(this, QApplication::translate("ImageEditorDialog", "Snapmatic Image Editor"), QApplication::translate("ImageEditorDialog", "Patching of Snapmatic Image failed because of I/O Error"));
return; return;
@ -400,8 +376,7 @@ void SnapmaticWidget::editSnapmaticImage()
telemetrySettings.beginGroup("Telemetry"); telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool(); bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup(); telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush()) if (pushUsageData && Telemetry->canPush()) {
{
QJsonDocument jsonDocument; QJsonDocument jsonDocument;
QJsonObject jsonObject; QJsonObject jsonObject;
jsonObject["Type"] = "ImageEdited"; jsonObject["Type"] = "ImageEdited";
@ -417,8 +392,7 @@ void SnapmaticWidget::editSnapmaticImage()
} }
#endif #endif
} }
else else {
{
QMessageBox::warning(this, QApplication::translate("ImageEditorDialog", "Snapmatic Image Editor"), QApplication::translate("ImageEditorDialog", "Patching of Snapmatic Image failed because of Image Error")); QMessageBox::warning(this, QApplication::translate("ImageEditorDialog", "Snapmatic Image Editor"), QApplication::translate("ImageEditorDialog", "Patching of Snapmatic Image failed because of Image Error"));
return; return;
} }
@ -429,42 +403,38 @@ void SnapmaticWidget::editSnapmaticImage()
void SnapmaticWidget::openMapViewer() void SnapmaticWidget::openMapViewer()
{ {
SnapmaticPicture *picture = smpic; SnapmaticPicture *picture = smpic;
MapLocationDialog *mapLocDialog = new MapLocationDialog(picture->getSnapmaticProperties().location.x, picture->getSnapmaticProperties().location.y, this); SnapmaticProperties currentProperties = picture->getSnapmaticProperties();
MapLocationDialog *mapLocDialog = new MapLocationDialog(currentProperties.location.x, currentProperties.location.y, this);
mapLocDialog->setCayoPerico(currentProperties.location.isCayoPerico);
mapLocDialog->setModal(true); mapLocDialog->setModal(true);
mapLocDialog->show(); mapLocDialog->show();
mapLocDialog->exec(); mapLocDialog->exec();
if (mapLocDialog->propUpdated()) if (mapLocDialog->propUpdated()) {
{
// Update Snapmatic Properties // Update Snapmatic Properties
SnapmaticProperties localSpJson = picture->getSnapmaticProperties(); currentProperties.location.x = mapLocDialog->getXpos();
localSpJson.location.x = mapLocDialog->getXpos(); currentProperties.location.y = mapLocDialog->getYpos();
localSpJson.location.y = mapLocDialog->getYpos(); currentProperties.location.z = 0;
localSpJson.location.z = 0;
// Update Snapmatic Picture // Update Snapmatic Picture
QString currentFilePath = picture->getPictureFilePath(); QString currentFilePath = picture->getPictureFilePath();
QString originalFilePath = picture->getOriginalPictureFilePath(); QString originalFilePath = picture->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak"; QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName)) if (!QFile::exists(backupFileName)) {
{
QFile::copy(currentFilePath, backupFileName); QFile::copy(currentFilePath, backupFileName);
} }
SnapmaticProperties fallbackProperties = picture->getSnapmaticProperties(); SnapmaticProperties fallbackProperties = picture->getSnapmaticProperties();
picture->setSnapmaticProperties(localSpJson); picture->setSnapmaticProperties(currentProperties);
if (!picture->exportPicture(currentFilePath)) if (!picture->exportPicture(currentFilePath)) {
{
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of I/O Error")); QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of I/O Error"));
picture->setSnapmaticProperties(fallbackProperties); picture->setSnapmaticProperties(fallbackProperties);
} }
#ifdef GTA5SYNC_TELEMETRY #ifdef GTA5SYNC_TELEMETRY
else else {
{
QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
telemetrySettings.beginGroup("Telemetry"); telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool(); bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup(); telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush()) if (pushUsageData && Telemetry->canPush()) {
{
QJsonDocument jsonDocument; QJsonDocument jsonDocument;
QJsonObject jsonObject; QJsonObject jsonObject;
jsonObject["Type"] = "LocationEdited"; jsonObject["Type"] = "LocationEdited";

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 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
@ -23,11 +23,6 @@
#include <QDesktopServices> #include <QDesktopServices>
#endif #endif
StandardPaths::StandardPaths()
{
}
QString StandardPaths::applicationsLocation() QString StandardPaths::applicationsLocation()
{ {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 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 @@
class StandardPaths class StandardPaths
{ {
public: public:
StandardPaths();
static QString applicationsLocation(); static QString applicationsLocation();
static QString cacheLocation(); static QString cacheLocation();
static QString dataLocation(); static QString dataLocation();

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 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,7 +17,9 @@
*****************************************************************************/ *****************************************************************************/
#include "StringParser.h" #include "StringParser.h"
#include "config.h"
#include <QTextDocument> #include <QTextDocument>
#include <QApplication>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QByteArray> #include <QByteArray>
#include <QFileInfo> #include <QFileInfo>
@ -25,16 +27,6 @@
#include <QList> #include <QList>
#include <QDir> #include <QDir>
#ifdef GTA5SYNC_PROJECT
#include <QApplication>
#include "config.h"
#endif
StringParser::StringParser()
{
}
QString StringParser::escapeString(const QString &toEscape) QString StringParser::escapeString(const QString &toEscape)
{ {
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
@ -44,7 +36,6 @@ QString StringParser::escapeString(const QString &toEscape)
#endif #endif
} }
#ifdef GTA5SYNC_PROJECT
QString StringParser::convertBuildedString(const QString &buildedStr) QString StringParser::convertBuildedString(const QString &buildedStr)
{ {
QString outputStr = buildedStr; QString outputStr = buildedStr;
@ -61,4 +52,3 @@ QString StringParser::convertBuildedString(const QString &buildedStr)
outputStr.replace("SEPARATOR:", QDir::separator()); outputStr.replace("SEPARATOR:", QDir::separator());
return outputStr; return outputStr;
} }
#endif

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer * gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2016-2017 Syping * Copyright (C) 2016-2021 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
@ -25,11 +25,8 @@
class StringParser class StringParser
{ {
public: public:
StringParser();
static QString escapeString(const QString &toEscape); static QString escapeString(const QString &toEscape);
#ifdef GTA5SYNC_PROJECT
static QString convertBuildedString(const QString &buildedStr); static QString convertBuildedString(const QString &buildedStr);
#endif
}; };
#endif // STRINGPARSER_H #endif // STRINGPARSER_H

View File

@ -77,96 +77,79 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D
ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, appVersion)); ui->labVersion->setText(QString("%1 %2").arg(GTA5SYNC_APPSTR, appVersion));
// Set Icon for Close Button // Set Icon for Close Button
if (QIcon::hasThemeIcon("dialog-close")) if (QIcon::hasThemeIcon("dialog-close")) {
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close")); ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
} }
else if (QIcon::hasThemeIcon("gtk-close")) else if (QIcon::hasThemeIcon("gtk-close")) {
{
ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close")); ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close"));
} }
// Set Icon for Reload Button // Set Icon for Reload Button
if (QIcon::hasThemeIcon("view-refresh")) if (QIcon::hasThemeIcon("view-refresh")) {
{
ui->cmdReload->setIcon(QIcon::fromTheme("view-refresh")); ui->cmdReload->setIcon(QIcon::fromTheme("view-refresh"));
} }
else if (QIcon::hasThemeIcon("reload")) else if (QIcon::hasThemeIcon("reload")) {
{
ui->cmdReload->setIcon(QIcon::fromTheme("reload")); ui->cmdReload->setIcon(QIcon::fromTheme("reload"));
} }
// Set Icon for Choose GTA V Folder Menu Item // Set Icon for Choose GTA V Folder Menu Item
if (QIcon::hasThemeIcon("document-open-folder")) if (QIcon::hasThemeIcon("document-open-folder")) {
{
ui->actionSelect_GTA_Folder->setIcon(QIcon::fromTheme("document-open-folder")); ui->actionSelect_GTA_Folder->setIcon(QIcon::fromTheme("document-open-folder"));
} }
else if (QIcon::hasThemeIcon("gtk-directory")) else if (QIcon::hasThemeIcon("gtk-directory")) {
{
ui->actionSelect_GTA_Folder->setIcon(QIcon::fromTheme("gtk-directory")); ui->actionSelect_GTA_Folder->setIcon(QIcon::fromTheme("gtk-directory"));
} }
// Set Icon for Open File Menu Item // Set Icon for Open File Menu Item
if (QIcon::hasThemeIcon("document-open")) if (QIcon::hasThemeIcon("document-open")) {
{
ui->actionOpen_File->setIcon(QIcon::fromTheme("document-open")); ui->actionOpen_File->setIcon(QIcon::fromTheme("document-open"));
} }
// Set Icon for Close Profile Menu Item // Set Icon for Close Profile Menu Item
if (QIcon::hasThemeIcon("dialog-close")) if (QIcon::hasThemeIcon("dialog-close")) {
{
ui->actionSelect_profile->setIcon(QIcon::fromTheme("dialog-close")); ui->actionSelect_profile->setIcon(QIcon::fromTheme("dialog-close"));
} }
else if (QIcon::hasThemeIcon("gtk-close")) else if (QIcon::hasThemeIcon("gtk-close")) {
{
ui->actionSelect_profile->setIcon(QIcon::fromTheme("gtk-close")); ui->actionSelect_profile->setIcon(QIcon::fromTheme("gtk-close"));
} }
// Set Icon for Exit Menu Item // Set Icon for Exit Menu Item
if (QIcon::hasThemeIcon("application-exit")) if (QIcon::hasThemeIcon("application-exit")) {
{
#ifndef Q_OS_MACOS // Setting icon for exit/quit lead to a crash in Mac OS X #ifndef Q_OS_MACOS // Setting icon for exit/quit lead to a crash in Mac OS X
ui->actionExit->setIcon(QIcon::fromTheme("application-exit")); ui->actionExit->setIcon(QIcon::fromTheme("application-exit"));
#endif #endif
} }
// Set Icon for Preferences Menu Item // Set Icon for Preferences Menu Item
if (QIcon::hasThemeIcon("preferences-system")) if (QIcon::hasThemeIcon("preferences-system")) {
{
#ifndef Q_OS_MACOS // Setting icon for preferences/settings/options lead to a crash in Mac OS X #ifndef Q_OS_MACOS // Setting icon for preferences/settings/options lead to a crash in Mac OS X
ui->actionOptions->setIcon(QIcon::fromTheme("preferences-system")); ui->actionOptions->setIcon(QIcon::fromTheme("preferences-system"));
#endif #endif
} }
else if (QIcon::hasThemeIcon("configure")) else if (QIcon::hasThemeIcon("configure")) {
{
#ifndef Q_OS_MACOS // Setting icon for preferences/settings/options lead to a crash in Mac OS X #ifndef Q_OS_MACOS // Setting icon for preferences/settings/options lead to a crash in Mac OS X
ui->actionOptions->setIcon(QIcon::fromTheme("configure")); ui->actionOptions->setIcon(QIcon::fromTheme("configure"));
#endif #endif
} }
// Set Icon for Profile Import Menu Item // Set Icon for Profile Import Menu Item
if (QIcon::hasThemeIcon("document-import")) if (QIcon::hasThemeIcon("document-import")) {
{
ui->action_Import->setIcon(QIcon::fromTheme("document-import")); ui->action_Import->setIcon(QIcon::fromTheme("document-import"));
} }
else if (QIcon::hasThemeIcon("document-open")) else if (QIcon::hasThemeIcon("document-open")) {
{
ui->action_Import->setIcon(QIcon::fromTheme("document-open")); ui->action_Import->setIcon(QIcon::fromTheme("document-open"));
} }
// Set Icon for Profile Export Menu Item // Set Icon for Profile Export Menu Item
if (QIcon::hasThemeIcon("document-export")) if (QIcon::hasThemeIcon("document-export")) {
{
ui->actionExport_selected->setIcon(QIcon::fromTheme("document-export")); ui->actionExport_selected->setIcon(QIcon::fromTheme("document-export"));
} }
else if (QIcon::hasThemeIcon("document-save")) else if (QIcon::hasThemeIcon("document-save")) {
{
ui->actionExport_selected->setIcon(QIcon::fromTheme("document-save")); ui->actionExport_selected->setIcon(QIcon::fromTheme("document-save"));
} }
// Set Icon for Profile Remove Menu Item // Set Icon for Profile Remove Menu Item
if (QIcon::hasThemeIcon("remove")) if (QIcon::hasThemeIcon("remove")) {
{
ui->actionDelete_selected->setIcon(QIcon::fromTheme("remove")); ui->actionDelete_selected->setIcon(QIcon::fromTheme("remove"));
} }
@ -245,8 +228,7 @@ void UserInterface::setupDirEnv(bool showFolderDialog)
void UserInterface::setupProfileUi() void UserInterface::setupProfileUi()
{ {
qreal screenRatio = AppEnv::screenRatio(); qreal screenRatio = AppEnv::screenRatio();
if (GTAV_Profiles.isEmpty()) if (GTAV_Profiles.isEmpty()) {
{
QPushButton *changeDirBtn = new QPushButton(tr("Select &GTA V Folder..."), ui->swSelection); QPushButton *changeDirBtn = new QPushButton(tr("Select &GTA V Folder..."), ui->swSelection);
changeDirBtn->setObjectName("cmdChangeDir"); changeDirBtn->setObjectName("cmdChangeDir");
changeDirBtn->setMinimumSize(0, 40 * screenRatio); changeDirBtn->setMinimumSize(0, 40 * screenRatio);
@ -256,8 +238,7 @@ void UserInterface::setupProfileUi()
QObject::connect(changeDirBtn, SIGNAL(clicked(bool)), this, SLOT(changeFolder_clicked())); QObject::connect(changeDirBtn, SIGNAL(clicked(bool)), this, SLOT(changeFolder_clicked()));
} }
else for (QString GTAV_Profile : GTAV_Profiles) else for (const QString &GTAV_Profile : GTAV_Profiles) {
{
QPushButton *profileBtn = new QPushButton(GTAV_Profile, ui->swSelection); QPushButton *profileBtn = new QPushButton(GTAV_Profile, ui->swSelection);
profileBtn->setObjectName(GTAV_Profile); profileBtn->setObjectName(GTAV_Profile);
profileBtn->setMinimumSize(0, 40 * screenRatio); profileBtn->setMinimumSize(0, 40 * screenRatio);
@ -277,8 +258,7 @@ void UserInterface::changeFolder_clicked()
void UserInterface::on_cmdReload_clicked() void UserInterface::on_cmdReload_clicked()
{ {
for (QPushButton *profileBtn : profileBtns) for (QPushButton *profileBtn : profileBtns) {
{
ui->vlButtons->removeWidget(profileBtn); ui->vlButtons->removeWidget(profileBtn);
delete profileBtn; delete profileBtn;
} }
@ -341,11 +321,8 @@ void UserInterface::closeEvent(QCloseEvent *ev)
UserInterface::~UserInterface() UserInterface::~UserInterface()
{ {
if (profileOpen) if (profileOpen)
{
closeProfile_p(); closeProfile_p();
} for (QPushButton *profileBtn : profileBtns) {
for (QPushButton *profileBtn : profileBtns)
{
delete profileBtn; delete profileBtn;
} }
profileBtns.clear(); profileBtns.clear();
@ -392,33 +369,25 @@ void UserInterface::profileLoaded()
void UserInterface::on_actionSelect_all_triggered() void UserInterface::on_actionSelect_all_triggered()
{ {
if (profileOpen) if (profileOpen)
{
profileUI->selectAllWidgets(); profileUI->selectAllWidgets();
}
} }
void UserInterface::on_actionDeselect_all_triggered() void UserInterface::on_actionDeselect_all_triggered()
{ {
if (profileOpen) if (profileOpen)
{
profileUI->deselectAllWidgets(); profileUI->deselectAllWidgets();
}
} }
void UserInterface::on_actionExport_selected_triggered() void UserInterface::on_actionExport_selected_triggered()
{ {
if (profileOpen) if (profileOpen)
{
profileUI->exportSelected(); profileUI->exportSelected();
}
} }
void UserInterface::on_actionDelete_selected_triggered() void UserInterface::on_actionDelete_selected_triggered()
{ {
if (profileOpen) if (profileOpen)
{
profileUI->deleteSelected(); profileUI->deleteSelected();
}
} }
void UserInterface::on_actionOptions_triggered() void UserInterface::on_actionOptions_triggered()
@ -443,9 +412,7 @@ void UserInterface::on_actionOptions_triggered()
void UserInterface::on_action_Import_triggered() void UserInterface::on_action_Import_triggered()
{ {
if (profileOpen) if (profileOpen)
{
profileUI->importFiles(); profileUI->importFiles();
}
} }
void UserInterface::on_actionOpen_File_triggered() void UserInterface::on_actionOpen_File_triggered()
@ -459,7 +426,11 @@ fileDialogPreOpen:
fileDialog.setViewMode(QFileDialog::Detail); fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptOpen); fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, false); fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);
#if QT_VERSION >= 0x050900
fileDialog.setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint); fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
fileDialog.setWindowTitle(tr("Open File...")); fileDialog.setWindowTitle(tr("Open File..."));
QStringList filters; QStringList filters;

View File

@ -177,7 +177,6 @@ INCLUDEPATH += ./anpro ./pcg ./tmext ./uimod
DEFINES += GTA5SYNC_QMAKE # We using qmake do we? DEFINES += GTA5SYNC_QMAKE # We using qmake do we?
DEFINES += GTA5SYNC_PROJECT # Enable exclusive gta5sync/gta5view functions DEFINES += GTA5SYNC_PROJECT # Enable exclusive gta5sync/gta5view functions
DEFINES += SNAPMATIC_NODEFAULT # Not assisting at proper usage of SnapmaticPicture class
# WINDOWS ONLY # WINDOWS ONLY

View File

@ -14,6 +14,7 @@
<file>gta5view-96.png</file> <file>gta5view-96.png</file>
<file>gta5view-128.png</file> <file>gta5view-128.png</file>
<file>gta5view-256.png</file> <file>gta5view-256.png</file>
<file>mapcayoperico.jpg</file>
<file>mappreview.jpg</file> <file>mappreview.jpg</file>
<file>next.svgz</file> <file>next.svgz</file>
<file>pointmaker-8.png</file> <file>pointmaker-8.png</file>

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

BIN
res/mapcayoperico.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB