nvda icon indicating copy to clipboard operation
nvda copied to clipboard

Setting search (experimental)

Open ABuffEr opened this issue 2 months ago • 3 comments

Link to issue number:

Possible experimental implementation for #16500

Summary of the issue:

NVDA does not provide any search/filter in settings.

Description of user facing changes

User can type in the search field, above the category list, and wait that the first result is focused. Then, he can press F3 to move on other results.

Description of development approach

First, this PR is just a proof-of-concept; it's not completed, and I don't know whether I'll be able to continue it further. I publish it today with the hope this work would be useful in any way.; so contributions or completely new PRs based on it are absolutely welcome.

So, what I did and how:

I worked only under MultiCategorySettingsDialog class. In makeSettings, added a search field with a timer, that launches search after 500 ms after user stops typing. In onFilterEditTextChange, the timer is restarted each time user digit a new char. In onCharHook, F3 calls onFilterEditTextReady to get new results (or cycle over them). In onFilterEditTextReady, the search field value is split into a list (to implement OR search), and I use itertools.cycle to manage circularly the result generator (and to cache its values). The method takes care also to adjust focus and selection of results. In searchGenerator there are two main parts: the for loop that loops over categories, that creates a generator for each category panel and yields results as long as there are ones; and the inner generator, that recursively searches on category panel controls to find one with value/label matching any search terms (via searchInLabel method), and yields a tuple as result, containing the matching wx control and the index (on first item) or the wx control to move focus to.

(see known issues)

Testing strategy:

Manual, searching various terms like exit, pitch, color, bookmark, and so on.

Known issues with pull request:

  • search is quite slow when many category panels are not instantiated yet;
  • closing settings dialog after a search often does not terminates all instances, raising MultiInstance error when you try to reopen it (I was not able to understand why);
  • implementing a shift+F3/previous result feature seems quite tricky;
  • having used no threading mechanism, the search is blocking against main thread, I suppose; I thought to implement a consumer-producer pattern, with a result list filled by background threads, but it's just an idea for now.

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.

ABuffEr avatar May 07 '24 15:05 ABuffEr