Skip to content

Commit 6f17a6b

Browse files
authored
Merge af13743 into 4b53f87
2 parents 4b53f87 + af13743 commit 6f17a6b

File tree

4 files changed

+61
-13
lines changed

4 files changed

+61
-13
lines changed

source/core.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,15 @@ def main():
219219
log.debug("loading config")
220220
import config
221221
config.initialize()
222+
if globalVars.appArgs.configPath == config.getUserDefaultConfigPath(useInstalledPathIfExists=True):
223+
# Make sure not to offer the ability to copy the current configuration to the user account.
224+
# This case always applies to the launcher when configPath is not overridden by the user, which is the default.
225+
# However, if a user wants to run the launcher with a custom configPath,
226+
# it is likely that he wants to copy that configuration when installing.
227+
# This check also applies to cases where a portable copy is run using the installed configuration,
228+
# in which case we want to avoid copying a configuration to itself.
229+
# We set the value to C{None} in order for the gui to determine when to disable the checkbox for this feature.
230+
globalVars.appArgs.copyPortableConfig = None
222231
if config.conf['development']['enableScratchpadDir']:
223232
log.info("Developer Scratchpad mode enabled")
224233
if not globalVars.appArgs.minimal and config.conf["general"]["playStartAndExitSounds"]:
@@ -467,7 +476,11 @@ def handlePowerStatusChange(self):
467476
globalPluginHandler.initialize()
468477
if globalVars.appArgs.install or globalVars.appArgs.installSilent:
469478
import gui.installerGui
470-
wx.CallAfter(gui.installerGui.doSilentInstall,startAfterInstall=not globalVars.appArgs.installSilent)
479+
wx.CallAfter(
480+
gui.installerGui.doSilentInstall,
481+
copyPortableConfig=globalVars.appArgs.copyPortableConfig,
482+
startAfterInstall=not globalVars.appArgs.installSilent
483+
)
471484
elif globalVars.appArgs.portablePath and (globalVars.appArgs.createPortable or globalVars.appArgs.createPortableSilent):
472485
import gui.installerGui
473486
wx.CallAfter(gui.installerGui.doCreatePortable,portableDirectory=globalVars.appArgs.portablePath,

source/gui/installerGui.py

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@
2121
from gui.dpiScalingHelper import DpiScalingHelperMixin
2222
import tones
2323

24-
def doInstall(createDesktopShortcut,startOnLogon,copyPortableConfig,isUpdate,silent=False,startAfterInstall=True):
24+
def doInstall(
25+
createDesktopShortcut=True,
26+
startOnLogon=True,
27+
isUpdate=False,
28+
copyPortableConfig=False,
29+
silent=False,
30+
startAfterInstall=True
31+
):
2532
progressDialog = gui.IndeterminateProgressDialog(gui.mainFrame,
2633
# Translators: The title of the dialog presented while NVDA is being updated.
2734
_("Updating NVDA") if isUpdate
@@ -49,7 +56,14 @@ def doInstall(createDesktopShortcut,startOnLogon,copyPortableConfig,isUpdate,sil
4956
# Translators: the title of a retry cancel dialog when NVDA installation fails
5057
title=_("File in Use")
5158
if winUser.MessageBox(None,message,title,winUser.MB_RETRYCANCEL)==winUser.IDRETRY:
52-
return doInstall(createDesktopShortcut,startOnLogon,copyPortableConfig,isUpdate,silent,startAfterInstall)
59+
return doInstall(
60+
createDesktopShortcut=createDesktopShortcut,
61+
startOnLogon=startOnLogon,
62+
copyPortableConfig=copyPortableConfig,
63+
isUpdate=isUpdate,
64+
silent=silent,
65+
startAfterInstall=startAfterInstall
66+
)
5367
if res!=0:
5468
log.error("Installation failed: %s"%res)
5569
# Translators: The message displayed when an error occurs during installation of NVDA.
@@ -78,16 +92,19 @@ def doInstall(createDesktopShortcut,startOnLogon,copyPortableConfig,isUpdate,sil
7892
else:
7993
wx.GetApp().ExitMainLoop()
8094

81-
def doSilentInstall(startAfterInstall=True):
95+
def doSilentInstall(
96+
copyPortableConfig=False,
97+
startAfterInstall=True
98+
):
8299
prevInstall=installer.comparePreviousInstall() is not None
83100
startOnLogon=globalVars.appArgs.enableStartOnLogon
84101
if startOnLogon is None:
85102
startOnLogon=config.getStartOnLogonScreen() if prevInstall else True
86103
doInstall(
87-
installer.isDesktopShortcutInstalled() if prevInstall else True,
88-
startOnLogon,
89-
False,
90-
prevInstall,
104+
createDesktopShortcut=installer.isDesktopShortcutInstalled() if prevInstall else True,
105+
startOnLogon=startOnLogon,
106+
isUpdate=prevInstall,
107+
copyPortableConfig=copyPortableConfig,
91108
silent=True,
92109
startAfterInstall=startAfterInstall
93110
)
@@ -170,8 +187,10 @@ def __init__(self, parent, isUpdate):
170187
# Translators: The label of a checkbox option in the Install NVDA dialog.
171188
createPortableText = _("Copy &portable configuration to current user account")
172189
self.copyPortableConfigCheckbox = optionsSizer.addItem(wx.CheckBox(self, label=createPortableText))
173-
self.copyPortableConfigCheckbox.Value = False
174-
if globalVars.appArgs.launcher:
190+
self.copyPortableConfigCheckbox.Value = bool(globalVars.appArgs.copyPortableConfig)
191+
if globalVars.appArgs.copyPortableConfig is None:
192+
# copyPortableConfig is set to C{None} in the main loop,
193+
# when copying the portable configuration should be disabled at all costs.
175194
self.copyPortableConfigCheckbox.Disable()
176195

177196
bHelper = sHelper.addDialogDismissButtons(guiHelper.ButtonHelper(wx.HORIZONTAL))
@@ -202,7 +221,12 @@ def __init__(self, parent, isUpdate):
202221

203222
def onInstall(self, evt):
204223
self.Hide()
205-
doInstall(self.createDesktopShortcutCheckbox.Value,self.startOnLogonCheckbox.Value,self.copyPortableConfigCheckbox.Value,self.isUpdate)
224+
doInstall(
225+
createDesktopShortcut=self.createDesktopShortcutCheckbox.Value,
226+
startOnLogon=self.startOnLogonCheckbox.Value,
227+
copyPortableConfig=self.copyPortableConfigCheckbox.Value,
228+
silent=self.isUpdate
229+
)
206230
self.Destroy()
207231

208232
def onCancel(self, evt):

source/nvda.pyw

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

83+
8384
#Process option arguments
8485
parser=NoConsoleOptionParser()
8586
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 currently doesn't actually do anything.
108118
# It is passed by Ease of Access so that if someone downgrades without uninstalling (despite our discouragement),
109119
# the downgraded copy won't be started in non-secure mode on secure desktops.

user_docs/en/userGuide.t2t

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2926,12 +2926,13 @@ Following are the command line options for NVDA:
29262926
| -m | --minimal | No sounds, no interface, no start message, etc. |
29272927
| -s | --secure | Secure mode (disables Python console and logging features, used often in secure screens) |
29282928
| None | --disable-addons | Addons will have no effect |
2929-
| None | --debug-logging | Enable debug level logging just for this run. This setting will override any other log level ( ""--loglevel"", -l) argument given, including no logging option. |
2930-
| None | --no-logging | Disable logging altogether while using NVDA. This setting can be overwritten if a log level ( ""--loglevel"", -l) is specified from command line or if debug logging is turned on. |
2929+
| None | --debug-logging | Enable debug level logging just for this run. This setting will override any other log level ( ""--loglevel"", -l) argument given, including no logging option |
2930+
| None | --no-logging | Disable logging altogether while using NVDA. This setting can be overwritten if a log level ( ""--loglevel"", -l) is specified from command line or if debug logging is turned on |
29312931
| None | --no-sr-flag | Don't change the global system screen reader flag |
29322932
| None | --install | Installs NVDA (starting the newly installed copy) |
29332933
| None | --install-silent | Silently installs NVDA (does not start the newly installed copy) |
29342934
| None | --enable-start-on-logon=True|False | When installing, enable NVDA's [start on the logon screen #StartAtWindowsLogon] |
2935+
| None | --copy-portable-config | When installing, copy the portable configuration from the provided path (--config-path, -c) to the current user account |
29352936
| None | --create-portable | Creates a portable copy of NVDA (starting the newly created copy). Requires --portable-path to be specified |
29362937
| None | --create-portable-silent | Creates a portable copy of NVDA (does not start the newly installed copy). Requires --portable-path to be specified |
29372938
| None | --portable-path=PORTABLEPATH | The path where a portable copy will be created |

0 commit comments

Comments
 (0)