IgKh / katvan

A bare-bones editor for Typst files, with a bias for Right-to-Left editing
GNU General Public License v3.0
35 stars 3 forks source link

Feature request: dark theme #6

Closed Munchotaur closed 1 month ago

Munchotaur commented 2 months ago

Hi, I'm finding Kanvan very usable except for the light theme which is an accessibility issue with my vision. Is it possible to include an optional dark theme in the AppImage at some point?

IgKh commented 2 months ago

Hi!

Katvan has dark theme support since version 0.5.0, but this extends to only the colors it chooses itself (the syntax highlighting colors, mostly). It is automatically set when the active Qt style is perceived to be dark. Based on that, a toggle to enable the dark mode colors won't do much good if the active style renders everything outside the editor box itself in light colors. So basically, to get Katvan to be in full dark mode, just get it to use any dark Qt style, based on whatever means you have / want.

... that is, except when running from an AppImage. The AppImage will only use whatever Qt plugins are bundled in it, and that means that only the built in "Fusion" style is available. That style can work in both light and dark modes, and will use a dark mode if the detected Qt platform theme plugin says that there is system-wide dark mode enabled. That should hopefully be sufficient I think - I don't want to bundle a different custom style, as it is very much a personal matter of taste.

The question is therefore - if you are seeing Katvan in light mode, but the rest of the system is in dark mode, then why? To help understand that, can you please provide the following info:

Thanks!

lngcc commented 2 months ago

Is there any way to set dark theme under windows?

Munchotaur commented 2 months ago

Belated answers but I hope they're still useful:

* Version of Katvan you are using.

Katvan 0.7.0-4a5bccd

  • Which desktop environment or similar is being used, and which version of it. Cinnamon 5.6.8
  • Are you on Wayland or on X11? X11
  • If not using KDE, do you have any setup to manage Qt settings and themes? I have the basic "QT5 Configuration Tool" installed
  • What are the values of environment variables XDG_CURRENT_DESKTOP, QT_QPA_PLATFORMTHEME and QT_STYLE_OVERRIDE? XDG_CURRENT_DESKTOP=X-Cinnamon QT_QPA_PLATFORMTHEME=qt5ct QT_STYLE_OVERRIDE not set

I think qt5ct just refers to any theme set by the QT5 Configuration Tool, which currently is Breeze Dark on my system.

IgKh commented 2 months ago

@lngcc It is the same deal on Windows - dark mode will be activated if the system-wide dark mode is enabled. This should happen automatically on Windows 11. On Windows 10 there is a known issue with the default Qt theme, and you need to switch to another. See something like https://www.youtube.com/watch?v=QzEmMD-NVIc for an example.

IgKh commented 2 months ago

@Munchotaur Thanks for the details! Cinnamon is a GTK3 based environment. It appears that the AppImage won't detect the GTK theme being dark due to the Gtk3 Qt platform theme not being included in the package. I'll add it to the next release.

I saw some projects made attempts to try and include qt5ct or qt6ct platform theme and proxy style in AppImages, but seems results are very mixed, since the style qt5ct is configured with might not be binary compatible with the Qt build inside the AppImage.

In the meanwhile, you might want to try running Katvan AppImage with the environment variable QT_QPA_PLATFORMTHEME=xdgdesktopportal. This might do the trick if Cinnamon has a proper XDG portal setup that is able to report the color scheme (that's the mechanism that Flatpak packages use).

Munchotaur commented 2 months ago

In the meanwhile, you might want to try running Katvan AppImage with the environment variable QT_QPA_PLATFORMTHEME=xdgdesktopportal. This might do the trick if Cinnamon has a proper XDG portal setup that is able to report the color scheme (that's the mechanism that Flatpak packages use).

This worked a treat. Thanks! I'll make a shell alias to set this env variable until such time as a fix is possible...

IgKh commented 1 month ago

AppImage of version 0.7.1 released just today has the extra component for Gtk environments. Checked that it works as expected on Gnome, should also work on Cinnamon.