first development version of 1.4.x

This commit is contained in:
Syping 2017-03-01 15:19:40 +01:00
parent 1ff4f353e3
commit 24b1f32bbe
63 changed files with 4792 additions and 4350 deletions

View file

@ -25,9 +25,10 @@ AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutDialog)
{
ui->setupUi(this);
aboutStr = ui->labAbout->text();
titleStr = this->windowTitle();
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
// Build Strings
QString appVersion = qApp->applicationVersion();
QString buildType = GTA5SYNC_BUILDTYPE;
buildType.replace("_", " ");
@ -38,6 +39,11 @@ AboutDialog::AboutDialog(QWidget *parent) :
#else
QString projectDes = tr("A project for viewing Grand Theft Auto V Snapmatic<br/>\nPictures and Savegames");
#endif
// Setup User Interface
ui->setupUi(this);
aboutStr = ui->labAbout->text();
titleStr = this->windowTitle();
ui->labAbout->setText(aboutStr.arg(appVersion % " (" % buildType % ")", buildStr, qVersion(), projectBuild, GTA5SYNC_APPVENDORLINK, GTA5SYNC_APPVENDOR, GTA5SYNC_COPYRIGHT, GTA5SYNC_APPSTR, projectDes));
this->setWindowTitle(titleStr.arg(GTA5SYNC_APPSTR));

View file

@ -150,9 +150,7 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
waitingLoop->exec();
delete waitingLoop;
netReply->deleteLater();
delete netReply;
netManager->deleteLater();
delete netManager;
}
}
@ -224,9 +222,7 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
currentPage++;
}
netReply->deleteLater();
delete netReply;
netManager->deleteLater();
delete netManager;
}
}

View file

