def refresh(self): toolsdefs, guidef = hglib.tortoisehgtools( self.ini, selectedlocation=self.location) self.toollist = self._guidef2toollist(guidef) self.setValue(guidef) self.clear() self.addItems(self.toollist)
def setupCustomToolsMenu(self, location): tools, toollist = hglib.tortoisehgtools(self._ui, location) submenu = QMenu(_('Custom Tools'), self.parent()) submenu.triggered.connect(self._runCustomCommandByMenu) for name in toollist: if name == '|': submenu.addSeparator() continue info = tools.get(name, None) if info is None: continue command = info.get('command', None) if not command: continue label = info.get('label', name) icon = info.get('icon', customtools.DEFAULTICONNAME) status = info.get('status') a = submenu.addAction(label) a.setData(name) if icon: a.setIcon(qtlib.geticon(icon)) if status: fdfilters = (_filestatus(status),) else: fdfilters = () self._customactions[name] = (a, fdfilters) submenu.menuAction().setVisible(bool(self._customactions)) self._addAction('customToolsMenu', submenu.menuAction(), ()) self._updateActions()
def addCustomToolsSubmenu(menu, ui, location, make, slot, label=_('Custom Tools')): ''' Add a custom tools submenu to an existing menus This can be used, for example, to add the custom tools submenu to the different file context menus ''' tools, toollist = hglib.tortoisehgtools(ui, selectedlocation=location) if not tools: return submenu = menu.addMenu(label) submenu.triggered.connect(slot) emptysubmenu = True for name in toollist: if name == '|': submenu.addSeparator() continue info = tools.get(name, None) if info is None: continue command = info.get('command', None) if not command: continue label = info.get('label', name) icon = info.get('icon', CustomToolConfigDialog._defaulticonname) status = info.get('status', 'MAR!C?S') a = make(label, None, frozenset(status), icon=icon, inmenu=submenu) if a is not None: a.setData(name) emptysubmenu = False if emptysubmenu: menu.removeAction(submenu.menuAction())
def _setupCustomTools(self, ui): tools, toollist = hglib.tortoisehgtools(ui, selectedlocation='workbench.custom-toolbar') # Clear the existing "custom" toolbar self.customtbar.clear() # and repopulate it again with the tool configuration # for the current repository if not tools: return for name in toollist: if name == '|': self._addNewSeparator(toolbar='custom') continue info = tools.get(name, None) if info is None: continue command = info.get('command', None) if not command: continue showoutput = info.get('showoutput', False) workingdir = info.get('workingdir', '') label = info.get('label', name) tooltip = info.get('tooltip', _("Execute custom tool '%s'") % label) icon = info.get('icon', 'tools-spanner-hammer') self._addNewAction(label, self._repofwd('runCustomCommand', [command, showoutput, workingdir]), icon=icon, tooltip=tooltip, enabled=True, toolbar='custom')
def refresh(self): toolsdefs, guidef = hglib.tortoisehgtools(self.ini, selectedlocation=self.location) self.toollist = self._guidef2toollist(guidef) self.setValue(guidef) self.clear() self.addItems(self.toollist)
def refresh(self): toolsdefs, guidef = hglib.tortoisehgtools(self.ini, selectedlocation=self.location) self.toollist = self._guidef2toollist(guidef) self.setValue(guidef) self.clear() for toolname in self.toollist: icon = toolsdefs.get(toolname, {}).get('icon', None) self.addOrInsertItem(toolname, icon=icon)
def refresh(self): toolsdefs, guidef = hglib.tortoisehgtools( self.ini, selectedlocation=self.location) self.toollist = self._guidef2toollist(guidef) self.setValue(guidef) self.clear() for toolname in self.toollist: icon = toolsdefs.get(toolname, {}).get('icon', None) self.addOrInsertItem(toolname, icon=icon)
def __init__(self, ini, parent=None, **opts): QFrame.__init__(self, parent, **opts) self.widgets = [] self.ini = ini self.tortoisehgtools, guidef = hglib.tortoisehgtools(self.ini) self.setValue(self.tortoisehgtools) # The frame has a header and 3 columns: # - The header shows a combo with the list of locations # - The columns show: # - The current location tool list and its associated buttons # - The add to list button # - The "available tools" list and its associated buttons topvbox = QVBoxLayout() self.setLayout(topvbox) topvbox.addWidget(QLabel(_('Select a GUI location to edit:'))) self.locationcombo = QComboBox( self, toolTip='Select the toolbar or menu to change') def selectlocation(index): location = self.locationcombo.itemText(index) for widget in self.widgets: if widget.location == location: widget.removeInvalid(self.value()) widget.show() else: widget.hide() self.locationcombo.currentIndexChanged.connect(selectlocation) topvbox.addWidget(self.locationcombo) hbox = QHBoxLayout() topvbox.addLayout(hbox) vbox = QVBoxLayout() self.globaltoollist = ToolListBox(self.ini, minimumwidth=100, parent=self) self.globaltoollist.doubleClicked.connect(self.editToolItem) vbox.addWidget(QLabel(_('Tools shown on selected location'))) for location in hglib.tortoisehgtoollocations: self.locationcombo.addItem(location) toollist = ToolListBox(self.ini, location=location, minimumwidth=100, parent=self) toollist.doubleClicked.connect(self.editToolFromName) vbox.addWidget(toollist) toollist.hide() self.widgets.append(toollist) deletefromlistbutton = QPushButton(_('Delete from list'), self) deletefromlistbutton.clicked.connect( lambda: self.forwardToCurrentToolList('deleteTool', remove=False)) vbox.addWidget(deletefromlistbutton) hbox.addLayout(vbox) vbox = QVBoxLayout() vbox.addWidget(QLabel('')) # to align all lists addtolistbutton = QPushButton('<< ' + _('Add to list') + ' <<', self) addtolistbutton.clicked.connect(self.addToList) addseparatorbutton = QPushButton('<< ' + _('Add separator'), self) addseparatorbutton.clicked.connect( lambda: self.forwardToCurrentToolList('addSeparator')) vbox.addWidget(addtolistbutton) vbox.addWidget(addseparatorbutton) vbox.addStretch() hbox.addLayout(vbox) vbox = QVBoxLayout() vbox.addWidget(QLabel(_('List of all tools'))) vbox.addWidget(self.globaltoollist) newbutton = QPushButton(_('New Tool ...'), self) newbutton.clicked.connect(self.newTool) editbutton = QPushButton(_('Edit Tool ...'), self) editbutton.clicked.connect(lambda: self.editTool(row=None)) deletebutton = QPushButton(_('Delete Tool'), self) deletebutton.clicked.connect(self.deleteCurrentTool) vbox.addWidget(newbutton) vbox.addWidget(editbutton) vbox.addWidget(deletebutton) hbox.addLayout(vbox) # Ensure that the first location list is shown selectlocation(0)
def refresh(self): self.tortoisehgtools, guidef = hglib.tortoisehgtools(self.ini) self.setValue(self.tortoisehgtools) self.globaltoollist.refresh() for w in self.widgets: w.refresh()
def __init__(self, ini, parent=None, **opts): QFrame.__init__(self, parent, **opts) self.widgets = [] self.ini = ini self.tortoisehgtools, guidef = hglib.tortoisehgtools(self.ini) self.setValue(self.tortoisehgtools) # The frame has a header and 3 columns: # - The header shows a combo with the list of locations # - The columns show: # - The current location tool list and its associated buttons # - The add to list button # - The "available tools" list and its associated buttons topvbox = QVBoxLayout() self.setLayout(topvbox) topvbox.addWidget(QLabel(_('Select a GUI location to edit:'))) self.locationcombo = QComboBox(self, toolTip=_('Select the toolbar or menu to change')) def selectlocation(index): location = self.locationcombo.itemData(index).toString() for widget in self.widgets: if widget.location == location: widget.removeInvalid(self.value()) widget.show() else: widget.hide() self.locationcombo.currentIndexChanged.connect(selectlocation) topvbox.addWidget(self.locationcombo) hbox = QHBoxLayout() topvbox.addLayout(hbox) vbox = QVBoxLayout() self.globaltoollist = ToolListBox(self.ini, minimumwidth=100, parent=self) self.globaltoollist.doubleClicked.connect(self.editToolItem) vbox.addWidget(QLabel(_('Tools shown on selected location'))) for location, locationdesc in hglib.tortoisehgtoollocations: self.locationcombo.addItem(locationdesc.decode('utf-8'), location) toollist = ToolListBox(self.ini, location=location, minimumwidth=100, parent=self) toollist.doubleClicked.connect(self.editToolFromName) vbox.addWidget(toollist) toollist.hide() self.widgets.append(toollist) deletefromlistbutton = QPushButton(_('Delete from list'), self) deletefromlistbutton.clicked.connect( lambda: self.forwardToCurrentToolList('deleteTool', remove=False)) vbox.addWidget(deletefromlistbutton) hbox.addLayout(vbox) vbox = QVBoxLayout() vbox.addWidget(QLabel('')) # to align all lists addtolistbutton = QPushButton('<< ' + _('Add to list') + ' <<', self) addtolistbutton.clicked.connect(self.addToList) addseparatorbutton = QPushButton('<< ' + _('Add separator'), self) addseparatorbutton.clicked.connect( lambda: self.forwardToCurrentToolList('addSeparator')) vbox.addWidget(addtolistbutton) vbox.addWidget(addseparatorbutton) vbox.addStretch() hbox.addLayout(vbox) vbox = QVBoxLayout() vbox.addWidget(QLabel(_('List of all tools'))) vbox.addWidget(self.globaltoollist) newbutton = QPushButton(_('New Tool ...'), self) newbutton.clicked.connect(self.newTool) editbutton = QPushButton(_('Edit Tool ...'), self) editbutton.clicked.connect(lambda: self.editTool(row=None)) deletebutton = QPushButton(_('Delete Tool'), self) deletebutton.clicked.connect(self.deleteCurrentTool) vbox.addWidget(newbutton) vbox.addWidget(editbutton) vbox.addWidget(deletebutton) hbox.addLayout(vbox) # Ensure that the first location list is shown selectlocation(0)