mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Add Create Copy to reviewer and use current card's deck (#1569)
* Use deck of current card when copying note * Add Create Copy to reviewer menu * Add ellipsis to Set Due Date
This commit is contained in:
parent
2df3698e8c
commit
30dc2cf7ea
3 changed files with 26 additions and 6 deletions
|
@ -1,6 +1,8 @@
|
||||||
# Copyright: Ankitects Pty Ltd and contributors
|
# Copyright: Ankitects Pty Ltd and contributors
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Callable, Optional
|
from typing import Callable, Optional
|
||||||
|
|
||||||
import aqt.editor
|
import aqt.editor
|
||||||
|
@ -54,12 +56,12 @@ class AddCards(QMainWindow):
|
||||||
gui_hooks.add_cards_did_init(self)
|
gui_hooks.add_cards_did_init(self)
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def set_note(self, note: Note) -> None:
|
def set_note(self, note: Note, deck_id: DeckId | None = None) -> None:
|
||||||
"""Set tags, field contents and notetype (and its deck)
|
"""Set tags, field contents and notetype according to `note`. Deck is set
|
||||||
according to `note`.
|
to `deck_id` or the deck last used with the notetype.
|
||||||
"""
|
"""
|
||||||
self.notetype_chooser.selected_notetype_id = note.mid
|
self.notetype_chooser.selected_notetype_id = note.mid
|
||||||
if deck_id := self.col.default_deck_for_notetype(note.mid):
|
if deck_id or (deck_id := self.col.default_deck_for_notetype(note.mid)):
|
||||||
self.deck_chooser.selected_deck_id = deck_id
|
self.deck_chooser.selected_deck_id = deck_id
|
||||||
|
|
||||||
new_note = self._new_note()
|
new_note = self._new_note()
|
||||||
|
|
|
@ -591,7 +591,8 @@ class Browser(QMainWindow):
|
||||||
|
|
||||||
def on_create_copy(self) -> None:
|
def on_create_copy(self) -> None:
|
||||||
if note := self.table.get_current_note():
|
if note := self.table.get_current_note():
|
||||||
aqt.dialogs.open("AddCards", self.mw).set_note(note)
|
deck_id = self.table.get_current_card().did
|
||||||
|
aqt.dialogs.open("AddCards", self.mw).set_note(note, deck_id)
|
||||||
|
|
||||||
@no_arg_trigger
|
@no_arg_trigger
|
||||||
@skip_if_selection_is_empty
|
@skip_if_selection_is_empty
|
||||||
|
|
|
@ -13,6 +13,7 @@ from dataclasses import dataclass
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
from typing import Any, Callable, Literal, Match, Sequence, cast
|
from typing import Any, Callable, Literal, Match, Sequence, cast
|
||||||
|
|
||||||
|
import aqt
|
||||||
from anki import hooks
|
from anki import hooks
|
||||||
from anki.cards import Card, CardId
|
from anki.cards import Card, CardId
|
||||||
from anki.collection import Config, OpChanges, OpChangesWithCount
|
from anki.collection import Config, OpChanges, OpChangesWithCount
|
||||||
|
@ -458,6 +459,7 @@ class Reviewer:
|
||||||
("-", self.bury_current_card),
|
("-", self.bury_current_card),
|
||||||
("!", self.suspend_current_note),
|
("!", self.suspend_current_note),
|
||||||
("@", self.suspend_current_card),
|
("@", self.suspend_current_card),
|
||||||
|
("Ctrl+Alt+E", self.on_create_copy),
|
||||||
("Ctrl+Delete", self.delete_current_note),
|
("Ctrl+Delete", self.delete_current_note),
|
||||||
("Ctrl+Shift+D", self.on_set_due),
|
("Ctrl+Shift+D", self.on_set_due),
|
||||||
("v", self.onReplayRecorded),
|
("v", self.onReplayRecorded),
|
||||||
|
@ -913,7 +915,11 @@ time = %(time)d;
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
[tr.studying_bury_card(), "-", self.bury_current_card],
|
[tr.studying_bury_card(), "-", self.bury_current_card],
|
||||||
[tr.actions_set_due_date(), "Ctrl+Shift+D", self.on_set_due],
|
[
|
||||||
|
tr.actions_with_ellipsis(action=tr.actions_set_due_date()),
|
||||||
|
"Ctrl+Shift+D",
|
||||||
|
self.on_set_due,
|
||||||
|
],
|
||||||
[tr.actions_suspend_card(), "@", self.suspend_current_card],
|
[tr.actions_suspend_card(), "@", self.suspend_current_card],
|
||||||
[tr.actions_options(), "O", self.onOptions],
|
[tr.actions_options(), "O", self.onOptions],
|
||||||
[tr.actions_card_info(), "I", self.on_card_info],
|
[tr.actions_card_info(), "I", self.on_card_info],
|
||||||
|
@ -922,6 +928,11 @@ time = %(time)d;
|
||||||
[tr.studying_mark_note(), "*", self.toggle_mark_on_current_note],
|
[tr.studying_mark_note(), "*", self.toggle_mark_on_current_note],
|
||||||
[tr.studying_bury_note(), "=", self.bury_current_note],
|
[tr.studying_bury_note(), "=", self.bury_current_note],
|
||||||
[tr.studying_suspend_note(), "!", self.suspend_current_note],
|
[tr.studying_suspend_note(), "!", self.suspend_current_note],
|
||||||
|
[
|
||||||
|
tr.actions_with_ellipsis(action=tr.actions_create_copy()),
|
||||||
|
"Ctrl+Alt+E",
|
||||||
|
self.on_create_copy,
|
||||||
|
],
|
||||||
[tr.studying_delete_note(), "Ctrl+Delete", self.delete_current_note],
|
[tr.studying_delete_note(), "Ctrl+Delete", self.delete_current_note],
|
||||||
None,
|
None,
|
||||||
[tr.actions_replay_audio(), "R", self.replayAudio],
|
[tr.actions_replay_audio(), "R", self.replayAudio],
|
||||||
|
@ -1042,6 +1053,12 @@ time = %(time)d;
|
||||||
lambda res: tooltip(tr.studying_cards_buried(count=res.count))
|
lambda res: tooltip(tr.studying_cards_buried(count=res.count))
|
||||||
).run_in_background()
|
).run_in_background()
|
||||||
|
|
||||||
|
def on_create_copy(self) -> None:
|
||||||
|
if self.card:
|
||||||
|
aqt.dialogs.open("AddCards", self.mw).set_note(
|
||||||
|
self.card.note(), self.card.did
|
||||||
|
)
|
||||||
|
|
||||||
def delete_current_note(self) -> None:
|
def delete_current_note(self) -> None:
|
||||||
# need to check state because the shortcut is global to the main
|
# need to check state because the shortcut is global to the main
|
||||||
# window
|
# window
|
||||||
|
|
Loading…
Reference in a new issue