def diff_context_menu_setup(self): """Set up the context menu for the diff display.""" menu = QtGui.QMenu(self) staged, modified, unmerged, untracked = cola.selection() if self.mode == self.model.mode_worktree: if modified: menu.addAction(self.tr('Stage &Hunk For Commit'), self.stage_hunk) menu.addAction(self.tr('Stage &Selected Lines'), self.stage_hunk_selection) menu.addSeparator() menu.addAction(self.tr('Undo Hunk'), self.undo_hunk) menu.addAction(self.tr('Undo Selection'), self.undo_selection) elif self.mode == self.model.mode_index: menu.addAction(self.tr('Unstage &Hunk From Commit'), self.unstage_hunk) menu.addAction(self.tr('Unstage &Selected Lines'), self.unstage_hunk_selection) elif self.mode == self.model.mode_branch: menu.addAction(self.tr('Apply Diff to Work Tree'), self.stage_hunk) menu.addAction(self.tr('Apply Diff Selection to Work Tree'), self.stage_hunk_selection) elif self.mode == self.model.mode_grep: menu.addAction(self.tr('Go Here'), self.goto_grep) menu.addSeparator() menu.addAction(self.tr('Copy'), self.copy_display) return menu
def contextMenuEvent(self, event): """Create the context menu for the diff display.""" menu = QtGui.QMenu(self) s = cola.selection() if self.model.stageable(): if s.modified and s.modified[0] in cola.model().submodules: action = menu.addAction(qtutils.icon('add.svg'), cmds.Stage.name(), cmds.run(cmds.Stage, s.modified)) action.setShortcut(cmds.Stage.SHORTCUT) menu.addAction(qtutils.git_icon(), N_('Launch git-cola'), cmds.run(cmds.OpenRepo, os.path.abspath(s.modified[0]))) elif s.modified: action = menu.addAction(qtutils.icon('add.svg'), N_('Stage Section'), self.stage_section) action.setShortcut(Qt.Key_H) menu.addAction(self.action_stage_selection) menu.addSeparator() menu.addAction(qtutils.icon('undo.svg'), N_('Revert Section...'), self.revert_section) menu.addAction(self.action_revert_selection) if self.model.unstageable(): if s.staged and s.staged[0] in cola.model().submodules: action = menu.addAction(qtutils.icon('remove.svg'), cmds.Unstage.name(), cmds.do(cmds.Unstage, s.staged)) action.setShortcut(cmds.Unstage.SHORTCUT) menu.addAction(qtutils.git_icon(), N_('Launch git-cola'), cmds.do(cmds.OpenRepo, os.path.abspath(s.staged[0]))) elif s.staged: action = menu.addAction(qtutils.icon('remove.svg'), N_('Unstage Section'), self.unstage_section) action.setShortcut(Qt.Key_H) menu.addAction(self.action_unstage_selection) if self.model.stageable() or self.model.unstageable(): menu.addSeparator() menu.addAction(self.launch_editor) menu.addAction(self.launch_difftool) menu.addSeparator() action = menu.addAction(qtutils.icon('edit-copy.svg'), N_('Copy'), self.copy) action.setShortcut(QtGui.QKeySequence.Copy) action = menu.addAction(qtutils.icon('edit-select-all.svg'), N_('Select All'), self.selectAll) action.setShortcut(QtGui.QKeySequence.SelectAll) menu.exec_(self.mapToGlobal(event.pos()))
def contextMenuEvent(self, event): """Create the context menu for the diff display.""" menu = QtGui.QMenu(self) staged, modified, unmerged, untracked = cola.selection() if self.mode == self.model.mode_worktree: if modified and modified[0] in cola.model().submodules: menu.addAction(qtutils.icon('add.svg'), self.tr('Stage'), SLOT(signals.stage, modified)) menu.addAction(qtutils.git_icon(), self.tr('Launch git-cola'), SLOT(signals.open_repo, os.path.abspath(modified[0]))) elif modified: menu.addAction(qtutils.icon('add.svg'), self.tr('Stage Section'), self.stage_section) menu.addAction(self.action_stage_selection) menu.addSeparator() menu.addAction(qtutils.icon('undo.svg'), self.tr('Revert Section...'), self.revert_section) menu.addAction(self.action_revert_selection) elif self.mode == self.model.mode_index: if staged and staged[0] in cola.model().submodules: menu.addAction(qtutils.icon('remove.svg'), self.tr('Unstage'), SLOT(signals.unstage, staged)) menu.addAction(qtutils.git_icon(), self.tr('Launch git-cola'), SLOT(signals.open_repo, os.path.abspath(staged[0]))) else: menu.addAction(qtutils.icon('remove.svg'), self.tr('Unstage Section'), self.unstage_section) menu.addAction(self.action_unstage_selection) elif self.mode == self.model.mode_branch: menu.addAction(qtutils.apply_icon(), self.tr('Apply Diff to Work Tree'), self.stage_section) menu.addAction(self.action_apply_selection) elif self.mode == self.model.mode_grep: menu.addAction(qtutils.icon('open.svg'), self.tr('Launch Editor'), lambda: guicmds.goto_grep(self.selected_line())) menu.addSeparator() menu.addAction(qtutils.icon('edit-copy.svg'), 'Copy', self.copy) menu.addAction(qtutils.icon('edit-select-all.svg'), 'Select All', self.selectAll) menu.exec_(self.mapToGlobal(event.pos()))
def contextMenuEvent(self, event): """Create the context menu for the diff display.""" menu = QtGui.QMenu(self) s = cola.selection() if self.model.stageable(): if s.modified and s.modified[0] in cola.model().submodules: action = menu.addAction(qtutils.icon('add.svg'), self.tr(cmds.Stage.NAME), cmds.run(cmds.Stage, s.modified)) action.setShortcut(cmds.Stage.SHORTCUT) menu.addAction( qtutils.git_icon(), self.tr('Launch git-cola'), cmds.run(cmds.OpenRepo, os.path.abspath(s.modified[0]))) elif s.modified: action = menu.addAction(qtutils.icon('add.svg'), self.tr('Stage Section'), self.stage_section) action.setShortcut(Qt.Key_H) menu.addAction(self.action_stage_selection) menu.addSeparator() menu.addAction(qtutils.icon('undo.svg'), self.tr('Revert Section...'), self.revert_section) menu.addAction(self.action_revert_selection) if self.model.unstageable(): if s.staged and s.staged[0] in cola.model().submodules: action = menu.addAction(qtutils.icon('remove.svg'), self.tr(cmds.Unstage.NAME), cmds.do(cmds.Unstage, s.staged)) action.setShortcut(cmds.Unstage.SHORTCUT) menu.addAction( qtutils.git_icon(), self.tr('Launch git-cola'), cmds.do(cmds.OpenRepo, os.path.abspath(s.staged[0]))) elif s.staged: action = menu.addAction(qtutils.icon('remove.svg'), self.tr('Unstage Section'), self.unstage_section) action.setShortcut(Qt.Key_H) menu.addAction(self.action_unstage_selection) if self.model.stageable() or self.model.unstageable(): menu.addSeparator() menu.addAction(self.launch_editor) menu.addAction(self.launch_difftool) menu.addSeparator() action = menu.addAction(qtutils.icon('edit-copy.svg'), 'Copy', self.copy) action.setShortcut(QtGui.QKeySequence.Copy) action = menu.addAction(qtutils.icon('edit-select-all.svg'), 'Select All', self.selectAll) action.setShortcut(QtGui.QKeySequence.SelectAll) menu.exec_(self.mapToGlobal(event.pos()))
def do(self): s = cola.selection() if s.unmerged: paths = s.unmerged if utils.is_win32(): utils.fork(['git', 'mergetool', '--no-prompt', '--'] + paths) else: utils.fork(['xterm', '-e', 'git', 'mergetool', '--no-prompt', '--'] + paths) else: difftool.run()
def contextMenuEvent(self, event): """Create the context menu for the diff display.""" menu = QtGui.QMenu(self) s = cola.selection() if self.model.stageable(): if s.modified and s.modified[0] in cola.model().submodules: action = menu.addAction(qtutils.icon('add.svg'), self.tr('Stage'), SLOT(signals.stage, s.modified)) action.setShortcut(defs.stage_shortcut) menu.addAction(qtutils.git_icon(), self.tr('Launch git-cola'), SLOT(signals.open_repo, os.path.abspath(s.modified[0]))) elif s.modified: action = menu.addAction(qtutils.icon('add.svg'), self.tr('Stage Section'), self.stage_section) action.setShortcut(Qt.Key_H) menu.addAction(self.action_stage_selection) menu.addSeparator() menu.addAction(qtutils.icon('undo.svg'), self.tr('Revert Section...'), self.revert_section) menu.addAction(self.action_revert_selection) if self.model.unstageable(): if s.staged and s.staged[0] in cola.model().submodules: action = menu.addAction(qtutils.icon('remove.svg'), self.tr('Unstage'), SLOT(signals.unstage, s.staged)) action.setShortcut(defs.stage_shortcut) menu.addAction(qtutils.git_icon(), self.tr('Launch git-cola'), SLOT(signals.open_repo, os.path.abspath(s.staged[0]))) elif s.staged: action = menu.addAction(qtutils.icon('remove.svg'), self.tr('Unstage Section'), self.unstage_section) action.setShortcut(Qt.Key_H) menu.addAction(self.action_unstage_selection) menu.addSeparator() action = menu.addAction(qtutils.icon('edit-copy.svg'), 'Copy', self.copy) action.setShortcut(QtGui.QKeySequence.Copy) action = menu.addAction(qtutils.icon('edit-select-all.svg'), 'Select All', self.selectAll) action.setShortcut(QtGui.QKeySequence.SelectAll) menu.exec_(self.mapToGlobal(event.pos()))
def run(): s = cola.selection() if s.staged: selection = s.staged elif s.unmerged: selection = s.unmerged elif s.modified: selection = s.modified elif s.untracked: selection = s.untracked else: return model = cola.model() launch_with_head(selection, bool(s.staged), model.head)
def diff_context_menu_setup(self): """Set up the context menu for the diff display.""" menu = QtGui.QMenu(self) staged, modified, unmerged, untracked = cola.selection() if self.mode == self.model.mode_worktree: if modified and modified[0] in cola.model().submodules: menu.addAction(self.tr('Stage'), SLOT(signals.stage, modified)) menu.addAction(self.tr('Launch git-cola'), SLOT(signals.open_repo, os.path.abspath(modified[0]))) elif modified: menu.addAction(self.tr('Stage &Hunk For Commit'), self.stage_hunk) menu.addAction(self.tr('Stage &Selected Lines'), self.stage_hunk_selection) menu.addSeparator() menu.addAction(self.tr('Undo Hunk'), self.undo_hunk) menu.addAction(self.tr('Undo Selected Lines'), self.undo_selection) elif self.mode == self.model.mode_index: if staged and staged[0] in cola.model().submodules: menu.addAction(self.tr('Unstage'), SLOT(signals.unstage, staged)) menu.addAction(self.tr('Launch git-cola'), SLOT(signals.open_repo, os.path.abspath(staged[0]))) else: menu.addAction(self.tr('Unstage &Hunk From Commit'), self.unstage_hunk) menu.addAction(self.tr('Unstage &Selected Lines'), self.unstage_hunk_selection) elif self.mode == self.model.mode_branch: menu.addAction(self.tr('Apply Diff to Work Tree'), self.stage_hunk) menu.addAction(self.tr('Apply Diff Selection to Work Tree'), self.stage_hunk_selection) elif self.mode == self.model.mode_grep: menu.addAction(self.tr('Go Here'), lambda: guicmds.goto_grep(self.selected_line())) menu.addSeparator() menu.addAction(self.tr('Copy'), self.copy_display) return menu
def __init__(self): s = cola.selection() allfiles = s.staged + s.unmerged + s.modified + s.untracked Edit.__init__(self, allfiles)