Im making an addon to insert new cards at the top of the queue. I have no idea what im doing, but I managed to cobble together everything i need except the part where i modify the actual new cards
This is what i got so far
from aqt import mw, gui_hooks
from aqt.utils import showInfo, qconnect
from aqt.qt import *
from anki.collection import CARD_TYPE_NEW
insert_at_first = False
def getMinPosition() -> int:
cardCount = mw.col.cardCount()
assert mw
assert mw.col.db
min_position = mw.col.db.first(
f"select min(due) from cards where type={CARD_TYPE_NEW} and odid=0"
)[0]
return min_position
def isInsertFirst(on) -> None:
min = getMinPosition()
on_text = "enabled" if on else "disabled"
showInfo(f"Insert New Cards On Top is now {on_text}\n\nFirst position is {min}")
action = QAction(mw)
action.setText("Insert new cards on top")
action.setCheckable(True)
action.setShortcut(QKeySequence("Ctrl+Alt+0"))
mw.form.menuTools.addAction(action)
action.toggled.connect(isInsertFirst)
Im looking at the hooks and i cant find a proper hook where i can access the card after or before being inserted
Ill keep looking, but a nudge on the right direction would be appreciated