mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -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/PartiallyClosableTabWidget.cpp
|
||||
QtUtils/PartiallyClosableTabWidget.h
|
||||
QtUtils/SetWindowDecorations.cpp
|
||||
QtUtils/SetWindowDecorations.h
|
||||
QtUtils/SignalBlocking.h
|
||||
QtUtils/UTF8CodePointCountValidator.cpp
|
||||
QtUtils/UTF8CodePointCountValidator.h
|
||||
@ -403,6 +405,7 @@ if (WIN32)
|
||||
PRIVATE
|
||||
gdi32.lib
|
||||
shell32.lib
|
||||
dwmapi.lib # Needed to set window decorations for dark theme
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -188,6 +188,7 @@
|
||||
<ClCompile Include="QtUtils\ModalMessageBox.cpp" />
|
||||
<ClCompile Include="QtUtils\NonDefaultQPushButton.cpp" />
|
||||
<ClCompile Include="QtUtils\PartiallyClosableTabWidget.cpp" />
|
||||
<ClCompile Include="QtUtils\SetWindowDecorations.cpp" />
|
||||
<ClCompile Include="QtUtils\UTF8CodePointCountValidator.cpp" />
|
||||
<ClCompile Include="QtUtils\WindowActivationEventFilter.cpp" />
|
||||
<ClCompile Include="QtUtils\WrapInScrollArea.cpp" />
|
||||
@ -379,6 +380,7 @@
|
||||
<QtMoc Include="QtUtils\FileOpenEventFilter.h" />
|
||||
<QtMoc Include="QtUtils\ParallelProgressDialog.h" />
|
||||
<QtMoc Include="QtUtils\PartiallyClosableTabWidget.h" />
|
||||
<ClInclude Include="QtUtils\SetWindowDecorations.h" />
|
||||
<QtMoc Include="QtUtils\UTF8CodePointCountValidator.h" />
|
||||
<QtMoc Include="QtUtils\WindowActivationEventFilter.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>
|
||||
<!--libcurl needs Crypt32.lib-->
|
||||
<AdditionalDependencies>Crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<!--Needed to set window decorations for dark theme-->
|
||||
<AdditionalDependencies>dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<!--See Common/CompatPatches.cpp-->
|
||||
<ForceSymbolReferences>enableCompatPatches</ForceSymbolReferences>
|
||||
</Link>
|
||||
|
Loading…
Reference in New Issue
Block a user