Example #1
0
    def tree_context_menu_setup(self):
        """Set up the status menu for the repo status tree."""
        staged, modified, unmerged, untracked = self.selection()
        menu = QtGui.QMenu(self)

        if staged:
            menu.addAction(self.tr('Unstage Selected'),
                           SLOT(signals.unstage, self.staged()))
            menu.addSeparator()
            menu.addAction(self.tr('Launch Editor'),
                           SLOT(signals.edit, self.staged()))
            menu.addAction(self.tr('Launch Diff Tool'),
                           SLOT(signals.difftool, True, self.staged()))
            menu.addSeparator()
            menu.addAction(self.tr('Remove Unstaged Edits'),
                    lambda: self._remove_unstaged_edits(use_staged=True))
            return menu

        if unmerged:
            if not utils.is_broken():
                menu.addAction(self.tr('Launch Merge Tool'),
                               SLOT(signals.mergetool, self.unmerged()))
            menu.addAction(self.tr('Launch Editor'),
                           SLOT(signals.edit, self.unmerged()))
            menu.addSeparator()
            menu.addAction(self.tr('Stage Selected'),
                           SLOT(signals.stage, self.unmerged()))
            return menu

        enable_staging = self.model.enable_staging()
        if enable_staging:
            menu.addAction(self.tr('Stage Selected'),
                           SLOT(signals.stage, self.unstaged()))
            menu.addSeparator()

        menu.addAction(self.tr('Launch Editor'),
                       SLOT(signals.edit, self.unstaged()))

        if modified and enable_staging:
            menu.addAction(self.tr('Launch Diff Tool'),
                           SLOT(signals.difftool, False, self.modified()))
            menu.addSeparator()
            menu.addAction(self.tr('Remove Unstaged Edits'),
                           self._remove_unstaged_edits)
            menu.addAction(self.tr('Remove Uncommited Edits'),
                           self._remove_uncommitted_edits)

        if untracked:
            menu.addSeparator()
            menu.addAction(self.tr('Delete File(s)'),
                           SLOT(signals.delete, self.untracked()))

        return menu
Example #2
0
    def tree_context_menu_setup(self):
        """Set up the status menu for the repo status tree."""
        staged, modified, unmerged, untracked = self.selection()
        menu = QtGui.QMenu(self)

        enable_staging = self.model.enable_staging()
        if not enable_staging:
            menu.addAction(self.tr("Unstage Selected"), SLOT(signals.unstage, self.staged()))

        if staged and staged[0] in cola.model().submodules:
            menu.addAction(self.tr("Launch git-cola"), SLOT(signals.open_repo, os.path.abspath(staged[0])))
            return menu
        elif staged:
            menu.addSeparator()
            menu.addAction(self.tr("Launch Editor"), SLOT(signals.edit, self.staged()))
            menu.addAction(self.tr("Launch Diff Tool"), SLOT(signals.difftool, True, self.staged()))
            menu.addSeparator()
            menu.addAction(self.tr("Remove Unstaged Edits"), lambda: self._remove_unstaged_edits(use_staged=True))
            return menu

        if unmerged:
            if not utils.is_broken():
                menu.addAction(self.tr("Launch Merge Tool"), SLOT(signals.mergetool, self.unmerged()))
            menu.addAction(self.tr("Launch Editor"), SLOT(signals.edit, self.unmerged()))
            menu.addSeparator()
            menu.addAction(self.tr("Stage Selected"), SLOT(signals.stage, self.unmerged()))
            return menu

        modified_submodule = modified and modified[0] in cola.model().submodules
        if enable_staging:
            menu.addAction(self.tr("Stage Selected"), SLOT(signals.stage, self.unstaged()))
            menu.addSeparator()

        if modified_submodule:
            menu.addAction(self.tr("Launch git-cola"), SLOT(signals.open_repo, os.path.abspath(modified[0])))
        elif self.unstaged():
            menu.addAction(self.tr("Launch Editor"), SLOT(signals.edit, self.unstaged()))

        if modified and enable_staging and not modified_submodule:
            menu.addAction(self.tr("Launch Diff Tool"), SLOT(signals.difftool, False, self.modified()))
            menu.addSeparator()
            menu.addAction(self.tr("Remove Unstaged Edits"), self._remove_unstaged_edits)
            menu.addAction(self.tr("Remove Uncommited Edits"), self._remove_uncommitted_edits)

        if untracked:
            menu.addSeparator()
            menu.addAction(self.tr("Delete File(s)"), SLOT(signals.delete, self.untracked()))
            menu.addSeparator()
            menu.addAction(self.tr("Add to .gitignore"), SLOT(signals.ignore, map(lambda x: "/" + x, self.untracked())))

        return menu