@ -23,6 +23,15 @@
#include <QImage>
#include <QDebug>
// IMAGES VALUES
#define snapmaticResolutionW 960
#define snapmaticResolutionH 536
#define snapmaticResolutionLW 430
#define snapmaticResolutionLH 240
#define snapmaticAvatarResolution 470
#define snapmaticAvatarPlacementW 145
#define snapmaticAvatarPlacementH 66
ImportDialog::ImportDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ImportDialog)
@ -51,7 +60,7 @@ ImportDialog::~ImportDialog()
void ImportDialog::processImage()
{
QImage snapmaticImage = workImage;
QPixmap snapmaticPixmap(960, 536);
QPixmap snapmaticPixmap(snapmaticResolutionW, snapmaticResolutionH);
snapmaticPixmap.fill(Qt::black);
QPainter snapmaticPainter(&snapmaticPixmap);
if (ui->cbAvatar->isChecked())
@ -61,24 +70,23 @@ void ImportDialog::processImage()
int diffHeight = 0;
if (ui->rbKeep->isChecked())
{
snapmaticImage = snapmaticImage.scaled(470, 470, Qt::KeepAspectRatio, Qt::SmoothTransformation);
snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (snapmaticImage.width() > snapmaticImage.height())
{
diffHeight = 470 - snapmaticImage.height();
diffHeight = snapmaticAvatarResolution - snapmaticImage.height();
diffHeight = diffHeight / 2;
}
else if (snapmaticImage.width() < snapmaticImage.height())
{
diffWidth = 470 - snapmaticImage.width();
diffWidth = snapmaticAvatarResolution - snapmaticImage.width();
diffWidth = diffWidth / 2;
}
}
else
{
snapmaticImage = snapmaticImage.scaled(470, 470, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
snapmaticPainter.drawImage(0, 0, avatarAreaImage);
snapmaticPainter.drawImage(145 + diffWidth, 66 + diffHeight, snapmaticImage);
snapmaticPainter.drawImage(snapmaticAvatarPlacementW + diffWidth, snapmaticAvatarPlacementH + diffHeight, snapmaticImage);
imageTitle = "Custom Avatar";
}
else
@ -88,28 +96,28 @@ void ImportDialog::processImage()
int diffHeight = 0;
if (ui->rbKeep->isChecked())
{
snapmaticImage = snapmaticImage.scaled(960, 536, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (snapmaticImage.width() != 960)
snapmaticImage = snapmaticImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (snapmaticImage.width() != snapmaticResolutionW)
{
diffWidth = 960 - snapmaticImage.width();
diffWidth = snapmaticResolutionW - snapmaticImage.width();
diffWidth = diffWidth / 2;
}
else if (snapmaticImage.height() != 536)
else if (snapmaticImage.height() != snapmaticResolutionH)
{
diffHeight = 536 - snapmaticImage.height();
diffHeight = snapmaticResolutionH - snapmaticImage.height();
diffHeight = diffHeight / 2;
}
}
else
{
snapmaticImage = snapmaticImage.scaled(960, 536, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
snapmaticImage = snapmaticImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, snapmaticImage);
imageTitle = "Custom Picture";
}
snapmaticPainter.end();
newImage = snapmaticPixmap.toImage();
ui->labPicture->setPixmap(snapmaticPixmap.scaled(430, 240, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
ui->labPicture->setPixmap(snapmaticPixmap.scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
QImage ImportDialog::image()
@ -162,3 +170,13 @@ void ImportDialog::on_cmdOK_clicked()
doImport = true;
close();
}
void ImportDialog::on_labPicture_labelPainted()
{
if (ui->cbAvatar->isChecked())
{
QPainter labelPainter(ui->labPicture);
labelPainter.drawImage(0, 0, avatarAreaImage.scaled(snapmaticResolutionLW, snapmaticResolutionLH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
labelPainter.end();
}
}

View file

@ -44,6 +44,7 @@ private slots:
void on_cbAvatar_clicked();
void on_cmdCancel_clicked();
void on_cmdOK_clicked();
void on_labPicture_labelPainted();
private:
Ui::ImportDialog *ui;

View file

@ -42,7 +42,7 @@
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labPicture">
<widget class="UiModLabel" name="labPicture">
<property name="minimumSize">
<size>
<width>430</width>
@ -175,6 +175,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>UiModLabel</class>
<extends>QLabel</extends>
<header>UiModLabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View file

@ -37,6 +37,10 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
QDialog(parent), profileDB(profileDB),
ui(new Ui::OptionsDialog)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
// Setup User Interface
ui->setupUi(this);
ui->tabWidget->setCurrentIndex(0);
ui->labPicCustomRes->setVisible(false);

View file

@ -23,6 +23,7 @@
#include "SidebarGenerator.h"
#include "StandardPaths.h"
#include "PictureExport.h"
#include "StringParser.h"
#include "GlobalString.h"
#include "UiModLabel.h"
@ -89,6 +90,10 @@ PictureDialog::PictureDialog(bool primaryWindow, QWidget *parent) :
void PictureDialog::setupPictureDialog(bool withDatabase_)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
// Setup User Interface
ui->setupUi(this);
windowTitleStr = this->windowTitle();
jsonDrawString = ui->labJSON->text();
@ -422,7 +427,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
}
created = picture->getSnapmaticProperties().createdDateTime.toString(Qt::DefaultLocaleShortDate);
plyrsList = picture->getSnapmaticProperties().playersList;
picTitl = picture->getPictureTitl();
picTitl = StringParser::escapeString(picture->getPictureTitle());
picArea = picture->getSnapmaticProperties().location.area;
if (globalMap.contains(picArea))
{
@ -596,7 +601,7 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button)
if (button == Qt::LeftButton)
{
QRect desktopRect = QApplication::desktop()->screenGeometry(this);
PictureWidget *pictureWidget = new PictureWidget(this);
PictureWidget *pictureWidget = new PictureWidget(this); // Work!
pictureWidget->setObjectName("PictureWidget");
#if QT_VERSION >= 0x050600
pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint^Qt::WindowStaysOnTopHint^Qt::MaximizeUsingFullscreenGeometryHint);
@ -620,8 +625,8 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button)
pictureWidget->raise();
pictureWidget->exec();
fullscreenWidget = 0;
delete pictureWidget;
fullscreenWidget = 0; // Work!
delete pictureWidget; // Work!
}
}

View file

@ -76,7 +76,7 @@ void PictureExport::exportAsPicture(QWidget *parent, SnapmaticPicture *picture)
settings.beginGroup("FileDialogs");
settings.beginGroup("ExportAsPicture");
fileDialogPreSave:
fileDialogPreSave: //Work?
QFileDialog fileDialog(parent);
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setViewMode(QFileDialog::Detail);
@ -145,12 +145,12 @@ fileDialogPreSave:
if (!QFile::remove(selectedFile))
{
QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("Failed to overwrite %1 with current Snapmatic picture").arg("\""+selectedFile+"\""));
goto fileDialogPreSave;
goto fileDialogPreSave; //Work?
}
}
else
{
goto fileDialogPreSave;
goto fileDialogPreSave; //Work?
}
}
@ -179,13 +179,13 @@ fileDialogPreSave:
if (!isSaved)
{
QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave;
goto fileDialogPreSave; //Work?
}
}
else
{
QMessageBox::warning(parent, PictureDialog::tr("Export as JPG picture"), PictureDialog::tr("No valid file is selected"));
goto fileDialogPreSave;
goto fileDialogPreSave; //Work?
}
}
@ -207,7 +207,7 @@ void PictureExport::exportAsSnapmatic(QWidget *parent, SnapmaticPicture *picture
adjustedPicPath.remove(adjustedPicPath.length() - 7, 7);
}
fileDialogPreSave:
fileDialogPreSave: //Work?
QFileInfo sgdFileInfo(adjustedPicPath);
QFileDialog fileDialog(parent);
fileDialog.setFileMode(QFileDialog::AnyFile);
@ -218,7 +218,7 @@ fileDialogPreSave:
fileDialog.setDefaultSuffix(".rem");
fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
fileDialog.setWindowTitle(PictureDialog::tr("Export as GTA Snapmatic..."));
fileDialog.setLabelText(QFileDialog::Accept, PictureDialog::tr("&Export"));
fileDialog.setLabelText(QFileDialog::Accept, PictureDialog::tr("Export"));
QStringList filters;
filters << PictureDialog::tr("GTA V Export (*.g5e)");
@ -248,12 +248,12 @@ fileDialogPreSave:
if (!QFile::remove(selectedFile))
{
QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Failed to overwrite %1 with current Snapmatic picture").arg("\""+selectedFile+"\""));
goto fileDialogPreSave;
goto fileDialogPreSave; //Work?
}
}
else
{
goto fileDialogPreSave;
goto fileDialogPreSave; //Work?
}
}
@ -263,7 +263,7 @@ fileDialogPreSave:
if (!isExported)
{
QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave;
goto fileDialogPreSave; //Work?
}
}
else
@ -284,7 +284,7 @@ fileDialogPreSave:
if (!isCopied)
{
QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("Failed to export current Snapmatic picture"));
goto fileDialogPreSave;
goto fileDialogPreSave; //Work?
}
else
{
@ -295,7 +295,7 @@ fileDialogPreSave:
else
{
QMessageBox::warning(parent, PictureDialog::tr("Export as GTA Snapmatic"), PictureDialog::tr("No valid file is selected"));
goto fileDialogPreSave;
goto fileDialogPreSave; //Work?
}
}

