Skip to content

Move some classes from the main gui module.#12105

Merged
seanbudd merged 6 commits into
nvaccess:masterfrom
lukaszgo1:I11950
Mar 23, 2021
Merged

Move some classes from the main gui module.#12105
seanbudd merged 6 commits into
nvaccess:masterfrom
lukaszgo1:I11950

Conversation

@lukaszgo1

@lukaszgo1 lukaszgo1 commented Feb 26, 2021

Copy link
Copy Markdown
Contributor

Link to issue number:

Related to #11950 , #11951 and #11958

Summary of the issue:

Code layout in the gui module is sup optimal. This can easily cause cyclic imports for one such example see #11950
While the issue mentioned above has been resolved it makes sense to reorganize this part of the code to minimize likelihood of similar problems in the future.

Description of how this pull request fixes the issue:

  • LauncherDialog, WelcomeDialog and AskAllowUsageStatsDialog were moved to the gui.startupDialogs module
  • getDocFilePath has been moved into the new documentationUtils module as there is no logical connection between it and gui

Testing strategy:

Manual testing:

  • Ensured that user guide, license file and change log can be opened both from binary copy and from sources.
  • Ensured that LauncherDialog is shown and works as expected when starting from the launcher.
  • Ensured that WelcomeDialog can be invoked from the help menu
  • Ensured that dialog which asks about stats collection still works as expected.
  • Ensured that context help works for all 3 moved dialogs and for a randomly chosen settings panel.

Known issues with pull request:

There are more places in the gui package which might benefit from the code reorganization.

Change log entry:

Section: Changes for developers:

  • WelcomeDialog, LauncherDialog and AskAllowUsageStatsDialog are moved to the gui.startupDialogs
  • getDocFilePath has been moved from gui to the documentationUtils module.

Code Review Checklist:

This checklist is a reminder of things commonly forgotten in a new PR.
Authors, please do a self-review and confirm you have considered the following items.
Mark items you have considered by checking them.
You can do this when editing the Pull request description with an x: [ ] becomes [x].
You can also check the checkboxes after the PR is created.

  • Pull Request description is up to date.
  • Unit tests.
  • System (end to end) tests.
  • Manual tests.
  • User Documentation.
  • Change log entry.
  • Context sensitive help for GUI changes.

@lukaszgo1

Copy link
Copy Markdown
Contributor Author

cc @feerrenrut

@seanbudd seanbudd mentioned this pull request Mar 18, 2021
18 tasks
@seanbudd seanbudd added the deprecated/2021.1 Label used to track deprecations due for removal in the 2021.1 release label Mar 18, 2021
@seanbudd seanbudd added this to the 2021.1 milestone Mar 18, 2021
@lukaszgo1

Copy link
Copy Markdown
Contributor Author

I've merged the latest master and fixed merge conflicts.

@seanbudd seanbudd self-assigned this Mar 22, 2021

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this @lukaszgo1, left some minor feedback but otherwise looks good to me

Comment thread source/core.py
Comment on lines +82 to +83
from gui.startupDialogs import WelcomeDialog
WelcomeDialog.run()

@seanbudd seanbudd Mar 22, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
from gui.startupDialogs import WelcomeDialog
WelcomeDialog.run()
gui.startupDialogs.WelcomeDialog.run()

I think we are trying to avoid these imports that aren't at the top of file, or the most outer scope when this isn't possible. Since gui has already been imported at the top of doStartupDialogs, if you want to import WelcomeDialog directly, it would be preferable to add the from gui.startupDialogs import WelcomeDialog statement to the top of doStartupDialogs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is a matter of style obviously, however since WelcomeDialog is used only for users who haven't disabled it so a very small percentage isn't it wasteful to always import it rather than do it conditionally as it is done now?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes, definitely a matter of preference. From a discussion with another developer these are fine as is. However in this case wouldn't there be no performance changes because the entire gui module has already been imported in the same scope?

Comment thread source/core.py
Comment thread source/documentationUtils.py Outdated
Comment thread source/gui/__init__.py
Comment thread source/gui/contextHelp.py Outdated
Comment thread source/gui/startupDialogs.py Outdated
Comment thread source/gui/startupDialogs.py Outdated
@seanbudd seanbudd merged commit fc6b73f into nvaccess:master Mar 23, 2021
@lukaszgo1 lukaszgo1 deleted the I11950 branch March 23, 2021 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecated/2021.1 Label used to track deprecations due for removal in the 2021.1 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants