mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
respond to play button clicks in preview screen + card layout screen
This commit is contained in:
parent
d8e3bc519b
commit
218c033104
2 changed files with 13 additions and 5 deletions
|
@ -24,7 +24,7 @@ from anki.utils import fmtTimeSpan, htmlToTextLine, ids2str, intTime, isMac, isW
|
||||||
from aqt import AnkiQt, gui_hooks
|
from aqt import AnkiQt, gui_hooks
|
||||||
from aqt.editor import Editor
|
from aqt.editor import Editor
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.sound import av_player
|
from aqt.sound import av_player, play_clicked_audio
|
||||||
from aqt.theme import theme_manager
|
from aqt.theme import theme_manager
|
||||||
from aqt.utils import (
|
from aqt.utils import (
|
||||||
MenuList,
|
MenuList,
|
||||||
|
@ -1634,6 +1634,11 @@ where id in %s"""
|
||||||
self._previewWeb.stdHtml(
|
self._previewWeb.stdHtml(
|
||||||
self.mw.reviewer.revHtml(), css=["reviewer.css"], js=jsinc
|
self.mw.reviewer.revHtml(), css=["reviewer.css"], js=jsinc
|
||||||
)
|
)
|
||||||
|
self._previewWeb.set_bridge_command(self._on_preview_bridge_cmd, "preview")
|
||||||
|
|
||||||
|
def _on_preview_bridge_cmd(self, cmd: str) -> Any:
|
||||||
|
if cmd.startswith("play:"):
|
||||||
|
play_clicked_audio(cmd, self.card)
|
||||||
|
|
||||||
def _renderPreview(self, cardChanged=False):
|
def _renderPreview(self, cardChanged=False):
|
||||||
self._cancelPreviewTimer()
|
self._cancelPreviewTimer()
|
||||||
|
|
|
@ -14,7 +14,7 @@ from anki.lang import _, ngettext
|
||||||
from anki.utils import isMac, isWin, joinFields
|
from anki.utils import isMac, isWin, joinFields
|
||||||
from aqt import gui_hooks
|
from aqt import gui_hooks
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.sound import av_player
|
from aqt.sound import av_player, play_clicked_audio
|
||||||
from aqt.theme import theme_manager
|
from aqt.theme import theme_manager
|
||||||
from aqt.utils import (
|
from aqt.utils import (
|
||||||
askUser,
|
askUser,
|
||||||
|
@ -220,9 +220,12 @@ class CardLayout(QDialog):
|
||||||
pform.backWeb.stdHtml(
|
pform.backWeb.stdHtml(
|
||||||
self.mw.reviewer.revHtml(), css=["reviewer.css"], js=jsinc
|
self.mw.reviewer.revHtml(), css=["reviewer.css"], js=jsinc
|
||||||
)
|
)
|
||||||
# specify a context for add-ons
|
pform.frontWeb.set_bridge_command(self._on_bridge_cmd, "card_layout")
|
||||||
pform.frontWeb.set_bridge_command(lambda msg: None, "card_layout")
|
pform.backWeb.set_bridge_command(self._on_bridge_cmd, "card_layout")
|
||||||
pform.backWeb.set_bridge_command(lambda msg: None, "card_layout")
|
|
||||||
|
def _on_bridge_cmd(self, cmd: str) -> Any:
|
||||||
|
if cmd.startswith("play:"):
|
||||||
|
play_clicked_audio(cmd, self.card)
|
||||||
|
|
||||||
def updateMainArea(self):
|
def updateMainArea(self):
|
||||||
if self._isCloze():
|
if self._isCloze():
|
||||||
|
|
Loading…
Reference in a new issue