better RDR 2 support, bug fixes + optimisation, libragephoto upstream
This commit is contained in:
parent
b19152fdae
commit
2d0830254b
10 changed files with 136 additions and 145 deletions
|
@ -25,6 +25,7 @@
|
|||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QMessageBox>
|
||||
#include <QFile>
|
||||
|
||||
#if QT_VERSION >= 0x050200
|
||||
#include <QFontDatabase>
|
||||
|
@ -190,7 +191,7 @@ bool JsonEditorDialog::saveJsonContent()
|
|||
QJsonDocument jsonDocument;
|
||||
QJsonObject jsonObject;
|
||||
jsonObject["Type"] = "JSONEdited";
|
||||
jsonObject["EditedSize"] = QString::number(smpic->ragePhoto()->photoSize());
|
||||
jsonObject["EditedSize"] = QString::number(smpic->getPictureSize());
|
||||
#if QT_VERSION >= 0x060000
|
||||
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
|
||||
#else
|
||||
|
|
|
@ -183,12 +183,10 @@ void PictureDialog::setupPictureDialog()
|
|||
globalMap = GlobalString::getGlobalMap();
|
||||
|
||||
// Set Icon for Close Button
|
||||
if (QIcon::hasThemeIcon("dialog-close")) {
|
||||
if (QIcon::hasThemeIcon("dialog-close"))
|
||||
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
|
||||
}
|
||||
else if (QIcon::hasThemeIcon("gtk-close")) {
|
||||
else if (QIcon::hasThemeIcon("gtk-close"))
|
||||
ui->cmdClose->setIcon(QIcon::fromTheme("gtk-close"));
|
||||
}
|
||||
|
||||
installEventFilter(this);
|
||||
|
||||
|
@ -251,9 +249,8 @@ void PictureDialog::styliseDialog()
|
|||
MARGINS margins = {0, 0, qRound(layout()->menuBar()->height() * AppEnv::screenRatioPR()), 0};
|
||||
HRESULT hr = S_OK;
|
||||
hr = DwmExtendFrameIntoClientArea(reinterpret_cast<HWND>(winId()), &margins);
|
||||
if (SUCCEEDED(hr)) {
|
||||
if (SUCCEEDED(hr))
|
||||
setStyleSheet("PictureDialog{background:transparent}");
|
||||
}
|
||||
}
|
||||
else {
|
||||
MARGINS margins = {0, 0, 0, 0};
|
||||
|
@ -261,9 +258,8 @@ void PictureDialog::styliseDialog()
|
|||
bool colorOk = false;
|
||||
QSettings dwmRegistry("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\DWM", QSettings::NativeFormat);
|
||||
QRgb color = dwmRegistry.value("ColorizationColor").toUInt(&colorOk);
|
||||
if (colorOk) {
|
||||
if (colorOk)
|
||||
setStyleSheet(QString("PictureDialog{background:%1}").arg(QColor::fromRgba(color).name()));
|
||||
}
|
||||
else {
|
||||
HRESULT hr = S_OK;
|
||||
BOOL isOpaqueBlend;
|
||||
|
@ -291,9 +287,8 @@ bool PictureDialog::nativeEvent(const QByteArray &eventType, void *message, long
|
|||
#endif
|
||||
{
|
||||
MSG *msg = reinterpret_cast<MSG*>(message);
|
||||
if (msg->message == 0x031e || msg->message == 0x0320) {
|
||||
if (msg->message == 0x031e || msg->message == 0x0320)
|
||||
styliseDialog();
|
||||
}
|
||||
return QWidget::nativeEvent(eventType, message, result);
|
||||
}
|
||||
#endif
|
||||
|
@ -337,11 +332,13 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
|
|||
case Qt::Key_2:
|
||||
if (overlayEnabled) {
|
||||
overlayEnabled = false;
|
||||
if (!previewMode) renderPicture();
|
||||
if (!previewMode)
|
||||
renderPicture();
|
||||
}
|
||||
else {
|
||||
overlayEnabled = true;
|
||||
if (!previewMode) renderPicture();
|
||||
if (!previewMode)
|
||||
renderPicture();
|
||||
}
|
||||
break;
|
||||
case Qt::Key_M:
|
||||
|
@ -376,9 +373,8 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
|
|||
if (ev->type() == QEvent::MouseButtonRelease) {
|
||||
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(ev);
|
||||
if (mouseEvent->pos().y() <= layout()->menuBar()->height()) {
|
||||
if (mouseEvent->button() == Qt::LeftButton) {
|
||||
if (mouseEvent->button() == Qt::LeftButton)
|
||||
dragStart = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dragStart && ev->type() == QEvent::MouseMove) {
|
||||
|
@ -447,9 +443,8 @@ void PictureDialog::renderOverlayPicture()
|
|||
preferedRect.setHeight(71 * screenRatio * screenRatioPR);
|
||||
overlaySpace.setHeight(80 * screenRatio * screenRatioPR);
|
||||
}
|
||||
else {
|
||||
else
|
||||
overlaySpace.setHeight(overlaySpace.height() + 6 * screenRatio * screenRatioPR);
|
||||
}
|
||||
|
||||
QImage overlayImage(overlaySpace.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
overlayImage.fill(Qt::transparent);
|
||||
|
@ -460,12 +455,10 @@ void PictureDialog::renderOverlayPicture()
|
|||
overlayPainter.drawText(preferedRect, Qt::AlignLeft | hOverlay | Qt::TextDontClip | Qt::TextWordWrap, overlayText);
|
||||
overlayPainter.end();
|
||||
|
||||
if (overlaySpace.width() < 194 * screenRatio * screenRatioPR) {
|
||||
if (overlaySpace.width() < 194 * screenRatio * screenRatioPR)
|
||||
overlaySpace.setWidth(200 * screenRatio * screenRatioPR);
|
||||
}
|
||||
else {
|
||||
else
|
||||
overlaySpace.setWidth(overlaySpace.width() + 6 * screenRatio * screenRatioPR);
|
||||
}
|
||||
|
||||
QImage overlayBorderImage(overlaySpace.width(), overlaySpace.height(), QImage::Format_ARGB6666_Premultiplied);
|
||||
overlayBorderImage.fill(QColor(15, 15, 15, 162));
|
||||
|
@ -492,6 +485,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
|
|||
QMessageBox::warning(this, tr("Snapmatic Picture Viewer"), tr("Failed at %1").arg(picture->getLastStep()));
|
||||
return;
|
||||
}
|
||||
setWindowTitle(windowTitleStr.arg(picture->getPictureTitle()));
|
||||
if (picture->isPicOk()) {
|
||||
snapmaticPicture = picture->getImage();
|
||||
renderPicture();
|
||||
|
@ -499,13 +493,10 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
|
|||
}
|
||||
if (picture->isJsonOk()) {
|
||||
crewStr = crewDB->getCrewName(crewID);
|
||||
if (globalMap.contains(picArea)) {
|
||||
if (globalMap.contains(picArea))
|
||||
picAreaStr = globalMap.value(picArea);
|
||||
}
|
||||
else {
|
||||
else
|
||||
picAreaStr = picArea;
|
||||
}
|
||||
setWindowTitle(windowTitleStr.arg(picTitl));
|
||||
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created));
|
||||
QTimer::singleShot(0, this, &PictureDialog::adaptDialogSize);
|
||||
}
|
||||
|
@ -548,15 +539,12 @@ void PictureDialog::renderPicture()
|
|||
shownImagePixmap.fill(Qt::black);
|
||||
QPainter shownImagePainter(&shownImagePixmap);
|
||||
const QImage renderImage = snapmaticPicture.scaled(renderResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
if (renderImage.width() < renderResolution.width()) {
|
||||
if (renderImage.width() < renderResolution.width())
|
||||
shownImagePainter.drawImage((renderResolution.width() - renderImage.width()) / 2, 0, renderImage, Qt::AutoColor);
|
||||
}
|
||||
else if (renderImage.height() < renderResolution.height()) {
|
||||
else if (renderImage.height() < renderResolution.height())
|
||||
shownImagePainter.drawImage(0, (renderResolution.height() - renderImage.height()) / 2, renderImage, Qt::AutoColor);
|
||||
}
|
||||
else {
|
||||
else
|
||||
shownImagePainter.drawImage(0, 0, renderImage, Qt::AutoColor);
|
||||
}
|
||||
if (previewMode) {
|
||||
QFont shownImagePainterFont;
|
||||
shownImagePainterFont.setPixelSize(12 * screenRatio * screenRatioPR);
|
||||
|
@ -565,9 +553,8 @@ void PictureDialog::renderPicture()
|
|||
shownImagePainter.setFont(shownImagePainterFont);
|
||||
shownImagePainter.drawText(QRect(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, 140 * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR), Qt::AlignLeft | Qt::TextWordWrap, tr("Avatar Preview Mode\nPress 1 for Default View"));
|
||||
}
|
||||
else if (overlayEnabled) {
|
||||
else if (overlayEnabled)
|
||||
shownImagePainter.drawImage(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, overlayTempImage, Qt::AutoColor);
|
||||
}
|
||||
shownImagePainter.end();
|
||||
shownImagePixmap.setDevicePixelRatio(screenRatioPR);
|
||||
ui->labPicture->setPixmap(shownImagePixmap);
|
||||
|
@ -598,12 +585,10 @@ QString PictureDialog::generateCrewString()
|
|||
SnapmaticPicture *picture = smpic; // used by macro
|
||||
const QString crewIDStr = crewID; // save operation time
|
||||
if (crewIDStr != "0" && !crewIDStr.isEmpty()) {
|
||||
if (crewIDStr != crewStr) {
|
||||
if (crewIDStr != crewStr)
|
||||
return QString("<a href=\"https://socialclub.rockstargames.com/crew/" % QString(crewStr).replace(" ", "_") % "/" % crewIDStr % "\">" % crewStr % "</a>");
|
||||
}
|
||||
else {
|
||||
else
|
||||
return QString(crewIDStr);
|
||||
}
|
||||
}
|
||||
return tr("No Crew");
|
||||
}
|
||||
|
@ -633,12 +618,10 @@ QString PictureDialog::generatePlayersString()
|
|||
|
||||
void PictureDialog::exportSnapmaticPicture()
|
||||
{
|
||||
if (rqFullscreen && fullscreenWidget != nullptr) {
|
||||
if (rqFullscreen && fullscreenWidget != nullptr)
|
||||
PictureExport::exportAsPicture(fullscreenWidget, smpic);
|
||||
}
|
||||
else {
|
||||
else
|
||||
PictureExport::exportAsPicture(this, smpic);
|
||||
}
|
||||
}
|
||||
|
||||
void PictureDialog::copySnapmaticPicture()
|
||||
|
@ -751,7 +734,7 @@ void PictureDialog::openPreviewMap()
|
|||
QJsonObject jsonObject;
|
||||
jsonObject["Type"] = "LocationEdited";
|
||||
jsonObject["ExtraFlags"] = "Viewer";
|
||||
jsonObject["EditedSize"] = QString::number(picture->ragePhoto()->photoSize());
|
||||
jsonObject["EditedSize"] = QString::number(picture->getPictureSize());
|
||||
#if QT_VERSION >= 0x060000
|
||||
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
|
||||
#else
|
||||
|
@ -779,11 +762,7 @@ void PictureDialog::editSnapmaticProperties()
|
|||
snapmaticEditor->setWindowIcon(windowIcon());
|
||||
snapmaticEditor->setSnapmaticPicture(picture);
|
||||
snapmaticEditor->setModal(true);
|
||||
#ifndef Q_OS_ANDROID
|
||||
snapmaticEditor->show();
|
||||
#else
|
||||
snapmaticEditor->showMaximized();
|
||||
#endif
|
||||
snapmaticEditor->exec();
|
||||
delete snapmaticEditor;
|
||||
}
|
||||
|
@ -829,7 +808,7 @@ void PictureDialog::editSnapmaticImage()
|
|||
QJsonObject jsonObject;
|
||||
jsonObject["Type"] = "ImageEdited";
|
||||
jsonObject["ExtraFlags"] = "Viewer";
|
||||
jsonObject["EditedSize"] = QString::number(smpic->ragePhoto()->photoSize());
|
||||
jsonObject["EditedSize"] = QString::number(smpic->getPictureSize());
|
||||
#if QT_VERSION >= 0x060000
|
||||
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
|
||||
#else
|
||||
|
@ -869,12 +848,10 @@ void PictureDialog::updated()
|
|||
{
|
||||
SnapmaticPicture *picture = smpic; // used by macro
|
||||
crewStr = crewDB->getCrewName(crewID);
|
||||
if (globalMap.contains(picArea)) {
|
||||
if (globalMap.contains(picArea))
|
||||
picAreaStr = globalMap[picArea];
|
||||
}
|
||||
else {
|
||||
else
|
||||
picAreaStr = picArea;
|
||||
}
|
||||
setWindowTitle(windowTitleStr.arg(picTitl));
|
||||
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created));
|
||||
QTimer::singleShot(0, this, &PictureDialog::adaptDialogSize);
|
||||
|
|
|
@ -281,7 +281,7 @@ fileDialogPreSave: //Work?
|
|||
}
|
||||
}
|
||||
else {
|
||||
bool isCopied = picture->exportPicture(selectedFile, SnapmaticFormat::PGTA_Format);
|
||||
bool isCopied = picture->exportPicture(selectedFile, SnapmaticFormat::PGTA5_Format);
|
||||
if (!isCopied) {
|
||||
QMessageBox::warning(parent, PictureDialog::tr("Export as Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture"));
|
||||
goto fileDialogPreSave; //Work?
|
||||
|
|
|
@ -660,7 +660,7 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
|
|||
QJsonDocument jsonDocument;
|
||||
QJsonObject jsonObject;
|
||||
jsonObject["Type"] = "ImportSuccess";
|
||||
jsonObject["ImportSize"] = QString::number(picture->ragePhoto()->photoSize());
|
||||
jsonObject["ImportSize"] = QString::number(picture->getPictureSize());
|
||||
#if QT_VERSION >= 0x060000
|
||||
jsonObject["ImportTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
|
||||
#else
|
||||
|
@ -872,7 +872,7 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
|
|||
QJsonObject jsonObject;
|
||||
jsonObject["Type"] = "ImportSuccess";
|
||||
jsonObject["ExtraFlag"] = "Dialog";
|
||||
jsonObject["ImportSize"] = QString::number(picture->ragePhoto()->photoSize());
|
||||
jsonObject["ImportSize"] = QString::number(picture->getPictureSize());
|
||||
#if QT_VERSION >= 0x060000
|
||||
jsonObject["ImportTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
|
||||
#else
|
||||
|
@ -919,7 +919,7 @@ bool ProfileInterface::importFile(QString selectedFile, QDateTime importDateTime
|
|||
QJsonDocument jsonDocument;
|
||||
QJsonObject jsonObject;
|
||||
jsonObject["Type"] = "ImportSuccess";
|
||||
jsonObject["ImportSize"] = QString::number(picture->ragePhoto()->photoSize());
|
||||
jsonObject["ImportSize"] = QString::number(picture->getPictureSize());
|
||||
#if QT_VERSION >= 0x060000
|
||||
jsonObject["ImportTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
|
||||
#else
|
||||
|
@ -1202,12 +1202,10 @@ bool ProfileInterface::importSnapmaticPicture(SnapmaticPicture *picture, bool wa
|
|||
adjustedFileName = picture->getOriginalPictureFileName();
|
||||
}
|
||||
}
|
||||
if (picture->exportPicture(profileFolder % "/" % adjustedFileName, SnapmaticFormat::PGTA_Format)) {
|
||||
picture->setSnapmaticFormat(SnapmaticFormat::PGTA_Format);
|
||||
if (picture->exportPicture(profileFolder % "/" % adjustedFileName, SnapmaticFormat::PGTA5_Format)) {
|
||||
picture->setSnapmaticFormat(SnapmaticFormat::PGTA5_Format);
|
||||
picture->setPicFilePath(profileFolder % "/" % adjustedFileName);
|
||||
#if QT_VERSION >= 0x050000
|
||||
snapmaticPics << picture->getPictureFileName();
|
||||
#endif
|
||||
pictureLoaded(picture, true);
|
||||
return true;
|
||||
}
|
||||
|
@ -1278,9 +1276,8 @@ void ProfileInterface::profileWidgetDeselected()
|
|||
int scrollBarValue = ui->saProfile->verticalScrollBar()->value();
|
||||
for (const QString &widgetStr : qAsConst(widgets)) {
|
||||
ProfileWidget *widget = widgets.key(widgetStr, nullptr);
|
||||
if (widget != nullptr && contentMode != 2) {
|
||||
if (widget != nullptr && contentMode != 2)
|
||||
widget->setSelectionMode(false);
|
||||
}
|
||||
}
|
||||
ui->saProfile->verticalScrollBar()->setValue(scrollBarValue);
|
||||
}
|
||||
|
|
|
@ -100,8 +100,8 @@ void ProfileLoader::run()
|
|||
SnapmaticPicture *picture = new SnapmaticPicture(picturePath);
|
||||
if (picture->readingPicture(true)) {
|
||||
if (picture->isFormatSwitched()) {
|
||||
picture->setSnapmaticFormat(SnapmaticFormat::PGTA_Format);
|
||||
if (picture->exportPicture(picturePath, SnapmaticFormat::PGTA_Format)) {
|
||||
picture->setSnapmaticFormat(SnapmaticFormat::PGTA5_Format);
|
||||
if (picture->exportPicture(picturePath, SnapmaticFormat::PGTA5_Format)) {
|
||||
emit pictureFixed(picture);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ void SnapmaticEditor::on_cmdApply_clicked()
|
|||
QJsonDocument jsonDocument;
|
||||
QJsonObject jsonObject;
|
||||
jsonObject["Type"] = "PropertyEdited";
|
||||
jsonObject["EditedSize"] = QString::number(smpic->ragePhoto()->photoSize());
|
||||
jsonObject["EditedSize"] = QString::number(smpic->getPictureSize());
|
||||
#if QT_VERSION >= 0x060000
|
||||
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
|
||||
#else
|
||||
|
|
|
@ -22,10 +22,9 @@
|
|||
#include <QJsonObject>
|
||||
#include <QStringList>
|
||||
#include <QVariantMap>
|
||||
#include <QJsonArray>
|
||||
#include <QFileInfo>
|
||||
#include <QPainter>
|
||||
#include <QString>
|
||||
#include <cstring>
|
||||
#include <QBuffer>
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
|
@ -409,6 +408,11 @@ inline void gta5view_export_save(QIODevice *ioDevice, RagePhotoData *data)
|
|||
ioDevice->write(uInt32Buffer, 4);
|
||||
}
|
||||
|
||||
inline bool gta5view_isGTAVFormat(uint32_t photoFormat)
|
||||
{
|
||||
return (photoFormat == G5EPhotoFormat::G5EX || photoFormat == RagePhoto::PhotoFormat::GTA5);
|
||||
}
|
||||
|
||||
// SNAPMATIC PICTURE CLASS
|
||||
SnapmaticPicture::SnapmaticPicture(const QString &fileName, QObject *parent) : QObject(parent), picFilePath(fileName)
|
||||
{
|
||||
|
@ -704,62 +708,62 @@ bool SnapmaticPicture::setPictureTitl(const QString &newTitle_)
|
|||
{
|
||||
QString newTitle = newTitle_;
|
||||
if (newTitle.length() > 39)
|
||||
newTitle = newTitle.left(39);
|
||||
newTitle.resize(39);
|
||||
p_ragePhoto.setTitle(newTitle.toStdString().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getExportPictureFileName()
|
||||
const QString SnapmaticPicture::getExportPictureFileName()
|
||||
{
|
||||
return picExportFileName;
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getOriginalPictureFileName()
|
||||
const QString SnapmaticPicture::getOriginalPictureFileName()
|
||||
{
|
||||
QString newPicFileName = picFileName;
|
||||
if (picFileName.right(4) == ".bak")
|
||||
newPicFileName = QString(picFileName).remove(picFileName.length() - 4, 4);
|
||||
if (picFileName.right(7) == ".hidden")
|
||||
newPicFileName = QString(picFileName).remove(picFileName.length() - 7, 7);
|
||||
if (picFileName.endsWith(".bak", Qt::CaseInsensitive))
|
||||
newPicFileName.resize(newPicFileName.length() - 4);
|
||||
if (picFileName.endsWith(".hidden", Qt::CaseInsensitive))
|
||||
newPicFileName.resize(newPicFileName.length() - 7);
|
||||
return newPicFileName;
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getOriginalPictureFilePath()
|
||||
const QString SnapmaticPicture::getOriginalPictureFilePath()
|
||||
{
|
||||
QString newPicFilePath = picFilePath;
|
||||
if (picFilePath.right(4) == ".bak")
|
||||
newPicFilePath = QString(picFilePath).remove(picFilePath.length() - 4, 4);
|
||||
if (picFilePath.right(7) == ".hidden")
|
||||
newPicFilePath = QString(picFilePath).remove(picFilePath.length() - 7, 7);
|
||||
if (picFileName.endsWith(".bak", Qt::CaseInsensitive))
|
||||
newPicFilePath.resize(newPicFilePath.length() - 4);
|
||||
if (picFileName.endsWith(".hidden", Qt::CaseInsensitive))
|
||||
newPicFilePath.resize(newPicFilePath.length() - 7);
|
||||
return newPicFilePath;
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getPictureFileName()
|
||||
const QString SnapmaticPicture::getPictureFileName()
|
||||
{
|
||||
return picFileName;
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getPictureFilePath()
|
||||
const QString SnapmaticPicture::getPictureFilePath()
|
||||
{
|
||||
return picFilePath;
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getPictureSortStr()
|
||||
const QString SnapmaticPicture::getPictureSortStr()
|
||||
{
|
||||
return sortStr;
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getPictureTitl()
|
||||
const QString SnapmaticPicture::getPictureTitl()
|
||||
{
|
||||
return p_ragePhoto.title();
|
||||
return QString::fromUtf8(p_ragePhoto.title());
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getPictureStr()
|
||||
const QString SnapmaticPicture::getPictureStr()
|
||||
{
|
||||
return pictureStr;
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getLastStep(bool readable)
|
||||
const QString SnapmaticPicture::getLastStep(bool readable)
|
||||
{
|
||||
if (readable) {
|
||||
QStringList lastStepList = lastStep.split(";/");
|
||||
|
@ -816,7 +820,7 @@ QString SnapmaticPicture::getLastStep(bool readable)
|
|||
|
||||
}
|
||||
|
||||
QImage SnapmaticPicture::getImage()
|
||||
const QImage SnapmaticPicture::getImage()
|
||||
{
|
||||
if (cacheEnabled)
|
||||
return cachePicture;
|
||||
|
@ -825,7 +829,7 @@ QImage SnapmaticPicture::getImage()
|
|||
return QImage();
|
||||
}
|
||||
|
||||
QByteArray SnapmaticPicture::getPictureStream()
|
||||
const QByteArray SnapmaticPicture::getPictureStream()
|
||||
{
|
||||
return QByteArray::fromRawData(p_ragePhoto.jpegData(), p_ragePhoto.jpegSize());
|
||||
}
|
||||
|
@ -858,7 +862,7 @@ bool SnapmaticPicture::isJsonOk()
|
|||
return jsonOk;
|
||||
}
|
||||
|
||||
QString SnapmaticPicture::getJsonStr()
|
||||
const QString SnapmaticPicture::getJsonStr()
|
||||
{
|
||||
return QString::fromUtf8(p_ragePhoto.json());
|
||||
}
|
||||
|
@ -870,6 +874,7 @@ SnapmaticProperties SnapmaticPicture::getSnapmaticProperties()
|
|||
|
||||
void SnapmaticPicture::parseJsonContent()
|
||||
{
|
||||
const uint32_t format = p_ragePhoto.format();
|
||||
QVariantMap jsonMap = jsonObject.toVariantMap();
|
||||
|
||||
bool jsonIncomplete = false;
|
||||
|
@ -906,7 +911,7 @@ void SnapmaticPicture::parseJsonContent()
|
|||
if (jsonObject["area"].isString()) { localProperties.location.area = jsonObject["area"].toString(); }
|
||||
else { jsonError = true; }
|
||||
}
|
||||
else { jsonIncomplete = true; }
|
||||
else if (gta5view_isGTAVFormat(format)) { jsonIncomplete = true; }
|
||||
if (jsonObject.contains("crewid")) {
|
||||
bool crewIDOk;
|
||||
localProperties.crewID = jsonMap["crewid"].toInt(&crewIDOk);
|
||||
|
@ -918,7 +923,7 @@ void SnapmaticPicture::parseJsonContent()
|
|||
localProperties.streetID = jsonMap["street"].toInt(&streetIDOk);
|
||||
if (!streetIDOk) { jsonError = true; }
|
||||
}
|
||||
else { jsonIncomplete = true; }
|
||||
else if (gta5view_isGTAVFormat(format)) { jsonIncomplete = true; }
|
||||
if (jsonObject.contains("creat")) {
|
||||
bool timestampOk;
|
||||
QDateTime createdTimestamp;
|
||||
|
@ -996,9 +1001,7 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties properties)
|
|||
|
||||
t_jsonObject["loc"] = locObject;
|
||||
t_jsonObject["uid"] = properties.uid;
|
||||
t_jsonObject["area"] = properties.location.area;
|
||||
t_jsonObject["crewid"] = properties.crewID;
|
||||
t_jsonObject["street"] = properties.streetID;
|
||||
t_jsonObject["creat"] = QJsonValue::fromVariant(properties.createdTimestamp);
|
||||
t_jsonObject["plyrs"] = QJsonValue::fromVariant(properties.playersList);
|
||||
t_jsonObject["meme"] = properties.isMeme;
|
||||
|
@ -1006,7 +1009,11 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties properties)
|
|||
t_jsonObject["slf"] = properties.isSelfie;
|
||||
t_jsonObject["drctr"] = properties.isFromDirector;
|
||||
t_jsonObject["rsedtr"] = properties.isFromRSEditor;
|
||||
t_jsonObject["onislandx"] = properties.location.isCayoPerico;
|
||||
if (gta5view_isGTAVFormat(p_ragePhoto.format())) {
|
||||
t_jsonObject["area"] = properties.location.area;
|
||||
t_jsonObject["street"] = properties.streetID;
|
||||
t_jsonObject["onislandx"] = properties.location.isCayoPerico;
|
||||
}
|
||||
|
||||
const QJsonDocument jsonDocument(t_jsonObject);
|
||||
if (setJsonStr(QString::fromUtf8(jsonDocument.toJson(QJsonDocument::Compact)))) {
|
||||
|
@ -1032,17 +1039,17 @@ bool SnapmaticPicture::setJsonStr(const QString &newJsonStr, bool updateProperti
|
|||
|
||||
// FILE MANAGEMENT
|
||||
|
||||
bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat format_)
|
||||
bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat format)
|
||||
{
|
||||
// Keep current format when Auto_Format is used
|
||||
SnapmaticFormat format = format_;
|
||||
if (format_ == SnapmaticFormat::Auto_Format) {
|
||||
if (p_ragePhoto.format() == G5EPhotoFormat::G5EX) {
|
||||
if (format == SnapmaticFormat::Auto_Format) {
|
||||
if (p_ragePhoto.format() == G5EPhotoFormat::G5EX)
|
||||
format = SnapmaticFormat::G5E_Format;
|
||||
}
|
||||
else {
|
||||
format = SnapmaticFormat::PGTA_Format;
|
||||
}
|
||||
else if (p_ragePhoto.format() == RagePhoto::PhotoFormat::GTA5)
|
||||
format = SnapmaticFormat::PGTA5_Format;
|
||||
else if (p_ragePhoto.format() == RagePhoto::PhotoFormat::RDR2)
|
||||
format = SnapmaticFormat::PRDR3_Format;
|
||||
else
|
||||
format = SnapmaticFormat::Unknown_Format;
|
||||
}
|
||||
|
||||
bool saveSuccess = false;
|
||||
|
@ -1159,7 +1166,12 @@ SnapmaticFormat SnapmaticPicture::getSnapmaticFormat()
|
|||
{
|
||||
if (p_ragePhoto.format() == G5EPhotoFormat::G5EX)
|
||||
return SnapmaticFormat::G5E_Format;
|
||||
return SnapmaticFormat::PGTA_Format;
|
||||
else if (p_ragePhoto.format() == RagePhoto::PhotoFormat::GTA5)
|
||||
return SnapmaticFormat::PGTA5_Format;
|
||||
else if (p_ragePhoto.format() == RagePhoto::PhotoFormat::RDR2)
|
||||
return SnapmaticFormat::PRDR3_Format;
|
||||
else
|
||||
return SnapmaticFormat::Unknown_Format;
|
||||
}
|
||||
|
||||
void SnapmaticPicture::setSnapmaticFormat(SnapmaticFormat format)
|
||||
|
@ -1168,11 +1180,15 @@ void SnapmaticPicture::setSnapmaticFormat(SnapmaticFormat format)
|
|||
p_ragePhoto.setFormat(G5EPhotoFormat::G5EX);
|
||||
return;
|
||||
}
|
||||
else if (format == SnapmaticFormat::PGTA_Format) {
|
||||
else if (format == SnapmaticFormat::PGTA5_Format) {
|
||||
p_ragePhoto.setFormat(RagePhoto::PhotoFormat::GTA5);
|
||||
return;
|
||||
}
|
||||
qDebug() << "setSnapmaticFormat: Invalid SnapmaticFormat defined, valid SnapmaticFormats are G5E_Format and PGTA_Format";
|
||||
else if (format == SnapmaticFormat::PRDR3_Format) {
|
||||
p_ragePhoto.setFormat(RagePhoto::PhotoFormat::RDR2);
|
||||
return;
|
||||
}
|
||||
qDebug() << "setSnapmaticFormat: Invalid SnapmaticFormat defined, valid SnapmaticFormats are G5E_Format, PGTA5_Format and PRDR3_Format";
|
||||
}
|
||||
|
||||
bool SnapmaticPicture::isFormatSwitched()
|
||||
|
|
|
@ -31,9 +31,8 @@ typedef RagePhotoA RagePhoto;
|
|||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QImage>
|
||||
#include <QFile>
|
||||
|
||||
enum class SnapmaticFormat : int { Auto_Format = 0, PGTA_Format = 1, JPEG_Format = 2, G5E_Format = 3 };
|
||||
enum class SnapmaticFormat : int32_t { Auto_Format = 0, PGTA5_Format = 1, PRDR3_Format = 2, JPEG_Format = 3, G5E_Format = 4, Unknown_Format = -1 };
|
||||
enum G5EExportFormat : uint32_t {
|
||||
G5E1P = 0x454C0010UL,
|
||||
G5E2P = 0x01000032UL,
|
||||
|
@ -79,17 +78,17 @@ public:
|
|||
bool readingPicture(bool cacheEnabled = false);
|
||||
bool isPicOk(); // Please use isPictureOk instead
|
||||
void clearCache();
|
||||
QImage getImage();
|
||||
QByteArray getPictureStream();
|
||||
QString getLastStep(bool readable = true);
|
||||
QString getPictureStr();
|
||||
QString getPictureTitl();
|
||||
QString getPictureSortStr();
|
||||
QString getPictureFileName();
|
||||
QString getPictureFilePath();
|
||||
QString getExportPictureFileName();
|
||||
QString getOriginalPictureFileName();
|
||||
QString getOriginalPictureFilePath();
|
||||
const QImage getImage();
|
||||
const QByteArray getPictureStream();
|
||||
const QString getLastStep(bool readable = true);
|
||||
const QString getPictureStr();
|
||||
const QString getPictureTitl();
|
||||
const QString getPictureSortStr();
|
||||
const QString getPictureFileName();
|
||||
const QString getPictureFilePath();
|
||||
const QString getExportPictureFileName();
|
||||
const QString getOriginalPictureFileName();
|
||||
const QString getOriginalPictureFilePath();
|
||||
bool setImage(const QImage &picture, bool eXtendMode = false);
|
||||
bool setPictureTitl(const QString &newTitle); // Please use setPictureTitle instead
|
||||
bool setPictureStream(const QByteArray &streamArray);
|
||||
|
@ -99,39 +98,40 @@ public:
|
|||
|
||||
// FILE MANAGEMENT
|
||||
bool exportPicture(const QString &fileName, SnapmaticFormat format = SnapmaticFormat::Auto_Format);
|
||||
void setPicFileName(const QString &picFileName); // Please use setPictureFileName instead
|
||||
void setPicFilePath(const QString &picFilePath); // Please use setPictureFilePath instead
|
||||
bool deletePicFile(); // Please use deletePictureFile instead
|
||||
void setPicFileName(const QString &picFileName);
|
||||
void setPicFilePath(const QString &picFilePath);
|
||||
bool deletePicFile();
|
||||
|
||||
// JSON
|
||||
bool isJsonOk();
|
||||
QString getJsonStr(); // Please use getPictureJson instead
|
||||
const QString getJsonStr();
|
||||
SnapmaticProperties getSnapmaticProperties();
|
||||
bool setSnapmaticProperties(SnapmaticProperties properties);
|
||||
bool setJsonStr(const QString &jsonStr, bool updateProperties = false); // Please use setPictureJson instead
|
||||
bool setJsonStr(const QString &jsonStr, bool updateProperties = false);
|
||||
|
||||
// VISIBILITY
|
||||
bool isHidden(); // Please use isPictureHidden instead
|
||||
bool isVisible(); // Please use isPictureVisible instead
|
||||
bool isHidden();
|
||||
bool isVisible();
|
||||
bool setPictureHidden();
|
||||
bool setPictureVisible();
|
||||
|
||||
// ALTERNATIVES (MORE DEVELOPER FRIENDLY FUNCTION CALLS)
|
||||
QString getJsonString() { return getJsonStr(); } // Please use getPictureJson instead
|
||||
QString getPictureJson() { return getJsonStr(); }
|
||||
QString getPictureTitle() { return getPictureTitl(); }
|
||||
QString getPictureString() { return getPictureStr(); }
|
||||
bool setJsonString(const QString &jsonString, bool updateProperties = false) { return setJsonStr(jsonString, updateProperties); } // Please use setPictureJson instead
|
||||
bool setPictureJson(const QString &json, bool updateProperties = false) { return setJsonStr(json, updateProperties); }
|
||||
bool setPictureTitle(const QString &title) { return setPictureTitl(title); }
|
||||
void setPictureFileName(const QString &fileName) { return setPicFileName(fileName); }
|
||||
void setPictureFilePath(const QString &filePath) { return setPicFilePath(filePath); }
|
||||
bool deletePictureFile() { return deletePicFile(); }
|
||||
bool isPictureOk() { return isPicOk(); }
|
||||
bool isPictureHidden() { return isHidden(); }
|
||||
bool isPictureVisible() { return isVisible(); }
|
||||
bool setHidden() { return setPictureHidden(); } // Please use setPictureHidden instead
|
||||
bool setVisible() { return setPictureVisible(); } // Please use setPictureVisible instead
|
||||
inline QString getJsonString() { return getJsonStr(); }
|
||||
inline QString getPictureJson() { return getJsonStr(); }
|
||||
inline QString getPictureTitle() { return getPictureTitl(); }
|
||||
inline uint32_t getPictureSize() { return ragePhoto()->jpegSize(); }
|
||||
inline QString getPictureString() { return getPictureStr(); }
|
||||
inline bool setJsonString(const QString &jsonString, bool updateProperties = false) { return setJsonStr(jsonString, updateProperties); } // Please use setPictureJson instead
|
||||
inline bool setPictureJson(const QString &json, bool updateProperties = false) { return setJsonStr(json, updateProperties); }
|
||||
inline bool setPictureTitle(const QString &title) { return setPictureTitl(title); }
|
||||
inline void setPictureFileName(const QString &fileName) { return setPicFileName(fileName); }
|
||||
inline void setPictureFilePath(const QString &filePath) { return setPicFilePath(filePath); }
|
||||
inline bool deletePictureFile() { return deletePicFile(); }
|
||||
inline bool isPictureOk() { return isPicOk(); }
|
||||
inline bool isPictureHidden() { return isHidden(); }
|
||||
inline bool isPictureVisible() { return isVisible(); }
|
||||
inline bool setHidden() { return setPictureHidden(); }
|
||||
inline bool setVisible() { return setPictureVisible(); }
|
||||
|
||||
// PREDEFINED PROPERTIES
|
||||
static QSize getSnapmaticResolution();
|
||||
|
|
|
@ -195,7 +195,7 @@ bool SnapmaticWidget::deletePicture()
|
|||
QJsonObject jsonObject;
|
||||
jsonObject["Type"] = "DeleteSuccess";
|
||||
jsonObject["ExtraFlags"] = "Snapmatic";
|
||||
jsonObject["DeletedSize"] = QString::number(smpic->ragePhoto()->photoSize());
|
||||
jsonObject["DeletedSize"] = QString::number(smpic->getPictureSize());
|
||||
#if QT_VERSION >= 0x060000
|
||||
jsonObject["DeletedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
|
||||
#else
|
||||
|
@ -381,7 +381,7 @@ void SnapmaticWidget::editSnapmaticImage()
|
|||
QJsonObject jsonObject;
|
||||
jsonObject["Type"] = "ImageEdited";
|
||||
jsonObject["ExtraFlags"] = "Interface";
|
||||
jsonObject["EditedSize"] = QString::number(smpic->ragePhoto()->photoSize());
|
||||
jsonObject["EditedSize"] = QString::number(smpic->getPictureSize());
|
||||
#if QT_VERSION >= 0x060000
|
||||
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
|
||||
#else
|
||||
|
@ -439,7 +439,7 @@ void SnapmaticWidget::openMapViewer()
|
|||
QJsonObject jsonObject;
|
||||
jsonObject["Type"] = "LocationEdited";
|
||||
jsonObject["ExtraFlags"] = "Interface";
|
||||
jsonObject["EditedSize"] = QString::number(smpic->ragePhoto()->photoSize());
|
||||
jsonObject["EditedSize"] = QString::number(smpic->getPictureSize());
|
||||
#if QT_VERSION >= 0x060000
|
||||
jsonObject["EditedTime"] = QString::number(QDateTime::currentDateTimeUtc().toSecsSinceEpoch());
|
||||
#else
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d75eba2a46ebee7c155502c0080ffb2b7fe32bcd
|
||||
Subproject commit 4ca8ac9297c571087836aab334a55f7414870876
|
Loading…
Reference in a new issue