Browse Source

added Snapmatic Players Editor

1.5.x
Syping 5 years ago
parent
commit
6938ca577d
  1. 8
      .travis.yml
  2. 4
      AboutDialog.cpp
  3. 23
      ImportDialog.cpp
  4. 2
      ImportDialog.ui
  5. 37
      JsonEditorDialog.cpp
  6. 3
      JsonEditorDialog.ui
  7. 5
      MapLocationDialog.cpp
  8. 10
      OptionsDialog.cpp
  9. 295
      PictureDialog.cpp
  10. 37
      PictureDialog.h
  11. 241
      PlayerListDialog.cpp
  12. 55
      PlayerListDialog.h
  13. 152
      PlayerListDialog.ui
  14. 9
      ProfileDatabase.cpp
  15. 1
      ProfileDatabase.h
  16. 29
      ProfileInterface.cpp
  17. 4
      SavegameDialog.cpp
  18. 109
      SnapmaticEditor.cpp
  19. 12
      SnapmaticEditor.h
  20. 19
      SnapmaticEditor.ui
  21. 183
      SnapmaticPicture.cpp
  22. 49
      SnapmaticPicture.h
  23. 2
      SnapmaticWidget.cpp
  24. 2
      config.h
  25. 3
      gta5view.pro
  26. 4
      res/app.rc

8
.travis.yml

@ -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-dev5\\\\\\\"" 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-dev6\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
- make -j 4
- sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt5 --pkgversion=$PACKAGE_VERSION --pkgrelease=dev5 --pkggroup=utility --maintainer="Syping on Travis \<[email protected]\>" --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=dev6 --pkggroup=utility --maintainer="Syping on Travis \<[email protected]\>" --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-dev5\\\\\\\"" 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-dev6\\\\\\\"" DEFINES+=GTA5SYNC_QCONF ../../gta5view.pro
- make -j 4
- sudo checkinstall -D --default --nodoc --install=no --pkgname=gta5view-qt4 --pkgversion=$PACKAGE_VERSION --pkgrelease=dev5 --pkggroup=utility --maintainer="Syping on Travis \<[email protected]\>" --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=dev6 --pkggroup=utility --maintainer="Syping on Travis \<[email protected]\>" --requires=libqtcore4,libqtgui4,libqt4-network,qtcore4-l10n --conflicts=gta5view,gta5view-qt5 --replaces=gta5view,gta5view-qt5 --pakdir=../../package
- cd ..
deploy:

4
AboutDialog.cpp

@ -28,6 +28,10 @@ AboutDialog::AboutDialog(QWidget *parent) :
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered)
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
// Build Strings
QString appVersion = qApp->applicationVersion();

23
ImportDialog.cpp

@ -38,6 +38,13 @@ ImportDialog::ImportDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ImportDialog)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowMinMaxButtonsHint);
#ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered)
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
ui->setupUi(this);
importAgreed = false;
insideAvatarZone = false;
@ -56,14 +63,26 @@ ImportDialog::ImportDialog(QWidget *parent) :
ui->cbIgnore->setChecked(false);
ui->labColour->setText(tr("Background Colour: <span style=\"color: %1\">%1</span>").arg(selectedColour.name()));
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
snapmaticResolutionLW = 430 * screenRatio;
snapmaticResolutionLH = 240 * screenRatio;
ui->vlButtom->setSpacing(6 * screenRatio);
#ifndef Q_OS_MAC
ui->vlButtom->setContentsMargins(9 * screenRatio, 6 * screenRatio, 9 * screenRatio, 9 * screenRatio);
#else
if (QApplication::style()->objectName() == "macintosh")
{
ui->vlButtom->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio);
}
else
{
ui->vlButtom->setContentsMargins(9 * screenRatio, 6 * screenRatio, 9 * screenRatio, 9 * screenRatio);
}
#endif
setMinimumSize(430 * screenRatio, 380 * screenRatio);
setMaximumSize(430 * screenRatio, 380 * screenRatio);
setFixedSize(430 * screenRatio, 380 * screenRatio);
ui->vlButtom->setSpacing(6 * screenRatio);
ui->vlButtom->setContentsMargins(9 * screenRatio, 6 * screenRatio, 9 * screenRatio, 9 * screenRatio);
}
ImportDialog::~ImportDialog()

2
ImportDialog.ui

@ -89,7 +89,7 @@
<property name="title">
<string>Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="vlSettings">
<item>
<layout class="QHBoxLayout" name="hlColor">
<item>

37
JsonEditorDialog.cpp

