mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
option for showing both sides in preview screen
This commit is contained in:
parent
3faa82571c
commit
29d6d93881
1 changed files with 17 additions and 3 deletions
|
@ -1238,6 +1238,12 @@ where id in %s""" % ids2str(sf))
|
||||||
self._previewNext.clicked.connect(self._onPreviewNext)
|
self._previewNext.clicked.connect(self._onPreviewNext)
|
||||||
self._previewReplay.clicked.connect(self._onReplayAudio)
|
self._previewReplay.clicked.connect(self._onReplayAudio)
|
||||||
|
|
||||||
|
self.previewShowBothSides = QCheckBox(_("Show Both Sides"))
|
||||||
|
bbox.addButton(self.previewShowBothSides, QDialogButtonBox.ActionRole)
|
||||||
|
self.previewShowBothSides.toggled.connect(self._onPreviewShowBothSides)
|
||||||
|
self._previewBothSides = self.col.conf.get("previewBothSides", False)
|
||||||
|
self.previewShowBothSides.setChecked(self._previewBothSides)
|
||||||
|
|
||||||
self._setupPreviewWebview()
|
self._setupPreviewWebview()
|
||||||
|
|
||||||
vbox.addWidget(bbox)
|
vbox.addWidget(bbox)
|
||||||
|
@ -1252,7 +1258,7 @@ where id in %s""" % ids2str(sf))
|
||||||
self.form.previewButton.setChecked(False)
|
self.form.previewButton.setChecked(False)
|
||||||
|
|
||||||
def _onPreviewPrev(self):
|
def _onPreviewPrev(self):
|
||||||
if self._previewState == "answer":
|
if self._previewState == "answer" and not self._previewBothSides:
|
||||||
self._previewState = "question"
|
self._previewState = "question"
|
||||||
self._renderPreview()
|
self._renderPreview()
|
||||||
else:
|
else:
|
||||||
|
@ -1274,7 +1280,8 @@ where id in %s""" % ids2str(sf))
|
||||||
if not self._previewWindow:
|
if not self._previewWindow:
|
||||||
return
|
return
|
||||||
current = self.currentRow()
|
current = self.currentRow()
|
||||||
canBack = (current > 0 or (current == 0 and self._previewState == "answer" ))
|
canBack = (current > 0 or (current == 0 and self._previewState == "answer"
|
||||||
|
and not self._previewBothSides))
|
||||||
self._previewPrev.setEnabled(not not (self.singleCard and canBack))
|
self._previewPrev.setEnabled(not not (self.singleCard and canBack))
|
||||||
canForward = self.currentRow() < self.model.rowCount(None) - 1 or \
|
canForward = self.currentRow() < self.model.rowCount(None) - 1 or \
|
||||||
self._previewState == "question"
|
self._previewState == "question"
|
||||||
|
@ -1325,7 +1332,9 @@ where id in %s""" % ids2str(sf))
|
||||||
txt = _("(please select 1 card)")
|
txt = _("(please select 1 card)")
|
||||||
bodyclass = ""
|
bodyclass = ""
|
||||||
else:
|
else:
|
||||||
if cardChanged:
|
if self._previewBothSides:
|
||||||
|
self._previewState = "answer"
|
||||||
|
elif cardChanged:
|
||||||
self._previewState = "question"
|
self._previewState = "question"
|
||||||
# need to force reload even if answer
|
# need to force reload even if answer
|
||||||
txt = c.q(reload=True)
|
txt = c.q(reload=True)
|
||||||
|
@ -1345,6 +1354,11 @@ where id in %s""" % ids2str(sf))
|
||||||
self._previewWeb.eval(
|
self._previewWeb.eval(
|
||||||
f"{func}({json.dumps(txt)},'{bodyclass}');")
|
f"{func}({json.dumps(txt)},'{bodyclass}');")
|
||||||
|
|
||||||
|
def _onPreviewShowBothSides(self, toggle):
|
||||||
|
self._previewBothSides = toggle
|
||||||
|
self.col.conf["previewBothSides"] = toggle
|
||||||
|
self.col.setMod()
|
||||||
|
|
||||||
# Card deletion
|
# Card deletion
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue