Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make gui.MainFrame.popupSettingsDialog part of the public API #15121

Merged
merged 3 commits into from
Jul 14, 2023
Merged
Changes from all commits
Commits
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
80 changes: 46 additions & 34 deletions source/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import core
from typing import (
Optional,
Type,
)
import systemUtils
from .message import (
Expand All @@ -41,9 +42,25 @@
# Be careful when removing, and only do in a compatibility breaking release.
from .exit import ExitDialog
from .settingsDialogs import (
BrailleDisplaySelectionDialog,
BrailleSettingsPanel,
BrowseModePanel,
DocumentFormattingPanel,
GeneralSettingsPanel,
InputCompositionPanel,
KeyboardSettingsPanel,
MouseSettingsPanel,
MultiCategorySettingsDialog,
NVDASettingsDialog,
ObjectPresentationPanel,
SettingsDialog,
SpeechSettingsPanel,
SpeechSymbolsDialog,
SynthesizerSelectionDialog,
TouchInteractionPanel,
ReviewCursorPanel,
UwpOcrPanel,
)
from .settingsDialogs import *
from .startupDialogs import WelcomeDialog
from .inputGestures import InputGesturesDialog
from . import logViewer
Expand Down Expand Up @@ -169,7 +186,7 @@ def onSaveConfigurationCommand(self,evt):
messageBox(_("Could not save configuration - probably read only file system"),_("Error"),wx.OK | wx.ICON_ERROR)

@blockAction.when(blockAction.Context.MODAL_DIALOG_OPEN)
def _popupSettingsDialog(self, dialog, *args, **kwargs):
def popupSettingsDialog(self, dialog: Type[SettingsDialog], *args, **kwargs):
self.prePopup()
try:
dialog(self, *args, **kwargs).Show()
Expand All @@ -184,15 +201,15 @@ def _popupSettingsDialog(self, dialog, *args, **kwargs):

@blockAction.when(blockAction.Context.SECURE_MODE)
def onDefaultDictionaryCommand(self, evt):
self._popupSettingsDialog(DefaultDictionaryDialog)
self.popupSettingsDialog(DefaultDictionaryDialog)

@blockAction.when(blockAction.Context.SECURE_MODE)
def onVoiceDictionaryCommand(self, evt):
self._popupSettingsDialog(VoiceDictionaryDialog)
self.popupSettingsDialog(VoiceDictionaryDialog)

@blockAction.when(blockAction.Context.SECURE_MODE)
def onTemporaryDictionaryCommand(self, evt):
self._popupSettingsDialog(TemporaryDictionaryDialog)
self.popupSettingsDialog(TemporaryDictionaryDialog)

@blockAction.when(blockAction.Context.SECURE_MODE)
def onExecuteUpdateCommand(self, evt):
Expand All @@ -201,13 +218,13 @@ def onExecuteUpdateCommand(self, evt):
from addonHandler import getIncompatibleAddons
if any(getIncompatibleAddons(apiVersion, backCompatToAPIVersion)):
confirmUpdateDialog = updateCheck.UpdateAskInstallDialog(
parent=gui.mainFrame,
parent=mainFrame,
destPath=destPath,
version=version,
apiVersion=apiVersion,
backCompatTo=backCompatToAPIVersion
)
gui.runScriptModalDialog(confirmUpdateDialog)
runScriptModalDialog(confirmUpdateDialog)
else:
updateCheck.executePendingUpdate()

Expand All @@ -232,57 +249,57 @@ def onExitCommand(self, evt):
log.error("NVDA already in process of exiting, this indicates a logic error.")

def onNVDASettingsCommand(self,evt):
self._popupSettingsDialog(NVDASettingsDialog)
self.popupSettingsDialog(NVDASettingsDialog)

def onGeneralSettingsCommand(self,evt):
self._popupSettingsDialog(NVDASettingsDialog, GeneralSettingsPanel)
self.popupSettingsDialog(NVDASettingsDialog, GeneralSettingsPanel)

def onSelectSynthesizerCommand(self,evt):
self._popupSettingsDialog(SynthesizerSelectionDialog)
self.popupSettingsDialog(SynthesizerSelectionDialog)

def onSpeechSettingsCommand(self,evt):
self._popupSettingsDialog(NVDASettingsDialog, SpeechSettingsPanel)
self.popupSettingsDialog(NVDASettingsDialog, SpeechSettingsPanel)

def onSelectBrailleDisplayCommand(self,evt):
self._popupSettingsDialog(BrailleDisplaySelectionDialog)
self.popupSettingsDialog(BrailleDisplaySelectionDialog)

def onBrailleSettingsCommand(self,evt):
self._popupSettingsDialog(NVDASettingsDialog, BrailleSettingsPanel)
self.popupSettingsDialog(NVDASettingsDialog, BrailleSettingsPanel)

def onKeyboardSettingsCommand(self,evt):
self._popupSettingsDialog(NVDASettingsDialog, KeyboardSettingsPanel)
self.popupSettingsDialog(NVDASettingsDialog, KeyboardSettingsPanel)

def onMouseSettingsCommand(self,evt):
self._popupSettingsDialog(NVDASettingsDialog, MouseSettingsPanel)
self.popupSettingsDialog(NVDASettingsDialog, MouseSettingsPanel)

def onTouchInteractionCommand(self,evt):
self._popupSettingsDialog(NVDASettingsDialog, TouchInteractionPanel)
self.popupSettingsDialog(NVDASettingsDialog, TouchInteractionPanel)

def onReviewCursorCommand(self,evt):
self._popupSettingsDialog(NVDASettingsDialog, ReviewCursorPanel)
self.popupSettingsDialog(NVDASettingsDialog, ReviewCursorPanel)

def onInputCompositionCommand(self,evt):
self._popupSettingsDialog(NVDASettingsDialog, InputCompositionPanel)
self.popupSettingsDialog(NVDASettingsDialog, InputCompositionPanel)

def onObjectPresentationCommand(self,evt):
self._popupSettingsDialog(NVDASettingsDialog, ObjectPresentationPanel)
self.popupSettingsDialog(NVDASettingsDialog, ObjectPresentationPanel)

def onBrowseModeCommand(self,evt):
self._popupSettingsDialog(NVDASettingsDialog, BrowseModePanel)
self.popupSettingsDialog(NVDASettingsDialog, BrowseModePanel)

def onDocumentFormattingCommand(self,evt):
self._popupSettingsDialog(NVDASettingsDialog, DocumentFormattingPanel)
self.popupSettingsDialog(NVDASettingsDialog, DocumentFormattingPanel)

def onUwpOcrCommand(self, evt):
self._popupSettingsDialog(NVDASettingsDialog, UwpOcrPanel)
self.popupSettingsDialog(NVDASettingsDialog, UwpOcrPanel)

@blockAction.when(blockAction.Context.SECURE_MODE)
def onSpeechSymbolsCommand(self, evt):
self._popupSettingsDialog(SpeechSymbolsDialog)
self.popupSettingsDialog(SpeechSymbolsDialog)

@blockAction.when(blockAction.Context.SECURE_MODE)
def onInputGesturesCommand(self, evt):
self._popupSettingsDialog(InputGesturesDialog)
self.popupSettingsDialog(InputGesturesDialog)

def onAboutCommand(self,evt):
# Translators: The title of the dialog to show about info for NVDA.
Expand Down Expand Up @@ -338,16 +355,11 @@ def onAddonsManagerCommand(self, evt: wx.MenuEvent):
blockAction.Context.RUNNING_LAUNCHER,
)
def onAddonStoreCommand(self, evt: wx.MenuEvent):
self.prePopup()
from ._addonStoreGui import AddonStoreDialog
from ._addonStoreGui.viewModels.store import AddonStoreVM
_storeVM = AddonStoreVM()
_storeVM.refresh()
try:
AddonStoreDialog(mainFrame, _storeVM).Show()
except SettingsDialog.MultiInstanceErrorWithDialog as errorWithDialog:
errorWithDialog.dialog.SetFocus()
self.postPopup()
self.popupSettingsDialog(AddonStoreDialog, _storeVM)

def onReloadPluginsCommand(self, evt):
import appModuleHandler, globalPluginHandler
Expand All @@ -362,8 +374,8 @@ def onReloadPluginsCommand(self, evt):
)
def onCreatePortableCopyCommand(self,evt):
self.prePopup()
import gui.installerGui
d=gui.installerGui.PortableCreaterDialog(gui.mainFrame)
from . import installerGui
d = installerGui.PortableCreaterDialog(mainFrame)
d.Show()
self.postPopup()

Expand All @@ -372,7 +384,7 @@ def onCreatePortableCopyCommand(self,evt):
blockAction.Context.MODAL_DIALOG_OPEN,
)
def onInstallCommand(self, evt):
from gui import installerGui
from . import installerGui
installerGui.showInstallGui()

@blockAction.when(
Expand Down Expand Up @@ -414,7 +426,7 @@ def onRunCOMRegistrationFixesCommand(self, evt):
def onConfigProfilesCommand(self, evt):
self.prePopup()
from .configProfiles import ProfilesDialog
ProfilesDialog(gui.mainFrame).Show()
ProfilesDialog(mainFrame).Show()
self.postPopup()


Expand Down