mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
add a class to preview a single card
This commit is contained in:
parent
944e82211f
commit
f42c164999
1 changed files with 27 additions and 0 deletions
|
@ -282,3 +282,30 @@ class BrowserPreviewer(Previewer):
|
||||||
def _renderScheduledPreview(self) -> None:
|
def _renderScheduledPreview(self) -> None:
|
||||||
super()._renderScheduledPreview()
|
super()._renderScheduledPreview()
|
||||||
self._updatePreviewButtons()
|
self._updatePreviewButtons()
|
||||||
|
|
||||||
|
|
||||||
|
class SingleCardPreviewer(Previewer):
|
||||||
|
def __init__(self, card: Card, *args, **kwargs):
|
||||||
|
self._card = card
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def card(self) -> Card:
|
||||||
|
return self._card
|
||||||
|
|
||||||
|
def _create_gui(self):
|
||||||
|
super()._create_gui()
|
||||||
|
self._other_side = self.bbox.addButton(
|
||||||
|
"Other side", QDialogButtonBox.ActionRole
|
||||||
|
)
|
||||||
|
self._other_side.setAutoDefault(False)
|
||||||
|
self._other_side.setShortcut(QKeySequence("Right"))
|
||||||
|
self._other_side.setShortcut(QKeySequence("Left"))
|
||||||
|
self._other_side.setToolTip(_("Shortcut key: Left or Right arrow"))
|
||||||
|
self._other_side.clicked.connect(self._on_other_side)
|
||||||
|
|
||||||
|
def _on_other_side(self):
|
||||||
|
if self._previewState == "question":
|
||||||
|
self._previewState = "answer"
|
||||||
|
else:
|
||||||
|
self._previewState = "question"
|
||||||
|
self._renderPreview()
|
||||||
|
|
Loading…
Reference in a new issue