-
-
Notifications
You must be signed in to change notification settings - Fork 769
preparing the new magnifier types #19915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,11 +10,13 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from typing import Literal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import ui | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from . import getMagnifier, initialize, terminate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from . import getMagnifier, initialize, terminate, changeMagnifierType | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from .config import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getDefaultZoomLevelString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getDefaultFilter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getDefaultFullscreenMode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getMagnifierType, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setMagnifierType, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ZoomLevel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from .magnifier import Magnifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -101,19 +103,31 @@ def toggleMagnifier() -> None: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| initialize() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| filter = getDefaultFilter() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fullscreenMode = getDefaultFullscreenMode() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ui.message( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pgettext( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| magnifierType = getMagnifierType() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zoomLevel = getDefaultZoomLevelString() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if magnifierType == MagnifierType.FULLSCREEN: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fullscreenMode = getDefaultFullscreenMode() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| msg = pgettext( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "magnifier", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Translators: Message announced when starting the NVDA magnifier. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Starting magnifier with {zoomLevel} zoom level, {filter} filter, and {fullscreenMode} full-screen mode", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Starting {magnifierType} magnifier with {zoomLevel} zoom level, {filter} filter, and {fullscreenMode} full-screen mode", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).format( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zoomLevel=getDefaultZoomLevelString(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| magnifierType=magnifierType.displayString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zoomLevel=zoomLevel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| filter=filter.displayString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fullscreenMode=fullscreenMode.displayString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| msg = pgettext( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "magnifier", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Translators: Message announced when starting the NVDA magnifier. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Starting {magnifierType} magnifier with {zoomLevel} zoom level and {filter} filter", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).format( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| magnifierType=magnifierType.displayString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zoomLevel=zoomLevel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| filter=filter.displayString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ui.message(msg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def zoom(direction: Direction) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -175,6 +189,30 @@ def toggleFilter() -> None: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def cycleMagnifierType() -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Cycle through magnifier types (full-screen, fixed, docked (to do), lens (to do))""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| magnifier: Magnifier = getMagnifier() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if magnifierIsActiveVerify( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| magnifier, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MagnifierAction.CHANGE_MAGNIFIER_TYPE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| types = list(MagnifierType) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| currentType = magnifier._magnifierType | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| idx = types.index(currentType) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| newType = types[(idx + 1) % len(types)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log.debug(f"Changing magnifier type from {currentType} to {newType}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| changeMagnifierType(newType) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setMagnifierType(newType) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| magnifier = getMagnifier() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+192
to
+206
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ui.message( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pgettext( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "magnifier", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Translators: Message announced when changing the magnifier type with {type} being the new magnifier type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Magnifier type changed to {type}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).format(type=magnifier._magnifierType.displayString), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+199
to
+212
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| types = list(MagnifierType) | |
| currentType = magnifier._magnifierType | |
| idx = types.index(currentType) | |
| newType = types[(idx + 1) % len(types)] | |
| log.debug(f"Changing magnifier type from {currentType} to {newType}") | |
| changeMagnifierType(newType) | |
| setMagnifierType(newType) | |
| magnifier = getMagnifier() | |
| ui.message( | |
| pgettext( | |
| "magnifier", | |
| # Translators: Message announced when changing the magnifier type with {type} being the new magnifier type. | |
| "Magnifier type changed to {type}", | |
| ).format(type=magnifier._magnifierType.displayString), | |
| selectableTypes = [ | |
| MagnifierType.FULLSCREEN, | |
| MagnifierType.FIXED, | |
| MagnifierType.DOCKED, | |
| MagnifierType.LENS, | |
| ] | |
| currentType = ( | |
| magnifier._magnifierType | |
| if magnifier._magnifierType in selectableTypes | |
| else getMagnifierType() | |
| ) | |
| if currentType not in selectableTypes: | |
| currentType = selectableTypes[0] | |
| idx = selectableTypes.index(currentType) | |
| newType = selectableTypes[(idx + 1) % len(selectableTypes)] | |
| log.debug(f"Changing magnifier type from {currentType} to {newType}") | |
| changeMagnifierType(newType) | |
| setMagnifierType(newType) | |
| ui.message( | |
| pgettext( | |
| "magnifier", | |
| # Translators: Message announced when changing the magnifier type with {type} being the new magnifier type. | |
| "Magnifier type changed to {type}", | |
| ).format(type=newType.displayString), |
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After switching to a non-fullscreen magnifier type, other commands (e.g. toggleFilter) still assume magnifier.filterType exists. PlaceholderMagnifier doesn’t implement filterType, so toggling filters will raise AttributeError once users cycle into FIXED/DOCKED/LENS. Either move a filterType property to the base Magnifier class (using _filterType), or implement it on PlaceholderMagnifier (and other future types).
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -42,7 +42,7 @@ class Magnifier: | |||||
|
|
||||||
| def __init__(self): | ||||||
| self._displayOrientation = getPrimaryDisplayOrientation() | ||||||
| self._magnifierType: MagnifierType = MagnifierType.FULLSCREEN | ||||||
| self._magnifierType: MagnifierType | ||||||
|
||||||
| self._magnifierType: MagnifierType | |
| self._magnifierType: MagnifierType | None = None |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||||||||||||
| # A part of NonVisual Desktop Access (NVDA) | ||||||||||||||||
| # Copyright (C) 2025 NV Access Limited, Antoine Haffreingue | ||||||||||||||||
| # This file may be used under the terms of the GNU General Public License, version 2 or later, as modified by the NVDA license. | ||||||||||||||||
| # For full terms and any additional permissions, see the NVDA license file: https://github.com/nvaccess/nvda/blob/master/copying.txt | ||||||||||||||||
| """ | ||||||||||||||||
| Placeholder magnifier module. | ||||||||||||||||
| """ | ||||||||||||||||
|
|
||||||||||||||||
| from .magnifier import Magnifier | ||||||||||||||||
| from .utils.types import Coordinates, MagnifierType | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| class PlaceholderMagnifier(Magnifier): | ||||||||||||||||
| def __init__(self): | ||||||||||||||||
| super().__init__() | ||||||||||||||||
| self._magnifierType = MagnifierType.PLACEHOLDER | ||||||||||||||||
| self._currentCoordinates = Coordinates(0, 0) | ||||||||||||||||
|
|
||||||||||||||||
| def _startMagnifier(self) -> None: | ||||||||||||||||
| super()._startMagnifier() | ||||||||||||||||
|
|
||||||||||||||||
| def _stopMagnifier(self) -> None: | ||||||||||||||||
| super()._stopMagnifier() | ||||||||||||||||
|
|
||||||||||||||||
| def _doUpdate(self): | ||||||||||||||||
| super()._doUpdate() | ||||||||||||||||
|
Comment on lines
+25
to
+26
|
||||||||||||||||
| def _doUpdate(self): | |
| super()._doUpdate() | |
| def _doUpdate(self) -> None: | |
| # Placeholder magnifier has no backing implementation to refresh. | |
| # Intentionally do nothing instead of delegating to the abstract | |
| # base implementation, which raises NotImplementedError. | |
| return |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5159,6 +5159,20 @@ def script_toggleFilter( | |||||
| ) -> None: | ||||||
| _magnifier.commands.toggleFilter() | ||||||
|
|
||||||
| @script( | ||||||
| description=_( | ||||||
| # Translators: Describes a command. | ||||||
| "Cycle through Magnifier type", | ||||||
|
||||||
| "Cycle through Magnifier type", | |
| "Cycle through magnifier types", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createMagnifierreturnsPlaceholderMagnifier()for FIXED/DOCKED/LENS, butPlaceholderMagnifiercurrently reports its type asMagnifierType.PLACEHOLDER. This breaks type cycling (the current type no longer matches the configured/selected type) and causes user announcements/config (setMagnifierType) to diverge from the actual instance state. Consider passing the requestedmagnifierTypeintoPlaceholderMagnifier(and settingself._magnifierTypeaccordingly) so the instance reflects the selected type.