hydrusnetwork / hydrus

A personal booru-style media tagger that can import files and tags from your hard drive and popular websites. Content can be shared with other users via user-run servers.
http://hydrusnetwork.github.io/hydrus/
Other
2.35k stars 154 forks source link

Handle OS light/dark themes gracefully #756

Open Difegue opened 3 years ago

Difegue commented 3 years ago

Kinda related to #371, but it is extra work.

Both Windows and macOS have support for light/dark themes, and macOS has an option to auto-toggle said theme based on the time of day. (Windows as well, through third-party software)

Currently Hydrus can only be set to one theme through qss - I'd like that to be expanded to two, one for both light and dark themes.
The end-goal would be automatic qss switching based on the current OS theme.

Difegue commented 3 years ago

After a bit more digging into Qt's feature set, it seems dark mode auto-switching is already natively supported for macOS when using the default styling.
It also works on Windows in beta form for the time being.
( One can test this on Hydrus by setting the environment variable QT_QPA_PLATFORM to windows:darkmode=2)

Setting replacement colors in a .QSS overwrites this of course, but you can theoretically write an entire stylesheet relying only on the default colors, and that'll handle light/dark mode switching nicely.
As such, I don't think it's worth the trouble setting up a dual .qss scenario anymore?

CuddleBear92 commented 3 years ago

As such, I don't think it's worth the trouble setting up a dual .qss scenario anymore?

Do think i like the idea of having two qss styles selected at once for each OS display mode. That way users can have different looks to them, like light mode could have a ligher color sceme like light blue and you could have something else for dark. just gives the user more power and control over their look and experience.

hydrusnetwork commented 1 year ago

@Difegue Thank you for this--I am sorry I am so late to it. Someone pointed me at that nice QT_QPA_PLATFORM env variable you have here, which I tried to look for when I found out about the windows darkmode thing, but couldn't find.

I just tested it, and it seems pretty good! Switching between light and dark while the program is running is buggy, but booting into darkmode looks great.

I have reports that the automatic macOS support for light/dark mode is not excellent, which is how I got lead here. I advised the guy in that case just to use one of the default darkmode QSSes to override the scatter of white panels his 'dark' macOS was nonetheless for whatever reason initialising with.

I'm still thinking about next steps for QSS. I want to integrate more of my options->colours stuff in there, and retire/update my old hardcoded darkmode. Let's keep watch on Qt in the future. This darkmode detection will presumably get more mature, and maybe in a couple of years there will be a nice proper Event for it that I can catch and perhaps slide in a switch to a different QSS or whatever seems appropriate. Let me know if you discover anything else!

Difegue commented 1 year ago

@hydrusnetwork I noticed you rolled back enabling darkmode:2 by default -- I'd noticed it getting quite a bit glitchy upon the Qt6 update so I'm not using it anymore myself 🥲 Sorry for not updating this issue with that info.

It doesn't look like the Qt peeps are very interested in improving upon this feature, but maybe that'll eventually change. https://bugreports.qt.io/browse/QTBUG-72028?focusedCommentId=677819&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-677819 oh shit nvm 6.4 improves it

hydrusnetwork commented 1 year ago

Thanks, no worries. I'm re-enabling it tomorrow as an opt-in via launch argument, and the '1' version instead of '2'. We'll see how this works in future!

floogulinc commented 1 year ago

@hydrusnetwork you should use 1 by default and have 2 be an opt-in.