Skip to content

Commit

Permalink
Use Windows settings to determine titlebar color
Browse files Browse the repository at this point in the history
  • Loading branch information
Silarn committed Nov 29, 2023
1 parent 04eff97 commit aa38125
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mo2_configure_executable(organizer
PRIVATE_DEPENDS
uibase githubpp bsatk esptk archive usvfs lootcli boost::program_options
Qt::WebEngineWidgets Qt::WebSockets)
target_link_libraries(organizer PUBLIC Shlwapi)
target_link_libraries(organizer PUBLIC Shlwapi Dwmapi)
mo2_install_target(organizer)

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/dlls.manifest.qt5"
Expand Down
11 changes: 11 additions & 0 deletions src/moapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QStringList>
#include <QStyleFactory>
#include <QStyleOption>
#include <dwmapi.h>
#include <iplugingame.h>
#include <log.h>
#include <report.h>
Expand Down Expand Up @@ -354,6 +355,16 @@ int MOApplication::run(MOMultiProcess& multiProcess)
log::debug("displaying main window");
mainWindow.show();
mainWindow.activateWindow();

BOOL USE_DARK_MODE = true;
if (!SUCCEEDED(DwmSetWindowAttribute(
(HWND)mainWindow.winId(), DWMWINDOWATTRIBUTE::DWMWA_USE_IMMERSIVE_DARK_MODE,
&USE_DARK_MODE, sizeof(USE_DARK_MODE)))) {
// Support Windows 10
DwmSetWindowAttribute((HWND)mainWindow.winId(), 19, &USE_DARK_MODE,
sizeof(USE_DARK_MODE));
}

splash.close();

tt.stop();
Expand Down

0 comments on commit aa38125

Please sign in to comment.