|
2 | 2 | # A part of NonVisual Desktop Access (NVDA) |
3 | 3 | # This file is covered by the GNU General Public License. |
4 | 4 | # See the file COPYING for more details. |
5 | | -# Copyright (C) 2006-2022 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee, |
| 5 | +# Copyright (C) 2006-2023 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Rui Batista, Joseph Lee, |
6 | 6 | # Leonard de Ruijter, Derek Riemer, Babbage B.V., Davy Kager, Ethan Holliger, Łukasz Golonka, Accessolutions, |
7 | | -# Julien Cochuyt, Jakub Lukowicz, Bill Dengler, Cyrille Bougot, Rob Meredith |
| 7 | +# Julien Cochuyt, Jakub Lukowicz, Bill Dengler, Cyrille Bougot, Rob Meredith, Luke Davis |
8 | 8 |
|
9 | 9 | import itertools |
10 | 10 | from typing import ( |
@@ -3628,6 +3628,52 @@ def script_reloadPlugins(self, gesture): |
3628 | 3628 | # Translators: Presented when plugins (app modules and global plugins) are reloaded. |
3629 | 3629 | ui.message(_("Plugins reloaded")) |
3630 | 3630 |
|
| 3631 | + @script( |
| 3632 | + description=_( |
| 3633 | + # Translators: input help mode message for Report destination URL of navigator link command |
| 3634 | + "Report the destination URL of the link in the navigator object. " |
| 3635 | + "If pressed twice, shows the URL in a window for easier review." |
| 3636 | + ), |
| 3637 | + gesture="kb:NVDA+k", |
| 3638 | + category=SCRCAT_TOOLS |
| 3639 | + ) |
| 3640 | + def script_reportLinkDestination(self, gesture: inputCore.InputGesture, forceBrowseable: bool = False) -> None: |
| 3641 | + """Generates a ui.message or ui.browseableMessage of a link's destination, if the navigator |
| 3642 | + object is a link, or an element with an included link such as a graphic. |
| 3643 | + @param forceBrowseable: skips the press once check, and displays the browseableMessage version. |
| 3644 | + """ |
| 3645 | + obj = api.getNavigatorObject() |
| 3646 | + if ( |
| 3647 | + obj.role == controlTypes.role.Role.LINK # If it's a link, or |
| 3648 | + or controlTypes.state.State.LINKED in obj.states # if it isn't a link but contains one |
| 3649 | + ): |
| 3650 | + if ( |
| 3651 | + forceBrowseable # If a browseable message is preferred unconditionally, or |
| 3652 | + or scriptHandler.getLastScriptRepeatCount() > 0 # if pressed more than once |
| 3653 | + ): |
| 3654 | + # Translators: Informs the user that the window contains the destination of the |
| 3655 | + # link with given title |
| 3656 | + ui.browseableMessage(obj.value, title=_("Destination of: {name}").format(name=obj.name)) |
| 3657 | + else: |
| 3658 | + ui.message(obj.value) # Speak the link |
| 3659 | + else: |
| 3660 | + # Translators: Tell user that the command has been run on something that is not a link |
| 3661 | + ui.message(_("Not a link.")) |
| 3662 | + |
| 3663 | + @script( |
| 3664 | + description=_( |
| 3665 | + # Translators: input help mode message for Report URL of navigator link in a window command |
| 3666 | + "Reports the destination URL of the link in the navigator object in a window, " |
| 3667 | + "instead of just speaking it. May be preferred by braille users." |
| 3668 | + ), |
| 3669 | + category=SCRCAT_TOOLS |
| 3670 | + ) |
| 3671 | + def script_reportLinkDestinationInWindow(self, gesture: inputCore.InputGesture) -> None: |
| 3672 | + """Uses the forceBrowseable flag of script_reportLinkDestination, to generate a |
| 3673 | + ui.browseableMessage of a link's destination. |
| 3674 | + """ |
| 3675 | + self.script_reportLinkDestination(gesture, True) |
| 3676 | + |
3631 | 3677 | @script( |
3632 | 3678 | # Translators: Input help mode message for a touchscreen gesture. |
3633 | 3679 | description=_("Moves to the next object in a flattened view of the object navigation hierarchy"), |
|
0 commit comments