View file

@ -42,6 +42,7 @@
#include <QPalette>
#include <QPainter>
#include <QRegExp>
#include <QAction>
#include <QDebug>
#include <QColor>
#include <QTimer>
@ -79,22 +80,18 @@ ProfileInterface::~ProfileInterface()
foreach(ProfileWidget *widget, widgets.keys())
{
widgets.remove(widget);
widget->deleteLater();
delete widget;
}
foreach(SavegameData *savegame, savegames)
{
savegames.removeAll(savegame);
savegame->deleteLater();
delete savegame;
}
foreach(SnapmaticPicture *picture, pictures)
{
pictures.removeAll(picture);
picture->deleteLater();
delete picture;
}
profileLoader->deleteLater();
delete profileLoader;
delete ui;
@ -318,32 +315,50 @@ void ProfileInterface::profileLoaded_p()
void ProfileInterface::savegameDeleted_event()
{
savegameDeleted((SavegameWidget*)sender());
savegameDeleted((SavegameWidget*)sender(), true);
}
void ProfileInterface::savegameDeleted(SavegameWidget *sgdWidget)
void ProfileInterface::savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteEmited)
{
SavegameData *savegame = sgdWidget->getSavegame();
if (sgdWidget->isSelected()) { sgdWidget->setSelected(false); }
widgets.remove(sgdWidget);
sgdWidget->close();
sgdWidget->deleteLater();
// Deleting when the widget did send a event cause a crash
if (isRemoteEmited)
{
sgdWidget->deleteLater();
}
else
{
delete sgdWidget;
}
savegames.removeAll(savegame);
delete savegame;
}
void ProfileInterface::pictureDeleted_event()
{
pictureDeleted((SnapmaticWidget*)sender());
pictureDeleted((SnapmaticWidget*)sender(), true);
}
void ProfileInterface::pictureDeleted(SnapmaticWidget *picWidget)
void ProfileInterface::pictureDeleted(SnapmaticWidget *picWidget, bool isRemoteEmited)
{
SnapmaticPicture *picture = picWidget->getPicture();
if (picWidget->isSelected()) { picWidget->setSelected(false); }
widgets.remove(picWidget);
picWidget->close();
picWidget->deleteLater();
// Deleting when the widget did send a event cause a crash
if (isRemoteEmited)
{
picWidget->deleteLater();
}
else
{
delete picWidget;
}
pictures.removeAll(picture);
delete picture;
}
@ -359,7 +374,7 @@ void ProfileInterface::on_cmdImport_clicked()
settings.beginGroup("FileDialogs");
settings.beginGroup("ImportCopy");
fileDialogPreOpen:
fileDialogPreOpen: //Work?
QFileDialog fileDialog(this);
fileDialog.setFileMode(QFileDialog::ExistingFiles);
fileDialog.setViewMode(QFileDialog::Detail);
@ -390,7 +405,7 @@ fileDialogPreOpen:
if (selectedFiles.length() == 1)
{
QString selectedFile = selectedFiles.at(0);
if (!importFile(selectedFile, true, 0)) goto fileDialogPreOpen;
if (!importFile(selectedFile, true, 0)) goto fileDialogPreOpen; //Work?
}
else if (selectedFiles.length() > 1)
{
@ -463,7 +478,7 @@ fileDialogPreOpen:
else
{
QMessageBox::warning(this, tr("Import"), tr("No valid file is selected"));
goto fileDialogPreOpen;
goto fileDialogPreOpen; //Work?
}
}
@ -920,7 +935,6 @@ void ProfileInterface::exportSelected()
if (exportThread->isFinished())
{
exportThread->deleteLater();
delete exportThread;
}
else
@ -928,7 +942,6 @@ void ProfileInterface::exportSelected()
QEventLoop threadFinishLoop;
QObject::connect(exportThread, SIGNAL(finished()), &threadFinishLoop, SLOT(quit()));
threadFinishLoop.exec();
exportThread->deleteLater();
delete exportThread;
}
}
@ -954,8 +967,7 @@ void ProfileInterface::deleteSelected()
if (widget->getWidgetType() == "SnapmaticWidget")
{
SnapmaticWidget *picWidget = (SnapmaticWidget*)widget;
QString fileName = picWidget->getPicturePath();
if (!QFile::exists(fileName) || QFile::remove(fileName))
if (picWidget->getPicture()->deletePicFile())
{
pictureDeleted(picWidget);
}

View file

@ -98,8 +98,8 @@ private:
bool importSavegameData(SavegameData *savegame, QString sgdPath, bool warn = true);
void pictureLoaded(SnapmaticPicture *picture, bool inserted);
void savegameLoaded(SavegameData *savegame, QString savegamePath, bool inserted);
void savegameDeleted(SavegameWidget *sgdWidget);
void pictureDeleted(SnapmaticWidget *picWidget);
void savegameDeleted(SavegameWidget *sgdWidget, bool isRemoteEmited = false);
void pictureDeleted(SnapmaticWidget *picWidget, bool isRemoteEmited = false);
void insertSnapmaticIPI(QWidget *widget);
void insertSavegameIPI(QWidget *widget);
void sortingProfileInterface();

View file

@ -34,7 +34,7 @@ void SavegameCopy::copySavegame(QWidget *parent, QString sgdPath)
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
fileDialogPreSave:
fileDialogPreSave: //Work?
QFileInfo sgdFileInfo(sgdPath);
QFileDialog fileDialog(parent);
fileDialog.setFileMode(QFileDialog::AnyFile);
@ -72,12 +72,12 @@ fileDialogPreSave:
if (!QFile::remove(selectedFile))
{
QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("Failed to overwrite %1 with current Savegame").arg("\""+selectedFile+"\""));
goto fileDialogPreSave;
goto fileDialogPreSave; //Work?
}
}
else
{
goto fileDialogPreSave;
goto fileDialogPreSave; //Work?
}
}
@ -85,13 +85,13 @@ fileDialogPreSave:
if (!isCopied)
{
QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("Failed to export current Savegame"));
goto fileDialogPreSave;
goto fileDialogPreSave; //Work?
}
}
else
{
QMessageBox::warning(parent, SavegameWidget::tr("Export Savegame"), SavegameWidget::tr("No valid file is selected"));
goto fileDialogPreSave;
goto fileDialogPreSave; //Work?
}
}

