mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Cleanup previous PR
We dont disable the preference as now the layout is dynamically switchable via keyboard shortcut, so it is conceivable the user might want to set that preference even when the current layout is Wide.
This commit is contained in:
parent
fb3e6c4c3b
commit
140ea63f8c
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -1927,14 +1927,6 @@ them to all have the same width and height</string>
|
||||
<property name="text">
|
||||
<string>Cover browser &position in the narrow layout:</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_cover_browser_narrow_view_position</cstring>
|
||||
</property>
|
||||
|
Loading…
x
Reference in New Issue
Block a user