Compare commits

...

5 Commits

Author SHA1 Message Date
Syping 5e7c7c580d project state update 2023-02-26 05:16:56 +01:00
Syping a4c5ad6c66 update version to 0.5.0 2020-10-23 14:21:33 +02:00
Syping 68dff71d17 merged with gta5view 1.8 2020-10-21 07:40:18 +02:00
Syping b387046fe5 update version to 0.3.0 2020-08-25 20:59:57 +02:00
Syping 4e83cb165a merged with gta5view 1.8 2020-08-25 20:47:50 +02:00
53 changed files with 3642 additions and 3134 deletions

View File

@ -22,13 +22,17 @@
#include "StandardPaths.h"
#include <QtGlobal>
#include <QStringBuilder>
#include <QDesktopWidget>
#include <QApplication>
#include <QSettings>
#include <QScreen>
#include <QDebug>
#include <QRect>
#include <QDir>
#if QT_VERSION < 0x050000
#include <QDesktopWidget>
#endif
#include <iostream>
using namespace std;
@ -153,7 +157,7 @@ QString AppEnv::getPluginsFolder()
QByteArray AppEnv::getUserAgent()
{
#if QT_VERSION >= 0x050400
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
QString kernelVersion = QSysInfo::kernelVersion();
const QStringList &kernelVersionList = kernelVersion.split(".");
if (kernelVersionList.length() > 2)
@ -210,7 +214,7 @@ QUrl AppEnv::getPlayerFetchingUrl(QString crewID, int pageNumber)
GameVersion AppEnv::getGameVersion()
{
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
argumentValue = "\\WOW6432Node";
@ -268,7 +272,7 @@ GameLanguage AppEnv::getGameLanguage(GameVersion gameVersion)
{
if (gameVersion == GameVersion::SocialClubVersion)
{
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
argumentValue = "\\WOW6432Node";
@ -282,7 +286,7 @@ GameLanguage AppEnv::getGameLanguage(GameVersion gameVersion)
}
else if (gameVersion == GameVersion::SteamVersion)
{
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
argumentValue = "\\WOW6432Node";
@ -443,7 +447,7 @@ bool AppEnv::setGameLanguage(GameVersion gameVersion, GameLanguage gameLanguage)
}
if (socialClubVersion)
{
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
argumentValue = "\\WOW6432Node";
@ -468,7 +472,7 @@ bool AppEnv::setGameLanguage(GameVersion gameVersion, GameLanguage gameLanguage)
}
if (steamVersion)
{
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
QString argumentValue;
#ifdef _WIN64
argumentValue = "\\WOW6432Node";

View File

@ -48,11 +48,8 @@ void DatabaseThread::run()
while (threadRunning)
{
if (threadRunning)
{
QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
threadLoop.exec();
}
QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
threadLoop.exec();
}
}
@ -65,7 +62,9 @@ void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &r
QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(AppEnv::getCrewFetchingUrl(crewID));
#if QT_VERSION >= 0x050600
#if QT_VERSION < 0x060000
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif
#endif
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
netRequest.setRawHeader("Accept", "text/html");
@ -138,7 +137,9 @@ void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int
QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, currentPage));
#if QT_VERSION >= 0x050600
#if QT_VERSION < 0x060000
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif
#endif
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
netRequest.setRawHeader("Accept", "application/json");

View File

@ -35,9 +35,11 @@ QMap<QString, QString> GlobalString::getGlobalMap()
{
QMap<QString, QString> globalMap;
QSettings globalFile(getLanguageFile(), QSettings::IniFormat);
#if QT_VERSION < 0x060000
globalFile.setIniCodec("UTF-8");
#endif
globalFile.beginGroup("Global");
for (QString globalStr : globalFile.childKeys())
for (const QString &globalStr : globalFile.childKeys())
{
globalMap[globalStr] = globalFile.value(globalStr, globalStr).toString();
}
@ -49,7 +51,9 @@ QString GlobalString::getString(QString valueStr, bool *ok)
{
QString globalString = valueStr;
QSettings globalFile(getLanguageFile(), QSettings::IniFormat);
#if QT_VERSION < 0x060000
globalFile.setIniCodec("UTF-8");
#endif
globalFile.beginGroup("Global");
QStringList globalStrList = globalFile.childKeys();
if (globalStrList.contains(valueStr))

View File

@ -16,10 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "ImportDialog.h"
#include "ui_ImportDialog.h"
#include "SnapmaticPicture.h"
#include "SidebarGenerator.h"
#include "StandardPaths.h"
#include "ImportDialog.h"
#include "imagecropper.h"
#include "AppEnv.h"
#include "config.h"
@ -39,8 +40,6 @@
#include <QRgb>
// IMAGES VALUES
#define snapmaticResolutionW 960
#define snapmaticResolutionH 536
#define snapmaticAvatarResolution 470
#define snapmaticAvatarPlacementW 145
#define snapmaticAvatarPlacementH 66
@ -139,7 +138,8 @@ void ImportDialog::processImage()
{
if (workImage.isNull()) return;
QImage snapmaticImage = workImage;
QPixmap snapmaticPixmap(snapmaticResolutionW, snapmaticResolutionH);
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
QPixmap snapmaticPixmap(snapmaticResolution);
snapmaticPixmap.fill(selectedColour);
QPainter snapmaticPainter(&snapmaticPixmap);
qreal screenRatioPR = AppEnv::screenRatioPR();
@ -149,21 +149,21 @@ void ImportDialog::processImage()
{
int diffWidth = 0;
int diffHeight = 0;
if (backImage.width() != snapmaticResolutionW)
if (backImage.width() != snapmaticResolution.width())
{
diffWidth = snapmaticResolutionW - backImage.width();
diffWidth = snapmaticResolution.width() - backImage.width();
diffWidth = diffWidth / 2;
}
else if (backImage.height() != snapmaticResolutionH)
else if (backImage.height() != snapmaticResolution.height())
{
diffHeight = snapmaticResolutionH - backImage.height();
diffHeight = snapmaticResolution.height() - backImage.height();
diffHeight = diffHeight / 2;
}
snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, backImage);
}
else
{
snapmaticPainter.drawImage(0, 0, QImage(backImage).scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
snapmaticPainter.drawImage(0, 0, QImage(backImage).scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
if (ui->cbAvatar->isChecked() && ui->cbForceAvatarColour->isChecked())
{
@ -204,21 +204,21 @@ void ImportDialog::processImage()
int diffHeight = 0;
if (!ui->cbIgnore->isChecked())
{
snapmaticImage = snapmaticImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (snapmaticImage.width() != snapmaticResolutionW)
snapmaticImage = snapmaticImage.scaled(snapmaticResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (snapmaticImage.width() != snapmaticResolution.width())
{
diffWidth = snapmaticResolutionW - snapmaticImage.width();
diffWidth = snapmaticResolution.width() - snapmaticImage.width();
diffWidth = diffWidth / 2;
}
else if (snapmaticImage.height() != snapmaticResolutionH)
else if (snapmaticImage.height() != snapmaticResolution.height())
{
diffHeight = snapmaticResolutionH - snapmaticImage.height();
diffHeight = snapmaticResolution.height() - snapmaticImage.height();
diffHeight = diffHeight / 2;
}
}
else
{
snapmaticImage = snapmaticImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
snapmaticImage = snapmaticImage.scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, snapmaticImage);
if (ui->cbWatermark->isChecked()) { processWatermark(&snapmaticPainter); }
@ -575,15 +575,16 @@ QImage ImportDialog::image()
void ImportDialog::setImage(QImage *image_)
{
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
origImage = *image_;
workImage = QImage();
if (image_->width() == image_->height())
{
insideAvatarZone = true;
ui->cbAvatar->setChecked(true);
if (image_->height() > snapmaticResolutionH)
if (image_->height() > snapmaticResolution.height())
{
workImage = image_->scaled(snapmaticResolutionH, snapmaticResolutionH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
workImage = image_->scaled(snapmaticResolution.height(), snapmaticResolution.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
delete image_;
}
else
@ -592,18 +593,18 @@ void ImportDialog::setImage(QImage *image_)
delete image_;
}
}
else if (image_->width() > snapmaticResolutionW && image_->width() > image_->height())
else if (image_->width() > snapmaticResolution.width() && image_->width() > image_->height())
{
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
workImage = image_->scaledToWidth(snapmaticResolutionW, Qt::SmoothTransformation);
workImage = image_->scaledToWidth(snapmaticResolution.width(), Qt::SmoothTransformation);
delete image_;
}
else if (image_->height() > snapmaticResolutionH && image_->height() > image_->width())
else if (image_->height() > snapmaticResolution.height() && image_->height() > image_->width())
{
insideAvatarZone = false;
ui->cbAvatar->setChecked(false);
workImage = image_->scaledToHeight(snapmaticResolutionH, Qt::SmoothTransformation);
workImage = image_->scaledToHeight(snapmaticResolution.height(), Qt::SmoothTransformation);
delete image_;
}
else
@ -788,7 +789,7 @@ fileDialogPreOpen:
QMessageBox::warning(this, QApplication::translate("ProfileInterface", "Import"), QApplication::translate("ProfileInterface", "Can't import %1 because file can't be parsed properly").arg("\""+selectedFileName+"\""));
goto fileDialogPreOpen;
}
backImage = importImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::KeepAspectRatio, Qt::SmoothTransformation);
backImage = importImage.scaled(SnapmaticPicture::getSnapmaticResolution(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
backgroundPath = selectedFile;
ui->labBackgroundImage->setText(tr("Background Image: %1").arg(tr("File", "Background Image: File")));
ui->cmdBackgroundWipe->setVisible(true);

View File

@ -70,9 +70,18 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
#if QT_VERSION >= 0x050200
ui->txtJSON->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
#else
QFont jsonFont = ui->txtJSON->font();
jsonFont.setStyleHint(QFont::Monospace);
jsonFont.setFixedPitch(true);
ui->txtJSON->setFont(jsonFont);
#endif
QFontMetrics fontMetrics(ui->txtJSON->font());
#if QT_VERSION >= 0x050B00
ui->txtJSON->setTabStopDistance(fontMetrics.horizontalAdvance(" "));
#else
ui->txtJSON->setTabStopWidth(fontMetrics.width(" "));
#endif
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonCode.toUtf8());
ui->txtJSON->setStyleSheet("QPlainTextEdit{background-color: rgb(46, 47, 48); color: rgb(238, 231, 172);}");

View File

@ -60,40 +60,10 @@ MapLocationDialog::~MapLocationDialog()
void MapLocationDialog::drawPointOnMap(double xpos_d, double ypos_d)
{
qreal screenRatio = AppEnv::screenRatio();
qreal screenRatioPR = AppEnv::screenRatioPR();
int pointMakerSize = 8 * screenRatio * screenRatioPR;
QPixmap pointMakerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMakerSize, pointMakerSize));
QSize mapPixelSize = QSize(width() * screenRatioPR, height() * screenRatioPR);
int pointMakerHalfSize = pointMakerSize / 2;
long xpos_ms = qRound(xpos_d);
long ypos_ms = qRound(ypos_d);
double xpos_ma = xpos_ms + 4000;
double ypos_ma = ypos_ms + 4000;
double xrat = (double)mapPixelSize.width() / 10000;
double yrat = (double)mapPixelSize.height() / 12000;
long xpos_mp = qRound(xpos_ma * xrat);
long ypos_mp = qRound(ypos_ma * yrat);
long xpos_pr = xpos_mp - pointMakerHalfSize;
long ypos_pr = ypos_mp + pointMakerHalfSize;
QPixmap mapPixmap(mapPixelSize);
QPainter mapPainter(&mapPixmap);
mapPainter.drawPixmap(0, 0, mapPixelSize.width(), mapPixelSize.height(), QPixmap(":/img/mappreview.jpg").scaled(mapPixelSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
mapPainter.drawPixmap(xpos_pr, mapPixelSize.height() - ypos_pr, pointMakerSize, pointMakerSize, pointMakerPixmap);
mapPainter.end();
#if QT_VERSION >= 0x050600
mapPixmap.setDevicePixelRatio(screenRatioPR);
#endif
QPalette backgroundPalette;
backgroundPalette.setBrush(backgroundRole(), QBrush(mapPixmap));
setPalette(backgroundPalette);
ui->labPos->setText(tr("X: %1\nY: %2", "X and Y position").arg(QString::number(xpos_d), QString::number(ypos_d)));
xpos_new = xpos_d;
ypos_new = ypos_d;
ui->labPos->setText(tr("X: %1\nY: %2", "X and Y position").arg(QString::number(xpos_d), QString::number(ypos_d)));
repaint();
}
void MapLocationDialog::on_cmdChange_clicked()
@ -125,6 +95,21 @@ void MapLocationDialog::on_cmdDone_clicked()
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);
}
#else
void MapLocationDialog::updatePosFromEvent(int x, int y)
{
QSize mapPixelSize = size();
@ -138,13 +123,60 @@ void MapLocationDialog::updatePosFromEvent(int x, int y)
double ypos_fp = ypos_rv - 4000;
drawPointOnMap(xpos_fp, ypos_fp);
}
#endif
void MapLocationDialog::paintEvent(QPaintEvent *ev)
{
QPainter painter(this);
qreal screenRatio = AppEnv::screenRatio();
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));
// Paint Marker
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;
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
}
else {
xpos_pr = xpos_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);
QDialog::paintEvent(ev);
}
void MapLocationDialog::mouseMoveEvent(QMouseEvent *ev)
{
if (!changeMode) { ev->ignore(); }
else if (ev->buttons() & Qt::LeftButton)
{
#if QT_VERSION >= 0x060000
updatePosFromEvent(ev->position().x(), ev->position().y());
#else
updatePosFromEvent(ev->x(), ev->y());
#endif
ev->accept();
}
else
@ -158,7 +190,11 @@ void MapLocationDialog::mouseReleaseEvent(QMouseEvent *ev)
if (!changeMode) { ev->ignore(); }
else if (ev->button() == Qt::LeftButton)
{
#if QT_VERSION >= 0x060000
updatePosFromEvent(ev->position().x(), ev->position().y());
#else
updatePosFromEvent(ev->x(), ev->y());
#endif
ev->accept();
}
else

View File

@ -39,6 +39,7 @@ public:
~MapLocationDialog();
protected:
void paintEvent(QPaintEvent *ev);
void mouseMoveEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);
@ -47,7 +48,11 @@ 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:

View File

@ -25,6 +25,11 @@
<property name="windowTitle">
<string>Snapmatic Map Viewer</string>
</property>
<property name="styleSheet">
<string notr="true">QDialog#MapLocationDialog {
background-color: transparent;
}</string>
</property>
<layout class="QVBoxLayout" name="vlMapPreview">
<property name="spacing">
<number>0</number>

111
MessageThread.cpp Normal file
View File

@ -0,0 +1,111 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2020 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "TranslationClass.h"
#include "MessageThread.h"
#include "AppEnv.h"
#include "config.h"
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QEventLoop>
#include <QUrlQuery>
#include <QTimer>
#include <QDebug>
#include <QUrl>
MessageThread::MessageThread(uint cacheId, QObject *parent) : QThread(parent), cacheId(cacheId)
{
threadRunning = true;
}
void MessageThread::run()
{
QEventLoop threadLoop;
QObject::connect(this, SIGNAL(threadTerminated()), &threadLoop, SLOT(quit()));
while (threadRunning) {
{
#ifdef GTA5SYNC_MOTD_WEBURL
QUrl motdWebUrl = QUrl(GTA5SYNC_MOTD_WEBURL);
#else
QUrl motdWebUrl = QUrl("https://motd.syping.de/gta5view-dev/");
#endif
QUrlQuery urlQuery(motdWebUrl);
urlQuery.addQueryItem("code", GTA5SYNC_BUILDCODE);
urlQuery.addQueryItem("cacheid", QString::number(cacheId));
urlQuery.addQueryItem("lang", Translator->getCurrentLanguage());
urlQuery.addQueryItem("version", GTA5SYNC_APPVER);
motdWebUrl.setQuery(urlQuery);
QNetworkAccessManager *netManager = new QNetworkAccessManager();
QNetworkRequest netRequest(motdWebUrl);
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
QNetworkReply *netReply = netManager->get(netRequest);
QEventLoop downloadLoop;
QObject::connect(netManager, SIGNAL(finished(QNetworkReply*)), &downloadLoop, SLOT(quit()));
QObject::connect(this, SIGNAL(threadTerminated()), &threadLoop, SLOT(quit()));
QTimer::singleShot(60000, &downloadLoop, SLOT(quit()));
downloadLoop.exec();
if (netReply->isFinished()) {
QByteArray jsonContent = netReply->readAll();
QString headerData = QString::fromUtf8(netReply->rawHeader("gta5view"));
if (!headerData.isEmpty()) {
QMap<QString,QString> headerMap;
const QStringList headerVarList = headerData.split(';');
for (QString headerVar : headerVarList) {
QStringList varValueList = headerVar.split('=');
if (varValueList.length() >= 2) {
const QString variable = varValueList.at(0).trimmed();
varValueList.removeFirst();
const QString value = varValueList.join('=');
headerMap.insert(variable, value);
}
}
if (headerMap.value("update", "false") == "true") {
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonContent);
emit messagesArrived(jsonDocument.object());
}
if (headerMap.contains("cache")) {
bool uintOk;
uint cacheVal = headerMap.value("cache").toUInt(&uintOk);
if (uintOk) {
cacheId = cacheVal;
emit updateCacheId(cacheId);
}
}
}
}
delete netReply;
delete netManager;
}
QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
threadLoop.exec();
}
}
void MessageThread::terminateThread()
{
threadRunning = false;
emit threadTerminated();
}

48
MessageThread.h Normal file
View File

@ -0,0 +1,48 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2020 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifndef MESSAGETHREAD_H
#define MESSAGETHREAD_H
#include <QJsonObject>
#include <QObject>
#include <QThread>
class MessageThread : public QThread
{
Q_OBJECT
public:
explicit MessageThread(uint cacheId, QObject *parent = 0);
public slots:
void terminateThread();
private:
bool threadRunning;
uint cacheId;
protected:
void run();
signals:
void messagesArrived(const QJsonObject &messageObject);
void updateCacheId(uint cacheId);
void threadTerminated();
};
#endif // MESSAGETHREAD_H

View File

@ -16,9 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "OptionsDialog.h"
#include "ui_OptionsDialog.h"
#include "TranslationClass.h"
#include "SnapmaticPicture.h"
#include "OptionsDialog.h"
#include "StandardPaths.h"
#include "UserInterface.h"
#include "AppEnv.h"
@ -74,7 +75,7 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
int desktopSizeHeight = desktopResolution.height();
#endif
aspectRatio = Qt::KeepAspectRatio;
defExportSize = QSize(960, 536);
defExportSize = SnapmaticPicture::getSnapmaticResolution();
cusExportSize = defExportSize;
defaultQuality = 100;
customQuality = 100;
@ -136,24 +137,33 @@ OptionsDialog::~OptionsDialog()
void OptionsDialog::setupTreeWidget()
{
for (QString playerIDStr : profileDB->getPlayers())
{
bool ok;
int playerID = playerIDStr.toInt(&ok);
if (ok)
const QStringList players = profileDB->getPlayers();
if (players.length() != 0) {
QStringList::const_iterator it = players.constBegin();
QStringList::const_iterator end = players.constEnd();
while (it != end)
{
QString playerName = profileDB->getPlayerName(playerID);
bool ok;
int playerID = it->toInt(&ok);
if (ok)
{
QString playerName = profileDB->getPlayerName(playerID);
QStringList playerTreeViewList;
playerTreeViewList += playerIDStr;
playerTreeViewList += playerName;
QStringList playerTreeViewList;
playerTreeViewList += *it;
playerTreeViewList += playerName;
QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList);
ui->twPlayers->addTopLevelItem(playerItem);
playerItems += playerItem;
QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList);
ui->twPlayers->addTopLevelItem(playerItem);
playerItems += playerItem;
}
it++;
}
ui->twPlayers->sortItems(1, Qt::AscendingOrder);
}
else {
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabPlayers));
}
ui->twPlayers->sortItems(1, Qt::AscendingOrder);
}
void OptionsDialog::setupLanguageBox()
@ -165,7 +175,7 @@ void OptionsDialog::setupLanguageBox()
QString cbSysStr = tr("%1 (Language priority)", "First language a person can talk with a different person/application. \"Native\" or \"Not Native\".").arg(tr("System",
"System in context of System default"));
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
QString cbAutoStr;
if (AppEnv::getGameLanguage(AppEnv::getGameVersion()) != GameLanguage::Undefined)
{
@ -292,7 +302,7 @@ void OptionsDialog::setupInterfaceSettings()
settings->beginGroup("Startup");
bool alwaysUseMessageFont = settings->value("AlwaysUseMessageFont", false).toBool();
ui->cbAlwaysUseMessageFont->setChecked(alwaysUseMessageFont);
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
if (QSysInfo::windowsVersion() >= 0x0080)
{
ui->gbFont->setVisible(false);
@ -358,10 +368,12 @@ void OptionsDialog::applySettings()
settings->setValue("Language", ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()));
settings->setValue("AreaLanguage", ui->cbAreaLanguage->itemData(ui->cbAreaLanguage->currentIndex()));
#endif
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
settings->setValue("NavigationBar", ui->cbSnapmaticNavigationBar->isChecked());
#endif
#else
settings->setValue("NavigationBar", ui->cbSnapmaticNavigationBar->isChecked());
#endif
settings->endGroup();
@ -615,7 +627,7 @@ void OptionsDialog::setupWindowsGameSettings()
{
#ifdef GTA5SYNC_GAME
GameVersion gameVersion = AppEnv::getGameVersion();
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
if (gameVersion != GameVersion::NoVersion)
{
if (gameVersion == GameVersion::SocialClubVersion)
@ -712,7 +724,7 @@ void OptionsDialog::setupCustomGTAFolder()
void OptionsDialog::setupSnapmaticPictureViewer()
{
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
settings->beginGroup("Interface");
ui->cbSnapmaticNavigationBar->setChecked(settings->value("NavigationBar", true).toBool());
@ -722,8 +734,9 @@ void OptionsDialog::setupSnapmaticPictureViewer()
ui->gbSnapmaticPictureViewer->setVisible(false);
#endif
#else
ui->cbSnapmaticNavigationBar->setVisible(false);
ui->gbSnapmaticPictureViewer->setVisible(false);
settings->beginGroup("Interface");
ui->cbSnapmaticNavigationBar->setChecked(settings->value("NavigationBar", true).toBool());
settings->endGroup();
#endif
}

View File

@ -33,7 +33,11 @@
#include "AppEnv.h"
#include "config.h"
#ifdef GTA5SYNC_WIN
#if QT_VERSION < 0x060000
#include <QDesktopWidget>
#endif
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
#include <QtWinExtras/QtWin>
#include <QtWinExtras/QWinEvent>
@ -41,7 +45,6 @@
#endif
#include <QStringBuilder>
#include <QDesktopWidget>
#include <QJsonDocument>
#include <QApplication>
#include <QFontMetrics>
@ -80,7 +83,11 @@
#define picPath picture->getPictureFilePath()
#define picTitl StringParser::escapeString(picture->getPictureTitle())
#define plyrsList picture->getSnapmaticProperties().playersList
#if QT_VERSION >= 0x060000
#define created QLocale().toString(picture->getSnapmaticProperties().createdDateTime, QLocale::ShortFormat)
#else
#define created picture->getSnapmaticProperties().createdDateTime.toString(Qt::DefaultLocaleShortDate)
#endif
PictureDialog::PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) :
QDialog(parent), profileDB(profileDB), crewDB(crewDB),
@ -135,12 +142,16 @@ void PictureDialog::setupPictureDialog()
smpic = nullptr;
crewStr = "";
// Get Snapmatic Resolution
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
QSize windowResolution = QSize(snapmaticResolution.width() / 2, snapmaticResolution.height() / 2);
// Avatar area
qreal screenRatio = AppEnv::screenRatio();
qreal screenRatioPR = AppEnv::screenRatioPR();
if (screenRatio != 1 || screenRatioPR != 1)
{
avatarAreaPicture = QImage(":/img/avatararea.png").scaledToHeight(536 * screenRatio * screenRatioPR, Qt::FastTransformation);
avatarAreaPicture = QImage(":/img/avatararea.png").scaledToHeight(windowResolution.height() * screenRatio * screenRatioPR, Qt::FastTransformation);
}
else
{
@ -151,7 +162,7 @@ void PictureDialog::setupPictureDialog()
avatarSize = 470;
// DPI calculation (picture)
ui->labPicture->setFixedSize(960 * screenRatio, 536 * screenRatio);
ui->labPicture->setFixedSize(windowResolution.width() * screenRatio, windowResolution.height() * screenRatio);
ui->labPicture->setFocusPolicy(Qt::StrongFocus);
ui->labPicture->setScaledContents(true);
@ -199,13 +210,13 @@ void PictureDialog::setupPictureDialog()
ui->jsonLayout->setContentsMargins(4 * screenRatio, 10 * screenRatio, 4 * screenRatio, 4 * screenRatio);
// Pre-adapt window for DPI
setFixedWidth(960 * screenRatio);
setFixedHeight(536 * screenRatio);
setFixedWidth(windowResolution.width() * screenRatio);
setFixedHeight(windowResolution.height() * screenRatio);
}
PictureDialog::~PictureDialog()
{
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
if (naviEnabled)
{
@ -216,6 +227,15 @@ PictureDialog::~PictureDialog()
delete layout()->menuBar();
}
#endif
#else
if (naviEnabled)
{
for (QObject *obj : layout()->menuBar()->children())
{
delete obj;
}
delete layout()->menuBar();
}
#endif
for (QObject *obj : manageMenu->children())
{
@ -236,139 +256,42 @@ void PictureDialog::closeEvent(QCloseEvent *ev)
void PictureDialog::addPreviousNextButtons()
{
// Windows Vista additions
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
QToolBar *uiToolbar = new QToolBar("Picture Toolbar", this);
uiToolbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
uiToolbar->setObjectName("uiToolbar");
uiToolbar->setObjectName("UiToolbar");
uiToolbar->addAction(QIcon(":/img/back.svgz"), "", this, SLOT(previousPictureRequestedSlot()));
uiToolbar->addAction(QIcon(":/img/next.svgz"), "", this, SLOT(nextPictureRequestedSlot()));
layout()->setMenuBar(uiToolbar);
naviEnabled = true;
#endif
#endif
}
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
#ifdef GTA5SYNC_APV
bool PictureDialog::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
*result = 0;
MSG *msg = static_cast<MSG*>(message);
LRESULT lRet = 0;
if (naviEnabled && QtWin::isCompositionEnabled())
{
if (msg->message == WM_NCCALCSIZE && msg->wParam == TRUE)
{
NCCALCSIZE_PARAMS *pncsp = reinterpret_cast<NCCALCSIZE_PARAMS*>(msg->lParam);
int sideBorderSize = ((frameSize().width() - size().width()) / 2);
#ifdef GTA5SYNC_APV_SIDE
int buttomBorderSize = sideBorderSize;
#else
int buttomBorderSize = (frameSize().height() - size().height());
QToolBar *uiToolbar = new QToolBar("Picture Toolbar", this);
#if QT_VERSION < 0x050600
qreal screenRatio = AppEnv::screenRatio();
if (screenRatio != 1) {
QSize iconSize = uiToolbar->iconSize();
uiToolbar->setIconSize(QSize(iconSize.width() * screenRatio, iconSize.height() * screenRatio));
}
#endif
uiToolbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
uiToolbar->setObjectName("UiToolbar");
uiToolbar->addAction(QIcon(":/img/back.svgz"), "", this, SLOT(previousPictureRequestedSlot()));
uiToolbar->addAction(QIcon(":/img/next.svgz"), "", this, SLOT(nextPictureRequestedSlot()));
layout()->setMenuBar(uiToolbar);
naviEnabled = true;
#endif
pncsp->rgrc[0].left += sideBorderSize;
pncsp->rgrc[0].right -= sideBorderSize;
pncsp->rgrc[0].bottom -= buttomBorderSize;
}
else if (msg->message == WM_NCHITTEST)
{
int CLOSE_BUTTON_ID = 20;
lRet = HitTestNCA(msg->hwnd, msg->lParam);
DwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lRet);
*result = lRet;
if (lRet != CLOSE_BUTTON_ID) { return QWidget::nativeEvent(eventType, message, result); }
}
else
{
return QWidget::nativeEvent(eventType, message, result);
}
}
else
{
return QWidget::nativeEvent(eventType, message, result);
}
return true;
}
LRESULT PictureDialog::HitTestNCA(HWND hWnd, LPARAM lParam)
{
int LEFTEXTENDWIDTH = 0;
int RIGHTEXTENDWIDTH = 0;
int BOTTOMEXTENDWIDTH = 0;
int TOPEXTENDWIDTH = layout()->menuBar()->height();
POINT ptMouse = {(int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)};
RECT rcWindow;
GetWindowRect(hWnd, &rcWindow);
RECT rcFrame = {};
AdjustWindowRectEx(&rcFrame, WS_OVERLAPPEDWINDOW & ~WS_CAPTION, FALSE, NULL);
USHORT uRow = 1;
USHORT uCol = 1;
bool fOnResizeBorder = false;
if (ptMouse.y >= rcWindow.top && ptMouse.y < rcWindow.top + TOPEXTENDWIDTH)
{
fOnResizeBorder = (ptMouse.y < (rcWindow.top - rcFrame.top));
uRow = 0;
}
else if (ptMouse.y < rcWindow.bottom && ptMouse.y >= rcWindow.bottom - BOTTOMEXTENDWIDTH)
{
uRow = 2;
}
if (ptMouse.x >= rcWindow.left && ptMouse.x < rcWindow.left + LEFTEXTENDWIDTH)
{
uCol = 0;
}
else if (ptMouse.x < rcWindow.right && ptMouse.x >= rcWindow.right - RIGHTEXTENDWIDTH)
{
uCol = 2;
}
LRESULT hitTests[3][3] =
{
{ HTTOPLEFT, fOnResizeBorder ? HTTOP : HTCAPTION, HTTOPRIGHT },
{ HTLEFT, HTNOWHERE, HTRIGHT },
{ HTBOTTOMLEFT, HTBOTTOM, HTBOTTOMRIGHT },
};
return hitTests[uRow][uCol];
}
void PictureDialog::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event)
// int newDialogHeight = (ui->labPicture->pixmap()->height() / AppEnv::screenRatioPR());
// newDialogHeight = newDialogHeight + ui->jsonFrame->height();
// if (naviEnabled) newDialogHeight = newDialogHeight + layout()->menuBar()->height();
// int buttomBorderSize = (frameSize().height() - size().height());
// int sideBorderSize = ((frameSize().width() - size().width()) / 2);
// int brokenDialogHeight = newDialogHeight + (buttomBorderSize - sideBorderSize);
// if (event->size().height() == brokenDialogHeight)
// {
// qDebug() << "BROKEN 1";
// setGeometry(geometry().x(), geometry().y(), width(), newDialogHeight);
// qDebug() << "BROKEN 2";
// event->ignore();
// }
}
#endif
#endif
#endif
void PictureDialog::adaptNewDialogSize(QSize newLabelSize)
{
Q_UNUSED(newLabelSize)
#if QT_VERSION >= 0x050F00
int newDialogHeight = SnapmaticPicture::getSnapmaticResolution().height() / 2;
#else
int newDialogHeight = (ui->labPicture->pixmap()->height() / AppEnv::screenRatioPR());
#endif
newDialogHeight = newDialogHeight + ui->jsonFrame->height();
if (naviEnabled) newDialogHeight = newDialogHeight + layout()->menuBar()->height();
setMaximumSize(width(), newDialogHeight);
@ -381,7 +304,7 @@ void PictureDialog::adaptNewDialogSize(QSize newLabelSize)
void PictureDialog::styliseDialog()
{
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
if (QtWin::isCompositionEnabled())
{
@ -403,7 +326,7 @@ void PictureDialog::styliseDialog()
bool PictureDialog::event(QEvent *event)
{
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
if (naviEnabled)
{
@ -488,7 +411,7 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
break;
}
}
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
if (obj != ui->labPicture && naviEnabled)
{
@ -686,10 +609,12 @@ void PictureDialog::renderPicture()
{
if (overlayEnabled)
{
QPixmap shownImagePixmap(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR);
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
QSize windowResolution = QSize(snapmaticResolution.width() / 2, snapmaticResolution.height() / 2);
QPixmap shownImagePixmap(windowResolution.width() * screenRatio * screenRatioPR, windowResolution.height() * screenRatio * screenRatioPR);
shownImagePixmap.fill(Qt::transparent);
QPainter shownImagePainter(&shownImagePixmap);
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(windowResolution.width() * screenRatio * screenRatioPR, windowResolution.height() * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
shownImagePainter.drawImage(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, overlayTempImage);
shownImagePainter.end();
#if QT_VERSION >= 0x050600
@ -699,10 +624,12 @@ void PictureDialog::renderPicture()
}
else
{
QPixmap shownImagePixmap(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR);
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
QSize windowResolution = QSize(snapmaticResolution.width() / 2, snapmaticResolution.height() / 2);
QPixmap shownImagePixmap(windowResolution.width() * screenRatio * screenRatioPR, windowResolution.height() * screenRatio * screenRatioPR);
shownImagePixmap.fill(Qt::transparent);
QPainter shownImagePainter(&shownImagePixmap);
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(windowResolution.width() * screenRatio * screenRatioPR, windowResolution.height() * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
shownImagePainter.end();
#if QT_VERSION >= 0x050600
shownImagePixmap.setDevicePixelRatio(screenRatioPR);
@ -713,15 +640,17 @@ void PictureDialog::renderPicture()
else
{
// Generating Avatar Preview
QPixmap avatarPixmap(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR);
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
QSize windowResolution = QSize(snapmaticResolution.width() / 2, snapmaticResolution.height() / 2);
QPixmap avatarPixmap(windowResolution.width() * screenRatio * screenRatioPR, windowResolution.height() * screenRatio * screenRatioPR);
QPainter snapPainter(&avatarPixmap);
QFont snapPainterFont;
snapPainterFont.setPixelSize(12 * screenRatio * screenRatioPR);
snapPainter.drawImage(0, 0, snapmaticPicture.scaled(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
snapPainter.drawImage(0, 0, snapmaticPicture.scaled(windowResolution.width() * screenRatio * screenRatioPR, windowResolution.height() * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
snapPainter.drawImage(0, 0, avatarAreaPicture);
snapPainter.setPen(QColor::fromRgb(255, 255, 255, 255));
snapPainter.setFont(snapPainterFont);
snapPainter.drawText(QRect(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, 140 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR), Qt::AlignLeft | Qt::TextWordWrap, tr("Avatar Preview Mode\nPress 1 for Default View"));
snapPainter.drawText(QRect(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, 140 * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR), Qt::AlignLeft | Qt::TextWordWrap, tr("Avatar Preview Mode\nPress 1 for Default View"));
snapPainter.end();
#if QT_VERSION >= 0x050600
avatarPixmap.setDevicePixelRatio(screenRatioPR);
@ -773,7 +702,7 @@ QString PictureDialog::generatePlayersString()
QString plyrsStr;
if (playersList.length() >= 1)
{
for (const QString player : playersList)
for (const QString &player : playersList)
{
const QString playerName = profileDB->getPlayerName(player);
if (player != playerName) {
@ -820,13 +749,17 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button)
{
if (button == Qt::LeftButton)
{
#if QT_VERSION >= 0x060000
QRect desktopRect = QApplication::screenAt(pos())->geometry();
#else
QRect desktopRect = QApplication::desktop()->screenGeometry(this);
#endif
PictureWidget *pictureWidget = new PictureWidget(this); // Work!
pictureWidget->setObjectName("PictureWidget");
#if QT_VERSION >= 0x050600
pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint^Qt::WindowStaysOnTopHint^Qt::MaximizeUsingFullscreenGeometryHint);
pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint^Qt::MaximizeUsingFullscreenGeometryHint);
#else
pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint^Qt::WindowStaysOnTopHint);
pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint);
#endif
pictureWidget->setWindowTitle(windowTitle());
pictureWidget->setStyleSheet("QLabel#pictureLabel{background-color: black;}");
@ -840,7 +773,7 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button)
pictureWidget->move(desktopRect.x(), desktopRect.y());
pictureWidget->resize(desktopRect.width(), desktopRect.height());
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
QtWin::markFullscreenWindow(pictureWidget, true);
#endif

View File

@ -29,14 +29,6 @@
#include <QEvent>
#include <QMenu>
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
#ifdef GTA5SYNC_APV
#include <dwmapi.h>
#endif
#endif
#endif
namespace Ui {
class PictureDialog;
}
@ -98,15 +90,6 @@ protected:
bool eventFilter(QObject *obj, QEvent *ev);
void mousePressEvent(QMouseEvent *ev);
bool event(QEvent *event);
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
#ifdef GTA5SYNC_APV
bool nativeEvent(const QByteArray &eventType, void *message, long *result);
LRESULT HitTestNCA(HWND hWnd, LPARAM lParam);
void resizeEvent(QResizeEvent *event);
#endif
#endif
#endif
private:
QString generateCrewString();
@ -136,7 +119,7 @@ private:
int avatarLocY;
int avatarSize;
QMenu *manageMenu;
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
QPoint dragPosition;
bool dragStart;

View File

@ -23,19 +23,19 @@
#include "StandardPaths.h"
#include "SidebarGenerator.h"
#include <QStringBuilder>
#include <QDesktopWidget>
#include <QApplication>
#include <QMessageBox>
#include <QFileDialog>
#include <QSettings>
#include <QRegExp>
#include <QDebug>
#if QT_VERSION < 0x050000
#include <QDesktopWidget>
#endif
#if QT_VERSION >= 0x050000
#include <QSaveFile>
#include <QScreen>
#else
#include <QDesktopWidget>
#endif
PictureExport::PictureExport()

View File

@ -19,7 +19,6 @@
#include "PictureDialog.h"
#include "PictureWidget.h"
#include "UiModLabel.h"
#include <QDesktopWidget>
#include <QApplication>
#include <QHBoxLayout>
#include <QKeyEvent>
@ -27,6 +26,10 @@
#include <QEvent>
#include <QDebug>
#if QT_VERSION < 0x060000
#include <QDesktopWidget>
#endif
PictureWidget::PictureWidget(QWidget *parent) : QDialog(parent)
{
installEventFilter(this);
@ -98,12 +101,21 @@ void PictureWidget::setImage(QImage image_)
void PictureWidget::updateWindowSize(int screenID)
{
#if QT_VERSION >= 0x060000
Q_UNUSED(screenID)
QRect desktopRect = QApplication::screenAt(pos())->geometry();
move(desktopRect.x(), desktopRect.y());
resize(desktopRect.width(), desktopRect.height());
showFullScreen();
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(desktopRect.width(), desktopRect.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
#else
if (screenID == QApplication::desktop()->screenNumber(this))
{
QRect desktopRect = QApplication::desktop()->screenGeometry(this);
this->move(desktopRect.x(), desktopRect.y());
this->resize(desktopRect.width(), desktopRect.height());
this->showFullScreen();
move(desktopRect.x(), desktopRect.y());
resize(desktopRect.width(), desktopRect.height());
showFullScreen();
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(desktopRect.width(), desktopRect.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
}
#endif
}

View File

@ -73,12 +73,32 @@ PlayerListDialog::PlayerListDialog(QStringList players, ProfileDatabase *profile
// Set Icon for Manage Buttons
if (QIcon::hasThemeIcon("go-previous") && QIcon::hasThemeIcon("go-next") && QIcon::hasThemeIcon("list-add"))
{
#if QT_VERSION < 0x050600
qreal screenRatio = AppEnv::screenRatio();
if (screenRatio != 1) {
QSize iconSize = ui->cmdMakeAv->iconSize();
iconSize = QSize(iconSize.width() * screenRatio, iconSize.height() * screenRatio);
ui->cmdMakeAv->setIconSize(iconSize);
ui->cmdMakeSe->setIconSize(iconSize);
ui->cmdMakeAd->setIconSize(iconSize);
}
#endif
ui->cmdMakeAv->setIcon(QIcon::fromTheme("go-previous"));
ui->cmdMakeSe->setIcon(QIcon::fromTheme("go-next"));
ui->cmdMakeAd->setIcon(QIcon::fromTheme("list-add"));
}
else
{
#if QT_VERSION < 0x050600
qreal screenRatio = AppEnv::screenRatio();
if (screenRatio != 1) {
QSize iconSize = ui->cmdMakeAv->iconSize();
iconSize = QSize(iconSize.width() * screenRatio, iconSize.height() * screenRatio);
ui->cmdMakeAv->setIconSize(iconSize);
ui->cmdMakeSe->setIconSize(iconSize);
ui->cmdMakeAd->setIconSize(iconSize);
}
#endif
ui->cmdMakeAv->setIcon(QIcon(":/img/back.svgz"));
ui->cmdMakeSe->setIcon(QIcon(":/img/next.svgz"));
ui->cmdMakeAd->setIcon(QIcon(":/img/add.svgz"));

View File

@ -52,7 +52,6 @@
#include <QClipboard>
#include <QFileInfo>
#include <QPainter>
#include <QRegExp>
#include <QAction>
#include <QDebug>
#include <QColor>
@ -264,14 +263,14 @@ void ProfileInterface::insertSnapmaticIPI(QWidget *widget)
QStringList widgetsKeyList = widgets.values();
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
#if QT_VERSION >= 0x050600
qSort(pictureKeyList.rbegin(), pictureKeyList.rend());
std::sort(pictureKeyList.rbegin(), pictureKeyList.rend());
#else
qSort(pictureKeyList.begin(), pictureKeyList.end(), qGreater<QString>());
#endif
int picIndex = pictureKeyList.indexOf(QRegExp(widgetKey));
int picIndex = pictureKeyList.indexOf(widgetKey);
ui->vlSnapmatic->insertWidget(picIndex, proWidget);
qApp->processEvents();
QApplication::processEvents();
ui->saProfile->ensureWidgetVisible(proWidget, 0, 0);
}
}
@ -284,11 +283,15 @@ void ProfileInterface::insertSavegameIPI(QWidget *widget)
QString widgetKey = widgets[proWidget];
QStringList widgetsKeyList = widgets.values();
QStringList savegameKeyList = widgetsKeyList.filter("SGD", Qt::CaseSensitive);
#if QT_VERSION >= 0x050600
std::sort(savegameKeyList.begin(), savegameKeyList.end());
#else
qSort(savegameKeyList.begin(), savegameKeyList.end());
int sgdIndex = savegameKeyList.indexOf(QRegExp(widgetKey));
#endif
int sgdIndex = savegameKeyList.indexOf(widgetKey);
ui->vlSavegame->insertWidget(sgdIndex, proWidget);
qApp->processEvents();
QApplication::processEvents();
ui->saProfile->ensureWidgetVisible(proWidget, 0, 0);
}
}
@ -303,7 +306,7 @@ void ProfileInterface::dialogNextPictureRequested(QWidget *dialog)
QStringList widgetsKeyList = widgets.values();
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
#if QT_VERSION >= 0x050600
qSort(pictureKeyList.rbegin(), pictureKeyList.rend());
std::sort(pictureKeyList.rbegin(), pictureKeyList.rend());
#else
qSort(pictureKeyList.begin(), pictureKeyList.end(), qGreater<QString>());
#endif
@ -314,7 +317,7 @@ void ProfileInterface::dialogNextPictureRequested(QWidget *dialog)
}
else
{
picIndex = pictureKeyList.indexOf(QRegExp(widgetKey));
picIndex = pictureKeyList.indexOf(widgetKey);
}
picIndex++;
if (pictureKeyList.length() > picIndex)
@ -338,7 +341,7 @@ void ProfileInterface::dialogPreviousPictureRequested(QWidget *dialog)
QStringList widgetsKeyList = widgets.values();
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
#if QT_VERSION >= 0x050600
qSort(pictureKeyList.rbegin(), pictureKeyList.rend());
std::sort(pictureKeyList.rbegin(), pictureKeyList.rend());
#else
qSort(pictureKeyList.begin(), pictureKeyList.end(), qGreater<QString>());
#endif
@ -349,7 +352,7 @@ void ProfileInterface::dialogPreviousPictureRequested(QWidget *dialog)
}
else
{
picIndex = pictureKeyList.indexOf(QRegExp(widgetKey));
picIndex = pictureKeyList.indexOf(widgetKey);
}
if (picIndex > 0)
{
@ -369,7 +372,12 @@ void ProfileInterface::sortingProfileInterface()
ui->vlSnapmatic->setEnabled(false);
QStringList widgetsKeyList = widgets.values();
#if QT_VERSION >= 0x050600
std::sort(widgetsKeyList.begin(), widgetsKeyList.end());
#else
qSort(widgetsKeyList.begin(), widgetsKeyList.end());
#endif
for (QString widgetKey : widgetsKeyList)
{
@ -387,7 +395,7 @@ void ProfileInterface::sortingProfileInterface()
ui->vlSavegame->setEnabled(true);
ui->vlSnapmatic->setEnabled(true);
qApp->processEvents();
QApplication::processEvents();
}
void ProfileInterface::profileLoaded_p()
@ -689,7 +697,8 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
return false;
}
QString customImageTitle;
QPixmap snapmaticPixmap(960, 536);
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
QPixmap snapmaticPixmap(snapmaticResolution);
snapmaticPixmap.fill(Qt::black);
QPainter snapmaticPainter(&snapmaticPixmap);
if (snapmaticImage.height() == snapmaticImage.width())
@ -716,15 +725,15 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
// Picture mode
int diffWidth = 0;
int diffHeight = 0;
snapmaticImage = snapmaticImage.scaled(960, 536, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (snapmaticImage.width() != 960)
snapmaticImage = snapmaticImage.scaled(snapmaticResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (snapmaticImage.width() != snapmaticResolution.height())
{
diffWidth = 960 - snapmaticImage.width();
diffWidth = snapmaticResolution.height() - snapmaticImage.width();
diffWidth = diffWidth / 2;
}
else if (snapmaticImage.height() != 536)
else if (snapmaticImage.height() != snapmaticResolution.width())
{
diffHeight = 536 - snapmaticImage.height();
diffHeight = snapmaticResolution.width() - snapmaticImage.height();
diffHeight = diffHeight / 2;
}
snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, snapmaticImage);
@ -751,7 +760,11 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
cEnough++;
}
spJson.createdDateTime = importDateTime;
#if QT_VERSION >= 0x060000
spJson.createdTimestamp = QString::number(spJson.createdDateTime.toSecsSinceEpoch()).toUInt();
#else
spJson.createdTimestamp = spJson.createdDateTime.toTime_t();
#endif
picture->setSnapmaticProperties(spJson);
picture->setPicFileName(QString("PRDR3%1").arg(QString::number(spJson.uid)));
picture->setPictureTitle(customImageTitle);
@ -805,7 +818,11 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
cEnough++;
}
spJson.createdDateTime = importDateTime;
#if QT_VERSION >= 0x060000
spJson.createdTimestamp = QString::number(spJson.createdDateTime.toSecsSinceEpoch()).toUInt();
#else
spJson.createdTimestamp = spJson.createdDateTime.toTime_t();
#endif
picture->setSnapmaticProperties(spJson);
picture->setPicFileName(QString("PRDR3%1").arg(QString::number(spJson.uid)));
picture->setPictureTitle(importDialog->getImageTitle());
@ -1050,7 +1067,11 @@ bool ProfileInterface::importImage(QImage *snapmaticImage, QDateTime importDateT
cEnough++;
}
spJson.createdDateTime = importDateTime;
#if QT_VERSION >= 0x060000
spJson.createdTimestamp = QString::number(spJson.createdDateTime.toSecsSinceEpoch()).toUInt();
#else
spJson.createdTimestamp = spJson.createdDateTime.toTime_t();
#endif
picture->setSnapmaticProperties(spJson);
picture->setPicFileName(QString("PRDR3%1").arg(QString::number(spJson.uid)));
picture->setPictureTitle(importDialog->getImageTitle());
@ -1094,7 +1115,11 @@ bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, bool wa
// Update Snapmatic uid
snapmaticProperties.uid = getRandomUid();
snapmaticProperties.createdDateTime = QDateTime::currentDateTime();
#if QT_VERSION >= 0x060000
snapmaticProperties.createdTimestamp = QString::number(snapmaticProperties.createdDateTime.toSecsSinceEpoch()).toUInt();
#else
snapmaticProperties.createdTimestamp = snapmaticProperties.createdDateTime.toTime_t();
#endif
bool fExists = QFile::exists(profileFolder % "/PRDR3" % QString::number(snapmaticProperties.uid));
bool fExistsBackup = QFile::exists(profileFolder % "/PRDR3" % QString::number(snapmaticProperties.uid) % ".bak");
bool fExistsHidden = QFile::exists(profileFolder % "/PRDR3" % QString::number(snapmaticProperties.uid) % ".hidden");
@ -1131,7 +1156,11 @@ bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, bool wa
// Update Snapmatic uid
snapmaticProperties.uid = getRandomUid();
snapmaticProperties.createdDateTime = QDateTime::currentDateTime();
#if QT_VERSION >= 0x060000
snapmaticProperties.createdTimestamp = QString::number(snapmaticProperties.createdDateTime.toSecsSinceEpoch()).toUInt();
#else
snapmaticProperties.createdTimestamp = snapmaticProperties.createdDateTime.toTime_t();
#endif
bool fExists = QFile::exists(profileFolder % "/PRDR3" % QString::number(snapmaticProperties.uid));
bool fExistsBackup = QFile::exists(profileFolder % "/PRDR3" % QString::number(snapmaticProperties.uid) % ".bak");
bool fExistsHidden = QFile::exists(profileFolder % "/PRDR3" % QString::number(snapmaticProperties.uid) % ".hidden");
@ -1304,7 +1333,7 @@ void ProfileInterface::exportSelected()
QString ExportPreSpan;
QString ExportPostSpan;
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
ExportPreSpan = "<span style=\"color: #003399; font-size: 12pt\">";
ExportPostSpan = "</span>";
#else
@ -1627,7 +1656,7 @@ void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev)
contextMenuOpened = true;
contextMenu.exec(ev->globalPos());
contextMenuOpened = false;
hoverProfileWidgetCheck();
QTimer::singleShot(0, this, SLOT(hoverProfileWidgetCheck()));
}
void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev)
@ -1660,7 +1689,7 @@ void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev)
contextMenuOpened = true;
contextMenu.exec(ev->globalPos());
contextMenuOpened = false;
hoverProfileWidgetCheck();
QTimer::singleShot(0, this, SLOT(hoverProfileWidgetCheck()));
}
void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
@ -1781,19 +1810,23 @@ bool ProfileInterface::eventFilter(QObject *watched, QEvent *event)
return true;
}
}
else if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::WindowActivate)
else if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease)
{
if ((watched->objectName() == "SavegameWidget" || watched->objectName() == "SnapmaticWidget") && isProfileLoaded)
{
ProfileWidget *pWidget = nullptr;
for (ProfileWidget *widget : widgets.keys())
QMap<ProfileWidget*, QString>::const_iterator it = widgets.constBegin();
QMap<ProfileWidget*, QString>::const_iterator end = widgets.constEnd();
while (it != end)
{
ProfileWidget *widget = it.key();
QPoint mousePos = widget->mapFromGlobal(QCursor::pos());
if (widget->rect().contains(mousePos))
{
pWidget = widget;
break;
}
it++;
}
if (pWidget != nullptr)
{
@ -1827,7 +1860,7 @@ bool ProfileInterface::eventFilter(QObject *watched, QEvent *event)
}
else if (event->type() == QEvent::WindowDeactivate && isProfileLoaded)
{
if (previousWidget != nullptr)
if (previousWidget != nullptr && watched == previousWidget)
{
previousWidget->setStyleSheet(QLatin1String(""));
previousWidget = nullptr;
@ -1863,13 +1896,17 @@ bool ProfileInterface::eventFilter(QObject *watched, QEvent *event)
void ProfileInterface::hoverProfileWidgetCheck()
{
ProfileWidget *pWidget = nullptr;
for (ProfileWidget *widget : widgets.keys())
QMap<ProfileWidget*, QString>::const_iterator it = widgets.constBegin();
QMap<ProfileWidget*, QString>::const_iterator end = widgets.constEnd();
while (it != end)
{
ProfileWidget *widget = it.key();
if (widget->underMouse())
{
pWidget = widget;
break;
}
it++;
}
if (pWidget != nullptr)
{
@ -2018,7 +2055,7 @@ void ProfileInterface::massTool(MassTool tool)
else
{
picture->emitUpdate();
qApp->processEvents();
QApplication::processEvents();
}
}
pbDialog.close();
@ -2117,7 +2154,7 @@ void ProfileInterface::massTool(MassTool tool)
else
{
picture->emitUpdate();
qApp->processEvents();
QApplication::processEvents();
}
}
pbDialog.close();
@ -2170,7 +2207,7 @@ preSelectionCrewID:
}
if (crewList.contains(QString::number(crewID)))
{
indexNum = crewList.indexOf(QRegExp(QString::number(crewID)));
indexNum = crewList.indexOf(QString::number(crewID));
}
QString newCrew = QInputDialog::getItem(this, QApplication::translate("SnapmaticEditor", "Snapmatic Crew"), QApplication::translate("SnapmaticEditor", "New Snapmatic crew:"), itemList, indexNum, true, &ok, windowFlags()^Qt::Dialog^Qt::WindowMinMaxButtonsHint);
if (ok && !newCrew.isEmpty())
@ -2248,7 +2285,7 @@ preSelectionCrewID:
else
{
picture->emitUpdate();
qApp->processEvents();
QApplication::processEvents();
}
}
pbDialog.close();
@ -2351,7 +2388,7 @@ preSelectionTitle:
else
{
picture->emitUpdate();
qApp->processEvents();
QApplication::processEvents();
}
}
pbDialog.close();

View File

@ -1,4 +1,7 @@
## rdr2view
Red Dead Redemption 2 Savegame and Snapmatic viewer/editor
Red Dead Redemption 2 Savegame and Photo viewer/editor.
rdr2view is ported from [gta5view](https://gta5view.syping.de/).
rdr2view is a port from [gta5view](https://gta5view.syping.de/).
**ATTENTION: rdr2view will not be developed anymore!**
**gta5view 1.11.0 will get support for RDR 2 as soon it's done.**

View File

@ -20,7 +20,6 @@
#include "StringParser.h"
#include "SavegameData.h"
#include <QStringBuilder>
#include <QTextCodec>
#include <QByteArray>
#include <QDebug>
#include <QFile>

View File

@ -23,7 +23,6 @@
#include "StringParser.h"
#include "AppEnv.h"
#include "config.h"
#include <QStringListIterator>
#include <QStringBuilder>
#include <QTextDocument>
#include <QInputDialog>
@ -438,7 +437,7 @@ void SnapmaticEditor::on_labCrew_linkActivated(const QString &link)
}
if (crewList.contains(QString::number(crewID)))
{
indexNum = crewList.indexOf(QRegExp(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())

View File

@ -22,7 +22,6 @@
#include <QJsonObject>
#include <QStringList>
#include <QVariantMap>
#include <QTextCodec>
#include <QJsonArray>
#include <QFileInfo>
#include <QPainter>
@ -33,6 +32,10 @@
#include <QSize>
#include <QFile>
#if QT_VERSION < 0x060000
#include <QTextCodec>
#endif
#if QT_VERSION >= 0x050000
#include <QSaveFile>
#else
@ -106,7 +109,7 @@ void SnapmaticPicture::reset()
jsonStr = QString();
// SNAPMATIC DEFAULTS
#ifdef GTA5SYNC_NOASSIST
#ifdef SNAPMATIC_NODEFAULT
careSnapDefault = false;
#else
careSnapDefault = true;
@ -433,8 +436,8 @@ QString SnapmaticPicture::getSnapmaticHeaderString(const QByteArray &snapmaticHe
QString SnapmaticPicture::getSnapmaticJSONString(const QByteArray &jsonBytes)
{
QByteArray jsonUsefulBytes = jsonBytes;
jsonUsefulBytes.replace('\x00', QString());
jsonUsefulBytes.replace('\x0c', QString());
jsonUsefulBytes.replace('\x00', "");
jsonUsefulBytes.replace('\x0c', "");
return QString::fromUtf8(jsonUsefulBytes.trimmed());
}
@ -464,7 +467,7 @@ 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 (isModernFormat) { picFileName = "PRDR5" % QString::number(localProperties.uid); }
if (isModernFormat) { picFileName = "PRDR3" % QString::number(localProperties.uid); }
picExportFileName = exportStr % "_" % cmpPicTitl;
}
@ -516,7 +519,17 @@ bool SnapmaticPicture::setImage(const QImage &picture)
}
}
}
if (saveSuccess) { return setPictureStream(picByteArray); }
if (saveSuccess) {
saveSuccess = setPictureStream(picByteArray);
if (saveSuccess) {
SnapmaticProperties properties = getSnapmaticProperties();
properties.pictureSize = picture.size();
if (!setSnapmaticProperties(properties)) {
qDebug() << "Failed to refresh Snapmatic properties!";
}
}
return saveSuccess;
}
}
return false;
}
@ -993,7 +1006,11 @@ void SnapmaticPicture::parseJsonContent()
bool timestampOk;
QDateTime createdTimestamp;
localProperties.createdTimestamp = jsonMap["creat"].toUInt(&timestampOk);
#if QT_VERSION >= 0x060000
createdTimestamp.setSecsSinceEpoch(QString::number(localProperties.createdTimestamp).toLongLong());
#else
createdTimestamp.setTime_t(localProperties.createdTimestamp);
#endif
localProperties.createdDateTime = createdTimestamp;
if (!timestampOk) { jsonError = true; }
}
@ -1034,6 +1051,12 @@ void SnapmaticPicture::parseJsonContent()
else { jsonError = true; }
}
// else { jsonIncomplete = true; } // Game release Snapmatic pictures prior May 2015 left out rsedtr, so don't force exists on that one
// RDR 2
if (jsonObject.contains("width") && jsonObject.contains("height")) {
if (jsonObject["width"].isDouble() && jsonObject["height"].isDouble()) { localProperties.pictureSize = QSize(jsonObject["width"].toInt(), jsonObject["height"].toInt()); }
else { jsonError = true; }
}
else { jsonIncomplete = true; }
if (!jsonIncomplete && !jsonError)
{
@ -1080,6 +1103,10 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties properties)
jsonObject["drctr"] = properties.isFromDirector;
jsonObject["rsedtr"] = properties.isFromRSEditor;
// RDR 2
jsonObject["width"] = properties.pictureSize.width();
jsonObject["height"] = properties.pictureSize.height();
jsonDocument.setObject(jsonObject);
if (setJsonStr(QString::fromUtf8(jsonDocument.toJson(QJsonDocument::Compact))))
@ -1417,7 +1444,13 @@ bool SnapmaticPicture::verifyTitleChar(const QChar &titleChar)
QString SnapmaticPicture::parseTitleString(const QByteArray &commitBytes, int maxLength)
{
Q_UNUSED(maxLength)
#if QT_VERSION >= 0x060000
QStringDecoder strDecoder = QStringDecoder(QStringDecoder::Utf16LE);
QString retStr = strDecoder(commitBytes);
retStr = retStr.trimmed();
#else
QString retStr = QTextCodec::codecForName("UTF-16LE")->toUnicode(commitBytes).trimmed();
#endif
retStr.remove(QChar('\x00'));
return retStr;
}