View file

@ -19,15 +19,15 @@
#include "StringParser.h"
#include "SavegameData.h"
#include <QTextCodec>
#include <QByteArray>
#include <QDebug>
#include <QFile>
#define savegameHeaderLength 260
#define verificationValue QByteArray::fromHex("00000001")
SavegameData::SavegameData(const QString &fileName, QObject *parent) : QObject(parent), savegameFileName(fileName)
{
// PARSE INT INIT - DO NOT CHANGE THIS VALUES
savegameHeaderLength = 260;
verificationValue = QByteArray::fromHex("00000001");
// INIT SAVEGAME
savegameStr = "";
savegameOk = 0;

View file

@ -40,10 +40,6 @@ private:
QString savegameStr;
QString lastStep;
bool savegameOk;
// PARSE INT
QByteArray verificationValue;
int savegameHeaderLength;
};
#endif // SAVEGAMEDATA_H

View file

@ -7,6 +7,10 @@ SavegameDialog::SavegameDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SavegameDialog)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
// Setup User Interface
ui->setupUi(this);
savegameLabStr = ui->labSavegameText->text();

View file

@ -19,6 +19,9 @@
#include "SnapmaticEditor.h"
#include "ui_SnapmaticEditor.h"
#include "SnapmaticPicture.h"
#include "StringParser.h"
#include <QTextDocument>
#include <QInputDialog>
#include <QMessageBox>
#include <QDebug>
#include <QFile>
@ -42,6 +45,7 @@ SnapmaticEditor::SnapmaticEditor(QWidget *parent) :
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
}
snapmaticTitle = "";
smpic = 0;
}
@ -179,6 +183,30 @@ void SnapmaticEditor::setSnapmaticPicture(SnapmaticPicture *picture)
{
ui->rbCustom->setChecked(true);
}
setSnapmaticTitle(picture->getPictureTitle());
}
void SnapmaticEditor::setSnapmaticTitle(const QString &title)
{
if (title.length() > 39)
{
snapmaticTitle = title.left(39);
}
else
{
snapmaticTitle = title;
}
QString editStr = QString("<a href=\"g5e://edittitle\" style=\"text-decoration: none;\">%1</a>").arg(tr("Edit"));
QString titleStr = tr("Title: %1 (%2)").arg(StringParser::escapeString(snapmaticTitle), editStr);
ui->labTitle->setText(titleStr);
if (SnapmaticPicture::verifyTitle(snapmaticTitle))
{
ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("<span style=\"color: green\">%1</a>").arg(tr("Yes", "Yes, should work fine"))));
}
else
{
ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("<span style=\"color: red\">%1</a>").arg(tr("No", "No, could lead to issues"))));
}
}
void SnapmaticEditor::on_cmdCancel_clicked()
@ -210,10 +238,19 @@ void SnapmaticEditor::on_cmdApply_clicked()
{
QFile::copy(adjustedFileName, backupFileName);
}
SnapmaticProperties fallbackProperties = smpic->getSnapmaticProperties();
QString fallbackTitle = smpic->getPictureTitle();
smpic->setSnapmaticProperties(localSpJson);
smpic->setPictureTitle(snapmaticTitle);
if (!smpic->exportPicture(originalFileName))
{
QMessageBox::warning(this, tr("Snapmatic Properties"), tr("Patching of Snapmatic Properties failed because of I/O Error"));
smpic->setSnapmaticProperties(fallbackProperties);
smpic->setPictureTitle(fallbackTitle);
}
else
{
smpic->emitUpdate();
}
}
close();
@ -251,3 +288,16 @@ void SnapmaticEditor::on_cbQualify_toggled(bool checked)
}
}
}
void SnapmaticEditor::on_labTitle_linkActivated(const QString &link)
{
if (link == "g5e://edittitle")
{
bool ok;
QString newTitle = QInputDialog::getText(this, tr("Snapmatic Title"), tr("New Snapmatic title:"), QLineEdit::Normal, snapmaticTitle, &ok, windowFlags());
if (ok && !newTitle.isEmpty())
{
setSnapmaticTitle(newTitle);
}
}
}

