mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Ensure that once the tag browser has the focus, Tab and Backtab don't move the focus to another widget.
See https://www.mobileread.com/forums/showthread.php?p=4158532#post4158532
This commit is contained in:
parent
c4d9b25446
commit
a9541405e8
@ -331,13 +331,26 @@ class TagsView(QTreeView): # {{{
|
|||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
# I don't see how current_index can ever be not valid, but ...
|
# I don't see how current_index can ever be not valid, but ...
|
||||||
if self.currentIndex().isValid():
|
if self.currentIndex().isValid():
|
||||||
if (gprefs['tag_browser_allow_keyboard_focus'] and
|
key = event.key()
|
||||||
event.key() == Qt.Key.Key_Return and self.state() != QAbstractItemView.State.EditingState):
|
if gprefs['tag_browser_allow_keyboard_focus']:
|
||||||
|
if key == Qt.Key.Key_Return and self.state() != QAbstractItemView.State.EditingState:
|
||||||
self.toggle_current_index()
|
self.toggle_current_index()
|
||||||
return
|
return
|
||||||
|
# Check if we are moving the focus and we are at the beginning or the
|
||||||
|
# end of the list. The goal is to prevent moving focus away from the
|
||||||
|
# tag browser.
|
||||||
|
on_node = self.model().get_node(self.currentIndex())
|
||||||
|
if key == Qt.Key.Key_Tab:
|
||||||
|
if on_node != self._model.root_item.children[-1]:
|
||||||
|
QTreeView.keyPressEvent(self, event)
|
||||||
|
return
|
||||||
|
if key == Qt.Key.Key_Backtab:
|
||||||
|
if on_node != self._model.root_item.children[0]:
|
||||||
|
QTreeView.keyPressEvent(self, event)
|
||||||
|
return
|
||||||
# If this is an edit request, mark the node to request whether to use VLs
|
# If this is an edit request, mark the node to request whether to use VLs
|
||||||
# As far as I can tell, F2 is used across all platforms
|
# As far as I can tell, F2 is used across all platforms
|
||||||
if event.key() == Qt.Key.Key_F2:
|
if key == Qt.Key.Key_F2:
|
||||||
node = self.model().get_node(self.currentIndex())
|
node = self.model().get_node(self.currentIndex())
|
||||||
if node.type == TagTreeItem.TAG:
|
if node.type == TagTreeItem.TAG:
|
||||||
# Saved search nodes don't use the VL test/dialog
|
# Saved search nodes don't use the VL test/dialog
|
||||||
|
Loading…
x
Reference in New Issue
Block a user