1 """QAction creator functions"""
11 def cmd_action(widget
, cmd
, context
, icon
, *shortcuts
):
12 """Wrap a generic ContextCommand in a QAction"""
13 action
= qtutils
.add_action(widget
, cmd
.name(), cmds
.run(cmd
, context
), *shortcuts
)
18 def launch_editor(context
, widget
, *shortcuts
):
19 """Create a QAction to launch an editor"""
22 widget
, cmds
.LaunchEditor
, context
, icon
, hotkeys
.EDIT
, *shortcuts
26 def launch_editor_at_line(context
, widget
, *shortcuts
):
27 """Create a QAction to launch an editor at the current line"""
30 widget
, cmds
.LaunchEditorAtLine
, context
, icon
, hotkeys
.EDIT
, *shortcuts
34 def launch_difftool(context
, widget
):
35 """Create a QAction to launch git-difftool(1)"""
37 cmd
= difftool
.LaunchDifftool
38 action
= qtutils
.add_action(
39 widget
, cmd
.name(), cmds
.run(cmd
, context
), hotkeys
.DIFF
45 def stage_or_unstage(context
, widget
):
46 """Create a QAction to stage or unstage the selection"""
49 widget
, cmds
.StageOrUnstage
, context
, icon
, hotkeys
.STAGE_SELECTION
53 def move_down(widget
):
54 """Create a QAction to select the next item"""
55 action
= qtutils
.add_action(
56 widget
, N_('Next File'), widget
.down
.emit
, hotkeys
.MOVE_DOWN_SECONDARY
58 action
.setIcon(icons
.move_down())
63 """Create a QAction to select the previous/above item"""
64 action
= qtutils
.add_action(
65 widget
, N_('Previous File'), widget
.up
.emit
, hotkeys
.MOVE_UP_SECONDARY
67 action
.setIcon(icons
.move_up())