clear audio queue when changing cards/editing

This commit is contained in:
Damien Elmes 2009-01-05 14:39:03 +09:00
parent aac727f2b5
commit 39d59d4d99
2 changed files with 8 additions and 1 deletions

View file

@ -11,6 +11,7 @@ from anki.errors import *
from anki.utils import stripHTML, parseTags from anki.utils import stripHTML, parseTags
from ankiqt.ui.utils import saveGeom, restoreGeom, saveSplitter, restoreSplitter from ankiqt.ui.utils import saveGeom, restoreGeom, saveSplitter, restoreSplitter
from ankiqt import ui from ankiqt import ui
from anki.sound import clearAudioQueue
class AddCards(QDialog): class AddCards(QDialog):
@ -114,6 +115,8 @@ question or answer on all cards."""), parent=self)
# we're guaranteed that all fields will exist now # we're guaranteed that all fields will exist now
"str": stripHTML(fact[fact.fields[0].name]), "str": stripHTML(fact[fact.fields[0].name]),
}) })
# stop anything playing
clearAudioQueue()
self.parent.deck.setUndoEnd(n) self.parent.deck.setUndoEnd(n)
self.parent.updateTitleBar() self.parent.updateTitleBar()
# start a new fact # start a new fact
@ -135,6 +138,8 @@ question or answer on all cards."""), parent=self)
QDialog.reject(self) QDialog.reject(self)
def onClose(self): def onClose(self):
# stop anything playing
clearAudioQueue()
if (self.editor.fieldsAreBlank() or if (self.editor.fieldsAreBlank() or
ui.utils.askUser(_("Close and lose current input?"), ui.utils.askUser(_("Close and lose current input?"),
self)): self)):

View file

@ -13,7 +13,7 @@ from PyQt4.QtCore import *
from PyQt4.QtGui import * from PyQt4.QtGui import *
from anki import DeckStorage from anki import DeckStorage
from anki.errors import * from anki.errors import *
from anki.sound import hasSound, playFromText from anki.sound import hasSound, playFromText, clearAudioQueue
from anki.utils import addTags, deleteTags, parseTags from anki.utils import addTags, deleteTags, parseTags
from anki.media import rebuildMediaDir from anki.media import rebuildMediaDir
from anki.db import OperationalError from anki.db import OperationalError
@ -327,6 +327,8 @@ Please do not file a bug report with Anki.\n\n""")
stats = self.deck.getStats() stats = self.deck.getStats()
if stats['gTotal'] % num == 0: if stats['gTotal'] % num == 0:
self.onSave() self.onSave()
# stop anything playing
clearAudioQueue()
self.moveToState("getQuestion") self.moveToState("getQuestion")
def startRefreshTimer(self): def startRefreshTimer(self):