View file

@ -33,6 +33,7 @@ class SnapmaticEditor : public QDialog
public:
explicit SnapmaticEditor(QWidget *parent = 0);
void setSnapmaticPicture(SnapmaticPicture *picture);
void setSnapmaticTitle(const QString &title);
~SnapmaticEditor();
private slots:
@ -47,11 +48,13 @@ private slots:
void on_cmdCancel_clicked();
void on_cmdApply_clicked();
void on_cbQualify_toggled(bool checked);
void on_labTitle_linkActivated(const QString &link);
private:
Ui::SnapmaticEditor *ui;
SnapmaticProperties localSpJson;
SnapmaticPicture *smpic;
QString snapmaticTitle;
void qualifyAvatar();
};

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>375</width>
<height>319</height>
<width>400</width>
<height>350</height>
</rect>
</property>
<property name="windowTitle">
@ -119,6 +119,50 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbTitle">
<property name="title">
<string>Snapmatic Title</string>
</property>
<layout class="QVBoxLayout" name="vlTitle">
<item>
<widget class="UiModLabel" name="labTitle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<property name="text">
<string>Title: %1 (%2)</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="UiModLabel" name="labAppropriate">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Appropriate: %1</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbExtras">
<property name="title">
@ -133,7 +177,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="labQualify">
<widget class="UiModLabel" name="labQualify">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
@ -212,6 +256,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>UiModLabel</class>
<extends>QLabel</extends>
<header>UiModLabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View file