View File

@ -38,6 +38,7 @@ struct SnapmaticProperties {
int size;
int crewID;
int streetID;
QSize pictureSize;
QStringList playersList;
uint createdTimestamp;
QDateTime createdDateTime;
@ -120,7 +121,7 @@ public:
bool setVisible() { return setPictureVisible(); } // Please use setPictureVisible instead
// PREDEFINED PROPERTIES
QSize getSnapmaticResolution();
static QSize getSnapmaticResolution();
// SNAPMATIC DEFAULTS
bool isSnapmaticDefaultsEnforced();

View File

@ -19,7 +19,6 @@
#include "StringParser.h"
#include <QTextDocument>
#include <QLibraryInfo>
#include <QTextCodec>
#include <QByteArray>
#include <QFileInfo>
#include <QString>
@ -49,12 +48,16 @@ QString StringParser::escapeString(const QString &toEscape)
QString StringParser::convertBuildedString(const QString &buildedStr)
{
QString outputStr = buildedStr;
QByteArray sharePath = GTA5SYNC_SHARE;
outputStr.replace("APPNAME:", GTA5SYNC_APPSTR);
outputStr.replace("SHAREDDIR:", QString::fromUtf8(sharePath));
outputStr.replace("RUNDIR:", QFileInfo(qApp->applicationFilePath()).absoluteDir().absolutePath());
outputStr.replace("APPNAME:", QString::fromUtf8(GTA5SYNC_APPSTR));
outputStr.replace("SHAREDDIR:", QString::fromUtf8(GTA5SYNC_SHARE));
outputStr.replace("RUNDIR:", QFileInfo(QApplication::applicationFilePath()).canonicalPath());
#if QT_VERSION >= 0x060000
outputStr.replace("QCONFLANG:", QLibraryInfo::path(QLibraryInfo::TranslationsPath));
outputStr.replace("QCONFPLUG:", QLibraryInfo::path(QLibraryInfo::PluginsPath));
#else
outputStr.replace("QCONFLANG:", QLibraryInfo::location(QLibraryInfo::TranslationsPath));
outputStr.replace("QCONFPLUG:", QLibraryInfo::location(QLibraryInfo::PluginsPath));
#endif
outputStr.replace("SEPARATOR:", QDir::separator());
return outputStr;
}

View File

@ -41,7 +41,7 @@
#define GTA5SYNC_TELEMETRY_WEBURL ""
#endif
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
#include "windows.h"
#include "intrin.h"
#include "d3d9.h"
@ -228,7 +228,7 @@ QJsonDocument TelemetryClass::getSystemHardware()
{
QJsonDocument jsonDocument;
QJsonObject jsonObject;
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
{
int CPUInfo[4] = {-1};
unsigned nExIds, ic = 0;

View File

@ -63,7 +63,11 @@ void TranslationClass::loadTranslation(QApplication *app)
{
app->installTranslator(&inQtTranslator);
}
#if QT_VERSION <= 0x060000
QLocale::setDefault(QLocale(currentLanguage));
#else
QLocale::setDefault(currentLanguage);
#endif
isLangLoaded = true;
return;
}
@ -147,7 +151,11 @@ void TranslationClass::loadTranslation(QApplication *app)
{
app->installTranslator(&inQtTranslator);
}
#if QT_VERSION <= 0x060000
QLocale::setDefault(QLocale(currentLanguage));
#else
QLocale::setDefault(currentLanguage);
#endif
isLangLoaded = true;
}
}
@ -176,7 +184,11 @@ void TranslationClass::loadTranslation(QApplication *app)
{
app->installTranslator(&inQtTranslator);
}
#if QT_VERSION <= 0x060000
QLocale::setDefault(QLocale(currentLanguage));
#else
QLocale::setDefault(currentLanguage);
#endif
isLangLoaded = true;
}
else
@ -195,7 +207,11 @@ void TranslationClass::loadTranslation(QApplication *app)
{
app->installTranslator(&inQtTranslator);
}
#if QT_VERSION <= 0x060000
QLocale::setDefault(QLocale(currentLanguage));
#else
QLocale::setDefault(currentLanguage);
#endif
isLangLoaded = true;
}
}
@ -219,7 +235,11 @@ void TranslationClass::loadTranslation(QApplication *app)
{
app->installTranslator(&inQtTranslator);
}
#if QT_VERSION <= 0x060000
QLocale::setDefault(QLocale(currentLanguage));
#else
QLocale::setDefault(currentLanguage);
#endif
isLangLoaded = true;
}
else if (!trLoadSuccess)
@ -236,7 +256,11 @@ void TranslationClass::loadTranslation(QApplication *app)
{
app->installTranslator(&inQtTranslator);
}
#if QT_VERSION <= 0x060000
QLocale::setDefault(QLocale(currentLanguage));
#else
QLocale::setDefault(currentLanguage);
#endif
isLangLoaded = true;
}
}

