The cover browser position option with the "auto" choice.

This commit is contained in:
Charles Haley 2024-01-07 11:28:23 +00:00
parent 3f35571f8d
commit 9f2045c3ba
4 changed files with 70 additions and 20 deletions

View File

@ -426,6 +426,7 @@ def create_defs():
defs['show_links_in_tag_browser'] = False defs['show_links_in_tag_browser'] = False
defs['show_notes_in_tag_browser'] = False defs['show_notes_in_tag_browser'] = False
defs['icons_on_right_in_tag_browser'] = True defs['icons_on_right_in_tag_browser'] = True
defs['cover_browser_narrow_view_position'] = 'automatic'
def migrate_tweak(tweak_name, pref_name): def migrate_tweak(tweak_name, pref_name):
# If the tweak has been changed then leave the tweak in the file so # If the tweak has been changed then leave the tweak in the file so

View File

@ -365,12 +365,26 @@ class CentralContainer(QWidget):
self.top_handle = h(Qt.Orientation.Horizontal) self.top_handle = h(Qt.Orientation.Horizontal)
self.bottom_handle = h(Qt.Orientation.Horizontal) self.bottom_handle = h(Qt.Orientation.Horizontal)
_last_cb_position = None
@property @property
def narrow_cb_on_top(self): def narrow_cb_on_top(self):
from calibre.gui2.ui import get_gui from calibre.gui2 import gui_prefs
gui = get_gui() prefs = gui_prefs()
ratio = self.width() / self.height() if gui is None else gui.width() / gui.height() p = self._last_cb_position = prefs['cover_browser_narrow_view_position']
return ratio <= 1.4 if p == 'automatic':
from calibre.gui2.ui import get_gui
gui = get_gui()
ratio = self.width() / self.height() if gui is None else gui.width() / gui.height()
return ratio <= 1.4
return bool(self._last_cb_position == 'on_top')
@property
def cb_on_top_changed(self):
from calibre.gui2 import gui_prefs
prefs = gui_prefs()
return (self._last_cb_position is None or
prefs['cover_browser_narrow_view_position'] != self._last_cb_position)
@property @property
def is_visible(self): def is_visible(self):
@ -404,7 +418,7 @@ class CentralContainer(QWidget):
def change_layout(self, gui, is_wide): def change_layout(self, gui, is_wide):
layout = Layout.wide if is_wide else Layout.narrow layout = Layout.wide if is_wide else Layout.narrow
if layout is self.layout: if layout is self.layout and not self.cb_on_top_changed:
return False return False
ss = self.serialized_settings() ss = self.serialized_settings()
before = ss[self.layout.name + '_visibility'] before = ss[self.layout.name + '_visibility']

View File

@ -610,6 +610,10 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('cover_flow_queue_length', config, restart_required=True) r('cover_flow_queue_length', config, restart_required=True)
r('cover_browser_reflections', gprefs) r('cover_browser_reflections', gprefs)
r('cover_browser_narrow_view_position', gprefs,
choices=[(_('Automatic'), 'automatic'), # Automatic must be first
(_('On top'), 'on_top'),
(_('On right'), 'on_right')])
r('cover_browser_title_template', db.prefs) r('cover_browser_title_template', db.prefs)
fm = db.field_metadata fm = db.field_metadata
r('cover_browser_subtitle_field', db.prefs, choices=[(_('No subtitle'), 'none')] + sorted( r('cover_browser_subtitle_field', db.prefs, choices=[(_('No subtitle'), 'none')] + sorted(
@ -836,6 +840,15 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
self.opt_gui_layout.addItem(_('Narrow'), 'narrow') self.opt_gui_layout.addItem(_('Narrow'), 'narrow')
self.opt_gui_layout.currentIndexChanged.connect(self.changed_signal) self.opt_gui_layout.currentIndexChanged.connect(self.changed_signal)
set_help_tips(self.opt_gui_layout, config.help('gui_layout')) set_help_tips(self.opt_gui_layout, config.help('gui_layout'))
self.opt_gui_layout.currentIndexChanged.connect(self.gui_layout_changed)
def set_cover_browser_position_enabled(self, is_wide):
self.opt_cover_browser_narrow_view_position.setEnabled(not is_wide)
if is_wide:
self.opt_cover_browser_narrow_view_position.setCurrentIndex(0)
def gui_layout_changed(self, dex):
self.set_cover_browser_position_enabled(dex == 0) #0 == wide
def initial_tab_changed(self): def initial_tab_changed(self):
self.sections_view.setCurrentRow(self.tabWidget.currentIndex()) self.sections_view.setCurrentRow(self.tabWidget.currentIndex())
@ -1044,6 +1057,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
self.tb_focus_label.setVisible(self.opt_tag_browser_allow_keyboard_focus.isChecked()) self.tb_focus_label.setVisible(self.opt_tag_browser_allow_keyboard_focus.isChecked())
self.update_color_palette_state() self.update_color_palette_state()
self.opt_gui_layout.setCurrentIndex(0 if self.gui.layout_container.is_wide else 1) self.opt_gui_layout.setCurrentIndex(0 if self.gui.layout_container.is_wide else 1)
self.set_cover_browser_position_enabled(self.gui.layout_container.is_wide)
def open_cg_cache(self): def open_cg_cache(self):
open_local_file(self.gui.grid_view.thumbnail_cache.location) open_local_file(self.gui.grid_view.thumbnail_cache.location)

View File

@ -1846,7 +1846,7 @@ that don't have children.&lt;/p&gt;</string>
<string>Cover &amp;browser</string> <string>Cover &amp;browser</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_11"> <layout class="QGridLayout" name="gridLayout_11">
<item row="1" column="0"> <item row="0" column="1" colspan="2">
<widget class="QCheckBox" name="opt_cb_fullscreen"> <widget class="QCheckBox" name="opt_cb_fullscreen">
<property name="text"> <property name="text">
<string>When showing in a separate window, show it &amp;fullscreen</string> <string>When showing in a separate window, show it &amp;fullscreen</string>
@ -1860,11 +1860,11 @@ that don't have children.&lt;/p&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1" colspan="2"> <item row="7" column="1" colspan="2">
<widget class="QSpinBox" name="opt_cover_flow_queue_length"/> <widget class="QSpinBox" name="opt_cover_flow_queue_length"/>
</item> </item>
<item row="3" column="0"> <item row="7" column="0">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_61">
<property name="text"> <property name="text">
<string>&amp;Number of covers to show in browse mode (needs restart):</string> <string>&amp;Number of covers to show in browse mode (needs restart):</string>
</property> </property>
@ -1873,7 +1873,7 @@ that don't have children.&lt;/p&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="2"> <item row="8" column="2">
<widget class="QPushButton" name="cover_browser_title_template_button"> <widget class="QPushButton" name="cover_browser_title_template_button">
<property name="text"> <property name="text">
<string>Template &amp;editor</string> <string>Template &amp;editor</string>
@ -1893,7 +1893,7 @@ that don't have children.&lt;/p&gt;</string>
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="7" column="1"> <item row="8" column="1">
<widget class="QLineEdit" name="opt_cover_browser_title_template"> <widget class="QLineEdit" name="opt_cover_browser_title_template">
<property name="toolTip"> <property name="toolTip">
<string>&lt;p&gt;The template used to generate the text below the covers. This template uses <string>&lt;p&gt;The template used to generate the text below the covers. This template uses
@ -1904,14 +1904,14 @@ empty template for no text.&lt;/p&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="3"> <item row="4" column="0">
<widget class="QCheckBox" name="opt_cover_browser_reflections"> <widget class="QCheckBox" name="opt_cover_browser_reflections">
<property name="text"> <property name="text">
<string>Show &amp;reflections</string> <string>Show &amp;reflections</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="3"> <item row="4" column="1" colspan="2">
<widget class="QCheckBox" name="opt_cb_preserve_aspect_ratio"> <widget class="QCheckBox" name="opt_cb_preserve_aspect_ratio">
<property name="toolTip"> <property name="toolTip">
<string>Show covers in their original aspect ratio instead of resizing <string>Show covers in their original aspect ratio instead of resizing
@ -1922,10 +1922,31 @@ them to all have the same width and height</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1" colspan="2"> <item row="6" column="0">
<widget class="QLabel" name="label_987">
<property name="text">
<string>Cover browser &amp;position in the narrow layout:</string>
</property>
<property name="toolTip">
<string>&lt;p&gt;This option controls the position of the cover browser when
using the Narrow user interface layout. "Automatic" will place the cover browser
on top or on the right of the book list depending on the aspect ratio of the
calibre window. "On top" places it over the book list, and "On right" places it
to the right of the book list. This option cannot be changed when using the
Wide user interface layout.&lt;/p&gt;</string>
</property>
<property name="buddy">
<cstring>opt_cover_browser_narrow_view_position</cstring>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2">
<widget class="QComboBox" name="opt_cover_browser_narrow_view_position"/>
</item>
<item row="9" column="1" colspan="2">
<widget class="QComboBox" name="opt_cover_browser_subtitle_field"/> <widget class="QComboBox" name="opt_cover_browser_subtitle_field"/>
</item> </item>
<item row="7" column="0"> <item row="8" column="0">
<widget class="QLabel" name="label_23"> <widget class="QLabel" name="label_23">
<property name="text"> <property name="text">
<string>&amp;Template for caption:</string> <string>&amp;Template for caption:</string>
@ -1935,7 +1956,7 @@ them to all have the same width and height</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0"> <item row="9" column="0">
<widget class="QLabel" name="label_24"> <widget class="QLabel" name="label_24">
<property name="text"> <property name="text">
<string>Fie&amp;ld for sub-title:</string> <string>Fie&amp;ld for sub-title:</string>
@ -1945,7 +1966,7 @@ them to all have the same width and height</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="1" column="1" colspan="2">
<widget class="QLabel" name="fs_help_msg"> <widget class="QLabel" name="fs_help_msg">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">margin-left: 1.5em</string> <string notr="true">margin-left: 1.5em</string>
@ -1958,7 +1979,7 @@ them to all have the same width and height</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0"> <item row="10" column="0">
<widget class="QLabel" name="label_26"> <widget class="QLabel" name="label_26">
<property name="text"> <property name="text">
<string>Show ne&amp;xt cover during auto scroll after:</string> <string>Show ne&amp;xt cover during auto scroll after:</string>
@ -1968,7 +1989,7 @@ them to all have the same width and height</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="1"> <item row="10" column="1">
<widget class="QDoubleSpinBox" name="opt_books_autoscroll_time"> <widget class="QDoubleSpinBox" name="opt_books_autoscroll_time">
<property name="suffix"> <property name="suffix">
<string> seconds</string> <string> seconds</string>
@ -1984,7 +2005,7 @@ them to all have the same width and height</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="2"> <item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="opt_cb_double_click_to_activate"> <widget class="QCheckBox" name="opt_cb_double_click_to_activate">
<property name="text"> <property name="text">
<string>&amp;Double click to view the central book, instead of single click</string> <string>&amp;Double click to view the central book, instead of single click</string>