@ -29,6 +29,7 @@
#include <QBuffer>
#include <QDebug>
#include <QImage>
#include <QSize>
#include <QFile>
// PARSER ALLOCATIONS
@ -49,11 +50,13 @@
#define titlStreamEditorLength 256
#define titlStreamCharacterMax 39
// IMAGES VALUES
#define snapmaticResolutionW 960
#define snapmaticResolutionH 536
#define snapmaticResolution QSize(snapmaticResolutionW, snapmaticResolutionH)
SnapmaticPicture::SnapmaticPicture(const QString &fileName, QObject *parent) : QObject(parent), picFilePath(fileName)
{
// PREDEFINED PROPERTIES
snapmaticResolution = QSize(960, 536);
reset();
}
@ -65,7 +68,7 @@ void SnapmaticPicture::reset()
{
// INIT PIC
rawPicContent = "";
cachePicture = QImage(0, 0, QImage::Format_RGB888);
cachePicture = QImage();
jpegRawContentSize = 0;
picExportFileName = "";
isCustomFormat = 0;
@ -483,51 +486,6 @@ bool SnapmaticPicture::setPictureTitl(const QString &newTitle_)
return false;
}
bool SnapmaticPicture::exportPicture(const QString &fileName, bool customFormat)
{
QFile *picFile = new QFile(fileName);
if (picFile->open(QIODevice::WriteOnly))
{
if (!customFormat)
{
// Classic straight export
picFile->write(rawPicContent);
picFile->close();
picFile->deleteLater();
}
else
{
// Modern compressed export
QByteArray stockFileNameUTF8 = picFileName.toUtf8();
QByteArray numberLength = QByteArray::number(stockFileNameUTF8.length());
if (numberLength.length() == 1)
{
numberLength.insert(0, "0");
}
else if (numberLength.length() != 2)
{
numberLength = "00";
}
picFile->write(QByteArray::fromHex("00")); // First Null Byte
picFile->write("G5E"); // GTA 5 Export
picFile->write(QByteArray::fromHex("1000")); // 2 byte GTA 5 Export Version
picFile->write("LEN"); // Before Length
picFile->write(QByteArray::fromHex(numberLength)); // Length in HEX before Compressed
picFile->write("FIL"); // Before File Name
picFile->write(stockFileNameUTF8); // File Name
picFile->write("COM"); // Before Compressed
picFile->write(qCompress(rawPicContent, 9)); // Compressed Snapmatic
picFile->close();
picFile->deleteLater();
}
return true;
}
else
{
return false;
}
}
QString SnapmaticPicture::getExportPictureFileName()
{
return picExportFileName;
@ -655,24 +613,34 @@ bool SnapmaticPicture::isPicOk()
return picOk;
}
void SnapmaticPicture::setPicFileName(QString picFileName_)
{
picFileName = picFileName_;
}
void SnapmaticPicture::setPicFilePath(QString picFilePath_)
{
picFilePath = picFilePath_;
}
void SnapmaticPicture::clearCache()
{
cacheEnabled = false;
cachePicture = QImage(0, 0, QImage::Format_RGB888);
cachePicture = QImage();
}
void SnapmaticPicture::emitUpdate()
{
emit updated();
}
// JSON part
bool SnapmaticPicture::isJsonOk()
{
return jsonOk;
}
QString SnapmaticPicture::getJsonStr()
{
return jsonStr;
}
SnapmaticProperties SnapmaticPicture::getSnapmaticProperties()
{
return localSpJson;
}
void SnapmaticPicture::parseJsonContent()
{
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonStr.toUtf8());
@ -733,21 +701,6 @@ void SnapmaticPicture::parseJsonContent()
jsonOk = true;
}
bool SnapmaticPicture::isJsonOk()
{
return jsonOk;
}
QString SnapmaticPicture::getJsonStr()
{
return jsonStr;
}
SnapmaticProperties SnapmaticPicture::getSnapmaticProperties()
{
return localSpJson;
}
bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties newSpJson)
{
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonStr.toUtf8());
@ -811,6 +764,70 @@ bool SnapmaticPicture::setSnapmaticProperties(SnapmaticProperties newSpJson)
return true;
}
// FILE MANAGEMENT
bool SnapmaticPicture::exportPicture(const QString &fileName, bool customFormat)
{
QFile *picFile = new QFile(fileName);
if (picFile->open(QIODevice::WriteOnly))
{
if (!customFormat)
{
// Classic straight export
picFile->write(rawPicContent);
picFile->close();
picFile->deleteLater();
}
else
{
// Modern compressed export
QByteArray stockFileNameUTF8 = picFileName.toUtf8();
QByteArray numberLength = QByteArray::number(stockFileNameUTF8.length());
if (numberLength.length() == 1)
{
numberLength.insert(0, "0");
}
else if (numberLength.length() != 2)
{
numberLength = "00";
}
picFile->write(QByteArray::fromHex("00")); // First Null Byte
picFile->write("G5E"); // GTA 5 Export
picFile->write(QByteArray::fromHex("1000")); // 2 byte GTA 5 Export Version
picFile->write("LEN"); // Before Length
picFile->write(QByteArray::fromHex(numberLength)); // Length in HEX before Compressed
picFile->write("FIL"); // Before File Name
picFile->write(stockFileNameUTF8); // File Name
picFile->write("COM"); // Before Compressed
picFile->write(qCompress(rawPicContent, 9)); // Compressed Snapmatic
picFile->close();
picFile->deleteLater();
}
return true;
}
else
{
return false;
}
}
void SnapmaticPicture::setPicFileName(const QString &picFileName_)
{
picFileName = picFileName_;
}
void SnapmaticPicture::setPicFilePath(const QString &picFilePath_)
{
picFilePath = picFilePath_;
}
bool SnapmaticPicture::deletePicFile()
{
if (!QFile::exists(picFilePath)) return true;
if (QFile::remove(picFilePath)) return true;
return false;
}
// VISIBILITY
bool SnapmaticPicture::isHidden()