@ -35,8 +35,13 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowMinMaxButtonsHint);
#ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered)
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
ui->setupUi(this);
ui->cmdClose->setDefault(true);
if (QIcon::hasThemeIcon("dialog-close"))
{
ui->cmdClose->setIcon(QIcon::fromTheme("dialog-close"));
@ -46,8 +51,8 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
#if QT_VERSION >= 0x050200
ui->txtJSON->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
#endif
QFontMetrics fm(ui->txtJSON->font());
ui->txtJSON->setTabStopWidth(fm.width(" "));
QFontMetrics fontMetrics(ui->txtJSON->font());
ui->txtJSON->setTabStopWidth(fontMetrics.width(" "));
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonCode.toUtf8());
ui->txtJSON->setStyleSheet("QPlainTextEdit{background-color: rgb(46, 47, 48); color: rgb(238, 231, 172);}");
@ -56,7 +61,15 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) :
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
#ifndef Q_OS_MAC
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 0, 9 * screenRatio, 0);
ui->vlInterface->setContentsMargins(0, 0, 0, 9 * screenRatio);
#else
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 0, 9 * screenRatio, 0);
ui->vlInterface->setContentsMargins(0, 0, 0, 9 * screenRatio);
#endif
if (screenRatio > 1)
{
ui->lineJSON->setMinimumHeight(qRound(1 * screenRatio));
@ -127,7 +140,25 @@ bool JsonEditorDialog::saveJsonContent()
smpic->setJsonStr(newCode, true);
if (!smpic->isJsonOk())
{
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of JSON Error"));
QString lastStep = smpic->getLastStep(false);
QString readableError;
if (lastStep.contains("JSONINCOMPLETE") && lastStep.contains("JSONERROR"))
{
readableError = SnapmaticPicture::tr("JSON is incomplete and malformed");
}
else if (lastStep.contains("JSONINCOMPLETE"))
{
readableError = SnapmaticPicture::tr("JSON is incomplete");
}
else if (lastStep.contains("JSONERROR"))
{
readableError = SnapmaticPicture::tr("JSON is malformed");
}
else
{
readableError = tr("JSON Error");
}
QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("Patching of Snapmatic Properties failed because of %1").arg(readableError));
smpic->setJsonStr(originalCode, true);
return false;
}

3
JsonEditorDialog.ui

@ -23,6 +23,9 @@
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<layout class="QVBoxLayout" name="vlJSON">
<property name="spacing">

5
MapLocationDialog.cpp

@ -29,6 +29,11 @@ MapLocationDialog::MapLocationDialog(double x, double y, QWidget *parent) :
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered)
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
ui->setupUi(this);
ui->cmdDone->setVisible(false);
ui->cmdApply->setVisible(false);

10
OptionsDialog.cpp

