mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Merge pull request #1035 from BlueGreenMagick/sidebar-on-click-index
change _on_click_current to _on_click_index
This commit is contained in:
commit
83c8d53da2
2 changed files with 6 additions and 5 deletions
|
@ -35,7 +35,7 @@ zjosua <zjosua@hotmail.com>
|
||||||
Arthur Milchior <arthur@milchior.fr>
|
Arthur Milchior <arthur@milchior.fr>
|
||||||
Yngve Hoiseth <yngve@hoiseth.net>
|
Yngve Hoiseth <yngve@hoiseth.net>
|
||||||
Ijgnd
|
Ijgnd
|
||||||
Yoonchae Lee
|
Yoonchae Lee <bluegreenmagick@gmail.com>
|
||||||
Evandro Coan <github.com/evandrocoan>
|
Evandro Coan <github.com/evandrocoan>
|
||||||
Alan Du <alanhdu@gmail.com>
|
Alan Du <alanhdu@gmail.com>
|
||||||
Yuchen Lei <lyc@xuming.studio>
|
Yuchen Lei <lyc@xuming.studio>
|
||||||
|
|
|
@ -442,11 +442,13 @@ class SidebarTreeView(QTreeView):
|
||||||
def mouseReleaseEvent(self, event: QMouseEvent) -> None:
|
def mouseReleaseEvent(self, event: QMouseEvent) -> None:
|
||||||
super().mouseReleaseEvent(event)
|
super().mouseReleaseEvent(event)
|
||||||
if event.button() == Qt.LeftButton:
|
if event.button() == Qt.LeftButton:
|
||||||
self._on_click_current()
|
idx = self.indexAt(event.pos())
|
||||||
|
self._on_click_index(idx)
|
||||||
|
|
||||||
def keyPressEvent(self, event: QKeyEvent) -> None:
|
def keyPressEvent(self, event: QKeyEvent) -> None:
|
||||||
if event.key() in (Qt.Key_Return, Qt.Key_Enter):
|
if event.key() in (Qt.Key_Return, Qt.Key_Enter):
|
||||||
self._on_click_current()
|
idx = self.currentIndex()
|
||||||
|
self._on_click_index(idx)
|
||||||
else:
|
else:
|
||||||
super().keyPressEvent(event)
|
super().keyPressEvent(event)
|
||||||
|
|
||||||
|
@ -516,8 +518,7 @@ class SidebarTreeView(QTreeView):
|
||||||
self.browser.editor.saveNow(on_save)
|
self.browser.editor.saveNow(on_save)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _on_click_current(self) -> None:
|
def _on_click_index(self, idx: QModelIndex) -> None:
|
||||||
idx = self.currentIndex()
|
|
||||||
if item := self.model().item_for_index(idx):
|
if item := self.model().item_for_index(idx):
|
||||||
if item.on_click:
|
if item.on_click:
|
||||||
item.on_click()
|
item.on_click()
|
||||||
|
|
Loading…
Reference in a new issue