diff --git a/AppEnv.cpp b/AppEnv.cpp index d3abbb8..ece650d 100644 --- a/AppEnv.cpp +++ b/AppEnv.cpp @@ -153,7 +153,7 @@ QString AppEnv::getPluginsFolder() QByteArray AppEnv::getUserAgent() { #if QT_VERSION >= 0x050400 -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN QString kernelVersion = QSysInfo::kernelVersion(); const QStringList &kernelVersionList = kernelVersion.split("."); if (kernelVersionList.length() > 2) @@ -210,7 +210,7 @@ QUrl AppEnv::getPlayerFetchingUrl(QString crewID, int pageNumber) GameVersion AppEnv::getGameVersion() { -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN QString argumentValue; #ifdef _WIN64 argumentValue = "\\WOW6432Node"; @@ -268,7 +268,7 @@ GameLanguage AppEnv::getGameLanguage(GameVersion gameVersion) { if (gameVersion == GameVersion::SocialClubVersion) { -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN QString argumentValue; #ifdef _WIN64 argumentValue = "\\WOW6432Node"; @@ -282,7 +282,7 @@ GameLanguage AppEnv::getGameLanguage(GameVersion gameVersion) } else if (gameVersion == GameVersion::SteamVersion) { -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN QString argumentValue; #ifdef _WIN64 argumentValue = "\\WOW6432Node"; @@ -443,7 +443,7 @@ bool AppEnv::setGameLanguage(GameVersion gameVersion, GameLanguage gameLanguage) } if (socialClubVersion) { -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN QString argumentValue; #ifdef _WIN64 argumentValue = "\\WOW6432Node"; @@ -468,7 +468,7 @@ bool AppEnv::setGameLanguage(GameVersion gameVersion, GameLanguage gameLanguage) } if (steamVersion) { -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN QString argumentValue; #ifdef _WIN64 argumentValue = "\\WOW6432Node"; diff --git a/CMakeLists.txt b/CMakeLists.txt index 97d4837..3232024 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt5 COMPONENTS Network Svg Widgets REQUIRED) find_package(Qt5 COMPONENTS LinguistTools QUIET) +if(WIN32) + find_package(Qt5 COMPONENTS WinExtras REQUIRED) + list(APPEND GTA5VIEW_EXTRALIBS + Qt5::WinExtras + ) +endif() + set(GTA5VIEW_SOURCES main.cpp AboutDialog.cpp @@ -122,7 +129,7 @@ set(GTA5VIEW_FORMS set(GTA5VIEW_DEFINES -DGTA5SYNC_CMAKE -DGTA5SYNC_PROJECT - -DGTA5SYNC_NOASSIST + -DSNAPMATIC_NODEFAULT ) set(GTA5VIEW_RESOURCES @@ -224,6 +231,11 @@ if(WITH_TELEMETRY) "-DGTA5SYNC_TELEMETRY_WEBURL=\"${TELEMETRY_WEBURL}\"" ) endif() + if(WIN32) + list(APPEND GTA5VIEW_EXTRALIBS + d3d9 + ) + endif() endif() if(GTA5VIEW_APPVER) @@ -279,6 +291,7 @@ if(GTA5VIEW_COMMIT) endif() add_executable(gta5view + WIN32 MACOSX_BUNDLE ${GTA5VIEW_HEADERS} ${GTA5VIEW_SOURCES} ${GTA5VIEW_FORMS} @@ -293,9 +306,13 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.16.0") target_precompile_headers(gta5view PRIVATE config.h) endif() +if(Qt5Core_VERSION VERSION_GREATER_EQUAL "5.14.0") + qt5_import_plugins(gta5view INCLUDE Qt5::QSvgPlugin) +endif() + target_compile_definitions(gta5view PRIVATE ${GTA5VIEW_DEFINES}) target_include_directories(gta5view PRIVATE ${GTA5VIEW_INCLUDEDIR}) -target_link_libraries(gta5view PRIVATE Qt5::Network Qt5::Svg Qt5::Widgets) +target_link_libraries(gta5view PRIVATE Qt5::Network Qt5::Svg Qt5::Widgets ${GTA5VIEW_EXTRALIBS}) install(TARGETS gta5view DESTINATION bin) install(FILES res/de.syping.gta5view.desktop DESTINATION share/applications) diff --git a/MapLocationDialog.cpp b/MapLocationDialog.cpp index 142083a..7c63b74 100644 --- a/MapLocationDialog.cpp +++ b/MapLocationDialog.cpp @@ -133,7 +133,7 @@ void MapLocationDialog::paintEvent(QPaintEvent *ev) long xpos_pr; long ypos_pr; if (screenRatioPR != 1) { -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN xpos_pr = xpos_mp - pointMarkerHalfSize; ypos_pr = ypos_mp + pointMarkerHalfSize; #else diff --git a/OptionsDialog.cpp b/OptionsDialog.cpp index 507df97..45d6942 100644 --- a/OptionsDialog.cpp +++ b/OptionsDialog.cpp @@ -174,7 +174,7 @@ void OptionsDialog::setupLanguageBox() QString cbSysStr = tr("%1 (Language priority)", "First language a person can talk with a different person/application. \"Native\" or \"Not Native\".").arg(tr("System", "System in context of System default")); -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN QString cbAutoStr; if (AppEnv::getGameLanguage(AppEnv::getGameVersion()) != GameLanguage::Undefined) { @@ -301,7 +301,7 @@ void OptionsDialog::setupInterfaceSettings() settings->beginGroup("Startup"); bool alwaysUseMessageFont = settings->value("AlwaysUseMessageFont", false).toBool(); ui->cbAlwaysUseMessageFont->setChecked(alwaysUseMessageFont); -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN if (QSysInfo::windowsVersion() >= 0x0080) { ui->gbFont->setVisible(false); @@ -367,7 +367,7 @@ void OptionsDialog::applySettings() settings->setValue("Language", ui->cbLanguage->itemData(ui->cbLanguage->currentIndex())); settings->setValue("AreaLanguage", ui->cbAreaLanguage->itemData(ui->cbAreaLanguage->currentIndex())); #endif -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN #if QT_VERSION >= 0x050200 settings->setValue("NavigationBar", ui->cbSnapmaticNavigationBar->isChecked()); #endif @@ -626,7 +626,7 @@ void OptionsDialog::setupWindowsGameSettings() { #ifdef GTA5SYNC_GAME GameVersion gameVersion = AppEnv::getGameVersion(); -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN if (gameVersion != GameVersion::NoVersion) { if (gameVersion == GameVersion::SocialClubVersion) @@ -723,7 +723,7 @@ void OptionsDialog::setupCustomGTAFolder() void OptionsDialog::setupSnapmaticPictureViewer() { -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN #if QT_VERSION >= 0x050200 settings->beginGroup("Interface"); ui->cbSnapmaticNavigationBar->setChecked(settings->value("NavigationBar", true).toBool()); diff --git a/PictureDialog.cpp b/PictureDialog.cpp index 0462efe..8597ebe 100644 --- a/PictureDialog.cpp +++ b/PictureDialog.cpp @@ -33,7 +33,7 @@ #include "AppEnv.h" #include "config.h" -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN #if QT_VERSION >= 0x050200 #include #include @@ -207,7 +207,7 @@ void PictureDialog::setupPictureDialog() PictureDialog::~PictureDialog() { -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN #if QT_VERSION >= 0x050200 if (naviEnabled) { @@ -247,7 +247,7 @@ void PictureDialog::closeEvent(QCloseEvent *ev) void PictureDialog::addPreviousNextButtons() { -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN #if QT_VERSION >= 0x050200 QToolBar *uiToolbar = new QToolBar("Picture Toolbar", this); uiToolbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); @@ -275,120 +275,6 @@ void PictureDialog::addPreviousNextButtons() #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(message); - LRESULT lRet = 0; - - if (naviEnabled && QtWin::isCompositionEnabled()) - { - if (msg->message == WM_NCCALCSIZE && msg->wParam == TRUE) - { - NCCALCSIZE_PARAMS *pncsp = reinterpret_cast(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() / AppEnv::screenRatioPR()); - // 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) @@ -409,7 +295,7 @@ void PictureDialog::adaptNewDialogSize(QSize newLabelSize) void PictureDialog::styliseDialog() { -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN #if QT_VERSION >= 0x050200 if (QtWin::isCompositionEnabled()) { @@ -431,7 +317,7 @@ void PictureDialog::styliseDialog() bool PictureDialog::event(QEvent *event) { -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN #if QT_VERSION >= 0x050200 if (naviEnabled) { @@ -516,7 +402,7 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev) break; } } -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN #if QT_VERSION >= 0x050200 if (obj != ui->labPicture && naviEnabled) { @@ -812,7 +698,7 @@ QString PictureDialog::generatePlayersString() QString plyrsStr; if (playersList.length() >= 1) { - for (const QString player : playersList) + for (const QString &player : playersList) { const QString playerName = profileDB->getPlayerName(player); if (player != playerName) { @@ -863,9 +749,9 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button) PictureWidget *pictureWidget = new PictureWidget(this); // Work! pictureWidget->setObjectName("PictureWidget"); #if QT_VERSION >= 0x050600 - pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint^Qt::WindowStaysOnTopHint^Qt::MaximizeUsingFullscreenGeometryHint); + pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint^Qt::MaximizeUsingFullscreenGeometryHint); #else - pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint^Qt::WindowStaysOnTopHint); + pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::FramelessWindowHint); #endif pictureWidget->setWindowTitle(windowTitle()); pictureWidget->setStyleSheet("QLabel#pictureLabel{background-color: black;}"); @@ -879,7 +765,7 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button) pictureWidget->move(desktopRect.x(), desktopRect.y()); pictureWidget->resize(desktopRect.width(), desktopRect.height()); -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN #if QT_VERSION >= 0x050200 QtWin::markFullscreenWindow(pictureWidget, true); #endif diff --git a/PictureDialog.h b/PictureDialog.h index b0be786..a24299b 100644 --- a/PictureDialog.h +++ b/PictureDialog.h @@ -29,14 +29,6 @@ #include #include -#ifdef GTA5SYNC_WIN -#if QT_VERSION >= 0x050200 -#ifdef GTA5SYNC_APV -#include -#endif -#endif -#endif - namespace Ui { class PictureDialog; } @@ -98,15 +90,6 @@ 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(); @@ -136,7 +119,7 @@ private: int avatarLocY; int avatarSize; QMenu *manageMenu; -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN #if QT_VERSION >= 0x050200 QPoint dragPosition; bool dragStart; diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index 94d83f2..7daed3c 100644 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -1325,7 +1325,7 @@ void ProfileInterface::exportSelected() QString ExportPreSpan; QString ExportPostSpan; -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN ExportPreSpan = ""; ExportPostSpan = ""; #else diff --git a/SnapmaticPicture.cpp b/SnapmaticPicture.cpp index b57e223..795f66f 100644 --- a/SnapmaticPicture.cpp +++ b/SnapmaticPicture.cpp @@ -106,7 +106,7 @@ void SnapmaticPicture::reset() jsonStr = QString(); // SNAPMATIC DEFAULTS -#ifdef GTA5SYNC_NOASSIST +#ifdef SNAPMATIC_NODEFAULT careSnapDefault = false; #else careSnapDefault = true; diff --git a/TelemetryClass.cpp b/TelemetryClass.cpp index eba6390..724e0c3 100644 --- a/TelemetryClass.cpp +++ b/TelemetryClass.cpp @@ -41,7 +41,7 @@ #define GTA5SYNC_TELEMETRY_WEBURL "" #endif -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN #include "windows.h" #include "intrin.h" #include "d3d9.h" @@ -228,7 +228,7 @@ QJsonDocument TelemetryClass::getSystemHardware() { QJsonDocument jsonDocument; QJsonObject jsonObject; -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN { int CPUInfo[4] = {-1}; unsigned nExIds, ic = 0; diff --git a/config.h b/config.h index 3a99c62..8402d44 100644 --- a/config.h +++ b/config.h @@ -121,10 +121,6 @@ #define GTA5SYNC_PLUG "RUNDIR:SEPARATOR:plugins" #endif -#ifdef GTA5SYNC_WINRT -#undef GTA5SYNC_WIN -#endif - #ifndef GTA5SYNC_COMPILER #ifdef __clang__ #ifndef Q_OS_MAC diff --git a/gta5view.pro b/gta5view.pro index 7761343..96f050d 100644 --- a/gta5view.pro +++ b/gta5view.pro @@ -175,15 +175,12 @@ INCLUDEPATH += ./anpro ./pcg ./tmext ./uimod DEFINES += GTA5SYNC_QMAKE # We using qmake do we? DEFINES += GTA5SYNC_PROJECT # Enable exclusive gta5sync/gta5view functions -DEFINES += GTA5SYNC_NOASSIST # Not assisting at proper usage of SnapmaticPicture class +DEFINES += SNAPMATIC_NODEFAULT # Not assisting at proper usage of SnapmaticPicture class # WINDOWS ONLY -win32: DEFINES += GTA5SYNC_WIN win32: RC_FILE += res/app.rc -win32: LIBS += -luser32 win32: CONFIG -= embed_manifest_exe -contains(DEFINES, GTA5SYNC_APV): greaterThan(QT_MAJOR_VERSION, 4): greaterThan(QT_MINOR_VERSION, 1): win32: LIBS += -ldwmapi contains(DEFINES, GTA5SYNC_TELEMETRY): win32: LIBS += -ld3d9 # Required for getting information about GPU # MAC OS X ONLY @@ -272,6 +269,6 @@ contains(DEFINES, GTA5SYNC_QCONF) { # CMAKE BASED STUFF -unix: greaterThan(QT_MAJOR_VERSION, 4) { - message("Building non-Windows gta5view with QMake is deprecated, please use CMake instead!") +greaterThan(QT_MAJOR_VERSION, 4) { + message("Building gta5view with QMake is deprecated, please use CMake instead!") } diff --git a/main.cpp b/main.cpp index 870a1bb..ce0035a 100644 --- a/main.cpp +++ b/main.cpp @@ -54,7 +54,7 @@ #include #include -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN #include "windows.h" #include #endif @@ -101,25 +101,12 @@ int main(int argc, char *argv[]) } } -#ifdef GTA5SYNC_WIN +#ifdef Q_OS_WIN #if QT_VERSION >= 0x050400 bool alwaysUseMessageFont = settings.value("AlwaysUseMessageFont", false).toBool(); if (QSysInfo::windowsVersion() >= 0x0080 || alwaysUseMessageFont) { - // Get Windows Font - NONCLIENTMETRICS ncm; - ncm.cbSize = sizeof(ncm); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0); - LOGFONTW uiFont = ncm.lfMessageFont; - QString uiFontStr(QString::fromStdWString(std::wstring(uiFont.lfFaceName))); - -#ifdef GTA5SYNC_DEBUG - qDebug() << QApplication::tr("Font") << QApplication::tr("Selected Font: %1").arg(uiFontStr); -#endif - - // Set Application Font - QFont appFont(uiFontStr, 9); - a.setFont(appFont); + a.setFont(QApplication::font("QMenu")); } #endif #endif