113 self.__module is not None and \ |
113 self.__module is not None and \ |
114 self.classNameCombo.count() == 0: |
114 self.classNameCombo.count() == 0: |
115 self.__initError = True |
115 self.__initError = True |
116 E5MessageBox.critical( |
116 E5MessageBox.critical( |
117 self, |
117 self, |
118 self.trUtf8("Create Dialog Code"), |
118 self.tr("Create Dialog Code"), |
119 self.trUtf8( |
119 self.tr( |
120 """The file <b>{0}</b> exists but does not contain""" |
120 """The file <b>{0}</b> exists but does not contain""" |
121 """ any classes.""").format(self.srcFile)) |
121 """ any classes.""").format(self.srcFile)) |
122 |
122 |
123 self.okButton.setEnabled(self.classNameCombo.count() > 0) |
123 self.okButton.setEnabled(self.classNameCombo.count() > 0) |
124 |
124 |
142 dlg = uic.loadUi(self.formFile) |
142 dlg = uic.loadUi(self.formFile) |
143 return dlg.objectName() |
143 return dlg.objectName() |
144 except (AttributeError, ImportError) as err: |
144 except (AttributeError, ImportError) as err: |
145 E5MessageBox.critical( |
145 E5MessageBox.critical( |
146 self, |
146 self, |
147 self.trUtf8("uic error"), |
147 self.tr("uic error"), |
148 self.trUtf8( |
148 self.tr( |
149 """<p>There was an error loading the form <b>{0}</b>""" |
149 """<p>There was an error loading the form <b>{0}</b>""" |
150 """.</p><p>{1}</p>""").format(self.formFile, str(err))) |
150 """.</p><p>{1}</p>""").format(self.formFile, str(err))) |
151 return "" |
151 return "" |
152 |
152 |
153 def __className(self): |
153 def __className(self): |
160 dlg = uic.loadUi(self.formFile) |
160 dlg = uic.loadUi(self.formFile) |
161 return dlg.metaObject().className() |
161 return dlg.metaObject().className() |
162 except (AttributeError, ImportError) as err: |
162 except (AttributeError, ImportError) as err: |
163 E5MessageBox.critical( |
163 E5MessageBox.critical( |
164 self, |
164 self, |
165 self.trUtf8("uic error"), |
165 self.tr("uic error"), |
166 self.trUtf8( |
166 self.tr( |
167 """<p>There was an error loading the form <b>{0}</b>""" |
167 """<p>There was an error loading the form <b>{0}</b>""" |
168 """.</p><p>{1}</p>""").format(self.formFile, str(err))) |
168 """.</p><p>{1}</p>""").format(self.formFile, str(err))) |
169 return "" |
169 return "" |
170 |
170 |
171 def __signatures(self): |
171 def __signatures(self): |
324 |
324 |
325 self.slotsView.sortByColumn(0, Qt.AscendingOrder) |
325 self.slotsView.sortByColumn(0, Qt.AscendingOrder) |
326 except (AttributeError, ImportError) as err: |
326 except (AttributeError, ImportError) as err: |
327 E5MessageBox.critical( |
327 E5MessageBox.critical( |
328 self, |
328 self, |
329 self.trUtf8("uic error"), |
329 self.tr("uic error"), |
330 self.trUtf8( |
330 self.tr( |
331 """<p>There was an error loading the form <b>{0}</b>""" |
331 """<p>There was an error loading the form <b>{0}</b>""" |
332 """.</p><p>{1}</p>""").format(self.formFile, str(err))) |
332 """.</p><p>{1}</p>""").format(self.formFile, str(err))) |
333 |
333 |
334 def __generateCode(self): |
334 def __generateCode(self): |
335 """ |
335 """ |
393 template = tmplFile.read() |
393 template = tmplFile.read() |
394 tmplFile.close() |
394 tmplFile.close() |
395 except IOError as why: |
395 except IOError as why: |
396 E5MessageBox.critical( |
396 E5MessageBox.critical( |
397 self, |
397 self, |
398 self.trUtf8("Code Generation"), |
398 self.tr("Code Generation"), |
399 self.trUtf8( |
399 self.tr( |
400 """<p>Could not open the code template file""" |
400 """<p>Could not open the code template file""" |
401 """ "{0}".</p><p>Reason: {1}</p>""") |
401 """ "{0}".</p><p>Reason: {1}</p>""") |
402 .format(tmplName, str(why))) |
402 .format(tmplName, str(why))) |
403 return |
403 return |
404 |
404 |
429 if not sourceImpl[-1].endswith("\n"): |
429 if not sourceImpl[-1].endswith("\n"): |
430 sourceImpl[-1] = "{0}{1}".format(sourceImpl[-1], "\n") |
430 sourceImpl[-1] = "{0}{1}".format(sourceImpl[-1], "\n") |
431 except IOError as why: |
431 except IOError as why: |
432 E5MessageBox.critical( |
432 E5MessageBox.critical( |
433 self, |
433 self, |
434 self.trUtf8("Code Generation"), |
434 self.tr("Code Generation"), |
435 self.trUtf8( |
435 self.tr( |
436 """<p>Could not open the source file "{0}".</p>""" |
436 """<p>Could not open the source file "{0}".</p>""" |
437 """<p>Reason: {1}</p>""") |
437 """<p>Reason: {1}</p>""") |
438 .format(self.srcFile, str(why))) |
438 .format(self.srcFile, str(why))) |
439 return |
439 return |
440 |
440 |
508 srcFile.write("".join(sourceImpl)) |
508 srcFile.write("".join(sourceImpl)) |
509 srcFile.close() |
509 srcFile.close() |
510 except IOError as why: |
510 except IOError as why: |
511 E5MessageBox.critical( |
511 E5MessageBox.critical( |
512 self, |
512 self, |
513 self.trUtf8("Code Generation"), |
513 self.tr("Code Generation"), |
514 self.trUtf8("""<p>Could not write the source file "{0}".</p>""" |
514 self.tr("""<p>Could not write the source file "{0}".</p>""" |
515 """<p>Reason: {1}</p>""") |
515 """<p>Reason: {1}</p>""") |
516 .format(self.filenameEdit.text(), str(why))) |
516 .format(self.filenameEdit.text(), str(why))) |
517 return |
517 return |
518 |
518 |
519 self.project.appendFile(self.filenameEdit.text()) |
519 self.project.appendFile(self.filenameEdit.text()) |
520 |
520 |