Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gui: Add Copy command feature on right-click to GUI History panel #4927

Merged
merged 2 commits into from
Jan 10, 2025
Merged
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
26 changes: 26 additions & 0 deletions gui/wxpython/history/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ def _popupMenuCommand(self):
"""Create popup menu for commands"""
menu = Menu()

copyItem = wx.MenuItem(menu, wx.ID_ANY, _("&Copy"))
menu.AppendItem(copyItem)
self.Bind(wx.EVT_MENU, self.OnCopyCmd, copyItem)

item = wx.MenuItem(menu, wx.ID_ANY, _("&Remove"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnRemoveCmd, item)
Expand Down Expand Up @@ -658,3 +662,25 @@ def OnDoubleClick(self, node):
self.CollapseNode(node, recursive=False)
else:
self.ExpandNode(node, recursive=False)

def OnCopyCmd(self, event):
"""Copy selected cmd to clipboard"""
self.DefineItems(self.GetSelected())
if not self.selected_command:
return

selected_command = self.selected_command[0]
command = selected_command.data["name"]

# Copy selected command to clipboard
try:
if wx.TheClipboard.Open():
try:
wx.TheClipboard.SetData(wx.TextDataObject(command))
self.showNotification.emit(
message=_("Command <{}> copied to clipboard").format(command)
)
finally:
wx.TheClipboard.Close()
except wx.PyWidgetError:
self.showNotification.emit(message=_("Failed to copy command to clipboard"))
Loading