Skip to content

Commit 426cb62

Browse files
authored
Merge 151f735 into 68c24da
2 parents 68c24da + 151f735 commit 426cb62

1 file changed

Lines changed: 25 additions & 16 deletions

File tree

source/gui/settingsDialogs.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Bill Dengler, Thomas Stivers,
55
# Julien Cochuyt, Peter Vágner, Cyrille Bougot, Mesar Hameed, Łukasz Golonka, Aaron Cannon,
66
# Adriani90, André-Abush Clause, Dawid Pieper, Heiko Folkerts, Takuya Nishimoto, Thomas Stivers,
7-
# jakubl7545, mltony, Rob Meredith, Burman's Computer and Education Ltd.
7+
# jakubl7545, mltony, Rob Meredith, Burman's Computer and Education Ltd, hwf1324.
88
# This file is covered by the GNU General Public License.
99
# See the file COPYING for more details.
1010
import logging
@@ -1649,6 +1649,7 @@ def _appendSpeechModesList(self, settingsSizerHelper: guiHelper.BoxSizerHelper)
16491649
self.speechModesList.Checked = [
16501650
mIndex for mIndex in range(len(self._allSpeechModes)) if mIndex not in excludedModes
16511651
]
1652+
self.speechModesList.Bind(wx.EVT_CHECKLISTBOX, self.onSpeechModesListChange)
16521653
self.speechModesList.Select(0)
16531654

16541655
def _appendDelayedCharacterDescriptions(self, settingsSizerHelper: guiHelper.BoxSizerHelper) -> None:
@@ -1686,20 +1687,11 @@ def onSave(self):
16861687
mIndex for mIndex in range(len(self._allSpeechModes)) if mIndex not in self.speechModesList.CheckedItems
16871688
]
16881689

1689-
def isValid(self) -> bool:
1690-
enabledSpeechModes = self.speechModesList.CheckedItems
1691-
if len(enabledSpeechModes) < 2:
1692-
log.debugWarning("Too few speech modes enabled.")
1693-
gui.messageBox(
1694-
# Translators: Message shown when not enough speech modes are enabled.
1695-
_("At least two speech modes have to be checked."),
1696-
# Translators: The title of the message box
1697-
_("Error"),
1698-
wx.OK | wx.ICON_ERROR,
1699-
self,
1700-
)
1701-
return False
1702-
if self._allSpeechModes.index(speech.SpeechMode.talk) not in enabledSpeechModes:
1690+
def onSpeechModesListChange(self, evt):
1691+
if (
1692+
evt.GetInt() == self._allSpeechModes.index(speech.SpeechMode.talk)
1693+
and not self.speechModesList.IsChecked(evt.GetInt())
1694+
):
17031695
if gui.messageBox(
17041696
_(
17051697
# Translators: Warning shown when 'talk' speech mode is disabled in settings.
@@ -1714,7 +1706,24 @@ def isValid(self) -> bool:
17141706
wx.YES | wx.NO | wx.ICON_WARNING,
17151707
self,
17161708
) == wx.NO:
1717-
return False
1709+
self.speechModesList.SetCheckedItems(
1710+
list(self.speechModesList.GetCheckedItems())
1711+
+ [self._allSpeechModes.index(speech.SpeechMode.talk)]
1712+
)
1713+
1714+
def isValid(self) -> bool:
1715+
enabledSpeechModes = self.speechModesList.CheckedItems
1716+
if len(enabledSpeechModes) < 2:
1717+
log.debugWarning("Too few speech modes enabled.")
1718+
gui.messageBox(
1719+
# Translators: Message shown when not enough speech modes are enabled.
1720+
_("At least two speech modes have to be checked."),
1721+
# Translators: The title of the message box
1722+
_("Error"),
1723+
wx.OK | wx.ICON_ERROR,
1724+
self,
1725+
)
1726+
return False
17181727
return super().isValid()
17191728

17201729

0 commit comments

Comments
 (0)