add option to disable audio interrupting

This commit is contained in:
Damien Elmes 2020-02-03 08:32:07 +10:00
parent 97e3602c14
commit 5d91580ce2
4 changed files with 30 additions and 2 deletions

View File

@ -332,6 +332,8 @@ close the profile or restart Anki."""
if not self.loadCollection(): if not self.loadCollection():
return return
self.pm.apply_profile_options()
# show main window # show main window
if self.pm.profile["mainWindowState"]: if self.pm.profile["mainWindowState"]:
restoreGeom(self, "mainWindow") restoreGeom(self, "mainWindow")

View File

@ -226,6 +226,7 @@ Not currently enabled; click the sync button in the main window to enable."""
self.form.pasteInvert.setChecked(self.prof.get("pasteInvert", False)) self.form.pasteInvert.setChecked(self.prof.get("pasteInvert", False))
self.form.showPlayButtons.setChecked(self.prof.get("showPlayButtons", True)) self.form.showPlayButtons.setChecked(self.prof.get("showPlayButtons", True))
self.form.nightMode.setChecked(self.mw.pm.night_mode()) self.form.nightMode.setChecked(self.mw.pm.night_mode())
self.form.interrupt_audio.setChecked(self.mw.pm.interrupt_audio())
def updateOptions(self): def updateOptions(self):
restart_required = False restart_required = False
@ -242,5 +243,7 @@ Not currently enabled; click the sync button in the main window to enable."""
self.mw.pm.set_night_mode(not self.mw.pm.night_mode()) self.mw.pm.set_night_mode(not self.mw.pm.night_mode())
restart_required = True restart_required = True
self.mw.pm.set_interrupt_audio(self.form.interrupt_audio.isChecked())
if restart_required: if restart_required:
showInfo(_("Changes will take effect when you restart Anki.")) showInfo(_("Changes will take effect when you restart Anki."))

View File

@ -481,7 +481,7 @@ please see:
elif mode == "angle": elif mode == "angle":
self.setGlMode("software") self.setGlMode("software")
# Helpers # Shared options
###################################################################### ######################################################################
def uiScale(self) -> float: def uiScale(self) -> float:
@ -501,3 +501,18 @@ please see:
def set_night_mode(self, on: bool) -> None: def set_night_mode(self, on: bool) -> None:
self.meta["night_mode"] = on self.meta["night_mode"] = on
# Profile-specific options
######################################################################
def interrupt_audio(self) -> bool:
return self.profile.get("interrupt_audio", True)
def set_interrupt_audio(self, val: bool) -> None:
self.profile["interrupt_audio"] = val
aqt.sound.av_player.interrupt_current_audio = val
######################################################################
def apply_profile_options(self) -> None:
aqt.sound.av_player.interrupt_current_audio = self.interrupt_audio()

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>422</width> <width>422</width>
<height>586</height> <height>611</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -94,6 +94,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="interrupt_audio">
<property name="text">
<string>Interrupt current audio when answering</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="pastePNG"> <widget class="QCheckBox" name="pastePNG">
<property name="text"> <property name="text">
@ -522,6 +529,7 @@
<tabstop>showEstimates</tabstop> <tabstop>showEstimates</tabstop>
<tabstop>showProgress</tabstop> <tabstop>showProgress</tabstop>
<tabstop>showPlayButtons</tabstop> <tabstop>showPlayButtons</tabstop>
<tabstop>interrupt_audio</tabstop>
<tabstop>pastePNG</tabstop> <tabstop>pastePNG</tabstop>
<tabstop>pasteInvert</tabstop> <tabstop>pasteInvert</tabstop>
<tabstop>nightMode</tabstop> <tabstop>nightMode</tabstop>