View File

@ -40,14 +40,21 @@
#include <QMessageBox>
#include <QSettings>
#include <QFileInfo>
#include <QTimer>
#include <QDebug>
#include <QFile>
#include <QDir>
#include <QMap>
#ifdef GTA5SYNC_MOTD
UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, MessageThread *threadMessage, QWidget *parent) :
QMainWindow(parent), profileDB(profileDB), crewDB(crewDB), threadDB(threadDB), threadMessage(threadMessage),
ui(new Ui::UserInterface)
#else
UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent) :
QMainWindow(parent), profileDB(profileDB), crewDB(crewDB), threadDB(threadDB),
ui(new Ui::UserInterface)
#endif
{
ui->setupUi(this);
contentMode = 0;
@ -328,7 +335,11 @@ void UserInterface::closeProfile_p()
void UserInterface::closeEvent(QCloseEvent *ev)
{
Q_UNUSED(ev)
#ifdef GTA5SYNC_MOTD
threadMessage->terminateThread();
#else
threadDB->terminateThread();
#endif
}
UserInterface::~UserInterface()
@ -603,6 +614,119 @@ void UserInterface::settingsApplied(int _contentMode, bool languageChanged)
}
}
#ifdef GTA5SYNC_MOTD
void UserInterface::messagesArrived(const QJsonObject &object)
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Messages");
QJsonObject::const_iterator it = object.constBegin();
QJsonObject::const_iterator end = object.constEnd();
QStringList messages;
while (it != end) {
const QString key = it.key();
const QJsonValue value = it.value();
bool uintOk;
uint messageId = key.toUInt(&uintOk);
if (uintOk && value.isString()) {
const QString valueStr = value.toString();
settings.setValue(QString::number(messageId), valueStr);
messages << valueStr;
}
it++;
}
settings.endGroup();
if (!messages.isEmpty())
showMessages(messages);
}
void UserInterface::showMessages(const QStringList messages)
{
QDialog *messageDialog = new QDialog(this);
messageDialog->setWindowTitle(tr("%1 - Messages").arg(GTA5SYNC_APPSTR));
messageDialog->setWindowFlags(messageDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
QVBoxLayout *messageLayout = new QVBoxLayout;
messageDialog->setLayout(messageLayout);
QStackedWidget *stackWidget = new QStackedWidget(messageDialog);
for (const QString message : messages) {
QLabel *messageLabel = new QLabel(messageDialog);
messageLabel->setText(message);
messageLabel->setWordWrap(true);
stackWidget->addWidget(messageLabel);
}
messageLayout->addWidget(stackWidget);
QHBoxLayout *buttonLayout = new QHBoxLayout;
QPushButton *backButton = new QPushButton(messageDialog);
QPushButton *nextButton = new QPushButton(messageDialog);
if (QIcon::hasThemeIcon("go-previous") && QIcon::hasThemeIcon("go-next") && QIcon::hasThemeIcon("list-add")) {
backButton->setIcon(QIcon::fromTheme("go-previous"));
nextButton->setIcon(QIcon::fromTheme("go-next"));
}
else {
backButton->setIcon(QIcon(":/img/back.svgz"));
nextButton->setIcon(QIcon(":/img/next.svgz"));
}
backButton->setEnabled(false);
if (stackWidget->count() <= 1) {
nextButton->setEnabled(false);
}
buttonLayout->addWidget(backButton);
buttonLayout->addWidget(nextButton);
buttonLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
QPushButton *closeButton = new QPushButton(messageDialog);
closeButton->setText(tr("&Close"));
if (QIcon::hasThemeIcon("dialog-close")) {
closeButton->setIcon(QIcon::fromTheme("dialog-close"));
}
else if (QIcon::hasThemeIcon("gtk-close")) {
closeButton->setIcon(QIcon::fromTheme("gtk-close"));
}
buttonLayout->addWidget(closeButton);
messageLayout->addLayout(buttonLayout);
QObject::connect(backButton, &QPushButton::clicked, [stackWidget,backButton,nextButton,closeButton]() {
int index = stackWidget->currentIndex();
if (index > 0) {
index--;
stackWidget->setCurrentIndex(index);
nextButton->setEnabled(true);
if (index > 0) {
backButton->setEnabled(true);
}
else {
backButton->setEnabled(false);
closeButton->setFocus();
}
}
});
QObject::connect(nextButton, &QPushButton::clicked, [stackWidget,backButton,nextButton,closeButton]() {
int index = stackWidget->currentIndex();
if (index < stackWidget->count()-1) {
index++;
stackWidget->setCurrentIndex(index);
backButton->setEnabled(true);
if (index < stackWidget->count()-1) {
nextButton->setEnabled(true);
}
else {
nextButton->setEnabled(false);
closeButton->setFocus();
}
}
});
QObject::connect(closeButton, &QPushButton::clicked, messageDialog, &QDialog::accept);
QObject::connect(messageDialog, &QDialog::finished, messageDialog, &QDialog::deleteLater);
QTimer::singleShot(0, closeButton, SLOT(setFocus()));
messageDialog->show();
}
void UserInterface::updateCacheId(uint cacheId)
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Messages");
settings.setValue("CacheId", cacheId);
settings.endGroup();
}
#endif
void UserInterface::on_actionSelect_GTA_Folder_triggered()
{
QString GTAV_Folder_Temp = QFileDialog::getExistingDirectory(this, tr("Select RDR 2 Folder..."), StandardPaths::documentsLocation(), QFileDialog::ShowDirsOnly);

View File

@ -31,6 +31,10 @@
#include <QString>
#include <QMap>
#ifdef GTA5SYNC_MOTD
#include "MessageThread.h"
#endif
namespace Ui {
class UserInterface;
}
@ -39,7 +43,11 @@ class UserInterface : public QMainWindow
{
Q_OBJECT
public:
#ifdef GTA5SYNC_MOTD
explicit UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, MessageThread *messageThread, QWidget *parent = 0);
#else
explicit UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent = 0);
#endif
void setupDirEnv();
~UserInterface();
@ -67,6 +75,11 @@ private slots:
void on_actionSet_Crew_triggered();
void on_actionSet_Title_triggered();
void settingsApplied(int contentMode, bool languageChanged);
#ifdef GTA5SYNC_MOTD
void messagesArrived(const QJsonObject &object);
void showMessages(const QStringList messages);
void updateCacheId(uint cacheId);
#endif
protected:
void closeEvent(QCloseEvent *ev);
@ -75,6 +88,9 @@ private:
ProfileDatabase *profileDB;
CrewDatabase *crewDB;
DatabaseThread *threadDB;
#ifdef GTA5SYNC_MOTD
MessageThread *threadMessage;
#endif
Ui::UserInterface *ui;
ProfileInterface *profileUI;
QList<QPushButton*> profileBtns;

