Skip to content
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

Create a MessageDialog API #17304

Merged
merged 214 commits into from
Dec 18, 2024
Merged

Create a MessageDialog API #17304

merged 214 commits into from
Dec 18, 2024

Conversation

SaschaCowley
Copy link
Member

@SaschaCowley SaschaCowley commented Oct 18, 2024

Link to issue number:

Closes #13007
Closes #12344
Closes #12353

Summary of the issue:

Currently, there are several ways to create message boxes/dialogs in NVDA, all of them with their own drawbacks.
Additionally, subclassing wx.Dialog (or using it directly) brings with it the risk of breaking parts of NVDA. See #13007 for in-depth discussion.

Thus, a new API for creating highly customizable dialogs that work well with NVDA is desired.

Description of user facing changes

This PR does not, in itself, introduce any end-user facing changes. However, it lays the groundwork for closing a number of issues.

Description of development approach

Subclassed wx.Dialog to add the desired functionality in #13007

Re-implemented the about box to use a MessageDialog.

Added a callback field to gui.blockAction._Context to allow adding a function to execute when the block condition is met.

Features and tasks

  • Rename buttons
  • Add custom buttons
  • Associate context help with the given message box
  • Show the dialog as a modal or a non-modal
  • for non modal dialogs:
    • provide a default return code when dialogs are forced to close (eg via an exit, perform cancel) (WIP)
    • attach a callback to handle return codes
    • refocus a dialog in the event of needing to close it
    • if a default return code is provided, make the dialog close-able with alt+F4 and escape (WIP)
  • for modal dialogs:
    • if wx.CANCEL is provided, make the dialog close-able with alt+F4 and escape (mostly done)
    • nice to have:
      • if wx.CANCEL is provided, perform this action when dialogs are forced to close.
      • refocus a dialog in the event of needing to close it
  • Ensure that the test Quits from keyboard with about dialog open is re-enabled and works.
  • Block exiting NVDA with modal MessageDialogs open.
  • Focus open MessageDialogs without default actions when exiting.
  • Tests
    • Unit tests
  • Document the new API in the developer guide
  • Migrate the new API from gui.MessageDialog to gui.message.
  • Mark other means of creating message dialogs as deprecated.
    • Re implement their internals to use the new API
      • gui.message.messageBox
      • gui.nvdaControls.MessageDialog
      • gui.nvdaControls._ContinueCancelDialog

Testing strategy:

Unit and manual tests.

Unit tests are extensive, and reach around 85% coverage of the newly added code.

Message box shim tested with a variety of inputs and unittests. This is a fairly straightforward adapter.

nvdaControls.MessageDialog tested that screen curtain and add-on install warning dialogs still work as expected. Its private subclass, _ContinueCancelDialog, was tested by attempting to run the CRFT.

Known issues with pull request:

Internal dialogs are yet to be migrated. This should be done gradually before the existing means of creating message dialogs are removed.

Slightly odd behaviour when a callback function blocks, and focusBlockingInstances is called, where a hidden dialog is focused. This can be worked around, but possibly not without unintended consequences.

Some invalid combinations (namely a button which is set as the default action but set not to close the dialog) are silently changed. While documenting this should be sufficient, logging or raising an exception may be warranted.

Visual proportions of the re-implemented About dialog are different.

The ctrl+c behaviour of copying the dialog's title, contents and buttons is not supported.

Future work

  • Remove all internal use of deprecated message dialog APIs.
  • Remove deprecated message dialog APIs in 2026.1.

Nice to have

  • Implement system tests for the new API.
  • Comprehensively document a manual test plan, and develop any associated scripts.
  • Add the ability to set a callback after a button has been added.
  • Add a helper to add a "don't show this message again" checkbox.

Code Review Checklist:

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

Summary by CodeRabbit

Release Notes for NVDA 2025.1

  • New Features

    • Support for math in PDFs, including MathML formulas.
    • New commands to adjust the volume of other applications.
    • Ability to navigate per sentence in Microsoft PowerPoint using keyboard shortcuts.
    • Enhanced URL reporting in Mozilla Firefox, including text fragments.
    • Added actions in the Add-on Store for managing add-on installations.
    • Support for specifying mirror URLs for updates and the Add-on Store.
    • Sorting options in the Add-on Store by publication date.
    • Automatic language switching with SAPI5 and Microsoft Speech Platform voices.
    • Configuration for braille navigation to speak current lines or paragraphs.
    • Improved reporting of selection updates in Microsoft Word.
  • Documentation

    • Added a new section on the message dialog API in the developer guide, detailing usage and customization options.

