threading issues fixed

This commit is contained in:
Rafael 2017-02-17 12:07:37 +01:00
parent a8501be581
commit 7591d805c9
13 changed files with 251 additions and 93 deletions

View file

@ -42,6 +42,9 @@ void DatabaseThread::run()
QEventLoop threadLoop;
QStringList crewList;
// Register thread loop end signal
QObject::connect(this, SIGNAL(threadEndCommited()), &threadLoop, SLOT(quit()));
// Quick time scan
if (crewList.length() <= 3)
{
@ -58,6 +61,7 @@ void DatabaseThread::run()
QEventLoop *waitingLoop = new QEventLoop();
QTimer::singleShot(10000, waitingLoop, SLOT(quit()));
QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
waitingLoop->exec();
delete waitingLoop;
@ -70,8 +74,11 @@ void DatabaseThread::run()
scanCrewMembersList(crewList, crewMaxPages, 10000);
emit playerNameUpdated();
QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
threadLoop.exec();
if (threadRunning)
{
QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
threadLoop.exec();
}
}
}
@ -79,7 +86,7 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
{
foreach (const QString &crewID, crewList)
{
if (crewID != "0")
if (threadRunning && crewID != "0")
{
QNetworkAccessManager *netManager = new QNetworkAccessManager();
@ -93,6 +100,7 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
QEventLoop *downloadLoop = new QEventLoop();
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
QObject::connect(this, SIGNAL(threadEndCommited()), downloadLoop, SLOT(quit()));
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
downloadLoop->exec();
delete downloadLoop;
@ -138,6 +146,7 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
QEventLoop *waitingLoop = new QEventLoop();
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
waitingLoop->exec();
delete waitingLoop;
@ -153,7 +162,7 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
{
foreach (const QString &crewID, crewList)
{
if (crewID != "0")
if (threadRunning && crewID != "0")
{
int currentPage = 0;
int foundPlayers = 0;
@ -173,6 +182,7 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
QEventLoop *downloadLoop = new QEventLoop();
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
QObject::connect(this, SIGNAL(threadEndCommited()), downloadLoop, SLOT(quit()));
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
downloadLoop->exec();
delete downloadLoop;
@ -207,6 +217,7 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
QEventLoop *waitingLoop = new QEventLoop();
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
waitingLoop->exec();
delete waitingLoop;
@ -221,3 +232,9 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
}
}
}
void DatabaseThread::doEndThread()
{
threadRunning = false;
emit threadEndCommited();
}

View file

@ -29,6 +29,9 @@ class DatabaseThread : public QThread
public:
explicit DatabaseThread(CrewDatabase *crewDB, QObject *parent = 0);
public slots:
void doEndThread();
private:
CrewDatabase *crewDB;
void scanCrewMembersList(QStringList crewList, int maxPages, int requestDelay);
@ -43,7 +46,7 @@ protected:
signals:
void playerNameFound(int playerID, QString playerName);
void playerNameUpdated();
void threadEndCommited();
};
#endif // DATABASETHREAD_H

View file

@ -49,6 +49,7 @@
#include <QPicture>
#include <QBitmap>
#include <QBuffer>
#include <QImage>
#include <QDebug>
#include <QList>
#include <QDrag>
@ -59,6 +60,34 @@
PictureDialog::PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) :
QDialog(parent), profileDB(profileDB), crewDB(crewDB),
ui(new Ui::PictureDialog)
{
primaryWindow = false;
setupPictureDialog(true);
}
PictureDialog::PictureDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::PictureDialog)
{
primaryWindow = false;
setupPictureDialog(false);
}
PictureDialog::PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) :
QDialog(parent), primaryWindow(primaryWindow), profileDB(profileDB), crewDB(crewDB),
ui(new Ui::PictureDialog)
{
setupPictureDialog(true);
}
PictureDialog::PictureDialog(bool primaryWindow, QWidget *parent) :
QDialog(parent), primaryWindow(primaryWindow),
ui(new Ui::PictureDialog)
{
setupPictureDialog(false);
}
void PictureDialog::setupPictureDialog(bool withDatabase_)
{
ui->setupUi(this);
windowTitleStr = this->windowTitle();
@ -66,9 +95,9 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, Q
ui->cmdExport->setEnabled(0);
plyrsList = QStringList();
fullscreenWidget = 0;
rqfullscreen = 0;
previewmode = 0;
navienabled = 0;
rqFullscreen = 0;
previewMode = 0;
naviEnabled = 0;
indexed = 0;
picArea = "";
picTitl = "";
@ -80,6 +109,9 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, Q
locZ = "";
smpic = 0;
// With datebase
withDatabase = withDatabase_;
// Avatar area
avatarAreaPicture = QImage(":/img/avatararea.png");
avatarLocX = 145;
@ -88,7 +120,7 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, Q
// Overlay area
renderOverlayPicture();
overlayenabled = 1;
overlayEnabled = 1;
// Export menu
exportMenu = new QMenu(this);
@ -121,6 +153,15 @@ PictureDialog::~PictureDialog()
delete ui;
}
void PictureDialog::closeEvent(QCloseEvent *ev)
{
Q_UNUSED(ev)
if (primaryWindow && withDatabase)
{
emit endDatabaseThread();
}
}
void PictureDialog::addPreviousNextButtons()
{
// Windows Vista additions
@ -132,7 +173,7 @@ void PictureDialog::addPreviousNextButtons()
uiToolbar->addAction(QIcon(":/img/back.png"), "", this, SLOT(previousPictureRequestedSlot()));
uiToolbar->addAction(QIcon(":/img/next.png"), "", this, SLOT(nextPictureRequestedSlot()));
ui->jsonFrame->setStyleSheet(QString("QFrame { background: %1; }").arg(palette.window().color().name()));
navienabled = true;
naviEnabled = true;
#endif
#endif
}
@ -142,7 +183,7 @@ void PictureDialog::adaptNewDialogSize(QSize newLabelSize)
Q_UNUSED(newLabelSize)
int newDialogHeight = ui->labPicture->pixmap()->height();
newDialogHeight = newDialogHeight + ui->jsonFrame->height();
if (navienabled) newDialogHeight = newDialogHeight + layout()->menuBar()->height();
if (naviEnabled) newDialogHeight = newDialogHeight + layout()->menuBar()->height();
setMinimumSize(width(), newDialogHeight);
setMaximumSize(width(), newDialogHeight);
setFixedHeight(newDialogHeight);
@ -176,7 +217,7 @@ bool PictureDialog::event(QEvent *event)
{
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
if (navienabled)
if (naviEnabled)
{
if (event->type() == QWinEvent::CompositionChange || event->type() == QWinEvent::ColorizationChange)
{
@ -220,27 +261,27 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
returnValue = true;
break;
case Qt::Key_1:
if (previewmode)
if (previewMode)
{
previewmode = false;
previewMode = false;
renderPicture();
}
else
{
previewmode = true;
previewMode = true;
renderPicture();
}
break;
case Qt::Key_2:
if (overlayenabled)
if (overlayEnabled)
{
overlayenabled = false;
if (!previewmode) renderPicture();
overlayEnabled = false;
if (!previewMode) renderPicture();
}
else
{
overlayenabled = true;
if (!previewmode) renderPicture();
overlayEnabled = true;
if (!previewMode) renderPicture();
}
break;
#if QT_VERSION >= 0x050300
@ -253,6 +294,10 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
on_labPicture_mouseDoubleClicked(Qt::LeftButton);
returnValue = true;
break;
case Qt::Key_Escape:
ui->cmdClose->click();
returnValue = true;
break;
}
}
}
@ -266,7 +311,7 @@ void PictureDialog::triggerFullscreenDoubeClick()
void PictureDialog::exportCustomContextMenuRequestedPrivate(const QPoint &pos, bool fullscreen)
{
rqfullscreen = fullscreen;
rqFullscreen = fullscreen;
exportMenu->popup(pos);
}
@ -295,10 +340,10 @@ void PictureDialog::renderOverlayPicture()
// Generating Overlay Preview
QRect preferedRect = QRect(0, 0, 200, 160);
QString overlayText = tr("Key 1 - Avatar Preview Mode\nKey 2 - Toggle Overlay\nArrow Keys - Navigate");
QPixmap overlayPixmap(1, 1);
overlayPixmap.fill(Qt::transparent);
QImage overlayImage(1, 1, QImage::Format_ARGB32_Premultiplied);
overlayImage.fill(Qt::transparent);
QPainter overlayPainter(&overlayPixmap);
QPainter overlayPainter(&overlayImage);
QFont overlayPainterFont;
overlayPainterFont.setPixelSize(12);
overlayPainter.setFont(overlayPainterFont);
@ -317,8 +362,8 @@ void PictureDialog::renderOverlayPicture()
overlaySpace.setHeight(overlaySpace.height() + 6);
}
overlayPixmap = overlayPixmap.scaled(overlaySpace.size());
overlayPainter.begin(&overlayPixmap);
overlayImage = overlayImage.scaled(overlaySpace.size());
overlayPainter.begin(&overlayImage);
overlayPainter.setPen(QColor::fromRgb(255, 255, 255, 255));
overlayPainter.setFont(overlayPainterFont);
overlayPainter.drawText(preferedRect, Qt::AlignLeft | hOverlay | Qt::TextDontClip | Qt::TextWordWrap, overlayText);
@ -333,16 +378,15 @@ void PictureDialog::renderOverlayPicture()
overlaySpace.setWidth(overlaySpace.width() + 6);
}
QPixmap overlayBorderImage(overlaySpace.width(), overlaySpace.height());
QImage overlayBorderImage(overlaySpace.width(), overlaySpace.height(), QImage::Format_ARGB6666_Premultiplied);
overlayBorderImage.fill(QColor(15, 15, 15, 162));
QPixmap overlayTempPixmap(overlaySpace.size());
overlayTempPixmap.fill(Qt::transparent);
QPainter overlayTempPainter(&overlayTempPixmap);
overlayTempPainter.drawPixmap(0, 0, overlayBorderImage);
overlayTempPainter.drawPixmap(3, 3, overlayPixmap);
overlayTempImage = QImage(overlaySpace.width(), overlaySpace.height(), QImage::Format_ARGB6666_Premultiplied);
overlayTempImage.fill(Qt::transparent);
QPainter overlayTempPainter(&overlayTempImage);
overlayTempPainter.drawImage(0, 0, overlayBorderImage);
overlayTempPainter.drawImage(3, 3, overlayImage);
overlayTempPainter.end();
overlayTempImage = overlayTempPixmap.toImage();
}
void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, bool _indexed, int _index)
@ -368,7 +412,14 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
locX = QString::number(picture->getSnapmaticProperties().location.x);
locY = QString::number(picture->getSnapmaticProperties().location.y);
locZ = QString::number(picture->getSnapmaticProperties().location.z);
crewID = crewDB->getCrewName(picture->getSnapmaticProperties().crewID);
if (withDatabase)
{
crewID = crewDB->getCrewName(picture->getSnapmaticProperties().crewID);
}
else
{
crewID = QString::number(picture->getSnapmaticProperties().crewID);
}
created = picture->getSnapmaticProperties().createdDateTime.toString(Qt::DefaultLocaleShortDate);
plyrsList = picture->getSnapmaticProperties().playersList;
picTitl = picture->getPictureTitl();
@ -387,7 +438,15 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
{
foreach (const QString &player, plyrsList)
{
QString playerName = profileDB->getPlayerName(player.toInt());
QString playerName;
if (withDatabase)
{
playerName = profileDB->getPlayerName(player.toInt());
}
else
{
playerName = player;
}
plyrsStr.append(", <a href=\"https://socialclub.rockstargames.com/member/");
plyrsStr.append(playerName);
plyrsStr.append("/");
@ -438,9 +497,9 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture)
void PictureDialog::renderPicture()
{
if (!previewmode)
if (!previewMode)
{
if (overlayenabled)
if (overlayEnabled)
{
QPixmap overlayAreaPixmap(960, 536);
overlayAreaPixmap.fill(Qt::transparent);
@ -479,7 +538,15 @@ void PictureDialog::playerNameUpdated()
QString plyrsStr;
foreach (const QString &player, plyrsList)
{
QString playerName = profileDB->getPlayerName(player.toInt());
QString playerName;
if (withDatabase)
{
playerName = profileDB->getPlayerName(player.toInt());
}
else
{
playerName = player;
}
plyrsStr.append(", <a href=\"https://socialclub.rockstargames.com/member/");
if (playerName != player)
{
@ -502,7 +569,7 @@ void PictureDialog::playerNameUpdated()
void PictureDialog::exportSnapmaticPicture()
{
if (rqfullscreen && fullscreenWidget)
if (rqFullscreen && fullscreenWidget)
{
PictureExport::exportAsPicture(fullscreenWidget, smpic);
}
@ -514,7 +581,7 @@ void PictureDialog::exportSnapmaticPicture()
void PictureDialog::copySnapmaticPicture()
{
if (rqfullscreen && fullscreenWidget)
if (rqFullscreen && fullscreenWidget)
{
PictureExport::exportAsSnapmatic(fullscreenWidget, smpic);
}

View file

@ -35,7 +35,11 @@ class PictureDialog : public QDialog
{
Q_OBJECT
public:
explicit PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0);
explicit PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0);
explicit PictureDialog(QWidget *parent = 0);
explicit PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0);
explicit PictureDialog(bool primaryWindow, QWidget *parent = 0);
void setupPictureDialog(bool withDatabase);
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, bool indexed, int index);
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, int index);
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk);
@ -70,8 +74,10 @@ signals:
void nextPictureRequested();
void previousPictureRequested();
void newPictureCommited(QImage picture);
void endDatabaseThread();
protected:
void closeEvent(QCloseEvent *ev);
bool eventFilter(QObject *obj, QEvent *ev);
void mousePressEvent(QMouseEvent *ev);
bool event(QEvent *event);
@ -100,10 +106,12 @@ private:
QString locX;
QString locY;
QString locZ;
bool overlayenabled;
bool rqfullscreen;
bool navienabled;
bool previewmode;
bool overlayEnabled;
bool primaryWindow;
bool withDatabase;
bool rqFullscreen;
bool naviEnabled;
bool previewMode;
bool indexed;
int index;
int avatarLocX;

View file

@ -73,7 +73,7 @@ void ProfileLoader::run()
emit loadingProgress(curFile, maximumV);
QString picturePath = profileFolder + QDir::separator() + SnapmaticPic;
SnapmaticPicture *picture = new SnapmaticPicture(picturePath);
if (picture->readingPicture())
if (picture->readingPicture(true, true, true))
{
emit pictureLoaded(picture);
int crewNumber = picture->getSnapmaticProperties().crewID;

View file

@ -24,6 +24,7 @@
#include <QVariantMap>
#include <QJsonArray>
#include <QFileInfo>
#include <QPainter>
#include <QString>
#include <QBuffer>
#include <QDebug>
@ -51,6 +52,9 @@ SnapmaticPicture::SnapmaticPicture(const QString &fileName, QObject *parent) : Q
titlStreamCharacterMax = 39;
rawPicContent = "";
// PREDEFINED PROPERTIES
snapmaticResolution = QSize(960, 536);
reset();
}
@ -64,7 +68,7 @@ void SnapmaticPicture::reset()
rawPicContent = "";
// INIT PIC
cachePicture = QImage(0, 0, QImage::Format_RGB32);
cachePicture = QImage(0, 0, QImage::Format_RGB888);
jpegRawContentSize = 0;
picExportFileName = "";
isCustomFormat = 0;
@ -79,9 +83,12 @@ void SnapmaticPicture::reset()
// INIT JSON
jsonOk = 0;
jsonStr = "";
// SNAPMATIC PROPERTIES
localSpJson = {};
}
bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_)
bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_, bool fastLoad)
{
// Start opening file
// lastStep is like currentStep
@ -239,6 +246,21 @@ bool SnapmaticPicture::readingPicture(bool writeEnabled_, bool cacheEnabled_)
QImage tempPicture;
picOk = tempPicture.loadFromData(jpegRawContent, "JPEG");
}
else if (!fastLoad)
{
QImage tempPicture = QImage(snapmaticResolution, QImage::Format_RGB888);
QPainter tempPainter(&tempPicture);
if (cachePicture.size() == snapmaticResolution)
{
tempPainter.drawImage(0, 0, cachePicture);
}
else
{
tempPainter.drawImage(0, 0, cachePicture.scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
tempPainter.end();
cachePicture = tempPicture;
}
// Read JSON Stream
if (!picStream->isReadable())
@ -351,12 +373,12 @@ void SnapmaticPicture::updateStrings()
picExportFileName = sortStr + "_" + cmpPicTitl;
}
bool SnapmaticPicture::readingPictureFromFile(const QString &fileName, bool writeEnabled_, bool cacheEnabled_)
bool SnapmaticPicture::readingPictureFromFile(const QString &fileName, bool writeEnabled_, bool cacheEnabled_, bool fastLoad)
{
if (fileName != "")
{
picFilePath = fileName;
return readingPicture(writeEnabled_, cacheEnabled_);
return readingPicture(writeEnabled_, cacheEnabled_, fastLoad);
}
else
{
@ -561,19 +583,30 @@ QImage SnapmaticPicture::getImage()
else if (writeEnabled)
{
bool returnOk = 0;
QImage returnPicture;
QImage tempPicture;
QImage returnPicture(snapmaticResolution, QImage::Format_RGB888);
QBuffer snapmaticStream(&rawPicContent);
snapmaticStream.open(QIODevice::ReadOnly);
if (snapmaticStream.seek(jpegStreamEditorBegin))
{
QByteArray jpegRawContent = snapmaticStream.read(jpegPicStreamLength);
returnOk = returnPicture.loadFromData(jpegRawContent, "JPEG");
returnOk = tempPicture.loadFromData(jpegRawContent, "JPEG");
}
snapmaticStream.close();
if (returnOk)
{
QPainter returnPainter(&returnPicture);
if (tempPicture.size() == snapmaticResolution)
{
returnPainter.drawImage(0, 0, tempPicture);
}
else
{
returnPainter.drawImage(0, 0, tempPicture.scaled(snapmaticResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
returnPainter.end();
return returnPicture;
}
}
@ -589,7 +622,7 @@ QImage SnapmaticPicture::getImage()
lastStep = "1;/1,OpenFile," + StringParser::convertDrawStringForLog(picFilePath);
picFile->deleteLater();
delete picFile;
return QImage(0, 0, QImage::Format_RGB32);
return QImage(0, 0, QImage::Format_RGB888);
}
rawPicContent = picFile->read(snapmaticFileMaxSize);
picFile->close();
@ -610,7 +643,7 @@ QImage SnapmaticPicture::getImage()
return returnPicture;
}
}
return QImage(0, 0, QImage::Format_RGB32);
return QImage(0, 0, QImage::Format_RGB888);
}
int SnapmaticPicture::getContentMaxLength()
@ -636,7 +669,7 @@ void SnapmaticPicture::setPicFilePath(QString picFilePath_)
void SnapmaticPicture::clearCache()
{
cacheEnabled = false;
cachePicture = QImage(0, 0, QImage::Format_RGB32);
cachePicture = QImage(0, 0, QImage::Format_RGB888);
}
// JSON part
@ -827,3 +860,10 @@ bool SnapmaticPicture::setPictureVisible()
}
return true;
}
// PREDEFINED PROPERTIES
QSize SnapmaticPicture::getSnapmaticResolution()
{
return snapmaticResolution;
}

