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 #if QT_VERSION >= 0x050200
ui->txtJSON->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); 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 #endif
QFontMetrics fontMetrics(ui->txtJSON->font()); QFontMetrics fontMetrics(ui->txtJSON->font());
#if QT_VERSION >= 0x050B00
ui->txtJSON->setTabStopDistance(fontMetrics.horizontalAdvance(" "));
#else
ui->txtJSON->setTabStopWidth(fontMetrics.width(" ")); ui->txtJSON->setTabStopWidth(fontMetrics.width(" "));
#endif
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonCode.toUtf8()); QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonCode.toUtf8());
ui->txtJSON->setStyleSheet("QPlainTextEdit{background-color: rgb(46, 47, 48); color: rgb(238, 231, 172);}"); 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) void MapLocationDialog::drawPointOnMap(double xpos_d, double ypos_d)
{ {
qreal screenRatio = AppEnv::screenRatio(); ui->labPos->setText(tr("X: %1\nY: %2", "X and Y position").arg(QString::number(xpos_d), QString::number(ypos_d)));
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);
xpos_new = xpos_d; xpos_new = xpos_d;
ypos_new = ypos_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() void MapLocationDialog::on_cmdChange_clicked()
@ -139,6 +109,48 @@ void MapLocationDialog::updatePosFromEvent(int x, int y)
drawPointOnMap(xpos_fp, ypos_fp); 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) void MapLocationDialog::mouseMoveEvent(QMouseEvent *ev)
{ {
if (!changeMode) { ev->ignore(); } if (!changeMode) { ev->ignore(); }

View File

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

View File

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

View File

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

View File

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

View File

@ -73,12 +73,32 @@ PlayerListDialog::PlayerListDialog(QStringList players, ProfileDatabase *profile
// Set Icon for Manage Buttons // Set Icon for Manage Buttons
if (QIcon::hasThemeIcon("go-previous") && QIcon::hasThemeIcon("go-next") && QIcon::hasThemeIcon("list-add")) 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->cmdMakeAv->setIcon(QIcon::fromTheme("go-previous"));
ui->cmdMakeSe->setIcon(QIcon::fromTheme("go-next")); ui->cmdMakeSe->setIcon(QIcon::fromTheme("go-next"));
ui->cmdMakeAd->setIcon(QIcon::fromTheme("list-add")); ui->cmdMakeAd->setIcon(QIcon::fromTheme("list-add"));
} }
else 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->cmdMakeAv->setIcon(QIcon(":/img/back.svgz"));
ui->cmdMakeSe->setIcon(QIcon(":/img/next.svgz")); ui->cmdMakeSe->setIcon(QIcon(":/img/next.svgz"));
ui->cmdMakeAd->setIcon(QIcon(":/img/add.svgz")); ui->cmdMakeAd->setIcon(QIcon(":/img/add.svgz"));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -199,10 +199,11 @@ QString QJsonDocument::escapeString(const QString &s) const {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Name: toJson // Name: toJson
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format) const { QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format, int indent) const {
QString b; QString b;
QTextStream ss(&b, QIODevice::WriteOnly | QIODevice::Text); QTextStream ss(&b, QIODevice::WriteOnly | QIODevice::Text);
bool compact = (format == JsonFormat::Compact);
switch(v.type()) { switch(v.type()) {
case QJsonValue::Null: case QJsonValue::Null:
@ -228,37 +229,43 @@ QString QJsonDocument::toJson(const QJsonValue &v, JsonFormat format) const {
case QJsonValue::Array: case QJsonValue::Array:
{ {
const QJsonArray a = v.toArray(); const QJsonArray a = v.toArray();
ss << "["; ss << (compact ? "[" : "[\n");
if(!a.empty()) { if(!a.empty()) {
QJsonArray::const_iterator it = a.begin(); QJsonArray::const_iterator it = a.begin();
QJsonArray::const_iterator e = a.end(); 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) { for(;it != e; ++it) {
ss << ','; ss << (compact ? "," : ",\n");
ss << toJson(*it, format); if (!compact) ss << QByteArray(4*indent, ' ');
ss << toJson(*it, format, indent+1);
} }
} }
ss << "]"; indent--;
ss << (compact ? "]" : QString("\n%1]").arg(QString(4*indent, ' ')));
} }
break; break;
case QJsonValue::Object: case QJsonValue::Object:
{ {
const QJsonObject o = v.toObject(); const QJsonObject o = v.toObject();
ss << "{"; ss << (compact ? "{" : "{\n");
if(!o.empty()) { if(!o.empty()) {
QJsonObject::const_iterator it = o.begin(); QJsonObject::const_iterator it = o.begin();
QJsonObject::const_iterator e = o.end(); QJsonObject::const_iterator e = o.end();
ss << '"' << escapeString(it.key()) << "\": " << toJson(it.value(), format); if (!compact) ss << QByteArray(4*indent, ' ');
ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, indent+1);
++it; ++it;
for(;it != e; ++it) { for(;it != e; ++it) {
ss << ','; ss << (compact ? "," : ",\n");
ss << '"' << escapeString(it.key()) << "\": " << toJson(it.value(), format); if (!compact) ss << QByteArray(4*indent, ' ');
ss << '"' << escapeString(it.key()) << (compact ? "\":" : "\": ") << toJson(it.value(), format, indent+1);
} }
} }
ss << "}"; indent--;
ss << (compact ? "}" : QString("\n%1}").arg(QString(4*indent, ' ')));
} }
break; break;
case QJsonValue::Undefined: case QJsonValue::Undefined:

View File

@ -88,7 +88,7 @@ public:
private: private:
void setRoot(const QJsonRoot &root); void setRoot(const QJsonRoot &root);
QString toJson(const QJsonValue &v, JsonFormat format) const; QString toJson(const QJsonValue &v, JsonFormat format, int indent = 1) const;
QString escapeString(const QString &s) const; QString escapeString(const QString &s) const;
private: private:

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