We've added some support for light and dark themed icons in icon and emblem rules. These changes are in calibre 7.19.
Changes:
- Addition of an is_dark_mode() template function. Use this in advanced rules to select which icon to return, for example in an 'if' statement.
- Automatic selection of themed icons based on the icon name and the current mode. The text from the help dialog in the rule definition dialog describes how to use it.
Quote:
calibre, version 7.18.100
You can use different icons in light and dark themes. To do this, add two icons to the icon list. One of the icons must have either the "plain" name, for example "ok.png", or the themed name, for example "ok-for-light-theme.png". The other icon must have a themed name with the same prefix, for example "ok-for-dark-theme.png".
Example: if the light theme icon is named "ok.png" then the dark theme icon must be named "ok-for-dark-theme.png". If the light theme icon is named "ok-for-light-theme.png" then the dark theme icon must be named either ok.png or "ok-for-dark-theme.png".
When defining a rule, use either of the icon names. The correct icon for the theme will automatically be used, if it exists.
You are not required to change existing rules to use theming. Decide the theme where the existing icon should be used then add the other icon with the correct themed name.
Remember to add both the light and dark theme icons to the list of icons.
|
Here is an advanced rule that uses the second method, themed icons. It would work in a basic rule as well.
Here are the relevant files in the cc_icons folder.
The result in light mode.
The result in dark mode. Yes, I should add the dark-mode quill icon.
The rules editor showing the help dialog.