From 210415fd4a23edd402dd6f1b17f98025f64265bb Mon Sep 17 00:00:00 2001
From: un-pogaz <46523284+un-pogaz@users.noreply.github.com>
Date: Fri, 31 Jan 2025 16:12:55 +0100
Subject: [PATCH] move "Look & Feel/Main interface" to its own widget
---
src/calibre/gui2/preferences/look_feel.py | 166 +-------
src/calibre/gui2/preferences/look_feel.ui | 354 +----------------
.../look_feel_tabs/main_interface.py | 193 ++++++++++
.../look_feel_tabs/main_interface.ui | 356 ++++++++++++++++++
4 files changed, 557 insertions(+), 512 deletions(-)
create mode 100644 src/calibre/gui2/preferences/look_feel_tabs/main_interface.py
create mode 100644 src/calibre/gui2/preferences/look_feel_tabs/main_interface.ui
diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py
index d3aa675d14..172320f9a4 100644
--- a/src/calibre/gui2/preferences/look_feel.py
+++ b/src/calibre/gui2/preferences/look_feel.py
@@ -10,16 +10,12 @@ from functools import partial
from threading import Thread
from qt.core import (
- QApplication,
QBrush,
QColor,
QColorDialog,
QComboBox,
QDialog,
QDialogButtonBox,
- QFont,
- QFontDialog,
- QFontInfo,
QFormLayout,
QHeaderView,
QIcon,
@@ -41,22 +37,19 @@ from qt.core import (
)
from calibre import human_readable
-from calibre.constants import ismacos, iswindows
from calibre.ebooks.metadata.book.render import DEFAULT_AUTHOR_LINK
from calibre.ebooks.metadata.sources.prefs import msprefs
-from calibre.gui2 import config, default_author_link, error_dialog, gprefs, icon_resource_manager, open_local_file, qt_app, question_dialog
+from calibre.gui2 import config, default_author_link, error_dialog, gprefs, open_local_file, question_dialog
from calibre.gui2.custom_column_widgets import get_field_list as em_get_field_list
from calibre.gui2.library.alternate_views import CM_TO_INCH, auto_height
-from calibre.gui2.preferences import ConfigWidgetBase, Setting, set_help_tips, test_widget
+from calibre.gui2.preferences import ConfigWidgetBase, test_widget
from calibre.gui2.preferences.coloring import EditRules
from calibre.gui2.preferences.look_feel_tabs import DisplayedFields, export_layout, import_layout, move_field_down, move_field_up, reset_layout
from calibre.gui2.preferences.look_feel_ui import Ui_Form
from calibre.gui2.widgets import BusyCursor
from calibre.gui2.widgets2 import Dialog
from calibre.startup import connect_lambda
-from calibre.utils.config import prefs
from calibre.utils.icu import sort_key
-from calibre.utils.localization import available_translations, get_lang, get_language
from calibre.utils.resources import get_path as P
from calibre.utils.resources import set_data
from polyglot.builtins import iteritems
@@ -322,53 +315,21 @@ class Background(QWidget): # {{{
# }}}
-class LanguageSetting(Setting):
-
- def commit(self):
- val = self.get_gui_val()
- oldval = self.get_config_val()
- if val != oldval:
- gprefs.set('last_used_language', oldval)
- return super().commit()
-
-
class ConfigWidget(ConfigWidgetBase, Ui_Form):
size_calculated = pyqtSignal(object)
def genesis(self, gui):
self.gui = gui
- self.ui_style_available = True
- if not ismacos and not iswindows:
- self.label_widget_style.setVisible(False)
- self.opt_ui_style.setVisible(False)
- self.ui_style_available = False
db = gui.library_view.model().db
r = self.register
- try:
- self.icon_theme_title = icon_resource_manager.user_theme_title
- except Exception:
- self.icon_theme_title = _('Default icons')
- self.icon_theme.setText(_('Icon theme: %s') % self.icon_theme_title)
- self.commit_icon_theme = None
- self.icon_theme_button.clicked.connect(self.choose_icon_theme)
self.default_author_link = DefaultAuthorLink(self.default_author_link_container)
self.default_author_link.changed_signal.connect(self.changed_signal)
- r('ui_style', gprefs, restart_required=True, choices=[(_('System default'), 'system'), (_('calibre style'), 'calibre')])
- r('book_list_tooltips', gprefs)
- r('dnd_merge', gprefs)
- r('wrap_toolbar_text', gprefs, restart_required=True)
- r('show_layout_buttons', gprefs)
- r('show_sb_all_actions_button', gprefs)
- # r('show_sb_preference_button', gprefs)
- r('row_numbers_in_book_list', gprefs)
r('bd_show_cover', gprefs)
r('bd_overlay_cover_size', gprefs)
- r('cover_corner_radius', gprefs)
- r('cover_corner_radius_unit', gprefs, choices=[(_('Pixels'), 'px'), (_('Percentage'), '%')])
r('cover_grid_width', gprefs)
r('cover_grid_height', gprefs)
r('cover_grid_cache_size_multiple', gprefs)
@@ -379,48 +340,13 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('emblem_size', gprefs)
r('emblem_position', gprefs, choices=[
(_('Left'), 'left'), (_('Top'), 'top'), (_('Right'), 'right'), (_('Bottom'), 'bottom')])
- r('book_list_extra_row_spacing', gprefs)
- r('booklist_grid', gprefs)
r('book_details_comments_heading_pos', gprefs, choices=[
(_('Never'), 'hide'), (_('Above text'), 'above'), (_('Beside text'), 'side')])
r('book_details_note_link_icon_width', gprefs)
self.id_links_button.clicked.connect(self.edit_id_link_rules)
- def get_esc_lang(l):
- if l == 'en':
- return 'English'
- return get_language(l)
-
- lang = get_lang()
- if lang is None or lang not in available_translations():
- lang = 'en'
- items = [(l, get_esc_lang(l)) for l in available_translations()
- if l != lang]
- if lang != 'en':
- items.append(('en', get_esc_lang('en')))
- items.sort(key=lambda x: x[1].lower())
- choices = [(y, x) for x, y in items]
- # Default language is the autodetected one
- choices = [(get_language(lang), lang)] + choices
- lul = gprefs.get('last_used_language')
- if lul and (lul in available_translations() or lul in ('en', 'eng')):
- choices.insert(1, ((get_language(lul), lul)))
- r('language', prefs, choices=choices, restart_required=True, setting=LanguageSetting)
-
- r('disable_animations', config)
- r('systray_icon', config, restart_required=True)
- r('show_splash_screen', gprefs)
- r('disable_tray_notification', config)
r('use_roman_numerals_for_series_number', config)
- choices = [(_('Off'), 'off'), (_('Small'), 'small'),
- (_('Medium-small'), 'mid-small'), (_('Medium'), 'medium'), (_('Large'), 'large')]
- r('toolbar_icon_size', gprefs, choices=choices)
-
- choices = [(_('If there is enough room'), 'auto'), (_('Always'), 'always'),
- (_('Never'), 'never')]
- r('toolbar_text', gprefs, choices=choices)
-
fm = db.field_metadata
choices = sorted(((fm[k]['name'], k) for k in fm.displayable_field_keys() if fm[k]['name']),
key=lambda x:sort_key(x[0]))
@@ -441,9 +367,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('edit_metadata_single_cc_label_length', gprefs)
r('edit_metadata_templates_only_F2_on_booklist', gprefs)
- self.current_font = self.initial_font = None
- self.change_font_button.clicked.connect(self.change_font)
-
self.display_model = DisplayedFields(self.gui.current_db, self.field_display_order)
self.display_model.dataChanged.connect(self.changed_signal)
self.field_display_order.setModel(self.display_model)
@@ -527,37 +450,10 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
self.sections_view.setSpacing(4)
self.sections_view.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.tabWidget.currentWidget().setFocus(Qt.FocusReason.OtherFocusReason)
- self.opt_ui_style.currentIndexChanged.connect(self.update_color_palette_state)
- self.opt_gui_layout.addItem(_('Wide'), 'wide')
- self.opt_gui_layout.addItem(_('Narrow'), 'narrow')
- self.opt_gui_layout.currentIndexChanged.connect(self.changed_signal)
- set_help_tips(self.opt_gui_layout, config.help('gui_layout'))
- self.button_adjust_colors.clicked.connect(self.adjust_colors)
-
- def adjust_colors(self):
- from calibre.gui2.dialogs.palette import PaletteConfig
- d = PaletteConfig(self)
- if d.exec() == QDialog.DialogCode.Accepted:
- d.apply_settings()
- self.changed_signal.emit()
def initial_tab_changed(self):
self.sections_view.setCurrentRow(self.tabWidget.currentIndex())
- def update_color_palette_state(self):
- if self.ui_style_available:
- enabled = self.opt_ui_style.currentData() == 'calibre'
- self.button_adjust_colors.setEnabled(enabled)
-
- def choose_icon_theme(self):
- from calibre.gui2.icon_theme import ChooseTheme
- d = ChooseTheme(self)
- if d.exec() == QDialog.DialogCode.Accepted:
- self.commit_icon_theme = d.commit_changes
- self.icon_theme_title = d.new_theme_title or _('Default icons')
- self.icon_theme.setText(_('Icon theme: %s') % self.icon_theme_title)
- self.changed_signal.emit()
-
def edit_id_link_rules(self):
if IdLinksEditor(self).exec() == QDialog.DialogCode.Accepted:
self.changed_signal.emit()
@@ -595,12 +491,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
ConfigWidgetBase.initialize(self)
self.default_author_link.value = default_author_link()
- font = gprefs['font']
- if font is not None:
- font = list(font)
- font.append(gprefs.get('font_stretch', QFont.Stretch.Unstretched))
- self.current_font = self.initial_font = font
- self.update_font_display()
self.display_model.initialize()
self.em_display_model.initialize()
self.bd_vertical_cats_model.initialize()
@@ -622,8 +512,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
self.opt_book_details_css.blockSignals(True)
self.opt_book_details_css.setPlainText(P('templates/book_details.css', data=True).decode('utf-8'))
self.opt_book_details_css.blockSignals(False)
- self.update_color_palette_state()
- self.opt_gui_layout.setCurrentIndex(0 if self.gui.layout_container.is_wide else 1)
def open_cg_cache(self):
open_local_file(self.gui.grid_view.thumbnail_cache.location)
@@ -659,11 +547,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
def restore_defaults(self):
ConfigWidgetBase.restore_defaults(self)
self.default_author_link.value = DEFAULT_AUTHOR_LINK
- ofont = self.current_font
- self.current_font = None
- if ofont is not None:
- self.changed_signal.emit()
- self.update_font_display()
self.display_model.restore_defaults()
self.em_display_model.restore_defaults()
self.bd_vertical_cats_model.restore_defaults()
@@ -674,7 +557,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
self.set_cg_color(gprefs.defaults['cover_grid_color'])
self.set_cg_texture(gprefs.defaults['cover_grid_texture'])
self.opt_book_details_css.setPlainText(P('templates/book_details.css', allow_user_override=False, data=True).decode('utf-8'))
- self.opt_gui_layout.setCurrentIndex(0)
def change_cover_grid_color(self):
col = QColorDialog.getColor(self.cg_bg_widget.bcol,
@@ -702,40 +584,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
self.set_cg_texture(gprefs.defaults['cover_grid_texture'])
self.changed_signal.emit()
- def build_font_obj(self):
- font_info = qt_app.original_font if self.current_font is None else self.current_font
- font = QFont(*(font_info[:4]))
- font.setStretch(font_info[4])
- return font
-
- def update_font_display(self):
- font = self.build_font_obj()
- fi = QFontInfo(font)
- name = str(fi.family())
-
- self.font_display.setFont(font)
- self.font_display.setText(name + f' [{fi.pointSize()}pt]')
-
- def change_font(self, *args):
- fd = QFontDialog(self.build_font_obj(), self)
- if fd.exec() == QDialog.DialogCode.Accepted:
- font = fd.selectedFont()
- fi = QFontInfo(font)
- self.current_font = [str(fi.family()), fi.pointSize(),
- fi.weight(), fi.italic(), font.stretch()]
- self.update_font_display()
- self.changed_signal.emit()
-
def commit(self, *args):
with BusyCursor():
- rr = ConfigWidgetBase.commit(self, *args)
- if self.current_font != self.initial_font:
- gprefs['font'] = (self.current_font[:4] if self.current_font else
- None)
- gprefs['font_stretch'] = (self.current_font[4] if self.current_font
- is not None else QFont.Stretch.Unstretched)
- QApplication.setFont(self.font_display.font())
- rr = True
self.display_model.commit()
self.em_display_model.commit()
self.bd_vertical_cats_model.commit()
@@ -744,36 +594,24 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
self.grid_rules.commit(self.gui.current_db.prefs)
gprefs['cover_grid_color'] = tuple(self.cg_bg_widget.bcol.getRgb())[:3]
gprefs['cover_grid_texture'] = self.cg_bg_widget.btex
- if self.commit_icon_theme is not None:
- self.commit_icon_theme()
gprefs['default_author_link'] = self.default_author_link.value
bcss = self.opt_book_details_css.toPlainText().encode('utf-8')
defcss = P('templates/book_details.css', data=True, allow_user_override=False)
if defcss == bcss:
bcss = None
set_data('templates/book_details.css', bcss)
- self.gui.layout_container.change_layout(self.gui, self.opt_gui_layout.currentIndex() == 0)
- return rr
def refresh_gui(self, gui):
gui.book_details.book_info.refresh_css()
- gui.place_layout_buttons()
m = gui.library_view.model()
m.update_db_prefs_cache()
m.beginResetModel(), m.endResetModel()
- self.update_font_display()
gui.tags_view.model().reset_tag_browser()
gui.library_view.refresh_book_details(force=True)
gui.library_view.refresh_grid()
gui.library_view.refresh_composite_edit()
- gui.library_view.set_row_header_visibility()
- for view in 'library memory card_a card_b'.split():
- getattr(gui, view + '_view').set_row_header_visibility()
- gui.library_view.refresh_row_sizing()
gui.grid_view.refresh_settings()
gui.update_auto_scroll_timeout()
- gui.sb_all_gui_actions_button.setVisible(gprefs['show_sb_all_actions_button'])
- # gui.sb_preferences_button.setVisible(gprefs['show_sb_preference_button'])
if __name__ == '__main__':
diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui
index 69784aab70..c8eb4a4e92 100644
--- a/src/calibre/gui2/preferences/look_feel.ui
+++ b/src/calibre/gui2/preferences/look_feel.ui
@@ -19,7 +19,7 @@
0
-
+
:/images/lt.png:/images/lt.png
@@ -27,353 +27,6 @@
&Main interface
-
- -
-
-
- User interface style (&needs restart):
-
-
- opt_ui_style
-
-
-
- -
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 20
- 1
-
-
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
- Change &icon theme
-
-
-
- -
-
-
- User interface &colors:
-
-
- button_adjust_colors
-
-
-
- -
-
-
- Adjust &colors
-
-
-
- -
-
-
- &User interface layout:
-
-
- opt_gui_layout
-
-
-
- -
-
-
-
- 250
- 16777215
-
-
-
- QComboBox::AdjustToMinimumContentsLengthWithIcon
-
-
- 20
-
-
-
- -
-
-
- Choose &language (needs restart):
-
-
- opt_language
-
-
-
- -
-
-
- QComboBox::AdjustToMinimumContentsLengthWithIcon
-
-
- 20
-
-
-
- -
-
-
- &Round the corners of covers:
-
-
- opt_cover_corner_radius
-
-
-
- -
-
-
-
-
-
- Round the corners of covers in many places they are displayed such as the Cover grid, Book details panel, etc. Adjust the amount of rounding with this setting. A value of between 5 and 10 looks good with most covers sizes. Zero disables rounding and is the default.
-
-
- no rounding
-
-
-
- -
-
-
- The unit for the cover corner rounding. Either pixel values or as a percentage of the cover size.
-
-
-
-
-
- -
-
-
- Enable s&ystem tray icon (needs restart)
-
-
-
- -
-
-
- Disable all animations. Useful if you have a slow/old computer.
-
-
- Disable &animations
-
-
-
- -
-
-
- 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.
-
-
- Disable n&otifications on job completion
-
-
-
- -
-
-
- Show the &splash screen at startup
-
-
-
- -
-
-
- Show &tooltips in the book list
-
-
-
- -
-
-
-
-
-
- &Interface font:
-
-
- font_display
-
-
-
- -
-
-
- true
-
-
-
-
-
- -
-
-
- Change &font (needs restart)
-
-
-
- -
-
-
- Toolbar
-
-
-
-
-
-
- -
-
-
- Icon si&ze:
-
-
- opt_toolbar_icon_size
-
-
-
- -
-
-
- -
-
-
- Show &text under icons:
-
-
- opt_toolbar_text
-
-
-
- -
-
-
- Use t&wo lines for the text under the icons (needs restart)
-
-
-
-
-
-
- -
-
-
- Status bar buttons
-
-
-
-
-
-
- Show individual buttons to control the layout of the interface rather than a single button with a popup.
-
-
- Show &layout buttons
-
-
-
- -
-
-
- Show a button that gives quick access to all available actions with a single click.
-
-
- S&how actions button
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 10
- 20
-
-
-
-
-
-
-
- -
-
-
- E&xtra spacing to add between rows in the book list (can be negative):
-
-
- opt_book_list_extra_row_spacing
-
-
-
- -
-
-
- px
-
-
- -20
-
-
-
- -
-
-
- Show &row numbers in the book list
-
-
-
- -
-
-
- Draw a &grid in the book list
-
-
-
- -
-
-
- Allow using &drag and drop to merge books
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
@@ -1377,6 +1030,11 @@ columns". Editing with mouse clicks and the Tab key will be disabled.</p
QWidget
calibre/gui2/preferences/look_feel_tabs.h
+
+ MainInterfaceTab
+ ConfigWidgetBase
+ calibre/gui2/preferences/look_feel_tabs/main_interface.h
+
TbDisplayTab
ConfigWidgetBase
diff --git a/src/calibre/gui2/preferences/look_feel_tabs/main_interface.py b/src/calibre/gui2/preferences/look_feel_tabs/main_interface.py
new file mode 100644
index 0000000000..763bef7122
--- /dev/null
+++ b/src/calibre/gui2/preferences/look_feel_tabs/main_interface.py
@@ -0,0 +1,193 @@
+#!/usr/bin/env python
+
+__license__ = 'GPL v3'
+__copyright__ = '2025, Kovid Goyal '
+__docformat__ = 'restructuredtext en'
+
+
+from qt.core import QApplication, QDialog, QFont, QFontDialog, QFontInfo
+
+from calibre.constants import ismacos, iswindows
+from calibre.gui2 import config, gprefs, icon_resource_manager, qt_app
+from calibre.gui2.preferences import LazyConfigWidgetBase, Setting, set_help_tips
+from calibre.gui2.preferences.look_feel_tabs.main_interface_ui import Ui_Form
+from calibre.gui2.widgets import BusyCursor
+from calibre.utils.config import prefs
+from calibre.utils.localization import available_translations, get_lang, get_language
+
+
+class LanguageSetting(Setting):
+
+ def commit(self):
+ val = self.get_gui_val()
+ oldval = self.get_config_val()
+ if val != oldval:
+ gprefs.set('last_used_language', oldval)
+ return super().commit()
+
+
+class MainInterfaceTab(LazyConfigWidgetBase, Ui_Form):
+
+ def genesis(self, gui):
+ self.gui = gui
+ self.ui_style_available = True
+ if not ismacos and not iswindows:
+ self.label_widget_style.setVisible(False)
+ self.opt_ui_style.setVisible(False)
+ self.ui_style_available = False
+
+ r = self.register
+
+ try:
+ self.icon_theme_title = icon_resource_manager.user_theme_title
+ except Exception:
+ self.icon_theme_title = _('Default icons')
+ self.icon_theme.setText(_('Icon theme: %s') % self.icon_theme_title)
+ self.commit_icon_theme = None
+ self.icon_theme_button.clicked.connect(self.choose_icon_theme)
+
+ r('ui_style', gprefs, restart_required=True, choices=[(_('System default'), 'system'), (_('calibre style'), 'calibre')])
+ r('book_list_tooltips', gprefs)
+ r('dnd_merge', gprefs)
+ r('wrap_toolbar_text', gprefs, restart_required=True)
+ r('show_layout_buttons', gprefs)
+ r('show_sb_all_actions_button', gprefs)
+ # r('show_sb_preference_button', gprefs)
+ r('row_numbers_in_book_list', gprefs)
+ r('cover_corner_radius', gprefs)
+ r('cover_corner_radius_unit', gprefs, choices=[(_('Pixels'), 'px'), (_('Percentage'), '%')])
+ r('book_list_extra_row_spacing', gprefs)
+ r('booklist_grid', gprefs)
+
+ def get_esc_lang(l):
+ if l == 'en':
+ return 'English'
+ return get_language(l)
+
+ lang = get_lang()
+ if lang is None or lang not in available_translations():
+ lang = 'en'
+ items = [(l, get_esc_lang(l)) for l in available_translations()
+ if l != lang]
+ if lang != 'en':
+ items.append(('en', get_esc_lang('en')))
+ items.sort(key=lambda x: x[1].lower())
+ choices = [(y, x) for x, y in items]
+ # Default language is the autodetected one
+ choices = [(get_language(lang), lang)] + choices
+ lul = gprefs.get('last_used_language')
+ if lul and (lul in available_translations() or lul in ('en', 'eng')):
+ choices.insert(1, ((get_language(lul), lul)))
+ r('language', prefs, choices=choices, restart_required=True, setting=LanguageSetting)
+
+ r('disable_animations', config)
+ r('systray_icon', config, restart_required=True)
+ r('show_splash_screen', gprefs)
+ r('disable_tray_notification', config)
+
+ choices = [(_('Off'), 'off'), (_('Small'), 'small'),
+ (_('Medium-small'), 'mid-small'), (_('Medium'), 'medium'), (_('Large'), 'large')]
+ r('toolbar_icon_size', gprefs, choices=choices)
+
+ choices = [(_('If there is enough room'), 'auto'), (_('Always'), 'always'),
+ (_('Never'), 'never')]
+ r('toolbar_text', gprefs, choices=choices)
+
+ self.current_font = self.initial_font = None
+ self.change_font_button.clicked.connect(self.change_font)
+
+ self.opt_ui_style.currentIndexChanged.connect(self.update_color_palette_state)
+ self.opt_gui_layout.addItem(_('Wide'), 'wide')
+ self.opt_gui_layout.addItem(_('Narrow'), 'narrow')
+ self.opt_gui_layout.currentIndexChanged.connect(self.changed_signal)
+ set_help_tips(self.opt_gui_layout, config.help('gui_layout'))
+ self.button_adjust_colors.clicked.connect(self.adjust_colors)
+
+ def lazy_initialize(self):
+ font = gprefs['font']
+ if font is not None:
+ font = list(font)
+ font.append(gprefs.get('font_stretch', QFont.Stretch.Unstretched))
+ self.current_font = self.initial_font = font
+ self.update_font_display()
+ self.update_color_palette_state()
+ self.opt_gui_layout.setCurrentIndex(0 if self.gui.layout_container.is_wide else 1)
+
+ def adjust_colors(self):
+ from calibre.gui2.dialogs.palette import PaletteConfig
+ d = PaletteConfig(self)
+ if d.exec() == QDialog.DialogCode.Accepted:
+ d.apply_settings()
+ self.changed_signal.emit()
+
+ def update_color_palette_state(self):
+ if self.ui_style_available:
+ enabled = self.opt_ui_style.currentData() == 'calibre'
+ self.button_adjust_colors.setEnabled(enabled)
+
+ def choose_icon_theme(self):
+ from calibre.gui2.icon_theme import ChooseTheme
+ d = ChooseTheme(self)
+ if d.exec() == QDialog.DialogCode.Accepted:
+ self.commit_icon_theme = d.commit_changes
+ self.icon_theme_title = d.new_theme_title or _('Default icons')
+ self.icon_theme.setText(_('Icon theme: %s') % self.icon_theme_title)
+ self.changed_signal.emit()
+
+ def build_font_obj(self):
+ font_info = qt_app.original_font if self.current_font is None else self.current_font
+ font = QFont(*(font_info[:4]))
+ font.setStretch(font_info[4])
+ return font
+
+ def change_font(self, *args):
+ fd = QFontDialog(self.build_font_obj(), self)
+ if fd.exec() == QDialog.DialogCode.Accepted:
+ font = fd.selectedFont()
+ fi = QFontInfo(font)
+ self.current_font = [str(fi.family()), fi.pointSize(),
+ fi.weight(), fi.italic(), font.stretch()]
+ self.update_font_display()
+ self.changed_signal.emit()
+
+ def update_font_display(self):
+ font = self.build_font_obj()
+ fi = QFontInfo(font)
+ name = str(fi.family())
+
+ self.font_display.setFont(font)
+ self.font_display.setText(name + f' [{fi.pointSize()}pt]')
+
+ def commit(self):
+ rr = LazyConfigWidgetBase.commit(self)
+ with BusyCursor():
+ if self.current_font != self.initial_font:
+ gprefs['font'] = (self.current_font[:4] if self.current_font else None)
+ gprefs['font_stretch'] = (self.current_font[4] if self.current_font
+ is not None else QFont.Stretch.Unstretched)
+ QApplication.setFont(self.font_display.font())
+ rr = True
+ if self.commit_icon_theme is not None:
+ self.commit_icon_theme()
+ self.gui.layout_container.change_layout(self.gui, self.opt_gui_layout.currentIndex() == 0)
+ return rr
+
+ def restore_defaults(self):
+ LazyConfigWidgetBase.restore_defaults(self)
+ ofont = self.current_font
+ self.current_font = None
+ if ofont is not None:
+ self.changed_signal.emit()
+ self.main_interface_tab.update_font_display()
+ self.opt_gui_layout.setCurrentIndex(0)
+ self.changed_signal.emit()
+
+ def refresh_gui(self, gui):
+ gui.place_layout_buttons()
+ self.update_font_display()
+ gui.library_view.set_row_header_visibility()
+ for view in 'library memory card_a card_b'.split():
+ getattr(gui, view + '_view').set_row_header_visibility()
+ gui.library_view.refresh_row_sizing()
+ gui.sb_all_gui_actions_button.setVisible(gprefs['show_sb_all_actions_button'])
+ # gui.sb_preferences_button.setVisible(gprefs['show_sb_preference_button'])
diff --git a/src/calibre/gui2/preferences/look_feel_tabs/main_interface.ui b/src/calibre/gui2/preferences/look_feel_tabs/main_interface.ui
new file mode 100644
index 0000000000..99a5a5592b
--- /dev/null
+++ b/src/calibre/gui2/preferences/look_feel_tabs/main_interface.ui
@@ -0,0 +1,356 @@
+
+
+ Form
+
+
+ -
+
+
+ User interface style (&needs restart):
+
+
+ opt_ui_style
+
+
+
+ -
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 20
+ 1
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Change &icon theme
+
+
+
+ -
+
+
+ User interface &colors:
+
+
+ button_adjust_colors
+
+
+
+ -
+
+
+ Adjust &colors
+
+
+
+ -
+
+
+ &User interface layout:
+
+
+ opt_gui_layout
+
+
+
+ -
+
+
+
+ 250
+ 16777215
+
+
+
+ QComboBox::AdjustToMinimumContentsLengthWithIcon
+
+
+ 20
+
+
+
+ -
+
+
+ Choose &language (needs restart):
+
+
+ opt_language
+
+
+
+ -
+
+
+ QComboBox::AdjustToMinimumContentsLengthWithIcon
+
+
+ 20
+
+
+
+ -
+
+
+ &Round the corners of covers:
+
+
+ opt_cover_corner_radius
+
+
+
+ -
+
+
-
+
+
+ Round the corners of covers in many places they are displayed such as the Cover grid, Book details panel, etc. Adjust the amount of rounding with this setting. A value of between 5 and 10 looks good with most covers sizes. Zero disables rounding and is the default.
+
+
+ no rounding
+
+
+
+ -
+
+
+ The unit for the cover corner rounding. Either pixel values or as a percentage of the cover size.
+
+
+
+
+
+ -
+
+
+ Enable s&ystem tray icon (needs restart)
+
+
+
+ -
+
+
+ Disable all animations. Useful if you have a slow/old computer.
+
+
+ Disable &animations
+
+
+
+ -
+
+
+ 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.
+
+
+ Disable n&otifications on job completion
+
+
+
+ -
+
+
+ Show the &splash screen at startup
+
+
+
+ -
+
+
+ Show &tooltips in the book list
+
+
+
+ -
+
+
-
+
+
+ &Interface font:
+
+
+ font_display
+
+
+
+ -
+
+
+ true
+
+
+
+
+
+ -
+
+
+ Change &font (needs restart)
+
+
+
+ -
+
+
+ Toolbar
+
+
+
-
+
+
+ -
+
+
+ Icon si&ze:
+
+
+ opt_toolbar_icon_size
+
+
+
+ -
+
+
+ -
+
+
+ Show &text under icons:
+
+
+ opt_toolbar_text
+
+
+
+ -
+
+
+ Use t&wo lines for the text under the icons (needs restart)
+
+
+
+
+
+
+ -
+
+
+ Status bar buttons
+
+
+
-
+
+
+ Show individual buttons to control the layout of the interface rather than a single button with a popup.
+
+
+ Show &layout buttons
+
+
+
+ -
+
+
+ Show a button that gives quick access to all available actions with a single click.
+
+
+ S&how actions button
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 10
+ 20
+
+
+
+
+
+
+
+ -
+
+
+ E&xtra spacing to add between rows in the book list (can be negative):
+
+
+ opt_book_list_extra_row_spacing
+
+
+
+ -
+
+
+ px
+
+
+ -20
+
+
+
+ -
+
+
+ Show &row numbers in the book list
+
+
+
+ -
+
+
+ Draw a &grid in the book list
+
+
+
+ -
+
+
+ Allow using &drag and drop to merge books
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+