removal and rework of legacy code

This commit is contained in:
Syping 2023-02-09 20:42:05 +01:00
parent a456b06ad3
commit 1528879b42
12 changed files with 115 additions and 177 deletions

View file

@ -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

View file

@ -21,7 +21,6 @@
#include "TranslationClass.h"
#include "StandardPaths.h"
#include "UserInterface.h"
#include "wrapper.h"
#include "AppEnv.h"
#include "config.h"
#include <QStringBuilder>
@ -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<Qt::AspectRatioMode>(settings->value("AspectRatio", Qt::KeepAspectRatio).toInt());
if (aspectRatio == Qt::IgnoreAspectRatio) {
ui->cbIgnoreAspectRatio->setChecked(true);
}

View file

@ -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<QMouseEvent*>(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<QImage>::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)

View file

@ -1632,7 +1632,7 @@ void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev)
SnapmaticWidget *picWidget = qobject_cast<SnapmaticWidget*>(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);
}
}

View file

@ -20,7 +20,6 @@
#include "ProfileLoader.h"
#include "SavegameData.h"
#include "CrewDatabase.h"
#include "wrapper.h"
#include <QStringBuilder>
#include <QVector>
#include <QString>
@ -29,9 +28,9 @@
#include <QDir>
#include <QList>
#else
#include "sys/types.h"
#include "sys/stat.h"
#include "dirent.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#endif
ProfileLoader::ProfileLoader(QString profileFolder, CrewDatabase *crewDB, QObject *parent) : QThread(parent), profileFolder(profileFolder), crewDB(crewDB)

View file

@ -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);

View file

@ -21,7 +21,6 @@
#include "SnapmaticPicture.h"
#include "PlayerListDialog.h"
#include "StringParser.h"
#include "wrapper.h"
#include "AppEnv.h"
#include "config.h"
#include <QStringBuilder>
@ -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("<a href=\"g5e://edittitle\" style=\"text-decoration: none;\">%1</a>").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("<span style=\"color: green\">%1</span>").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("<span style=\"color: red\">%1</span>").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("<a href=\"g5e://editcrew\" style=\"text-decoration: none;\">%1</a>").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_)

View file

@ -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);

View file

@ -27,15 +27,6 @@
#include <QList>
#include <QDir>
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;

View file

@ -25,7 +25,6 @@
class StringParser
{
public:
static QString escapeString(const QString &toEscape);
static QString convertBuildedString(const QString &buildedStr);
};

View file

@ -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();
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#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