Fix #1503910 [Cmd+T doesn't toggle TOC back off when in window mode](https://bugs.launchpad.net/calibre/+bug/1503910)

This commit is contained in:
Kovid Goyal 2015-10-09 17:29:19 +05:30
parent 581ecb67b1
commit c5fb9e75de
2 changed files with 19 additions and 0 deletions

View File

@ -138,6 +138,17 @@ class EbookViewer(MainWindow):
self.search.focus_to_library.connect(lambda: self.view.setFocus(Qt.OtherFocusReason))
self.toc.pressed[QModelIndex].connect(self.toc_clicked)
self.toc.searched.connect(partial(self.toc_clicked, force=True))
def toggle_toc(ev):
try:
key = self.view.shortcuts.get_match(ev)
except AttributeError:
pass
if key == 'Table of Contents':
ev.accept()
self.action_table_of_contents.trigger()
return True
return False
self.toc.handle_shortcuts = toggle_toc
self.reference.goto.connect(self.goto)
self.bookmarks.edited.connect(self.bookmarks_edited)
self.bookmarks.activated.connect(self.goto_bookmark)

View File

@ -95,6 +95,14 @@ class TOCView(QTreeView):
m.addAction(_('Collapse all items'), self.collapseAll)
m.exec_(self.mapToGlobal(pos))
def keyPressEvent(self, event):
try:
if self.handle_shortcuts(event):
return
except AttributeError:
pass
return QTreeView.keyPressEvent(self, event)
class TOCSearch(QWidget):
def __init__(self, toc_view, parent=None):