Skip to content
Permalink
Browse files

Optionally play sounds when toggling screen curtain (#10611)

* 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 f194afaec02a3465ceb769ee88543ea337c6eb9e
@@ -232,3 +232,4 @@ Luke Davis
Larry Wang
Doug Lee
Doc Mehta
Andre Louis
@@ -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.
@@ -18,6 +18,7 @@
import gui
from logHandler import log
from typing import Optional, Type
import nvwave


class MAGCOLOREFFECT(Structure):
@@ -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:
@@ -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"
@@ -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")
@@ -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
Binary file not shown.
Binary file not shown.
@@ -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].

0 comments on commit f194afa

Please sign in to comment.
You can’t perform that action at this time.