Skip to content

Commit b7653da

Browse files
authored
Merge becd99a into 20342a3
2 parents 20342a3 + becd99a commit b7653da

2 files changed

Lines changed: 94 additions & 25 deletions

File tree

source/gui/__init__.py

Lines changed: 88 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
# messageBox is accessed through `gui.messageBox` as opposed to `gui.message.messageBox` throughout NVDA,
3131
# be cautious when removing
3232
messageBox,
33+
displayDialogAsModal,
3334
)
35+
from .nvdaControls import MessageDialog
3436
from . import blockAction
3537
from .speechDict import (
3638
DefaultDictionaryDialog,
@@ -67,6 +69,7 @@
6769
import speechViewer
6870
import winUser
6971
import api
72+
import gui.contextHelp as contextHelp
7073
import NVDAState
7174

7275

@@ -438,35 +441,96 @@ def onInstallCommand(self, evt):
438441
blockAction.Context.SECURE_MODE,
439442
blockAction.Context.MODAL_DIALOG_OPEN,
440443
)
441-
def onRunCOMRegistrationFixesCommand(self, evt):
442-
if messageBox(
443-
# Translators: A message to warn the user when starting the COM Registration Fixing tool
444-
_("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?"),
445-
# Translators: The title of the warning dialog displayed when launching the COM Registration Fixing tool
446-
_("Warning"),wx.YES|wx.NO|wx.ICON_WARNING,self
447-
)==wx.NO:
444+
def onRunCOMRegistrationFixesCommand(self, evt) -> None:
445+
"""Manages the interactive running of the COM Registration Fixing Tool.
446+
Shows a dialog to the user, giving an overview of what is going to happen.
447+
If the user chooses to continue: runs the tool, and displays a completion dialog.
448+
Cancels the run attempt if the user fails or declines the UAC prompt.
449+
"""
450+
# Translators: Explain the COM Registration Fixing tool to users before running
451+
introMessage: str = _(
452+
"""Welcome to the COM Registration Fixing tool.
453+
This tool is used by NVDA to fix problems it may have as it tries to interact with various applications, or with Windows itself.\n
454+
It examines the system registry for corrupted or missing accessibility entries and will correct them.\n
455+
Those entries can sometimes be damaged by installing or uninstalling programs, or other system events. This can result in "unknown" or "pane" being spoken instead of the content you were expecting, or previously accessible elements suddenly no longer reading correctly.\n\n
456+
You have most likely been asked to run this tool by NVDA support or a power user trying to assist you.\n
457+
Because it needs to modify the Windows registry, if you have User Account Control (UAC) active, you will be prompted by UAC before this tool can do its job. This is normal and you should answer by pressing the yes button.\n\n
458+
Do you wish to try to repair the registry now?\n""" # noqa: E501 Flake8 sees this block as one line
459+
)
460+
# Translators: The title of various dialogs displayed when using the COM Registration Fixing tool
461+
genericTitle: str = _("Fix COM Registrations")
462+
'''class CRFTInfoPromptDialog(MessageDialog):
463+
def _addButtons(self, buttonHelper):
464+
"""Adds continue / cancel buttons.
465+
"""
466+
continueButton = buttonHelper.addButton(
467+
self,
468+
id=wx.ID_OK,
469+
# Translators: a button in the COM Registration Fixing Tool info dialog which will run the tool.
470+
label=_("&Continue")
471+
)
472+
continueButton.SetDefault()
473+
continueButton.Bind(wx.EVT_BUTTON, lambda evt: self.EndModal(wx.OK))
474+
cancel = buttonHelper.addButton(
475+
self,
476+
id=wx.ID_CANCEL,
477+
# Translators: Cancels the COM Registration Fixing Tool.
478+
label=_("Cancel")
479+
)
480+
cancel.Bind(wx.EVT_BUTTON, lambda evt: self.EndModal(wx.CANCEL))
481+
#response = displayDialogAsModal(CRFTInfoPromptDialog(
482+
'''
483+
response: int = messageBox(
484+
introMessage,
485+
caption=genericTitle,
486+
style=wx.YES_NO | wx.CANCEL | wx.STAY_ON_TOP,
487+
parent=self
488+
)
489+
if response == wx.CANCEL or response == wx.NO:
490+
log.debug("Run of COM Registration Fixing Tool canceled before UAC.")
448491
return
449-
progressDialog = IndeterminateProgressDialog(mainFrame,
450-
# Translators: The title of the dialog presented while NVDA is running the COM Registration fixing tool
451-
_("COM Registration Fixing Tool"),
452-
# Translators: The message displayed while NVDA is running the COM Registration fixing tool
453-
_("Please wait while NVDA tries to fix your system's COM registrations.")
492+
progressDialog = IndeterminateProgressDialog(
493+
mainFrame,
494+
genericTitle,
495+
# Translators: The message displayed while NVDA is running the COM Registration fixing tool
496+
_("Please wait while NVDA attempts to fix your system's COM registrations...")
454497
)
498+
error: Optional[str] = None
455499
try:
456500
systemUtils.execElevated(config.SLAVE_FILENAME, ["fixCOMRegistrations"])
457-
except:
458-
log.error("Could not execute fixCOMRegistrations command",exc_info=True)
459-
progressDialog.done()
460-
del progressDialog
501+
except WindowsError as e:
502+
# 1223 is "The operation was canceled by the user."
503+
if e.winerror == 1223:
504+
# Same as if the user selected "no" in the initial dialog.
505+
log.debug("Run of COM Registration Fixing Tool canceled during UAC.")
506+
return
507+
else:
508+
log.error("Could not execute fixCOMRegistrations command", exc_info=True)
509+
error = e # Hold for later display to the user
510+
return # Safe because of finally block
511+
except Exception as e:
512+
log.error("Could not execute fixCOMRegistrations command", exc_info=True)
513+
return
514+
finally: # Clean up the progress dialog, and display any important error to the user before returning
515+
progressDialog.done()
516+
del progressDialog
517+
self.postPopup()
518+
# If there was a Windows error, inform the user because it may have support value
519+
if error is not None:
520+
messageBox(
521+
_(
522+
# Translators: message shown to the user on COM Registration Fix fail
523+
"The COM Registration Fixing Tool was unsuccessful. This Windows "
524+
"error may provide more information. {}"
525+
).format(error),
526+
# Translators: Added to the title of the dialog showing the COM Registration Fix failure
527+
genericTitle + " " + _("Failed"), wx.OK
528+
)
529+
# Display success dialog if there were no errors
461530
messageBox(
462-
_(
463-
# Translators: The message displayed when the COM Registration Fixing tool completes.
464-
"The COM Registration Fixing tool has finished. "
465-
"It is highly recommended that you restart your computer now, to make sure the changes take full effect."
466-
),
467-
# Translators: The title of a dialog presented when the COM Registration Fixing tool is complete.
468-
_("COM Registration Fixing Tool"),
469-
wx.OK
531+
# Translators: Message shown when the COM Registration Fixing tool completes.
532+
_("The COM Registration Fixing Tool has completed successfully."),
533+
genericTitle, wx.OK
470534
)
471535

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

user_docs/en/changes.t2t

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ What's New in NVDA
3636
- Allows splitting NVDA sounds in one channel (e.g. left) while sounds from all other applications in the other channel (e.g. right).
3737
- Toggled by ``NVDA+alt+s``.
3838
-
39-
39+
-
4040

4141
== Changes ==
4242
- Add-on Store:
@@ -51,6 +51,10 @@ What's New in NVDA
5151
-
5252
-
5353
- Padding dots commonly used in tables of contents are not reported anymore at low punctuation levels. (#15845, @CyrilleB79)
54+
- Changes to the COM Registration Fixing Tool:
55+
- It will now show a message to the user, including the error, in the rare event of a Windows error while attempting COM re-registrations. (#12355, @XLTechie) - The tool no longer starts with off-putting warning language. (#12351, @XLTechie)
56+
- The initial window can now be exited with ``escape`` or ``alt+F4``. (#10799, @XLTechie)
57+
-
5458
-
5559

5660
== Bug Fixes ==
@@ -74,6 +78,7 @@ What's New in NVDA
7478
-
7579
- Fixed a rare case when saving the configuration may fail to save all profiles. (#16343, @CyrilleB79)
7680
-In Firefox and Chromium-based browsers, NVDA will correctly enter focus mode when pressing enter when positioned within a presentational list (ul / ol) inside editable content. (#16325)
81+
- The COM Registration Fixing Tool will no longer claim success, if it fails or is cancelled during the UAC phase. (#12345, @XLTechie)
7782
-
7883

7984

0 commit comments

Comments
 (0)