View File

@ -20,6 +20,7 @@
#include "imagecropper.h"
#include "AppEnv.h"
#include <QPainterPath>
#include <QMouseEvent>
#include <QPainter>

View File

@ -44,7 +44,7 @@
#endif
#ifndef GTA5SYNC_APPVER
#define GTA5SYNC_APPVER "0.2.0"
#define GTA5SYNC_APPVER "0.5.0"
#endif
#if __cplusplus
@ -107,22 +107,16 @@
#define GTA5SYNC_INLANG ":/tr"
#endif
#endif
#endif
#else
#ifndef GTA5SYNC_SHARE
#define GTA5SYNC_SHARE "RUNDIR:"
#endif
#ifndef GTA5SYNC_LANG
#define GTA5SYNC_LANG "SHAREDDIR:SEPARATOR:lang"
#endif
#ifndef GTA5SYNC_PLUG
#define GTA5SYNC_PLUG "RUNDIR:SEPARATOR:plugins"
#endif
#ifdef GTA5SYNC_WINRT
#undef GTA5SYNC_WIN
#endif
#ifndef GTA5SYNC_COMPILER

View File

@ -31,7 +31,6 @@
#include "IconLoader.h"
#include "AppEnv.h"
#include "config.h"
#include <QDesktopWidget>
#include <QStringBuilder>
#include <QSignalMapper>
#include <QStyleFactory>
@ -54,11 +53,19 @@
#include <QFont>
#include <QFile>
#ifdef GTA5SYNC_WIN
#if QT_VERSION < 0x060000
#include <QDesktopWidget>
#endif
#ifdef Q_OS_WIN
#include "windows.h"
#include <iostream>
#endif
#ifdef GTA5SYNC_MOTD
#include "MessageThread.h"
#endif
#ifdef GTA5SYNC_TELEMETRY
#include "TelemetryClass.h"
#endif
@ -66,16 +73,16 @@
int main(int argc, char *argv[])
{
#if QT_VERSION >= 0x050600
#if QT_VERSION < 0x060000
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
#endif
#endif
QApplication a(argc, argv);
a.setApplicationName(GTA5SYNC_APPSTR);
a.setApplicationVersion(GTA5SYNC_APPVER);
a.setQuitOnLastWindowClosed(false);
QResource::registerResource(":/global/global.rcc");
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("Startup");
@ -99,25 +106,12 @@ int main(int argc, char *argv[])
}
}
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050400
bool alwaysUseMessageFont = settings.value("AlwaysUseMessageFont", false).toBool();
if (QSysInfo::windowsVersion() >= 0x0080 || alwaysUseMessageFont)
{
// Get Windows Font
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(ncm);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
LOGFONTW uiFont = ncm.lfMessageFont;
QString uiFontStr(QString::fromStdWString(std::wstring(uiFont.lfFaceName)));
#ifdef GTA5SYNC_DEBUG
qDebug() << QApplication::tr("Font") << QApplication::tr("Selected Font: %1").arg(uiFontStr);
#endif
// Set Application Font
QFont appFont(uiFontStr, 9);
a.setFont(appFont);
a.setFont(QApplication::font("QMenu"));
}
#endif
#endif
@ -260,9 +254,7 @@ int main(int argc, char *argv[])
bool readOk = picture.readingPictureFromFile(arg1);
picDialog.setWindowIcon(IconLoader::loadingAppIcon());
picDialog.setSnapmaticPicture(&picture, readOk);
#ifndef Q_OS_LINUX
picDialog.setWindowFlags(picDialog.windowFlags()^Qt::Dialog^Qt::Window);
#endif
int crewID = picture.getSnapmaticProperties().crewID;
if (crewID != 0) { crewDB.addCrew(crewID); }
@ -307,7 +299,26 @@ int main(int argc, char *argv[])
QObject::connect(&threadDB, SIGNAL(finished()), &a, SLOT(quit()));
threadDB.start();
#ifdef GTA5SYNC_MOTD
uint cacheId;
{
QSettings messageSettings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
messageSettings.beginGroup("Messages");
cacheId = messageSettings.value("CacheId", 0).toUInt();
messageSettings.endGroup();
}
MessageThread threadMessage(cacheId);
QObject::connect(&threadMessage, SIGNAL(finished()), &threadDB, SLOT(terminateThread()));
threadMessage.start();
#endif
#ifdef GTA5SYNC_MOTD
UserInterface uiWindow(&profileDB, &crewDB, &threadDB, &threadMessage);
QObject::connect(&threadMessage, SIGNAL(messagesArrived(QJsonObject)), &uiWindow, SLOT(messagesArrived(QJsonObject)));
QObject::connect(&threadMessage, SIGNAL(updateCacheId(uint)), &uiWindow, SLOT(updateCacheId(uint)));
#else
UserInterface uiWindow(&profileDB, &crewDB, &threadDB);
#endif
uiWindow.setWindowIcon(IconLoader::loadingAppIcon());
uiWindow.setupDirEnv();
#ifdef Q_OS_ANDROID

