Restore CALIBRE_USE_DARK_PALETTE on windows

This commit is contained in:
Kovid Goyal 2022-06-30 08:34:39 +05:30
parent 09f6568dd7
commit ce171699dc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 9 additions and 2 deletions

View File

@ -49,7 +49,7 @@ Environment variables
the system theme -- beware of crashes and hangs.
* ``CALIBRE_SHOW_DEPRECATION_WARNINGS`` - causes calibre to print deprecation warnings to stdout. Useful for calibre developers.
* ``CALIBRE_NO_DEFAULT_PROGRAMS`` - prevent calibre from automatically registering the filetypes it is capable of handling with Windows.
* ``CALIBRE_USE_DARK_PALETTE`` - set it to ``1`` to have calibre use dark colors and ``0`` for light colors. Works on **Linux only**.
* ``CALIBRE_USE_DARK_PALETTE`` - set it to ``1`` to have calibre use dark colors and ``0`` for light colors. Overrides the system-wide dark setting. When set, changes to the colors while calibre is running will not take effect. Works on **Linux and Windows only**.
* ``SYSFS_PATH`` - Use if sysfs is mounted somewhere other than /sys
* ``http_proxy``, ``https_proxy`` - used on Linux to specify an HTTP(S) proxy

View File

@ -1229,6 +1229,9 @@ class Application(QApplication):
using_calibre_style = True
if using_calibre_style:
if iswindows:
if 'CALIBRE_USE_DARK_PALETTE' in os.environ:
use_dark_palette = os.environ.get('CALIBRE_USE_DARK_PALETTE') == '1'
else:
use_dark_palette = windows_is_system_dark_mode_enabled()
elif ismacos:
use_dark_palette = False
@ -1257,6 +1260,8 @@ class Application(QApplication):
@pyqtSlot(str, str, QDBusVariant)
def linux_desktop_setting_changed(self, namespace, key, val):
if (namespace, key) == ('org.freedesktop.appearance', 'color-scheme'):
if 'CALIBRE_USE_DARK_PALETTE' in os.environ:
return
use_dark_palette = val.variant() == 1
if use_dark_palette != bool(self.is_dark_theme):
if use_dark_palette:
@ -1266,6 +1271,8 @@ class Application(QApplication):
self.on_palette_change()
def check_for_windows_palette_change(self):
if 'CALIBRE_USE_DARK_PALETTE' in os.environ:
return
use_dark_palette = bool(windows_is_system_dark_mode_enabled())
if bool(self.is_dark_theme) != use_dark_palette:
if use_dark_palette: