diff --git a/CMakeLists.txt b/CMakeLists.txt index 3057f85..a789697 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,7 +95,6 @@ set(GTA5VIEW_SOURCES set(GTA5VIEW_HEADERS src/config.h - src/wrapper.h src/AboutDialog.h src/AppEnv.h src/CrewDatabase.h diff --git a/src/OptionsDialog.cpp b/src/OptionsDialog.cpp index eddf145..df9da2b 100644 --- a/src/OptionsDialog.cpp +++ b/src/OptionsDialog.cpp @@ -21,7 +21,6 @@ #include "TranslationClass.h" #include "StandardPaths.h" #include "UserInterface.h" -#include "wrapper.h" #include "AppEnv.h" #include "config.h" #include @@ -65,16 +64,10 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) : ui->cmdCancel->setDefault(true); ui->cmdCancel->setFocus(); -#if QT_VERSION >= 0x050000 qreal screenRatioPR = AppEnv::screenRatioPR(); QRect desktopResolution = QApplication::primaryScreen()->geometry(); int desktopSizeWidth = qRound((double)desktopResolution.width() * screenRatioPR); int desktopSizeHeight = qRound((double)desktopResolution.height() * screenRatioPR); -#else - QRect desktopResolution = QApplication::desktop()->screenGeometry(this); - int desktopSizeWidth = desktopResolution.width(); - int desktopSizeHeight = desktopResolution.height(); -#endif aspectRatio = Qt::KeepAspectRatio; defExportSize = SnapmaticPicture::getSnapmaticResolution(); cusExportSize = defExportSize; @@ -560,7 +553,7 @@ void OptionsDialog::setupPictureSettings() ui->rbPicDefaultRes->setChecked(true); } - aspectRatio = (Qt::AspectRatioMode)settings->value("AspectRatio", Qt::KeepAspectRatio).toInt(); + aspectRatio = static_cast(settings->value("AspectRatio", Qt::KeepAspectRatio).toInt()); if (aspectRatio == Qt::IgnoreAspectRatio) { ui->cbIgnoreAspectRatio->setChecked(true); } diff --git a/src/PictureDialog.cpp b/src/PictureDialog.cpp index 2d4ca6a..ccb4237 100644 --- a/src/PictureDialog.cpp +++ b/src/PictureDialog.cpp @@ -84,7 +84,7 @@ #define crewID QString::number(picture->getSnapmaticProperties().crewID) #define picArea picture->getSnapmaticProperties().location.area #define picPath picture->getPictureFilePath() -#define picTitl StringParser::escapeString(picture->getPictureTitle()) +#define picTitl picture->getPictureTitle().toHtmlEscaped() #define plyrsList picture->getSnapmaticProperties().playersList #if QT_VERSION >= 0x060000 #define created QLocale().toString(picture->getSnapmaticProperties().createdDateTime, QLocale::ShortFormat) @@ -168,15 +168,15 @@ void PictureDialog::setupPictureDialog() // Manage menu manageMenu = new QMenu(this); - manageMenu->addAction(tr("Export as &Picture..."), this, SLOT(exportSnapmaticPicture())); - manageMenu->addAction(tr("Export as &Snapmatic..."), this, SLOT(copySnapmaticPicture())); + manageMenu->addAction(tr("Export as &Picture..."), this, &PictureDialog::exportSnapmaticPicture); + manageMenu->addAction(tr("Export as &Snapmatic..."), this, &PictureDialog::copySnapmaticPicture); manageMenu->addSeparator(); - manageMenu->addAction(tr("&Edit Properties..."), this, SLOT(editSnapmaticProperties())); - manageMenu->addAction(tr("&Overwrite Image..."), this, SLOT(editSnapmaticImage())); + manageMenu->addAction(tr("&Edit Properties..."), this, &PictureDialog::editSnapmaticProperties); + manageMenu->addAction(tr("&Overwrite Image..."), this, &PictureDialog::editSnapmaticImage); manageMenu->addSeparator(); - QAction *openViewerAction = manageMenu->addAction(tr("Open &Map Viewer..."), this, SLOT(openPreviewMap())); + QAction *openViewerAction = manageMenu->addAction(tr("Open &Map Viewer..."), this, &PictureDialog::openPreviewMap); openViewerAction->setShortcut(Qt::Key_M); - manageMenu->addAction(tr("Open &JSON Editor..."), this, SLOT(editSnapmaticRawJson())); + manageMenu->addAction(tr("Open &JSON Editor..."), this, &PictureDialog::editSnapmaticRawJson); ui->cmdManage->setMenu(manageMenu); // Global map @@ -221,8 +221,8 @@ void PictureDialog::addPreviousNextButtons() QToolBar *uiToolbar = new QToolBar("Picture Toolbar", this); uiToolbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); uiToolbar->setObjectName("UiToolbar"); - uiToolbar->addAction(QIcon(AppEnv::getImagesFolder() % "/back.svgz"), "", this, SLOT(previousPictureRequestedSlot())); - uiToolbar->addAction(QIcon(AppEnv::getImagesFolder() % "/next.svgz"), "", this, SLOT(nextPictureRequestedSlot())); + uiToolbar->addAction(QIcon(AppEnv::getImagesFolder() % "/back.svgz"), "", this, &PictureDialog::previousPictureRequestedSlot); + uiToolbar->addAction(QIcon(AppEnv::getImagesFolder() % "/next.svgz"), "", this, &PictureDialog::nextPictureRequestedSlot); #ifdef Q_OS_MAC #if QT_VERSION >= 0x050000 uiToolbar->setStyle(QStyleFactory::create("Fusion")); @@ -348,12 +348,10 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev) openPreviewMap(); returnValue = true; break; -#if QT_VERSION >= 0x050300 case Qt::Key_Exit: ui->cmdClose->click(); returnValue = true; break; -#endif case Qt::Key_Enter: case Qt::Key_Return: on_labPicture_mouseDoubleClicked(Qt::LeftButton); returnValue = true; @@ -365,7 +363,6 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev) } } #ifdef Q_OS_WIN -#if QT_VERSION >= 0x050000 if (obj != ui->labPicture && naviEnabled) { if (ev->type() == QEvent::MouseButtonPress) { QMouseEvent *mouseEvent = dynamic_cast(ev); @@ -395,7 +392,6 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev) } } } -#endif #endif } return returnValue; @@ -485,8 +481,8 @@ void PictureDialog::renderOverlayPicture() void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, bool _indexed, int _index) { if (smpic != nullptr) { - QObject::disconnect(smpic, SIGNAL(updated()), this, SLOT(updated())); - QObject::disconnect(smpic, SIGNAL(customSignal(QString)), this, SLOT(customSignal(QString))); + QObject::disconnect(smpic, &SnapmaticPicture::updated, this, &PictureDialog::updated); + QObject::disconnect(smpic, &SnapmaticPicture::customSignal, this, &PictureDialog::customSignal); } snapmaticPicture = QImage(); indexed = _indexed; @@ -511,14 +507,14 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk, } setWindowTitle(windowTitleStr.arg(picTitl)); ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created)); - QTimer::singleShot(0, this, SLOT(adaptDialogSize())); + QTimer::singleShot(0, this, &PictureDialog::adaptDialogSize); } else { ui->labJSON->setText(jsonDrawString.arg("0", "0", "0", tr("No Players"), tr("No Crew"), tr("Unknown Location"))); - QTimer::singleShot(0, this, SLOT(adaptDialogSize())); + QTimer::singleShot(0, this, &PictureDialog::adaptDialogSize); } - QObject::connect(smpic, SIGNAL(updated()), this, SLOT(updated())); - QObject::connect(smpic, SIGNAL(customSignal(QString)), this, SLOT(customSignal(QString))); + QObject::connect(smpic, &SnapmaticPicture::updated, this, &PictureDialog::updated); + QObject::connect(smpic, &SnapmaticPicture::customSignal, this, &PictureDialog::customSignal); emit newPictureCommited(snapmaticPicture); } @@ -573,9 +569,7 @@ void PictureDialog::renderPicture() shownImagePainter.drawImage(3 * screenRatio * screenRatioPR, 3 * screenRatio * screenRatioPR, overlayTempImage, Qt::AutoColor); } shownImagePainter.end(); -#if QT_VERSION >= 0x050600 shownImagePixmap.setDevicePixelRatio(screenRatioPR); -#endif ui->labPicture->setPixmap(shownImagePixmap); } @@ -586,7 +580,7 @@ void PictureDialog::crewNameUpdated() if (crewIDStr == crewStr) { crewStr = crewDB->getCrewName(crewIDStr); ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created)); - QTimer::singleShot(0, this, SLOT(adaptDialogSize())); + QTimer::singleShot(0, this, &PictureDialog::adaptDialogSize); } } @@ -595,7 +589,7 @@ void PictureDialog::playerNameUpdated() SnapmaticPicture *picture = smpic; // used by macro if (plyrsList.count() >= 1) { ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created)); - QTimer::singleShot(0, this, SLOT(adaptDialogSize())); + QTimer::singleShot(0, this, &PictureDialog::adaptDialogSize); } } @@ -675,9 +669,9 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button) pictureWidget->setModal(true); fullscreenWidget = pictureWidget; - QObject::connect(this, SIGNAL(newPictureCommited(QImage)), pictureWidget, SLOT(setImage(QImage))); - QObject::connect(pictureWidget, SIGNAL(nextPictureRequested()), this, SLOT(dialogNextPictureRequested())); - QObject::connect(pictureWidget, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested())); + QObject::connect(this, &PictureDialog::newPictureCommited, pictureWidget, QOverload::of(&PictureWidget::setImage)); + QObject::connect(pictureWidget, &PictureWidget::nextPictureRequested, this, &PictureDialog::dialogNextPictureRequested); + QObject::connect(pictureWidget, &PictureWidget::previousPictureRequested, this, &PictureDialog::dialogPreviousPictureRequested); pictureWidget->move(desktopRect.x(), desktopRect.y()); pictureWidget->resize(desktopRect.width(), desktopRect.height()); @@ -866,11 +860,7 @@ void PictureDialog::editSnapmaticRawJson() } jsonEditor->setWindowIcon(windowIcon()); jsonEditor->setModal(true); -#ifndef Q_OS_ANDROID jsonEditor->show(); -#else - jsonEditor->showMaximized(); -#endif jsonEditor->exec(); delete jsonEditor; } @@ -887,7 +877,7 @@ void PictureDialog::updated() } setWindowTitle(windowTitleStr.arg(picTitl)); ui->labJSON->setText(jsonDrawString.arg(locX, locY, locZ, generatePlayersString(), generateCrewString(), picTitl, picAreaStr, created)); - QTimer::singleShot(0, this, SLOT(adaptDialogSize())); + QTimer::singleShot(0, this, &PictureDialog::adaptDialogSize); } void PictureDialog::customSignal(QString signal) diff --git a/src/ProfileInterface.cpp b/src/ProfileInterface.cpp index 63f66f6..4621140 100644 --- a/src/ProfileInterface.cpp +++ b/src/ProfileInterface.cpp @@ -1632,7 +1632,7 @@ void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev) SnapmaticWidget *picWidget = qobject_cast(sender()); if (picWidget != previousWidget) { if (previousWidget != nullptr) { - previousWidget->setStyleSheet(QLatin1String("")); + previousWidget->setStyleSheet(QString()); } picWidget->setStyleSheet(QString("QFrame#SnapmaticFrame{background-color:palette(highlight)}QLabel#labPicStr{color:palette(highlighted-text)}")); previousWidget = picWidget; @@ -1642,69 +1642,81 @@ void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev) if (contentMode < 20 || selectedCount == 0) { QMenu editMenu(SnapmaticWidget::tr("Edi&t"), picWidget); if (picWidget->isHidden()) { - editMenu.addAction(SnapmaticWidget::tr("Show &In-game"), picWidget, SLOT(makePictureVisibleSlot())); + editMenu.addAction(SnapmaticWidget::tr("Show &In-game"), picWidget, &SnapmaticWidget::makePictureVisibleSlot); } else { - editMenu.addAction(SnapmaticWidget::tr("Hide &In-game"), picWidget, SLOT(makePictureHiddenSlot())); + editMenu.addAction(SnapmaticWidget::tr("Hide &In-game"), picWidget, &SnapmaticWidget::makePictureHiddenSlot); } - editMenu.addAction(PictureDialog::tr("&Edit Properties..."), picWidget, SLOT(editSnapmaticProperties())); - editMenu.addAction(PictureDialog::tr("&Overwrite Image..."), picWidget, SLOT(editSnapmaticImage())); + editMenu.addAction(PictureDialog::tr("&Edit Properties..."), picWidget, &SnapmaticWidget::editSnapmaticProperties); + editMenu.addAction(PictureDialog::tr("&Overwrite Image..."), picWidget, &SnapmaticWidget::editSnapmaticImage); editMenu.addSeparator(); - editMenu.addAction(PictureDialog::tr("Open &Map Viewer..."), picWidget, SLOT(openMapViewer())); - editMenu.addAction(PictureDialog::tr("Open &JSON Editor..."), picWidget, SLOT(editSnapmaticRawJson())); + editMenu.addAction(PictureDialog::tr("Open &Map Viewer..."), picWidget, &SnapmaticWidget::openMapViewer); + editMenu.addAction(PictureDialog::tr("Open &JSON Editor..."), picWidget, &SnapmaticWidget::editSnapmaticRawJson); QMenu exportMenu(SnapmaticWidget::tr("&Export"), this); - exportMenu.addAction(PictureDialog::tr("Export as &Picture..."), picWidget, SLOT(on_cmdExport_clicked())); - exportMenu.addAction(PictureDialog::tr("Export as &Snapmatic..."), picWidget, SLOT(on_cmdCopy_clicked())); - contextMenu.addAction(SnapmaticWidget::tr("&View"), picWidget, SLOT(on_cmdView_clicked())); + exportMenu.addAction(PictureDialog::tr("Export as &Picture..."), picWidget, &SnapmaticWidget::on_cmdExport_clicked); + exportMenu.addAction(PictureDialog::tr("Export as &Snapmatic..."), picWidget, &SnapmaticWidget::on_cmdCopy_clicked); + contextMenu.addAction(SnapmaticWidget::tr("&View"), picWidget, &SnapmaticWidget::on_cmdView_clicked); contextMenu.addMenu(&editMenu); contextMenu.addMenu(&exportMenu); - contextMenu.addAction(SnapmaticWidget::tr("&Remove"), picWidget, SLOT(on_cmdDelete_clicked())); + contextMenu.addAction(SnapmaticWidget::tr("&Remove"), picWidget, &SnapmaticWidget::on_cmdDelete_clicked); contextMenu.addSeparator(); if (!picWidget->isSelected()) - contextMenu.addAction(SnapmaticWidget::tr("&Select"), picWidget, SLOT(pictureSelected())); + contextMenu.addAction(SnapmaticWidget::tr("&Select"), picWidget, &SnapmaticWidget::pictureSelected); else { - contextMenu.addAction(SnapmaticWidget::tr("&Deselect"), picWidget, SLOT(pictureSelected())); + contextMenu.addAction(SnapmaticWidget::tr("&Deselect"), picWidget, &SnapmaticWidget::pictureSelected); } if (selectedCount != widgets.count()) { - contextMenu.addAction(SnapmaticWidget::tr("Select &All"), picWidget, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A")); + QAction *action = contextMenu.addAction(SnapmaticWidget::tr("Select &All"), picWidget, &SnapmaticWidget::selectAllWidgets); + action->setShortcut(QKeySequence::fromString("Ctrl+A")); } if (selectedCount != 0) { - contextMenu.addAction(SnapmaticWidget::tr("&Deselect All"), picWidget, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); + QAction *action = contextMenu.addAction(SnapmaticWidget::tr("&Deselect All"), picWidget, &SnapmaticWidget::deselectAllWidgets); + action->setShortcut(QKeySequence::fromString("Ctrl+D")); } contextMenuOpened = true; contextMenu.exec(ev->globalPos()); contextMenuOpened = false; - QTimer::singleShot(0, this, SLOT(hoverProfileWidgetCheck())); + QTimer::singleShot(0, this, &ProfileInterface::hoverProfileWidgetCheck); } else { QMenu editMenu(SnapmaticWidget::tr("Edi&t"), picWidget); - editMenu.addAction(QApplication::translate("UserInterface", "&Qualify as Avatar"), this, SLOT(massToolQualify()), QKeySequence::fromString("Shift+Q")); - editMenu.addAction(QApplication::translate("UserInterface", "Change &Players..."), this, SLOT(massToolPlayers()), QKeySequence::fromString("Shift+P")); - editMenu.addAction(QApplication::translate("UserInterface", "Change &Crew..."), this, SLOT(massToolCrew()), QKeySequence::fromString("Shift+C")); - editMenu.addAction(QApplication::translate("UserInterface", "Change &Title..."), this, SLOT(massToolTitle()), QKeySequence::fromString("Shift+T")); + QAction *action = editMenu.addAction(QApplication::translate("UserInterface", "&Qualify as Avatar"), this, &ProfileInterface::massToolQualify); + action->setShortcut(QKeySequence::fromString("Shift+Q")); + action = editMenu.addAction(QApplication::translate("UserInterface", "Change &Players..."), this, &ProfileInterface::massToolPlayers); + action->setShortcut(QKeySequence::fromString("Shift+P")); + action = editMenu.addAction(QApplication::translate("UserInterface", "Change &Crew..."), this, &ProfileInterface::massToolCrew); + action->setShortcut(QKeySequence::fromString("Shift+C")); + action = editMenu.addAction(QApplication::translate("UserInterface", "Change &Title..."), this, &ProfileInterface::massToolTitle); + action->setShortcut(QKeySequence::fromString("Shift+T")); editMenu.addSeparator(); - editMenu.addAction(SnapmaticWidget::tr("Show &In-game"), this, SLOT(enableSelected()), QKeySequence::fromString("Shift+E")); - editMenu.addAction(SnapmaticWidget::tr("Hide &In-game"), this, SLOT(disableSelected()), QKeySequence::fromString("Shift+D")); + action = editMenu.addAction(SnapmaticWidget::tr("Show &In-game"), this, &ProfileInterface::enableSelected); + action->setShortcut(QKeySequence::fromString("Shift+E")); + action = editMenu.addAction(SnapmaticWidget::tr("Hide &In-game"), this, &ProfileInterface::disableSelected); + action->setShortcut(QKeySequence::fromString("Shift+D")); contextMenu.addMenu(&editMenu); - contextMenu.addAction(SavegameWidget::tr("&Export"), this, SLOT(exportSelected()), QKeySequence::fromString("Ctrl+E")); - contextMenu.addAction(SavegameWidget::tr("&Remove"), this, SLOT(deleteSelectedR()), QKeySequence::fromString("Ctrl+Del")); + action = contextMenu.addAction(SavegameWidget::tr("&Export"), this, &ProfileInterface::exportSelected); + action->setShortcut(QKeySequence::fromString("Ctrl+E")); + action = contextMenu.addAction(SavegameWidget::tr("&Remove"), this, &ProfileInterface::deleteSelectedR); + action->setShortcut(QKeySequence::fromString("Ctrl+Del")); contextMenu.addSeparator(); if (!picWidget->isSelected()) { - contextMenu.addAction(SnapmaticWidget::tr("&Select"), picWidget, SLOT(pictureSelected())); + contextMenu.addAction(SnapmaticWidget::tr("&Select"), picWidget, &SnapmaticWidget::pictureSelected); } else { - contextMenu.addAction(SnapmaticWidget::tr("&Deselect"), picWidget, SLOT(pictureSelected())); + contextMenu.addAction(SnapmaticWidget::tr("&Deselect"), picWidget, &SnapmaticWidget::pictureSelected); } if (selectedCount != widgets.count()) { - contextMenu.addAction(SnapmaticWidget::tr("Select &All"), picWidget, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A")); + action = contextMenu.addAction(SnapmaticWidget::tr("Select &All"), picWidget, &SnapmaticWidget::selectAllWidgets); + action->setShortcut(QKeySequence::fromString("Ctrl+A")); } if (selectedCount != 0) { - contextMenu.addAction(SnapmaticWidget::tr("&Deselect All"), picWidget, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); + action = contextMenu.addAction(SnapmaticWidget::tr("&Deselect All"), picWidget, &SnapmaticWidget::deselectAllWidgets); + action->setShortcut(QKeySequence::fromString("Ctrl+D")); } contextMenuOpened = true; contextMenu.exec(ev->globalPos()); contextMenuOpened = false; - QTimer::singleShot(0, this, SLOT(hoverProfileWidgetCheck())); + QTimer::singleShot(0, this, &ProfileInterface::hoverProfileWidgetCheck); } } @@ -1721,55 +1733,67 @@ void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev) QMenu contextMenu(sgdWidget); const int selectedCount = selectedWidgets(); if (contentMode < 20 || selectedCount == 0) { - contextMenu.addAction(SavegameWidget::tr("&View"), sgdWidget, SLOT(on_cmdView_clicked())); - contextMenu.addAction(SavegameWidget::tr("&Export"), sgdWidget, SLOT(on_cmdCopy_clicked())); - contextMenu.addAction(SavegameWidget::tr("&Remove"), sgdWidget, SLOT(on_cmdDelete_clicked())); + contextMenu.addAction(SavegameWidget::tr("&View"), sgdWidget, &SavegameWidget::on_cmdView_clicked); + contextMenu.addAction(SavegameWidget::tr("&Export"), sgdWidget, &SavegameWidget::on_cmdCopy_clicked); + contextMenu.addAction(SavegameWidget::tr("&Remove"), sgdWidget, &SavegameWidget::on_cmdDelete_clicked); contextMenu.addSeparator(); if (!sgdWidget->isSelected()) { - contextMenu.addAction(SavegameWidget::tr("&Select"), sgdWidget, SLOT(savegameSelected())); + contextMenu.addAction(SavegameWidget::tr("&Select"), sgdWidget, &SavegameWidget::savegameSelected); } else { - contextMenu.addAction(SavegameWidget::tr("&Deselect"), sgdWidget, SLOT(savegameSelected())); + contextMenu.addAction(SavegameWidget::tr("&Deselect"), sgdWidget, &SavegameWidget::savegameSelected); } if (selectedCount != widgets.count()) { - contextMenu.addAction(SavegameWidget::tr("Select &All"), sgdWidget, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A")); + QAction *action = contextMenu.addAction(SavegameWidget::tr("Select &All"), sgdWidget, &SavegameWidget::selectAllWidgets); + action->setShortcut(QKeySequence::fromString("Ctrl+A")); } if (selectedCount != 0) { - contextMenu.addAction(SavegameWidget::tr("&Deselect All"), sgdWidget, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); + QAction *action = contextMenu.addAction(SavegameWidget::tr("&Deselect All"), sgdWidget, &SavegameWidget::deselectAllWidgets); + action->setShortcut(QKeySequence::fromString("Ctrl+D")); } contextMenuOpened = true; contextMenu.exec(ev->globalPos()); contextMenuOpened = false; - QTimer::singleShot(0, this, SLOT(hoverProfileWidgetCheck())); + QTimer::singleShot(0, this, &ProfileInterface::hoverProfileWidgetCheck); } else { QMenu editMenu(SnapmaticWidget::tr("Edi&t"), sgdWidget); - editMenu.addAction(QApplication::translate("UserInterface", "&Qualify as Avatar"), this, SLOT(massToolQualify()), QKeySequence::fromString("Shift+Q")); - editMenu.addAction(QApplication::translate("UserInterface", "Change &Players..."), this, SLOT(massToolPlayers()), QKeySequence::fromString("Shift+P")); - editMenu.addAction(QApplication::translate("UserInterface", "Change &Crew..."), this, SLOT(massToolCrew()), QKeySequence::fromString("Shift+C")); - editMenu.addAction(QApplication::translate("UserInterface", "Change &Title..."), this, SLOT(massToolTitle()), QKeySequence::fromString("Shift+T")); + QAction *action = editMenu.addAction(QApplication::translate("UserInterface", "&Qualify as Avatar"), this, &ProfileInterface::massToolQualify); + action->setShortcut(QKeySequence::fromString("Shift+Q")); + action = editMenu.addAction(QApplication::translate("UserInterface", "Change &Players..."), this, &ProfileInterface::massToolPlayers); + action->setShortcut(QKeySequence::fromString("Shift+P")); + action = editMenu.addAction(QApplication::translate("UserInterface", "Change &Crew..."), this, &ProfileInterface::massToolCrew); + action->setShortcut(QKeySequence::fromString("Shift+C")); + action = editMenu.addAction(QApplication::translate("UserInterface", "Change &Title..."), this, &ProfileInterface::massToolTitle); + action->setShortcut(QKeySequence::fromString("Shift+T")); editMenu.addSeparator(); - editMenu.addAction(SnapmaticWidget::tr("Show &In-game"), this, SLOT(enableSelected()), QKeySequence::fromString("Shift+E")); - editMenu.addAction(SnapmaticWidget::tr("Hide &In-game"), this, SLOT(disableSelected()), QKeySequence::fromString("Shift+D")); + action = editMenu.addAction(SnapmaticWidget::tr("Show &In-game"), this, &ProfileInterface::enableSelected); + action->setShortcut(QKeySequence::fromString("Shift+E")); + action = editMenu.addAction(SnapmaticWidget::tr("Hide &In-game"), this, &ProfileInterface::disableSelected); + action->setShortcut(QKeySequence::fromString("Shift+D")); contextMenu.addMenu(&editMenu); - contextMenu.addAction(SavegameWidget::tr("&Export"), this, SLOT(exportSelected()), QKeySequence::fromString("Ctrl+E")); - contextMenu.addAction(SavegameWidget::tr("&Remove"), this, SLOT(deleteSelectedR()), QKeySequence::fromString("Ctrl+Del")); + action = contextMenu.addAction(SavegameWidget::tr("&Export"), this, &ProfileInterface::exportSelected); + action->setShortcut(QKeySequence::fromString("Ctrl+E")); + action = contextMenu.addAction(SavegameWidget::tr("&Remove"), this, &ProfileInterface::deleteSelectedR); + action->setShortcut(QKeySequence::fromString("Ctrl+Del")); contextMenu.addSeparator(); if (!sgdWidget->isSelected()) - contextMenu.addAction(SavegameWidget::tr("&Select"), sgdWidget, SLOT(savegameSelected())); + contextMenu.addAction(SavegameWidget::tr("&Select"), sgdWidget, &SavegameWidget::savegameSelected); else { - contextMenu.addAction(SavegameWidget::tr("&Deselect"), sgdWidget, SLOT(savegameSelected())); + contextMenu.addAction(SavegameWidget::tr("&Deselect"), sgdWidget, &SavegameWidget::savegameSelected); } if (selectedCount != widgets.count()) { - contextMenu.addAction(SavegameWidget::tr("Select &All"), sgdWidget, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A")); + action = contextMenu.addAction(SavegameWidget::tr("Select &All"), sgdWidget, &SavegameWidget::selectAllWidgets); + action->setShortcut(QKeySequence::fromString("Ctrl+A")); } if (selectedCount != 0) { - contextMenu.addAction(SavegameWidget::tr("&Deselect All"), sgdWidget, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); + action = contextMenu.addAction(SavegameWidget::tr("&Deselect All"), sgdWidget, &SavegameWidget::deselectAllWidgets); + action->setShortcut(QKeySequence::fromString("Ctrl+D")); } contextMenuOpened = true; contextMenu.exec(ev->globalPos()); contextMenuOpened = false; - QTimer::singleShot(0, this, SLOT(hoverProfileWidgetCheck())); + QTimer::singleShot(0, this, &ProfileInterface::hoverProfileWidgetCheck); } } diff --git a/src/ProfileLoader.cpp b/src/ProfileLoader.cpp index a4e4318..8d4fadc 100644 --- a/src/ProfileLoader.cpp +++ b/src/ProfileLoader.cpp @@ -20,7 +20,6 @@ #include "ProfileLoader.h" #include "SavegameData.h" #include "CrewDatabase.h" -#include "wrapper.h" #include #include #include @@ -29,9 +28,9 @@ #include #include #else -#include "sys/types.h" -#include "sys/stat.h" -#include "dirent.h" +#include +#include +#include #endif ProfileLoader::ProfileLoader(QString profileFolder, CrewDatabase *crewDB, QObject *parent) : QThread(parent), profileFolder(profileFolder), crewDB(crewDB) diff --git a/src/SavegameWidget.h b/src/SavegameWidget.h index 103fa55..b3a7dea 100644 --- a/src/SavegameWidget.h +++ b/src/SavegameWidget.h @@ -1,6 +1,6 @@ /***************************************************************************** * gta5view Grand Theft Auto V Profile Viewer -* Copyright (C) 2016-2017 Syping +* Copyright (C) 2016-2023 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 @@ -44,15 +44,17 @@ public: void retranslate(); ~SavegameWidget(); -private slots: +public slots: void on_cmdView_clicked(); void on_cmdCopy_clicked(); void on_cmdDelete_clicked(); - void on_cbSelected_stateChanged(int arg1); void savegameSelected(); void selectAllWidgets(); void deselectAllWidgets(); +private slots: + void on_cbSelected_stateChanged(int arg1); + protected: void mouseDoubleClickEvent(QMouseEvent *ev); void mouseReleaseEvent(QMouseEvent *ev); diff --git a/src/SnapmaticEditor.cpp b/src/SnapmaticEditor.cpp index 3ce3f4c..3cbff56 100644 --- a/src/SnapmaticEditor.cpp +++ b/src/SnapmaticEditor.cpp @@ -21,7 +21,6 @@ #include "SnapmaticPicture.h" #include "PlayerListDialog.h" #include "StringParser.h" -#include "wrapper.h" #include "AppEnv.h" #include "config.h" #include @@ -42,11 +41,7 @@ SnapmaticEditor::SnapmaticEditor(CrewDatabase *crewDB, ProfileDatabase *profileD ui(new Ui::SnapmaticEditor) { // Set Window Flags -#if QT_VERSION >= 0x050900 setWindowFlag(Qt::WindowContextHelpButtonHint, false); -#else - setWindowFlags(windowFlags()^Qt::WindowContextHelpButtonHint); -#endif ui->setupUi(this); ui->cmdCancel->setDefault(true); @@ -236,7 +231,7 @@ void SnapmaticEditor::setSnapmaticTitle(const QString &title) snapmaticTitle = title; } QString editStr = QString("%1").arg(tr("Edit")); - QString titleStr = tr("Title: %1 (%2)").arg(StringParser::escapeString(snapmaticTitle), editStr); + QString titleStr = tr("Title: %1 (%2)").arg(snapmaticTitle.toHtmlEscaped(), editStr); ui->labTitle->setText(titleStr); if (SnapmaticPicture::verifyTitle(snapmaticTitle)) { ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("%1").arg(tr("Yes", "Yes, should work fine")))); @@ -244,25 +239,21 @@ void SnapmaticEditor::setSnapmaticTitle(const QString &title) else { ui->labAppropriate->setText(tr("Appropriate: %1").arg(QString("%1").arg(tr("No", "No, could lead to issues")))); } -#ifndef Q_OS_ANDROID ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width())); ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width())); if (heightForWidth(width()) > height()) resize(width(), heightForWidth(width())); -#endif } void SnapmaticEditor::setSnapmaticCrew(const QString &crew) { QString editStr = QString("%1").arg(tr("Edit")); - QString crewStr = tr("Crew: %1 (%2)").arg(StringParser::escapeString(crew), editStr); + QString crewStr = tr("Crew: %1 (%2)").arg(crew.toHtmlEscaped(), editStr); ui->labCrew->setText(crewStr); -#ifndef Q_OS_ANDROID ui->gbValues->resize(ui->gbValues->width(), ui->gbValues->heightForWidth(ui->gbValues->width())); ui->frameWidget->resize(ui->gbValues->width(), ui->frameWidget->heightForWidth(ui->frameWidget->width())); if (heightForWidth(width()) > height()) resize(width(), heightForWidth(width())); -#endif } QString SnapmaticEditor::returnCrewName(int crewID_) diff --git a/src/SnapmaticWidget.h b/src/SnapmaticWidget.h index 8c28f12..80cbcdc 100644 --- a/src/SnapmaticWidget.h +++ b/src/SnapmaticWidget.h @@ -1,6 +1,6 @@ /***************************************************************************** * gta5view Grand Theft Auto V Profile Viewer -* Copyright (C) 2016-2017 Syping +* Copyright (C) 2016-2023 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 @@ -53,24 +53,26 @@ public: void retranslate(); ~SnapmaticWidget(); -private slots: +public slots: void on_cmdView_clicked(); void on_cmdCopy_clicked(); void on_cmdExport_clicked(); void on_cmdDelete_clicked(); - void on_cbSelected_stateChanged(int arg1); - void adjustTextColor(); void pictureSelected(); void selectAllWidgets(); void deselectAllWidgets(); - void dialogNextPictureRequested(); - void dialogPreviousPictureRequested(); void makePictureVisibleSlot(); void makePictureHiddenSlot(); void editSnapmaticProperties(); void editSnapmaticRawJson(); void editSnapmaticImage(); void openMapViewer(); + +private slots: + void on_cbSelected_stateChanged(int arg1); + void adjustTextColor(); + void dialogNextPictureRequested(); + void dialogPreviousPictureRequested(); void snapmaticUpdated(); void customSignal(QString signal); diff --git a/src/StringParser.cpp b/src/StringParser.cpp index 4ac3fba..4c9d2b9 100644 --- a/src/StringParser.cpp +++ b/src/StringParser.cpp @@ -27,15 +27,6 @@ #include #include -QString StringParser::escapeString(const QString &toEscape) -{ -#if QT_VERSION >= 0x050000 - return toEscape.toHtmlEscaped(); -#else - return Qt::escape(toEscape); -#endif -} - QString StringParser::convertBuildedString(const QString &buildedStr) { QString outputStr = buildedStr; diff --git a/src/StringParser.h b/src/StringParser.h index 7dac436..4cf25a9 100644 --- a/src/StringParser.h +++ b/src/StringParser.h @@ -25,7 +25,6 @@ class StringParser { public: - static QString escapeString(const QString &toEscape); static QString convertBuildedString(const QString &buildedStr); }; diff --git a/src/UserInterface.cpp b/src/UserInterface.cpp index e65b852..8ec369d 100644 --- a/src/UserInterface.cpp +++ b/src/UserInterface.cpp @@ -305,9 +305,7 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D // DPI calculation qreal screenRatio = AppEnv::screenRatio(); -#ifndef Q_QS_ANDROID resize(625 * screenRatio, 500 * screenRatio); -#endif ui->vlUserInterface->setSpacing(6 * screenRatio); ui->vlUserInterface->setContentsMargins(9 * screenRatio, 9 * screenRatio, 9 * screenRatio, 9 * screenRatio); } @@ -496,12 +494,7 @@ void UserInterface::on_actionAbout_gta5sync_triggered() AboutDialog *aboutDialog = new AboutDialog(this); aboutDialog->setWindowIcon(windowIcon()); aboutDialog->setModal(true); -#ifdef Q_OS_ANDROID - // Android ... - aboutDialog->showMaximized(); -#else aboutDialog->show(); -#endif aboutDialog->exec(); delete aboutDialog; } @@ -544,12 +537,7 @@ void UserInterface::on_actionOptions_triggered() QObject::connect(optionsDialog, SIGNAL(settingsApplied(int, bool)), this, SLOT(settingsApplied(int, bool))); optionsDialog->setModal(true); -#ifdef Q_OS_ANDROID - // Android ... - optionsDialog->showMaximized(); -#else optionsDialog->show(); -#endif optionsDialog->exec(); delete optionsDialog; @@ -606,7 +594,7 @@ bool UserInterface::openFile(QString selectedFile, bool warn) { QString selectedFileName = QFileInfo(selectedFile).fileName(); if (QFile::exists(selectedFile)) { - if (selectedFileName.left(4) == "PGTA" || selectedFileName.right(4) == ".g5e") { + if (selectedFileName.startsWith("PGTA5") || selectedFileName.startsWith("PRDR3") || selectedFileName.endsWith(".g5e")) { SnapmaticPicture *picture = new SnapmaticPicture(selectedFile); if (picture->readingPicture()) { openSnapmaticFile(picture); @@ -676,14 +664,9 @@ void UserInterface::openSnapmaticFile(SnapmaticPicture *picture) QObject::connect(threadDB, SIGNAL(crewNameUpdated()), &picDialog, SLOT(crewNameUpdated())); QObject::connect(threadDB, SIGNAL(playerNameUpdated()), &picDialog, SLOT(playerNameUpdated())); -#ifdef Q_OS_ANDROID - // Android optimization should be put here - picDialog.showMaximized(); -#else picDialog.show(); picDialog.setMinimumSize(picDialog.size()); picDialog.setMaximumSize(picDialog.size()); -#endif picDialog.exec(); } @@ -693,12 +676,7 @@ void UserInterface::openSavegameFile(SavegameData *savegame) SavegameDialog sgdDialog(this); sgdDialog.setSavegameData(savegame, savegame->getSavegameFileName(), true); sgdDialog.setModal(true); -#ifdef Q_OS_ANDROID - // Android optimization should be put here - sgdDialog.showMaximized(); -#else sgdDialog.show(); -#endif sgdDialog.exec(); } diff --git a/src/wrapper.h b/src/wrapper.h deleted file mode 100644 index 9ea0443..0000000 --- a/src/wrapper.h +++ /dev/null @@ -1,30 +0,0 @@ -/***************************************************************************** -* gta5view Grand Theft Auto V Profile Viewer -* Copyright (C) 2021 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 . -*****************************************************************************/ - -#ifndef WRAPPER_H -#define WRAPPER_H - -#if QT_VERSION < 0x050700 -#if __cplusplus > 201703L -#define qAsConst(x) std::as_const(x) -#else -#define qAsConst -#endif -#endif - -#endif // WRAPPER_H