mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use a preference for choosing the color palette
This commit is contained in:
parent
4b0885b828
commit
49c8fd5191
@ -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
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1083</width>
|
||||
<height>579</height>
|
||||
<height>594</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -50,13 +50,17 @@
|
||||
<string>&Main interface</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="opt_disable_tray_notification">
|
||||
<property name="toolTip">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
<item row="7" column="1">
|
||||
<widget class="QCheckBox" name="opt_show_layout_buttons">
|
||||
<property name="text">
|
||||
<string>Disable n&otifications on job completion</string>
|
||||
<string>Show &layout buttons in the status bar (needs restart)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="opt_systray_icon">
|
||||
<property name="text">
|
||||
<string>Enable s&ystem tray icon (needs restart)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -67,7 +71,77 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="8" column="1">
|
||||
<widget class="QPushButton" name="change_font_button">
|
||||
<property name="text">
|
||||
<string>Change &font (needs restart)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="icon_theme_button">
|
||||
<property name="text">
|
||||
<string>Change &icon theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>E&xtra spacing to add between rows in the book list (can be negative):</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_book_list_extra_row_spacing</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="opt_show_splash_screen">
|
||||
<property name="text">
|
||||
<string>Show the &splash screen at startup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="opt_language">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="opt_gui_layout">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QSpinBox" name="opt_book_list_extra_row_spacing">
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="opt_ui_style"/>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
@ -88,43 +162,34 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="opt_gui_layout">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="opt_disable_animations">
|
||||
<property name="toolTip">
|
||||
<string>Disable all animations. Useful if you have a slow/old computer.</string>
|
||||
</property>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>Disable &animations</string>
|
||||
<string>&User interface layout (needs restart):</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_gui_layout</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="opt_language">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>20</number>
|
||||
<item row="12" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_booklist_grid">
|
||||
<property name="text">
|
||||
<string>Draw a &grid in the book list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_widget_style">
|
||||
<property name="text">
|
||||
<string>User interface style (&needs restart):</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_ui_style</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -137,89 +202,31 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_widget_style">
|
||||
<property name="text">
|
||||
<string>User interface style (&needs restart):</string>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="opt_disable_animations">
|
||||
<property name="toolTip">
|
||||
<string>Disable all animations. Useful if you have a slow/old computer.</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_ui_style</cstring>
|
||||
<property name="text">
|
||||
<string>Disable &animations</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="icon_theme_button">
|
||||
<property name="text">
|
||||
<string>Change &icon theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<item row="13" column="0">
|
||||
<widget class="QCheckBox" name="opt_dnd_merge">
|
||||
<property name="text">
|
||||
<string>Allow using &drag and drop to merge books</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="opt_show_splash_screen">
|
||||
<property name="text">
|
||||
<string>Show the &splash screen at startup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<item row="11" column="0">
|
||||
<widget class="QCheckBox" name="opt_row_numbers_in_book_list">
|
||||
<property name="text">
|
||||
<string>Show &row numbers in the book list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_booklist_grid">
|
||||
<property name="text">
|
||||
<string>Draw a &grid in the book list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>&User interface layout (needs restart):</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_gui_layout</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Choose &language (needs restart):</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_language</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="opt_systray_icon">
|
||||
<property name="text">
|
||||
<string>Enable s&ystem tray icon (needs restart)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QSpinBox" name="opt_book_list_extra_row_spacing">
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Toolbar</string>
|
||||
@ -261,40 +268,50 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="opt_disable_tray_notification">
|
||||
<property name="toolTip">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>E&xtra spacing to add between rows in the book list (can be negative):</string>
|
||||
<string>Disable n&otifications on job completion</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Choose &language (needs restart):</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_book_list_extra_row_spacing</cstring>
|
||||
<cstring>opt_language</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QPushButton" name="change_font_button">
|
||||
<property name="text">
|
||||
<string>Change &font (needs restart)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="opt_ui_style"/>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="opt_show_layout_buttons">
|
||||
<property name="text">
|
||||
<string>Show &layout buttons in the status bar (needs restart)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="opt_book_list_tooltips">
|
||||
<property name="text">
|
||||
<string>Show &tooltips in the book list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_20">
|
||||
<property name="text">
|
||||
<string>Color &palette (needs restart):</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_color_palette</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="opt_color_palette">
|
||||
<property name="toolTip">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QTabWidget" name="cover_grid_tab">
|
||||
|
Loading…
x
Reference in New Issue
Block a user