diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 7332ddf56b..913d7b0622 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -426,6 +426,7 @@ def create_defs(): defs['show_links_in_tag_browser'] = False defs['show_notes_in_tag_browser'] = False defs['icons_on_right_in_tag_browser'] = True + defs['cover_browser_narrow_view_position'] = 'automatic' def migrate_tweak(tweak_name, pref_name): # If the tweak has been changed then leave the tweak in the file so diff --git a/src/calibre/gui2/central.py b/src/calibre/gui2/central.py index 9fdb13e0e4..7c09c5086f 100644 --- a/src/calibre/gui2/central.py +++ b/src/calibre/gui2/central.py @@ -365,12 +365,26 @@ class CentralContainer(QWidget): self.top_handle = h(Qt.Orientation.Horizontal) self.bottom_handle = h(Qt.Orientation.Horizontal) + _last_cb_position = None + @property def narrow_cb_on_top(self): - 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 + from calibre.gui2 import gui_prefs + prefs = gui_prefs() + p = self._last_cb_position = prefs['cover_browser_narrow_view_position'] + 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 def is_visible(self): @@ -404,7 +418,7 @@ class CentralContainer(QWidget): def change_layout(self, gui, is_wide): 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 ss = self.serialized_settings() before = ss[self.layout.name + '_visibility'] diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index 4fd18c28e4..7b9d91fd32 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -610,6 +610,10 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): r('cover_flow_queue_length', config, restart_required=True) 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) fm = db.field_metadata 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.currentIndexChanged.connect(self.changed_signal) 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): 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.update_color_palette_state() 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): open_local_file(self.gui.grid_view.thumbnail_cache.location) diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index f3217b86f6..94660e18da 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -1846,7 +1846,7 @@ that don't have children.</p> Cover &browser - + When showing in a separate window, show it &fullscreen @@ -1860,11 +1860,11 @@ that don't have children.</p> - + - - + + &Number of covers to show in browse mode (needs restart): @@ -1873,7 +1873,7 @@ that don't have children.</p> - + Template &editor @@ -1893,7 +1893,7 @@ that don't have children.</p> - + <p>The template used to generate the text below the covers. This template uses @@ -1904,14 +1904,14 @@ empty template for no text.</p> - + Show &reflections - + Show covers in their original aspect ratio instead of resizing @@ -1922,10 +1922,31 @@ them to all have the same width and height - + + + + Cover browser &position in the narrow layout: + + + <p>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.</p> + + + opt_cover_browser_narrow_view_position + + + + + + + - + &Template for caption: @@ -1935,7 +1956,7 @@ them to all have the same width and height - + Fie&ld for sub-title: @@ -1945,7 +1966,7 @@ them to all have the same width and height - + margin-left: 1.5em @@ -1958,7 +1979,7 @@ them to all have the same width and height - + Show ne&xt cover during auto scroll after: @@ -1968,7 +1989,7 @@ them to all have the same width and height - + seconds @@ -1984,7 +2005,7 @@ them to all have the same width and height - + &Double click to view the central book, instead of single click