Improve DWM code, remove WinExtras dependency
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Syping 2021-02-11 20:20:52 +01:00
parent c1b0053ac8
commit dd9c4a7f16
7 changed files with 54 additions and 42 deletions

View File

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

View File

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

View File

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

View File

@ -38,10 +38,7 @@
#endif
#ifdef Q_OS_WIN
#if QT_VERSION >= 0x050200
#include <QtWinExtras/QtWin>
#include <QtWinExtras/QWinEvent>
#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<HWND>(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<HWND>(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<MSG*>(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<QMouseEvent*>(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();

View File

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

View File

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