1 """QAction creator functions"""
2 from __future__
import absolute_import
, division
, unicode_literals
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
),
19 def launch_editor(context
, widget
, *shortcuts
):
20 """Create a QAction to launch an editor"""
22 return cmd_action(widget
, cmds
.LaunchEditor
, context
, icon
, hotkeys
.EDIT
,
26 def launch_editor_at_line(context
, widget
, *shortcuts
):
27 """Create a QAction to launch an editor"""
29 return cmd_action(widget
, cmds
.LaunchEditorAtLine
, context
, icon
,
30 hotkeys
.EDIT
, *shortcuts
)
33 def launch_difftool(context
, widget
):
34 """Create a QAction to launch git-difftool(1)"""
36 cmd
= cmds
.LaunchDifftool
37 action
= qtutils
.add_action(widget
, cmd
.name(), cmds
.run(cmd
, context
),
43 def stage_or_unstage(context
, widget
):
44 """Create a QAction to stage or unstage the selection"""
46 return cmd_action(widget
, cmds
.StageOrUnstage
, context
, icon
,
47 hotkeys
.STAGE_SELECTION
)
50 def move_down(widget
):
51 """Create a QAction to select the next item"""
52 return qtutils
.add_action(widget
, N_('Next File'), widget
.down
.emit
,
53 hotkeys
.MOVE_DOWN_SECONDARY
)
57 """Create a QAction to select the previous/above item"""
58 return qtutils
.add_action(widget
, N_('Previous File'), widget
.up
.emit
,
59 hotkeys
.MOVE_UP_SECONDARY
)