@ -42,13 +42,17 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered)
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
// Setup User Interface
ui->setupUi(this);
ui->tabWidget->setCurrentIndex(0);
ui->labPicCustomRes->setVisible(false);
QRect desktopResolution = qApp->desktop()->screenGeometry(parent);
QRect desktopResolution = QApplication::desktop()->screenGeometry(this);
int desktopSizeWidth = desktopResolution.width();
int desktopSizeHeight = desktopResolution.height();
aspectRatio = Qt::KeepAspectRatio;
@ -256,7 +260,7 @@ void OptionsDialog::setupInterfaceSettings()
ui->gbFont->setVisible(false);
ui->cbAlwaysUseMessageFont->setVisible(false);
#endif
QString currentStyle = qApp->style()->objectName();
QString currentStyle = QApplication::style()->objectName();
QString appStyle = settings->value("AppStyle", currentStyle).toString();
bool customStyle = settings->value("CustomStyle", false).toBool();
const QStringList availableStyles = QStyleFactory::keys();
@ -374,7 +378,7 @@ void OptionsDialog::applySettings()
QString newStyle = ui->cbStyleList->currentText();
settings->setValue("CustomStyle", true);
settings->setValue("AppStyle", newStyle);
qApp->setStyle(QStyleFactory::create(newStyle));
QApplication::setStyle(QStyleFactory::create(newStyle));
}
else
{

295
PictureDialog.cpp

@ -42,6 +42,8 @@
#include <QDesktopWidget>
#include <QJsonDocument>
#include <QApplication>
#include <QFontMetrics>
#include <QSizePolicy>
#include <QStaticText>
#include <QFileDialog>
#include <QMessageBox>
@ -79,35 +81,24 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, Q
ui(new Ui::PictureDialog)
{
primaryWindow = false;
setupPictureDialog(true);
}
PictureDialog::PictureDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::PictureDialog)
{
primaryWindow = false;
setupPictureDialog(false);
setupPictureDialog();
}
PictureDialog::PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent) :
QDialog(parent), primaryWindow(primaryWindow), profileDB(profileDB), crewDB(crewDB),
ui(new Ui::PictureDialog)
{
setupPictureDialog(true);
setupPictureDialog();
}
PictureDialog::PictureDialog(bool primaryWindow, QWidget *parent) :
QDialog(parent), primaryWindow(primaryWindow),
ui(new Ui::PictureDialog)
{
setupPictureDialog(false);
}
void PictureDialog::setupPictureDialog(bool withDatabase_)
void PictureDialog::setupPictureDialog()
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint^Qt::CustomizeWindowHint);
#ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered)
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
// Setup User Interface
ui->setupUi(this);
@ -122,9 +113,6 @@ void PictureDialog::setupPictureDialog(bool withDatabase_)
smpic = nullptr;
crewStr = "";
// With datebase
withDatabase = withDatabase_;
// Avatar area
qreal screenRatio = AppEnv::screenRatio();
if (screenRatio != 1)
@ -145,14 +133,14 @@ void PictureDialog::setupPictureDialog(bool withDatabase_)
// Manage menu
manageMenu = new QMenu(this);
jpegExportAction = manageMenu->addAction(tr("Export as &Picture..."), this, SLOT(exportSnapmaticPicture()));
pgtaExportAction = manageMenu->addAction(tr("Export as &Snapmatic..."), this, SLOT(copySnapmaticPicture()));
manageMenuSep1 = manageMenu->addSeparator();
propEditorAction = manageMenu->addAction(tr("&Edit Properties..."), this, SLOT(editSnapmaticProperties()));
manageMenuSep2 = manageMenu->addSeparator();
openViewerAction = manageMenu->addAction(tr("Open &Map Viewer..."), this, SLOT(openPreviewMap()));
manageMenu->addAction(tr("Export as &Picture..."), this, SLOT(exportSnapmaticPicture()));
manageMenu->addAction(tr("Export as &Snapmatic..."), this, SLOT(copySnapmaticPicture()));
manageMenu->addSeparator();
manageMenu->addAction(tr("&Edit Properties..."), this, SLOT(editSnapmaticProperties()));
manageMenu->addSeparator();
QAction *openViewerAction = manageMenu->addAction(tr("Open &Map Viewer..."), this, SLOT(openPreviewMap()));
openViewerAction->setShortcut(Qt::Key_M);
jsonEditorAction = manageMenu->addAction(tr("Open &JSON Editor..."), this, SLOT(editSnapmaticRawJson()));
manageMenu->addAction(tr("Open &JSON Editor..."), this, SLOT(editSnapmaticRawJson()));
ui->cmdManage->setMenu(manageMenu);
// Global map
@ -179,13 +167,22 @@ void PictureDialog::setupPictureDialog(bool withDatabase_)
PictureDialog::~PictureDialog()
{
delete propEditorAction;
delete openViewerAction;
delete jsonEditorAction;
delete jpegExportAction;
delete pgtaExportAction;
delete manageMenuSep1;
delete manageMenuSep2;
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
if (naviEnabled)
{
for (QObject *obj : layout()->menuBar()->children())
{
delete obj;
}
delete layout()->menuBar();
}
#endif
#endif
for (QObject *obj : manageMenu->children())
{
delete obj;
}
delete manageMenu;
delete ui;
}
@ -193,7 +190,7 @@ PictureDialog::~PictureDialog()
void PictureDialog::closeEvent(QCloseEvent *ev)
{
Q_UNUSED(ev)
if (primaryWindow && withDatabase)
if (primaryWindow)
{
emit endDatabaseThread();
}
@ -204,25 +201,140 @@ void PictureDialog::addPreviousNextButtons()
// Windows Vista additions
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
QPalette palette;
QToolBar *uiToolbar = new QToolBar("Picture Toolbar", this);
layout()->setMenuBar(uiToolbar);
uiToolbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
uiToolbar->setObjectName("uiToolbar");
uiToolbar->addAction(QIcon(":/img/back.png"), "", this, SLOT(previousPictureRequestedSlot()));
uiToolbar->addAction(QIcon(":/img/next.png"), "", this, SLOT(nextPictureRequestedSlot()));
ui->jsonFrame->setStyleSheet(QString("QFrame { background: %1; }").arg(palette.window().color().name()));
layout()->setMenuBar(uiToolbar);
naviEnabled = true;
#endif
#endif
}
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
#ifdef GTA5SYNC_APV
bool PictureDialog::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
*result = 0;
MSG *msg = static_cast<MSG*>(message);
LRESULT lRet = 0;
if (naviEnabled && QtWin::isCompositionEnabled())
{
if (msg->message == WM_NCCALCSIZE && msg->wParam == TRUE)
{
NCCALCSIZE_PARAMS *pncsp = reinterpret_cast<NCCALCSIZE_PARAMS*>(msg->lParam);
int sideBorderSize = ((frameSize().width() - size().width()) / 2);
#ifdef GTA5SYNC_APV_SIDE
int buttomBorderSize = sideBorderSize;
#else
int buttomBorderSize = (frameSize().height() - size().height());
#endif
pncsp->rgrc[0].left += sideBorderSize;
pncsp->rgrc[0].right -= sideBorderSize;
pncsp->rgrc[0].bottom -= buttomBorderSize;
}
else if (msg->message == WM_NCHITTEST)
{
int CLOSE_BUTTON_ID = 20;
lRet = HitTestNCA(msg->hwnd, msg->lParam);
DwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lRet);
*result = lRet;
if (lRet != CLOSE_BUTTON_ID) { return QWidget::nativeEvent(eventType, message, result); }
}
else
{
return QWidget::nativeEvent(eventType, message, result);
}
}
else
{
return QWidget::nativeEvent(eventType, message, result);
}
return true;
}
LRESULT PictureDialog::HitTestNCA(HWND hWnd, LPARAM lParam)
{
int LEFTEXTENDWIDTH = 0;
int RIGHTEXTENDWIDTH = 0;
int BOTTOMEXTENDWIDTH = 0;
int TOPEXTENDWIDTH = layout()->menuBar()->height();
POINT ptMouse = {(int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)};
RECT rcWindow;
GetWindowRect(hWnd, &rcWindow);
RECT rcFrame = {};
AdjustWindowRectEx(&rcFrame, WS_OVERLAPPEDWINDOW & ~WS_CAPTION, FALSE, NULL);
USHORT uRow = 1;
USHORT uCol = 1;
bool fOnResizeBorder = false;
if (ptMouse.y >= rcWindow.top && ptMouse.y < rcWindow.top + TOPEXTENDWIDTH)
{
fOnResizeBorder = (ptMouse.y < (rcWindow.top - rcFrame.top));
uRow = 0;
}
else if (ptMouse.y < rcWindow.bottom && ptMouse.y >= rcWindow.bottom - BOTTOMEXTENDWIDTH)
{
uRow = 2;
}
if (ptMouse.x >= rcWindow.left && ptMouse.x < rcWindow.left + LEFTEXTENDWIDTH)
{
uCol = 0;
}
else if (ptMouse.x < rcWindow.right && ptMouse.x >= rcWindow.right - RIGHTEXTENDWIDTH)
{
uCol = 2;
}
LRESULT hitTests[3][3] =
{
{ HTTOPLEFT, fOnResizeBorder ? HTTOP : HTCAPTION, HTTOPRIGHT },
{ HTLEFT, HTNOWHERE, HTRIGHT },
{ HTBOTTOMLEFT, HTBOTTOM, HTBOTTOMRIGHT },
};
return hitTests[uRow][uCol];
}
void PictureDialog::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event)
// int newDialogHeight = ui->labPicture->pixmap()->height();
// newDialogHeight = newDialogHeight + ui->jsonFrame->height();
// if (naviEnabled) newDialogHeight = newDialogHeight + layout()->menuBar()->height();
// int buttomBorderSize = (frameSize().height() - size().height());
// int sideBorderSize = ((frameSize().width() - size().width()) / 2);
// int brokenDialogHeight = newDialogHeight + (buttomBorderSize - sideBorderSize);
// if (event->size().height() == brokenDialogHeight)
// {
// qDebug() << "BROKEN 1";
// setGeometry(geometry().x(), geometry().y(), width(), newDialogHeight);
// qDebug() << "BROKEN 2";
// event->ignore();
// }
}
#endif
#endif
#endif
void PictureDialog::adaptNewDialogSize(QSize newLabelSize)
{
Q_UNUSED(newLabelSize)
int newDialogHeight = ui->labPicture->pixmap()->height();
newDialogHeight = newDialogHeight + ui->jsonFrame->height();
if (naviEnabled) newDialogHeight = newDialogHeight + layout()->menuBar()->height();
setMinimumSize(width(), newDialogHeight);
setMaximumSize(width(), newDialogHeight);
setMinimumSize(width(), newDialogHeight);
setFixedHeight(newDialogHeight);
ui->labPicture->updateGeometry();
ui->jsonFrame->updateGeometry();
@ -235,15 +347,16 @@ void PictureDialog::stylizeDialog()
#if QT_VERSION >= 0x050200
if (QtWin::isCompositionEnabled())
{
QPalette palette;
QtWin::extendFrameIntoClientArea(this, 0, this->layout()->menuBar()->height(), 0, 0);
setAttribute(Qt::WA_TranslucentBackground, true);
setAttribute(Qt::WA_NoSystemBackground, false);
ui->jsonFrame->setStyleSheet(QString("QFrame { background: %1; }").arg(palette.window().color().name()));
setStyleSheet("PictureDialog { background: transparent; }");
}
else
{
QPalette palette;
QtWin::resetExtendedFrame(this);
setAttribute(Qt::WA_TranslucentBackground, false);
ui->jsonFrame->setStyleSheet(QString("QFrame { background: %1; }").arg(palette.window().color().name()));
setStyleSheet(QString("PictureDialog { background: %1; }").arg(QtWin::realColorizationColor().name()));
}
#endif
@ -283,7 +396,7 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
{
if (ev->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = (QKeyEvent*)ev;
QKeyEvent *keyEvent = dynamic_cast<QKeyEvent*>(ev);
switch (keyEvent->key()){
case Qt::Key_Left:
emit previousPictureRequested();
@ -337,6 +450,49 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev)
break;
}
}
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
if (obj != ui->labPicture && naviEnabled)
{
if (ev->type() == QEvent::MouseButtonPress)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(ev);
if (mouseEvent->pos().y() <= layout()->menuBar()->height())
{
if (mouseEvent->button() == Qt::LeftButton)
{
dragPosition = mouseEvent->pos();
dragStart = true;
}
}
}
if (ev->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(ev);
if (mouseEvent->pos().y() <= layout()->menuBar()->height())
{
if (mouseEvent->button() == Qt::LeftButton)
{
dragStart = false;
}
}
}
if (ev->type() == QEvent::MouseMove && dragStart)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(ev);
if (mouseEvent->pos().y() <= layout()->menuBar()->height())
{
if (mouseEvent->buttons() & Qt::LeftButton)
{
QPoint diff = mouseEvent->pos() - dragPosition;
move(QPoint(pos() + diff));
updateGeometry();
}
}
}
}
#endif
#endif
}
return returnValue;
}
@ -378,15 +534,11 @@ void PictureDialog::renderOverlayPicture()
qreal screenRatio = AppEnv::screenRatio();
QRect preferedRect = QRect(0, 0, 200 * screenRatio, 160 * screenRatio);
QString overlayText = tr("Key 1 - Avatar Preview Mode\nKey 2 - Toggle Overlay\nArrow Keys - Navigate");
QImage overlayImage(1, 1, QImage::Format_ARGB32_Premultiplied);
overlayImage.fill(Qt::transparent);
QPainter overlayPainter(&overlayImage);
QFont overlayPainterFont;
overlayPainterFont.setPixelSize(12 * screenRatio);
overlayPainter.setFont(overlayPainterFont);
QRect overlaySpace = overlayPainter.boundingRect(preferedRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextDontClip | Qt::TextWordWrap, overlayText);
overlayPainter.end();
QFontMetrics fontMetrics(overlayPainterFont);
QRect overlaySpace = fontMetrics.boundingRect(preferedRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextDontClip | Qt::TextWordWrap, overlayText);
int hOverlay = Qt::AlignTop;
if (overlaySpace.height() < 74 * screenRatio)
@ -400,8 +552,10 @@ void PictureDialog::renderOverlayPicture()
overlaySpace.setHeight(overlaySpace.height() + 6 * screenRatio);
}
overlayImage = overlayImage.scaled(overlaySpace.size());
overlayPainter.begin(&overlayImage);
QImage overlayImage(overlaySpace.size(), QImage::Format_ARGB32_Premultiplied);
overlayImage.fill(Qt::transparent);
QPainter overlayPainter(&overlayImage);
overlayPainter.setPen(QColor::fromRgb(255, 255, 255, 255));
overlayPainter.setFont(overlayPainterFont);
overlayPainter.drawText(preferedRect, Qt::AlignLeft | hOverlay | Qt::TextDontClip | Qt::TextWordWrap, overlayText);
@ -447,14 +601,7 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk,
}
if (picture->isJsonOk())
{
if (withDatabase)
{
crewStr = crewDB->getCrewName(crewID);
}
else
{
crewStr = crewID;
}
crewStr = crewDB->getCrewName(crewID);
if (globalMap.contains(picArea))
{
picAreaStr = globalMap[picArea];
@ -564,7 +711,7 @@ void PictureDialog::crewNameUpdated()
{
SnapmaticPicture *picture = smpic; // used by macro
QString crewIDStr = crewID;
if (withDatabase && crewIDStr == crewStr)
if (crewIDStr == crewStr)
{
crewStr = crewDB->getCrewName(crewIDStr);
ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created));
@ -601,17 +748,10 @@ QString PictureDialog::generatePlayersString()
for (QString player : playersList)
{
QString playerName;
if (withDatabase)
{
playerName = profileDB->getPlayerName(player.toInt());
}
else
{
playerName = player;
}
playerName = profileDB->getPlayerName(player);
plyrsStr += ", <a href=\"https://socialclub.rockstargames.com/member/" % playerName % "/" % player % "\">" % playerName % "</a>";
}
plyrsStr.remove(0,2);
plyrsStr.remove(0, 2);
}
else
{
@ -746,11 +886,11 @@ void PictureDialog::editSnapmaticProperties()
SnapmaticEditor *snapmaticEditor;
if (rqFullscreen && fullscreenWidget != nullptr)
{
snapmaticEditor = new SnapmaticEditor(crewDB, fullscreenWidget);
snapmaticEditor = new SnapmaticEditor(crewDB, profileDB, fullscreenWidget);
}
else
{
snapmaticEditor = new SnapmaticEditor(crewDB, this);
snapmaticEditor = new SnapmaticEditor(crewDB, profileDB, this);
}
snapmaticEditor->setWindowIcon(windowIcon());
snapmaticEditor->setSnapmaticPicture(picture);
@ -782,14 +922,7 @@ void PictureDialog::editSnapmaticRawJson()
void PictureDialog::updated()
{
SnapmaticPicture *picture = smpic; // used by macro
if (withDatabase)
{
crewStr = crewDB->getCrewName(crewID);
}
else
{
crewStr = crewID;
}
crewStr = crewDB->getCrewName(crewID);
if (globalMap.contains(picArea))
{
picAreaStr = globalMap[picArea];

37
PictureDialog.h

@ -22,11 +22,21 @@
#include "SnapmaticPicture.h"
#include "ProfileDatabase.h"
#include "CrewDatabase.h"
#include <QResizeEvent>
#include <QMouseEvent>
#include <QToolBar>
#include <QDialog>
#include <QEvent>
#include <QMenu>
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
#ifdef GTA5SYNC_APV
#include <dwmapi.h>
#endif
#endif
#endif
namespace Ui {
class PictureDialog;
}
@ -36,10 +46,8 @@ class PictureDialog : public QDialog
Q_OBJECT
public:
explicit PictureDialog(ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0);
explicit PictureDialog(QWidget *parent = 0);
explicit PictureDialog(bool primaryWindow, ProfileDatabase *profileDB, CrewDatabase *crewDB, QWidget *parent = 0);
explicit PictureDialog(bool primaryWindow, QWidget *parent = 0);
void setupPictureDialog(bool withDatabase);
void setupPictureDialog();
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, bool indexed, int index);
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, int index);
void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk);
@ -86,6 +94,15 @@ protected:
bool eventFilter(QObject *obj, QEvent *ev);
void mousePressEvent(QMouseEvent *ev);
bool event(QEvent *event);
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
#ifdef GTA5SYNC_APV
bool nativeEvent(const QByteArray &eventType, void *message, long *result);
LRESULT HitTestNCA(HWND hWnd, LPARAM lParam);
void resizeEvent(QResizeEvent *event);
#endif
#endif
#endif
private:
QString generateCrewString();
@ -97,13 +114,6 @@ private:
QMap<QString, QString> globalMap;
SnapmaticPicture *smpic;
QWidget *fullscreenWidget;
QAction *jpegExportAction;
QAction *pgtaExportAction;
QAction *propEditorAction;
QAction *openViewerAction;
QAction *jsonEditorAction;
QAction *manageMenuSep1;
QAction *manageMenuSep2;
QImage avatarAreaPicture;
QImage snapmaticPicture;
QImage overlayTempImage;
@ -112,7 +122,6 @@ private:
QString picAreaStr;
QString crewStr;
bool overlayEnabled;
bool withDatabase;
bool rqFullscreen;
bool naviEnabled;
bool previewMode;
@ -122,6 +131,12 @@ private:
int avatarLocY;
int avatarSize;
QMenu *manageMenu;
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
QPoint dragPosition;
bool dragStart;
#endif
#endif
};
#endif // PICTUREDIALOG_H

