Skip to content

Commit f2ee2af

Browse files
authored
Merge 4ce4dc3 into f2bb38c
2 parents f2bb38c + 4ce4dc3 commit f2ee2af

4 files changed

Lines changed: 49 additions & 8 deletions

File tree

source/gui/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from . import guiHelper
2727
from .settingsDialogs import SettingsDialog
2828
from .settingsDialogs import *
29+
from .startupDialogs import WelcomeDialog
2930
from .inputGestures import InputGesturesDialog
3031
import speechDictHandler
3132
from . import logViewer
@@ -367,7 +368,7 @@ def onConfigProfilesCommand(self, evt):
367368

368369
class SysTrayIcon(wx.adv.TaskBarIcon):
369370

370-
def __init__(self, frame):
371+
def __init__(self, frame: MainFrame):
371372
super(SysTrayIcon, self).__init__()
372373
icon=wx.Icon(ICON_PATH,wx.BITMAP_TYPE_ICO)
373374
self.SetIcon(icon, versionInfo.name)
@@ -684,6 +685,7 @@ def onOk(self, evt):
684685
if action >= 2 and config.isAppX:
685686
action += 1
686687
if action == 0:
688+
WelcomeDialog.saveAndCloseInstances()
687689
if not core.triggerNVDAExit():
688690
log.error("NVDA already in process of exiting, this indicates a logic error.")
689691
return # there's no need to destroy ExitDialog in this instance as triggerNVDAExit will do this

source/gui/startupDialogs.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# This file may be used under the terms of the GNU General Public License, version 2 or later.
55
# For more details see: https://www.gnu.org/licenses/gpl-2.0.html
66

7+
from typing import Set
8+
import weakref
79
import wx
810

911
import config
@@ -36,10 +38,12 @@ class WelcomeDialog(
3638
"Press NVDA+n at any time to activate the NVDA menu.\n"
3739
"From this menu, you can configure NVDA, get help and access other NVDA functions."
3840
)
41+
_instances: Set["WelcomeDialog"] = weakref.WeakSet()
3942

4043
def __init__(self, parent):
4144
# Translators: The title of the Welcome dialog when user starts NVDA for the first time.
4245
super().__init__(parent, wx.ID_ANY, _("Welcome to NVDA"))
46+
WelcomeDialog._instances.add(self)
4347

4448
mainSizer = wx.BoxSizer(wx.VERTICAL)
4549
# Translators: The header for the Welcome dialog when user starts NVDA for the first time.
@@ -108,6 +112,7 @@ def onOk(self, evt):
108112
except Exception:
109113
log.debugWarning("Could not save", exc_info=True)
110114
self.EndModal(wx.ID_OK)
115+
self.Close()
111116

112117
@classmethod
113118
def run(cls):
@@ -117,9 +122,17 @@ def run(cls):
117122
gui.mainFrame.prePopup()
118123
d = cls(gui.mainFrame)
119124
d.ShowModal()
120-
wx.CallAfter(d.Destroy)
121125
gui.mainFrame.postPopup()
122126

127+
@classmethod
128+
def saveAndCloseInstances(cls):
129+
instances = list(cls._instances)
130+
for instance in instances:
131+
if instance and not instance.IsBeingDeleted() and instance.IsModal():
132+
instance.onOk(None) # Save and close
133+
else:
134+
cls._instances.remove(instance)
135+
123136

124137
class LauncherDialog(
125138
gui.contextHelp.ContextHelpMixin,

tests/system/robot/startupShutdownNVDA.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ def NVDA_Starts():
3939
_process.process_should_be_running(_nvdaProcessAlias)
4040

4141

42+
def open_welcome_dialog_from_menu():
43+
spy = _nvdaLib.getSpyLib()
44+
spy.emulateKeyPress("NVDA+n")
45+
spy.emulateKeyPress("h")
46+
spy.emulateKeyPress("l")
47+
spy.wait_for_specific_speech("Welcome to NVDA") # ensure the dialog is present.
48+
49+
50+
def open_about_dialog_from_menu():
51+
spy = _nvdaLib.getSpyLib()
52+
spy.emulateKeyPress("NVDA+n")
53+
spy.emulateKeyPress("h")
54+
spy.emulateKeyPress("a")
55+
spy.wait_for_specific_speech("About NVDA") # ensure the dialog is present.
56+
57+
4258
def quits_from_menu(showExitDialog=True):
4359
"""Ensure NVDA can be quit from menu."""
4460
spy = _nvdaLib.getSpyLib()
@@ -61,17 +77,14 @@ def quits_from_menu(showExitDialog=True):
6177
_builtIn.sleep(1) # the dialog is not always receiving the enter keypress, wait a little for it
6278
spy.emulateKeyPress("enter", blockUntilProcessed=False) # don't block so NVDA can exit
6379

64-
_process.wait_for_process(_nvdaProcessAlias, timeout="10 sec")
80+
_process.wait_for_process(_nvdaProcessAlias, timeout="3 sec")
6581
_process.process_should_be_stopped(_nvdaProcessAlias)
6682

6783

6884
def quits_from_keyboard():
6985
"""Ensure NVDA can be quit from keyboard."""
7086
spy = _nvdaLib.getSpyLib()
71-
spy.wait_for_specific_speech("Welcome to NVDA") # ensure the dialog is present.
72-
spy.wait_for_speech_to_finish()
73-
_builtIn.sleep(1) # the dialog is not always receiving the enter keypress, wait a little longer for it
74-
spy.emulateKeyPress("enter")
87+
_builtIn.sleep(1) # the dialog is not always receiving the enter keypress, wait a little for it
7588

7689
spy.emulateKeyPress("NVDA+q")
7790
exitTitleIndex = spy.wait_for_specific_speech("Exit NVDA")
@@ -87,8 +100,9 @@ def quits_from_keyboard():
87100
])
88101
)
89102
_builtIn.sleep(1) # the dialog is not always receiving the enter keypress, wait a little longer for it
103+
_process.process_should_be_running(_nvdaProcessAlias)
90104
spy.emulateKeyPress("enter", blockUntilProcessed=False) # don't block so NVDA can exit
91-
_process.wait_for_process(_nvdaProcessAlias, timeout="10 sec")
105+
_process.wait_for_process(_nvdaProcessAlias, timeout="3 sec")
92106
_process.process_should_be_stopped(_nvdaProcessAlias)
93107

94108

tests/system/robot/startupShutdownNVDA.robot

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ Quits from keyboard
3636
[Documentation] Starts NVDA and ensures that it can be quit using the keyboard
3737
quits_from_keyboard # run test
3838

39+
Quits from keyboard with welcome dialog open
40+
[Documentation] Starts NVDA and ensures that it can be quit with the welcome dialog open
41+
[Setup] start NVDA standard-dontShowWelcomeDialog.ini
42+
open welcome dialog from menu
43+
quits from keyboard # run test
44+
45+
Quits from keyboard with about dialog open
46+
[Documentation] Starts NVDA and ensures that it can be quit with the about dialog open
47+
[Setup] start NVDA standard-dontShowWelcomeDialog.ini
48+
open about dialog from menu
49+
quits from keyboard # run test
50+
3951
Quits from menu
4052
[Documentation] Starts NVDA and ensures that it can be quit using the keyboard
4153
[Setup] start NVDA standard-dontShowExitDialog.ini

0 commit comments

Comments
 (0)