diff --git a/manual/customize.rst b/manual/customize.rst
index cf9976a5c4..217c581624 100644
--- a/manual/customize.rst
+++ b/manual/customize.rst
@@ -49,7 +49,6 @@ 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. 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
diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py
index 982dda5d49..e3942f6c97 100644
--- a/src/calibre/gui2/__init__.py
+++ b/src/calibre/gui2/__init__.py
@@ -307,6 +307,7 @@ def create_defs():
defs['auto_add_auto_convert'] = True
defs['auto_add_everything'] = False
defs['ui_style'] = 'calibre' if iswindows or ismacos else 'system'
+ defs['color_palette'] = 'system'
defs['tag_browser_old_look'] = False
defs['tag_browser_hide_empty_categories'] = False
defs['tag_browser_always_autocollapse'] = False
@@ -1041,6 +1042,10 @@ class Application(QApplication):
palette_changed = pyqtSignal()
def __init__(self, args, force_calibre_style=False, override_program_name=None, headless=False, color_prefs=gprefs, windows_app_uid=None):
+ if ismacos and not headless:
+ from calibre_extensions.cocoa import set_appearance
+ if gprefs['color_palette'] != 'system':
+ set_appearance(gprefs['color_palette'])
self.ignore_palette_changes = False
QNetworkProxyFactory.setUseSystemConfiguration(True)
# Allow import of webengine after construction of QApplication on new
@@ -1226,21 +1231,15 @@ 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()
+ use_dark_palette = gprefs['color_palette'] == 'dark' or (gprefs['color_palette'] == 'system' and windows_is_system_dark_mode_enabled())
elif ismacos:
- use_dark_palette = False
+ use_dark_palette = gprefs['color_palette'] == 'dark'
else:
- if 'CALIBRE_USE_DARK_PALETTE' in os.environ:
- use_dark_palette = os.environ.get('CALIBRE_USE_DARK_PALETTE') == '1'
- else:
- use_dark_palette = linux_is_system_dark_mode_enabled()
- bus = QDBusConnection.sessionBus()
- bus.connect(
- 'org.freedesktop.portal.Desktop', '/org/freedesktop/portal/desktop',
- 'org.freedesktop.portal.Settings', 'SettingChanged', 'ssv', self.linux_desktop_setting_changed)
+ use_dark_palette = gprefs['color_palette'] == 'dark' or (gprefs['color_palette'] == 'system' and linux_is_system_dark_mode_enabled())
+ bus = QDBusConnection.sessionBus()
+ bus.connect(
+ 'org.freedesktop.portal.Desktop', '/org/freedesktop/portal/desktop',
+ 'org.freedesktop.portal.Settings', 'SettingChanged', 'ssv', self.linux_desktop_setting_changed)
if use_dark_palette:
self.set_dark_mode_palette()
elif self.original_palette_modified:
@@ -1257,7 +1256,7 @@ 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:
+ if gprefs['color_palette'] != 'system':
return
use_dark_palette = val.variant() == 1
if use_dark_palette != bool(self.is_dark_theme):
@@ -1268,7 +1267,7 @@ class Application(QApplication):
self.on_palette_change()
def check_for_windows_palette_change(self):
- if 'CALIBRE_USE_DARK_PALETTE' in os.environ:
+ if gprefs['color_palette'] != 'system':
return
use_dark_palette = bool(windows_is_system_dark_mode_enabled())
if bool(self.is_dark_theme) != use_dark_palette:
diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py
index 472184974e..4a130871d6 100644
--- a/src/calibre/gui2/preferences/look_feel.py
+++ b/src/calibre/gui2/preferences/look_feel.py
@@ -415,6 +415,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
self.default_author_link.changed_signal.connect(self.changed_signal)
r('gui_layout', config, restart_required=True, choices=[(_('Wide'), 'wide'), (_('Narrow'), 'narrow')])
r('ui_style', gprefs, restart_required=True, choices=[(_('System default'), 'system'), (_('calibre style'), 'calibre')])
+ r('color_palette', gprefs, restart_required=True, choices=[(_('System default'), 'system'), (_('Light'), 'light'), (_('Dark'), 'dark')])
r('book_list_tooltips', gprefs)
r('dnd_merge', gprefs)
r('wrap_toolbar_text', gprefs, restart_required=True)
diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui
index cee6960463..3ab29a802e 100644
--- a/src/calibre/gui2/preferences/look_feel.ui
+++ b/src/calibre/gui2/preferences/look_feel.ui
@@ -7,7 +7,7 @@
0
0
1083
- 579
+ 594
@@ -50,13 +50,17 @@
&Main interface
- -
-
-
- Disable popup notifications when calibre completes jobs such a conversion, sending to device etc. The notifications are sent via the operating system notification facility, if available. Note that on Windows, you have to enable the system tray icon for notifications to work.
-
+
-
+
- Disable n&otifications on job completion
+ Show &layout buttons in the status bar (needs restart)
+
+
+
+ -
+
+
+ Enable s&ystem tray icon (needs restart)
@@ -67,7 +71,77 @@
- -
+
-
+
+
+ Change &font (needs restart)
+
+
+
+ -
+
+
+ Change &icon theme
+
+
+
+ -
+
+
+ E&xtra spacing to add between rows in the book list (can be negative):
+
+
+ opt_book_list_extra_row_spacing
+
+
+
+ -
+
+
+ Show the &splash screen at startup
+
+
+
+ -
+
+
+ QComboBox::AdjustToMinimumContentsLengthWithIcon
+
+
+ 20
+
+
+
+ -
+
+
+
+ 250
+ 16777215
+
+
+
+ QComboBox::AdjustToMinimumContentsLengthWithIcon
+
+
+ 20
+
+
+
+ -
+
+
+ px
+
+
+ -20
+
+
+
+ -
+
+
+ -
-
@@ -88,43 +162,34 @@
- -
-
-
-
- 250
- 16777215
-
-
-
- QComboBox::AdjustToMinimumContentsLengthWithIcon
-
-
- 20
-
-
-
- -
-
-
- Disable all animations. Useful if you have a slow/old computer.
-
+
-
+
- Disable &animations
+ &User interface layout (needs restart):
+
+
+ opt_gui_layout
- -
-
-
- QComboBox::AdjustToMinimumContentsLengthWithIcon
-
-
- 20
+
-
+
+
+ Draw a &grid in the book list
- -
+
-
+
+
+ User interface style (&needs restart):
+
+
+ opt_ui_style
+
+
+
+ -
Qt::Vertical
@@ -137,89 +202,31 @@
- -
-
-
- User interface style (&needs restart):
+
-
+
+
+ Disable all animations. Useful if you have a slow/old computer.
-
- opt_ui_style
+
+ Disable &animations
- -
-
-
- Change &icon theme
-
-
-
- -
+
-
Allow using &drag and drop to merge books
- -
-
-
- Show the &splash screen at startup
-
-
-
- -
+
-
Show &row numbers in the book list
- -
-
-
- Draw a &grid in the book list
-
-
-
- -
-
-
- &User interface layout (needs restart):
-
-
- opt_gui_layout
-
-
-
- -
-
-
- Choose &language (needs restart):
-
-
- opt_language
-
-
-
- -
-
-
- Enable s&ystem tray icon (needs restart)
-
-
-
- -
-
-
- px
-
-
- -20
-
-
-
- -
+
-
Toolbar
@@ -261,40 +268,50 @@
- -
-
+
-
+
+
+ Disable popup notifications when calibre completes jobs such a conversion, sending to device etc. The notifications are sent via the operating system notification facility, if available. Note that on Windows, you have to enable the system tray icon for notifications to work.
+
- E&xtra spacing to add between rows in the book list (can be negative):
+ Disable n&otifications on job completion
+
+
+
+ -
+
+
+ Choose &language (needs restart):
- opt_book_list_extra_row_spacing
+ opt_language
- -
-
-
- Change &font (needs restart)
-
-
-
- -
-
-
- -
-
-
- Show &layout buttons in the status bar (needs restart)
-
-
-
- -
+
-
Show &tooltips in the book list
+ -
+
+
+ Color &palette (needs restart):
+
+
+ opt_color_palette
+
+
+
+ -
+
+
+ The colors to use for the calibre interface. By default the system colors are used. You can change this to force a light or dark color scheme. Note that if this is not set to system default then if the system wide color scheme is changed calibre will not follow it.
+
+
+