Do not show the virtual libraries tab bar when no virtual libraries are present. See #1988609 ([Enhancement] VL Toolbar/Menu options)

This commit is contained in:
Kovid Goyal 2022-09-14 12:33:18 +05:30
parent d4ebabcdd5
commit b8366228fb
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 12 additions and 8 deletions

View File

@ -400,7 +400,7 @@ class VLTabs(QTabBar): # {{{
self.currentChanged.connect(self.tab_changed) self.currentChanged.connect(self.tab_changed)
self.tabMoved.connect(self.tab_moved, type=Qt.ConnectionType.QueuedConnection) self.tabMoved.connect(self.tab_moved, type=Qt.ConnectionType.QueuedConnection)
self.tabCloseRequested.connect(self.tab_close) self.tabCloseRequested.connect(self.tab_close)
self.setVisible(gprefs['show_vl_tabs']) self.update_visibility()
self.next_action = a = QAction(self) self.next_action = a = QAction(self)
a.triggered.connect(partial(self.next_tab, delta=1)), self.gui.addAction(a) a.triggered.connect(partial(self.next_tab, delta=1)), self.gui.addAction(a)
self.previous_action = a = QAction(self) self.previous_action = a = QAction(self)
@ -421,14 +421,17 @@ class VLTabs(QTabBar): # {{{
idx = (self.currentIndex() + delta) % self.count() idx = (self.currentIndex() + delta) % self.count()
self.setCurrentIndex(idx) self.setCurrentIndex(idx)
def update_visibility(self):
self.setVisible(gprefs['show_vl_tabs'] and self.count() > 1)
def enable_bar(self): def enable_bar(self):
gprefs['show_vl_tabs'] = True gprefs['show_vl_tabs'] = True
self.setVisible(True) self.update_visibility()
self.gui.set_number_of_books_shown() self.gui.set_number_of_books_shown()
def disable_bar(self): def disable_bar(self):
gprefs['show_vl_tabs'] = False gprefs['show_vl_tabs'] = False
self.setVisible(False) self.update_visibility()
self.gui.set_number_of_books_shown() self.gui.set_number_of_books_shown()
def lock_tab(self): def lock_tab(self):
@ -515,6 +518,7 @@ class VLTabs(QTabBar): # {{{
# On some OS X machines (using native style) the tab button is # On some OS X machines (using native style) the tab button is
# on the left # on the left
pass pass
self.update_visibility()
def update_current(self): def update_current(self):
self.rebuild() self.rebuild()

View File

@ -397,11 +397,11 @@ class SearchRestrictionMixin:
m.addMenu(a).setIcon(QIcon.ic('minus.png')) m.addMenu(a).setIcon(QIcon.ic('minus.png'))
m.addAction(QIcon.ic('toc.png'), _('Quick select Virtual library'), self.choose_vl_triggerred) m.addAction(QIcon.ic('toc.png'), _('Quick select Virtual library'), self.choose_vl_triggerred)
if add_tabs_action: if add_tabs_action:
if gprefs['show_vl_tabs']: if gprefs['show_vl_tabs']:
m.addAction(_('Hide Virtual library tabs'), self.vl_tabs.disable_bar) m.addAction(_('Hide Virtual library tabs'), self.vl_tabs.disable_bar)
else: else:
m.addAction(_('Show Virtual libraries as tabs'), self.vl_tabs.enable_bar) m.addAction(_('Show Virtual libraries as tabs'), self.vl_tabs.enable_bar)
m.addSeparator() m.addSeparator()