experiment with using right click for AND/OR/NOT
This frees up Ctrl/Shift+left click to behave like in a typical GUI app. On a Mac users can either two finger click, or Command+click in conjunction with one of the other modifiers. https://github.com/ankitects/anki/issues/1011
This commit is contained in:
parent
68c4b10dcd
commit
9048a1ff3c
@ -274,8 +274,7 @@ class SidebarTreeView(QTreeView):
|
||||
self.col = self.mw.col
|
||||
self.current_search: Optional[str] = None
|
||||
|
||||
self.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||
self.customContextMenuRequested.connect(self.onContextMenu) # type: ignore
|
||||
self.setContextMenuPolicy(Qt.PreventContextMenu)
|
||||
self.context_menus: Dict[SidebarItemType, Sequence[Tuple[str, Callable]]] = {
|
||||
SidebarItemType.DECK: (
|
||||
(tr(TR.ACTIONS_RENAME), self.rename_deck),
|
||||
@ -407,7 +406,13 @@ class SidebarTreeView(QTreeView):
|
||||
def mouseReleaseEvent(self, event: QMouseEvent) -> None:
|
||||
super().mouseReleaseEvent(event)
|
||||
if event.button() == Qt.LeftButton:
|
||||
if not self._keyboard_modified_pressed():
|
||||
self._on_click_current()
|
||||
elif event.button() == Qt.RightButton:
|
||||
if self._keyboard_modified_pressed():
|
||||
self._on_click_current()
|
||||
else:
|
||||
self.onContextMenu(event.pos())
|
||||
|
||||
def keyPressEvent(self, event: QKeyEvent) -> None:
|
||||
if event.key() in (Qt.Key_Return, Qt.Key_Enter):
|
||||
@ -415,6 +420,10 @@ class SidebarTreeView(QTreeView):
|
||||
else:
|
||||
super().keyPressEvent(event)
|
||||
|
||||
def _keyboard_modified_pressed(self) -> bool:
|
||||
mods = self.mw.app.keyboardModifiers()
|
||||
return bool(mods & (Qt.ShiftModifier | Qt.AltModifier | Qt.ControlModifier))
|
||||
|
||||
###########
|
||||
|
||||
def handle_drag_drop(self, sources: List[SidebarItem], target: SidebarItem) -> bool:
|
||||
|
Loading…
Reference in New Issue
Block a user