added ability to change Snapmatic Location
This commit is contained in:
parent
f62b1b08c0
commit
a591adf6ea
33 changed files with 1586 additions and 730 deletions
|
@ -32,14 +32,14 @@ before_script:
|
|||
|
||||
script:
|
||||
- cd qt5
|
||||
- qmake -qt=5 GTA5SYNC_PREFIX=/usr QMAKE_CXXFLAGS+=-std=c++11 DEFINES+=GTA5SYNC_BUILDTYPE_DEV "DEFINES+=GTA5SYNC_APPVER=\\\\\\\"$PACKAGE_VERSION-dev2\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
|
||||
- qmake -qt=5 GTA5SYNC_PREFIX=/usr QMAKE_CXXFLAGS+=-std=c++11 DEFINES+=GTA5SYNC_BUILDTYPE_DEV "DEFINES+=GTA5SYNC_APPVER=\\\\\\\"$PACKAGE_VERSION-dev3\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
|
||||
- make -j 4
|
||||
- sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt5 --pkgversion=$PACKAGE_VERSION --pkgrelease=dev2 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --requires=libqt5core5a,libqt5gui5,libqt5network5,libqt5widgets5,qttranslations5-l10n --conflicts=gta5view,gta5view-qt4 --replaces=gta5view,gta5view-qt4 --pakdir=../../package
|
||||
- sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt5 --pkgversion=$PACKAGE_VERSION --pkgrelease=dev3 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --requires=libqt5core5a,libqt5gui5,libqt5network5,libqt5widgets5,qttranslations5-l10n --conflicts=gta5view,gta5view-qt4 --replaces=gta5view,gta5view-qt4 --pakdir=../../package
|
||||
- cd ..
|
||||
- cd qt4
|
||||
- qmake -qt=4 GTA5SYNC_PREFIX=/usr QMAKE_CXXFLAGS+=-std=c++11 DEFINES+=GTA5SYNC_BUILDTYPE_DEV "DEFINES+=GTA5SYNC_APPVER=\\\\\\\"$PACKAGE_VERSION-dev2\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
|
||||
- qmake -qt=4 GTA5SYNC_PREFIX=/usr QMAKE_CXXFLAGS+=-std=c++11 DEFINES+=GTA5SYNC_BUILDTYPE_DEV "DEFINES+=GTA5SYNC_APPVER=\\\\\\\"$PACKAGE_VERSION-dev3\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
|
||||
- make -j 4
|
||||
- sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt4 --pkgversion=$PACKAGE_VERSION --pkgrelease=dev2 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --requires=libqtcore4,libqtgui4,libqt4-network,qtcore4-l10n --conflicts=gta5view,gta5view-qt5 --replaces=gta5view,gta5view-qt5 --pakdir=../../package
|
||||
- sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt4 --pkgversion=$PACKAGE_VERSION --pkgrelease=dev3 --pkggroup=utility --maintainer="Syping on Travis \<travisci@syping.de\>" --requires=libqtcore4,libqtgui4,libqt4-network,qtcore4-l10n --conflicts=gta5view,gta5view-qt5 --replaces=gta5view,gta5view-qt5 --pakdir=../../package
|
||||
- cd ..
|
||||
|
||||
deploy:
|
||||
|
|
|
@ -32,9 +32,11 @@
|
|||
#include <QUrl>
|
||||
|
||||
#define crewMaxPages 83
|
||||
#define maxLoadFails 3
|
||||
|
||||
DatabaseThread::DatabaseThread(CrewDatabase *crewDB, QObject *parent) : QThread(parent), crewDB(crewDB)
|
||||
{
|
||||
continueLastCrew = true;
|
||||
threadRunning = true;
|
||||
}
|
||||
|
||||
|
@ -46,7 +48,7 @@ void DatabaseThread::run()
|
|||
QStringList crewListR;
|
||||
|
||||
// Register thread loop end signal
|
||||
QObject::connect(this, SIGNAL(threadEndCommited()), &threadLoop, SLOT(quit()));
|
||||
QObject::connect(this, SIGNAL(threadTerminated()), &threadLoop, SLOT(quit()));
|
||||
|
||||
// Setup crewList for Quick time scan
|
||||
crewList = crewDB->getCrews();
|
||||
|
@ -130,7 +132,6 @@ void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &r
|
|||
if (threadRunning && crewID != QLatin1String("0"))
|
||||
{
|
||||
QNetworkAccessManager *netManager = new QNetworkAccessManager();
|
||||
|
||||
QNetworkRequest netRequest(AppEnv::getCrewFetchingUrl(crewID));
|
||||
#if QT_VERSION >= 0x050600
|
||||
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||
|
@ -144,9 +145,10 @@ void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &r
|
|||
|
||||
QEventLoop *downloadLoop = new QEventLoop();
|
||||
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
|
||||
QObject::connect(this, SIGNAL(threadEndCommited()), downloadLoop, SLOT(quit()));
|
||||
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), downloadLoop, SLOT(quit())); }
|
||||
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
|
||||
downloadLoop->exec();
|
||||
downloadLoop->disconnect();
|
||||
delete downloadLoop;
|
||||
|
||||
if (netReply->isFinished())
|
||||
|
@ -168,11 +170,15 @@ void DatabaseThread::scanCrewReference(const QStringList &crewList, const int &r
|
|||
}
|
||||
}
|
||||
|
||||
QEventLoop *waitingLoop = new QEventLoop();
|
||||
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
|
||||
QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
|
||||
waitingLoop->exec();
|
||||
delete waitingLoop;
|
||||
if (threadRunning)
|
||||
{
|
||||
QEventLoop *waitingLoop = new QEventLoop();
|
||||
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
|
||||
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), waitingLoop, SLOT(quit())); }
|
||||
waitingLoop->exec();
|
||||
waitingLoop->disconnect();
|
||||
delete waitingLoop;
|
||||
}
|
||||
|
||||
delete netReply;
|
||||
delete netManager;
|
||||
|
@ -186,14 +192,14 @@ void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int
|
|||
{
|
||||
if (threadRunning && crewID != QLatin1String("0"))
|
||||
{
|
||||
int currentFail = 0;
|
||||
int currentPage = 0;
|
||||
int foundPlayers = 0;
|
||||
int totalPlayers = 1000;
|
||||
|
||||
while(foundPlayers < totalPlayers && currentPage < maxPages)
|
||||
while(foundPlayers < totalPlayers && currentPage < maxPages && (continueLastCrew ? true : threadRunning))
|
||||
{
|
||||
QNetworkAccessManager *netManager = new QNetworkAccessManager();
|
||||
|
||||
QNetworkRequest netRequest(AppEnv::getPlayerFetchingUrl(crewID, currentPage));
|
||||
#if QT_VERSION >= 0x050600
|
||||
netRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||
|
@ -207,9 +213,10 @@ void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int
|
|||
|
||||
QEventLoop *downloadLoop = new QEventLoop();
|
||||
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
|
||||
QObject::connect(this, SIGNAL(threadEndCommited()), downloadLoop, SLOT(quit()));
|
||||
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), downloadLoop, SLOT(quit())); }
|
||||
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
|
||||
downloadLoop->exec();
|
||||
downloadLoop->disconnect();
|
||||
delete downloadLoop;
|
||||
|
||||
if (netReply->isFinished())
|
||||
|
@ -227,30 +234,43 @@ void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int
|
|||
for (QVariant memberVariant : memberList)
|
||||
{
|
||||
QMap<QString, QVariant> memberMap = memberVariant.toMap();
|
||||
foundPlayers++;
|
||||
if (memberMap.contains("RockstarId") && memberMap.contains("Name"))
|
||||
{
|
||||
int RockstarId = memberMap["RockstarId"].toInt();
|
||||
QString memberName = memberMap["Name"].toString();
|
||||
if (!memberName.isEmpty() && RockstarId != 0)
|
||||
{
|
||||
foundPlayers++;
|
||||
emit playerNameFound(RockstarId, memberName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QEventLoop *waitingLoop = new QEventLoop();
|
||||
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
|
||||
QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
|
||||
waitingLoop->exec();
|
||||
delete waitingLoop;
|
||||
|
||||
currentPage++;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentFail++;
|
||||
if (currentFail == maxLoadFails)
|
||||
{
|
||||
currentFail = 0;
|
||||
currentPage++;
|
||||
}
|
||||
}
|
||||
|
||||
delete netReply;
|
||||
delete netManager;
|
||||
|
||||
if (foundPlayers < totalPlayers && currentPage < maxPages && (continueLastCrew ? true : threadRunning))
|
||||
{
|
||||
QEventLoop *waitingLoop = new QEventLoop();
|
||||
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
|
||||
if (!continueLastCrew) { QObject::connect(this, SIGNAL(threadTerminated()), waitingLoop, SLOT(quit())); }
|
||||
waitingLoop->exec();
|
||||
waitingLoop->disconnect();
|
||||
delete waitingLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +278,7 @@ void DatabaseThread::scanCrewMembersList(const QStringList &crewList, const int
|
|||
|
||||
void DatabaseThread::deleteCompatibleCrews(QStringList *crewList)
|
||||
{
|
||||
for (QString& crewNID : *crewList)
|
||||
for (QString crewNID : *crewList)
|
||||
{
|
||||
if (crewDB->isCompatibleCrew(crewNID))
|
||||
{
|
||||
|
@ -270,7 +290,7 @@ void DatabaseThread::deleteCompatibleCrews(QStringList *crewList)
|
|||
QStringList DatabaseThread::deleteCompatibleCrews(const QStringList &crewList)
|
||||
{
|
||||
QStringList crewListR = crewList;
|
||||
for (QString& crewNID : crewListR)
|
||||
for (QString crewNID : crewListR)
|
||||
{
|
||||
if (crewDB->isCompatibleCrew(crewNID))
|
||||
{
|
||||
|
@ -280,8 +300,8 @@ QStringList DatabaseThread::deleteCompatibleCrews(const QStringList &crewList)
|
|||
return crewListR;
|
||||
}
|
||||
|
||||
void DatabaseThread::doEndThread()
|
||||
void DatabaseThread::terminateThread()
|
||||
{
|
||||
threadRunning = false;
|
||||
emit threadEndCommited();
|
||||
emit threadTerminated();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
explicit DatabaseThread(CrewDatabase *crewDB, QObject *parent = 0);
|
||||
|
||||
public slots:
|
||||
void doEndThread();
|
||||
void terminateThread();
|
||||
|
||||
private:
|
||||
CrewDatabase *crewDB;
|
||||
|
@ -38,6 +38,7 @@ private:
|
|||
void scanCrewReference(const QStringList &crewList, const int &requestDelay);
|
||||
void deleteCompatibleCrews(QStringList *crewList);
|
||||
QStringList deleteCompatibleCrews(const QStringList &crewList);
|
||||
bool continueLastCrew;
|
||||
bool threadRunning;
|
||||
int plyrPerReq;
|
||||
|
||||
|
@ -49,7 +50,7 @@ signals:
|
|||
void crewNameUpdated();
|
||||
void playerNameFound(int playerID, QString playerName);
|
||||
void playerNameUpdated();
|
||||
void threadEndCommited();
|
||||
void threadTerminated();
|
||||
};
|
||||
|
||||
#endif // DATABASETHREAD_H
|
||||
|
|
|
@ -76,7 +76,7 @@ void ExportThread::run()
|
|||
// End Picture Settings
|
||||
|
||||
int intExportProgress = 0;
|
||||
foreach(ProfileWidget *widget, profileMap.keys())
|
||||
for (ProfileWidget *widget : profileMap.keys())
|
||||
{
|
||||
if (widget->isSelected())
|
||||
{
|
||||
|
|
|
@ -74,11 +74,5 @@ QString GlobalString::getLanguageFile()
|
|||
|
||||
QString GlobalString::getLanguage()
|
||||
{
|
||||
QString language = TCInstance->getCurrentLanguage();
|
||||
QStringList langList = QString(language).replace("-", "_").split("_");
|
||||
if (langList.length() >= 1)
|
||||
{
|
||||
language = langList.at(0);
|
||||
}
|
||||
return language;
|
||||
return TCInstance->getCurrentAreaLanguage();
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ ImportDialog::~ImportDialog()
|
|||
|
||||
void ImportDialog::processImage()
|
||||
{
|
||||
if (workImage.isNull()) return;
|
||||
QImage snapmaticImage = workImage;
|
||||
QPixmap snapmaticPixmap(snapmaticResolutionW, snapmaticResolutionH);
|
||||
snapmaticPixmap.fill(selectedColour);
|
||||
|
@ -101,7 +102,7 @@ void ImportDialog::processImage()
|
|||
snapmaticImage = snapmaticImage.scaled(snapmaticAvatarResolution, snapmaticAvatarResolution, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
snapmaticPainter.drawImage(snapmaticAvatarPlacementW + diffWidth, snapmaticAvatarPlacementH + diffHeight, snapmaticImage);
|
||||
imageTitle = "Custom Avatar";
|
||||
imageTitle = tr("Custom Avatar", "Custom Avatar Description in SC, don't use Special Character!");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -127,7 +128,7 @@ void ImportDialog::processImage()
|
|||
snapmaticImage = snapmaticImage.scaled(snapmaticResolutionW, snapmaticResolutionH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, snapmaticImage);
|
||||
imageTitle = "Custom Picture";
|
||||
imageTitle = tr("Custom Picture", "Custom Picture Description in SC, don't use Special Character!");
|
||||
}
|
||||
snapmaticPainter.end();
|
||||
newImage = snapmaticPixmap.toImage();
|
||||
|
@ -139,13 +140,38 @@ QImage ImportDialog::image()
|
|||
return newImage;
|
||||
}
|
||||
|
||||
void ImportDialog::setImage(const QImage &image_)
|
||||
void ImportDialog::setImage(QImage *image_)
|
||||
{
|
||||
workImage = image_;
|
||||
if (workImage.width() == workImage.height())
|
||||
workImage = QImage();
|
||||
if (image_->width() == image_->height())
|
||||
{
|
||||
insideAvatarZone = true;
|
||||
ui->cbAvatar->setChecked(true);
|
||||
if (image_->height() > snapmaticResolutionH)
|
||||
{
|
||||
workImage = image_->scaled(snapmaticResolutionH, snapmaticResolutionH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
delete image_;
|
||||
}
|
||||
else
|
||||
{
|
||||
workImage = *image_;
|
||||
delete image_;
|
||||
}
|
||||
}
|
||||
else if (image_->width() > snapmaticResolutionW && image_->width() > image_->height())
|
||||
{
|
||||
workImage = image_->scaledToWidth(snapmaticResolutionW, Qt::SmoothTransformation);
|
||||
delete image_;
|
||||
}
|
||||
else if (image_->height() > snapmaticResolutionH && image_->height() > image_->width())
|
||||
{
|
||||
workImage = image_->scaledToHeight(snapmaticResolutionH, Qt::SmoothTransformation);
|
||||
delete image_;
|
||||
}
|
||||
else
|
||||
{
|
||||
workImage = *image_;
|
||||
delete image_;
|
||||
}
|
||||
processImage();
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
~ImportDialog();
|
||||
QImage image();
|
||||
QString getImageTitle();
|
||||
void setImage(const QImage &image);
|
||||
void setImage(QImage *image);
|
||||
bool isImportAgreed();
|
||||
|
||||
private slots:
|
||||
|
|
197
MapLocationDialog.cpp
Normal file
197
MapLocationDialog.cpp
Normal file
|
@ -0,0 +1,197 @@
|
|||
/*****************************************************************************
|
||||
* gta5sync GRAND THEFT AUTO V SYNC
|
||||
* Copyright (C) 2017 Syping
|
||||
*
|
||||
* 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/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "MapLocationDialog.h"
|
||||
#include "ui_MapLocationDialog.h"
|
||||
#include "IconLoader.h"
|
||||
#include "AppEnv.h"
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
|
||||
MapLocationDialog::MapLocationDialog(double x, double y, QWidget *parent) :
|
||||
QDialog(parent), xpos_old(x), ypos_old(y),
|
||||
ui(new Ui::MapLocationDialog)
|
||||
{
|
||||
// Set Window Flags
|
||||
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
|
||||
ui->setupUi(this);
|
||||
ui->cmdDone->setVisible(false);
|
||||
ui->cmdApply->setVisible(false);
|
||||
ui->cmdRevert->setVisible(false);
|
||||
ui->cmdDone->setCursor(Qt::ArrowCursor);
|
||||
|
||||
// DPI calculation
|
||||
qreal screenRatio = AppEnv::screenRatio();
|
||||
int widgetMargin = qRound(3 * screenRatio);
|
||||
ui->hlMapDialog->setContentsMargins(widgetMargin, widgetMargin, widgetMargin, widgetMargin);
|
||||
ui->vlMapDialog->setSpacing(widgetMargin);
|
||||
setMinimumSize(500 * screenRatio, 600 * screenRatio);
|
||||
setMaximumSize(500 * screenRatio, 600 * screenRatio);
|
||||
setFixedSize(500 * screenRatio, 600 * screenRatio);
|
||||
setMouseTracking(true);
|
||||
|
||||
changeMode = false;
|
||||
propUpdate = false;
|
||||
drawPointOnMap(xpos_old, ypos_old);
|
||||
}
|
||||
|
||||
MapLocationDialog::~MapLocationDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MapLocationDialog::drawPointOnMap(double xpos_d, double ypos_d)
|
||||
{
|
||||
qreal screenRatio = AppEnv::screenRatio();
|
||||
int pointMakerSize = 8 * screenRatio;
|
||||
QPixmap pointMakerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMakerSize, pointMakerSize));
|
||||
QSize mapPixelSize = size();
|
||||
|
||||
int pointMakerHalfSize = pointMakerSize / 2;
|
||||
long xpos_ms = qRound(xpos_d);
|
||||
long ypos_ms = qRound(ypos_d);
|
||||
double xpos_ma = xpos_ms + 4000;
|
||||
double ypos_ma = ypos_ms + 4000;
|
||||
double xrat = (double)mapPixelSize.width() / 10000;
|
||||
double yrat = (double)mapPixelSize.height() / 12000;
|
||||
long xpos_mp = qRound(xpos_ma * xrat);
|
||||
long ypos_mp = qRound(ypos_ma * yrat);
|
||||
long xpos_pr = xpos_mp - pointMakerHalfSize;
|
||||
long ypos_pr = ypos_mp + pointMakerHalfSize;
|
||||
|
||||
QPixmap mapPixmap(mapPixelSize);
|
||||
QPainter mapPainter(&mapPixmap);
|
||||
mapPainter.drawPixmap(0, 0, mapPixelSize.width(), mapPixelSize.height(), QPixmap(":/img/mappreview.jpg").scaled(mapPixelSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||
mapPainter.drawPixmap(xpos_pr, mapPixelSize.height() - ypos_pr, pointMakerSize, pointMakerSize, pointMakerPixmap);
|
||||
mapPainter.end();
|
||||
|
||||
QPalette backgroundPalette;
|
||||
backgroundPalette.setBrush(backgroundRole(), QBrush(mapPixmap));
|
||||
setPalette(backgroundPalette);
|
||||
|
||||
xpos_new = xpos_d;
|
||||
ypos_new = ypos_d;
|
||||
ui->labPos->setText(tr("X: %1\nY: %2", "X and Y position").arg(QString::number(xpos_d), QString::number(ypos_d)));
|
||||
}
|
||||
|
||||
void MapLocationDialog::on_cmdChange_clicked()
|
||||
{
|
||||
qreal screenRatio = AppEnv::screenRatio();
|
||||
int pointMakerSize = 8 * screenRatio;
|
||||
QPixmap pointMakerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMakerSize, pointMakerSize));
|
||||
QCursor pointMakerCursor(pointMakerPixmap);
|
||||
ui->cmdDone->setVisible(true);
|
||||
ui->cmdApply->setVisible(false);
|
||||
ui->cmdChange->setVisible(false);
|
||||
ui->cmdRevert->setVisible(false);
|
||||
|
||||
setCursor(pointMakerCursor);
|
||||
changeMode = true;
|
||||
}
|
||||
|
||||
void MapLocationDialog::on_cmdDone_clicked()
|
||||
{
|
||||
ui->cmdDone->setVisible(false);
|
||||
ui->cmdChange->setVisible(true);
|
||||
if (xpos_new != xpos_old || ypos_new != ypos_old)
|
||||
{
|
||||
ui->cmdApply->setVisible(true);
|
||||
ui->cmdRevert->setVisible(true);
|
||||
}
|
||||
|
||||
setCursor(Qt::ArrowCursor);
|
||||
changeMode = false;
|
||||
}
|
||||
|
||||
void MapLocationDialog::updatePosFromEvent(int x, int y)
|
||||
{
|
||||
QSize mapPixelSize = size();
|
||||
int xpos_ad = x;
|
||||
int ypos_ad = mapPixelSize.height() - y;
|
||||
double xrat = 10000 / (double)mapPixelSize.width();
|
||||
double yrat = 12000 / (double)mapPixelSize.height();
|
||||
double xpos_rv = xrat * xpos_ad;
|
||||
double ypos_rv = yrat * ypos_ad;
|
||||
double xpos_fp = xpos_rv - 4000;
|
||||
double ypos_fp = ypos_rv - 4000;
|
||||
drawPointOnMap(xpos_fp, ypos_fp);
|
||||
}
|
||||
|
||||
void MapLocationDialog::mouseMoveEvent(QMouseEvent *ev)
|
||||
{
|
||||
if (!changeMode) { ev->ignore(); }
|
||||
else if (ev->buttons() & Qt::LeftButton)
|
||||
{
|
||||
updatePosFromEvent(ev->x(), ev->y());
|
||||
ev->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
ev->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void MapLocationDialog::mouseReleaseEvent(QMouseEvent *ev)
|
||||
{
|
||||
if (!changeMode) { ev->ignore(); }
|
||||
else if (ev->button() == Qt::LeftButton)
|
||||
{
|
||||
updatePosFromEvent(ev->x(), ev->y());
|
||||
ev->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
ev->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
void MapLocationDialog::on_cmdApply_clicked()
|
||||
{
|
||||
propUpdate = true;
|
||||
xpos_old = xpos_new;
|
||||
ypos_old = ypos_new;
|
||||
ui->cmdApply->setVisible(false);
|
||||
ui->cmdRevert->setVisible(false);
|
||||
}
|
||||
|
||||
void MapLocationDialog::on_cmdRevert_clicked()
|
||||
{
|
||||
drawPointOnMap(xpos_old, ypos_old);
|
||||
ui->cmdApply->setVisible(false);
|
||||
ui->cmdRevert->setVisible(false);
|
||||
}
|
||||
|
||||
bool MapLocationDialog::propUpdated()
|
||||
{
|
||||
return propUpdate;
|
||||
}
|
||||
|
||||
double MapLocationDialog::getXpos()
|
||||
{
|
||||
return xpos_old;
|
||||
}
|
||||
|
||||
double MapLocationDialog::getYpos()
|
||||
{
|
||||
return ypos_old;
|
||||
}
|
||||
|
||||
void MapLocationDialog::on_cmdClose_clicked()
|
||||
{
|
||||
close();
|
||||
}
|
|
@ -16,26 +16,48 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPPREVIEWDIALOG_H
|
||||
#define MAPPREVIEWDIALOG_H
|
||||
#ifndef MAPLOCATIONDIALOG_H
|
||||
#define MAPLOCATIONDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMouseEvent>
|
||||
|
||||
namespace Ui {
|
||||
class MapPreviewDialog;
|
||||
class MapLocationDialog;
|
||||
}
|
||||
|
||||
class MapPreviewDialog : public QDialog
|
||||
class MapLocationDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MapPreviewDialog(QWidget *parent = 0);
|
||||
explicit MapLocationDialog(double x, double y, QWidget *parent = 0);
|
||||
void drawPointOnMap(double x, double y);
|
||||
~MapPreviewDialog();
|
||||
bool propUpdated();
|
||||
double getXpos();
|
||||
double getYpos();
|
||||
~MapLocationDialog();
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QMouseEvent *ev);
|
||||
void mouseReleaseEvent(QMouseEvent *ev);
|
||||
|
||||
private slots:
|
||||
void on_cmdDone_clicked();
|
||||
void on_cmdApply_clicked();
|
||||
void on_cmdChange_clicked();
|
||||
void on_cmdRevert_clicked();
|
||||
void updatePosFromEvent(int x, int y);
|
||||
void on_cmdClose_clicked();
|
||||
|
||||
private:
|
||||
Ui::MapPreviewDialog *ui;
|
||||
Ui::MapLocationDialog *ui;
|
||||
double xpos_old;
|
||||
double ypos_old;
|
||||
double xpos_new;
|
||||
double ypos_new;
|
||||
bool propUpdate;
|
||||
bool changeMode;
|
||||
};
|
||||
|
||||
#endif // MAPPREVIEWDIALOG_H
|
||||
#endif // MAPLOCATIONDIALOG_H
|
218
MapLocationDialog.ui
Normal file
218
MapLocationDialog.ui
Normal file
|
@ -0,0 +1,218 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MapLocationDialog</class>
|
||||
<widget class="QDialog" name="MapLocationDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>600</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>600</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Snapmatic Map Viewer</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vlMapPreview">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="hlMapDialog">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="vlPosLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="labPos">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel{
|
||||
color: rgb(255, 255, 255);
|
||||
}</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="vsPosSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hsMapDialog">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="vlMapDialog">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cmdClose">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="vsMapDialog">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cmdApply">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Apply</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cmdRevert">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Revert</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cmdChange">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Set</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cmdDone">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Done</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,73 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* gta5sync GRAND THEFT AUTO V SYNC
|
||||
* Copyright (C) 2017 Syping
|
||||
*
|
||||
* 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/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "MapPreviewDialog.h"
|
||||
#include "ui_MapPreviewDialog.h"
|
||||
#include "IconLoader.h"
|
||||
#include "AppEnv.h"
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
|
||||
MapPreviewDialog::MapPreviewDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::MapPreviewDialog)
|
||||
{
|
||||
// Set Window Flags
|
||||
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
// DPI calculation
|
||||
qreal screenRatio = AppEnv::screenRatio();
|
||||
setMinimumSize(500 * screenRatio, 600 * screenRatio);
|
||||
setMaximumSize(500 * screenRatio, 600 * screenRatio);
|
||||
setFixedSize(500 * screenRatio, 600 * screenRatio);
|
||||
}
|
||||
|
||||
MapPreviewDialog::~MapPreviewDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MapPreviewDialog::drawPointOnMap(double xpos_d, double ypos_d)
|
||||
{
|
||||
qreal screenRatio = AppEnv::screenRatio();
|
||||
int pointMakerSize = 8 * screenRatio;
|
||||
QPixmap pointMakerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMakerSize, pointMakerSize));
|
||||
QSize mapPixelSize = size();
|
||||
|
||||
int pointMakerHalfSize = pointMakerSize / 2;
|
||||
long xpos_ms = qRound(xpos_d);
|
||||
long ypos_ms = qRound(ypos_d);
|
||||
double xpos_ma = xpos_ms + 4000;
|
||||
double ypos_ma = ypos_ms + 4000;
|
||||
double xrat = (double)mapPixelSize.width() / 10000;
|
||||
double yrat = (double)mapPixelSize.height() / 12000;
|
||||
long xpos_mp = qRound(xpos_ma * xrat);
|
||||
long ypos_mp = qRound(ypos_ma * yrat);
|
||||
long xpos_pr = xpos_mp - pointMakerHalfSize;
|
||||
long ypos_pr = ypos_mp + pointMakerHalfSize;
|
||||
|
||||
QPixmap mapPixmap(mapPixelSize);
|
||||
QPainter mapPainter(&mapPixmap);
|
||||
mapPainter.drawPixmap(0, 0, mapPixelSize.width(), mapPixelSize.height(), QPixmap(":/img/mappreview.jpg").scaled(mapPixelSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||
mapPainter.drawPixmap(xpos_pr, mapPixelSize.height() - ypos_pr, pointMakerSize, pointMakerSize, pointMakerPixmap);
|
||||
mapPainter.end();
|
||||
|
||||
ui->labPicture->setPixmap(mapPixmap);
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MapPreviewDialog</class>
|
||||
<widget class="QDialog" name="MapPreviewDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>600</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>600</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Snapmatic Map Viewer</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vlMapPreview">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="UiModLabel" name="labPicture">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>UiModLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>uimod/UiModLabel.h</header>
|
||||
<slots>
|
||||
<signal>mouseMoved()</signal>
|
||||
<signal>mouseReleased()</signal>
|
||||
<signal>mousePressed()</signal>
|
||||
<signal>mouseDoubleClicked()</signal>
|
||||
</slots>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -125,18 +125,21 @@ void OptionsDialog::setupLanguageBox()
|
|||
{
|
||||
settings->beginGroup("Interface");
|
||||
currentLanguage = settings->value("Language", "System").toString();
|
||||
currentAreaLanguage = settings->value("AreaLanguage", "Auto").toString();
|
||||
settings->endGroup();
|
||||
|
||||
QString cbSysStr = tr("%1 (Next Closest Language)", "First language a person can talk with a different person/application. \"Native\" or \"Not Native\".").arg(tr("System",
|
||||
"System in context of System default"));
|
||||
QString cbAutoStr = tr("%1 (Closest to Interface)", "Next closest language compared to the Interface").arg(tr("Auto", "Automatic language choice."));
|
||||
ui->cbLanguage->addItem(cbSysStr, "System");
|
||||
ui->cbAreaLanguage->addItem(cbAutoStr, "Auto");
|
||||
|
||||
QStringList availableLanguages;
|
||||
availableLanguages << QString("en_GB");
|
||||
#ifndef GTA5SYNC_QCONF
|
||||
availableLanguages << TCInstance->listTranslations(AppEnv::getExLangFolder());
|
||||
availableLanguages << TranslationClass::listTranslations(AppEnv::getExLangFolder());
|
||||
#endif
|
||||
availableLanguages << TCInstance->listTranslations(AppEnv::getInLangFolder());
|
||||
availableLanguages << TranslationClass::listTranslations(AppEnv::getInLangFolder());
|
||||
availableLanguages.removeDuplicates();
|
||||
availableLanguages.sort();
|
||||
|
||||
|
@ -144,7 +147,6 @@ void OptionsDialog::setupLanguageBox()
|
|||
{
|
||||
QLocale langLocale(lang);
|
||||
QString cbLangStr = langLocale.nativeLanguageName() % " (" % langLocale.nativeCountryName() % ") [" % lang % "]";
|
||||
|
||||
QString langIconStr = "flag-" % TranslationClass::getCountryCode(langLocale);
|
||||
|
||||
ui->cbLanguage->addItem(QIcon::fromTheme(langIconStr), cbLangStr, lang);
|
||||
|
@ -158,6 +160,59 @@ void OptionsDialog::setupLanguageBox()
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
QString aCurrentLanguage = QString("en_GB");
|
||||
if (TCInstance->isLanguageLoaded()) { aCurrentLanguage = TCInstance->getCurrentLanguage(); }
|
||||
QLocale currentLocale = QLocale(aCurrentLanguage);
|
||||
ui->labCurrentLanguage->setText(tr("Current: %1").arg(currentLocale.nativeLanguageName() % " (" % currentLocale.nativeCountryName() % ") [" % aCurrentLanguage % "]"));
|
||||
|
||||
availableLanguages.clear();
|
||||
availableLanguages << TranslationClass::listAreaTranslations();
|
||||
availableLanguages.removeDuplicates();
|
||||
availableLanguages.sort();
|
||||
|
||||
for (QString lang : availableLanguages)
|
||||
{
|
||||
// correcting Language Location if possible
|
||||
QString aLang = lang;
|
||||
if (QFile::exists(":/global/global." % lang % ".loc"))
|
||||
{
|
||||
QFile locFile(":/global/global." % lang % ".loc");
|
||||
if (locFile.open(QFile::ReadOnly))
|
||||
{
|
||||
aLang = QString::fromUtf8(locFile.readLine()).trimmed();
|
||||
locFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
QLocale langLocale(aLang);
|
||||
QString cbLangStr = langLocale.nativeLanguageName() % " (" % langLocale.nativeCountryName() % ") [" % aLang % "]";
|
||||
QString langIconStr = "flag-" % TranslationClass::getCountryCode(langLocale);
|
||||
|
||||
ui->cbAreaLanguage->addItem(QIcon::fromTheme(langIconStr), cbLangStr, lang);
|
||||
if (currentAreaLanguage == lang)
|
||||
{
|
||||
#if QT_VERSION >= 0x050000
|
||||
ui->cbAreaLanguage->setCurrentText(cbLangStr);
|
||||
#else
|
||||
int indexOfLang = ui->cbAreaLanguage->findText(cbLangStr);
|
||||
ui->cbAreaLanguage->setCurrentIndex(indexOfLang);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
QString aCurrentAreaLanguage = TCInstance->getCurrentAreaLanguage();
|
||||
if (QFile::exists(":/global/global." % currentAreaLanguage % ".loc"))
|
||||
{
|
||||
QFile locFile(":/global/global." % currentAreaLanguage % ".loc");
|
||||
if (locFile.open(QFile::ReadOnly))
|
||||
{
|
||||
aCurrentAreaLanguage = QString::fromUtf8(locFile.readLine()).trimmed();
|
||||
locFile.close();
|
||||
}
|
||||
}
|
||||
currentLocale = QLocale(aCurrentAreaLanguage);
|
||||
ui->labCurrentAreaLanguage->setText(tr("Current: %1").arg(currentLocale.nativeLanguageName() % " (" % currentLocale.nativeCountryName() % ") [" % aCurrentAreaLanguage % "]"));
|
||||
}
|
||||
|
||||
void OptionsDialog::setupRadioButtons()
|
||||
|
@ -195,8 +250,10 @@ void OptionsDialog::applySettings()
|
|||
settings->beginGroup("Interface");
|
||||
#if QT_VERSION >= 0x050000
|
||||
settings->setValue("Language", ui->cbLanguage->currentData());
|
||||
settings->setValue("AreaLanguage", ui->cbAreaLanguage->currentData());
|
||||
#else
|
||||
settings->setValue("Language", ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()));
|
||||
settings->setValue("AreaLanguage", ui->cbAreaLanguage->itemData(ui->cbAreaLanguage->currentIndex()));
|
||||
#endif
|
||||
#ifdef GTA5SYNC_WIN
|
||||
#if QT_VERSION >= 0x050200
|
||||
|
@ -255,8 +312,10 @@ void OptionsDialog::applySettings()
|
|||
|
||||
#if QT_VERSION >= 0x050000
|
||||
bool languageChanged = ui->cbLanguage->currentData().toString() != currentLanguage;
|
||||
bool languageAreaChanged = ui->cbAreaLanguage->currentData().toString() != currentAreaLanguage;
|
||||
#else
|
||||
bool languageChanged = ui->cbLanguage->itemData(ui->cbLanguage->currentIndex()).toString() != currentLanguage;
|
||||
bool languageAreaChanged = ui->cbAreaLanguage->itemData(ui->cbLanguage->currentIndex()).toString() != currentAreaLanguage;
|
||||
#endif
|
||||
if (languageChanged)
|
||||
{
|
||||
|
@ -264,6 +323,10 @@ void OptionsDialog::applySettings()
|
|||
TCInstance->initUserLanguage();
|
||||
TCInstance->loadTranslation(qApp);
|
||||
}
|
||||
else if (languageAreaChanged)
|
||||
{
|
||||
TCInstance->initUserLanguage();
|
||||
}
|
||||
|
||||
emit settingsApplied(newContentMode, languageChanged);
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ private:
|
|||
Ui::OptionsDialog *ui;
|
||||
QList<QTreeWidgetItem*> playerItems;
|
||||
Qt::AspectRatioMode aspectRatio;
|
||||
QString currentAreaLanguage;
|
||||
QString currentLanguage;
|
||||
QString currentCFolder;
|
||||
QString defaultProfile;
|
||||
|
|
|
@ -390,12 +390,38 @@
|
|||
<item>
|
||||
<widget class="QGroupBox" name="gbLanguage">
|
||||
<property name="title">
|
||||
<string>Language</string>
|
||||
<string>Interface</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vlLanguage">
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbLanguage"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labCurrentLanguage">
|
||||
<property name="text">
|
||||
<string>Current: %1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbAreas">
|
||||
<property name="title">
|
||||
<string>Areas</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbAreaLanguage"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labCurrentAreaLanguage">
|
||||
<property name="text">
|
||||
<string>Current: %1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "ProfileDatabase.h"
|
||||
#include "ui_PictureDialog.h"
|
||||
#include "SidebarGenerator.h"
|
||||
#include "MapPreviewDialog.h"
|
||||
#include "MapLocationDialog.h"
|
||||
#include "SnapmaticEditor.h"
|
||||
#include "StandardPaths.h"
|
||||
#include "PictureExport.h"
|
||||
|
@ -691,21 +691,48 @@ int PictureDialog::getIndex()
|
|||
|
||||
void PictureDialog::openPreviewMap()
|
||||
{
|
||||
MapPreviewDialog *mapPreviewDialog;
|
||||
MapLocationDialog *mapLocDialog;
|
||||
if (rqFullscreen && fullscreenWidget != nullptr)
|
||||
{
|
||||
mapPreviewDialog = new MapPreviewDialog(fullscreenWidget);
|
||||
mapLocDialog = new MapLocationDialog(smpic->getSnapmaticProperties().location.x, smpic->getSnapmaticProperties().location.y, fullscreenWidget);
|
||||
}
|
||||
else
|
||||
{
|
||||
mapPreviewDialog = new MapPreviewDialog(this);
|
||||
mapLocDialog = new MapLocationDialog(smpic->getSnapmaticProperties().location.x, smpic->getSnapmaticProperties().location.y, this);
|
||||
}
|
||||
mapPreviewDialog->setWindowIcon(windowIcon());
|
||||
mapPreviewDialog->setModal(true);
|
||||
mapPreviewDialog->drawPointOnMap(smpic->getSnapmaticProperties().location.x, smpic->getSnapmaticProperties().location.y);
|
||||
mapPreviewDialog->show();
|
||||
mapPreviewDialog->exec();
|
||||
delete mapPreviewDialog;
|
||||
mapLocDialog->setWindowIcon(windowIcon());
|
||||
mapLocDialog->setModal(true);
|
||||
mapLocDialog->show();
|
||||
mapLocDialog->exec();
|
||||
if (mapLocDialog->propUpdated())
|
||||
{
|
||||
// Update Snapmatic Properties
|
||||
SnapmaticProperties localSpJson = smpic->getSnapmaticProperties();
|
||||
localSpJson.location.x = mapLocDialog->getXpos();
|
||||
localSpJson.location.y = mapLocDialog->getYpos();
|
||||
localSpJson.location.z = 0;
|
||||
|
||||
// Update Snapmatic Picture
|
||||
QString currentFilePath = smpic->getPictureFilePath();
|
||||
QString originalFilePath = smpic->getOriginalPictureFilePath();
|
||||
QString backupFileName = originalFilePath % ".bak";
|
||||
if (!QFile::exists(backupFileName))
|
||||
{
|
||||
QFile::copy(currentFilePath, backupFileName);
|
||||
}
|
||||
SnapmaticProperties fallbackProperties = smpic->getSnapmaticProperties();
|
||||
smpic->setSnapmaticProperties(localSpJson);
|
||||
if (!smpic->exportPicture(currentFilePath))
|
||||
{
|
||||
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of I/O Error"));
|
||||
smpic->setSnapmaticProperties(fallbackProperties);
|
||||
}
|
||||
else
|
||||
{
|
||||
updated();
|
||||
}
|
||||
}
|
||||
delete mapLocDialog;
|
||||
}
|
||||
|
||||
void PictureDialog::editSnapmaticProperties()
|
||||
|
@ -739,6 +766,9 @@ void PictureDialog::updated()
|
|||
crewID = QString::number(smpic->getSnapmaticProperties().crewID);
|
||||
crewStr = QString::number(smpic->getSnapmaticProperties().crewID);
|
||||
}
|
||||
locX = QString::number(smpic->getSnapmaticProperties().location.x);
|
||||
locY = QString::number(smpic->getSnapmaticProperties().location.y);
|
||||
locZ = QString::number(smpic->getSnapmaticProperties().location.z);
|
||||
picTitl = StringParser::escapeString(smpic->getPictureTitle());
|
||||
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created));
|
||||
}
|
||||
|
|
|
@ -96,25 +96,27 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
|
|||
|
||||
ProfileInterface::~ProfileInterface()
|
||||
{
|
||||
foreach (ProfileWidget *widget, widgets.keys())
|
||||
for (ProfileWidget *widget : widgets.keys())
|
||||
{
|
||||
widgets.remove(widget);
|
||||
widget->removeEventFilter(this);
|
||||
widget->disconnect();
|
||||
delete widget;
|
||||
}
|
||||
foreach (SavegameData *savegame, savegames)
|
||||
widgets.clear();
|
||||
|
||||
for (SavegameData *savegame : savegames)
|
||||
{
|
||||
savegames.removeAll(savegame);
|
||||
delete savegame;
|
||||
}
|
||||
foreach (SnapmaticPicture *picture, pictures)
|
||||
savegames.clear();
|
||||
|
||||
for (SnapmaticPicture *picture : pictures)
|
||||
{
|
||||
pictures.removeAll(picture);
|
||||
delete picture;
|
||||
}
|
||||
delete profileLoader;
|
||||
pictures.clear();
|
||||
|
||||
delete profileLoader;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
@ -617,7 +619,7 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
|
|||
}
|
||||
QString currentTime = QTime::currentTime().toString("HHmmss");
|
||||
SnapmaticProperties spJson = picture->getSnapmaticProperties();
|
||||
spJson.uid = QString(currentTime +
|
||||
spJson.uid = QString(currentTime %
|
||||
QString::number(QDate::currentDate().dayOfYear())).toInt();
|
||||
bool fExists = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid));
|
||||
bool fExistsHidden = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid) % ".hidden");
|
||||
|
@ -625,7 +627,7 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
|
|||
while ((fExists || fExistsHidden) && cEnough < 5000)
|
||||
{
|
||||
currentTime = QString::number(currentTime.toInt() - 1);
|
||||
spJson.uid = QString(currentTime +
|
||||
spJson.uid = QString(currentTime %
|
||||
QString::number(QDate::currentDate().dayOfYear())).toInt();
|
||||
fExists = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid));
|
||||
fExistsHidden = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid) % ".hidden");
|
||||
|
@ -650,11 +652,11 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
|
|||
delete picture;
|
||||
return false;
|
||||
}
|
||||
QImage snapmaticImage;
|
||||
QImage *importImage = new QImage();
|
||||
QImageReader snapmaticImageReader;
|
||||
snapmaticImageReader.setDecideFormatFromContent(true);
|
||||
snapmaticImageReader.setDevice(&snapmaticFile);
|
||||
if (!snapmaticImageReader.read(&snapmaticImage))
|
||||
if (!snapmaticImageReader.read(importImage))
|
||||
{
|
||||
QMessageBox::warning(this, tr("Import"), tr("Can't import %1 because file can't be parsed properly").arg("\""+selectedFileName+"\""));
|
||||
delete picture;
|
||||
|
@ -662,7 +664,7 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
|
|||
}
|
||||
ImportDialog *importDialog = new ImportDialog(this);
|
||||
importDialog->setWindowFlags(importDialog->windowFlags()^Qt::WindowContextHelpButtonHint);
|
||||
importDialog->setImage(snapmaticImage);
|
||||
importDialog->setImage(importImage);
|
||||
importDialog->setModal(true);
|
||||
importDialog->show();
|
||||
importDialog->exec();
|
||||
|
@ -680,7 +682,7 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
|
|||
while ((fExists || fExistsHidden) && cEnough < 25)
|
||||
{
|
||||
currentTime = QString::number(currentTime.toInt() - 1);
|
||||
spJson.uid = QString(currentTime +
|
||||
spJson.uid = QString(currentTime %
|
||||
QString::number(QDate::currentDate().dayOfYear())).toInt();
|
||||
fExists = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid));
|
||||
fExistsHidden = QFile::exists(profileFolder % "/PGTA5" % QString::number(spJson.uid) % ".hidden");
|
||||
|
@ -820,7 +822,7 @@ void ProfileInterface::profileWidgetSelected()
|
|||
{
|
||||
if (selectedWidgts == 0)
|
||||
{
|
||||
foreach (ProfileWidget *widget, widgets.keys())
|
||||
for (ProfileWidget *widget : widgets.keys())
|
||||
{
|
||||
widget->setSelectionMode(true);
|
||||
}
|
||||
|
@ -833,7 +835,7 @@ void ProfileInterface::profileWidgetDeselected()
|
|||
if (selectedWidgts == 1)
|
||||
{
|
||||
int scrollBarValue = ui->saProfile->verticalScrollBar()->value();
|
||||
foreach (ProfileWidget *widget, widgets.keys())
|
||||
for (ProfileWidget *widget : widgets.keys())
|
||||
{
|
||||
if (contentMode != 2)
|
||||
{
|
||||
|
@ -847,7 +849,7 @@ void ProfileInterface::profileWidgetDeselected()
|
|||
|
||||
void ProfileInterface::selectAllWidgets()
|
||||
{
|
||||
foreach (ProfileWidget *widget, widgets.keys())
|
||||
for (ProfileWidget *widget : widgets.keys())
|
||||
{
|
||||
widget->setSelected(true);
|
||||
}
|
||||
|
@ -855,7 +857,7 @@ void ProfileInterface::selectAllWidgets()
|
|||
|
||||
void ProfileInterface::deselectAllWidgets()
|
||||
{
|
||||
foreach (ProfileWidget *widget, widgets.keys())
|
||||
for (ProfileWidget *widget : widgets.keys())
|
||||
{
|
||||
widget->setSelected(false);
|
||||
}
|
||||
|
@ -879,7 +881,7 @@ void ProfileInterface::exportSelected()
|
|||
if (exportDirectory != "")
|
||||
{
|
||||
settings.setValue(profileName, exportDirectory);
|
||||
foreach (ProfileWidget *widget, widgets.keys())
|
||||
for (ProfileWidget *widget : widgets.keys())
|
||||
{
|
||||
if (widget->isSelected())
|
||||
{
|
||||
|
@ -1022,7 +1024,7 @@ void ProfileInterface::deleteSelected()
|
|||
{
|
||||
if (QMessageBox::Yes == QMessageBox::warning(this, tr("Remove selected"), tr("You really want remove the selected Snapmatic picutres and Savegame files?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
|
||||
{
|
||||
foreach (ProfileWidget *widget, widgets.keys())
|
||||
for (ProfileWidget *widget : widgets.keys())
|
||||