@@ -249,30 +249,113 @@ def registerInstallation(installDir,startMenuFolder,shouldCreateDesktopShortcut,
249249 config ._setStartOnLogonScreen (startOnLogonScreen )
250250 NVDAExe = os .path .join (installDir ,u"nvda.exe" )
251251 slaveExe = os .path .join (installDir ,u"nvda_slave.exe" )
252+ try :
253+ _updateShotcuts (NVDAExe , installDir , shouldCreateDesktopShortcut , slaveExe , startMenuFolder )
254+ except Exception :
255+ log .error ("Error while creating shortcuts" , exc_info = True )
256+ registerAddonFileAssociation (slaveExe )
257+
258+
259+ def _updateShotcuts (NVDAExe , installDir , shouldCreateDesktopShortcut , slaveExe , startMenuFolder ) -> None :
252260 if shouldCreateDesktopShortcut :
253- # #8320: -r|--replace is now the default. Nevertheless, keep creating
254- # the shortcut with the now superfluous argument in case a downgrade of
255- # NVDA is later performed.
256261 # Translators: The shortcut key used to start NVDA.
257262 # This should normally be left as is, but might be changed for some locales
258263 # if the default key causes problems for the normal locale keyboard layout.
259264 # The key must be formatted as described in this article:
260265 # http://msdn.microsoft.com/en-us/library/3zb1shc6%28v=vs.84%29.aspx
261- createShortcut (u"NVDA.lnk" ,targetPath = slaveExe ,arguments = "launchNVDA -r" ,hotkey = _ ("CTRL+ALT+N" ),workingDirectory = installDir ,prependSpecialFolder = "AllUsersDesktop" )
262- createShortcut (os .path .join (startMenuFolder ,"NVDA.lnk" ),targetPath = NVDAExe ,workingDirectory = installDir ,prependSpecialFolder = "AllUsersPrograms" )
266+ hotkeyTranslated = _ ("CTRL+ALT+N" )
267+ try :
268+ # #8320: -r|--replace is now the default. Nevertheless, keep creating
269+ # the shortcut with the now superfluous argument in case a downgrade of
270+ # NVDA is later performed.
271+ createShortcut (u"NVDA.lnk" , targetPath = slaveExe , arguments = "launchNVDA -r" , hotkey = hotkeyTranslated ,
272+ workingDirectory = installDir , prependSpecialFolder = "AllUsersDesktop" )
273+ except Exception :
274+ log .error (
275+ "Error creating Desktop/NVDA.lnk. Trying without translated hotkey."
276+ f" Translation: { hotkeyTranslated } "
277+ )
278+ createShortcut (u"NVDA.lnk" , targetPath = slaveExe , arguments = "launchNVDA -r" , hotkey = "CTRL+ALT+N" ,
279+ workingDirectory = installDir , prependSpecialFolder = "AllUsersDesktop" )
280+ try :
281+ createShortcut (os .path .join (startMenuFolder , "NVDA.lnk" ), targetPath = NVDAExe , workingDirectory = installDir ,
282+ prependSpecialFolder = "AllUsersPrograms" )
283+ except Exception :
284+ log .error ("Error creating startMenu/NVDA.lnk, no mitigation possible." )
285+
263286 # Translators: A label for a shortcut in start menu and a menu entry in NVDA menu (to go to NVDA website).
264- createShortcut (os .path .join (startMenuFolder ,_ ("NVDA web site" )+ ".lnk" ),targetPath = versionInfo .url ,prependSpecialFolder = "AllUsersPrograms" )
287+ webSiteTranslated = _ ("NVDA web site" )
288+ try :
289+ createShortcut (os .path .join (startMenuFolder , webSiteTranslated + ".lnk" ), targetPath = versionInfo .url ,
290+ prependSpecialFolder = "AllUsersPrograms" )
291+ except Exception :
292+ log .error (
293+ "Error creating startMenu/NVDA web site.lnk, trying without translation of filename."
294+ f" Translation: { webSiteTranslated } "
295+ )
296+ createShortcut (os .path .join (startMenuFolder , "NVDA web site.lnk" ), targetPath = versionInfo .url ,
297+ prependSpecialFolder = "AllUsersPrograms" )
298+
265299 # Translators: A label for a shortcut item in start menu to uninstall NVDA from the computer.
266- createShortcut (os .path .join (startMenuFolder ,_ ("Uninstall NVDA" )+ ".lnk" ),targetPath = os .path .join (installDir ,"uninstall.exe" ),workingDirectory = installDir ,prependSpecialFolder = "AllUsersPrograms" )
300+ uninstallTranslated = _ ("Uninstall NVDA" )
301+ try :
302+ createShortcut (os .path .join (startMenuFolder , uninstallTranslated + ".lnk" ),
303+ targetPath = os .path .join (installDir , "uninstall.exe" ), workingDirectory = installDir ,
304+ prependSpecialFolder = "AllUsersPrograms" )
305+ except Exception :
306+ log .error (
307+ "Error creating startMenu/Uninstall NVDA.lnk, trying without translation of filename."
308+ f" Translation: { uninstallTranslated } "
309+ )
310+ createShortcut (os .path .join (startMenuFolder , "Uninstall NVDA.lnk" ),
311+ targetPath = os .path .join (installDir , "uninstall.exe" ), workingDirectory = installDir ,
312+ prependSpecialFolder = "AllUsersPrograms" )
313+
267314 # Translators: A label for a shortcut item in start menu to open current user's NVDA configuration directory.
268- createShortcut (os .path .join (startMenuFolder ,_ ("Explore NVDA user configuration directory" )+ ".lnk" ),targetPath = slaveExe ,arguments = "explore_userConfigPath" ,workingDirectory = installDir ,prependSpecialFolder = "AllUsersPrograms" )
315+ exploreConfDirTranslated = _ ("Explore NVDA user configuration directory" )
316+ try :
317+ createShortcut (os .path .join (startMenuFolder , exploreConfDirTranslated + ".lnk" ),
318+ targetPath = slaveExe , arguments = "explore_userConfigPath" , workingDirectory = installDir ,
319+ prependSpecialFolder = "AllUsersPrograms" )
320+ except Exception :
321+ log .error (
322+ "Error creating startMenu/Explore NVDA user configuration directory.lnk,"
323+ " trying without translation of filename."
324+ f" Translation: { exploreConfDirTranslated } "
325+ )
326+ createShortcut (os .path .join (startMenuFolder , "Explore NVDA user configuration directory.lnk" ),
327+ targetPath = slaveExe , arguments = "explore_userConfigPath" , workingDirectory = installDir ,
328+ prependSpecialFolder = "AllUsersPrograms" )
329+
269330 # Translators: The label of the NVDA Documentation menu in the Start Menu.
270- docFolder = os .path .join (startMenuFolder ,_ ("Documentation" ))
331+ docFolder = os .path .join (startMenuFolder , _ ("Documentation" ))
332+
271333 # Translators: The label of the Start Menu item to open the Commands Quick Reference document.
272- createShortcut (os .path .join (docFolder ,_ ("Commands Quick Reference" )+ ".lnk" ),targetPath = getDocFilePath ("keyCommands.html" ,installDir ),prependSpecialFolder = "AllUsersPrograms" )
334+ commandsRefTranslated = _ ("Commands Quick Reference" )
335+ try :
336+ createShortcut (os .path .join (docFolder , commandsRefTranslated + ".lnk" ),
337+ targetPath = getDocFilePath ("keyCommands.html" , installDir ), prependSpecialFolder = "AllUsersPrograms" )
338+ except Exception :
339+ log .error (
340+ "Error creating startMenu/Commands Quick Reference.lnk, trying without translation of filename."
341+ f" Translation: { commandsRefTranslated } "
342+ )
343+ createShortcut (os .path .join (docFolder , "Commands Quick Reference.lnk" ),
344+ targetPath = getDocFilePath ("keyCommands.html" , installDir ), prependSpecialFolder = "AllUsersPrograms" )
345+
273346 # Translators: A label for a shortcut in start menu to open NVDA user guide.
274- createShortcut (os .path .join (docFolder ,_ ("User Guide" )+ ".lnk" ),targetPath = getDocFilePath ("userGuide.html" ,installDir ),prependSpecialFolder = "AllUsersPrograms" )
275- registerAddonFileAssociation (slaveExe )
347+ userGuideTranslated = _ ("User Guide" )
348+ try :
349+ createShortcut (os .path .join (docFolder , userGuideTranslated + ".lnk" ),
350+ targetPath = getDocFilePath ("userGuide.html" , installDir ), prependSpecialFolder = "AllUsersPrograms" )
351+ except Exception :
352+ log .error (
353+ "Error creating startMenu/User Guide.lnk, trying without translation of filename."
354+ f" Translation: { userGuideTranslated } "
355+ )
356+ createShortcut (os .path .join (docFolder , "User Guide.lnk" ),
357+ targetPath = getDocFilePath ("userGuide.html" , installDir ), prependSpecialFolder = "AllUsersPrograms" )
358+
276359
277360def isDesktopShortcutInstalled ():
278361 wsh = _getWSH ()
0 commit comments