Allow CALIBRE_USE_DARK_PALETTE override registry setting on windows

This commit is contained in:
Kovid Goyal 2019-12-08 20:40:44 +05:30
parent 0a1d4cfcbf
commit d974b2f39c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 14 additions and 11 deletions

View File

@ -8,7 +8,7 @@ Customizing calibre
calibre has a highly modular design. Various parts of it can be customized. You can learn how to create calibre has a highly modular design. Various parts of it can be customized. You can learn how to create
*recipes* to add new sources of online content to calibre in the Section :ref:`news`. Here, you will learn, *recipes* to add new sources of online content to calibre in the Section :ref:`news`. Here, you will learn,
first, how to use environment variables and *tweaks* to customize calibre's behavior, and then how to first, how to use environment variables and *tweaks* to customize calibre's behavior, and then how to
specify your own static resources like icons and templates to override the defaults and finally how to specify your own static resources like icons and templates to override the defaults and finally how to
use *plugins* to add functionality to calibre. use *plugins* to add functionality to calibre.
.. contents:: .. contents::
@ -30,7 +30,7 @@ Environment variables
* ``CALIBRE_DEVELOP_FROM`` - Used to run from a calibre development environment. See :ref:`develop`. * ``CALIBRE_DEVELOP_FROM`` - Used to run from a calibre development environment. See :ref:`develop`.
* ``CALIBRE_OVERRIDE_LANG`` - Used to force the language used by the interface (ISO 639 language code) * ``CALIBRE_OVERRIDE_LANG`` - Used to force the language used by the interface (ISO 639 language code)
* ``CALIBRE_TEST_TRANSLATION`` - Used to test a translation .po file (should be the path to the .po file) * ``CALIBRE_TEST_TRANSLATION`` - Used to test a translation .po file (should be the path to the .po file)
* ``CALIBRE_NO_NATIVE_FILEDIALOGS`` - Causes calibre to not use native file dialogs for selecting files/directories. * ``CALIBRE_NO_NATIVE_FILEDIALOGS`` - Causes calibre to not use native file dialogs for selecting files/directories.
* ``CALIBRE_NO_NATIVE_MENUBAR`` - Causes calibre to not create a native (global) menu on Ubuntu Unity and similar linux desktop environments. The menu is instead placed inside the window, as is traditional. * ``CALIBRE_NO_NATIVE_MENUBAR`` - Causes calibre to not create a native (global) menu on Ubuntu Unity and similar linux desktop environments. The menu is instead placed inside the window, as is traditional.
* ``CALIBRE_USE_SYSTEM_THEME`` - By default, on Linux, calibre uses its own * ``CALIBRE_USE_SYSTEM_THEME`` - By default, on Linux, calibre uses its own
builtin Qt style. This is to avoid crashes and hangs caused by incompatibilities builtin Qt style. This is to avoid crashes and hangs caused by incompatibilities
@ -40,6 +40,8 @@ Environment variables
the system theme -- beware of crashes and hangs. 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_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_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 normal colors (ignored on macOS).
On Windows 10 in the absence of this variable, the windows system preference for dark colors is used.
* ``SYSFS_PATH`` - Use if sysfs is mounted somewhere other than /sys * ``SYSFS_PATH`` - Use if sysfs is mounted somewhere other than /sys
* ``http_proxy``, ``https_proxy`` - Used on linux to specify an HTTP(S) proxy * ``http_proxy``, ``https_proxy`` - Used on linux to specify an HTTP(S) proxy
@ -58,7 +60,7 @@ The default values for the tweaks are reproduced below
Overriding icons, templates, et cetera Overriding icons, templates, et cetera
---------------------------------------- ----------------------------------------
.. note:: .. note::
calibre has direct support for icon themes, there are several icon themes calibre has direct support for icon themes, there are several icon themes
available for calibre, that you can use by going to :guilabel:`Preferences->Interface->Look & Feel->Change Icon theme`. available for calibre, that you can use by going to :guilabel:`Preferences->Interface->Look & Feel->Change Icon theme`.
The icon themes use the same mechanism as described below for overriding static resources. The icon themes use the same mechanism as described below for overriding static resources.
@ -66,15 +68,15 @@ Overriding icons, templates, et cetera
calibre allows you to override the static resources, like icons, javascript and calibre allows you to override the static resources, like icons, javascript and
templates for the metadata jacket, catalogs, etc. with customized versions that templates for the metadata jacket, catalogs, etc. with customized versions that
you like. All static resources are stored in the resources sub-folder of the you like. All static resources are stored in the resources sub-folder of the
calibre install location. On Windows, this is usually :file:`C:\\Program Files\\Calibre2\\resources`. calibre install location. On Windows, this is usually :file:`C:\\Program Files\\Calibre2\\resources`.
On macOS, :file:`/Applications/calibre.app/Contents/Resources/resources/`. On linux, if On macOS, :file:`/Applications/calibre.app/Contents/Resources/resources/`. On linux, if
you are using the binary installer from the calibre website it will be you are using the binary installer from the calibre website it will be
:file:`/opt/calibre/resources`. These paths can change depending on where you :file:`/opt/calibre/resources`. These paths can change depending on where you
choose to install calibre. choose to install calibre.
You should not change the files in this resources folder, as your changes will You should not change the files in this resources folder, as your changes will
get overwritten the next time you update calibre. Instead, go to get overwritten the next time you update calibre. Instead, go to
:guilabel:`Preferences->Advanced->Miscellaneous` and click :guilabel:`Preferences->Advanced->Miscellaneous` and click
:guilabel:`Open calibre configuration directory`. In this configuration directory, create a :guilabel:`Open calibre configuration directory`. In this configuration directory, create a
sub-folder called resources and place the files you want to override in it. sub-folder called resources and place the files you want to override in it.
Place the files in the appropriate sub folders, for example place images in Place the files in the appropriate sub folders, for example place images in
@ -110,4 +112,3 @@ Customizing calibre with plugins
calibre has a very modular design. Almost all functionality in calibre comes in the form of plugins. Plugins are used for conversion, for downloading news (though these are called recipes), for various components of the user interface, to connect to different devices, to process files when adding them to calibre and so on. You can get a complete list of all the built-in plugins in calibre by going to :guilabel:`Preferences->Advanced->Plugins`. calibre has a very modular design. Almost all functionality in calibre comes in the form of plugins. Plugins are used for conversion, for downloading news (though these are called recipes), for various components of the user interface, to connect to different devices, to process files when adding them to calibre and so on. You can get a complete list of all the built-in plugins in calibre by going to :guilabel:`Preferences->Advanced->Plugins`.
You can write your own plugins to customize and extend the behavior of calibre. The plugin architecture in calibre is very simple, see the tutorial :ref:`pluginstutorial`. You can write your own plugins to customize and extend the behavior of calibre. The plugin architecture in calibre is very simple, see the tutorial :ref:`pluginstutorial`.

View File

@ -1021,10 +1021,12 @@ class Application(QApplication):
using_calibre_style = True using_calibre_style = True
if using_calibre_style: if using_calibre_style:
use_dark_palette = False use_dark_palette = False
if iswindows: if 'CALIBRE_USE_DARK_PALETTE' in os.environ:
use_dark_palette = windows_is_system_dark_mode_enabled() if not isosx:
elif not isosx: use_dark_palette = os.environ['CALIBRE_USE_DARK_PALETTE'] != '0'
use_dark_palette = os.environ.get('CALIBRE_USE_DARK_PALETTE') == '1' else:
if iswindows:
use_dark_palette = windows_is_system_dark_mode_enabled()
if use_dark_palette: if use_dark_palette:
self.set_dark_mode_palette() self.set_dark_mode_palette()