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