keepassxc icon indicating copy to clipboard operation
keepassxc copied to clipboard

Make the titlebar dark when dark mode is enabled (Windows)

Open semi-transparent-dodecahedron opened this issue 4 years ago • 16 comments

Summary

A dark titlebar when dark mode is enabled.

Examples

img img(1)

Context

The white titlebar greats a visual disruption and also hurts the eye if dark mode is enabled in other places such as in Windows shell, browser etc.

Possible implementation

There is an API (undocumented) introduced in W10 v1809 that changes the titlebar color for Win32 apps: https://github.com/ysc3839/win32-darkmode/blob/cc26549b65b25d6f3168a80238792545bd401271/win32-darkmode/DarkMode.h#L107

This is a known issue and we haven't really found a way to make it work with the Win32 API and Msys2. I'll check if the proposed solution works, but so far all attempts have failed or would have required us to draw our own title bars entirely.

phoerious avatar Jul 28 '21 09:07 phoerious

Could be possible when we go to visual studio

droidmonkey avatar Jul 28 '21 10:07 droidmonkey

UWP/XAML apps have all the APIs for this kind of stuff. Win32 is more restricted, but with access to the full WinRT API it could be easier.

phoerious avatar Jul 30 '21 08:07 phoerious

I just saw in a Reddit thread that the dark titlebar support is publicly available in the Windows 11 SDK and that the documentation will be updated soon: https://www.reddit.com/r/Windows11/comments/qw7o69/comment/hl1tibg/

redudant-overflowing avatar Nov 18 '21 21:11 redudant-overflowing

I tried out the APIs, but something doesn't work. No matter what I do, the titlebar stays white. Maybe Qt is interfering somewhere.

phoerious avatar Nov 22 '21 20:11 phoerious

@phoerious might be able to give this another go with the WinRT API's.

droidmonkey avatar Mar 21 '22 13:03 droidmonkey

I was able to do change the title bar colour with the Win32 API, but only to pure black, which looked even more out of place than leaving it white. Does WinRT allow custom colours or do we have to render CSDs?

phoerious avatar Mar 21 '22 14:03 phoerious

Could be buried somewhere in here: https://docs.microsoft.com/en-us/uwp/api/windows.ui?view=winrt-22000

But this might also require a CoreWindow to be created... which we cannot do with Qt.

droidmonkey avatar Mar 21 '22 15:03 droidmonkey

Qt 5.15, at least, might support it via a darkmode=1 argument to the Windows platform plugin (QGuiApplication - Platform-Specific Arguments), you can launch KeePassXC with -platform windows:darkmode=1 to enable it. But it would be nice to enable it by default. Perhaps via qt.conf? (It's probably not enabled by default since Qt Widgets doesn't come with a native dark mode style. It is something KeePassXC implemented)

I'm not sure whether Qt 6 has added native support for this or enabled this by default for Qt Widgets since Qt 5.15. – https://github.com/keepassxreboot/keepassxc/issues/7782#issue-1191039285

From the duplicate issue I opened. (Damn search...)

This is how this can be implemented, by just adding a key to qt.conf:

[Platforms]
WindowsArguments = darkmode=1

(I only tested using the CLI approach for setting this)

segevfiner avatar Apr 04 '22 09:04 segevfiner

Just commenting to act as an upvote and track the issue.

EricLauber avatar Sep 16 '22 22:09 EricLauber

We haven't done anything in this regard, because the Win32 dark mode is pretty useless. The only option Windows provides via the old API is a pitch black title bar.

phoerious avatar Sep 17 '22 20:09 phoerious

Gotta love Windows.....

JohnLGalt avatar Sep 18 '22 09:09 JohnLGalt

But KeePassXC has added it's own dark mode. Just adding what I listed in https://github.com/keepassxreboot/keepassxc/issues/6775#issuecomment-1087320697 will also make the title bar dark for completion.

segevfiner avatar Sep 18 '22 15:09 segevfiner

The dark Windows title bar doesn't match our dark theme in the slightest.

phoerious avatar Sep 21 '22 12:09 phoerious

Not surprising, but isn't this still better than a light one when the rest of the app is dark...?

segevfiner avatar Sep 21 '22 14:09 segevfiner

I would say no. It looks quite out of place, actually.

phoerious avatar Sep 21 '22 14:09 phoerious

I will be happy to have a dark mode that is not optimal, better than burn-in on my oled from the bright white titlebar.

leowinterde avatar Sep 23 '22 16:09 leowinterde

Without this qt.conf the titlebar is white when you do not use your accent color for titlebars. This setting is possible in Windows 11 (don't remember windows 10 at this point). Adding the qt.conf settings above has no affect if the below setting is activated, so I think adding the qt.conf is a win win.

image

droidmonkey avatar Sep 23 '22 18:09 droidmonkey

Without this qt.conf the titlebar is white when you do not use your accent color for titlebars. This setting is possible in Windows 11 (don't remember windows 10 at this point). Adding the qt.conf settings above has no affect if the below setting is activated, so I think adding the qt.conf is a win win.

image

Just because you didn't show the Win10 menu version, here it is for anyone else: image

Renegade-Master avatar Oct 24 '22 13:10 Renegade-Master