4040import keyboardHandler
4141import languageHandler
4242import logHandler
43+ from _magnifier .commands import toggleMagnifier
4344import _magnifier .config as magnifierConfig
4445from _magnifier .utils .types import Filter , FullScreenMode , MagnifierFollowFocusType
4546import queueHandler
@@ -6049,6 +6050,18 @@ def makeSettings(
60496050 sizer = settingsSizer ,
60506051 )
60516052
6053+ # Enable the magnifier
6054+ # Translators: The label for a setting in magnifier settings to enable or disable the magnifier.
6055+ enableMagnifierText = _ ("&Enable magnifier (immediate effect)" )
6056+ self ._magnifierEnabledInitially = magnifierConfig .getEnabled ()
6057+ self .enableMagnifierCheckBox = sHelper .addItem (wx .CheckBox (self , label = enableMagnifierText ))
6058+ self .bindHelpEvent (
6059+ "MagnifierEnable" ,
6060+ self .enableMagnifierCheckBox ,
6061+ )
6062+ self .enableMagnifierCheckBox .Bind (wx .EVT_CHECKBOX , self .onEnableMagnifierChange )
6063+ self .enableMagnifierCheckBox .SetValue (self ._magnifierEnabledInitially )
6064+
60526065 # ZOOM SETTINGS
60536066 # Translators: The label for a setting in magnifier settings to select the zoom level.
60546067 zoomLabelText = _ ("&Zoom level:" )
@@ -6066,7 +6079,7 @@ def makeSettings(
60666079 self .zoomList ,
60676080 )
60686081
6069- # Set value from config
6082+ # Set value from config
60706083 zoomLevel = magnifierConfig .getZoomLevel ()
60716084 zoomIndex = bisect .bisect_left (zoomValues , zoomLevel )
60726085 # Find the closest value
@@ -6099,7 +6112,7 @@ def makeSettings(
60996112
61006113 # FILTER SETTINGS
61016114 # Translators: The label for a setting in magnifier settings to select the default filter
6102- filterLabelText = _ ("&filter :" )
6115+ filterLabelText = _ ("F&ilter :" )
61036116 filterChoices = [f .displayString for f in Filter ]
61046117 self .filterList = sHelper .addLabeledControl (
61056118 filterLabelText ,
@@ -6114,7 +6127,7 @@ def makeSettings(
61146127
61156128 # FULLSCREEN MODE SETTINGS
61166129 # Translators: The label for a setting in magnifier settings to select the full-screen mode
6117- fullscreenModeLabelText = _ ("&fullscreen mode:" )
6130+ fullscreenModeLabelText = _ ("&Fullscreen mode:" )
61186131 fullscreenModeChoices = [mode .displayString for mode in FullScreenMode ] if FullScreenMode else []
61196132 self .fullscreenModeList = sHelper .addLabeledControl (
61206133 fullscreenModeLabelText ,
@@ -6170,7 +6183,7 @@ def makeSettings(
61706183
61716184 # KEEP MOUSE CENTERED
61726185 # Translators: The label for a checkbox to keep the mouse pointer centered in the magnifier view
6173- keepMouseCenteredText = _ ("Keep & mouse pointer centered in magnifier view" )
6186+ keepMouseCenteredText = _ ("Keep mouse pointer & centered in magnifier view" )
61746187 self .keepMouseCenteredCheckBox = sHelper .addItem (wx .CheckBox (self , label = keepMouseCenteredText ))
61756188 self .bindHelpEvent (
61766189 "MagnifierKeepMouseCentered" ,
@@ -6180,6 +6193,8 @@ def makeSettings(
61806193
61816194 def onSave (self ):
61826195 """Save the current selections to config."""
6196+ magnifierConfig .setEnabled (self .enableMagnifierCheckBox .GetValue ())
6197+
61836198 selectedZoom = self .zoomList .GetSelection ()
61846199 magnifierConfig .setZoomLevel (magnifierConfig .ZoomLevel .zoom_range ()[selectedZoom ])
61856200
@@ -6196,6 +6211,20 @@ def onSave(self):
61966211 magnifierConfig .setFollowState (focusType , checkBox .GetValue ())
61976212 config .conf ["magnifier" ]["keepMouseCentered" ] = self .keepMouseCenteredCheckBox .GetValue ()
61986213
6214+ def onDiscard (self ):
6215+ """Restore magnifier state from original settings from config."""
6216+ if self ._magnifierEnabledInitially != magnifierConfig .getEnabled ():
6217+ toggleMagnifier ()
6218+ self .enableMagnifierCheckBox .SetValue (self ._magnifierEnabledInitially )
6219+
6220+ def onEnableMagnifierChange (self , evt : wx .CommandEvent ):
6221+ """Enable magnifier immediately when the checkbox is toggled, and update the checkbox state if there is an error enabling the magnifier."""
6222+ requestedEnabled = evt .IsChecked ()
6223+ currentEnabled = magnifierConfig .getEnabled ()
6224+ if requestedEnabled != currentEnabled :
6225+ toggleMagnifier ()
6226+ self .enableMagnifierCheckBox .SetValue (magnifierConfig .getEnabled ())
6227+
61996228
62006229class PrivacyAndSecuritySettingsPanel (SettingsPanel ):
62016230 # Translators: The title of the privacy and security category in NVDA's settings.
0 commit comments