Add Cayo Perico Map, optimisations
All checks were successful
continuous-integration/drone/push Build is passing

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)
{
// Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
// Build Strings
QString appVersion = QApplication::applicationVersion();

View file

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

View file

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

View file

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

View file

@ -29,7 +29,11 @@ MapLocationDialog::MapLocationDialog(double x, double y, QWidget *parent) :
ui(new Ui::MapLocationDialog)
{
// Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
ui->setupUi(this);
ui->cmdDone->setVisible(false);
@ -45,12 +49,10 @@ MapLocationDialog::MapLocationDialog(double x, double y, QWidget *parent) :
ui->vlMapDialog->setSpacing(widgetMargin);
setMinimumSize(500 * screenRatio, 600 * screenRatio);
setMaximumSize(500 * screenRatio, 600 * screenRatio);
setFixedSize(500 * screenRatio, 600 * screenRatio);
setMouseTracking(true);
changeMode = false;
propUpdate = false;
drawPointOnMap(xpos_old, ypos_old);
}
MapLocationDialog::~MapLocationDialog()
@ -66,6 +68,22 @@ void MapLocationDialog::drawPointOnMap(double xpos_d, double ypos_d)
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()
{
qreal screenRatio = AppEnv::screenRatio();
@ -85,45 +103,34 @@ void MapLocationDialog::on_cmdDone_clicked()
{
ui->cmdDone->setVisible(false);
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->cmdRevert->setVisible(true);
}
setCursor(Qt::ArrowCursor);
changeMode = false;
}
#if QT_VERSION >= 0x060000
void MapLocationDialog::updatePosFromEvent(double x, double y)
{
QSize mapPixelSize = size();
double xpos_ad = x;
double 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);
double x_per = x / mapPixelSize.width(); // get X %
double y_per = y / mapPixelSize.height(); // get Y %
double x_pos, y_pos;
if (p_isCayoPerico) {
x_pos = x_per * 2340; // 2340 is 100% for X (Cayo Perico)
y_pos = y_per * -2340; // -2340 is 100% for Y (Cayo Perico)
x_pos = x_pos + 3560; // +3560 gets corrected for X (Cayo Perico)
y_pos = y_pos - 3980; // -4000 gets corrected for Y (Cayo Perico)
}
#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);
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);
}
#endif
void MapLocationDialog::paintEvent(QPaintEvent *ev)
{
@ -132,73 +139,110 @@ void MapLocationDialog::paintEvent(QPaintEvent *ev)
qreal screenRatioPR = AppEnv::screenRatioPR();
// Paint Map
QSize mapPixelSize = QSize(width() * screenRatioPR, height() * screenRatioPR);
painter.drawPixmap(0, 0, width(), height(), QPixmap(":/img/mappreview.jpg").scaled(mapPixelSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
QImage mapImage;
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
QSize mapPixelSize = size();
int pointMarkerSize = 8 * screenRatio;
int pointMarkerHalfSize = pointMarkerSize / 2;
long xpos_ms = qRound(xpos_new);
long ypos_ms = qRound(ypos_new);
double xpos_ma = xpos_ms + 4000;
double ypos_ma = ypos_ms + 4000;
double xrat = (double)width() / 10000;
double yrat = (double)height() / 12000;
long xpos_mp = qRound(xpos_ma * xrat);
long ypos_mp = qRound(ypos_ma * yrat);
long xpos_pr;
long ypos_pr;
double xpos_mp, ypos_mp;
if (p_isCayoPerico) {
double xpos_per = xpos_new - 3560; // correct X in reserve
double ypos_per = ypos_new + 3980; // correct y in reserve
xpos_per = xpos_per / 2340; // divide 100% for X
ypos_per = ypos_per / -2340; // divide 100% for Y
xpos_mp = xpos_per * mapPixelSize.width(); // locate window width pos
ypos_mp = ypos_per * mapPixelSize.height(); // locate window height pos
}
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) {
#ifdef Q_OS_WIN
xpos_pr = xpos_mp - pointMarkerHalfSize;
ypos_pr = ypos_mp + pointMarkerHalfSize;
#else
xpos_pr = xpos_mp - pointMarkerHalfSize + screenRatioPR;
ypos_pr = ypos_mp + pointMarkerHalfSize - screenRatioPR;
#endif
ypos_pr = ypos_mp - pointMarkerHalfSize + screenRatioPR;
}
else {
xpos_pr = xpos_mp - pointMarkerHalfSize;
ypos_pr = ypos_mp + pointMarkerHalfSize;
ypos_pr = ypos_mp - pointMarkerHalfSize;
}
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);
}
void MapLocationDialog::mouseMoveEvent(QMouseEvent *ev)
{
if (!changeMode) { ev->ignore(); }
else if (ev->buttons() & Qt::LeftButton)
{
if (!changeMode) {
ev->ignore();
}
else if (ev->buttons() & Qt::LeftButton) {
#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
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
ev->accept();
}
else
{
else {
ev->ignore();
}
}
void MapLocationDialog::mouseReleaseEvent(QMouseEvent *ev)
{
if (!changeMode) { ev->ignore(); }
else if (ev->button() == Qt::LeftButton)
{
if (!changeMode) {
ev->ignore();
}
else if (ev->button() == Qt::LeftButton) {
#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
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
ev->accept();
}
else
{
else {
ev->ignore();
}
}

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* 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
* it under the terms of the GNU General Public License as published by
@ -33,6 +33,7 @@ class MapLocationDialog : public QDialog
public:
explicit MapLocationDialog(double x, double y, QWidget *parent = 0);
void drawPointOnMap(double x, double y);
void setCayoPerico(bool isCayoPerico);
bool propUpdated();
double getXpos();
double getYpos();
@ -48,11 +49,7 @@ private slots:
void on_cmdApply_clicked();
void on_cmdChange_clicked();
void on_cmdRevert_clicked();
#if QT_VERSION >= 0x060000
void updatePosFromEvent(double x, double y);
#else
void updatePosFromEvent(int x, int y);
#endif
void on_cmdClose_clicked();
private:
@ -62,6 +59,7 @@ private:
double ypos_new;
bool propUpdate;
bool changeMode;
bool p_isCayoPerico;
Ui::MapLocationDialog *ui;
};

View file

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

View file

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

View file

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

View file

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

View file

@ -41,41 +41,38 @@ SnapmaticEditor::SnapmaticEditor(CrewDatabase *crewDB, ProfileDatabase *profileD
ui(new Ui::SnapmaticEditor)
{
// Set Window Flags
#if QT_VERSION >= 0x050900
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
ui->setupUi(this);
ui->cmdCancel->setDefault(true);
ui->cmdCancel->setFocus();
// 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"));
}
else if (QIcon::hasThemeIcon("dialog-apply"))
{
else if (QIcon::hasThemeIcon("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"));
}
else if (QIcon::hasThemeIcon("dialog-ok"))
{
else if (QIcon::hasThemeIcon("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"));
}
// Set Icon for Cancel Button
if (QIcon::hasThemeIcon("dialog-cancel"))
{
if (QIcon::hasThemeIcon("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"));
}
@ -96,27 +93,18 @@ SnapmaticEditor::~SnapmaticEditor()
void SnapmaticEditor::selfie_toggled(bool checked)
{
if (checked)
{
isSelfie = true;
}
else
{
isSelfie = false;
}
isSelfie = checked;
}
void SnapmaticEditor::mugshot_toggled(bool checked)
{
if (checked)
{
if (checked) {
isMugshot = true;
ui->cbDirector->setEnabled(false);
ui->cbDirector->setChecked(false);
}
else
{
else {
isMugshot = false;
ui->cbDirector->setEnabled(true);
}
@ -124,14 +112,12 @@ void SnapmaticEditor::mugshot_toggled(bool checked)
void SnapmaticEditor::editor_toggled(bool checked)
{
if (checked)
{
if (checked) {
isEditor = true;
ui->cbDirector->setEnabled(false);
ui->cbDirector->setChecked(false);
}
else
{
else {
isEditor = false;
ui->cbDirector->setEnabled(true);
}
@ -139,8 +125,7 @@ void SnapmaticEditor::editor_toggled(bool checked)
void SnapmaticEditor::on_rbSelfie_toggled(bool checked)
{
if (checked)
{
if (checked) {
mugshot_toggled(false);
editor_toggled(false);
selfie_toggled(true);
@ -149,8 +134,7 @@ void SnapmaticEditor::on_rbSelfie_toggled(bool checked)
void SnapmaticEditor::on_rbMugshot_toggled(bool checked)
{
if (checked)
{
if (checked) {
selfie_toggled(false);
editor_toggled(false);
mugshot_toggled(true);
@ -159,8 +143,7 @@ void SnapmaticEditor::on_rbMugshot_toggled(bool checked)
void SnapmaticEditor::on_rbEditor_toggled(bool checked)
{
if (checked)
{
if (checked) {
selfie_toggled(false);
mugshot_toggled(false);
editor_toggled(true);
@ -169,8 +152,7 @@ void SnapmaticEditor::on_rbEditor_toggled(bool checked)
void SnapmaticEditor::on_rbCustom_toggled(bool checked)
{
if (checked)
{
if (checked) {
selfie_toggled(false);
mugshot_toggled(false);
editor_toggled(false);
@ -189,20 +171,16 @@ void SnapmaticEditor::setSnapmaticPicture(SnapmaticPicture *picture)
playersList = snapmaticProperties.playersList;
ui->cbDirector->setChecked(snapmaticProperties.isFromDirector);
ui->cbMeme->setChecked(snapmaticProperties.isMeme);
if (isSelfie)
{
if (isSelfie) {
ui->rbSelfie->setChecked(true);
}
else if (isMugshot)
{
else if (isMugshot) {
ui->rbMugshot->setChecked(true);
}
else if (isEditor)
{
else if (isEditor) {
ui->rbEditor->setChecked(true);
}
else
{
else {
ui->rbCustom->setChecked(true);
}
setSnapmaticCrew(returnCrewName(crewID));
@ -212,8 +190,7 @@ void SnapmaticEditor::setSnapmaticPicture(SnapmaticPicture *picture)
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)));
}
}
@ -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 playersStr;
if (players.length() != 1)
{
if (players.length() != 1) {
playersStr = tr("Players: %1 (%2)", "Multiple Player are inserted here");
}
else
{
else {
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));
}
else
{
else {
ui->labPlayers->setText(playersStr.arg(QApplication::translate("PictureDialog", "No Players"), editStr));
}
#ifndef Q_OS_ANDROID
ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->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
}
void SnapmaticEditor::setSnapmaticTitle(const QString &title)
{
if (title.length() > 39)
{
if (title.length() > 39) {
snapmaticTitle = title.left(39);
}
else
{
else {
snapmaticTitle = title;
}
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);
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"))));
}
else
{
else {
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
ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->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
}
@ -288,7 +259,8 @@ void SnapmaticEditor::setSnapmaticCrew(const QString &crew)
#ifndef Q_OS_ANDROID
ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->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
}
@ -304,8 +276,7 @@ void SnapmaticEditor::on_cmdCancel_clicked()
void SnapmaticEditor::on_cmdApply_clicked()
{
if (ui->cbQualify->isChecked())
{
if (ui->cbQualify->isChecked()) {
qualifyAvatar();
}
snapmaticProperties.crewID = crewID;
@ -315,27 +286,23 @@ void SnapmaticEditor::on_cmdApply_clicked()
snapmaticProperties.isFromDirector = ui->cbDirector->isChecked();
snapmaticProperties.isMeme = ui->cbMeme->isChecked();
snapmaticProperties.playersList = playersList;
if (smpic)
{
if (smpic) {
QString currentFilePath = smpic->getPictureFilePath();
QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName))
{
if (!QFile::exists(backupFileName)) {
QFile::copy(currentFilePath, backupFileName);
}
SnapmaticProperties fallbackProperties = smpic->getSnapmaticProperties();
QString fallbackTitle = smpic->getPictureTitle();
smpic->setSnapmaticProperties(snapmaticProperties);
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"));
smpic->setSnapmaticProperties(fallbackProperties);
smpic->setPictureTitle(fallbackTitle);
}
else
{
else {
smpic->updateStrings();
smpic->emitUpdate();
#ifdef GTA5SYNC_TELEMETRY
@ -343,8 +310,7 @@ void SnapmaticEditor::on_cmdApply_clicked()
telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush())
{
if (pushUsageData && Telemetry->canPush()) {
QJsonDocument jsonDocument;
QJsonObject jsonObject;
jsonObject["Type"] = "PropertyEdited";
@ -373,8 +339,7 @@ void SnapmaticEditor::qualifyAvatar()
void SnapmaticEditor::on_cbQualify_toggled(bool checked)
{
if (checked)
{
if (checked) {
ui->cbMeme->setEnabled(false);
ui->cbDirector->setEnabled(false);
ui->rbCustom->setEnabled(false);
@ -382,15 +347,13 @@ void SnapmaticEditor::on_cbQualify_toggled(bool checked)
ui->rbEditor->setEnabled(false);
ui->rbMugshot->setEnabled(false);
}
else
{
else {
ui->cbMeme->setEnabled(true);
ui->rbCustom->setEnabled(true);
ui->rbSelfie->setEnabled(true);
ui->rbEditor->setEnabled(true);
ui->rbMugshot->setEnabled(true);
if (ui->rbSelfie->isChecked() || ui->rbCustom->isChecked())
{
if (ui->rbSelfie->isChecked() || ui->rbCustom->isChecked()) {
ui->cbDirector->setEnabled(true);
}
}
@ -398,8 +361,7 @@ void SnapmaticEditor::on_cbQualify_toggled(bool checked)
void SnapmaticEditor::on_labPlayers_linkActivated(const QString &link)
{
if (link == "g5e://editplayers")
{
if (link == "g5e://editplayers") {
PlayerListDialog *playerListDialog = new PlayerListDialog(playersList, profileDB, this);
connect(playerListDialog, SIGNAL(playerListUpdated(QStringList)), this, SLOT(playerListUpdated(QStringList)));
playerListDialog->setModal(true);
@ -411,12 +373,10 @@ void SnapmaticEditor::on_labPlayers_linkActivated(const QString &link)
void SnapmaticEditor::on_labTitle_linkActivated(const QString &link)
{
if (link == "g5e://edittitle")
{
if (link == "g5e://edittitle") {
bool ok;
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);
}
}
@ -424,39 +384,33 @@ void SnapmaticEditor::on_labTitle_linkActivated(const QString &link)
void SnapmaticEditor::on_labCrew_linkActivated(const QString &link)
{
if (link == "g5e://editcrew")
{
if (link == "g5e://editcrew") {
bool ok;
int indexNum = 0;
QStringList itemList;
QStringList crewList = crewDB->getCrews();
if (!crewList.contains(QLatin1String("0")))
{
if (!crewList.contains(QLatin1String("0"))) {
crewList += QLatin1String("0");
}
crewList.sort();
for (QString crew : crewList)
{
for (const QString &crew : crewList) {
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));
}
QString newCrew = QInputDialog::getItem(this, tr("Snapmatic Crew"), tr("New Snapmatic crew:"), itemList, indexNum, true, &ok, windowFlags());
if (ok && !newCrew.isEmpty())
{
if (newCrew.contains(" ")) newCrew = newCrew.split(" ").at(0);
if (newCrew.length() > 10) return;
for (QChar crewChar : newCrew)
{
if (!crewChar.isNumber())
{
if (ok && !newCrew.isEmpty()) {
if (newCrew.contains(" "))
newCrew = newCrew.split(" ").at(0);
if (newCrew.length() > 10)
return;
for (const QChar &crewChar : newCrew) {
if (!crewChar.isNumber()) {
return;
}
}
if (!crewList.contains(newCrew))
{
if (!crewList.contains(newCrew)) {
crewDB->addCrew(crewID);
}
crewID = newCrew.toInt();

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* 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
* it under the terms of the GNU General Public License as published by
@ -84,8 +84,7 @@ bool SnapmaticPicture::preloadFile()
isFormatSwitch = false;
if (!picFile->open(QFile::ReadOnly))
{
if (!picFile->open(QFile::ReadOnly)) {
lastStep = "1;/1,OpenFile," % convertDrawStringForLog(picFilePath);
delete picFile;
return false;
@ -98,8 +97,7 @@ bool SnapmaticPicture::preloadFile()
if (!ok)
return false;
if (picFilePath.right(4) != QLatin1String(".g5e"))
{
if (picFilePath.right(4) != QLatin1String(".g5e")) {
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX)
isFormatSwitch = true;
}
@ -122,9 +120,9 @@ bool SnapmaticPicture::readingPicture(bool cacheEnabled_)
if (!ok)
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;
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"));
sortStr = localProperties.createdDateTime.toString("yyMMddHHmmss") % 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;
}
bool SnapmaticPicture::readingPictureFromFile(const QString &fileName, bool cacheEnabled_)
{
if (!fileName.isEmpty())
{
if (!fileName.isEmpty()) {
picFilePath = fileName;
return readingPicture(cacheEnabled_);
}
else
{
else {
return false;
}
}
@ -244,12 +241,10 @@ QString SnapmaticPicture::getExportPictureFileName()
QString SnapmaticPicture::getOriginalPictureFileName()
{
QString newPicFileName = picFileName;
if (picFileName.right(4) == ".bak")
{
if (picFileName.right(4) == ".bak") {
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);
}
return newPicFileName;
@ -258,12 +253,10 @@ QString SnapmaticPicture::getOriginalPictureFileName()
QString SnapmaticPicture::getOriginalPictureFilePath()
{
QString newPicFilePath = picFilePath;
if (picFilePath.right(4) == ".bak")
{
if (picFilePath.right(4) == ".bak") {
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);
}
return newPicFilePath;
@ -296,79 +289,65 @@ QString SnapmaticPicture::getPictureStr()
QString SnapmaticPicture::getLastStep(bool readable)
{
if (readable)
{
if (readable) {
QStringList lastStepList = lastStep.split(";/");
if (lastStepList.length() < 2) { return lastStep; }
if (lastStepList.length() < 2)
return lastStep;
bool intOk;
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);
if (!intOk) { return lastStep; }
if (argsCount == 1)
{
if (argsCount == 1) {
QString currentAction = descStepList.at(1);
QString actionFile = descStepList.at(2);
if (currentAction == "OpenFile")
{
if (currentAction == "OpenFile") {
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 actionFile = descStepList.at(2);
QString actionError = descStepList.at(4);
QString actionError2;
if (argsCount == 4) { actionError2 = descStepList.at(5); }
if (currentAction == "ReadingFile")
{
if (currentAction == "ReadingFile") {
QString readableError = actionError;
if (actionError == "NOHEADER")
{
if (actionError == "NOHEADER") {
readableError = tr("header not exists");
}
else if (actionError == "MALFORMEDHEADER")
{
else if (actionError == "MALFORMEDHEADER") {
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);
}
else if (actionError == "NOJSON" || actionError == "CTJSON")
{
else if (actionError == "NOJSON" || actionError == "CTJSON") {
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);
}
else if (actionError == "NODESC" || actionError == "CTDESC")
{
else if (actionError == "NODESC" || actionError == "CTDESC") {
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");
}
else if (actionError == "JSONINCOMPLETE")
{
else if (actionError == "JSONINCOMPLETE") {
readableError = tr("JSON is incomplete");
}
else if (actionError == "JSONERROR")
{
else if (actionError == "JSONERROR") {
readableError = tr("JSON is malformed");
}
return tr("reading file %1 because of %2", "Example for %2: JSON is malformed error").arg(actionFile, readableError);
}
else
{
else {
return lastStep;
}
}
else
{
else {
return lastStep;
}
}
@ -437,25 +416,20 @@ void SnapmaticPicture::parseJsonContent()
bool jsonIncomplete = false;
bool jsonError = false;
if (jsonObject.contains("loc"))
{
if (jsonObject["loc"].isObject())
{
if (jsonObject.contains("loc")) {
if (jsonObject["loc"].isObject()) {
QJsonObject locObject = jsonObject["loc"].toObject();
if (locObject.contains("x"))
{
if (locObject.contains("x")) {
if (locObject["x"].isDouble()) { localProperties.location.x = locObject["x"].toDouble(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (locObject.contains("y"))
{
if (locObject.contains("y")) {
if (locObject["y"].isDouble()) { localProperties.location.y = locObject["y"].toDouble(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (locObject.contains("z"))
{
if (locObject.contains("z")) {
if (locObject["z"].isDouble()) { localProperties.location.z = locObject["z"].toDouble(); }
else { jsonError = true; }
}
@ -464,35 +438,30 @@ void SnapmaticPicture::parseJsonContent()
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("uid"))
{
if (jsonObject.contains("uid")) {
bool uidOk;
localProperties.uid = jsonMap["uid"].toInt(&uidOk);
if (!uidOk) { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("area"))
{
if (jsonObject.contains("area")) {
if (jsonObject["area"].isString()) { localProperties.location.area = jsonObject["area"].toString(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("crewid"))
{
if (jsonObject.contains("crewid")) {
bool crewIDOk;
localProperties.crewID = jsonMap["crewid"].toInt(&crewIDOk);
if (!crewIDOk) { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("street"))
{
if (jsonObject.contains("street")) {
bool streetIDOk;
localProperties.streetID = jsonMap["street"].toInt(&streetIDOk);
if (!streetIDOk) { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("creat"))
{
if (jsonObject.contains("creat")) {
bool timestampOk;
QDateTime createdTimestamp;
localProperties.createdTimestamp = jsonMap["creat"].toUInt(&timestampOk);
@ -505,59 +474,53 @@ void SnapmaticPicture::parseJsonContent()
if (!timestampOk) { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("plyrs"))
{
if (jsonObject.contains("plyrs")) {
if (jsonObject["plyrs"].isArray()) { localProperties.playersList = jsonMap["plyrs"].toStringList(); }
else { jsonError = true; }
}
// 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(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("mug"))
{
if (jsonObject.contains("mug")) {
if (jsonObject["mug"].isBool()) { localProperties.isMug = jsonObject["mug"].toBool(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("slf"))
{
if (jsonObject.contains("slf")) {
if (jsonObject["slf"].isBool()) { localProperties.isSelfie = jsonObject["slf"].toBool(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("drctr"))
{
if (jsonObject.contains("drctr")) {
if (jsonObject["drctr"].isBool()) { localProperties.isFromDirector = jsonObject["drctr"].toBool(); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (jsonObject.contains("rsedtr"))
{
if (jsonObject.contains("rsedtr")) {
if (jsonObject["rsedtr"].isBool()) { localProperties.isFromRSEditor = jsonObject["rsedtr"].toBool(); }
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;
}
else
{
if (jsonIncomplete && jsonError)
{
else {
if (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";
}
else if (jsonError)
{
else if (jsonError) {
lastStep = "2;/3,ReadingFile," % convertDrawStringForLog(picFilePath) % ",3,JSONERROR";
}
jsonOk = false;
@ -585,10 +548,10 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties properties)
jsonObject["slf"] = properties.isSelfie;
jsonObject["drctr"] = properties.isFromDirector;
jsonObject["rsedtr"] = properties.isFromRSEditor;
jsonObject["onislandx"] = properties.location.isCayoPerico;
QJsonDocument jsonDocument(jsonObject);
if (setJsonStr(QString::fromUtf8(jsonDocument.toJson(QJsonDocument::Compact))))
{
if (setJsonStr(QString::fromUtf8(jsonDocument.toJson(QJsonDocument::Compact)))) {
localProperties = properties;
return true;
}
@ -613,14 +576,11 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
{
// Keep current format when Auto_Format is used
SnapmaticFormat format = format_;
if (format_ == SnapmaticFormat::Auto_Format)
{
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX)
{
if (format_ == SnapmaticFormat::Auto_Format) {
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX) {
format = SnapmaticFormat::G5E_Format;
}
else
{
else {
format = SnapmaticFormat::PGTA_Format;
}
}
@ -631,10 +591,8 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
#else
QFile *picFile = new QFile(StandardPaths::tempLocation() % "/" % QFileInfo(fileName).fileName() % ".tmp");
#endif
if (picFile->open(QIODevice::WriteOnly))
{
if (format == SnapmaticFormat::G5E_Format)
{
if (picFile->open(QIODevice::WriteOnly)) {
if (format == SnapmaticFormat::G5E_Format) {
p_ragePhoto.save(picFile, RagePhoto::PhotoFormat::G5EX);
#if QT_VERSION >= 0x050000
saveSuccess = picFile->commit();
@ -644,8 +602,7 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
#endif
delete picFile;
}
else if (format == SnapmaticFormat::JPEG_Format)
{
else if (format == SnapmaticFormat::JPEG_Format) {
picFile->write(p_ragePhoto.photoData());
#if QT_VERSION >= 0x050000
saveSuccess = picFile->commit();
@ -655,8 +612,7 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
#endif
delete picFile;
}
else
{
else {
p_ragePhoto.save(picFile, RagePhoto::PhotoFormat::GTA5);
#if QT_VERSION >= 0x050000
saveSuccess = picFile->commit();
@ -688,8 +644,7 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
#endif
return saveSuccess;
}
else
{
else {
delete picFile;
return saveSuccess;
}
@ -708,16 +663,13 @@ void SnapmaticPicture::setPicFilePath(const QString &picFilePath_)
bool SnapmaticPicture::deletePicFile()
{
bool success = false;
if (!QFile::exists(picFilePath))
{
if (!QFile::exists(picFilePath)) {
success = true;
}
else if (QFile::remove(picFilePath))
{
else if (QFile::remove(picFilePath)) {
success = true;
}
if (isHidden())
{
if (isHidden()) {
const QString picBakPath = QString(picFilePath).remove(picFilePath.length() - 7, 7) % ".bak";
if (QFile::exists(picBakPath)) QFile::remove(picBakPath);
}
@ -732,8 +684,7 @@ bool SnapmaticPicture::deletePicFile()
bool SnapmaticPicture::isHidden()
{
if (picFilePath.right(7) == QLatin1String(".hidden"))
{
if (picFilePath.right(7) == QLatin1String(".hidden")) {
return true;
}
return false;
@ -741,8 +692,7 @@ bool SnapmaticPicture::isHidden()
bool SnapmaticPicture::isVisible()
{
if (picFilePath.right(7) == QLatin1String(".hidden"))
{
if (picFilePath.right(7) == QLatin1String(".hidden")) {
return false;
}
return true;
@ -750,15 +700,12 @@ bool SnapmaticPicture::isVisible()
bool SnapmaticPicture::setPictureHidden()
{
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX)
{
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX) {
return false;
}
if (!isHidden())
{
if (!isHidden()) {
QString newPicFilePath = QString(picFilePath % ".hidden");
if (QFile::rename(picFilePath, newPicFilePath))
{
if (QFile::rename(picFilePath, newPicFilePath)) {
picFilePath = newPicFilePath;
return true;
}
@ -769,15 +716,12 @@ bool SnapmaticPicture::setPictureHidden()
bool SnapmaticPicture::setPictureVisible()
{
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX)
{
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX) {
return false;
}
if (isHidden())
{
if (isHidden()) {
QString newPicFilePath = QString(picFilePath).remove(picFilePath.length() - 7, 7);
if (QFile::rename(picFilePath, newPicFilePath))
{
if (QFile::rename(picFilePath, newPicFilePath)) {
picFilePath = newPicFilePath;
return true;
}
@ -797,8 +741,7 @@ QSize SnapmaticPicture::getSnapmaticResolution()
SnapmaticFormat SnapmaticPicture::getSnapmaticFormat()
{
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX)
{
if (p_ragePhoto.photoFormat() == RagePhoto::PhotoFormat::G5EX) {
return SnapmaticFormat::G5E_Format;
}
return SnapmaticFormat::PGTA_Format;
@ -806,13 +749,11 @@ SnapmaticFormat SnapmaticPicture::getSnapmaticFormat()
void SnapmaticPicture::setSnapmaticFormat(SnapmaticFormat format)
{
if (format == SnapmaticFormat::G5E_Format)
{
if (format == SnapmaticFormat::G5E_Format) {
p_ragePhoto.setPhotoFormat(RagePhoto::PhotoFormat::G5EX);
return;
}
else if (format == SnapmaticFormat::PGTA_Format)
{
else if (format == SnapmaticFormat::PGTA_Format) {
p_ragePhoto.setPhotoFormat(RagePhoto::PhotoFormat::GTA5);
return;
}
@ -829,10 +770,8 @@ bool SnapmaticPicture::isFormatSwitched()
bool SnapmaticPicture::verifyTitle(const QString &title)
{
// VERIFY TITLE FOR BE A VALID SNAPMATIC TITLE
if (title.length() <= 39 && title.length() > 0)
{
for (const QChar &titleChar : title)
{
if (title.length() <= 39 && title.length() > 0) {
for (const QChar &titleChar : title) {
if (!verifyTitleChar(titleChar)) return false;
}
return true;
@ -843,8 +782,7 @@ bool SnapmaticPicture::verifyTitle(const QString &title)
bool SnapmaticPicture::verifyTitleChar(const QChar &titleChar)
{
// VERIFY CHAR FOR BE A VALID SNAPMATIC CHARACTER
if (titleChar.isLetterOrNumber() || titleChar.isPrint())
{
if (titleChar.isLetterOrNumber() || titleChar.isPrint()) {
if (titleChar == '<' || titleChar == '>' || titleChar == '\\') return false;
return true;
}

View file

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

View file

@ -85,7 +85,8 @@ void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture)
QPixmap renderPixmap(renderResolution);
renderPixmap.fill(Qt::transparent);
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()) {
renderPainter.drawImage((renderResolution.width() - renderImage.width()) / 2, 0, renderImage, Qt::AutoColor);
}
@ -115,8 +116,7 @@ void SnapmaticWidget::snapmaticUpdated()
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);
ui->labPicture->setPixmap(SnapmaticPixmap);
}
@ -146,7 +146,8 @@ void SnapmaticWidget::on_cmdView_clicked()
QObject::connect(picDialog, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested()));
// add previous next buttons
if (navigationBar) picDialog->addPreviousNextButtons();
if (navigationBar)
picDialog->addPreviousNextButtons();
// show picture dialog
#ifdef Q_OS_ANDROID
@ -175,23 +176,21 @@ void SnapmaticWidget::on_cmdExport_clicked()
void SnapmaticWidget::on_cmdDelete_clicked()
{
if (deletePicture()) emit pictureDeleted();
if (deletePicture())
emit pictureDeleted();
}
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);
if (uchoice == QMessageBox::Yes)
{
if (smpic->deletePictureFile())
{
if (uchoice == QMessageBox::Yes) {
if (smpic->deletePictureFile()) {
#ifdef GTA5SYNC_TELEMETRY
QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush())
{
if (pushUsageData && Telemetry->canPush()) {
QJsonDocument jsonDocument;
QJsonObject jsonObject;
jsonObject["Type"] = "DeleteSuccess";
@ -208,8 +207,7 @@ bool SnapmaticWidget::deletePicture()
#endif
return true;
}
else
{
else {
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)
{
ProfileWidget::mouseReleaseEvent(ev);
if (ui->cbSelected->isVisible())
{
if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{
if (ui->cbSelected->isVisible()) {
if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) {
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
}
}
else
{
else {
const int contentMode = getContentMode();
if ((contentMode == 0 || contentMode == 10 || contentMode == 20) && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{
if (ev->modifiers().testFlag(Qt::ShiftModifier))
{
if ((contentMode == 0 || contentMode == 10 || contentMode == 20) && rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) {
if (ev->modifiers().testFlag(Qt::ShiftModifier)) {
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
}
else
{
else {
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());
}
}
@ -257,8 +248,7 @@ void SnapmaticWidget::mouseDoubleClickEvent(QMouseEvent *ev)
ProfileWidget::mouseDoubleClickEvent(ev);
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();
}
}
@ -290,32 +280,27 @@ void SnapmaticWidget::dialogPreviousPictureRequested()
void SnapmaticWidget::on_cbSelected_stateChanged(int arg1)
{
if (arg1 == Qt::Checked)
{
if (arg1 == Qt::Checked) {
emit widgetSelected();
}
else if (arg1 == Qt::Unchecked)
{
else if (arg1 == Qt::Unchecked) {
emit widgetDeselected();
}
}
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())));
}
else
{
else {
ui->labPicStr->setStyleSheet("");
}
}
bool SnapmaticWidget::makePictureHidden()
{
if (smpic->setPictureHidden())
{
if (smpic->setPictureHidden()) {
adjustTextColor();
return true;
}
@ -324,8 +309,7 @@ bool SnapmaticWidget::makePictureHidden()
bool SnapmaticWidget::makePictureVisible()
{
if (smpic->setPictureVisible())
{
if (smpic->setPictureVisible()) {
adjustTextColor();
return true;
}
@ -335,18 +319,14 @@ bool SnapmaticWidget::makePictureVisible()
void SnapmaticWidget::makePictureHiddenSlot()
{
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()+"\""));
}
}
void SnapmaticWidget::makePictureVisibleSlot()
{
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()+"\""));
}
}
void SnapmaticWidget::editSnapmaticProperties()
{
@ -375,21 +355,17 @@ void SnapmaticWidget::editSnapmaticImage()
importDialog->enableOverwriteMode();
importDialog->setModal(true);
importDialog->exec();
if (importDialog->isImportAgreed())
{
if (importDialog->isImportAgreed()) {
const QByteArray previousPicture = smpic->getPictureStream();
bool success = smpic->setImage(importDialog->image());
if (success)
{
if (success) {
QString currentFilePath = smpic->getPictureFilePath();
QString originalFilePath = smpic->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName))
{
if (!QFile::exists(backupFileName)) {
QFile::copy(currentFilePath, backupFileName);
}
if (!smpic->exportPicture(currentFilePath))
{
if (!smpic->exportPicture(currentFilePath)) {
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"));
return;
@ -400,8 +376,7 @@ void SnapmaticWidget::editSnapmaticImage()
telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush())
{
if (pushUsageData && Telemetry->canPush()) {
QJsonDocument jsonDocument;
QJsonObject jsonObject;
jsonObject["Type"] = "ImageEdited";
@ -417,8 +392,7 @@ void SnapmaticWidget::editSnapmaticImage()
}
#endif
}
else
{
else {
QMessageBox::warning(this, QApplication::translate("ImageEditorDialog", "Snapmatic Image Editor"), QApplication::translate("ImageEditorDialog", "Patching of Snapmatic Image failed because of Image Error"));
return;
}
@ -429,42 +403,38 @@ void SnapmaticWidget::editSnapmaticImage()
void SnapmaticWidget::openMapViewer()
{
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->show();
mapLocDialog->exec();
if (mapLocDialog->propUpdated())
{
if (mapLocDialog->propUpdated()) {
// Update Snapmatic Properties
SnapmaticProperties localSpJson = picture->getSnapmaticProperties();
localSpJson.location.x = mapLocDialog->getXpos();
localSpJson.location.y = mapLocDialog->getYpos();
localSpJson.location.z = 0;
currentProperties.location.x = mapLocDialog->getXpos();
currentProperties.location.y = mapLocDialog->getYpos();
currentProperties.location.z = 0;
// Update Snapmatic Picture
QString currentFilePath = picture->getPictureFilePath();
QString originalFilePath = picture->getOriginalPictureFilePath();
QString backupFileName = originalFilePath % ".bak";
if (!QFile::exists(backupFileName))
{
if (!QFile::exists(backupFileName)) {
QFile::copy(currentFilePath, backupFileName);
}
SnapmaticProperties fallbackProperties = picture->getSnapmaticProperties();
picture->setSnapmaticProperties(localSpJson);
if (!picture->exportPicture(currentFilePath))
{
picture->setSnapmaticProperties(currentProperties);
if (!picture->exportPicture(currentFilePath)) {
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of I/O Error"));
picture->setSnapmaticProperties(fallbackProperties);
}
#ifdef GTA5SYNC_TELEMETRY
else
{
else {
QSettings telemetrySettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
telemetrySettings.beginGroup("Telemetry");
bool pushUsageData = telemetrySettings.value("PushUsageData", false).toBool();
telemetrySettings.endGroup();
if (pushUsageData && Telemetry->canPush())
{
if (pushUsageData && Telemetry->canPush()) {
QJsonDocument jsonDocument;
QJsonObject jsonObject;
jsonObject["Type"] = "LocationEdited";

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* 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
* it under the terms of the GNU General Public License as published by
@ -23,11 +23,6 @@
#include <QDesktopServices>
#endif
StandardPaths::StandardPaths()
{
}
QString StandardPaths::applicationsLocation()
{
#if QT_VERSION >= 0x050000

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* 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
* it under the terms of the GNU General Public License as published by
@ -24,7 +24,6 @@
class StandardPaths
{
public:
StandardPaths();
static QString applicationsLocation();
static QString cacheLocation();
static QString dataLocation();

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* 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
* it under the terms of the GNU General Public License as published by
@ -17,7 +17,9 @@
*****************************************************************************/
#include "StringParser.h"
#include "config.h"
#include <QTextDocument>
#include <QApplication>
#include <QLibraryInfo>
#include <QByteArray>
#include <QFileInfo>
@ -25,16 +27,6 @@
#include <QList>
#include <QDir>
#ifdef GTA5SYNC_PROJECT
#include <QApplication>
#include "config.h"
#endif
StringParser::StringParser()
{
}
QString StringParser::escapeString(const QString &toEscape)
{
#if QT_VERSION >= 0x050000
@ -44,7 +36,6 @@ QString StringParser::escapeString(const QString &toEscape)
#endif
}
#ifdef GTA5SYNC_PROJECT
QString StringParser::convertBuildedString(const QString &buildedStr)
{
QString outputStr = buildedStr;
@ -61,4 +52,3 @@ QString StringParser::convertBuildedString(const QString &buildedStr)
outputStr.replace("SEPARATOR:", QDir::separator());
return outputStr;
}
#endif

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* 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
* it under the terms of the GNU General Public License as published by
@ -25,11 +25,8 @@
class StringParser
{
public:
StringParser();
static QString escapeString(const QString &toEscape);
#ifdef GTA5SYNC_PROJECT
static QString convertBuildedString(const QString &buildedStr);
#endif
};
#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));
// Set Icon for Close Button
if (QIcon::hasThemeIcon("dialog-close"))
{
if (QIcon::hasThemeIcon("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"));
}
// Set Icon for Reload Button
if (QIcon::hasThemeIcon("view-refresh"))
{
if (QIcon::hasThemeIcon("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"));
}
// 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"));
}
else if (QIcon::hasThemeIcon("gtk-directory"))
{
else if (QIcon::hasThemeIcon("gtk-directory")) {
ui->actionSelect_GTA_Folder->setIcon(QIcon::fromTheme("gtk-directory"));
}
// 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"));
}
// 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"));
}
else if (QIcon::hasThemeIcon("gtk-close"))
{
else if (QIcon::hasThemeIcon("gtk-close")) {
ui->actionSelect_profile->setIcon(QIcon::fromTheme("gtk-close"));
}
// 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
ui->actionExit->setIcon(QIcon::fromTheme("application-exit"));
#endif
}
// 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
ui->actionOptions->setIcon(QIcon::fromTheme("preferences-system"));
#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
ui->actionOptions->setIcon(QIcon::fromTheme("configure"));
#endif
}
// 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"));
}
else if (QIcon::hasThemeIcon("document-open"))
{
else if (QIcon::hasThemeIcon("document-open")) {
ui->action_Import->setIcon(QIcon::fromTheme("document-open"));
}
// 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"));
}
else if (QIcon::hasThemeIcon("document-save"))
{
else if (QIcon::hasThemeIcon("document-save")) {
ui->actionExport_selected->setIcon(QIcon::fromTheme("document-save"));
}
// Set Icon for Profile Remove Menu Item
if (QIcon::hasThemeIcon("remove"))
{
if (QIcon::hasThemeIcon("remove")) {
ui->actionDelete_selected->setIcon(QIcon::fromTheme("remove"));
}
@ -245,8 +228,7 @@ void UserInterface::setupDirEnv(bool showFolderDialog)
void UserInterface::setupProfileUi()
{
qreal screenRatio = AppEnv::screenRatio();
if (GTAV_Profiles.isEmpty())
{
if (GTAV_Profiles.isEmpty()) {
QPushButton *changeDirBtn = new QPushButton(tr("Select &GTA V Folder..."), ui->swSelection);
changeDirBtn->setObjectName("cmdChangeDir");
changeDirBtn->setMinimumSize(0, 40 * screenRatio);
@ -256,8 +238,7 @@ void UserInterface::setupProfileUi()
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);
profileBtn->setObjectName(GTAV_Profile);
profileBtn->setMinimumSize(0, 40 * screenRatio);
@ -277,8 +258,7 @@ void UserInterface::changeFolder_clicked()
void UserInterface::on_cmdReload_clicked()
{
for (QPushButton *profileBtn : profileBtns)
{
for (QPushButton *profileBtn : profileBtns) {
ui->vlButtons->removeWidget(profileBtn);
delete profileBtn;
}
@ -341,11 +321,8 @@ void UserInterface::closeEvent(QCloseEvent *ev)
UserInterface::~UserInterface()
{
if (profileOpen)
{
closeProfile_p();
}
for (QPushButton *profileBtn : profileBtns)
{
for (QPushButton *profileBtn : profileBtns) {
delete profileBtn;
}
profileBtns.clear();
@ -392,34 +369,26 @@ void UserInterface::profileLoaded()
void UserInterface::on_actionSelect_all_triggered()
{
if (profileOpen)
{
profileUI->selectAllWidgets();
}
}
void UserInterface::on_actionDeselect_all_triggered()
{
if (profileOpen)
{
profileUI->deselectAllWidgets();
}
}
void UserInterface::on_actionExport_selected_triggered()
{
if (profileOpen)
{
profileUI->exportSelected();
}
}
void UserInterface::on_actionDelete_selected_triggered()
{
if (profileOpen)
{
profileUI->deleteSelected();
}
}
void UserInterface::on_actionOptions_triggered()
{
@ -443,10 +412,8 @@ void UserInterface::on_actionOptions_triggered()
void UserInterface::on_action_Import_triggered()
{
if (profileOpen)
{
profileUI->importFiles();
}
}
void UserInterface::on_actionOpen_File_triggered()
{
@ -459,7 +426,11 @@ fileDialogPreOpen:
fileDialog.setViewMode(QFileDialog::Detail);
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);
#if QT_VERSION >= 0x050900
fileDialog.setWindowFlag(Qt::WindowContextHelpButtonHint, false);
#else
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
#endif
fileDialog.setWindowTitle(tr("Open File..."));
QStringList filters;

View file

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

View file

@ -14,6 +14,7 @@
<file>gta5view-96.png</file>
<file>gta5view-128.png</file>
<file>gta5view-256.png</file>
<file>mapcayoperico.jpg</file>
<file>mappreview.jpg</file>
<file>next.svgz</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