fix preview closing
https://anki.tenderapp.com/discussions/beta-testing/1868-anki-2124-beta#comment_48228480
This commit is contained in:
parent
55b99511c0
commit
61793f92b8
@ -1569,7 +1569,7 @@ where id in %s"""
|
|||||||
self._previewer.close()
|
self._previewer.close()
|
||||||
self._previewer = None
|
self._previewer = None
|
||||||
else:
|
else:
|
||||||
self._previewer = PreviewDialog(self, self.mw)
|
self._previewer = PreviewDialog(self, self.mw, self._on_preview_closed)
|
||||||
self._previewer.open()
|
self._previewer.open()
|
||||||
|
|
||||||
def _renderPreview(self, cardChanged=False):
|
def _renderPreview(self, cardChanged=False):
|
||||||
@ -1580,6 +1580,9 @@ where id in %s"""
|
|||||||
if self._previewer:
|
if self._previewer:
|
||||||
self._previewer.cancel_timer()
|
self._previewer.cancel_timer()
|
||||||
|
|
||||||
|
def _on_preview_closed(self):
|
||||||
|
self._previewer = None
|
||||||
|
|
||||||
# Card deletion
|
# Card deletion
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
from typing import Any, List, Optional, Union
|
from typing import Any, Callable, List, Optional, Union
|
||||||
|
|
||||||
from anki.cards import Card
|
from anki.cards import Card
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
@ -34,10 +34,11 @@ class Previewer(QDialog):
|
|||||||
_timer = None
|
_timer = None
|
||||||
_show_both_sides = False
|
_show_both_sides = False
|
||||||
|
|
||||||
def __init__(self, parent: QWidget, mw: AnkiQt):
|
def __init__(self, parent: QWidget, mw: AnkiQt, on_close: Callable[[], None]):
|
||||||
super().__init__(None, Qt.Window)
|
super().__init__(None, Qt.Window)
|
||||||
self._open = True
|
self._open = True
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
|
self._close_callback = on_close
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
|
|
||||||
def card(self) -> Optional[Card]:
|
def card(self) -> Optional[Card]:
|
||||||
@ -90,9 +91,9 @@ class Previewer(QDialog):
|
|||||||
self.mw.reviewer.replayAudio(self)
|
self.mw.reviewer.replayAudio(self)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if self:
|
self._on_close()
|
||||||
self.close()
|
super().close()
|
||||||
self._on_close()
|
self._close_callback()
|
||||||
|
|
||||||
def _on_close(self):
|
def _on_close(self):
|
||||||
self._open = False
|
self._open = False
|
||||||
|
Loading…
Reference in New Issue
Block a user