diff --git a/.ci/app.rc b/.ci/app.rc index ec976d2..92f6518 100644 --- a/.ci/app.rc +++ b/.ci/app.rc @@ -24,7 +24,7 @@ BEGIN VALUE "FileDescription", "gta5view" VALUE "FileVersion", "MAJOR_VER.MINOR_VER.PATCH_VERSTR_BUILD_VER" VALUE "InternalName", "gta5view" - VALUE "LegalCopyright", "Copyright © 2016-2020 Syping" + VALUE "LegalCopyright", "Copyright © 2016-2021 Syping" VALUE "OriginalFilename", "gta5view.exe" VALUE "ProductName", "gta5view" VALUE "ProductVersion", "MAJOR_VER.MINOR_VER.PATCH_VERSTR_BUILD_VER" diff --git a/.ci/gta5view.nsi b/.ci/gta5view.nsi index 2049d43..ef7e4be 100644 --- a/.ci/gta5view.nsi +++ b/.ci/gta5view.nsi @@ -113,7 +113,6 @@ File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Gui.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Network.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Svg.dll" File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5Widgets.dll" -File "/usr/local/lib/x86_64-w64-mingw32/qt5/bin/Qt5WinExtras.dll" SetOutPath "$INSTDIR\lang" File "../build/gta5sync_en_US.qm" File "../build/gta5sync_de.qm" @@ -203,7 +202,6 @@ Delete "$INSTDIR\Qt5Gui.dll" Delete "$INSTDIR\Qt5Network.dll" Delete "$INSTDIR\Qt5Svg.dll" Delete "$INSTDIR\Qt5Widgets.dll" -Delete "$INSTDIR\Qt5WinExtras.dll" Delete "$INSTDIR\lang\gta5sync_en_US.qm" Delete "$INSTDIR\lang\gta5sync_de.qm" Delete "$INSTDIR\lang\gta5sync_fr.qm" diff --git a/CMakeLists.txt b/CMakeLists.txt index e16c70c..e8e4219 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,9 +21,8 @@ find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Network Svg Widgets REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS LinguistTools QUIET) if(WIN32) - find_package(Qt${QT_VERSION_MAJOR} COMPONENTS WinExtras REQUIRED) list(APPEND GTA5VIEW_LIBS - Qt${QT_VERSION_MAJOR}::WinExtras + dwmapi ) list(APPEND GTA5VIEW_DEFINES -DUNICODE @@ -40,9 +39,9 @@ if(APPLE) ) set(MACOSX_BUNDLE_BUNDLE_NAME gta5view) set(MACOSX_BUNDLE_BUNDLE_VERSION 1.10.0) - set(MACOSX_BUNDLE_ICON_FILE 5sync.icns) + set(MACOSX_BUNDLE_ICON_FILE gta5view.icns) set(MACOSX_BUNDLE_GUI_IDENTIFIER de.syping.gta5view) - set_source_files_properties(res/5sync.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") + set_source_files_properties(res/gta5view.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") endif() list(APPEND GTA5VIEW_DEFINES diff --git a/PictureDialog.cpp b/PictureDialog.cpp index 6ae3323..40c30c0 100644 --- a/PictureDialog.cpp +++ b/PictureDialog.cpp @@ -38,10 +38,7 @@ #endif #ifdef Q_OS_WIN -#if QT_VERSION >= 0x050200 -#include -#include -#endif +#include "dwmapi.h" #endif #ifdef Q_OS_MAC @@ -258,36 +255,55 @@ void PictureDialog::adaptDialogSize() void PictureDialog::styliseDialog() { #ifdef Q_OS_WIN -#if QT_VERSION >= 0x050200 - if (QtWin::isCompositionEnabled()) { - QPalette palette; - QtWin::extendFrameIntoClientArea(this, 0, qRound(layout()->menuBar()->height() * AppEnv::screenRatioPR()), 0, 0); - ui->jsonFrame->setStyleSheet(QString("QFrame{background:%1;}").arg(palette.window().color().name())); - setStyleSheet("PictureDialog{background:transparent;}"); + BOOL isEnabled; + DwmIsCompositionEnabled(&isEnabled); + if (isEnabled == TRUE) { + MARGINS margins = {0, 0, qRound(layout()->menuBar()->height() * AppEnv::screenRatioPR()), 0}; + HRESULT hr = S_OK; + hr = DwmExtendFrameIntoClientArea(reinterpret_cast(winId()), &margins); + if (SUCCEEDED(hr)) { + setStyleSheet("PictureDialog{background:transparent}"); + } } else { - QPalette palette; - QtWin::resetExtendedFrame(this); - ui->jsonFrame->setStyleSheet(QString("QFrame{background:%1;}").arg(palette.window().color().name())); - setStyleSheet(QString("PictureDialog{background:%1;}").arg(QtWin::realColorizationColor().name())); + MARGINS margins = {0, 0, 0, 0}; + DwmExtendFrameIntoClientArea(reinterpret_cast(winId()), &margins); + bool colorOk = false; + QSettings dwmRegistry("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\DWM", QSettings::NativeFormat); + QRgb color = dwmRegistry.value("ColorizationColor").toUInt(&colorOk); + if (colorOk) { + setStyleSheet(QString("PictureDialog{background:%1}").arg(QColor::fromRgba(color).name())); + } + else { + HRESULT hr = S_OK; + BOOL isOpaqueBlend; + DWORD colorization; + hr = DwmGetColorizationColor(&colorization, &isOpaqueBlend); + if (SUCCEEDED(hr) && isOpaqueBlend == FALSE) { + color = colorization; + setStyleSheet(QString("PictureDialog{background:%1}").arg(QColor::fromRgba(color).name())); + } + else { + setStyleSheet("PictureDialog{background:palette(window)}"); + } + } } -#endif + ui->jsonFrame->setStyleSheet("QFrame{background:palette(window)}"); #endif } -bool PictureDialog::event(QEvent *event) -{ #ifdef Q_OS_WIN -#if QT_VERSION >= 0x050200 - if (naviEnabled) { - if (event->type() == QWinEvent::CompositionChange || event->type() == QWinEvent::ColorizationChange) { - styliseDialog(); - } +#if QT_VERSION >= 0x050000 +bool PictureDialog::nativeEvent(const QByteArray &eventType, void *message, long *result) +{ + MSG *msg = reinterpret_cast(message); + if (msg->message == WM_DWMCOMPOSITIONCHANGED || msg->message == WM_DWMCOLORIZATIONCOLORCHANGED) { + styliseDialog(); } -#endif -#endif - return QDialog::event(event); + return QWidget::nativeEvent(eventType, message, result); } +#endif +#endif void PictureDialog::nextPictureRequestedSlot() { @@ -355,7 +371,7 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev) } } #ifdef Q_OS_WIN -#if QT_VERSION >= 0x050200 +#if QT_VERSION >= 0x050000 if (obj != ui->labPicture && naviEnabled) { if (ev->type() == QEvent::MouseButtonPress) { QMouseEvent *mouseEvent = dynamic_cast(ev); @@ -674,11 +690,6 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button) pictureWidget->move(desktopRect.x(), desktopRect.y()); pictureWidget->resize(desktopRect.width(), desktopRect.height()); -#ifdef Q_OS_WIN -#if QT_VERSION >= 0x050200 - QtWin::markFullscreenWindow(pictureWidget, true); -#endif -#endif pictureWidget->showFullScreen(); pictureWidget->setFocus(); pictureWidget->raise(); diff --git a/PictureDialog.h b/PictureDialog.h index 3e81915..f51c534 100644 --- a/PictureDialog.h +++ b/PictureDialog.h @@ -89,7 +89,11 @@ protected: void closeEvent(QCloseEvent *ev); bool eventFilter(QObject *obj, QEvent *ev); void mousePressEvent(QMouseEvent *ev); - bool event(QEvent *event); +#ifdef Q_OS_WIN +#if QT_VERSION >= 0x050000 + bool nativeEvent(const QByteArray &eventType, void *message, long *result); +#endif +#endif private: QString generateCrewString(); @@ -120,7 +124,7 @@ private: int avatarSize; QMenu *manageMenu; #ifdef Q_OS_WIN -#if QT_VERSION >= 0x050200 +#if QT_VERSION >= 0x050000 QPoint dragPosition; bool dragStart; #endif diff --git a/gta5view.pro b/gta5view.pro index 27c8e84..2191beb 100644 --- a/gta5view.pro +++ b/gta5view.pro @@ -19,7 +19,7 @@ QT += core gui network svg greaterThan(QT_MAJOR_VERSION, 4): QT += widgets -greaterThan(QT_MAJOR_VERSION, 4): greaterThan(QT_MINOR_VERSION, 1): win32: QT += winextras +greaterThan(QT_MAJOR_VERSION, 4): greaterThan(QT_MINOR_VERSION, 1): win32: LIBS += -ldwmapi DEPLOYMENT.display_name = gta5view TARGET = gta5view @@ -186,7 +186,7 @@ win32: CONFIG -= embed_manifest_exe contains(DEFINES, GTA5SYNC_TELEMETRY): win32: LIBS += -ld3d9 # Required for getting information about GPU # MAC OS X ONLY -macx: ICON = res/5sync.icns +macx: ICON = res/gta5view.icns # QT4 ONLY STUFF diff --git a/res/5sync.icns b/res/gta5view.icns similarity index 100% rename from res/5sync.icns rename to res/gta5view.icns