merged with gta5view 1.8

This commit is contained in:
Syping 2020-08-25 20:47:50 +02:00
parent 181e18503c
commit 4e83cb165a
22 changed files with 2274 additions and 2145 deletions

View file

@ -70,9 +70,18 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
#if QT_VERSION >= 0x050200
ui->txtJSON->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
#else
QFont jsonFont = ui->txtJSON->font();
jsonFont.setStyleHint(QFont::Monospace);
jsonFont.setFixedPitch(true);
ui->txtJSON->setFont(jsonFont);
#endif
QFontMetrics fontMetrics(ui->txtJSON->font());
#if QT_VERSION >= 0x050B00
ui->txtJSON->setTabStopDistance(fontMetrics.horizontalAdvance(" "));
#else
ui->txtJSON->setTabStopWidth(fontMetrics.width(" "));
#endif
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonCode.toUtf8());
ui->txtJSON->setStyleSheet("QPlainTextEdit{background-color: rgb(46, 47, 48); color: rgb(238, 231, 172);}");

View file

@ -60,40 +60,10 @@ MapLocationDialog::~MapLocationDialog()
void MapLocationDialog::drawPointOnMap(double xpos_d, double ypos_d)
{
qreal screenRatio = AppEnv::screenRatio();
qreal screenRatioPR = AppEnv::screenRatioPR();
int pointMakerSize = 8 * screenRatio * screenRatioPR;
QPixmap pointMakerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMakerSize, pointMakerSize));
QSize mapPixelSize = QSize(width() * screenRatioPR, height() * screenRatioPR);
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();
#if QT_VERSION >= 0x050600
mapPixmap.setDevicePixelRatio(screenRatioPR);
#endif
QPalette backgroundPalette;
backgroundPalette.setBrush(backgroundRole(), QBrush(mapPixmap));
setPalette(backgroundPalette);
ui->labPos->setText(tr("X: %1\nY: %2", "X and Y position").arg(QString::number(xpos_d), QString::number(ypos_d)));
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)));
repaint();
}
void MapLocationDialog::on_cmdChange_clicked()
@ -139,6 +109,48 @@ void MapLocationDialog::updatePosFromEvent(int x, int y)
drawPointOnMap(xpos_fp, ypos_fp);
}
void MapLocationDialog::paintEvent(QPaintEvent *ev)
{
QPainter painter(this);
qreal screenRatio = AppEnv::screenRatio();
qreal screenRatioPR = AppEnv::screenRatioPR();
// Paint Map
QSize mapPixelSize = QSize(width() * screenRatioPR, height() * screenRatioPR);
painter.drawPixmap(0, 0, width(), height(), QPixmap(":/img/mappreview.jpg").scaled(mapPixelSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
// Paint Marker
int pointMarkerSize = 8 * screenRatio;
int pointMarkerHalfSize = pointMarkerSize / 2;
long xpos_ms = qRound(xpos_new);
long ypos_ms = qRound(ypos_new);
double xpos_ma = xpos_ms + 4000;
double ypos_ma = ypos_ms + 4000;
double xrat = (double)width() / 10000;
double yrat = (double)height() / 12000;
long xpos_mp = qRound(xpos_ma * xrat);
long ypos_mp = qRound(ypos_ma * yrat);
long xpos_pr;
long ypos_pr;
if (screenRatioPR != 1) {
#ifdef GTA5SYNC_WIN
xpos_pr = xpos_mp - pointMarkerHalfSize;
ypos_pr = ypos_mp + pointMarkerHalfSize;
#else
xpos_pr = xpos_mp - pointMarkerHalfSize + screenRatioPR;
ypos_pr = ypos_mp + pointMarkerHalfSize - screenRatioPR;
#endif
}
else {
xpos_pr = xpos_mp - pointMarkerHalfSize;
ypos_pr = ypos_mp + pointMarkerHalfSize;
}
QPixmap mapMarkerPixmap = IconLoader::loadingPointmakerIcon().pixmap(QSize(pointMarkerSize, pointMarkerSize));
painter.drawPixmap(xpos_pr, height() - ypos_pr, pointMarkerSize, pointMarkerSize, mapMarkerPixmap);
QDialog::paintEvent(ev);
}
void MapLocationDialog::mouseMoveEvent(QMouseEvent *ev)
{
if (!changeMode) { ev->ignore(); }

View file

@ -39,6 +39,7 @@ public:
~MapLocationDialog();
protected:
void paintEvent(QPaintEvent *ev);
void mouseMoveEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);

View file

@ -25,6 +25,11 @@
<property name="windowTitle">
<string>Snapmatic Map Viewer</string>
</property>
<property name="styleSheet">
<string notr="true">QDialog#MapLocationDialog {
background-color: transparent;
}</string>
</property>
<layout class="QVBoxLayout" name="vlMapPreview">
<property name="spacing">
<number>0</number>

View file

@ -136,24 +136,33 @@ OptionsDialog::~OptionsDialog()
void OptionsDialog::setupTreeWidget()
{
for (QString playerIDStr : profileDB->getPlayers())
{
bool ok;
int playerID = playerIDStr.toInt(&ok);
if (ok)
const QStringList players = profileDB->getPlayers();
if (players.length() != 0) {
QStringList::const_iterator it = players.constBegin();
QStringList::const_iterator end = players.constEnd();
while (it != end)
{
QString playerName = profileDB->getPlayerName(playerID);
bool ok;
int playerID = it->toInt(&ok);
if (ok)
{
QString playerName = profileDB->getPlayerName(playerID);
QStringList playerTreeViewList;
playerTreeViewList += playerIDStr;
playerTreeViewList += playerName;
QStringList playerTreeViewList;
playerTreeViewList += *it;
playerTreeViewList += playerName;
QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList);
ui->twPlayers->addTopLevelItem(playerItem);
playerItems += playerItem;
QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList);
ui->twPlayers->addTopLevelItem(playerItem);
playerItems += playerItem;
}
it++;
}
ui->twPlayers->sortItems(1, Qt::AscendingOrder);
}
else {
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabPlayers));
}
ui->twPlayers->sortItems(1, Qt::AscendingOrder);
}
void OptionsDialog::setupLanguageBox()
@ -362,6 +371,8 @@ void OptionsDialog::applySettings()
#if QT_VERSION >= 0x050200
settings->setValue("NavigationBar", ui->cbSnapmaticNavigationBar->isChecked());
#endif
#else
settings->setValue("NavigationBar", ui->cbSnapmaticNavigationBar->isChecked());
#endif
settings->endGroup();
@ -722,8 +733,9 @@ void OptionsDialog::setupSnapmaticPictureViewer()
ui->gbSnapmaticPictureViewer->setVisible(false);
#endif
#else
ui->cbSnapmaticNavigationBar->setVisible(false);
ui->gbSnapmaticPictureViewer->setVisible(false);
settings->beginGroup("Interface");
ui->cbSnapmaticNavigationBar->setChecked(settings->value("NavigationBar", true).toBool());
settings->endGroup();
#endif
}