tests/unit/test_messageDialog.py Outdated Show resolved Hide resolved
tests/unit/test_messageDialog.py Outdated Show resolved Hide resolved
tests/unit/test_messageDialog.py Outdated Show resolved Hide resolved
tests/unit/test_messageDialog.py Outdated Show resolved Hide resolved
tests/unit/test_messageDialog.py Show resolved Hide resolved
tests/unit/test_messageDialog.py Outdated Show resolved Hide resolved
tests/unit/test_messageDialog.py Outdated Show resolved Hide resolved
tests/unit/test_messageDialog.py Outdated Show resolved Hide resolved
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 @SaschaCowley for all your excellent work here! Full review complete!

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.

yahoo congrats on finishing this!

@SaschaCowley SaschaCowley merged commit 2477780 into master Dec 18, 2024
4 of 5 checks passed
@SaschaCowley SaschaCowley deleted the i13007 branch December 18, 2024 06:53
@github-actions github-actions bot added this to the 2025.1 milestone Dec 18, 2024
@gerald-hartig
Copy link
Collaborator

Nice work @SaschaCowley

SaschaCowley added a commit that referenced this pull request Dec 20, 2024
@SaschaCowley SaschaCowley restored the i13007 branch December 20, 2024 01:02
michaelDCurran pushed a commit that referenced this pull request Dec 20, 2024
This reverts commit 2477780.
Reverts #17304
Issues fixed
Fixes #17560
Fixes #17553
Issues reopened
Reopens #13007
Reopens #12344
Reopens #12353
Reason for revert
This PR broke two important NVDA functions, and there is insufficient time before the Christmas/New Years break to fix the issues, so we are temporarily reverting so that alphas work over the break:
• The CRFT no longer works, as gui.message.MessageDialog's inheritance from ContextHelpMixin was accidentally removed.
• Update checking no longer works, as runScriptModalDialog was modified to increment and decrement _messageBoxCounter, but UpdateAskInstallDialog attempts to restart NVDA before it has been closed, so the update fails as NVDA appears to be in an unsafe state.
@SaschaCowley SaschaCowley mentioned this pull request Jan 6, 2025
7 tasks
SaschaCowley added a commit that referenced this pull request Jan 8, 2025
Closes #13007
Closes #12344
Closes #12353

Summary of the issue:

This is the second PR to merge the message dialog API into NVDA. The previous merge was at `f437723`.
See #17304 for full implementation details.
The original PR was reverted by #17561, due to #17553 and #17560.

Description of user facing changes
This PR does not, in itself, introduce any end-user facing changes. However, it lays the groundwork for closing a number of issues.

Tasks
- [x] Fix the COM registration fixing tool (#17560)
- [x] Fix NVDA updates (#17553)

Description of development approach
Restored `gui.nvdaControls.MessageDialog` inheriting from `ContextHelpMixin`, which was accidentally lost.

Changed `updateCheck.UpdateAskInstallDialog.onUpdateButton` and `onPostponeButton` to simply end the modal, returning the appropriate code. Added a static method to `UpdateAskInstallDialog` which returns a callback function which, when given the return code from `UpdateAskInstallDialog`, performs the appropriate action. Added a property method to generate this callback function given the attributes of the instance on which it is called.

Testing strategy:
Created a portable copy of NVDA (`scons dist`), and tested running the CRFT:

- Running and granting permission - works as expected
- Running and denying permission - works as expected
- Cancelling - works as expected

Added `updateVersionType="snapshot:alpha" to `source/versionInfo.py`, and tested updating with NVDA running from source:

1. Attempt updating via NVDA menu -> Help -> Check for update... -> Download update -> Update - works as expected
2. Update by downloading then postponing update, then exit NVDA -> Install pending update
    a. Without incompatible updates installed - works as expected
    b. With incompatible updates installed - works as expected
3. Update by downloading then postponing update, restarting NVDA, then NVDA menu -> Install pending update - works as expected
4. Update by downloading then postponing update, restarting NVDA, then accepting the prompt to install the update - works as expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.
Projects
None yet
8 participants