CMake improvements, deprecate QMake for Qt5, GTA5SYNC_WIN -> Q_OS_WIN,
All checks were successful
continuous-integration/drone/push Build is passing

APV removed
This commit is contained in:
Syping 2020-09-26 16:12:55 +02:00
parent 15dfc2c84b
commit 39436a6dbf
12 changed files with 52 additions and 186 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -33,7 +33,7 @@
#include "AppEnv.h"
#include "config.h"
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
#include <QtWinExtras/QtWin>
#include <QtWinExtras/QWinEvent>
@ -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<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() / 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

View file

@ -29,14 +29,6 @@
#include <QEvent>
#include <QMenu>
#ifdef GTA5SYNC_WIN
#if QT_VERSION >= 0x050200
#ifdef GTA5SYNC_APV
#include <dwmapi.h>
#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;

View file

@ -1325,7 +1325,7 @@ void ProfileInterface::exportSelected()
QString ExportPreSpan;
QString ExportPostSpan;
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
ExportPreSpan = "<span style=\"color: #003399; font-size: 12pt\">";
ExportPostSpan = "</span>";
#else

View file

@ -106,7 +106,7 @@ void SnapmaticPicture::reset()
jsonStr = QString();
// SNAPMATIC DEFAULTS
#ifdef GTA5SYNC_NOASSIST
#ifdef SNAPMATIC_NODEFAULT
careSnapDefault = false;
#else
careSnapDefault = true;

View file

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

View file

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

View file

@ -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!")
}

View file

@ -54,7 +54,7 @@
#include <QFont>
#include <QFile>
#ifdef GTA5SYNC_WIN
#ifdef Q_OS_WIN
#include "windows.h"
#include <iostream>
#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