mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
DolphinQt: Add function to set a QWidget's window decorations to dark ones on Windows.
This commit is contained in:
parent
adbe56ce15
commit
e8d23af0f2
@ -294,6 +294,8 @@ add_executable(dolphin-emu
|
|||||||
QtUtils/ParallelProgressDialog.h
|
QtUtils/ParallelProgressDialog.h
|
||||||
QtUtils/PartiallyClosableTabWidget.cpp
|
QtUtils/PartiallyClosableTabWidget.cpp
|
||||||
QtUtils/PartiallyClosableTabWidget.h
|
QtUtils/PartiallyClosableTabWidget.h
|
||||||
|
QtUtils/SetWindowDecorations.cpp
|
||||||
|
QtUtils/SetWindowDecorations.h
|
||||||
QtUtils/SignalBlocking.h
|
QtUtils/SignalBlocking.h
|
||||||
QtUtils/UTF8CodePointCountValidator.cpp
|
QtUtils/UTF8CodePointCountValidator.cpp
|
||||||
QtUtils/UTF8CodePointCountValidator.h
|
QtUtils/UTF8CodePointCountValidator.h
|
||||||
@ -403,6 +405,7 @@ if (WIN32)
|
|||||||
PRIVATE
|
PRIVATE
|
||||||
gdi32.lib
|
gdi32.lib
|
||||||
shell32.lib
|
shell32.lib
|
||||||
|
dwmapi.lib # Needed to set window decorations for dark theme
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -188,6 +188,7 @@
|
|||||||
<ClCompile Include="QtUtils\ModalMessageBox.cpp" />
|
<ClCompile Include="QtUtils\ModalMessageBox.cpp" />
|
||||||
<ClCompile Include="QtUtils\NonDefaultQPushButton.cpp" />
|
<ClCompile Include="QtUtils\NonDefaultQPushButton.cpp" />
|
||||||
<ClCompile Include="QtUtils\PartiallyClosableTabWidget.cpp" />
|
<ClCompile Include="QtUtils\PartiallyClosableTabWidget.cpp" />
|
||||||
|
<ClCompile Include="QtUtils\SetWindowDecorations.cpp" />
|
||||||
<ClCompile Include="QtUtils\UTF8CodePointCountValidator.cpp" />
|
<ClCompile Include="QtUtils\UTF8CodePointCountValidator.cpp" />
|
||||||
<ClCompile Include="QtUtils\WindowActivationEventFilter.cpp" />
|
<ClCompile Include="QtUtils\WindowActivationEventFilter.cpp" />
|
||||||
<ClCompile Include="QtUtils\WrapInScrollArea.cpp" />
|
<ClCompile Include="QtUtils\WrapInScrollArea.cpp" />
|
||||||
@ -379,6 +380,7 @@
|
|||||||
<QtMoc Include="QtUtils\FileOpenEventFilter.h" />
|
<QtMoc Include="QtUtils\FileOpenEventFilter.h" />
|
||||||
<QtMoc Include="QtUtils\ParallelProgressDialog.h" />
|
<QtMoc Include="QtUtils\ParallelProgressDialog.h" />
|
||||||
<QtMoc Include="QtUtils\PartiallyClosableTabWidget.h" />
|
<QtMoc Include="QtUtils\PartiallyClosableTabWidget.h" />
|
||||||
|
<ClInclude Include="QtUtils\SetWindowDecorations.h" />
|
||||||
<QtMoc Include="QtUtils\UTF8CodePointCountValidator.h" />
|
<QtMoc Include="QtUtils\UTF8CodePointCountValidator.h" />
|
||||||
<QtMoc Include="QtUtils\WindowActivationEventFilter.h" />
|
<QtMoc Include="QtUtils\WindowActivationEventFilter.h" />
|
||||||
<QtMoc Include="RenderWidget.h" />
|
<QtMoc Include="RenderWidget.h" />
|
||||||
|
25
Source/Core/DolphinQt/QtUtils/SetWindowDecorations.cpp
Normal file
25
Source/Core/DolphinQt/QtUtils/SetWindowDecorations.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright 2023 Dolphin Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "DolphinQt/Settings.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <dwmapi.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void SetQWidgetWindowDecorations(QWidget* widget)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (!Settings::Instance().IsSystemDark())
|
||||||
|
return;
|
||||||
|
|
||||||
|
BOOL use_dark_title_bar = TRUE;
|
||||||
|
DwmSetWindowAttribute(HWND(widget->winId()),
|
||||||
|
20 /* DWMWINDOWATTRIBUTE::DWMWA_USE_IMMERSIVE_DARK_MODE */,
|
||||||
|
&use_dark_title_bar, DWORD(sizeof(use_dark_title_bar)));
|
||||||
|
#endif
|
||||||
|
}
|
9
Source/Core/DolphinQt/QtUtils/SetWindowDecorations.h
Normal file
9
Source/Core/DolphinQt/QtUtils/SetWindowDecorations.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// Copyright 2023 Dolphin Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
|
// Changes the window decorations (title bar) to dark if the user uses dark mode on Windows.
|
||||||
|
void SetQWidgetWindowDecorations(QWidget* widget);
|
@ -79,6 +79,8 @@
|
|||||||
<AdditionalDependencies>avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;bcrypt.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;bcrypt.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<!--libcurl needs Crypt32.lib-->
|
<!--libcurl needs Crypt32.lib-->
|
||||||
<AdditionalDependencies>Crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>Crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<!--Needed to set window decorations for dark theme-->
|
||||||
|
<AdditionalDependencies>dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<!--See Common/CompatPatches.cpp-->
|
<!--See Common/CompatPatches.cpp-->
|
||||||
<ForceSymbolReferences>enableCompatPatches</ForceSymbolReferences>
|
<ForceSymbolReferences>enableCompatPatches</ForceSymbolReferences>
|
||||||
</Link>
|
</Link>
|
||||||
|
Loading…
Reference in New Issue
Block a user