View file

@ -71,10 +71,14 @@ public:
bool setImage(const QImage &picture);
bool setPictureTitl(const QString &newTitle);
bool setPictureStream(const QByteArray &picByteArray);
bool exportPicture(const QString &fileName, bool customFormat = false);
void setPicFileName(QString picFileName);
void setPicFilePath(QString picFilePath);
void updateStrings();
void emitUpdate();
// FILE MANAGEMENT
bool exportPicture(const QString &fileName, bool customFormat = false);
void setPicFileName(const QString &picFileName);
void setPicFilePath(const QString &picFilePath);
bool deletePicFile();
// ALTERNATIVES
QString getPictureTitle() { return getPictureTitl(); }
@ -122,9 +126,6 @@ private:
// PICTURE STREAM
QByteArray rawPicContent;
// PREDEFINED PROPERTIES
QSize snapmaticResolution;
// JSON
void parseJsonContent();
bool jsonOk;
@ -135,6 +136,7 @@ private:
static bool verifyTitleChar(const QChar &titleChar);
signals:
void updated();
public slots:
};

View file

@ -23,6 +23,7 @@
#include "DatabaseThread.h"
#include "PictureDialog.h"
#include "PictureExport.h"
#include "StringParser.h"
#include "config.h"
#include <QMessageBox>
#include <QPixmap>
@ -84,6 +85,7 @@ void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture)
picPath = picture->getPictureFilePath();
picTitl = picture->getPictureTitl();
picStr = picture->getPictureStr();
QObject::connect(picture, SIGNAL(updated()), this, SLOT(snapmaticUpdated()));
QPixmap SnapmaticPixmap = QPixmap::fromImage(picture->getImage().scaled(ui->labPicture->width(), ui->labPicture->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::AutoColor);
ui->labPicStr->setText(picStr + "\n" + picTitl + "");
@ -94,6 +96,15 @@ void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture)
adjustTextColor();
}
void SnapmaticWidget::snapmaticUpdated()
{
// Current only strings get updated
picPath = smpic->getPictureFilePath();
picTitl = smpic->getPictureTitl();
picStr = smpic->getPictureStr();
ui->labPicStr->setText(picStr + "\n" + picTitl + "");
}
void SnapmaticWidget::on_cmdView_clicked()
{
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
@ -102,7 +113,6 @@ void SnapmaticWidget::on_cmdView_clicked()
settings.endGroup();
PictureDialog *picDialog = new PictureDialog(profileDB, crewDB, this);
picDialog->setWindowFlags(picDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
picDialog->setSnapmaticPicture(smpic, true);
picDialog->setModal(true);
@ -135,23 +145,25 @@ void SnapmaticWidget::on_cmdExport_clicked()
}
void SnapmaticWidget::on_cmdDelete_clicked()
{
if (deletePicture()) emit pictureDeleted();
}
bool SnapmaticWidget::deletePicture()
{
int uchoice = QMessageBox::question(this, tr("Delete picture"), tr("Are you sure to delete %1 from your Snapmatic pictures?").arg("\""+picStr+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (uchoice == QMessageBox::Yes)
{
if (!QFile::exists(picPath))
if (smpic->deletePicFile())
{
emit pictureDeleted();
}
else if(QFile::remove(picPath))
{
emit pictureDeleted();
return true;
}
else
{
QMessageBox::warning(this, tr("Delete picture"), tr("Failed at deleting %1 from your Snapmatic pictures").arg("\""+picStr+"\""));
}
}
return false;
}
void SnapmaticWidget::mousePressEvent(QMouseEvent *ev)

View file

@ -42,6 +42,7 @@ public:
void setSnapmaticPicture(SnapmaticPicture *picture);
void setSelectionMode(bool selectionMode);
void setSelected(bool isSelected);
bool deletePicture();
bool makePictureVisible();
bool makePictureHidden();
SnapmaticPicture *getPicture();
@ -66,6 +67,7 @@ private slots:
void makePictureVisibleSlot();
void makePictureHiddenSlot();
void editSnapmaticProperties();
void snapmaticUpdated();
protected:
bool eventFilter(QObject *obj, QEvent *ev);

View file

@ -18,6 +18,7 @@
#include "StringParser.h"
#include "config.h"
#include <QTextDocument>
#include <QApplication>
#include <QTextCodec>
#include <QByteArray>
@ -60,3 +61,12 @@ QString StringParser::convertBuildedString(const QString &buildedStr)
outputStr.replace("$SEPARATOR", QDir::separator());
return outputStr;
}
QString StringParser::escapeString(const QString &toEscape)
{
#if QT_VERSION >= 0x050000
return toEscape.toHtmlEscaped();
#else
return Qt::escape(toEscape);
#endif
}

View file

@ -30,6 +30,7 @@ public:
static QString convertDrawStringForLog(const QString &inputStr);
static QString convertLogStringForDraw(const QString &inputStr);
static QString convertBuildedString(const QString &buildedStr);
static QString escapeString(const QString &toEscape);
};
#endif // STRINGPARSER_H

View file

@ -208,7 +208,6 @@ void UserInterface::closeProfile()
ui->menuProfile->setEnabled(false);
ui->actionSelect_profile->setEnabled(false);
ui->swProfile->removeWidget(profileUI);
profileUI->deleteLater();
delete profileUI;
}
this->setWindowTitle(defaultWindowTitle.arg(tr("Select Profile")));
@ -248,11 +247,10 @@ void UserInterface::openSelectProfile()
void UserInterface::on_actionAbout_gta5sync_triggered()
{
AboutDialog *aboutDialog = new AboutDialog(this);
aboutDialog->setWindowFlags(aboutDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
aboutDialog->setWindowIcon(windowIcon());
aboutDialog->setModal(true);
aboutDialog->show();
aboutDialog->exec();
aboutDialog->deleteLater();
delete aboutDialog;
}
@ -297,13 +295,14 @@ void UserInterface::on_actionDelete_selected_triggered()
void UserInterface::on_actionOptions_triggered()
{
OptionsDialog *optionsDialog = new OptionsDialog(profileDB, this);
optionsDialog->setWindowFlags(optionsDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
optionsDialog->setWindowIcon(windowIcon());
optionsDialog->commitProfiles(GTAV_Profiles);
QObject::connect(optionsDialog, SIGNAL(settingsApplied(int,QString)), this, SLOT(settingsApplied(int,QString)));
QObject::connect(optionsDialog, SIGNAL(settingsApplied(int, QString)), this, SLOT(settingsApplied(int, QString)));
optionsDialog->setModal(true);
optionsDialog->show();
optionsDialog->exec();
delete optionsDialog;
}
@ -428,35 +427,30 @@ bool UserInterface::openFile(QString selectedFile, bool warn)
v