Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 84 additions & 21 deletions source/gui/installerGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,88 @@ def _canPortableConfigBeCopied() -> bool:
return True


def _restartWindows() -> bool:
"""Issue a Windows restart command. Returns True if the command succeeded."""
result = subprocess.run(["shutdown", "/r", "/t", "0"], creationflags=subprocess.CREATE_NO_WINDOW)
return result.returncode == 0


def _showPostInstallDialog(isUpdate: bool, startAfterInstall: bool) -> None:
Comment thread
kefaslungu marked this conversation as resolved.
"""Show the post-install dialog after NVDA installation completes.

Presents the user with options to restart Windows, start the installed copy,
or exit NVDA.
"""
if isUpdate:
message = _(
# Translators: The message displayed when NVDA has been successfully updated,
# shown in the post-install dialog.
"Successfully updated your installation of NVDA."
" It is recommended to restart Windows after updating."
" NVDA may malfunction without a restart.",
)
else:
message = _(
# Translators: The message displayed when NVDA has been successfully installed,
# shown in the post-install dialog.
"Successfully installed NVDA."
" It is recommended to restart Windows after installing."
" NVDA may malfunction without a restart.",
)
dialog = MessageDialog(
parent=gui.mainFrame,
message=message,
# Translators: The title of the post-install dialog.
title=_("Success"),
buttons=None,
helpId="RestartWindowsAfterInstall",
)
# Translators: Button in the post-install dialog to restart Windows immediately.
dialog.addButton(ReturnCode.CUSTOM_1, label=_("Restart &Windows"), defaultFocus=True)
if startAfterInstall:
# Translators: Button in the post-install dialog to start the newly installed NVDA.
dialog.addButton(ReturnCode.CUSTOM_2, label=_("&Start NVDA"), fallbackAction=True)
# Translators: Button in the post-install dialog to exit NVDA.
dialog.addButton(ReturnCode.CANCEL, label=_("E&xit NVDA"), fallbackAction=not startAfterInstall)
match dialog.ShowModal():
case ReturnCode.CUSTOM_1:
if _restartWindows():
if not core.triggerNVDAExit(None):
log.error("NVDA already in process of exiting, this indicates a logic error.")
else:
# Restart failed — inform the user.
# Only exit if a new copy can be started so the user keeps a screen reader.
gui.messageBox(
# Translators: Message shown when Windows restart fails after NVDA installation.
_("Failed to restart Windows. Please restart Windows manually."),
# Translators: Title of the error dialog shown when Windows restart fails.
_("Error"),
wx.OK | wx.ICON_ERROR,
)
if startAfterInstall:
Comment thread
seanbudd marked this conversation as resolved.
newNVDA = core.NewNVDAInstance(
filePath=os.path.join(WritePaths.defaultInstallDir, "nvda.exe"),
parameters=_generate_executionParameters(),
)
if not core.triggerNVDAExit(newNVDA):
log.error("NVDA already in process of exiting, this indicates a logic error.")
else:
if not core.triggerNVDAExit(None):
log.error("NVDA already in process of exiting, this indicates a logic error.")
case ReturnCode.CUSTOM_2:
newNVDA = core.NewNVDAInstance(
filePath=os.path.join(WritePaths.defaultInstallDir, "nvda.exe"),
parameters=_generate_executionParameters(),
)
if not core.triggerNVDAExit(newNVDA):
log.error("NVDA already in process of exiting, this indicates a logic error.")
case ReturnCode.CANCEL:
if not core.triggerNVDAExit(None):
log.error("NVDA already in process of exiting, this indicates a logic error.")
case _ as returnCode:
log.error(f"Unexpected return code from post-install dialog: {returnCode}")


def doInstall(
createDesktopShortcut: bool = True,
startOnLogon: bool = False,
Expand Down Expand Up @@ -126,27 +208,8 @@ def doInstall(

startAfterInstall = startAfterInstall and not isRunningElevated()
if not silent:
msg = (
# Translators: The message displayed when NVDA has been successfully installed.
_("Successfully installed NVDA. ")
if not isUpdate
# Translators: The message displayed when NVDA has been successfully updated.
else _("Successfully updated your installation of NVDA. ")
)
gui.messageBox(
msg
+ (
# Translators: The message displayed to the user after NVDA is installed
# and the installed copy is about to be started.
_("Please press OK to start the installed copy.")
if startAfterInstall
# Translators: The message displayed to the user after NVDA is installed
# and the installer is about to close without starting the installed copy.
else _("Please press OK to close the installer.")
),
# Translators: The title of a dialog presented to indicate a successful operation.
_("Success"),
)
_showPostInstallDialog(isUpdate=isUpdate, startAfterInstall=startAfterInstall)
return

newNVDA = None
if startAfterInstall:
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

### New Features

* After installing or updating NVDA, a dialog now offers options to restart Windows, start the installed copy, or exit the installer. (#19268, #19718, @kefaslungu)
* NVDA now includes a built-in Magnifier feature that allows you to zoom and magnify parts of the screen. (#19228, @Boumtchack)
* The magnifier supports various zoom levels, color filters (normal, grayscale, inverted), and different focus tracking modes.
* Color filters can help users with visual impairments or light sensitivity by inverting or desaturating screen colors.
Expand Down
16 changes: 14 additions & 2 deletions user_docs/en/userGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ If you have already closed this dialog or are wanting to install from a portable
The installation dialog that appears will confirm whether you wish to install NVDA and will also tell you whether this installation will be updating a previous install.
Pressing the Continue button will start installing NVDA.
There are also a few options in this dialog which are explained below.
Once the installation has completed, a message will appear telling you that it was successful.
Pressing OK at this point will restart the newly installed copy of NVDA.
Once the installation has completed, a dialog will appear with options for what to do next.
See [Restart Windows After Installation](#RestartWindowsAfterInstall) for more information.

#### Incompatible add-ons warning {#InstallWithIncompatibleAddons}

Expand All @@ -449,6 +449,18 @@ This option allows you to choose whether or not NVDA should copy the user config
This will not copy the configuration for any other users of this system nor to the system configuration for use during Windows sign-in and [other secure screens](#SecureScreens).
This option is only available when installing from a portable copy, not when installing directly from the downloaded Launcher package.

#### Restart Windows After Installation {#RestartWindowsAfterInstall}

After NVDA has been successfully installed or updated, a dialog will appear recommending that you restart Windows.
Restarting ensures that NVDA is fully registered with the system and works correctly in all applications.

The dialog provides the following options:

* Restart Windows: Immediately restart Windows.
* Start NVDA: Start the newly installed copy of NVDA without restarting.
* Note: this option is not available when the installer is run with elevated (administrator) privileges.
* Exit NVDA: Close without starting NVDA or restarting Windows.

Comment thread
kefaslungu marked this conversation as resolved.
### Creating a Portable Copy {#CreatingAPortableCopy}

If creating a portable copy directly from the NVDA download package, press the Create Portable Copy button.
Expand Down
Loading