View File

@ -39,45 +39,45 @@ QJsonDocument::QJsonDocument() : root_(0) {
// Name: QJsonDocument
//------------------------------------------------------------------------------
QJsonDocument::QJsonDocument(const QJsonObject &object) : root_(0) {
setObject(object);
setObject(object);
}
//------------------------------------------------------------------------------
// Name: QJsonDocument
//------------------------------------------------------------------------------
QJsonDocument::QJsonDocument(const QJsonArray &array) : root_(0) {
setArray(array);
setArray(array);
}
//------------------------------------------------------------------------------
// Name: QJsonDocument
//------------------------------------------------------------------------------
QJsonDocument::QJsonDocument(const QJsonDocument &other) : root_(0) {
if(other.root_) {
root_ = other.root_->clone();
}
if(other.root_) {
root_ = other.root_->clone();
}
}
//------------------------------------------------------------------------------
// Name: ~QJsonDocument
//------------------------------------------------------------------------------
QJsonDocument::~QJsonDocument() {
delete root_;
delete root_;
}
//------------------------------------------------------------------------------
// Name: operator=
//------------------------------------------------------------------------------
QJsonDocument &QJsonDocument::operator=(const QJsonDocument &other) {
QJsonDocument(other).swap(*this);
return *this;
QJsonDocument(other).swap(*this);
return *this;
}
//------------------------------------------------------------------------------
// Name: operator!=
//------------------------------------------------------------------------------
bool QJsonDocument::operator!=(const QJsonDocument &other) const {
return !(*this == other);
return !(*this == other);
}
//------------------------------------------------------------------------------
@ -85,30 +85,30 @@ bool QJsonDocument::operator!=(const QJsonDocument &other) const {
//------------------------------------------------------------------------------
bool QJsonDocument::operator==(const QJsonDocument &other) const {
if(isArray() && other.isArray()) {
return array() == other.array();
}
if(isArray() && other.isArray()) {
return array() == other.array();
}
if(isObject() && other.isObject()) {
return object() == other.object();
}
if(isObject() && other.isObject()) {
return object() == other.object();
}
if(isEmpty() && other.isEmpty()) {
return true;
}
if(isEmpty() && other.isEmpty()) {
return true;
}
if(isNull() && other.isNull()) {
return true;
}
if(isNull() && other.isNull()) {
return true;
}
return false;
return false;
}
//------------------------------------------------------------------------------
// Name: isArray
//------------------------------------------------------------------------------
bool QJsonDocument::isArray() const {
return root_ && root_->toArray();
return root_ && root_->toArray();
}
//------------------------------------------------------------------------------
@ -116,56 +116,56 @@ bool QJsonDocument::isArray() const {
//------------------------------------------------------------------------------
bool QJsonDocument::isEmpty() const {
// TODO(eteran): figure out the rules here that Qt5 uses
// it *looks* like they define empty as being NULL
// which is obviously different than this
// TODO(eteran): figure out the rules here that Qt5 uses
// it *looks* like they define empty as being NULL
// which is obviously different than this
return !root_;
return !root_;
}
//------------------------------------------------------------------------------
// Name: isNull
//------------------------------------------------------------------------------
bool QJsonDocument::isNull() const {
return !root_;
return !root_;
}
//------------------------------------------------------------------------------
// Name: isObject
//------------------------------------------------------------------------------
bool QJsonDocument::isObject() const {
return root_ && root_->toObject();
return root_ && root_->toObject();
}
//------------------------------------------------------------------------------
// Name: setArray
//------------------------------------------------------------------------------
void QJsonDocument::setArray(const QJsonArray &array) {
setRoot(array);
setRoot(array);
}
//------------------------------------------------------------------------------
// Name: setObject
//------------------------------------------------------------------------------
void QJsonDocument::setObject(const QJsonObject &object) {
setRoot(object);
setRoot(object);
}
//------------------------------------------------------------------------------
// Name: setRoot
//------------------------------------------------------------------------------
void QJsonDocument::setRoot(const QJsonRoot &root) {
delete root_;
root_ = root.clone();
delete root_;
root_ = root.clone();
}
//------------------------------------------------------------------------------
// Name: toBinaryData
//------------------------------------------------------------------------------
QByteArray QJsonDocument::toBinaryData() const {
QByteArray r;
// TODO(eteran): implement this
return r;
QByteArray r;
// TODO(eteran): implement this
return r;
}
//------------------------------------------------------------------------------
@ -173,100 +173,107 @@ QByteArray QJsonDocument::toBinaryData() const {
//------------------------------------------------------------------------------
QString QJsonDocument::escapeString(const QString &s) const {
QString r;
QString r;
Q_FOREACH(QChar ch, s) {
switch(ch.toLatin1()) {
case '\"': r.append("\\\""); break;
case '\\': r.append("\\\\"); break;
#if 0
case '/': r.append("\\/"); break;
#endif
case '\b': r.append("\\b"); break;
case '\f': r.append("\\f"); break;
case '\n': r.append("\\n"); break;
case '\r': r.append("\\r"); break;
case '\t': r.append("\\t"); break;
default:
r += ch;
break;
}
}
Q_FOREACH(QChar ch, s) {
switch(ch.toLatin1()) {
case '\"': r.append("\\\""); break;
case '\\': r.append("\\\\"); break;
#if 0
case '/': r.append("\\/"); break;
#endif
case '\b': r.append("\\b"); break;
case '\f': r.append("\\f"); break;
case '\n': r.append("\\n"); break;
case '\r': r.append("\\r"); break;
case '\t': r.append("\\t"); break;
default:
r += ch;
break;
}
}
return r;
return r;
}
//------------------------------------------------------------------------------
// Name: toJson
//------------------------------------------------------------------------------
QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format) const {
QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format, int indent) const {
QString b;
QTextStream ss(&b, QIODevice::WriteOnly | QIODevice::Text);
QString b;
QTextStream ss(&b, QIODevice::WriteOnly | QIODevice::Text);
bool compact = (format == JsonFormat::Compact);
switch(v.type()) {
case QJsonValue::Null:
ss << "null";
break;
case QJsonValue::Bool:
ss << (v.toBool() ? "true" : "false");
break;
case QJsonValue::Double:
{
double d = v.toDouble ();
if (qIsFinite(d)) {
// +2 to format to ensure the expected precision
ss << QByteArray::number(d, 'g', 15 + 2); // ::digits10 is 15
} else {
ss << "null"; // +INF || -INF || NaN (see RFC4627#section2.4)
}
}
break;
case QJsonValue::String:
ss << '"' << escapeString(v.toString()) << '"';
break;
case QJsonValue::Array:
{
const QJsonArray a = v.toArray();
ss << "[";
if(!a.empty()) {
QJsonArray::const_iterator it = a.begin();
QJsonArray::const_iterator e = a.end();
switch(v.type()) {
case QJsonValue::Null:
ss << "null";
break;
case QJsonValue::Bool:
ss << (v.toBool() ? "true" : "false");
break;
case QJsonValue::Double:
{
double d = v.toDouble ();
if (qIsFinite(d)) {
// +2 to format to ensure the expected precision
ss << QByteArray::number(d, 'g', 15 + 2); // ::digits10 is 15
} else {
ss << "null"; // +INF || -INF || NaN (see RFC4627#section2.4)
}
}
break;
case QJsonValue::String:
ss << '"' << escapeString(v.toString()) << '"';
break;
case QJsonValue::Array:
{
const QJsonArray a = v.toArray();
ss << (compact ? "[" : "[\n");
if(!a.empty()) {
QJsonArray::const_iterator it = a.begin();
QJsonArray::const_iterator e = a.end();
ss << toJson(*it++, format);
if (!compact) ss << QByteArray(4*indent, ' ');
ss << toJson(*it++, format, indent+1);
for(;it != e; ++it) {
ss << ',';
ss << toJson(*it, format);
}
}
ss << "]";
}
break;
case QJsonValue::Object:
{
const QJsonObject o = v.toObject();
ss << "{";
if(!o.empty()) {
QJsonObject::const_iterator it = o.begin();
QJsonObject::const_iterator e = o.end();
for(;it != e; ++it) {
ss << (compact ? "," : ",\n");
if (!compact) ss << QByteArray(4*indent, ' ');
ss << toJson(*it, format, indent+1);
}
}
indent--;
ss << (compact ? "]" : QString("\n%1]").arg(QString(4*indent, ' ')));
}
break;
case QJsonValue::Object:
{
const QJsonObject o = v.toObject();
ss << (compact ? "{" : "{\n");
if(!o.empty()) {
QJsonObject::const_iterator it = o.begin();
QJsonObject::const_iterator e = o.end();
ss << '"' << escapeString(it.key()) << "\": " << toJson(it.value(), format);
++it;
for(;it != e; ++it) {
ss << ',';
ss << '"' << escapeString(it.key()) << "\": " << toJson(it.value(), format);
}
}
ss << "}";
}
break;
case QJsonValue::Undefined:
Q_ASSERT(0);
break;
}
if (!compact) ss << QByteArray(4*indent, ' ');
ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, indent+1);
++it;
for(;it != e; ++it) {
ss << (compact ? "," : ",\n");
if (!compact) ss << QByteArray(4*indent, ' ');
ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, indent+1);
}
}
indent--;
ss << (compact ? "}" : QString("\n%1}").arg(QString(4*indent, ' ')));
}
break;
case QJsonValue::Undefined:
Q_ASSERT(0);
break;
}
return b;
return b;
}
//------------------------------------------------------------------------------
@ -274,19 +281,19 @@ QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format) const {
//------------------------------------------------------------------------------
QByteArray QJsonDocument::toJson(JsonFormat format) const {
Q_UNUSED(format);
Q_UNUSED(format);
if(isArray()) {
QString s = toJson(array(), format);
return s.toUtf8();
}
if(isArray()) {
QString s = toJson(array(), format);
return s.toUtf8();
}
if(isObject()) {
QString s = toJson(object(), format);
return s.toUtf8();
}
if(isObject()) {
QString s = toJson(object(), format);
return s.toUtf8();
}
return QByteArray();
return QByteArray();
}
//------------------------------------------------------------------------------
@ -294,17 +301,17 @@ QByteArray QJsonDocument::toJson(JsonFormat format) const {
//------------------------------------------------------------------------------
QVariant QJsonDocument::toVariant() const {
if(!isEmpty()) {
if(QJsonObject *const object = root_->toObject()) {
return object->toVariantMap();
}
if(!isEmpty()) {
if(QJsonObject *const object = root_->toObject()) {
return object->toVariantMap();
}
if(QJsonArray *const array = root_->toArray()) {
return array->toVariantList();
}
}
if(QJsonArray *const array = root_->toArray()) {
return array->toVariantList();
}
}
return QVariant();
return QVariant();
}
//------------------------------------------------------------------------------
@ -312,13 +319,13 @@ QVariant QJsonDocument::toVariant() const {
//------------------------------------------------------------------------------
QJsonArray QJsonDocument::array() const {
if(!isEmpty()) {
if(QJsonArray *const array = root_->toArray()) {
return *array;
}
}
if(!isEmpty()) {
if(QJsonArray *const array = root_->toArray()) {
return *array;
}
}
return QJsonArray();
return QJsonArray();
}
//------------------------------------------------------------------------------
@ -326,54 +333,54 @@ QJsonArray QJsonDocument::array() const {
//------------------------------------------------------------------------------
QJsonObject QJsonDocument::object() const {
if(!isEmpty()) {
if(QJsonObject *const object = root_->toObject()) {
return *object;
}
}
if(!isEmpty()) {
if(QJsonObject *const object = root_->toObject()) {
return *object;
}
}
return QJsonObject();
return QJsonObject();
}
//------------------------------------------------------------------------------
// Name: rawData
//------------------------------------------------------------------------------
const char *QJsonDocument::rawData(int *size) const {
Q_UNUSED(size);
// TODO(eteran): implement this
return 0;
Q_UNUSED(size);
// TODO(eteran): implement this
return 0;
}
//------------------------------------------------------------------------------
// Name: fromBinaryData
//------------------------------------------------------------------------------
QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidation validation) {
Q_UNUSED(data);
Q_UNUSED(validation);
Q_UNUSED(data);
Q_UNUSED(validation);
QJsonDocument doc;
// TODO(eteran): implement this
return doc;
QJsonDocument doc;
// TODO(eteran): implement this
return doc;
}
//------------------------------------------------------------------------------
// Name: fromJson
//------------------------------------------------------------------------------
QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *error) {
QJsonDocument doc;
QJsonDocument doc;
const char *const begin = json.constData();
const char *const end = begin + json.size();
const char *const begin = json.constData();
const char *const end = begin + json.size();
QJsonParser parser(begin, end);
QJsonParser parser(begin, end);
doc.root_ = parser.parse();
doc.root_ = parser.parse();
if(error) {
*error = parser.state();
}
if(error) {
*error = parser.state();
}
return doc;
return doc;
}
//------------------------------------------------------------------------------
@ -381,10 +388,10 @@ QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *e
//------------------------------------------------------------------------------
QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidation validation) {
// data has to be aligned to a 4 byte boundary.
Q_ASSERT(!(reinterpret_cast<quintptr>(data) % 3));
// data has to be aligned to a 4 byte boundary.
Q_ASSERT(!(reinterpret_cast<quintptr>(data) % 3));
return fromBinaryData(QByteArray::fromRawData(data, size), validation);
return fromBinaryData(QByteArray::fromRawData(data, size), validation);
}
//------------------------------------------------------------------------------
@ -392,26 +399,26 @@ QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidat
//------------------------------------------------------------------------------
QJsonDocument QJsonDocument::fromVariant(const QVariant &variant) {
QJsonDocument doc;
QJsonDocument doc;
if (variant.type() == QVariant::Map) {
doc.setObject(QJsonObject::fromVariantMap(variant.toMap()));
} else if (variant.type() == QVariant::Hash) {
doc.setObject(QJsonObject::fromVariantHash(variant.toHash()));
} else if (variant.type() == QVariant::List) {
doc.setArray(QJsonArray::fromVariantList(variant.toList()));
} else if (variant.type() == QVariant::StringList) {
doc.setArray(QJsonArray::fromStringList(variant.toStringList()));
}
if (variant.type() == QVariant::Map) {
doc.setObject(QJsonObject::fromVariantMap(variant.toMap()));
} else if (variant.type() == QVariant::Hash) {
doc.setObject(QJsonObject::fromVariantHash(variant.toHash()));
} else if (variant.type() == QVariant::List) {
doc.setArray(QJsonArray::fromVariantList(variant.toList()));
} else if (variant.type() == QVariant::StringList) {
doc.setArray(QJsonArray::fromStringList(variant.toStringList()));
}
return doc;
return doc;
}
//------------------------------------------------------------------------------
// Name: swap
//------------------------------------------------------------------------------
void QJsonDocument::swap(QJsonDocument &other) {
qSwap(root_, other.root_);
qSwap(root_, other.root_);
}
#endif

View File

@ -36,66 +36,66 @@ class QJsonRoot;
class QJsonDocument {
public:
enum DataValidation {
Validate = 0,
BypassValidation = 1
};
enum DataValidation {
Validate = 0,
BypassValidation = 1
};
enum JsonFormat {
Indented,
Compact
};
enum JsonFormat {
Indented,
Compact
};
public:
QJsonDocument();
QJsonDocument(const QJsonObject &object);
QJsonDocument(const QJsonArray &array);
QJsonDocument(const QJsonDocument &other);
~QJsonDocument();
QJsonDocument();
QJsonDocument(const QJsonObject &object);
QJsonDocument(const QJsonArray &array);
QJsonDocument(const QJsonDocument &other);
~QJsonDocument();
public:
QJsonDocument &operator=(const QJsonDocument &other);
QJsonDocument &operator=(const QJsonDocument &other);
public:
bool operator!=(const QJsonDocument &other) const;
bool operator==(const QJsonDocument &other) const;
bool operator!=(const QJsonDocument &other) const;
bool operator==(const QJsonDocument &other) const;
public:
bool isArray() const;
bool isEmpty() const;
bool isNull() const;
bool isObject() const;
bool isArray() const;
bool isEmpty() const;
bool isNull() const;
bool isObject() const;
public:
QByteArray toBinaryData() const;
QByteArray toJson(JsonFormat format = Indented) const;
QVariant toVariant() const;
QByteArray toBinaryData() const;
QByteArray toJson(JsonFormat format = Indented) const;
QVariant toVariant() const;
public:
QJsonArray array() const;
QJsonObject object() const;
const char *rawData(int *size) const;
QJsonArray array() const;
QJsonObject object() const;
const char *rawData(int *size) const;
public:
void setArray(const QJsonArray &array);
void setObject(const QJsonObject &object);
void setArray(const QJsonArray &array);
void setObject(const QJsonObject &object);
public:
static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate);
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = 0);
static QJsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate);
static QJsonDocument fromVariant(const QVariant &variant);
static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate);
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = 0);
static QJsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate);
static QJsonDocument fromVariant(const QVariant &variant);
private:
void setRoot(const QJsonRoot &root);
QString toJson(const QJsonValue &v, JsonFormat format) const;
QString escapeString(const QString &s) const;
void setRoot(const QJsonRoot &root);
QString toJson(const QJsonValue &v, JsonFormat format, int indent = 1) const;
QString escapeString(const QString &s) const;
private:
void swap(QJsonDocument &other);
void swap(QJsonDocument &other);
private:
QJsonRoot *root_;
QJsonRoot *root_;
};
#endif

