Skip to content

Avoid a situation where no NVDA modifier key is defined #14528

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

Merged
merged 11 commits into from
Jan 18, 2023

Conversation

CyrilleB79
Copy link
Collaborator

@CyrilleB79 CyrilleB79 commented Jan 10, 2023

Link to issue number:

Fixes #14527

May be considered a follow-up of #14233.

Summary of the issue:

When configuring NVDA Modifier Key for a non-default profile and for the default profile, we can end-up with no NVDA key defined at all in the non-default profile (see #14527 for detailed steps).

This is due to the fact that the config stores one item per NVDA key but that there is a dependency between these values to honor the requirement that at least one key should be defined as NVDA key. These values are checked when changing NVDA keys via the GUI. But the requirement may be missed when switching profiles and stacking their configurations.

There is also a second scenario allowing to have no NVDA key defined using only default profile:

  • In keyboard settings enable only caps lock and disable both insert, then validate
  • Open the NVDA startup dialog via Help menu, uncheck caps lock and validate.
    This scenario is quite unlikely but there is no check in NVDA startup dialog to prevent such situation.

Description of user facing changes

Situations where no NVDA key is defined will not be possible anymore.

Description of development approach

  • Use only one config item to store the used NVDA modifier keys.
  • Define a config flag for NVDA key; each value corresponds to one bit so that all the values can be bitwise or-ed and the reesulting value can be stored in the config as an integer.

During the dev, I have had to import key labels (via the config flag) early during NVDA startup. This has caused issues since pgettext was not yet defined at this moment. I have tried to fix this; but please double-check it because I do not know very well this part of the code and why gettext translations need to be initialized two times during NVDA startup.

Note: with this PR, keyboardHandler.SUPPORTED_NVDA_MODIFIER_KEY is not used anymore in NVDA's code. Should I deprecate it?

Testing strategy:

Manual tests:

  • Check config upgrade in nvda.ini
  • Modify NVDA modifier keys in keyboard parameters
  • Enable or not caps lock as NVDA modifier in NVDA startup dialog
  • Test scenario of Possibility to have no more NVDA key defined #14527
  • Test 2nd scenario with startup dialog described in this PR.

Unit tests:

  • New unit tests created to check various config upgrade situations

Known issues with pull request:

None

Change log entries:

Bug fixes
When configuring NVDA it will be ensured that at least one key is defined as NVDA key in any situation. (#14527)

Deprecation:
keyboardHandler.SUPPORTED_NVDA_MODIFIER_KEYS is deprecated with no direct replacement. Consider using the class config.configFlags.NVDAKey instead. (#14528)

API breaking changes:

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • Security precautions taken.

@AppVeyorBot
Copy link

See test results for failed build of commit e3c1c5a506

…through startup dialog and remove unneeded imports.
@AppVeyorBot
Copy link

See test results for failed build of commit 2f93e756b8

@AppVeyorBot
Copy link

See test results for failed build of commit 7ac0f5ad22

@CyrilleB79 CyrilleB79 marked this pull request as ready for review January 11, 2023 11:04
@CyrilleB79 CyrilleB79 requested a review from a team as a code owner January 11, 2023 11:04
@CyrilleB79 CyrilleB79 requested a review from seanbudd January 11, 2023 11:04
@seanbudd seanbudd added the merge-early Merge Early in a developer cycle label Jan 11, 2023
@seanbudd seanbudd added this to the 2023.2 milestone Jan 11, 2023
@seanbudd seanbudd added api-breaking-change and removed merge-early Merge Early in a developer cycle labels Jan 12, 2023
@seanbudd seanbudd modified the milestones: 2023.2, 2023.1 Jan 12, 2023
@seanbudd seanbudd marked this pull request as draft January 12, 2023 03:06
@CyrilleB79 CyrilleB79 marked this pull request as ready for review January 13, 2023 12:12
CyrilleB79 and others added 2 commits January 16, 2023 11:14
@CyrilleB79
Copy link
Collaborator Author

@seanbudd I have addressed all the review comments.

However I have raised a new question while addressing the review. Please answer before merging. Thanks.

@seanbudd
Copy link
Member

Note: with this PR, keyboardHandler.SUPPORTED_NVDA_MODIFIER_KEY is not used anymore in NVDA's code. Should I deprecate it?

Yes, this is a good idea. Suggest NVDAKey as a replacement

Copy link
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if I missed any other questions

@CyrilleB79
Copy link
Collaborator Author

Let me know if I missed any other questions

Yes please, your feedback to this comment in nvda.pyw:

While working on the review in nvda_slave.pyw, I realize that the install method does not take any parameter there, wherease here in nvda.pyw, it takes True as parameter. This was already the case before this PR.

The help on this install method is as follows:

>>> help(trans.install)
Help on method install in module gettext:

install(names=None) method of gettext.GNUTranslations instance

And the documentation indicates:

install(names=None)
This method installs gettext() into the built-in namespace, binding it to _.
If the names parameter is given, it must be a sequence containing the names of functions you want to install in the builtins namespace in addition to _(). Supported names are 'gettext', 'ngettext', 'lgettext' and 'lngettext'.

This True parameter does not make sens to me. Is it a bug or something left over after a change in the signature of the install method?

Should I remove this parameter? If yes, should I do it here or in a separate PR (in case this causes unexpected issue and need to be reverted)?

@seanbudd
Copy link
Member

I agree, remove the parameter in this PR.

@CyrilleB79
Copy link
Collaborator Author

I have addressed the parameter issue and implemented the deprecation. I have also updated the initial description's change log with the deprecation info.

The PR is ready to review again.

@CyrilleB79 CyrilleB79 requested a review from seanbudd January 17, 2023 08:41
Copy link
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

@seanbudd seanbudd merged commit c066145 into nvaccess:master Jan 18, 2023
@CyrilleB79 CyrilleB79 deleted the nvdaKey branch January 18, 2023 08:09
seanbudd pushed a commit that referenced this pull request Feb 22, 2023
…bels displayed in the user's language (#14658)

Fixes #14657

Summary of the issue:
In pull request #14528 keyLabels were imported pretty early during NVDA's startup. Since this module contains localized strings at the module level these are translated before languageHandler is initialized. This means that they're translated either to the default language of the system, or for locales for which Python's locale.getdefaultlocale fails they remain in English, disregarding the language set in preferences.

Description of user facing changes
Key labels are once again presented in the language set in preferences.

Description of development approach
keyLabels are imported lazily in the configFlags
I've added docstring to the keyLabels module explaining when it can be safely imported.
Testing strategy:
On a English Windows set NVDA's language to Polish, ensured that key labels in the keyboard help and in the preferences are displayed in Polish.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possibility to have no more NVDA key defined
4 participants