Skip to content

Commit 0d25bc4

Browse files
authored
Merge 3963cd2 into 8d6a860
2 parents 8d6a860 + 3963cd2 commit 0d25bc4

3 files changed

Lines changed: 43 additions & 18 deletions

File tree

source/braille.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,18 +3132,17 @@ def handlePostConfigProfileSwitch(self):
31323132

31333133
if (configuredTether := config.conf["braille"]["tetherTo"]) != TetherTo.AUTO.value:
31343134
self._tether = configuredTether
3135-
if config.conf["braille"]["translationTable"] == "auto":
3136-
config.conf["braille"]["translationTable"] = brailleTables.getDefaultTableForCurLang(
3137-
brailleTables.TableType.OUTPUT,
3138-
)
31393135
tableName = config.conf["braille"]["translationTable"]
31403136
# #6140: Migrate to new table names as smoothly as possible.
31413137
newTableName = brailleTables.RENAMED_TABLES.get(tableName)
31423138
if newTableName:
31433139
tableName = config.conf["braille"]["translationTable"] = newTableName
31443140
if tableName != self._table.fileName:
31453141
try:
3146-
self._table = brailleTables.getTable(tableName)
3142+
if config.conf["braille"]["translationTable"] == "auto":
3143+
self._table = brailleTables.getDefaultTableForCurLang(brailleTables.TableType.OUTPUT)
3144+
else:
3145+
self._table = brailleTables.getTable(tableName)
31473146
except LookupError:
31483147
log.error(
31493148
f"Invalid translation table ({tableName}), "

source/brailleInput.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,16 +451,17 @@ def handleCaretMove(self, obj):
451451
self.flushBuffer()
452452

453453
def handlePostConfigProfileSwitch(self):
454-
if config.conf["braille"]["inputTable"] == "auto":
455-
config.conf["braille"]["inputTable"] = brailleTables.getDefaultTableForCurLang(
456-
brailleTables.TableType.INPUT,
457-
)
458454
# #6140: Migrate to new table names as smoothly as possible.
459455
tableName = config.conf["braille"]["inputTable"]
460456
newTableName = brailleTables.RENAMED_TABLES.get(tableName)
461457
if newTableName:
462458
tableName = config.conf["braille"]["inputTable"] = newTableName
463-
table = config.conf["braille"]["inputTable"]
459+
if config.conf["braille"]["inputTable"] == "auto":
460+
table = brailleTables.getDefaultTableForCurLang(
461+
brailleTables.TableType.INPUT,
462+
)
463+
else:
464+
table = config.conf["braille"]["inputTable"]
464465
if table != self._table.fileName:
465466
try:
466467
self._table = brailleTables.getTable(tableName)

source/gui/settingsDialogs.py

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4388,11 +4388,20 @@ def makeSettings(self, settingsSizer):
43884388
outputsLabelText = _("&Output table:")
43894389
self.outTables = [table for table in tables if table.output]
43904390
self.outTableNames = [table.fileName for table in self.outTables]
4391-
outTableChoices = [table.displayName for table in self.outTables]
4391+
outTableForCurLangIndex = self.outTableNames.index(
4392+
brailleTables.getDefaultTableForCurLang(brailleTables.TableType.OUTPUT),
4393+
)
4394+
self.outTableForCurLang = self.outTables[outTableForCurLangIndex]
4395+
# Translators: An option in Braille settings to select a braille table automatically, according to the current language.
4396+
outTableChoices = [_("Automatic (%s)" % self.outTableForCurLang.displayName)]
4397+
outTableChoices.extend([table.displayName for table in self.outTables])
43924398
self.outTableList = sHelper.addLabeledControl(outputsLabelText, wx.Choice, choices=outTableChoices)
43934399
self.bindHelpEvent("BrailleSettingsOutputTable", self.outTableList)
43944400
try:
4395-
selection = self.outTables.index(braille.handler.table)
4401+
if config.conf["braille"]["translationTable"] == "auto":
4402+
selection = 0
4403+
else:
4404+
selection = self.outTables.index(braille.handler.table) + 1
43964405
self.outTableList.SetSelection(selection)
43974406
except: # noqa: E722
43984407
log.exception()
@@ -4405,11 +4414,21 @@ def makeSettings(self, settingsSizer):
44054414
# Translators: The label for a setting in braille settings to select the input table (the braille table used to type braille characters on a braille keyboard).
44064415
inputLabelText = _("&Input table:")
44074416
self.inTables = [table for table in tables if table.input]
4408-
inTableChoices = [table.displayName for table in self.inTables]
4417+
self.inTableNames = [table.fileName for table in self.inTables]
4418+
inTableForCurLangIndex = self.inTableNames.index(
4419+
brailleTables.getDefaultTableForCurLang(brailleTables.TableType.INPUT),
4420+
)
4421+
self.inTableForCurLang = self.inTables[inTableForCurLangIndex]
4422+
# Translators: An option in Braille settings to select a braille table automatically, according to the current language.
4423+
inTableChoices = [_("Automatic (%s)" % self.inTableForCurLang.displayName)]
4424+
inTableChoices.extend([table.displayName for table in self.inTables])
44094425
self.inTableList = sHelper.addLabeledControl(inputLabelText, wx.Choice, choices=inTableChoices)
44104426
self.bindHelpEvent("BrailleSettingsInputTable", self.inTableList)
44114427
try:
4412-
selection = self.inTables.index(brailleInput.handler.table)
4428+
if config.conf["braille"]["inputTable"] == "auto":
4429+
selection = 0
4430+
else:
4431+
selection = self.inTables.index(brailleInput.handler.table) + 1
44134432
self.inTableList.SetSelection(selection)
44144433
except: # noqa: E722
44154434
log.exception()
@@ -4714,13 +4733,19 @@ def makeSettings(self, settingsSizer):
47144733

47154734
def onSave(self):
47164735
AutoSettingsMixin.onSave(self)
4717-
4718-
braille.handler.table = self.outTables[self.outTableList.GetSelection()]
4719-
brailleInput.handler.table = self.inTables[self.inTableList.GetSelection()]
4736+
if self.outTableList.GetSelection():
4737+
braille.handler.table = self.outTables[self.outTableList.GetSelection() - 1]
4738+
else:
4739+
braille.handler.table = self.outTableForCurLang
4740+
config.conf["braille"]["translationTable"] = "auto"
4741+
if self.inTableList.GetSelection():
4742+
brailleInput.handler.table = self.inTables[self.inTableList.GetSelection() - 1]
4743+
else:
4744+
brailleInput.handler.table = self.inTableForCurLang
4745+
config.conf["braille"]["inputTable"] = "auto"
47204746
mode = list(braille.BrailleMode)[self.brailleModes.GetSelection()]
47214747
config.conf["braille"]["mode"] = mode.value
47224748
braille.handler.mainBuffer.clear()
4723-
config.conf["braille"]["translationTable"] = self.outTableNames[self.outTableList.GetSelection()]
47244749
config.conf["braille"]["expandAtCursor"] = self.expandAtCursorCheckBox.GetValue()
47254750
config.conf["braille"]["showCursor"] = self.showCursorCheckBox.GetValue()
47264751
config.conf["braille"]["cursorBlink"] = self.cursorBlinkCheckBox.GetValue()

0 commit comments

Comments
 (0)