Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions source/globalCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4945,7 +4945,6 @@ def script_copyRemoteLink(self, gesture: "inputCore.InputGesture"):
ui.message(_("Copied link"))

@script(
gesture="kb:alt+NVDA+pageDown",
category=SCRCAT_REMOTE,
# Translators: Documentation string for the script that disconnects a remote session.
description=_("Disconnect a remote session"),
Expand All @@ -4959,7 +4958,6 @@ def script_disconnectFromRemote(self, gesture: "inputCore.InputGesture"):
remoteClient._remoteClient.disconnect()

@script(
gesture="kb:alt+NVDA+pageUp",
# Translators: Documentation string for the script that invokes the remote session.
description=_("""Connect to a remote computer"""),
category=SCRCAT_REMOTE,
Expand All @@ -4973,6 +4971,18 @@ def script_connectToRemote(self, gesture: "inputCore.InputGesture"):
return
remoteClient._remoteClient.doConnect()

@script(
# Translators: Describes the command that creates a remote session, or disconnects it if one already exists.
"Toggle Remote connection",
category=SCRCAT_REMOTE,
gesture="kb:NVDA+alt+r",
)
def script_toggleRemoteConnection(self, gesture: "inputCore.InputGesture") -> None:
if remoteClient._remoteClient.isConnected():
self.script_disconnectFromRemote(gesture)
else:
self.script_connectToRemote(gesture)

@script(
# Translators: Documentation string for the script that toggles the control between guest and host machine.
description=_("Toggles the control between guest and host machine"),
Expand Down
71 changes: 41 additions & 30 deletions source/remoteClient/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,8 @@ def __init__(self, client: "RemoteClient") -> None:
self.client = client
sysTrayIcon = gui.mainFrame.sysTrayIcon
toolsMenu = sysTrayIcon.toolsMenu
self.connectItem: wx.MenuItem = self.Append(
wx.ID_ANY,
# Translators: Item in NVDA Remote submenu to connect to a remote computer.
_("Connect..."),
# Translators: Tooltip for the Connect menu item in the NVDA Remote submenu.
_("Remotely connect to another computer running NVDA Remote Access"),
)
sysTrayIcon.Bind(
wx.EVT_MENU,
self.client.doConnect,
self.connectItem,
)
# Translators: Item in NVDA Remote submenu to disconnect from a remote computer.
self.disconnectItem: wx.MenuItem = self.Append(
wx.ID_ANY,
# Translators: Menu item in NVDA Remote submenu to disconnect from another computer running NVDA Remote Access.
_("Disconnect"),
# Translators: Tooltip for the Disconnect menu item in the NVDA Remote submenu.
_("Disconnect from another computer running NVDA Remote Access"),
)
self.disconnectItem.Enable(False)
sysTrayIcon.Bind(
wx.EVT_MENU,
self.onDisconnectItem,
self.disconnectItem,
)
self.connectionItem: wx.MenuItem = self.Append(wx.ID_ANY, " ")
self._switchToConnectItem()
self.muteItem: wx.MenuItem = self.Append(
wx.ID_ANY,
# Translators: Menu item in NvDA Remote submenu to mute speech and sounds from the remote computer.
Expand Down Expand Up @@ -155,8 +131,10 @@ def onSendCtrlAltDel(self, evt: wx.CommandEvent) -> None:
self.client.sendSAS()

def handleConnected(self, mode: ConnectionMode, connected: bool) -> None:
self.connectItem.Enable(not connected)
self.disconnectItem.Enable(connected)
if connected:
self._switchToDisconnectItem()
else:
self._switchToConnectItem()
self.muteItem.Enable(connected)
if not connected:
self.muteItem.Check(False)
Expand All @@ -165,5 +143,38 @@ def handleConnected(self, mode: ConnectionMode, connected: bool) -> None:
self.sendCtrlAltDelItem.Enable(connected)

def handleConnecting(self, mode: ConnectionMode) -> None:
self.disconnectItem.Enable(True)
self.connectItem.Enable(False)
self._switchToDisconnectItem()

def _switchToConnectItem(self):
"""Switch to showing the "Connect..." item in the menu.

Sets the label, help text and event bindings of the connection item
to those appropriate for creating a new Remote session.
"""
# Translators: Item in NVDA Remote submenu to connect to a remote computer.
self.connectionItem.SetItemLabel(_("Connect..."))
# Translators: Tooltip for the Connect menu item in the NVDA Remote submenu.
self.connectionItem.SetHelp(_("Remotely connect to another computer running NVDA Remote Access"))
gui.mainFrame.sysTrayIcon.Unbind(wx.EVT_MENU, self.connectionItem)
gui.mainFrame.sysTrayIcon.Bind(
wx.EVT_MENU,
self.client.doConnect,
self.connectionItem,
)

def _switchToDisconnectItem(self):
"""Switch to showing the "Disconnect" item in the menu.

Sets the label, help text and event bindings of the connection item
to those appropriate for disconnecting an existing Remote session.
"""
# Translators: Menu item in NVDA Remote submenu to disconnect from another computer running NVDA Remote Access.
self.connectionItem.SetItemLabel(_("Disconnect"))
# Translators: Tooltip for the Disconnect menu item in the NVDA Remote submenu.
self.connectionItem.SetHelp(_("Disconnect from another computer running NVDA Remote Access"))
gui.mainFrame.sysTrayIcon.Unbind(wx.EVT_MENU, self.connectionItem)
gui.mainFrame.sysTrayIcon.Bind(
wx.EVT_MENU,
self.onDisconnectItem,
self.connectionItem,
)
2 changes: 1 addition & 1 deletion user_docs/en/userGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -3696,7 +3696,7 @@ Once the session is active, you can switch between controlling the remote comput
|--------------------------|----------------------|-------------------------------------------|
| Toggle Control | `NVDA+f11` | Switch between controlling and local. |
| Push Clipboard | `NVDA+ctrl+shift+c` | Send clipboard text to the other machine. |
| Disconnect | `NVDA+alt+pageDown`| End the remote session. |
| Connect or disconnect | `NVDA+alt+r`| If a remote session is in progress, disconnect from it. Otherwise, start a new Remote session. |
<!-- KC:endInclude -->

You can assign further commands in the Remote section of the [Input Gestures dialog](#InputGestures).
Expand Down