Skip to content

Commit 93f0d78

Browse files
authored
Merge e8cb906 into b9a8fbc
2 parents b9a8fbc + e8cb906 commit 93f0d78

8 files changed

Lines changed: 348 additions & 156 deletions

File tree

source/NVDAObjects/window/excel.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import speech
2626
from tableUtils import HeaderCellInfo, HeaderCellTracker
2727
import config
28+
from config.configFlags import ReportCellBorders
2829
import textInfos
2930
import colors
3031
import eventHandler
@@ -1038,7 +1039,7 @@ def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):
10381039
formatField['background-color']=colors.RGB.fromCOLORREF(int(cellObj.interior.color))
10391040
except COMError:
10401041
pass
1041-
if formatConfig["reportBorderStyle"]:
1042+
if formatConfig["reportCellBorders"] != ReportCellBorders.OFF:
10421043
borders = None
10431044
hasMergedCells = self.obj.excelCellObject.mergeCells
10441045
if hasMergedCells:
@@ -1050,7 +1051,10 @@ def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):
10501051
else:
10511052
borders = cellObj.borders
10521053
try:
1053-
formatField['border-style']=getCellBorderStyleDescription(borders,reportBorderColor=formatConfig['reportBorderColor'])
1054+
formatField['border-style'] = getCellBorderStyleDescription(
1055+
borders,
1056+
reportBorderColor=formatConfig['reportCellBorders'] == ReportCellBorders.COLOR_AND_STYLE,
1057+
)
10541058
except COMError:
10551059
pass
10561060
return formatField,(self._startOffset,self._endOffset)

source/braille.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
import keyboardHandler
3333
import baseObject
3434
import config
35-
from config.configFlags import ReportTableHeaders
35+
from config.configFlags import (
36+
ShowMessages,
37+
ReportTableHeaders,
38+
)
3639
from logHandler import log
3740
import controlTypes
3841
import api
@@ -1781,7 +1784,10 @@ def __init__(self):
17811784
self._cells = []
17821785
self._cursorBlinkTimer = None
17831786
config.post_configProfileSwitch.register(self.handlePostConfigProfileSwitch)
1784-
self._tether = config.conf["braille"]["tetherTo"]
1787+
if config.conf["braille"]["tetherTo"] == self.TETHER_AUTO:
1788+
self._tether = self.TETHER_FOCUS
1789+
else:
1790+
self._tether = config.conf["braille"]["tetherTo"]
17851791
self._detectionEnabled = False
17861792
self._detector = None
17871793
self._rawText = u""
@@ -1817,8 +1823,8 @@ def setTether(self, tether, auto=False):
18171823
self._tether = tether
18181824
self.mainBuffer.clear()
18191825

1820-
def _get_shouldAutoTether(self):
1821-
return self.enabled and config.conf["braille"]["autoTether"]
1826+
def _get_shouldAutoTether(self) -> bool:
1827+
return self.enabled and config.conf["braille"]["tetherTo"] == self.TETHER_AUTO
18221828

18231829
displaySize: int
18241830