View file

@ -135,12 +135,15 @@ void PictureDialog::setupPictureDialog()
smpic = nullptr;
crewStr = "";
// Get Snapmatic Resolution
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
// Avatar area
qreal screenRatio = AppEnv::screenRatio();
qreal screenRatioPR = AppEnv::screenRatioPR();
if (screenRatio != 1 || screenRatioPR != 1)
{
avatarAreaPicture = QImage(":/img/avatararea.png").scaledToHeight(536 * screenRatio * screenRatioPR, Qt::FastTransformation);
avatarAreaPicture = QImage(":/img/avatararea.png").scaledToHeight(snapmaticResolution.height() * screenRatio * screenRatioPR, Qt::FastTransformation);
}
else
{
@ -151,7 +154,7 @@ void PictureDialog::setupPictureDialog()
avatarSize = 470;
// DPI calculation (picture)
ui->labPicture->setFixedSize(960 * screenRatio, 536 * screenRatio);
ui->labPicture->setFixedSize(snapmaticResolution.width() * screenRatio, snapmaticResolution.height() * screenRatio);
ui->labPicture->setFocusPolicy(Qt::StrongFocus);
ui->labPicture->setScaledContents(true);
@ -199,8 +202,8 @@ void PictureDialog::setupPictureDialog()
ui->jsonLayout->setContentsMargins(4 * screenRatio, 10 * screenRatio, 4 * screenRatio, 4 * screenRatio);
// Pre-adapt window for DPI
setFixedWidth(960 * screenRatio);
setFixedHeight(536 * screenRatio);
setFixedWidth(snapmaticResolution.width() * screenRatio);
setFixedHeight(snapmaticResolution.height() * screenRatio);
}
PictureDialog::~PictureDialog()
@ -216,6 +219,15 @@ PictureDialog::~PictureDialog()
delete layout()->menuBar();
}
#endif
#else
if (naviEnabled)
{
for (QObject *obj : layout()->menuBar()->children())
{
delete obj;
}
delete layout()->menuBar();
}
#endif
for (QObject *obj : manageMenu->children())
{
@ -236,18 +248,31 @@ void PictureDialog::closeEvent(QCloseEvent *ev)
void PictureDialog::addPreviousNextButtons()
{
// Windows Vista additions
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
QToolBar *uiToolbar = new QToolBar("Picture Toolbar", this);
uiToolbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
uiToolbar->setObjectName("uiToolbar");
uiToolbar->setObjectName("UiToolbar");
uiToolbar->addAction(QIcon(":/img/back.svgz"), "", this, SLOT(previousPictureRequestedSlot()));
uiToolbar->addAction(QIcon(":/img/next.svgz"), "", this, SLOT(nextPictureRequestedSlot()));
layout()->setMenuBar(uiToolbar);
naviEnabled = true;
#endif
#else
QToolBar *uiToolbar = new QToolBar("Picture Toolbar", this);
#if QT_VERSION < 0x050600
qreal screenRatio = AppEnv::screenRatio();
if (screenRatio != 1) {
QSize iconSize = uiToolbar->iconSize();
uiToolbar->setIconSize(QSize(iconSize.width() * screenRatio, iconSize.height() * screenRatio));
}
#endif
uiToolbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
uiToolbar->setObjectName("UiToolbar");
uiToolbar->addAction(QIcon(":/img/back.svgz"), "", this, SLOT(previousPictureRequestedSlot()));
uiToolbar->addAction(QIcon(":/img/next.svgz"), "", this, SLOT(nextPictureRequestedSlot()));
layout()->setMenuBar(uiToolbar);
naviEnabled = true;
#endif
}
@ -368,7 +393,11 @@ void PictureDialog::resizeEvent(QResizeEvent *event)
void PictureDialog::adaptNewDialogSize(QSize newLabelSize)
{
Q_UNUSED(newLabelSize)
#if QT_VERSION >= 0x050F00
int newDialogHeight = SnapmaticPicture::getSnapmaticResolution().height();
#else
int newDialogHeight = (ui->labPicture->pixmap()->height() / AppEnv::screenRatioPR());
#endif
newDialogHeight = newDialogHeight + ui->jsonFrame->height();
if (naviEnabled) newDialogHeight = newDialogHeight + layout()->menuBar()->height();
setMaximumSize(width(), newDialogHeight);
@ -686,10 +715,11 @@ void PictureDialog::renderPicture()
{
if (overlayEnabled)
{
QPixmap shownImagePixmap(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR);
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
QPixmap shownImagePixmap(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR);
shownImagePixmap.fill(Qt::transparent);
QPainter shownImagePainter(&shownImagePixmap);
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
shownImagePainter.drawImage(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, overlayTempImage);
shownImagePainter.end();
#if QT_VERSION >= 0x050600
@ -699,10 +729,11 @@ void PictureDialog::renderPicture()
}
else
{
QPixmap shownImagePixmap(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR);
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
QPixmap shownImagePixmap(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR);
shownImagePixmap.fill(Qt::transparent);
QPainter shownImagePainter(&shownImagePixmap);
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
shownImagePainter.drawImage(0, 0, snapmaticPicture.scaled(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
shownImagePainter.end();
#if QT_VERSION >= 0x050600
shownImagePixmap.setDevicePixelRatio(screenRatioPR);
@ -713,15 +744,16 @@ void PictureDialog::renderPicture()
else
{
// Generating Avatar Preview
QPixmap avatarPixmap(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR);
QSize snapmaticResolution = SnapmaticPicture::getSnapmaticResolution();
QPixmap avatarPixmap(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR);
QPainter snapPainter(&avatarPixmap);
QFont snapPainterFont;
snapPainterFont.setPixelSize(12 * screenRatio * screenRatioPR);
snapPainter.drawImage(0, 0, snapmaticPicture.scaled(960 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
snapPainter.drawImage(0, 0, snapmaticPicture.scaled(snapmaticResolution.width() * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
snapPainter.drawImage(0, 0, avatarAreaPicture);
snapPainter.setPen(QColor::fromRgb(255, 255, 255, 255));
snapPainter.setFont(snapPainterFont);
snapPainter.drawText(QRect(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, 140 * screenRatio * screenRatioPR, 536 * screenRatio * screenRatioPR), Qt::AlignLeft | Qt::TextWordWrap, tr("Avatar Preview Mode\nPress 1 for Default View"));
snapPainter.drawText(QRect(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, 140 * screenRatio * screenRatioPR, snapmaticResolution.height() * screenRatio * screenRatioPR), Qt::AlignLeft | Qt::TextWordWrap, tr("Avatar Preview Mode\nPress 1 for Default View"));
snapPainter.end();
#if QT_VERSION >= 0x050600
avatarPixmap.setDevicePixelRatio(screenRatioPR);

View file

@ -73,12 +73,32 @@ PlayerListDialog::PlayerListDialog(QStringList players, ProfileDatabase *profile
// Set Icon for Manage Buttons
if (QIcon::hasThemeIcon("go-previous") && QIcon::hasThemeIcon("go-next") && QIcon::hasThemeIcon("list-add"))
{
#if QT_VERSION < 0x050600
qreal screenRatio = AppEnv::screenRatio();
if (screenRatio != 1) {
QSize iconSize = ui->cmdMakeAv->iconSize();
iconSize = QSize(iconSize.width() * screenRatio, iconSize.height() * screenRatio);
ui->cmdMakeAv->setIconSize(iconSize);
ui->cmdMakeSe->setIconSize(iconSize);
ui->cmdMakeAd->setIconSize(iconSize);
}
#endif
ui->cmdMakeAv->setIcon(QIcon::fromTheme("go-previous"));
ui->cmdMakeSe->setIcon(QIcon::fromTheme("go-next"));
ui->cmdMakeAd->setIcon(QIcon::fromTheme("list-add"));
}
else
{
#if QT_VERSION < 0x050600
qreal screenRatio = AppEnv::screenRatio();
if (screenRatio != 1) {
QSize iconSize = ui->cmdMakeAv->iconSize();
iconSize = QSize(iconSize.width() * screenRatio, iconSize.height() * screenRatio);
ui->cmdMakeAv->setIconSize(iconSize);
ui->cmdMakeSe->setIconSize(iconSize);
ui->cmdMakeAd->setIconSize(iconSize);
}
#endif
ui->cmdMakeAv->setIcon(QIcon(":/img/back.svgz"));
ui->cmdMakeSe->setIcon(QIcon(":/img/next.svgz"));
ui->cmdMakeAd->setIcon(QIcon(":/img/add.svgz"));

View file

@ -264,7 +264,11 @@ void ProfileInterface::insertSnapmaticIPI(QWidget *widget)
QStringList widgetsKeyList = widgets.values();
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
#if QT_VERSION >= 0x050600
#if QT_VERSION >= 0x050F00
std::sort(pictureKeyList.rbegin(), pictureKeyList.rend());
#else
qSort(pictureKeyList.rbegin(), pictureKeyList.rend());
#endif
#else
qSort(pictureKeyList.begin(), pictureKeyList.end(), qGreater<QString>());
#endif
@ -284,7 +288,11 @@ void ProfileInterface::insertSavegameIPI(QWidget *widget)
QString widgetKey = widgets[proWidget];
QStringList widgetsKeyList = widgets.values();
QStringList savegameKeyList = widgetsKeyList.filter("SGD", Qt::CaseSensitive);
#if QT_VERSION >= 0x050F00
std::sort(savegameKeyList.begin(), savegameKeyList.end());
#else
qSort(savegameKeyList.begin(), savegameKeyList.end());
#endif
int sgdIndex = savegameKeyList.indexOf(QRegExp(widgetKey));
ui->vlSavegame->insertWidget(sgdIndex, proWidget);
@ -303,7 +311,11 @@ void ProfileInterface::dialogNextPictureRequested(QWidget *dialog)
QStringList widgetsKeyList = widgets.values();
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
#if QT_VERSION >= 0x050600
#if QT_VERSION >= 0x050F00
std::sort(pictureKeyList.rbegin(), pictureKeyList.rend());
#else
qSort(pictureKeyList.rbegin(), pictureKeyList.rend());
#endif
#else
qSort(pictureKeyList.begin(), pictureKeyList.end(), qGreater<QString>());
#endif
@ -338,7 +350,11 @@ void ProfileInterface::dialogPreviousPictureRequested(QWidget *dialog)
QStringList widgetsKeyList = widgets.values();
QStringList pictureKeyList = widgetsKeyList.filter("PIC", Qt::CaseSensitive);
#if QT_VERSION >= 0x050600
#if QT_VERSION >= 0x050F00
std::sort(pictureKeyList.rbegin(), pictureKeyList.rend());
#else
qSort(pictureKeyList.rbegin(), pictureKeyList.rend());
#endif
#else
qSort(pictureKeyList.begin(), pictureKeyList.end(), qGreater<QString>());
#endif
@ -369,7 +385,12 @@ void ProfileInterface::sortingProfileInterface()
ui->vlSnapmatic->setEnabled(false);
QStringList widgetsKeyList = widgets.values();
#if QT_VERSION >= 0x050F00
std::sort(widgetsKeyList.begin(), widgetsKeyList.end());
#else
qSort(widgetsKeyList.begin(), widgetsKeyList.end());
#endif
for (QString widgetKey : widgetsKeyList)
{
@ -1627,7 +1648,7 @@ void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev)
contextMenuOpened = true;
contextMenu.exec(ev->globalPos());
contextMenuOpened = false;
hoverProfileWidgetCheck();
QTimer::singleShot(0, this, SLOT(hoverProfileWidgetCheck()));
}
void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev)
@ -1660,7 +1681,7 @@ void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev)
contextMenuOpened = true;
contextMenu.exec(ev->globalPos());
contextMenuOpened = false;
hoverProfileWidgetCheck();
QTimer::singleShot(0, this, SLOT(hoverProfileWidgetCheck()));
}
void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
@ -1781,19 +1802,23 @@ bool ProfileInterface::eventFilter(QObject *watched, QEvent *event)
return true;
}
}
else if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::WindowActivate)
else if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease)
{
if ((watched->objectName() == "SavegameWidget" || watched->objectName() == "SnapmaticWidget") && isProfileLoaded)
{
ProfileWidget *pWidget = nullptr;
for (ProfileWidget *widget : widgets.keys())
QMap<ProfileWidget*, QString>::const_iterator it = widgets.constBegin();
QMap<ProfileWidget*, QString>::const_iterator end = widgets.constEnd();
while (it != end)
{
ProfileWidget *widget = it.key();
QPoint mousePos = widget->mapFromGlobal(QCursor::pos());
if (widget->rect().contains(mousePos))
{
pWidget = widget;
break;
}
it++;
}
if (pWidget != nullptr)
{
@ -1827,7 +1852,7 @@ bool ProfileInterface::eventFilter(QObject *watched, QEvent *event)
}
else if (event->type() == QEvent::WindowDeactivate && isProfileLoaded)
{
if (previousWidget != nullptr)
if (previousWidget != nullptr && watched == previousWidget)
{
previousWidget->setStyleSheet(QLatin1String(""));
previousWidget = nullptr;
@ -1863,13 +1888,17 @@ bool ProfileInterface::eventFilter(QObject *watched, QEvent *event)
void ProfileInterface::hoverProfileWidgetCheck()
{
ProfileWidget *pWidget = nullptr;
for (ProfileWidget *widget : widgets.keys())
QMap<ProfileWidget*, QString>::const_iterator it = widgets.constBegin();
QMap<ProfileWidget*, QString>::const_iterator end = widgets.constEnd();
while (it != end)
{
ProfileWidget *widget = it.key();
if (widget->underMouse())
{
pWidget = widget;
break;
}
it++;
}
if (pWidget != nullptr)
{

View file

@ -433,8 +433,8 @@ QString SnapmaticPicture::getSnapmaticHeaderString(const QByteArray &snapmaticHe
QString SnapmaticPicture::getSnapmaticJSONString(const QByteArray &jsonBytes)
{
QByteArray jsonUsefulBytes = jsonBytes;
jsonUsefulBytes.replace('\x00', QString());
jsonUsefulBytes.replace('\x0c', QString());
jsonUsefulBytes.replace('\x00', "");
jsonUsefulBytes.replace('\x0c', "");
return QString::fromUtf8(jsonUsefulBytes.trimmed());
}
@ -1339,7 +1339,8 @@ bool SnapmaticPicture::setPictureVisible()
QSize SnapmaticPicture::getSnapmaticResolution()
{
return snapmaticResolution;
// keep old UI size for now
return QSize(960, 536);
}
// SNAPMATIC DEFAULTS

View file

@ -120,7 +120,7 @@ public:
bool setVisible() { return setPictureVisible(); } // Please use setPictureVisible instead
// PREDEFINED PROPERTIES
QSize getSnapmaticResolution();
static QSize getSnapmaticResolution();
// SNAPMATIC DEFAULTS
bool isSnapmaticDefaultsEnforced();

View file

@ -20,6 +20,7 @@
#include "imagecropper.h"
#include "AppEnv.h"
#include <QPainterPath>
#include <QMouseEvent>
#include <QPainter>

View file

@ -44,7 +44,7 @@
#endif
#ifndef GTA5SYNC_APPVER
#define GTA5SYNC_APPVER "0.2.0"
#define GTA5SYNC_APPVER "0.3.0"
#endif
#if __cplusplus

View file

@ -39,45 +39,45 @@ QJsonDocument::QJsonDocument() : root_(0) {
// Name: QJsonDocument
//------------------------------------------------------------------------------
QJsonDocument::QJsonDocument(const QJsonObject &object) : root_(0) {
setObject(object);
setObject(object);
}
//------------------------------------------------------------------------------
// Name: QJsonDocument
//------------------------------------------------------------------------------
QJsonDocument::QJsonDocument(const QJsonArray &array) : root_(0) {
setArray(array);
setArray(array);
}
//------------------------------------------------------------------------------
// Name: QJsonDocument
//------------------------------------------------------------------------------
QJsonDocument::QJsonDocument(const QJsonDocument &other) : root_(0) {
if(other.root_) {
root_ = other.root_->clone();
}
if(other.root_) {
root_ = other.root_->clone();
}
}
//------------------------------------------------------------------------------
// Name: ~QJsonDocument
//------------------------------------------------------------------------------
QJsonDocument::~QJsonDocument() {
delete root_;
delete root_;
}
//------------------------------------------------------------------------------
// Name: operator=
//------------------------------------------------------------------------------
QJsonDocument &QJsonDocument::operator=(const QJsonDocument &other) {
QJsonDocument(other).swap(*this);
return *this;
QJsonDocument(other).swap(*this);
return *this;
}
//------------------------------------------------------------------------------
// Name: operator!=
//------------------------------------------------------------------------------
bool QJsonDocument::operator!=(const QJsonDocument &other) const {
return !(*this == other);
return !(*this == other);
}
//------------------------------------------------------------------------------
@ -85,30 +85,30 @@ bool QJsonDocument::operator!=(const QJsonDocument &other) const {
//------------------------------------------------------------------------------
bool QJsonDocument::operator==(const QJsonDocument &other) const {
if(isArray() && other.isArray()) {
return array() == other.array();
}
if(isArray() && other.isArray()) {
return array() == other.array();
}
if(isObject() && other.isObject()) {
return object() == other.object();
}
if(isObject() && other.isObject()) {
return object() == other.object();
}
if(isEmpty() && other.isEmpty()) {
return true;
}
if(isEmpty() && other.isEmpty()) {
return true;
}
if(isNull() && other.isNull()) {
return true;
}
if(isNull() && other.isNull()) {
return true;
}
return false;
return false;
}
//------------------------------------------------------------------------------
// Name: isArray
//------------------------------------------------------------------------------
bool QJsonDocument::isArray() const {
return root_ && root_->toArray();
return root_ && root_->toArray();
}
//------------------------------------------------------------------------------
@ -116,56 +116,56 @@ bool QJsonDocument::isArray() const {
//------------------------------------------------------------------------------
bool QJsonDocument::isEmpty() const {
// TODO(eteran): figure out the rules here that Qt5 uses
// it *looks* like they define empty as being NULL
// which is obviously different than this
// TODO(eteran): figure out the rules here that Qt5 uses
// it *looks* like they define empty as being NULL
// which is obviously different than this
return !root_;
return !root_;
}
//------------------------------------------------------------------------------
// Name: isNull
//------------------------------------------------------------------------------
bool QJsonDocument::isNull() const {
return !root_;
return !root_;
}
//------------------------------------------------------------------------------
// Name: isObject
//------------------------------------------------------------------------------
bool QJsonDocument::isObject() const {
return root_ && root_->toObject();
return root_ && root_->toObject();
}
//------------------------------------------------------------------------------
// Name: setArray
//------------------------------------------------------------------------------
void QJsonDocument::setArray(const QJsonArray &array) {
setRoot(array);
setRoot(array);
}
//------------------------------------------------------------------------------
// Name: setObject
//------------------------------------------------------------------------------
void QJsonDocument::setObject(const QJsonObject &object) {
setRoot(object);
setRoot(object);
}
//------------------------------------------------------------------------------
// Name: setRoot
//------------------------------------------------------------------------------
void QJsonDocument::setRoot(const QJsonRoot &root) {
delete root_;
root_ = root.clone();
delete root_;
root_ = root.clone();
}
//------------------------------------------------------------------------------
// Name: toBinaryData
//------------------------------------------------------------------------------
QByteArray QJsonDocument::toBinaryData() const {
QByteArray r;
// TODO(eteran): implement this
return r;
QByteArray r;
// TODO(eteran): implement this
return r;
}
//------------------------------------------------------------------------------
@ -173,100 +173,107 @@ QByteArray QJsonDocument::toBinaryData() const {
//------------------------------------------------------------------------------
QString QJsonDocument::escapeString(const QString &s) const {
QString r;
QString r;
Q_FOREACH(QChar ch, s) {
switch(ch.toLatin1()) {
case '\"': r.append("\\\""); break;
case '\\': r.append("\\\\"); break;
#if 0
case '/': r.append("\\/"); break;
#endif
case '\b': r.append("\\b"); break;
case '\f': r.append("\\f"); break;
case '\n': r.append("\\n"); break;
case '\r': r.append("\\r"); break;
case '\t': r.append("\\t"); break;
default:
r += ch;
break;
}
}
Q_FOREACH(QChar ch, s) {
switch(ch.toLatin1()) {
case '\"': r.append("\\\""); break;
case '\\': r.append("\\\\"); break;
#if 0
case '/': r.append("\\/"); break;
#endif
case '\b': r.append("\\b"); break;
case '\f': r.append("\\f"); break;
case '\n': r.append("\\n"); break;
case '\r': r.append("\\r"); break;
case '\t': r.append("\\t"); break;
default:
r += ch;
break;
}
}
return r;
return r;
}
//------------------------------------------------------------------------------
// Name: toJson
//------------------------------------------------------------------------------
QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format) const {
QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format, int indent) const {
QString b;
QTextStream ss(&b, QIODevice::WriteOnly | QIODevice::Text);
QString b;
QTextStream ss(&b, QIODevice::WriteOnly | QIODevice::Text);
bool compact = (format == JsonFormat::Compact);
switch(v.type()) {
case QJsonValue::Null:
ss << "null";
break;
case QJsonValue::Bool:
ss << (v.toBool() ? "true" : "false");
break;
case QJsonValue::Double:
{
double d = v.toDouble ();
if (qIsFinite(d)) {
// +2 to format to ensure the expected precision
ss << QByteArray::number(d, 'g', 15 + 2); // ::digits10 is 15
} else {
ss << "null"; // +INF || -INF || NaN (see RFC4627#section2.4)
}
}
break;
case QJsonValue::String:
ss << '"' << escapeString(v.toString()) << '"';
break;
case QJsonValue::Array:
{
const QJsonArray a = v.toArray();
ss << "[";
if(!a.empty()) {
QJsonArray::const_iterator it = a.begin();
QJsonArray::const_iterator e = a.end();
switch(v.type()) {
case QJsonValue::Null:
ss << "null";
break;
case QJsonValue::Bool:
ss << (v.toBool() ? "true" : "false");
break;
case QJsonValue::Double:
{
double d = v.toDouble ();
if (qIsFinite(d)) {
// +2 to format to ensure the expected precision
ss << QByteArray::number(d, 'g', 15 + 2); // ::digits10 is 15
} else {
ss << "null"; // +INF || -INF || NaN (see RFC4627#section2.4)
}
}
break;
case QJsonValue::String:
ss << '"' << escapeString(v.toString()) << '"';
break;
case QJsonValue::Array:
{
const QJsonArray a = v.toArray();
ss << (compact ? "[" : "[\n");
if(!a.empty()) {
QJsonArray::const_iterator it = a.begin();
QJsonArray::const_iterator e = a.end();
ss << toJson(*it++, format);
if (!compact) ss << QByteArray(4*indent, ' ');
ss << toJson(*it++, format, indent+1);
for(;it != e; ++it) {
ss << ',';
ss << toJson(*it, format);
}
}
ss << "]";
}
break;
case QJsonValue::Object:
{
const QJsonObject o = v.toObject();
ss << "{";
if(!o.empty()) {
QJsonObject::const_iterator it = o.begin();
QJsonObject::const_iterator e = o.end();
for(;it != e; ++it) {
ss << (compact ? "," : ",\n");
if (!compact) ss << QByteArray(4*indent, ' ');
ss << toJson(*it, format, indent+1);
}
}
indent--;
ss << (compact ? "]" : QString("\n%1]").arg(QString(4*indent, ' ')));
}
break;
case QJsonValue::Object:
{
const QJsonObject o = v.toObject();
ss << (compact ? "{" : "{\n");
if(!o.empty()) {
QJsonObject::const_iterator it = o.begin();
QJsonObject::const_iterator e = o.end();
ss << '"' << escapeString(it.key()) << "\": " << toJson(it.value(), format);
++it;
for(;it != e; ++it) {
ss << ',';
ss << '"' << escapeString(it.key()) << "\": " << toJson(it.value(), format);
}
}
ss << "}";
}
break;
case QJsonValue::Undefined:
Q_ASSERT(0);
break;
}
if (!compact) ss << QByteArray(4*indent, ' ');
ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, indent+1);
++it;
for(;it != e; ++it) {
ss << (compact ? "," : ",\n");
if (!compact) ss << QByteArray(4*indent, ' ');
ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, indent+1);
}
}
indent--;
ss << (compact ? "}" : QString("\n%1}").arg(QString(4*indent, ' ')));
}
break;
case QJsonValue::Undefined:
Q_ASSERT(0);
break;
}
return b;
return b;
}
//------------------------------------------------------------------------------
@ -274,19 +281,19 @@ QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format) const {
//------------------------------------------------------------------------------
QByteArray QJsonDocument::toJson(JsonFormat format) const {
Q_UNUSED(format);
Q_UNUSED(format);
if(isArray()) {
QString s = toJson(array(), format);
return s.toUtf8();
}
if(isArray()) {
QString s = toJson(array(), format);
return s.toUtf8();
}
if(isObject()) {
QString s = toJson(object(), format);
return s.toUtf8();
}
if(isObject()) {
QString s = toJson(object(), format);
return s.toUtf8();
}
return QByteArray();
return QByteArray();
}
//------------------------------------------------------------------------------
@ -294,17 +301,17 @@ QByteArray QJsonDocument::toJson(JsonFormat format) const {
//------------------------------------------------------------------------------
QVariant QJsonDocument::toVariant() const {
if(!isEmpty()) {
if(QJsonObject *const object = root_->toObject()) {
return object->toVariantMap();
}
if(!isEmpty()) {
if(QJsonObject *const object = root_->toObject()) {
return object->toVariantMap();
}
if(QJsonArray *const array = root_->toArray()) {
return array->toVariantList();
}
}
if(QJsonArray *const array = root_->toArray()) {
return array->toVariantList();
}
}
return QVariant();
return QVariant();
}
//------------------------------------------------------------------------------
@ -312,13 +319,13 @@ QVariant QJsonDocument::toVariant() const {
//------------------------------------------------------------------------------
QJsonArray QJsonDocument::array() const {
if(!isEmpty()) {
if(QJsonArray *const array = root_->toArray()) {
return *array;
}
}
if(!isEmpty()) {
if(QJsonArray *const array = root_->toArray()) {
return *array;
}
}
return QJsonArray();
return QJsonArray();
}
//------------------------------------------------------------------------------
@ -326,54 +333,54 @@ QJsonArray QJsonDocument::array() const {
//------------------------------------------------------------------------------
QJsonObject QJsonDocument::object() const {
if(!isEmpty()) {
if(QJsonObject *const object = root_->toObject()) {
return *object;
}
}
if(!isEmpty()) {
if(QJsonObject *const object = root_->toObject()) {
return *object;
}
}
return QJsonObject();
return QJsonObject();
}
//------------------------------------------------------------------------------
// Name: rawData
//------------------------------------------------------------------------------
const char *QJsonDocument::rawData(int *size) const {
Q_UNUSED(size);
// TODO(eteran): implement this
return 0;
Q_UNUSED(size);
// TODO(eteran): implement this
return 0;
}
//------------------------------------------------------------------------------
// Name: fromBinaryData
//------------------------------------------------------------------------------
QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidation validation) {
Q_UNUSED(data);
Q_UNUSED(validation);
Q_UNUSED(data);
Q_UNUSED(validation);
QJsonDocument doc;
// TODO(eteran): implement this
return doc;
QJsonDocument doc;
// TODO(eteran): implement this
return doc;
}
//------------------------------------------------------------------------------
// Name: fromJson
//------------------------------------------------------------------------------
QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *error) {
QJsonDocument doc;
QJsonDocument doc;
const char *const begin = json.constData();
const char *const end = begin + json.size();
const char *const begin = json.constData();
const char *const end = begin + json.size();
QJsonParser parser(begin, end);
QJsonParser parser(begin, end);
doc.root_ = parser.parse();
doc.root_ = parser.parse();
if(error) {
*error = parser.state();
}
if(error) {
*error = parser.state();
}
return doc;
return doc;
}
//------------------------------------------------------------------------------
@ -381,10 +388,10 @@ QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *e
//------------------------------------------------------------------------------
QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidation validation) {
// data has to be aligned to a 4 byte boundary.
Q_ASSERT(!(reinterpret_cast<quintptr>(data) % 3));
// data has to be aligned to a 4 byte boundary.
Q_ASSERT(!(reinterpret_cast<quintptr>(data) % 3));
return fromBinaryData(QByteArray::fromRawData(data, size), validation);
return fromBinaryData(QByteArray::fromRawData(data, size), validation);
}
//------------------------------------------------------------------------------
@ -392,26 +399,26 @@ QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidat
//------------------------------------------------------------------------------
QJsonDocument QJsonDocument::fromVariant(const QVariant &variant) {
QJsonDocument doc;
QJsonDocument doc;
if (variant.type() == QVariant::Map) {
doc.setObject(QJsonObject::fromVariantMap(variant.toMap()));
} else if (variant.type() == QVariant::Hash) {
doc.setObject(QJsonObject::fromVariantHash(variant.toHash()));
} else if (variant.type() == QVariant::List) {
doc.setArray(QJsonArray::fromVariantList(variant.toList()));
} else if (variant.type() == QVariant::StringList) {
doc.setArray(QJsonArray::fromStringList(variant.toStringList()));
}
if (variant.type() == QVariant::Map) {
doc.setObject(QJsonObject::fromVariantMap(variant.toMap()));
} else if (variant.type() == QVariant::Hash) {
doc.setObject(QJsonObject::fromVariantHash(variant.toHash()));
} else if (variant.type() == QVariant::List) {
doc.setArray(QJsonArray::fromVariantList(variant.toList()));
} else if (variant.type() == QVariant::StringList) {
doc.setArray(QJsonArray::fromStringList(variant.toStringList()));
}
return doc;
return doc;
}
//------------------------------------------------------------------------------
// Name: swap
//------------------------------------------------------------------------------
void QJsonDocument::swap(QJsonDocument &other) {
qSwap(root_, other.root_);
qSwap(root_, other.root_);
}
#endif

View file

@ -36,66 +36,66 @@ class QJsonRoot;
class QJsonDocument {
public:
enum DataValidation {
Validate = 0,
BypassValidation = 1
};
enum DataValidation {
Validate = 0,
BypassValidation = 1
};
enum JsonFormat {
Indented,
Compact
};
enum JsonFormat {
Indented,
Compact
};
public:
QJsonDocument();
QJsonDocument(const QJsonObject &object);
QJsonDocument(const QJsonArray &array);
QJsonDocument(const QJsonDocument &other);
~QJsonDocument();
QJsonDocument();
QJsonDocument(const QJsonObject &object);
QJsonDocument(const QJsonArray &array);
QJsonDocument(const QJsonDocument &other);
~QJsonDocument();
public:
QJsonDocument &operator=(const QJsonDocument &other);
QJsonDocument &operator=(const QJsonDocument &other);
public:
bool operator!=(const QJsonDocument &other) const;
bool operator==(const QJsonDocument &other) const;
bool operator!=(const QJsonDocument &other) const;
bool operator==(const QJsonDocument &other) const;
public:
bool isArray() const;
bool isEmpty() const;
bool isNull() const;
bool isObject() const;
bool isArray() const;
bool isEmpty() const;
bool isNull() const;
bool isObject() const;
public:
QByteArray toBinaryData() const;
QByteArray toJson(JsonFormat format = Indented) const;
QVariant toVariant() const;
QByteArray toBinaryData() const;
QByteArray toJson(JsonFormat format = Indented) const;
QVariant toVariant() const;
public:
QJsonArray array() const;
QJsonObject object() const;
const char *rawData(int *size) const;
QJsonArray array() const;
QJsonObject object() const;
const char *rawData(int *size) const;
public:
void setArray(const QJsonArray &array);
void setObject(const QJsonObject &object);
void setArray(const QJsonArray &array);
void setObject(const QJsonObject &object);
public:
static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate);
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = 0);
static QJsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate);
static QJsonDocument fromVariant(const QVariant &variant);
static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate);
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = 0);
static QJsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate);
static QJsonDocument fromVariant(const QVariant &variant);
private:
void setRoot(const QJsonRoot &root);
QString toJson(const QJsonValue &v, JsonFormat format) const;
QString escapeString(const QString &s) const;
void setRoot(const QJsonRoot &root);
QString toJson(const QJsonValue &v, JsonFormat format, int indent = 1) const;
QString escapeString(const QString &s) const;
private:
void swap(QJsonDocument &other);
void swap(QJsonDocument &other);
private:
QJsonRoot *root_;
QJsonRoot *root_;
};
#endif

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff