diff --git a/src/calibre/gui2/central.py b/src/calibre/gui2/central.py index 7c09c5086f..9a4bdb6093 100644 --- a/src/calibre/gui2/central.py +++ b/src/calibre/gui2/central.py @@ -365,26 +365,21 @@ class CentralContainer(QWidget): self.top_handle = h(Qt.Orientation.Horizontal) self.bottom_handle = h(Qt.Orientation.Horizontal) - _last_cb_position = None + _last_cb_position = gui = None @property def narrow_cb_on_top(self): - from calibre.gui2 import gui_prefs - prefs = gui_prefs() - p = self._last_cb_position = prefs['cover_browser_narrow_view_position'] + p = self._last_cb_position = gprefs['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() + gui = self.gui or self + ratio = gui.width() / gui.height() return ratio <= 1.4 - return bool(self._last_cb_position == 'on_top') + return p == '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) + gprefs['cover_browser_narrow_view_position'] != self._last_cb_position) @property def is_visible(self): @@ -398,6 +393,7 @@ class CentralContainer(QWidget): w.setParent(self) def initialize_with_gui(self, gui, book_list_widget): + self.gui = gui self.tag_browser_button.initialize_with_gui(gui) self.book_details_button.initialize_with_gui(gui) self.cover_browser_button.initialize_with_gui(gui) @@ -597,10 +593,8 @@ class CentralContainer(QWidget): self.update() def toggle_layout(self): - from calibre.gui2.ui import get_gui - gui = get_gui() - if gui: - self.change_layout(gui, self.layout is Layout.narrow) + if self.gui: + self.change_layout(self.gui, self.layout is Layout.narrow) else: self.layout = Layout.narrow if self.layout is Layout.wide else Layout.wide self.relayout() diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index 7b9d91fd32..0dc9d527e2 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -840,15 +840,6 @@ 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()) @@ -1057,7 +1048,11 @@ 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) + set_help_tips(self.opt_cover_browser_narrow_view_position, _( + '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.')) 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 94660e18da..a3c4173f0b 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -1927,14 +1927,6 @@ 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