@@ -2028,7 +2034,11 @@ def message(self, text):
20282034
If a key is pressed the message will be dismissed by the next text being written to the display.
20292035
@postcondition: The message is displayed.
20302036
"""
2031-
if not self.enabled or config.conf["braille"]["messageTimeout"] == 0 or text is None:
2037+
if (
2038+
not self.enabled
2039+
or config.conf["braille"]["showMessages"] == ShowMessages.DISABLED
2040+
or text is None
2041+
):
20322042
return
20332043
if self.buffer is self.messageBuffer:
20342044
self.buffer.clear()
@@ -2046,7 +2056,7 @@ def _resetMessageTimer(self):
20462056
"""Reset the message timeout.
20472057
@precondition: A message is currently being displayed.
20482058
"""
2049-
if config.conf["braille"]["noMessageTimeout"]:
2059+
if config.conf["braille"]["showMessages"] == ShowMessages.SHOW_INDEFINITELY:
20502060
return
20512061
# Configured timeout is in seconds.
20522062
timeout = config.conf["braille"]["messageTimeout"] * 1000

source/config/configFlags.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,63 @@
99
from utils.displayString import DisplayStringIntEnum
1010

1111

12+
@unique
13+
class ShowMessages(DisplayStringIntEnum):
14+
"""Enumeration containing the possible config values for "Show messages" option in braille settings.
15+
16+
Use ShowMessages.MEMBER.value to compare with the config;
17+
use ShowMessages.MEMBER.displayString in the UI for a translatable description of this member.
18+
"""
19+
20+
DISABLED = 0
21+
USE_TIMEOUT = 1
22+
SHOW_INDEFINITELY = 2
23+
24+
@property
25+
def _displayStringLabels(self):
26+
return {
27+
# Translators: One of the show states of braille messages
28+
# (the disabled mode turns off showing of braille messages completely).
29+
ShowMessages.DISABLED: _("Disabled"),
30+
# Translators: One of the show states of braille messages
31+
# (the timeout mode shows messages for the specific time).
32+
ShowMessages.USE_TIMEOUT: _("Use timeout"),
33+
# Translators: One of the show states of braille messages
34+
# (the indefinitely mode prevents braille messages from disappearing automatically).
35+
ShowMessages.SHOW_INDEFINITELY: _("Show indefinitely"),
36+
}
37+
38+
39+
@unique
40+
class ReportLineIndentation(DisplayStringIntEnum):
41+
"""Enumeration containing the possible config values to report line indent.
42+
43+
Use ReportLineIndentation.MEMBER.value to compare with the config;
44+
use ReportLineIndentation.MEMBER.displayString in the UI for a translatable description of this member.
45+
"""
46+
47+
OFF = 0
48+
SPEECH = 1
49+
TONES = 2
50+
SPEECH_AND_TONES = 3
51+
52+
@property
53+
def _displayStringLabels(self):
54+
return {
55+
# Translators: A choice in a combo box in the document formatting dialog to report No line Indentation.
56+
ReportLineIndentation.OFF: _("Off"),
57+
# Translators: A choice in a combo box in the document formatting dialog to report indentation
58+
# with Speech.
59+
ReportLineIndentation.SPEECH: pgettext('line indentation setting', "Speech"),
60+
# Translators: A choice in a combo box in the document formatting dialog to report indentation
61+
# with tones.
62+
ReportLineIndentation.TONES: _("Tones"),
63+
# Translators: A choice in a combo box in the document formatting dialog to report indentation with both
64+
# Speech and tones.
65+
ReportLineIndentation.SPEECH_AND_TONES: _("Both Speech and Tones"),
66+
}
67+
68+
1269
@unique
1370
class ReportTableHeaders(DisplayStringIntEnum):
1471
"""Enumeration containing the possible config values to report table headers.
@@ -38,3 +95,30 @@ def _displayStringLabels(self):
3895
# document formatting settings panel.
3996
ReportTableHeaders.COLUMNS: _("Columns"),
4097
}
98+
99+
100+
@unique
101+
class ReportCellBorders(DisplayStringIntEnum):
102+
"""Enumeration containing the possible config values to report cell borders.
103+
104+
Use ReportCellBorders.MEMBER.value to compare with the config;
105+
use ReportCellBorders.MEMBER.displayString in the UI for a translatable description of this member.
106+
"""
107+
108+
OFF = 0
109+
STYLE = 1
110+
COLOR_AND_STYLE = 2
111+
112+
@property
113+
def _displayStringLabels(self):
114+
return {
115+
# Translators: This is the label for a combobox in the
116+
# document formatting settings panel.
117+
ReportCellBorders.OFF: _("Off"),
118+
# Translators: This is the label for a combobox in the
119+
# document formatting settings panel.
120+
ReportCellBorders.STYLE: _("Styles"),
121+
# Translators: This is the label for a combobox in the
122+
# document formatting settings panel.
123+
ReportCellBorders.COLOR_AND_STYLE: _("Both Colors and Styles"),
124+
}

source/config/configSpec.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#: provide an upgrade step (@see profileUpgradeSteps.py). An upgrade step does not need to be added when
1313
#: just adding a new element to (or removing from) the schema, only when old versions of the config
1414
#: (conforming to old schema versions) will not work correctly with the new schema.
15-
latestSchemaVersion = 8
15+
latestSchemaVersion = 9
1616

1717
#: The configuration specification string
1818
#: @type: String
@@ -68,12 +68,12 @@
6868
cursorBlinkRate = integer(default=500,min=200,max=2000)
6969
cursorShapeFocus = integer(default=192,min=1,max=255)
7070
cursorShapeReview = integer(default=128,min=1,max=255)
71-
noMessageTimeout = boolean(default=false)
71+
# How braille display will show messages
72+
# 0: Disabled, 1: Use timeout, 2: Show indefinitely
73+
showMessages = integer(0, 4, default=1)
7274
# Timeout after the message will disappear from braille display
73-
# 0 means that no message will be shown
74-
messageTimeout = integer(default=4,min=0,max=20)
75-
tetherTo = string(default="focus")
76-
autoTether = boolean(default=true)
75+
messageTimeout = integer(default=4,min=1,max=20)
76+
tetherTo = option("auto", "focus", "review", default="auto")
7777
readByParagraph = boolean(default=false)
7878
wordWrap = boolean(default=true)
7979
focusContextPresentation = option("changedContext", "fill", "scroll", default="changedContext")
@@ -202,16 +202,16 @@
202202
reportSpellingErrors = boolean(default=true)
203203
reportPage = boolean(default=true)
204204
reportLineNumber = boolean(default=False)
205-
reportLineIndentation = boolean(default=False)
206-
reportLineIndentationWithTones = boolean(default=False)
205+
# 0: Off, 1: Speech, 2: Tones, 3: Both Speech and Tones
206+
reportLineIndentation = integer(0, 3, default=0)
207207
reportParagraphIndentation = boolean(default=False)
208208
reportTables = boolean(default=true)
209209
includeLayoutTables = boolean(default=False)
210210
# 0: Off, 1: Rows and columns, 2: Rows, 3: Columns
211211
reportTableHeaders = integer(0, 3, default=1)
212212
reportTableCellCoords = boolean(default=True)
213-
reportBorderStyle = boolean(default=False)
214-
reportBorderColor = boolean(default=False)
213+
# 0: Off, 1: style, 2: color and style
214+
reportCellBorders = integer(0, 2, default=0)
215215
reportLinks = boolean(default=true)
216216
reportGraphics = boolean(default=True)
217217
reportComments = boolean(default=true)

0 commit comments

Comments
 (0)