Make Virtual Library tabs lockable (no close button)

This commit is contained in:
Serized 2018-01-20 10:38:06 +01:00
parent 8ab7330b17
commit 0d38679313
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['closable_tabs'] = 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['closable_tabs'])
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['closable_tabs'] = False
self.setTabsClosable(False)
def unlock_tab(self):
gprefs['closable_tabs'] = 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['closable_tabs']:
m.addAction(_('Lock virtual library tabs'), self.lock_tab)
if not gprefs['closable_tabs']:
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 '')