def newWorkflow(self): if self.btnSave.isEnabled() and QMessageBox.question( None, self.tr("Metatools"), self. tr("Template contains unsaved data. Create new template without saving?" ), QMessageBox.Yes | QMessageBox.No) == QMessageBox.No: return self.clearFormFields() self.workflowTemplate = WorkflowTemplate() self.btnSave.setEnabled(False)
def workflowChanged(self): templateName = self.cmbWorkflow.currentText() if templateName == "": self.workflowTemplate = WorkflowTemplate() self.btnRemove.setEnabled(False) return self.workflowTemplate = self.workflowTemplateManager.loadTemplate( templateName) self.templateToForm(self.workflowTemplate) self.btnSave.setEnabled(False) self.btnRemove.setEnabled(True)
def __init__(self): QDialog.__init__(self) self.setupUi(self) self.workflowTemplateManager = WorkflowTemplateManager(currentPath) self.workflowTemplate = WorkflowTemplate() self.btnSave = self.buttonBox.button(QDialogButtonBox.Save) self.btnClose = self.buttonBox.button(QDialogButtonBox.Close) self.btnNew.clicked.connect(self.newWorkflow) self.btnRemove.clicked.connect(self.removeWorkflow) self.leName.textEdited.connect(self.templateModified) self.textDescription.textChanged.connect(self.templateModified) self.cmbWorkflow.currentIndexChanged.connect(self.workflowChanged) self.buttonBox.accepted.disconnect(self.accept) self.btnSave.clicked.connect(self.saveTemplate) self.manageGui()
def templateFromForm(self): template = WorkflowTemplate() template.name = self.leName.text() template.description = self.textDescription.toPlainText() return template