Skip to content

Commit

Permalink
Optionally play sounds when toggling screen curtain (nvaccess#10611)
Browse files Browse the repository at this point in the history
* Add scree curtain sounds, ensure that it only enables once

* Add Andre Louis as a contributor

* Use mono sounds instead

* Update user guide, review actions
  • Loading branch information
LeonarddeR authored and michaelDCurran committed Jan 12, 2020
1 parent a4b72aa commit f194afa
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
1 change: 1 addition & 0 deletions contributors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,4 @@ Luke Davis
Larry Wang
Doug Lee
Doc Mehta
Andre Louis
9 changes: 5 additions & 4 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2459,10 +2459,11 @@ def _enableScreenCurtain(doEnable: bool = True):
enableMessage = _("Temporary Screen curtain, enabled until next restart")

try:
vision.handler.initializeProvider(
screenCurtainProviderInfo,
temporary=tempEnable,
)
if not alreadyRunning:
vision.handler.initializeProvider(
screenCurtainProviderInfo,
temporary=tempEnable,
)
except Exception:
log.error("Screen curtain initialization error", exc_info=True)
# Translators: Reported when the screen curtain could not be enabled.
Expand Down
24 changes: 23 additions & 1 deletion source/visionEnhancementProviders/screenCurtain.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import gui
from logHandler import log
from typing import Optional, Type
import nvwave


class MAGCOLOREFFECT(Structure):
Expand Down Expand Up @@ -100,9 +101,16 @@ class Magnification:
)


# Translators: Description for a screen curtain setting to play sounds when enabling/disabling the curtain
playToggleSoundsCheckBoxText = _("&Play sound when toggling {screenCurtainTranslatedName}").format(
screenCurtainTranslatedName=screenCurtainTranslatedName
)


class ScreenCurtainSettings(providerBase.VisionEnhancementProviderSettings):

warnOnLoad: bool
playToggleSounds: bool

@classmethod
def getId(cls) -> str:
Expand All @@ -119,9 +127,13 @@ def _get_supportedSettings(self) -> SupportedSettingType:
warnOnLoadCheckBoxText,
defaultVal=True
),
BooleanDriverSetting(
"playToggleSounds",
playToggleSoundsCheckBoxText,
defaultVal=True
),
]


warnOnLoadText = _(
# Translators: A warning shown when activating the screen curtain.
# the translation of "Screen Curtain" should match the "translated name"
Expand Down Expand Up @@ -314,6 +326,11 @@ def __init__(self):
Magnification.MagInitialize()
Magnification.MagSetFullscreenColorEffect(TRANSFORM_BLACK)
Magnification.MagShowSystemCursor(False)
if self.getSettings().playToggleSounds:
try:
nvwave.playWaveFile(r"waves\screenCurtainOn.wav")
except Exception:
log.exception()

def terminate(self):
log.debug(f"Terminating ScreenCurtain")
Expand All @@ -322,6 +339,11 @@ def terminate(self):
finally:
Magnification.MagShowSystemCursor(True)
Magnification.MagUninitialize()
if self.getSettings().playToggleSounds:
try:
nvwave.playWaveFile(r"waves\screenCurtainOff.wav")
except Exception:
log.exception()

def registerEventExtensionPoints(self, extensionPoints):
# The screen curtain isn't interested in any events
Expand Down
Binary file added source/waves/screenCurtainOff.wav
Binary file not shown.
Binary file added source/waves/screenCurtainOn.wav
Binary file not shown.
5 changes: 4 additions & 1 deletion user_docs/en/userGuide.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,10 @@ If you are sure, you can choose the Yes button to enable the screen curtain.
If you no longer want to see this warning message every time, you can change this behavior in the dialog that displays the message.
You can always restore the warning by checking the "Always show a warning when loading Screen Curtain" check box next to the "Make screen black" check box.

To toggle the SCreen Curtain from anywhere, please assign a custom gesture using the [Input Gestures dialog #InputGestures].
To toggle the Screen Curtain from anywhere, please assign a custom gesture using the [Input Gestures dialog #InputGestures].

By default, sounds are played when the Screen Curtain is toggled.
When you want to change this behavior, you can uncheck the "Play sound when toggling Screen Curtain" check box.

==== Settings for third party visual aids ====[VisionSettingsThirdPartyVisualAids]
Additional vision enhancement providers can be provided in [NVDA add-ons #AddonsManager].
Expand Down

0 comments on commit f194afa

Please sign in to comment.