2016-02-26 22:22:34 +01:00
|
|
|
/*****************************************************************************
|
2017-06-05 18:16:17 +02:00
|
|
|
* gta5sync-spv Grand Theft Auto Snapmatic Picture Viewer
|
2017-02-11 04:21:55 +01:00
|
|
|
* Copyright (C) 2016-2017 Syping
|
2016-02-26 22:22:34 +01:00
|
|
|
*
|
2016-03-21 07:54:14 +01:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2016-02-26 22:22:34 +01:00
|
|
|
*
|
2016-03-21 07:54:14 +01:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2016-02-26 22:22:34 +01:00
|
|
|
*
|
2016-03-21 07:54:14 +01:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-02-26 22:22:34 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2016-03-20 21:57:18 +01:00
|
|
|
#ifndef SNAPMATICPICTURE_H
|
|
|
|
#define SNAPMATICPICTURE_H
|
2016-02-26 22:22:34 +01:00
|
|
|
|
2016-03-21 21:33:22 +01:00
|
|
|
#include <QStringList>
|
2016-05-08 19:07:55 +02:00
|
|
|
#include <QDateTime>
|
2016-03-20 21:57:18 +01:00
|
|
|
#include <QObject>
|
2016-03-21 03:10:28 +01:00
|
|
|
#include <QString>
|
2016-03-27 09:52:23 +02:00
|
|
|
#include <QImage>
|
2016-03-21 03:10:28 +01:00
|
|
|
#include <QFile>
|
2016-02-26 22:22:34 +01:00
|
|
|
|
2016-12-10 04:35:24 +01:00
|
|
|
struct SnapmaticProperties {
|
|
|
|
struct SnapmaticLocation {
|
2017-02-11 04:21:55 +01:00
|
|
|
QString area;
|
2016-12-10 04:35:24 +01:00
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
double z;
|
|
|
|
};
|
2017-02-11 04:21:55 +01:00
|
|
|
int uid;
|
2016-12-10 04:35:24 +01:00
|
|
|
int crewID;
|
|
|
|
QStringList playersList;
|
|
|
|
uint createdTimestamp;
|
|
|
|
QDateTime createdDateTime;
|
|
|
|
bool isMeme;
|
|
|
|
bool isMug;
|
|
|
|
bool isSelfie;
|
|
|
|
bool isFromDirector;
|
|
|
|
bool isFromRSEditor;
|
|
|
|
SnapmaticLocation location;
|
|
|
|
};
|
|
|
|
|
2016-03-20 21:57:18 +01:00
|
|
|
class SnapmaticPicture : public QObject
|
2016-02-26 22:22:34 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2016-04-06 04:22:30 +02:00
|
|
|
explicit SnapmaticPicture(const QString &fileName = "", QObject *parent = 0);
|
2016-12-09 23:13:21 +01:00
|
|
|
~SnapmaticPicture();
|
2017-02-11 04:21:55 +01:00
|
|
|
void reset();
|
2017-06-05 18:16:17 +02:00
|
|
|
bool readingPictureFromFile(const QString &fileName, bool writeEnabled = true, bool cacheEnabled = false, bool fastLoad = true, bool lowRamMode = false);
|
|
|
|
bool readingPicture(bool writeEnabled = true, bool cacheEnabled = false, bool fastLoad = true, bool lowRamMode = false);
|
2016-03-21 22:29:57 +01:00
|
|
|
bool isPicOk();
|
2016-12-09 23:13:21 +01:00
|
|
|
void clearCache();
|
2017-02-11 04:21:55 +01:00
|
|
|
QImage getImage();
|
2016-03-21 03:10:28 +01:00
|
|
|
QString getLastStep();
|
|
|
|
QString getPictureStr();
|
2017-02-11 04:21:55 +01:00
|
|
|
QString getPictureHead();
|
2016-03-29 13:17:38 +02:00
|
|
|
QString getPictureTitl();
|
|
|
|
QString getPictureDesc();
|
2016-04-06 04:22:30 +02:00
|
|
|
QString getPictureSortStr();
|
2016-04-03 10:17:01 +02:00
|
|
|
QString getPictureFileName();
|
2017-02-11 04:21:55 +01:00
|
|
|
QString getPictureFilePath();
|
2016-04-06 04:22:30 +02:00
|
|
|
QString getExportPictureFileName();
|
2017-02-11 04:21:55 +01:00
|
|
|
int getContentMaxLength();
|
|
|
|
bool setImage(const QImage &picture);
|
|
|
|
bool setPictureTitl(const QString &newTitle);
|
|
|
|
bool setPictureStream(const QByteArray &picByteArray);
|
|
|
|
void updateStrings();
|
2017-03-01 15:19:40 +01:00
|
|
|
void emitUpdate();
|
|
|
|
|
|
|
|
// FILE MANAGEMENT
|
2017-03-30 03:44:48 +02:00
|
|
|
bool exportPicture(const QString &fileName, const QString format = "PGTA");
|
2017-03-01 15:19:40 +01:00
|
|
|
void setPicFileName(const QString &picFileName);
|
|
|
|
void setPicFilePath(const QString &picFilePath);
|
|
|
|
bool deletePicFile();
|
2017-02-11 04:21:55 +01:00
|
|
|
|
|
|
|
// ALTERNATIVES
|
|
|
|
QString getPictureTitle() { return getPictureTitl(); }
|
|
|
|
QString getPictureString() { return getPictureStr(); }
|
|
|
|
QString getPictureDescription() { return getPictureDesc(); }
|
|
|
|
bool setPictureTitle(const QString &newTitle) { return setPictureTitl(newTitle); }
|
2016-02-26 22:22:34 +01:00
|
|
|
|
2016-03-21 21:33:22 +01:00
|
|
|
// JSON
|
2016-03-21 22:29:57 +01:00
|
|
|
bool isJsonOk();
|
2016-03-21 21:33:22 +01:00
|
|
|
QString getJsonStr();
|
2016-12-10 04:35:24 +01:00
|
|
|
SnapmaticProperties getSnapmaticProperties();
|
2016-12-10 05:56:09 +01:00
|
|
|
bool setSnapmaticProperties(SnapmaticProperties newSpJson);
|
2016-03-21 21:33:22 +01:00
|
|
|
|
2016-10-27 08:59:08 +02:00
|
|
|
// VISIBILITY
|
|
|
|
bool isHidden();
|
|
|
|
bool setPictureHidden();
|
|
|
|
bool setPictureVisible();
|
|
|
|
|
2017-02-17 12:07:37 +01:00
|
|
|
// PREDEFINED PROPERTIES
|
|
|
|
QSize getSnapmaticResolution();
|
|
|
|
|
2017-02-25 06:30:37 +01:00
|
|
|
// VERIFY CONTENT
|
|
|
|
static bool verifyTitle(const QString &title);
|
|
|
|
|
2016-02-26 22:22:34 +01:00
|
|
|
private:
|
2017-02-11 04:21:55 +01:00
|
|
|
QString getSnapmaticHeaderString(const QByteArray &snapmaticHeader);
|
2016-04-06 04:22:30 +02:00
|
|
|
QString getSnapmaticJSONString(const QByteArray &jsonBytes);
|
|
|
|
QString getSnapmaticTIDEString(const QByteArray &tideBytes);
|
2016-03-27 09:52:23 +02:00
|
|
|
QImage cachePicture;
|
2016-04-06 04:22:30 +02:00
|
|
|
QString picExportFileName;
|
2016-03-21 03:10:28 +01:00
|
|
|
QString picFileName;
|
2017-02-11 04:21:55 +01:00
|
|
|
QString picFilePath;
|
|
|
|
QString pictureHead;
|
2016-03-21 03:10:28 +01:00
|
|
|
QString pictureStr;
|
|
|
|
QString lastStep;
|
2016-04-06 04:22:30 +02:00
|
|
|
QString sortStr;
|
2016-03-29 13:17:38 +02:00
|
|
|
QString titlStr;
|
|
|
|
QString descStr;
|
2016-03-21 22:29:57 +01:00
|
|
|
bool picOk;
|
2017-06-05 18:16:17 +02:00
|
|
|
bool lowRamMode;
|
2016-07-23 00:13:57 +02:00
|
|
|
bool writeEnabled;
|
2016-12-09 23:13:21 +01:00
|
|
|
bool cacheEnabled;
|
2017-02-11 04:21:55 +01:00
|
|
|
bool isCustomFormat;
|
|
|
|
int jpegRawContentSize;
|
2017-03-30 03:44:48 +02:00
|
|
|
int jpegRawContentSizeE;
|
2016-03-21 21:33:22 +01:00
|
|
|
|
2017-02-25 06:30:37 +01:00
|
|
|
// PICTURE STREAM
|
2016-07-22 16:06:36 +02:00
|
|
|
QByteArray rawPicContent;
|
|
|
|
|
2016-03-21 21:33:22 +01:00
|
|
|
// JSON
|
2016-12-10 05:56:09 +01:00
|
|
|
void parseJsonContent();
|
2016-03-21 22:29:57 +01:00
|
|
|
bool jsonOk;
|
2016-03-20 21:57:18 +01:00
|
|
|
QString jsonStr;
|
2016-12-10 04:35:24 +01:00
|
|
|
SnapmaticProperties localSpJson;
|
2016-03-20 21:57:18 +01:00
|
|
|
|
2017-02-25 06:30:37 +01:00
|
|
|
// VERIFY CONTENT
|
|
|
|
static bool verifyTitleChar(const QChar &titleChar);
|
|
|
|
|
2016-03-20 21:57:18 +01:00
|
|
|
signals:
|
2017-03-01 15:19:40 +01:00
|
|
|
void updated();
|
2016-03-20 21:57:18 +01:00
|
|
|
|
|
|
|
public slots:
|
2016-02-26 22:22:34 +01:00
|
|
|
};
|
|
|
|
|
2016-03-20 21:57:18 +01:00
|
|
|
#endif // SNAPMATICPICTURE_H
|