View file

@ -53,8 +53,8 @@ public:
explicit SnapmaticPicture(const QString &fileName = "", QObject *parent = 0);
~SnapmaticPicture();
void reset();
bool readingPictureFromFile(const QString &fileName, bool writeEnabled = true, bool cacheEnabled = false);
bool readingPicture(bool writeEnabled = true, bool cacheEnabled = true);
bool readingPictureFromFile(const QString &fileName, bool writeEnabled = true, bool cacheEnabled = false, bool fastLoad = false);
bool readingPicture(bool writeEnabled = true, bool cacheEnabled = true, bool fastLoad = false);
bool isPicOk();
void clearCache();
QImage getImage();
@ -93,6 +93,9 @@ public:
bool setPictureHidden();
bool setPictureVisible();
// PREDEFINED PROPERTIES
QSize getSnapmaticResolution();
private:
QString getSnapmaticHeaderString(const QByteArray &snapmaticHeader);
QString getSnapmaticJSONString(const QByteArray &jsonBytes);
@ -132,6 +135,9 @@ private:
int titlStreamCharacterMax;
QByteArray rawPicContent;
// PREDEFINED PROPERTIES
QSize snapmaticResolution;
// JSON
void parseJsonContent();
bool jsonOk;

View file

@ -85,7 +85,7 @@ void SnapmaticWidget::setSnapmaticPicture(SnapmaticPicture *picture)
picTitl = picture->getPictureTitl();
picStr = picture->getPictureStr();
QPixmap SnapmaticPixmap = QPixmap::fromImage(picture->getImage().scaled(ui->labPicture->width(), ui->labPicture->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation), Qt::AutoColor);
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 + "");
ui->labPicture->setPixmap(SnapmaticPixmap);

