mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 00:36:38 -04:00
split _updatePreviewButtons
This will allow to create a hierarchy in this class
This commit is contained in:
parent
f42c164999
commit
79dece3124
1 changed files with 8 additions and 2 deletions
|
@ -260,18 +260,24 @@ class BrowserPreviewer(Previewer):
|
||||||
def _updatePreviewButtons(self):
|
def _updatePreviewButtons(self):
|
||||||
if not self._previewWindow:
|
if not self._previewWindow:
|
||||||
return
|
return
|
||||||
|
self._previewPrev.setEnabled(self._should_enable_prev())
|
||||||
|
self._previewNext.setEnabled(self._should_enable_next())
|
||||||
|
|
||||||
|
def _should_enable_prev(self):
|
||||||
current = self.parent.currentRow()
|
current = self.parent.currentRow()
|
||||||
canBack = current > 0 or (
|
canBack = current > 0 or (
|
||||||
current == 0
|
current == 0
|
||||||
and self._previewState == "answer"
|
and self._previewState == "answer"
|
||||||
and not self._previewBothSides
|
and not self._previewBothSides
|
||||||
)
|
)
|
||||||
self._previewPrev.setEnabled(bool(self.parent.singleCard and canBack))
|
return bool(self.parent.singleCard and canBack)
|
||||||
|
|
||||||
|
def _should_enable_next(self):
|
||||||
canForward = (
|
canForward = (
|
||||||
self.parent.currentRow() < self.parent.model.rowCount(None) - 1
|
self.parent.currentRow() < self.parent.model.rowCount(None) - 1
|
||||||
or self._previewState == "question"
|
or self._previewState == "question"
|
||||||
)
|
)
|
||||||
self._previewNext.setEnabled(bool(self.parent.singleCard and canForward))
|
return bool(self.parent.singleCard and canForward)
|
||||||
|
|
||||||
def _onClosePreview(self):
|
def _onClosePreview(self):
|
||||||
super()._onClosePreview()
|
super()._onClosePreview()
|
||||||
|
|
Loading…
Reference in a new issue