Skip to content

Commit

Permalink
incubates #6197
Browse files Browse the repository at this point in the history
Adds option to open speech viewer on startup. Re #5050

Merge branch 'i5050-AddOptionForSpeechViewerOnStartup' into next
  • Loading branch information
feerrenrut committed Jul 29, 2016
2 parents 3fb3144 + 7bed789 commit 9b1f771
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions source/config/__init__.py
Expand Up @@ -135,6 +135,9 @@ def validateConfig(configObj,validator,validationResult=None,keyList=None):
audioCoordinates_maxPitch = integer(default=880)
reportMouseShapeChanges = boolean(default=false)
[speechViewer]
showSpeechViewerAtStartup = boolean(default=false)
#Keyboard settings
[keyboard]
useCapsLockAsNVDAModifierKey = boolean(default=false)
Expand Down
3 changes: 2 additions & 1 deletion source/core.py
Expand Up @@ -53,6 +53,8 @@ def doStartupDialogs():
wx.OK | wx.ICON_EXCLAMATION)
if config.conf["general"]["showWelcomeDialogAtStartup"]:
gui.WelcomeDialog.run()
if config.conf["speechViewer"]["showSpeechViewerAtStartup"]:
gui.mainFrame.onToggleSpeechViewerCommand(evt=None)
import inputCore
if inputCore.manager.userGestureMap.lastUpdateContainedError:
import wx
Expand Down Expand Up @@ -237,7 +239,6 @@ def onEndSession(evt):
log.debug("Initializing GUI")
import gui
gui.initialize()

import audioDucking
if audioDucking.isAudioDuckingSupported():
# the GUI mainloop must be running for this to work so delay it
Expand Down
15 changes: 13 additions & 2 deletions source/speechViewer.py
Expand Up @@ -6,9 +6,10 @@

import wx
import gui
import config
from logHandler import log

class SpeechViewerFrame(wx.MiniFrame):
class SpeechViewerFrame(wx.Dialog):

def __init__(self, onDestroyCallBack):
super(SpeechViewerFrame, self).__init__(gui.mainFrame, wx.ID_ANY, _("NVDA Speech Viewer"), style=wx.CAPTION | wx.RESIZE_BORDER | wx.STAY_ON_TOP)
Expand All @@ -18,6 +19,13 @@ def __init__(self, onDestroyCallBack):
sizer = wx.BoxSizer(wx.VERTICAL)
self.textCtrl = wx.TextCtrl(self, -1,size=(500,500),style=wx.TE_RICH2|wx.TE_READONLY|wx.TE_MULTILINE)
sizer.Add(self.textCtrl, proportion=1, flag=wx.EXPAND)
# Translators: The label for a setting in the speech viewer that controls whether the speech viewer is shown at startup or not.
self.shouldShowOnStartupCheckBox = wx.CheckBox(self,wx.NewId(),label=_("&Show Speech Viewer on Startup"))
self.shouldShowOnStartupCheckBox.SetValue(config.conf["speechViewer"]["showSpeechViewerAtStartup"])
self.shouldShowOnStartupCheckBox.Bind(wx.EVT_CHECKBOX, self.onShouldShowOnStartupChanged)
sizer.Add(self.shouldShowOnStartupCheckBox, border=5, flag=wx.ALL)
# set the check box as having focus, by default the textCtrl has focus which stops the speechviewer output (even if another window is in focus)
self.shouldShowOnStartupCheckBox.SetFocus()
sizer.Fit(self)
self.SetSizer(sizer)
self.Show(True)
Expand All @@ -30,6 +38,9 @@ def onClose(self, evt):
return
evt.Veto()

def onShouldShowOnStartupChanged(self, evt):
config.conf["speechViewer"]["showSpeechViewerAtStartup"] = self.shouldShowOnStartupCheckBox.IsChecked()

def onDestroy(self, evt):
log.debug("SpeechViewer destroyed")
self.onDestroyCallBack()
Expand All @@ -48,7 +59,7 @@ def appendText(text):
if not isinstance(text,basestring):
return
#If the speech viewer text control has the focus, we want to disable updates
#Otherwize it would be impossible to select text, or even just read it (as a blind person).
#Otherwise it would be impossible to select text, or even just read it (as a blind person).
if _guiFrame.FindFocus()==_guiFrame.textCtrl:
return
_guiFrame.textCtrl.AppendText(text + "\n")
Expand Down

0 comments on commit 9b1f771

Please sign in to comment.