From 95e020f743ea40c347ffaabc373e8c7a6db03dc8 Mon Sep 17 00:00:00 2001 From: Arthur Milchior Date: Mon, 30 Mar 2020 15:40:19 +0200 Subject: [PATCH] use card method --- qt/aqt/previewer.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qt/aqt/previewer.py b/qt/aqt/previewer.py index 57992fcec..9bfce6339 100644 --- a/qt/aqt/previewer.py +++ b/qt/aqt/previewer.py @@ -2,8 +2,9 @@ import json import re import time from dataclasses import dataclass -from typing import Any, Union +from typing import Any, Optional, Union +from anki.cards import Card from anki.lang import _ from aqt import AnkiQt, gui_hooks from aqt.qt import ( @@ -38,6 +39,9 @@ class Previewer: self.parent = parent self.mw = mw + def card(self) -> Optional[Card]: + return self.parent.card + def _openPreview(self): self._previewState = "question" self._lastPreviewState = None @@ -163,7 +167,7 @@ class Previewer: def _on_preview_bridge_cmd(self, cmd: str) -> Any: if cmd.startswith("play:"): - play_clicked_audio(cmd, self.parent.card) + play_clicked_audio(cmd, self.card()) def _renderPreview(self, cardChanged=False): self._cancelPreviewTimer() @@ -191,7 +195,7 @@ class Previewer: if not self._previewWindow: return - c = self.parent.card + c = self.card() func = "_showQuestion" if not c or not self.parent.singleCard: txt = _("(please select 1 card)") @@ -253,7 +257,7 @@ class Previewer: self._renderPreview() def _previewStateAndMod(self): - c = self.parent.card + c = self.card() n = c.note() n.load() return (self._previewState, c.id, n.mod)