Allow removing the close button from tabs in the Virtual library tab bar. Right click the tab bar and choose "Lock tabs" to do that.

Merge branch 'master' of https://github.com/Serized/calibre
This commit is contained in:
Kovid Goyal 2018-01-21 08:19:32 +05:30
commit 80599a0425
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 23 additions and 1 deletions

View File

@ -139,6 +139,7 @@ def create_defs():
defs['cover_grid_show_title'] = False defs['cover_grid_show_title'] = False
defs['cover_grid_texture'] = None defs['cover_grid_texture'] = None
defs['show_vl_tabs'] = False defs['show_vl_tabs'] = False
defs['vl_tabs_closable'] = True
defs['show_highlight_toggle_button'] = False defs['show_highlight_toggle_button'] = False
defs['add_comments_to_email'] = False defs['add_comments_to_email'] = False
defs['cb_preserve_aspect_ratio'] = False defs['cb_preserve_aspect_ratio'] = False

View File

@ -396,7 +396,7 @@ class VLTabs(QTabBar): # {{{
self.setDocumentMode(True) self.setDocumentMode(True)
self.setDrawBase(False) self.setDrawBase(False)
self.setMovable(True) self.setMovable(True)
self.setTabsClosable(True) self.setTabsClosable(gprefs['vl_tabs_closable'])
self.gui = parent self.gui = parent
self.ignore_tab_changed = False self.ignore_tab_changed = False
self.currentChanged.connect(self.tab_changed) self.currentChanged.connect(self.tab_changed)
@ -432,6 +432,23 @@ class VLTabs(QTabBar): # {{{
gprefs['show_vl_tabs'] = False gprefs['show_vl_tabs'] = False
self.setVisible(False) self.setVisible(False)
def lock_tab(self):
gprefs['vl_tabs_closable'] = False
self.setTabsClosable(False)
def unlock_tab(self):
gprefs['vl_tabs_closable'] = True
self.setTabsClosable(True)
try:
self.tabButton(0, self.RightSide).setVisible(False)
except AttributeError:
try:
self.tabButton(0, self.LeftSide).setVisible(False)
except AttributeError:
# On some OS X machines (using native style) the tab button is
# on the left
pass
def tab_changed(self, idx): def tab_changed(self, idx):
if self.ignore_tab_changed: if self.ignore_tab_changed:
return return
@ -512,6 +529,10 @@ class VLTabs(QTabBar): # {{{
for x in hidden: for x in hidden:
s.addAction(x, partial(self.restore, x)) s.addAction(x, partial(self.restore, x))
m.addAction(_('Hide virtual library tabs'), self.disable_bar) m.addAction(_('Hide virtual library tabs'), self.disable_bar)
if gprefs['vl_tabs_closable']:
m.addAction(_('Lock virtual library tabs'), self.lock_tab)
else:
m.addAction(_('Unlock virtual library tabs'), self.unlock_tab)
i = self.tabAt(ev.pos()) i = self.tabAt(ev.pos())
if i > -1: if i > -1:
vl = unicode(self.tabData(i) or '') vl = unicode(self.tabData(i) or '')