241
PlayerListDialog.cpp

@ -0,0 +1,241 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2016-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 "PlayerListDialog.h"
#include "ui_PlayerListDialog.h"
#include "AppEnv.h"
#include <QFontMetrics>
#include <QInputDialog>
#include <QMessageBox>
#include <QPainter>
#include <QPixmap>
#include <QDebug>
PlayerListDialog::PlayerListDialog(QStringList players, ProfileDatabase *profileDB, QWidget *parent) :
QDialog(parent), players(players), profileDB(profileDB),
ui(new Ui::PlayerListDialog)
{
// Set Window Flags
setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint);
#ifdef Q_OS_LINUX
// for stupid Window Manager (GNOME 3 should feel triggered)
setWindowFlags(windowFlags()^Qt::Dialog^Qt::Window);
#endif
ui->setupUi(this);
ui->cmdCancel->setDefault(true);
if (QIcon::hasThemeIcon("dialog-ok-apply"))
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok-apply"));
}
else if (QIcon::hasThemeIcon("dialog-apply"))
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-apply"));
}
else if (QIcon::hasThemeIcon("dialog-ok"))
{
ui->cmdApply->setIcon(QIcon::fromTheme("dialog-ok"));
}
if (QIcon::hasThemeIcon("dialog-cancel"))
{
ui->cmdCancel->setIcon(QIcon::fromTheme("dialog-cancel"));
}
drawSwitchButtons();
buildInterface();
// DPI calculation
qreal screenRatio = AppEnv::screenRatio();
resize(500 * screenRatio, 350 * screenRatio);
}
PlayerListDialog::~PlayerListDialog()
{
for (QObject *object : ui->listAvPlayers->children())
{
delete object;
}
for (QObject *object : ui->listSePlayers->children())
{
delete object;
}
delete ui;
}
void PlayerListDialog::drawSwitchButtons()
{
QFont painterFont = ui->cmdApply->font();
QPalette palette;
QFontMetrics fontMetrics(painterFont);
QRect makeAvRect = fontMetrics.boundingRect(QRect(0, 0, 0, 0), Qt::AlignCenter | Qt::TextDontClip, "<");
QRect makeSeRect = fontMetrics.boundingRect(QRect(0, 0, 0, 0), Qt::AlignCenter | Qt::TextDontClip, ">");
QRect makeAdRect = fontMetrics.boundingRect(QRect(0, 0, 0, 0), Qt::AlignCenter | Qt::TextDontClip, "+");
int makeAvSize;
if (makeAvRect.height() > makeAvRect.width())
{
makeAvSize = makeAvRect.height();
}
else
{
makeAvSize = makeAvRect.width();
}
int makeSeSize;
if (makeSeRect.height() > makeSeRect.width())
{
makeSeSize = makeSeRect.height();
}
else
{
makeSeSize = makeSeRect.width();
}
int makeAdSize;
if (makeAdRect.height() > makeAdRect.width())
{
makeAdSize = makeAdRect.height();
}
else
{
makeAdSize = makeAdRect.width();
}
QImage avImage(makeAvSize, makeAvSize, QImage::Format_ARGB32_Premultiplied);
avImage.fill(Qt::transparent);
QImage seImage(makeSeSize, makeSeSize, QImage::Format_ARGB32_Premultiplied);
seImage.fill(Qt::transparent);
QImage adImage(makeAdSize, makeAdSize, QImage::Format_ARGB32_Premultiplied);
adImage.fill(Qt::transparent);
QPainter avPainter(&avImage);
avPainter.setFont(painterFont);
avPainter.setBrush(palette.buttonText());
avPainter.drawText(0, 0, makeAvSize, makeAvSize, Qt::AlignCenter | Qt::TextDontClip, "<");
avPainter.end();
QPainter sePainter(&seImage);
sePainter.setFont(painterFont);
sePainter.setBrush(palette.buttonText());
sePainter.drawText(0, 0, makeSeSize, makeSeSize, Qt::AlignCenter | Qt::TextDontClip, ">");
sePainter.end();
QPainter adPainter(&adImage);
adPainter.setFont(painterFont);
adPainter.setBrush(palette.buttonText());
adPainter.drawText(0, 0, makeAdSize, makeAdSize, Qt::AlignCenter | Qt::TextDontClip, "+");
adPainter.end();
ui->cmdMakeAv->setIconSize(avImage.size());
ui->cmdMakeSe->setIconSize(seImage.size());
ui->cmdMakeAd->setIconSize(adImage.size());
ui->cmdMakeAv->setIcon(QIcon(QPixmap::fromImage(avImage)));
ui->cmdMakeSe->setIcon(QIcon(QPixmap::fromImage(seImage)));
ui->cmdMakeAd->setIcon(QIcon(QPixmap::fromImage(adImage)));
}
void PlayerListDialog::on_cmdCancel_clicked()
{
close();
}
void PlayerListDialog::buildInterface()
{
const QStringList dbPlayers = profileDB->getPlayers();
for (QString sePlayer : players)
{
ui->listSePlayers->addItem(QString("%1 (%2)").arg(sePlayer, profileDB->getPlayerName(sePlayer)));
}
for (QString dbPlayer : dbPlayers)
{
if (!players.contains(dbPlayer))
{
ui->listAvPlayers->addItem(QString("%1 (%2)").arg(dbPlayer, profileDB->getPlayerName(dbPlayer)));
}
}
}
void PlayerListDialog::on_cmdMakeAv_clicked()
{
for (QListWidgetItem *item : ui->listSePlayers->selectedItems())
{
QString playerItemText = item->text();
delete item;
ui->listAvPlayers->addItem(playerItemText);
ui->listAvPlayers->sortItems(Qt::AscendingOrder);
}
}
void PlayerListDialog::on_cmdMakeSe_clicked()
{
int maxPlayers = 30;
if (maxPlayers < ui->listSePlayers->count() + ui->listAvPlayers->selectedItems().count())
{
QMessageBox::warning(this, tr("Add Players..."), tr("Failed to add more Players because the limit of Players are %1!").arg(QString::number(maxPlayers)));
return;
}
for (QListWidgetItem *item : ui->listAvPlayers->selectedItems())
{
QString playerItemText = item->text();
delete item;
ui->listSePlayers->addItem(playerItemText);
}
}
void PlayerListDialog::on_cmdMakeAd_clicked()
{
bool playerOk;
int playerID = QInputDialog::getInt(this, tr("Add Player..."), tr("Enter Social Club Player ID"), 1, 1, 214783647, 1, &playerOk, windowFlags());
if (playerOk)
{
for (int i = 0; i < ui->listAvPlayers->count(); ++i)
{
QListWidgetItem *item = ui->listAvPlayers->item(i);
QString playerItemText = item->text();
if (playerItemText.split(" ").at(0) == QString::number(playerID))
{
delete item;
ui->listSePlayers->addItem(playerItemText);
return;
}
}
for (int i = 0; i < ui->listSePlayers->count(); ++i)
{
QListWidgetItem *item = ui->listSePlayers->item(i);
QString playerItemText = item->text();
if (playerItemText.split(" ").at(0) == QString::number(playerID))
{
QMessageBox::warning(this, tr("Add Player..."), tr("Failed to add Player %1 because Player %1 is already added!").arg(QString::number(playerID)));
//ui->listSePlayers->setCurrentItem(item);
return;
}
}
QString playerItemText = QString("%1 (%1)").arg(QString::number(playerID));
ui->listSePlayers->addItem(playerItemText);
}
}
void PlayerListDialog::on_cmdApply_clicked()
{
players.clear();
for (int i = 0; i < ui->listSePlayers->count(); ++i)
{
players += ui->listSePlayers->item(i)->text().split(" ").at(0);
}
emit playerListUpdated(players);
close();
}

