def interact_handler(self, wrapper): prompt, password, choices, default = wrapper.data prompt = hglib.tounicode(prompt) if choices: dlg = QMessageBox(QMessageBox.Question, _('TortoiseHg Prompt'), prompt, parent=self.parent()) dlg.setWindowFlags(Qt.Sheet) dlg.setWindowModality(Qt.WindowModal) for index, choice in enumerate(choices): button = dlg.addButton(hglib.tounicode(choice), QMessageBox.ActionRole) button.response = index if index == default: dlg.setDefaultButton(button) dlg.exec_() button = dlg.clickedButton() if button is 0: self.responseq.put(None) else: self.responseq.put(button.response) else: mode = password and QLineEdit.Password \ or QLineEdit.Normal text, ok = qtlib.getTextInput(self.parent(), _('TortoiseHg Prompt'), prompt.title(), mode=mode) if ok: text = hglib.fromunicode(text) else: text = None self.responseq.put(text)
def newShelf(self, interactive): shelve = time.strftime('%Y-%m-%d_%H-%M-%S') + \ '_parent_rev_%d' % self.repo['.'].rev() if interactive: name, ok = qtlib.getTextInput(self, _('TortoiseHg New Shelf Name'), _('Specify name of new shelf'), text=shelve) if not ok: return shelve = hglib.fromunicode(name) invalids = (':', '#', '/', '\\', '<', '>', '|') bads = [c for c in shelve if c in invalids] if bads: qtlib.ErrorMsgBox(_('Bad filename'), _('A shelf name cannot contain :#/\\<>|')) return try: fn = os.path.join('shelves', shelve) shelfpath = self.repo.join(fn) if os.path.exists(shelfpath): qtlib.ErrorMsgBox(_('File already exists'), _('A shelf file of that name already exists')) return self.repo.makeshelf(shelve) self.showMessage(_('New shelf created')) self.refreshCombos() if shelfpath in self.shelves: self.combob.setCurrentIndex(self.shelves.index(shelfpath)) except EnvironmentError, e: self.showMessage(hglib.tounicode(str(e)))
def newShelf(self, interactive): shelve = time.strftime('%Y-%m-%d_%H-%M-%S') + \ '_parent_rev_%d' % self.repo['.'].rev() if interactive: name, ok = qtlib.getTextInput(self, _('TortoiseHg New Shelf Name'), _('Specify name of new shelf'), text=shelve) if not ok: return shelve = hglib.fromunicode(name) invalids = (':', '#', '/', '\\', '<', '>', '|') bads = [c for c in shelve if c in invalids] if bads: qtlib.ErrorMsgBox(_('Bad filename'), _('A shelf name cannot contain :#/\\<>|')) return try: fn = os.path.join('shelves', shelve) shelfpath = self.repo.join(fn) if os.path.exists(shelfpath): qtlib.ErrorMsgBox( _('File already exists'), _('A shelf file of that name already exists')) return self.repo.makeshelf(shelve) self.showMessage(_('New shelf created')) self.refreshCombos() if shelfpath in self.shelves: self.combob.setCurrentIndex(self.shelves.index(shelfpath)) except EnvironmentError, e: self.showMessage(hglib.tounicode(str(e)))
def onGuardConfigure(self): item = self.queueListWidget.currentItem() patch = item._thgpatch if item._thgguards: uguards = hglib.tounicode(' '.join(item._thgguards)) else: uguards = '' new, ok = qtlib.getTextInput(self, _('Configure guards'), _('Input new guards for %s:') % hglib.tounicode(patch), text=uguards) if not ok or new == uguards: return guards = [] for guard in hglib.fromunicode(new).split(' '): guard = guard.strip() if not guard: continue if not (guard[0] == '+' or guard[0] == '-'): self.showMessage.emit(_('Guards must begin with "+" or "-"')) continue guards.append(guard) cmdline = ['qguard', '-R', self.repo.root, '--', patch] if guards: cmdline += guards else: cmdline.insert(3, '--none') if self.cmd.running(): return self.repo.incrementBusyCount() self.qtbar.setEnabled(False) self.cmd.run(cmdline)
def qqueueAdd(self): title = _('TortoiseHg Prompt') # this is the only way I found to make that dialog wide enough :( label = _('New patch queue name') + (u' ' * 30) qname, ok = qtlib.getTextInput(self, title, label) qname = hglib.fromunicode(qname) if qname and ok: opts = ['--create', qname] self.qqueueCommand(opts)
def passwordPrompt(self): pwd, ok = qtlib.getTextInput(self, _('Review Board'), _('Password:'), mode=QLineEdit.Password) if ok and pwd: self.password = pwd return True else: self.password = None return False
def _onGuardConfigure(self): model = self._queueListWidget.model() index = self._queueListWidget.currentIndex() patch = model.patchName(index) uguards = ' '.join(model.patchGuards(index)) new, ok = qtlib.getTextInput(self, _('Configure guards'), _('Input new guards for %s:') % patch, text=uguards) if not ok or new == uguards: return self._patchActions.guardPatch(patch, unicode(new).split())
def qqueueRename(self): uq = self.ql.item(self.ql.currentRow()).text() q = hglib.fromunicode(uq) if q == 'patches': return title = _('TortoiseHg Prompt') # this is the only way I found to make that dialog wide enough :( label = (_("Rename patch queue '%s' to") % uq) + (u' ' * 30) newqname, ok = qtlib.getTextInput(self, title, label) if newqname: newqname = hglib.fromunicode(newqname) if newqname and ok: opts = ['--rename', newqname] self.qqueueCommand(opts)
def _gotorev(self): rev, ok = qtlib.getTextInput(self, _("Goto revision"), _("Enter revision identifier")) if ok: self.gotorev(rev)