From 88f43b55d3da83ba650524eea096a557493ed8c1 Mon Sep 17 00:00:00 2001 From: Syping Date: Sat, 25 Feb 2017 06:30:37 +0100 Subject: [PATCH] last changes from gta5sync --- ProfileInterface.cpp | 2 +- SnapmaticPicture.cpp | 70 ++++++++++++++++++++++++++++++-------------- SnapmaticPicture.h | 24 +++++---------- 3 files changed, 56 insertions(+), 40 deletions(-) diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index 021b5cf..4ce95af 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -1063,7 +1063,7 @@ void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev) SnapmaticWidget *picWidget = (SnapmaticWidget*)sender(); QMenu contextMenu(picWidget); QMenu editMenu(SnapmaticWidget::tr("Edi&t"), picWidget); - if (isHidden()) + if (picWidget->isHidden()) { editMenu.addAction(SnapmaticWidget::tr("Show &In-game"), picWidget, SLOT(makePictureVisibleSlot())); } diff --git a/SnapmaticPicture.cpp b/SnapmaticPicture.cpp index c4fb88a..23201fb 100755 --- a/SnapmaticPicture.cpp +++ b/SnapmaticPicture.cpp @@ -31,27 +31,26 @@ #include #include +// PARSER ALLOCATIONS +#define snapmaticHeaderLength 278 +#define snapmaticUsefulLength 260 +#define snapmaticFileMaxSize 528192 +#define jpegHeaderLineDifStr 2 +#define jpegPreHeaderLength 14 +#define jpegPicStreamLength 524288 +#define jsonStreamLength 3076 +#define tideStreamLength 260 + +// EDITOR ALLOCATIONS +#define jpegStreamEditorBegin 292 +#define jsonStreamEditorBegin 524588 +#define jsonStreamEditorLength 3072 +#define titlStreamEditorBegin 527668 +#define titlStreamEditorLength 256 +#define titlStreamCharacterMax 39 + SnapmaticPicture::SnapmaticPicture(const QString &fileName, QObject *parent) : QObject(parent), picFilePath(fileName) { - // PARSE INT INIT - DO NOT CHANGE THIS VALUES - snapmaticHeaderLength = 278; - snapmaticUsefulLength = 260; - snapmaticFileMaxSize = 528192; - jpegHeaderLineDifStr = 2; - jpegPreHeaderLength = 14; - jpegPicStreamLength = 524288; - jsonStreamLength = 3076; - tideStreamLength = 260; - - // PARSE EDITOR INIT - jpegStreamEditorBegin = 292; - jsonStreamEditorBegin = 524588; - jsonStreamEditorLength = 3072; - titlStreamEditorBegin = 527668; - titlStreamEditorLength = 256; - titlStreamCharacterMax = 39; - rawPicContent = ""; - // PREDEFINED PROPERTIES snapmaticResolution = QSize(960, 536); @@ -64,10 +63,8 @@ SnapmaticPicture::~SnapmaticPicture() void SnapmaticPicture::reset() { - // PARSE EDITOR INIT - rawPicContent = ""; - // INIT PIC + rawPicContent = ""; cachePicture = QImage(0, 0, QImage::Format_RGB888); jpegRawContentSize = 0; picExportFileName = ""; @@ -362,6 +359,8 @@ void SnapmaticPicture::updateStrings() cmpPicTitl.replace(" ", "_"); cmpPicTitl.replace(":", "-"); cmpPicTitl.replace("\\", ""); + cmpPicTitl.replace("{", ""); + cmpPicTitl.replace("}", ""); cmpPicTitl.replace("/", ""); cmpPicTitl.replace("<", ""); cmpPicTitl.replace(">", ""); @@ -867,3 +866,30 @@ QSize SnapmaticPicture::getSnapmaticResolution() { return snapmaticResolution; } + +// VERIFY CONTENT + +bool SnapmaticPicture::verifyTitle(const QString &title) +{ + // VERIFY TITLE FOR BE A VALID SNAPMATIC TITLE + if (title.length() <= titlStreamCharacterMax) + { + foreach(const QChar &titleChar, title) + { + if (!verifyTitleChar(titleChar)) return false; + } + return true; + } + return false; +} + +bool SnapmaticPicture::verifyTitleChar(const QChar &titleChar) +{ + // VERIFY CHAR FOR BE A VALID SNAPMATIC CHARACTER + if (titleChar.isLetterOrNumber() || titleChar.isPrint()) + { + if (titleChar == '<' || titleChar == '>' || titleChar == '\\') return false; + return true; + } + return false; +} diff --git a/SnapmaticPicture.h b/SnapmaticPicture.h index 49a3d3d..034636b 100755 --- a/SnapmaticPicture.h +++ b/SnapmaticPicture.h @@ -96,6 +96,9 @@ public: // PREDEFINED PROPERTIES QSize getSnapmaticResolution(); + // VERIFY CONTENT + static bool verifyTitle(const QString &title); + private: QString getSnapmaticHeaderString(const QByteArray &snapmaticHeader); QString getSnapmaticJSONString(const QByteArray &jsonBytes); @@ -116,23 +119,7 @@ private: bool isCustomFormat; int jpegRawContentSize; - // PARSE INT - int snapmaticHeaderLength; - int snapmaticUsefulLength; - int snapmaticFileMaxSize; - int jpegHeaderLineDifStr; - int jpegPreHeaderLength; - int jpegPicStreamLength; - int jsonStreamLength; - int tideStreamLength; - - // PARSE EDITOR - int jpegStreamEditorBegin; - int jsonStreamEditorBegin; - int jsonStreamEditorLength; - int titlStreamEditorBegin; - int titlStreamEditorLength; - int titlStreamCharacterMax; + // PICTURE STREAM QByteArray rawPicContent; // PREDEFINED PROPERTIES @@ -144,6 +131,9 @@ private: QString jsonStr; SnapmaticProperties localSpJson; + // VERIFY CONTENT + static bool verifyTitleChar(const QChar &titleChar); + signals: public slots: