mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -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):
|
||||
if not self._previewWindow:
|
||||
return
|
||||
self._previewPrev.setEnabled(self._should_enable_prev())
|
||||
self._previewNext.setEnabled(self._should_enable_next())
|
||||
|
||||
def _should_enable_prev(self):
|
||||
current = self.parent.currentRow()
|
||||
canBack = current > 0 or (
|
||||
current == 0
|
||||
and self._previewState == "answer"
|
||||
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 = (
|
||||
self.parent.currentRow() < self.parent.model.rowCount(None) - 1
|
||||
or self._previewState == "question"
|
||||
)
|
||||
self._previewNext.setEnabled(bool(self.parent.singleCard and canForward))
|
||||
return bool(self.parent.singleCard and canForward)
|
||||
|
||||
def _onClosePreview(self):
|
||||
super()._onClosePreview()
|
||||
|
|
Loading…
Reference in a new issue