55
PlayerListDialog.h

@ -0,0 +1,55 @@
/*****************************************************************************
* gta5sync GRAND THEFT AUTO V SYNC
* Copyright (C) 2016-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/>.
*****************************************************************************/
#ifndef PLAYERLISTDIALOG_H
#define PLAYERLISTDIALOG_H
#include "ProfileDatabase.h"
#include <QDialog>
namespace Ui {
class PlayerListDialog;
}
class PlayerListDialog : public QDialog
{
Q_OBJECT
public:
explicit PlayerListDialog(QStringList players, ProfileDatabase *profileDB, QWidget *parent = 0);
~PlayerListDialog();
private slots:
void on_cmdCancel_clicked();
void on_cmdMakeAv_clicked();
void on_cmdMakeSe_clicked();
void on_cmdMakeAd_clicked();
void on_cmdApply_clicked();
private:
QStringList players;
ProfileDatabase *profileDB;
Ui::PlayerListDialog *ui;
void drawSwitchButtons();
void buildInterface();
signals:
void playerListUpdated(QStringList playerList);
};
#endif // PLAYERLISTDIALOG_H

152
PlayerListDialog.ui

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PlayerListDialog</class>
<widget class="QDialog" name="PlayerListDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>350</height>
</rect>
</property>
<property name="windowTitle">
<string>Edit Players...</string>
</property>
<layout class="QVBoxLayout" name="vlInterface">
<item>
<layout class="QHBoxLayout" name="hlPlayers">
<item>
<layout class="QVBoxLayout" name="vlAvPlayers">
<item>
<widget class="QLabel" name="labAvPlayers">
<property name="text">
<string>Available Players:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listAvPlayers">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="vlButtons">
<item>
<spacer name="vsButtons1">
<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="cmdMakeSe">
<property name="text">
<string/>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdMakeAv">
<property name="text">
<string/>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdMakeAd">
<property name="text">
<string/>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="vsButtons2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="vlSePlayers">
<item>
<widget class="QLabel" name="labSePlayers">
<property name="text">
<string>Selected Players:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listSePlayers">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="hlButtons">
<item>
<spacer name="hsButtons">
<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>
<widget class="QPushButton" name="cmdApply">
<property name="text">
<string>&amp;Apply</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdCancel">
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

9
ProfileDatabase.cpp

@ -57,6 +57,15 @@ QStringList ProfileDatabase::getPlayers()
return profileDB->childKeys();
}
QString ProfileDatabase::getPlayerName(QString playerID)
{
QMutexLocker locker(&mutex);
#ifdef GTA5SYNC_DEBUG
qDebug() << "getPlayerName" << playerID;
#endif
return profileDB->value(playerID, playerID).toString();
}
QString ProfileDatabase::getPlayerName(int playerID)
{
QMutexLocker locker(&mutex);

1
ProfileDatabase.h

@ -29,6 +29,7 @@ class ProfileDatabase : public QObject
Q_OBJECT
public:
explicit ProfileDatabase(QObject *parent = 0);
QString getPlayerName(QString playerID);
QString getPlayerName(int playerID);
QStringList getPlayers();
~ProfileDatabase();

29
ProfileInterface.cpp

@ -89,8 +89,16 @@ ProfileInterface::ProfileInterface(ProfileDatabase *profileDB, CrewDatabase *cre
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio);
#else
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 15 * screenRatio, 15 * screenRatio, 17 * screenRatio);
if (QApplication::style()->objectName() == "macintosh")
{
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 15 * screenRatio, 15 * screenRatio, 17 * screenRatio);
}
else
{
ui->hlButtons->setSpacing(6 * screenRatio);
ui->hlButtons->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio);