Skip to content

Commit 054795c

Browse files
authored
Merge cb0466e into 72e4ff9
2 parents 72e4ff9 + cb0466e commit 054795c

1 file changed

Lines changed: 90 additions & 22 deletions

File tree

source/gui/__init__.py

Lines changed: 90 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
# messageBox is accessed through `gui.messageBox` as opposed to `gui.message.messageBox` throughout NVDA,
3333
# be cautious when removing
3434
messageBox,
35+
displayDialogAsModal,
3536
)
37+
from nvdaControls import MessageDialog
3638
from . import blockAction
3739
from .speechDict import (
3840
DefaultDictionaryDialog,
@@ -69,6 +71,7 @@
6971
import speechViewer
7072
import winUser
7173
import api
74+
import gui.contextHelp as contextHelp
7275
import NVDAState
7376

7477

@@ -430,34 +433,99 @@ def onInstallCommand(self, evt):
430433
blockAction.Context.MODAL_DIALOG_OPEN,
431434
)
432435
def onRunCOMRegistrationFixesCommand(self, evt):
433-
if messageBox(
434-
# Translators: A message to warn the user when starting the COM Registration Fixing tool
435-
_("You are about to run the COM Registration Fixing tool. This tool will try to fix common system problems that stop NVDA from being able to access content in many programs including Firefox and Internet Explorer. This tool must make changes to the System registry and therefore requires administrative access. Are you sure you wish to proceed?"),
436-
# Translators: The title of the warning dialog displayed when launching the COM Registration Fixing tool
437-
_("Warning"),wx.YES|wx.NO|wx.ICON_WARNING,self
438-
)==wx.NO:
436+
"""Manages the interactive running of the COM Registration Fixing Tool.
437+
Shows a dialog to the user, giving a brief overview of what is going to happen.
438+
If the user chooses to continue: runs the tool, and displays a completion dialog.
439+
Silently cancels the run attempt if the user fails or declines the UAC prompt.
440+
"""
441+
self.prePopup()
442+
# Translators: Explain the COM Registration Fixing tool to users before running
443+
INTRO_MESSAGE = _("""Welcome to the COM Registration Fixing tool.
444+
This tool is used by NVDA to fix problems it may have as it tries to interact
445+
with various applications, or with Windows itself.
446+
It examines the system registry for corrupted or missing accessibility entries and will correct them.
447+
Those entries can sometimes be damaged by installing or uninstalling programs,
448+
or other system events. This can result in "unknown" or "pane" being spoken instead of the content you
449+
were expecting, or previously accessible elements suddenly no longer reading correctly.
450+
451+
You have most likely been asked to run this tool by NVDA support or a power user trying to assist you.
452+
453+
Because it may need to modify the Windows registry, if you have User Account Control (UAC) active, you will
454+
be prompted by UAC before it can do its job. This is normal and you should answer using the Yes button.
455+
456+
Do you wish to try to repair the registry at this time?""") # noqa: E501 Flake8 sees this block as one line
457+
class CRFTInfoPromptDialog(MessageDialog):
458+
def _addButtons(self, buttonHelper):
459+
"""Adds continue / cancel buttons.
460+
"""
461+
continueButton = buttonHelper.addButton(
462+
self,
463+
id=wx.ID_OK,
464+
# Translators: a button in the COM Registration Fixing Tool info dialog which will run the tool.
465+
label=_("&Continue")
466+
)
467+
continueButton.SetDefault()
468+
continueButton.Bind(wx.EVT_BUTTON, lambda evt: self.EndModal(wx.OK))
469+
cancel = buttonHelper.addButton(
470+
self,
471+
id=wx.ID_CANCEL,
472+
# Translators: Cancels the COM Registration Fixing Tool.
473+
label=_("Cancel")
474+
)
475+
cancel.Bind(wx.EVT_BUTTON, lambda evt: self.EndModal(wx.CANCEL))
476+
response = displayDialogAsModal(CRFTInfoPromptDialog(
477+
self,
478+
# Translators: The title of the notice dialog displayed when launching the COM Registration Fixing tool
479+
_("Fix COM Registrations"),
480+
INTRO_MESSAGE
481+
))
482+
if response == wx.CANCEL:
483+
log.debug("Run of COM Registration Fixing Tool canceled before UAC.")
439484
return
440-
progressDialog = IndeterminateProgressDialog(mainFrame,
441-
# Translators: The title of the dialog presented while NVDA is running the COM Registration fixing tool
485+
progressDialog = IndeterminateProgressDialog(
486+
mainFrame,
487+
# Translators: The title of the dialog presented while NVDA is running the COM Registration fixing tool
442488
_("COM Registration Fixing Tool"),
443-
# Translators: The message displayed while NVDA is running the COM Registration fixing tool
444-
_("Please wait while NVDA tries to fix your system's COM registrations.")
489+
# Translators: The message displayed while NVDA is running the COM Registration fixing tool
490+
_("Please wait while NVDA attempts to fix your system's COM registrations...")
445491
)
446492
try:
493+
error = None
447494
systemUtils.execElevated(config.SLAVE_FILENAME, ["fixCOMRegistrations"])
448-
except:
449-
log.error("Could not execute fixCOMRegistrations command",exc_info=True)
450-
progressDialog.done()
451-
del progressDialog
495+
except WindowsError as e:
496+
# 1223 is "The operation was canceled by the user."
497+
if e.winerror == 1223:
498+
# Same as if the user selected "no" in the initial dialog.
499+
log.debug("Run of COM Registration Fixing Tool canceled during UAC.")
500+
return
501+
else:
502+
log.error("Could not execute fixCOMRegistrations command", exc_info=True)
503+
error = e # Hold for later display to the user
504+
return
505+
except Exception as e:
506+
log.error("Could not execute fixCOMRegistrations command", exc_info=True)
507+
return
508+
finally: # Clean up the progress dialog, and display any important error to the user before returning
509+
progressDialog.done()
510+
del progressDialog
511+
# If there was a Windows error, inform the user because it may have support value
512+
if error is not None:
513+
messageBox(
514+
_(
515+
# Translators: message shown to the user on COM Registration Fix fail
516+
"The COM Registration Fixing Tool was unsuccessful. This Windows "
517+
"error may provide more information. {}"
518+
).format(error),
519+
# Translators: title of the dialog showing the COM Registration Fix failure
520+
_("COM Registration Fix Tool Failed"), wx.OK
521+
)
522+
# Display success dialog if there were no errors
452523
messageBox(
453-
_(
454-
# Translators: The message displayed when the COM Registration Fixing tool completes.
455-
"The COM Registration Fixing tool has finished. "
456-
"It is highly recommended that you restart your computer now, to make sure the changes take full effect."
457-
),
458-
# Translators: The title of a dialog presented when the COM Registration Fixing tool is complete.
459-
_("COM Registration Fixing Tool"),
460-
wx.OK
524+
# Translators: Message shown when the COM Registration Fixing tool completes.
525+
_("The COM Registration Fixing Tool has completed successfully."),
526+
# Translators: The title of a dialog presented when the COM Registration
527+
# Fixing Tool completes successfully.
528+
_("COM Registration Fixing Tool"), wx.OK
461529
)
462530

463531
@blockAction.when(blockAction.Context.MODAL_DIALOG_OPEN)

0 commit comments

Comments
 (0)