예제 #1
0
def _legacy_undo(*, parent: QWidget) -> None:
    from aqt import mw

    assert mw
    assert mw.col

    reviewing = mw.state == "review"
    just_refresh_reviewer = False

    result = mw.col.undo_legacy()

    if result is None:
        # should not happen
        showInfo("nothing to undo", parent=parent)
        mw.update_undo_actions()
        return

    elif isinstance(result, LegacyReviewUndo):
        name = tr.scheduling_review()

        if reviewing:
            # push the undone card to the top of the queue
            cid = result.card.id
            card = mw.col.get_card(cid)
            mw.reviewer.cardQueue.append(card)

            gui_hooks.review_did_undo(cid)

            just_refresh_reviewer = True

    elif isinstance(result, LegacyCheckpoint):
        name = result.name

    else:
        assert_exhaustive(result)
        assert False

    if just_refresh_reviewer:
        mw.reviewer.nextCard()
    else:
        # full queue+gui reset required
        mw.reset()

    tooltip(tr.undo_action_undone(action=name), parent=parent)
    gui_hooks.state_did_revert(name)
    mw.update_undo_actions()
예제 #2
0
파일: tree.py 프로젝트: kaczmarj/anki
    def _card_state_tree(self, root: SidebarItem) -> None:
        icon = ":/icons/circle.svg"
        icon_outline = ":/icons/circle-outline.svg"

        root = self._section_root(
            root=root,
            name=tr.browsing_sidebar_card_state(),
            icon=icon_outline,
            collapse_key=Config.Bool.COLLAPSE_CARD_STATE,
            type=SidebarItemType.CARD_STATE_ROOT,
        )
        type = SidebarItemType.CARD_STATE
        colored_icon = ColoredIcon(path=icon, color=colors.DISABLED)

        root.add_simple(
            tr.actions_new(),
            icon=colored_icon.with_color(colors.NEW_COUNT),
            type=type,
            search_node=SearchNode(card_state=SearchNode.CARD_STATE_NEW),
        )

        root.add_simple(
            name=tr.scheduling_learning(),
            icon=colored_icon.with_color(colors.LEARN_COUNT),
            type=type,
            search_node=SearchNode(card_state=SearchNode.CARD_STATE_LEARN),
        )
        root.add_simple(
            name=tr.scheduling_review(),
            icon=colored_icon.with_color(colors.REVIEW_COUNT),
            type=type,
            search_node=SearchNode(card_state=SearchNode.CARD_STATE_REVIEW),
        )
        root.add_simple(
            name=tr.browsing_suspended(),
            icon=colored_icon.with_color(colors.SUSPENDED_FG),
            type=type,
            search_node=SearchNode(card_state=SearchNode.CARD_STATE_SUSPENDED),
        )
        root.add_simple(
            name=tr.browsing_buried(),
            icon=colored_icon.with_color(colors.BURIED_FG),
            type=type,
            search_node=SearchNode(card_state=SearchNode.CARD_STATE_BURIED),
        )