529 itm = self.currentItem() |
529 itm = self.currentItem() |
530 groupName = ( |
530 groupName = ( |
531 itm.getName() if isinstance(itm, TemplateGroup) else itm.getGroupName() |
531 itm.getName() if isinstance(itm, TemplateGroup) else itm.getGroupName() |
532 ) |
532 ) |
533 |
533 |
534 dlg = TemplatePropertiesDialog(self) |
534 dlg = TemplatePropertiesDialog(parent=self) |
535 dlg.setSelectedGroup(groupName) |
535 dlg.setSelectedGroup(groupName) |
536 if dlg.exec() == QDialog.DialogCode.Accepted: |
536 if dlg.exec() == QDialog.DialogCode.Accepted: |
537 name, description, groupName, template = dlg.getData() |
537 name, description, groupName, template = dlg.getData() |
538 self.addEntry(groupName, name, description, template) |
538 self.addEntry(groupName, name, description, template) |
539 self.__dirty = True |
539 self.__dirty = True |
540 |
540 |
541 def __addGroup(self): |
541 def __addGroup(self): |
542 """ |
542 """ |
543 Private slot to handle the Add Group context menu action. |
543 Private slot to handle the Add Group context menu action. |
544 """ |
544 """ |
545 dlg = TemplatePropertiesDialog(self, True) |
545 dlg = TemplatePropertiesDialog(parent=self, groupMode=True) |
546 if dlg.exec() == QDialog.DialogCode.Accepted: |
546 if dlg.exec() == QDialog.DialogCode.Accepted: |
547 name, language = dlg.getData() |
547 name, language = dlg.getData() |
548 self.addGroup(name, language) |
548 self.addGroup(name, language) |
549 self.__dirty = True |
549 self.__dirty = True |
550 |
550 |
553 Private slot to handle the Edit context menu action. |
553 Private slot to handle the Edit context menu action. |
554 """ |
554 """ |
555 itm = self.currentItem() |
555 itm = self.currentItem() |
556 editGroup = not isinstance(itm, TemplateEntry) |
556 editGroup = not isinstance(itm, TemplateEntry) |
557 |
557 |
558 dlg = TemplatePropertiesDialog(self, editGroup, itm) |
558 dlg = TemplatePropertiesDialog(parent=self, groupMode=editGroup, itm=itm) |
559 if dlg.exec() == QDialog.DialogCode.Accepted: |
559 if dlg.exec() == QDialog.DialogCode.Accepted: |
560 if editGroup: |
560 if editGroup: |
561 name, language = dlg.getData() |
561 name, language = dlg.getData() |
562 self.changeGroup(itm.getName(), name, language) |
562 self.changeGroup(itm.getName(), name, language) |
563 else: |
563 else: |
771 if v in variables: |
771 if v in variables: |
772 variables.remove(v) |
772 variables.remove(v) |
773 |
773 |
774 if variables: |
774 if variables: |
775 if Preferences.getTemplates("SingleDialog"): |
775 if Preferences.getTemplates("SingleDialog"): |
776 dlg = TemplateMultipleVariablesDialog(variables, self) |
776 dlg = TemplateMultipleVariablesDialog(variables, parent=self) |
777 if dlg.exec() == QDialog.DialogCode.Accepted: |
777 if dlg.exec() == QDialog.DialogCode.Accepted: |
778 varValues.update(dlg.getVariables()) |
778 varValues.update(dlg.getVariables()) |
779 ok = True |
779 ok = True |
780 else: |
780 else: |
781 for var in variables: |
781 for var in variables: |
782 dlg = TemplateSingleVariableDialog(var, self) |
782 dlg = TemplateSingleVariableDialog(var, parent=self) |
783 if dlg.exec() == QDialog.DialogCode.Accepted: |
783 if dlg.exec() == QDialog.DialogCode.Accepted: |
784 varValues[var] = dlg.getVariable() |
784 varValues[var] = dlg.getVariable() |
785 else: |
785 else: |
786 return |
786 return |
787 del dlg |
787 del dlg |