Esempio n. 1
0
    def _setupCustomSubmenu(self, menu):
        def make(text, func, types=None, icon=None, inmenu=None):
            action = inmenu.addAction(text)
            if icon:
                action.setIcon(qtlib.geticon(icon))
            return action

        menu.addSeparator()
        customtools.addCustomToolsSubmenu(menu, self.repo.ui,
            location='workbench.filelist.custom-menu',
            make=make,
            slot=self._runCustomCommandByMenu)
Esempio n. 2
0
    def _setupCustomSubmenu(self, menu):
        def make(text, func, types=None, icon=None, inmenu=None):
            action = inmenu.addAction(text)
            if icon:
                action.setIcon(qtlib.geticon(icon))
            return action

        menu.addSeparator()
        customtools.addCustomToolsSubmenu(
            menu,
            self.repo.ui,
            location='workbench.filelist.custom-menu',
            make=make,
            slot=self._runCustomCommandByMenu)
Esempio n. 3
0
    def makeMenu(self, selrows):
        self.selrows = selrows
        repo, menu = self.repo, self.menu

        alltypes = set()
        for types, wfile in selrows:
            alltypes |= types

        menu.clear()
        addedActions = False
        for action in self.allactions:
            if action is None:
                if addedActions:
                    menu.addSeparator()
                    addedActions = False
            elif action._filetypes & alltypes:
                menu.addAction(action)
                addedActions = True

        def make(text, func, types=None, icon=None, inmenu=None,
                 slot=self.runAction):
            if not types & alltypes:
                return
            if inmenu is None:
                inmenu = menu
            action = inmenu.addAction(text)
            action._filetypes = types
            action._runfunc = func
            if icon:
                action.setIcon(qtlib.geticon(icon))
            if func is not None:
                action.triggered.connect(slot)
            return action

        if len(repo.parents()) > 1:
            make(_('View O&ther'), viewother, frozenset('MA'))

        if len(selrows) == 1:
            menu.addSeparator()
            make(_('&Copy...'), copy, frozenset('MC'), 'edit-copy',
                 slot=self.runDialogAction)
            make(_('Re&name...'), rename, frozenset('MC'), 'hg-rename',
                 slot=self.runDialogAction)

        menu.addSeparator()
        customtools.addCustomToolsSubmenu(menu, repo.ui,
            location='workbench.commit.custom-menu',
            make=make,
            slot=self._runCustomCommandByMenu)

        # Add 'was renamed from' actions for unknown files
        t, path = selrows[0]
        wctx = self.repo[None]
        if t & frozenset('?') and wctx.deleted():
            rmenu = QMenu(_('Was renamed from'), self.parent())
            for d in wctx.deleted()[:15]:
                def mkaction(deleted):
                    a = rmenu.addAction(hglib.tounicode(deleted))
                    a.triggered.connect(lambda: renamefromto(repo, deleted, path))
                mkaction(d)
            menu.addSeparator()
            menu.addMenu(rmenu)

        # Add restart merge actions for resolved files
        if alltypes & frozenset('u'):
            f = make(_('Restart Mer&ge'), resolve, frozenset('u'))
            files = [f for t, f in selrows if 'u' in t]
            rmenu = QMenu(_('Restart Merge &with'), self.parent())
            for tool in hglib.mergetools(repo.ui):
                def mkaction(rtool):
                    a = rmenu.addAction(hglib.tounicode(rtool))
                    a.triggered.connect(lambda: resolve_with(rtool, repo, files))
                mkaction(tool)
            menu.addSeparator()
            menu.addMenu(rmenu)
        return menu