gta5view/SnapmaticPicture.h

172 lines
6 KiB
C
Raw Normal View History

2017-10-09 08:35:48 +02:00
/*****************************************************************************
* gta5spv Grand Theft Auto Snapmatic Picture Viewer
2020-11-15 12:29:33 +01:00
* Copyright (C) 2016-2020 Syping
2017-10-09 08:35:48 +02: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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifndef SNAPMATICPICTURE_H
#define SNAPMATICPICTURE_H
#include "RagePhoto.h"
2017-10-09 08:35:48 +02:00
#include <QStringList>
#include <QDateTime>
#include <QObject>
#include <QString>
#include <QImage>
#include <QFile>
enum class SnapmaticFormat : int { Auto_Format = 0, PGTA_Format = 1, JPEG_Format = 2, G5E_Format = 3 };
struct SnapmaticProperties {
struct SnapmaticLocation {
QString area;
double x;
double y;
double z;
};
int uid;
int crewID;
int streetID;
2017-10-09 08:35:48 +02:00
QStringList playersList;
uint createdTimestamp;
QDateTime createdDateTime;
bool isMeme;
bool isMug;
bool isSelfie;
bool isFromDirector;
bool isFromRSEditor;
SnapmaticLocation location;
};
class SnapmaticPicture : public QObject
{
Q_OBJECT
public:
explicit SnapmaticPicture(const QString &fileName = "", QObject *parent = 0);
~SnapmaticPicture();
void reset();
bool preloadFile();
bool readingPictureFromFile(const QString &fileName, bool cacheEnabled = false);
bool readingPicture(bool cacheEnabled = false);
2017-12-12 04:45:46 +01:00
bool isPicOk(); // Please use isPictureOk instead
2017-10-09 08:35:48 +02:00
void clearCache();
QImage getImage();
2017-12-17 13:03:43 +01:00
QByteArray getPictureStream();
2017-12-12 04:45:46 +01:00
QString getLastStep(bool readable = true);
2017-10-09 08:35:48 +02:00
QString getPictureStr();
QString getPictureTitl();
QString getPictureSortStr();
QString getPictureFileName();
QString getPictureFilePath();
QString getExportPictureFileName();
2017-10-12 22:21:45 +02:00
QString getOriginalPictureFileName();
QString getOriginalPictureFilePath();
int getContentMaxLength();
2020-11-15 13:15:16 +01:00
bool setImage(const QImage &picture, bool eXtendMode = false);
2017-12-12 04:45:46 +01:00
bool setPictureTitl(const QString &newTitle); // Please use setPictureTitle instead
bool setPictureStream(const QByteArray &streamArray);
2017-10-09 08:35:48 +02:00
void updateStrings();
void emitUpdate();
2017-12-17 13:03:43 +01:00
void emitCustomSignal(const QString &signal);
2017-10-09 08:35:48 +02:00
// FILE MANAGEMENT
bool exportPicture(const QString &fileName, SnapmaticFormat format = SnapmaticFormat::Auto_Format);
2017-12-12 04:45:46 +01:00
void setPicFileName(const QString &picFileName); // Please use setPictureFileName instead
void setPicFilePath(const QString &picFilePath); // Please use setPictureFilePath instead
bool deletePicFile(); // Please use deletePictureFile instead
2017-10-09 08:35:48 +02:00
// JSON
bool isJsonOk();
2017-12-12 04:45:46 +01:00
QString getJsonStr(); // Please use getPictureJson instead
2017-10-09 08:35:48 +02:00
SnapmaticProperties getSnapmaticProperties();
2017-12-12 04:45:46 +01:00
bool setSnapmaticProperties(SnapmaticProperties properties);
bool setJsonStr(const QString &jsonStr, bool updateProperties = false); // Please use setPictureJson instead
2017-10-09 08:35:48 +02:00
// VISIBILITY
2017-12-12 04:45:46 +01:00
bool isHidden(); // Please use isPictureHidden instead
bool isVisible(); // Please use isPictureVisible instead
2017-10-09 08:35:48 +02:00
bool setPictureHidden();
bool setPictureVisible();
2017-12-12 04:45:46 +01:00
// 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
2017-10-09 08:35:48 +02:00
// PREDEFINED PROPERTIES
static QSize getSnapmaticResolution();
2017-10-09 08:35:48 +02:00
// SNAPMATIC FORMAT
SnapmaticFormat getSnapmaticFormat();
void setSnapmaticFormat(SnapmaticFormat format);
bool isFormatSwitched();
2017-10-09 08:35:48 +02:00
// VERIFY CONTENT
static bool verifyTitle(const QString &title);
// STRING OPERATIONS
static QString parseTitleString(const QByteArray &commitBytes, int maxLength);
static QString convertDrawStringForLog(const QString &inputStr);
static QString convertLogStringForDraw(const QString &inputStr);
2020-11-15 12:29:33 +01:00
// RAGEPHOTO
RagePhoto* ragePhoto();
2017-10-09 08:35:48 +02:00
private:
QImage cachePicture;
QString picExportFileName;
QString picFileName;
QString picFilePath;
QString pictureStr;
QString lastStep;
QString sortStr;
bool picOk;
bool cacheEnabled;
bool isFormatSwitch;
2017-10-09 08:35:48 +02:00
// JSON
void parseJsonContent();
bool jsonOk;
2017-12-12 04:45:46 +01:00
SnapmaticProperties localProperties;
2017-10-09 08:35:48 +02:00
// VERIFY CONTENT
static bool verifyTitleChar(const QChar &titleChar);
// RAGEPHOTO
2020-11-15 12:29:33 +01:00
RagePhoto p_ragePhoto;
2017-10-09 08:35:48 +02:00
signals:
2017-12-17 13:03:43 +01:00
void customSignal(QString signal);
2017-10-09 08:35:48 +02:00
void preloaded();
void updated();
void loaded();
public slots:
};
#endif // SNAPMATICPICTURE_H