View File

@ -16,7 +16,7 @@
#* along with this program. If not, see <http://www.gnu.org/licenses/>.
#*****************************************************************************/
QT += core gui network svg
QT += core gui network svg
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
greaterThan(QT_MAJOR_VERSION, 4): greaterThan(QT_MINOR_VERSION, 1): win32: QT += winextras
@ -40,6 +40,7 @@ SOURCES += main.cpp \
ImportDialog.cpp \
JsonEditorDialog.cpp \
MapLocationDialog.cpp \
MessageThread.cpp \
OptionsDialog.cpp \
PictureDialog.cpp \
PictureExport.cpp \
@ -69,7 +70,7 @@ SOURCES += main.cpp \
uimod/UiModLabel.cpp \
uimod/UiModWidget.cpp
HEADERS += \
HEADERS += \
AboutDialog.h \
AppEnv.h \
CrewDatabase.h \
@ -81,6 +82,7 @@ HEADERS += \
ImportDialog.h \
JsonEditorDialog.h \
MapLocationDialog.h \
MessageThread.h \
OptionsDialog.h \
PictureDialog.h \
PictureExport.h \
@ -112,7 +114,7 @@ HEADERS += \
uimod/UiModLabel.h \
uimod/UiModWidget.h
FORMS += \
FORMS += \
AboutDialog.ui \
ExportDialog.ui \
ImportDialog.ui \
@ -160,8 +162,9 @@ INCLUDEPATH += ./anpro ./pcg ./tmext ./uimod
# GTA5SYNC/GTA5VIEW/RDR2VIEW ONLY
DEFINES += GTA5SYNC_PROJECT # Enable exclusive gta5sync/gta5view/rdr2view functions
DEFINES += GTA5SYNC_NOASSIST # Not assisting at proper usage of SnapmaticPicture class
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
@ -229,9 +232,21 @@ contains(DEFINES, GTA5SYNC_QCONF){
# TELEMETRY BASED STUFF
!contains(DEFINES, GTA5SYNC_TELEMETRY){
!contains(DEFINES, GTA5SYNC_TELEMETRY) {
SOURCES -= TelemetryClass.cpp \
tmext/TelemetryClassAuthenticator.cpp
HEADERS -= TelemetryClass.h \
tmext/TelemetryClassAuthenticator.h
}
!contains(DEFINES, GTA5SYNC_MOTD) {
SOURCES -= MessageThread.cpp
HEADERS -= MessageThread.h
} else {
lessThan(QT_MAJOR_VERSION, 5) {
SOURCES -= MessageThread.cpp
HEADERS -= MessageThread.h
DEFINES -= GTA5SYNC_MOTD
message("Messages require Qt5 or newer!")
}
}

View File

@ -7,8 +7,8 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "rdr2view.exe.manifest"
#include <windows.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0, 2, 0, 0
PRODUCTVERSION 0, 2, 0, 0
FILEVERSION 0, 5, 0, 0
PRODUCTVERSION 0, 5, 0, 0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0
FILEOS VOS_NT_WINDOWS32
@ -25,12 +25,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Syping"
VALUE "FileDescription", "rdr2view"
VALUE "FileVersion", "0.2.0"
VALUE "FileVersion", "0.5.0"
VALUE "InternalName", "rdr2view"
VALUE "LegalCopyright", "Copyright © 2016-2020 Syping"
VALUE "OriginalFilename", "rdr2view.exe"
VALUE "ProductName", "rdr2view"
VALUE "ProductVersion", "0.2.0"
VALUE "ProductVersion", "0.5.0"
END
END
END

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,6 +1,6 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017 Syping
* Copyright (C) 2017-2020 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,7 +17,6 @@
*****************************************************************************/
#include "JSHighlighter.h"
#include <QRegExp>
JSHighlighter::JSHighlighter(QTextDocument *parent) :
QSyntaxHighlighter(parent)
@ -31,34 +30,61 @@ JSHighlighter::JSHighlighter(QTextDocument *parent) :
keywordPatterns << "\\btrue\\b" << "\\bfalse\\b";
for (QString pattern : keywordPatterns)
{
#if QT_VERSION >= 0x050000
rule.pattern = QRegularExpression(pattern);
#else
rule.pattern = QRegExp(pattern);
#endif
rule.format = keywordFormat;
highlightingRules.append(rule);
}
QBrush doubleBrush(QColor::fromRgb(66, 137, 244));
doubleFormat.setForeground(doubleBrush);
#if QT_VERSION >= 0x050000
rule.pattern = QRegularExpression("[+-]?\\d*\\.?\\d+");
#else
rule.pattern = QRegExp("[+-]?\\d*\\.?\\d+");
#endif
rule.format = doubleFormat;
highlightingRules.append(rule);
QBrush quotationBrush(QColor::fromRgb(66, 244, 104));
quotationFormat.setForeground(quotationBrush);
#if QT_VERSION >= 0x050000
rule.pattern = QRegularExpression("\"[^\"]*\"");
#else
rule.pattern = QRegExp("\"[^\"]*\"");
#endif
rule.format = quotationFormat;
highlightingRules.append(rule);
QBrush objectBrush(QColor::fromRgb(255, 80, 80));
objectFormat.setForeground(objectBrush);
#if QT_VERSION >= 0x050000
rule.pattern = QRegularExpression("\"[^\"]*\"(?=:)");
#else
rule.pattern = QRegExp("\"[^\"]*\"(?=:)");
#endif
rule.format = objectFormat;
highlightingRules.append(rule);
}
void JSHighlighter::highlightBlock(const QString &text)
{
for (HighlightingRule rule : highlightingRules)
#if QT_VERSION >= 0x050000
for (const HighlightingRule &rule : qAsConst(highlightingRules))
#else
for (const HighlightingRule &rule : highlightingRules)
#endif
{
#if QT_VERSION >= 0x050000
QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
while (matchIterator.hasNext()) {
QRegularExpressionMatch match = matchIterator.next();
setFormat(match.capturedStart(), match.capturedLength(), rule.format);
}
#else
QRegExp expression(rule.pattern);
int index = expression.indexIn(text);
while (index >= 0)
@ -67,6 +93,7 @@ void JSHighlighter::highlightBlock(const QString &text)
setFormat(index, length, rule.format);
index = expression.indexIn(text, index + length);
}
#endif
}
setCurrentBlockState(0);
}

View File

@ -1,6 +1,6 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2017 Syping
* Copyright (C) 2017-2020 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -24,10 +24,15 @@
#include <QTextDocument>
#include <QTextFormat>
#include <QStringList>
#include <QRegExp>
#include <QVector>
#include <QHash>
#if QT_VERSION >= 0x050000
#include <QRegularExpression>
#else
#include <QRegExp>
#endif
class QTextDocument;
class JSHighlighter : public QSyntaxHighlighter
@ -37,7 +42,11 @@ class JSHighlighter : public QSyntaxHighlighter
public:
struct HighlightingRule
{
#if QT_VERSION >= 0x050000
QRegularExpression pattern;
#else
QRegExp pattern;
#endif
QTextCharFormat format;
};
QVector<HighlightingRule> highlightingRules;

View File

@ -80,7 +80,11 @@ void UiModWidget::paintEvent(QPaintEvent *paintEvent)
{
Q_UNUSED(paintEvent)
QStyleOption opt;
#if QT_VERSION <= 0x060000
opt.initFrom(this);
#else
opt.init(this);
#endif
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}