View file

@ -201,6 +201,12 @@ void UserInterface::closeProfile()
this->setWindowTitle(defaultWindowTitle.arg(tr("Select Profile")));
}
void UserInterface::closeEvent(QCloseEvent *ev)
{
Q_UNUSED(ev)
threadDB->doEndThread();
}
UserInterface::~UserInterface()
{
foreach (QPushButton *profileBtn, profileBtns)

View file

@ -26,6 +26,7 @@
#include "CrewDatabase.h"
#include "SavegameData.h"
#include <QMainWindow>
#include <QCloseEvent>
#include <QString>
#include <QMap>
@ -62,6 +63,9 @@ private slots:
void on_action_Disable_In_game_triggered();
void settingsApplied(int contentMode, QString language);
protected:
void closeEvent(QCloseEvent *ev);
private:
ProfileDatabase *profileDB;
CrewDatabase *crewDB;

View file

@ -50,7 +50,7 @@
#ifndef GTA5SYNC_APPVER
#ifndef GTA5SYNC_DAILYB
#define GTA5SYNC_APPVER "1.3.1"
#define GTA5SYNC_APPVER "1.3.2"
#else
#define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB)
#endif

View file

@ -425,60 +425,67 @@ int main(int argc, char *argv[])
if (selectedAction == "showpic")
{
CrewDatabase *crewDB = new CrewDatabase();
ProfileDatabase *profileDB = new ProfileDatabase();
DatabaseThread *threadDB = new DatabaseThread(crewDB);
PictureDialog *picDialog = new PictureDialog(profileDB, crewDB);
CrewDatabase crewDB;
ProfileDatabase profileDB;
DatabaseThread threadDB(&crewDB);
PictureDialog picDialog(true, &profileDB, &crewDB);
SnapmaticPicture picture;
bool readOk = picture.readingPictureFromFile(arg1);
picDialog->setWindowFlags(picDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
picDialog->setWindowIcon(IconLoader::loadingAppIcon());
picDialog->setSnapmaticPicture(&picture, readOk);
picDialog.setWindowFlags(picDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
picDialog.setWindowIcon(IconLoader::loadingAppIcon());
picDialog.setSnapmaticPicture(&picture, readOk);
int crewID = picture.getSnapmaticProperties().crewID;
if (crewID != 0) { crewDB->addCrew(crewID); }
if (crewID != 0) { crewDB.addCrew(crewID); }
if (!readOk) { return 1; }
QObject::connect(threadDB, SIGNAL(playerNameFound(int, QString)), profileDB, SLOT(setPlayerName(int, QString)));
QObject::connect(threadDB, SIGNAL(playerNameUpdated()), picDialog, SLOT(playerNameUpdated()));
threadDB->start();
QEventLoop threadLoop;
QObject::connect(&threadDB, SIGNAL(playerNameFound(int, QString)), &profileDB, SLOT(setPlayerName(int, QString)));
QObject::connect(&threadDB, SIGNAL(playerNameUpdated()), &picDialog, SLOT(playerNameUpdated()));
QObject::connect(&threadDB, SIGNAL(finished()), &threadLoop, SLOT(quit()));
QObject::connect(&picDialog, SIGNAL(endDatabaseThread()), &threadDB, SLOT(doEndThread()));
threadDB.start();
picDialog->show();
picDialog->setMinimumSize(picDialog->size());
picDialog->setMaximumSize(picDialog->size());
picDialog.show();
return a.exec();
threadLoop.exec();
return 0;
}
else if (selectedAction == "showsgd")
{
SavegameDialog *savegameDialog = new SavegameDialog();
SavegameDialog savegameDialog;
SavegameData savegame;
bool readOk = savegame.readingSavegameFromFile(arg1);
savegameDialog->setWindowFlags(savegameDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
savegameDialog->setWindowIcon(IconLoader::loadingAppIcon());
savegameDialog->setSavegameData(&savegame, arg1, readOk);
savegameDialog.setWindowFlags(savegameDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
savegameDialog.setWindowIcon(IconLoader::loadingAppIcon());
savegameDialog.setSavegameData(&savegame, arg1, readOk);
if (!readOk) { return 1; }
savegameDialog->show();
savegameDialog.show();
return a.exec();
}
CrewDatabase *crewDB = new CrewDatabase();
ProfileDatabase *profileDB = new ProfileDatabase();
DatabaseThread *threadDB = new DatabaseThread(crewDB);
CrewDatabase crewDB;
ProfileDatabase profileDB;
DatabaseThread threadDB(&crewDB);
QObject::connect(threadDB, SIGNAL(playerNameFound(int, QString)), profileDB, SLOT(setPlayerName(int, QString)));
threadDB->start();
QEventLoop threadLoop;
QObject::connect(&threadDB, SIGNAL(playerNameFound(int, QString)), &profileDB, SLOT(setPlayerName(int, QString)));
QObject::connect(&threadDB, SIGNAL(finished()), &threadLoop, SLOT(quit()));
threadDB.start();
UserInterface *uiWindow = new UserInterface(profileDB, crewDB, threadDB);
uiWindow->setWindowIcon(IconLoader::loadingAppIcon());
uiWindow->setupDirEnv();
uiWindow->show();
UserInterface uiWindow(&profileDB, &crewDB, &threadDB);
uiWindow.setWindowIcon(IconLoader::loadingAppIcon());
uiWindow.setupDirEnv();
uiWindow.show();
return a.exec();
threadLoop.exec();
return 0;
}

View file

@ -7,8 +7,8 @@ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "gta5view.exe.manifest"
#include <windows.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1, 3, 0, 0
PRODUCTVERSION 1, 3, 0, 0
FILEVERSION 1, 3, 2, 0
PRODUCTVERSION 1, 3, 2, 0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0
FILEOS VOS_NT_WINDOWS32
@ -25,12 +25,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Syping"
VALUE "FileDescription", "gta5view\0"
VALUE "FileVersion", "1.3.0\0"
VALUE "FileVersion", "1.3.2\0"
VALUE "InternalName", "gta5view\0"
VALUE "LegalCopyright", "Copyright © 2016-2017 Syping\0"
VALUE "OriginalFilename", "gta5view.exe\0"
VALUE "ProductName", "gta5view\0"
VALUE "ProductVersion", "1.3.0\0"
VALUE "ProductVersion", "1.3.2\0"
END
END
END