Add bulk shortcut#73
Conversation
…log-darkmode Copilot/fix notification dialog darkmode
Testing revealed that a more minimal approach wasnt working for me. may not be optimal, but works. Disclosure: ChatGPT 5.3 Codex was used for this Commit.
|
Would it be possible to make the Hotkey editable in e.g. the settings window so people can use a combination of their choosing with yours being the default setting? |
There was a problem hiding this comment.
Pull request overview
This PR adds a Browser-level keyboard shortcut to trigger AnkiCollab’s existing “bulk suggest notes” flow, making it accessible without using the context menu.
Changes:
- Added a Browser menu
QActionbound toCtrl+Alt+Bto trigger bulk suggest on the current selection. - Updated the Browser context menu label to display the new shortcut hint.
- Registered the new Browser menu initializer hook.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def add_browser_bulk_suggest_action(browser: Browser) -> None: | ||
| action = QAction("AnkiCollab: Bulk suggest notes", browser) | ||
| action.setShortcut(QKeySequence("Ctrl+Alt+B")) | ||
| action.setShortcutContext(Qt.WidgetWithChildrenShortcut) | ||
| action.triggered.connect(lambda: trigger_bulk_suggest_from_browser(browser)) | ||
| browser.form.menu_Notes.addAction(action) |
There was a problem hiding this comment.
add_browser_bulk_suggest_action() adds the menu/shortcut action even when logged out, unlike other browser menu initializers (e.g., add_browser_menu_item() and context_menu_bulk_suggest()) which early-return when not logged in. Consider adding the same auth_manager.is_logged_in() guard here to avoid exposing non-functional menu items/shortcuts to logged-out users.
| context_menu.addAction( | ||
| "AnkiCollab: Bulk suggest notes", | ||
| "AnkiCollab: Bulk suggest notes\tCtrl+Alt+B", | ||
| lambda: bulk_suggest_handler(browser, nids=selected_nids), | ||
| ) |
There was a problem hiding this comment.
The shortcut string (Ctrl+Alt+B) is now duplicated in two places: embedded in the context menu label and set on the QAction. This can drift over time if the shortcut ever changes. Prefer reusing the same QAction (or a shared constant) for both the menu item and context menu so the displayed shortcut stays consistent automatically.
| action = QAction("AnkiCollab: Bulk suggest notes", browser) | ||
| action.setShortcut(QKeySequence("Ctrl+Alt+B")) | ||
| action.setShortcutContext(Qt.WidgetWithChildrenShortcut) | ||
| action.triggered.connect(lambda: trigger_bulk_suggest_from_browser(browser)) |
There was a problem hiding this comment.
QAction.triggered emits a boolean argument (checked). Connecting it to lambda: ... will raise a TypeError at runtime when the shortcut/action is triggered. Use aqt.qt.qconnect(action.triggered, ...) (as in gear_menu_setup.py) or make the slot accept the checked argument (e.g., lambda _=False: ...).
| action.triggered.connect(lambda: trigger_bulk_suggest_from_browser(browser)) | |
| action.triggered.connect(lambda _checked=False: trigger_bulk_suggest_from_browser(browser)) |
Most definitely, but I'd have to vibecode it / get more familiar with python first and ofc find the time. I'd suggest marking this PR as a draft or closing it while I get on that. |
Added new function for a bulk suggestoin keyboard shortcut.
Testing revealed that a more minimal approach wasnt working for me. may not be optimal, but works.
Disclosure: ChatGPT 5.3 Codex was used for this Commit.