Skip to content

Commit 744b79d

Browse files
authored
Merge a77a7cb into e1f3ba9
2 parents e1f3ba9 + a77a7cb commit 744b79d

File tree

4 files changed

+65
-11
lines changed

4 files changed

+65
-11
lines changed

source/core.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,17 @@ def main():
226226
log.debug("loading config")
227227
import config
228228
config.initialize()
229+
if globalVars.appArgs.configPath == config.getUserDefaultConfigPath(useInstalledPathIfExists=True):
230+
# Make sure not to offer the ability to copy the current configuration to the user account.
231+
# This case always applies to the launcher when configPath is not overridden by the user,
232+
# which is the default.
233+
# However, if a user wants to run the launcher with a custom configPath,
234+
# it is likely that he wants to copy that configuration when installing.
235+
# This check also applies to cases where a portable copy is run using the installed configuration,
236+
# in which case we want to avoid copying a configuration to itself.
237+
# We set the value to C{None} in order for the gui to determine
238+
# when to disable the checkbox for this feature.
239+
globalVars.appArgs.copyPortableConfig = None
229240
if config.conf['development']['enableScratchpadDir']:
230241
log.info("Developer Scratchpad mode enabled")
231242
if not globalVars.appArgs.minimal and config.conf["general"]["playStartAndExitSounds"]:
@@ -475,7 +486,11 @@ def handlePowerStatusChange(self):
475486
globalPluginHandler.initialize()
476487
if globalVars.appArgs.install or globalVars.appArgs.installSilent:
477488
import gui.installerGui
478-
wx.CallAfter(gui.installerGui.doSilentInstall,startAfterInstall=not globalVars.appArgs.installSilent)
489+
wx.CallAfter(
490+
gui.installerGui.doSilentInstall,
491+
copyPortableConfig=globalVars.appArgs.copyPortableConfig,
492+
startAfterInstall=not globalVars.appArgs.installSilent
493+
)
479494
elif globalVars.appArgs.portablePath and (globalVars.appArgs.createPortable or globalVars.appArgs.createPortableSilent):
480495
import gui.installerGui
481496
wx.CallAfter(gui.installerGui.doCreatePortable,portableDirectory=globalVars.appArgs.portablePath,

source/gui/installerGui.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@
2222
import tones
2323
import systemUtils
2424

25-
def doInstall(createDesktopShortcut,startOnLogon,copyPortableConfig,isUpdate,silent=False,startAfterInstall=True):
25+
26+
def doInstall(
27+
createDesktopShortcut=True,
28+
startOnLogon=True,
29+
isUpdate=False,
30+
copyPortableConfig=False,
31+
silent=False,
32+
startAfterInstall=True
33+
):
2634
progressDialog = gui.IndeterminateProgressDialog(gui.mainFrame,
2735
# Translators: The title of the dialog presented while NVDA is being updated.
2836
_("Updating NVDA") if isUpdate
@@ -55,7 +63,14 @@ def doInstall(createDesktopShortcut,startOnLogon,copyPortableConfig,isUpdate,sil
5563
# Translators: the title of a retry cancel dialog when NVDA installation fails
5664
title=_("File in Use")
5765
if winUser.MessageBox(None,message,title,winUser.MB_RETRYCANCEL)==winUser.IDRETRY:
58-
return doInstall(createDesktopShortcut,startOnLogon,copyPortableConfig,isUpdate,silent,startAfterInstall)
66+
return doInstall(
67+
createDesktopShortcut=createDesktopShortcut,
68+
startOnLogon=startOnLogon,
69+
copyPortableConfig=copyPortableConfig,
70+
isUpdate=isUpdate,
71+
silent=silent,
72+
startAfterInstall=startAfterInstall
73+
)
5974
if res!=0:
6075
log.error("Installation failed: %s"%res)
6176
# Translators: The message displayed when an error occurs during installation of NVDA.
@@ -88,16 +103,20 @@ def doInstall(createDesktopShortcut,startOnLogon,copyPortableConfig,isUpdate,sil
88103
else:
89104
wx.GetApp().ExitMainLoop()
90105

91-
def doSilentInstall(startAfterInstall=True):
106+
107+
def doSilentInstall(
108+
copyPortableConfig=False,
109+
startAfterInstall=True
110+
):
92111
prevInstall=installer.comparePreviousInstall() is not None
93112
startOnLogon=globalVars.appArgs.enableStartOnLogon
94113
if startOnLogon is None:
95114
startOnLogon=config.getStartOnLogonScreen() if prevInstall else True
96115
doInstall(
97-
installer.isDesktopShortcutInstalled() if prevInstall else True,
98-
startOnLogon,
99-
False,
100-
prevInstall,
116+
createDesktopShortcut=installer.isDesktopShortcutInstalled() if prevInstall else True,
117+
startOnLogon=startOnLogon,
118+
isUpdate=prevInstall,
119+
copyPortableConfig=copyPortableConfig,
101120
silent=True,
102121
startAfterInstall=startAfterInstall
103122
)
@@ -181,8 +200,10 @@ def __init__(self, parent, isUpdate):
181200
# Translators: The label of a checkbox option in the Install NVDA dialog.
182201
createPortableText = _("Copy &portable configuration to current user account")
183202
self.copyPortableConfigCheckbox = optionsSizer.addItem(wx.CheckBox(self, label=createPortableText))
184-
self.copyPortableConfigCheckbox.Value = False
185-
if globalVars.appArgs.launcher:
203+
self.copyPortableConfigCheckbox.Value = bool(globalVars.appArgs.copyPortableConfig)
204+
if globalVars.appArgs.copyPortableConfig is None:
205+
# copyPortableConfig is set to C{None} in the main loop,
206+
# when copying the portable configuration should be disabled at all costs.
186207
self.copyPortableConfigCheckbox.Disable()
187208

188209
bHelper = sHelper.addDialogDismissButtons(guiHelper.ButtonHelper(wx.HORIZONTAL))
@@ -213,7 +234,12 @@ def __init__(self, parent, isUpdate):
213234

214235
def onInstall(self, evt):
215236
self.Hide()
216-
doInstall(self.createDesktopShortcutCheckbox.Value,self.startOnLogonCheckbox.Value,self.copyPortableConfigCheckbox.Value,self.isUpdate)
237+
doInstall(
238+
createDesktopShortcut=self.createDesktopShortcutCheckbox.Value,
239+
startOnLogon=self.startOnLogonCheckbox.Value,
240+
copyPortableConfig=self.copyPortableConfigCheckbox.Value,
241+
silent=self.isUpdate
242+
)
217243
self.Destroy()
218244

219245
def onCancel(self, evt):
@@ -227,7 +253,9 @@ def onReviewAddons(self, evt):
227253
)
228254
incompatibleAddons.ShowModal()
229255

256+
230257
class InstallingOverNewerVersionDialog(wx.Dialog, DpiScalingHelperMixin):
258+
231259
def __init__(self):
232260
# Translators: The title of a warning dialog.
233261
wx.Dialog.__init__(self, gui.mainFrame, title=_("Warning"))

source/nvda.pyw

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def stringToBool(string):
8181
except ValidateError as e:
8282
raise argparse.ArgumentTypeError(e.message)
8383

84+
8485
#Process option arguments
8586
parser=NoConsoleOptionParser()
8687
quitGroup = parser.add_mutually_exclusive_group()
@@ -104,6 +105,15 @@ parser.add_argument('--portable-path',dest='portablePath',default=None,type=str,
104105
parser.add_argument('--launcher',action="store_true",dest='launcher',default=False,help="Started from the launcher")
105106
parser.add_argument('--enable-start-on-logon',metavar="True|False",type=stringToBool,dest='enableStartOnLogon',default=None,
106107
help="When installing, enable NVDA's start on the logon screen")
108+
parser.add_argument(
109+
'--copy-portable-config',
110+
action="store_true",
111+
dest='copyPortableConfig',
112+
default=False,
113+
help=(
114+
"When installing, copy the portable configuration "
115+
"from the provided path (--config-path, -c) to the current user account"
116+
))
107117
# This option is passed by Ease of Access so that if someone downgrades without uninstalling
108118
# (despite our discouragement), the downgraded copy won't be started in non-secure mode on secure desktops.
109119
# (Older versions always required the --secure option to start in secure mode.)

user_docs/en/userGuide.t2t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3115,6 +3115,7 @@ Following are the command line options for NVDA:
31153115
| None | --install | Installs NVDA (starting the newly installed copy) |
31163116
| None | --install-silent | Silently installs NVDA (does not start the newly installed copy) |
31173117
| None | --enable-start-on-logon=True|False | When installing, enable NVDA's [Use NVDA during Windows sign-in #StartAtWindowsLogon] |
3118+
| None | --copy-portable-config | When installing, copy the portable configuration from the provided path (--config-path, -c) to the current user account |
31183119
| None | --create-portable | Creates a portable copy of NVDA (starting the newly created copy). Requires --portable-path to be specified |
31193120
| None | --create-portable-silent | Creates a portable copy of NVDA (does not start the newly installed copy). Requires --portable-path to be specified |
31203121
| None | --portable-path=PORTABLEPATH | The path where a portable copy will be created |

0 commit comments

Comments
 (0)