112 |
112 |
113 if os.path.exists(self.srcFile) and \ |
113 if os.path.exists(self.srcFile) and \ |
114 self.__module is not None and \ |
114 self.__module is not None and \ |
115 self.classNameCombo.count() == 0: |
115 self.classNameCombo.count() == 0: |
116 self.__initError = True |
116 self.__initError = True |
117 E5MessageBox.critical(self, |
117 E5MessageBox.critical( |
|
118 self, |
118 self.trUtf8("Create Dialog Code"), |
119 self.trUtf8("Create Dialog Code"), |
119 self.trUtf8( |
120 self.trUtf8( |
120 """The file <b>{0}</b> exists but does not contain""" |
121 """The file <b>{0}</b> exists but does not contain""" |
121 """ any classes.""").format(self.srcFile)) |
122 """ any classes.""").format(self.srcFile)) |
122 |
123 |
140 """ |
141 """ |
141 try: |
142 try: |
142 dlg = uic.loadUi(self.formFile) |
143 dlg = uic.loadUi(self.formFile) |
143 return dlg.objectName() |
144 return dlg.objectName() |
144 except (AttributeError, ImportError) as err: |
145 except (AttributeError, ImportError) as err: |
145 E5MessageBox.critical(self, |
146 E5MessageBox.critical( |
|
147 self, |
146 self.trUtf8("uic error"), |
148 self.trUtf8("uic error"), |
147 self.trUtf8( |
149 self.trUtf8( |
148 """<p>There was an error loading the form <b>{0}</b>""" |
150 """<p>There was an error loading the form <b>{0}</b>""" |
149 """.</p><p>{1}</p>""").format(self.formFile, str(err))) |
151 """.</p><p>{1}</p>""").format(self.formFile, str(err))) |
150 return "" |
152 return "" |
157 """ |
159 """ |
158 try: |
160 try: |
159 dlg = uic.loadUi(self.formFile) |
161 dlg = uic.loadUi(self.formFile) |
160 return dlg.metaObject().className() |
162 return dlg.metaObject().className() |
161 except (AttributeError, ImportError) as err: |
163 except (AttributeError, ImportError) as err: |
162 E5MessageBox.critical(self, |
164 E5MessageBox.critical( |
|
165 self, |
163 self.trUtf8("uic error"), |
166 self.trUtf8("uic error"), |
164 self.trUtf8( |
167 self.trUtf8( |
165 """<p>There was an error loading the form <b>{0}</b>""" |
168 """<p>There was an error loading the form <b>{0}</b>""" |
166 """.</p><p>{1}</p>""").format(self.formFile, str(err))) |
169 """.</p><p>{1}</p>""").format(self.formFile, str(err))) |
167 return "" |
170 return "" |
258 bytes(metaMethod.methodSignature())\ |
261 bytes(metaMethod.methodSignature())\ |
259 .decode().split("(")[0]) |
262 .decode().split("(")[0]) |
260 else: |
263 else: |
261 method = "on_{0}_{1}".format( |
264 method = "on_{0}_{1}".format( |
262 name, metaMethod.signature().split("(")[0]) |
265 name, metaMethod.signature().split("(")[0]) |
263 method2 = "{0}({1})".format(method, |
266 method2 = "{0}({1})".format( |
264 ", ".join( |
267 method, ", ".join( |
265 [self.__mapType(t) |
268 [self.__mapType(t) |
266 for t in metaMethod.parameterTypes()])) |
269 for t in metaMethod.parameterTypes()])) |
267 |
270 |
268 if method2 in signatureList or \ |
271 if method2 in signatureList or \ |
269 method in signatureList: |
272 method in signatureList: |
320 ) |
323 ) |
321 itm2.setCheckState(Qt.Unchecked) |
324 itm2.setCheckState(Qt.Unchecked) |
322 |
325 |
323 self.slotsView.sortByColumn(0, Qt.AscendingOrder) |
326 self.slotsView.sortByColumn(0, Qt.AscendingOrder) |
324 except (AttributeError, ImportError) as err: |
327 except (AttributeError, ImportError) as err: |
325 E5MessageBox.critical(self, |
328 E5MessageBox.critical( |
|
329 self, |
326 self.trUtf8("uic error"), |
330 self.trUtf8("uic error"), |
327 self.trUtf8( |
331 self.trUtf8( |
328 """<p>There was an error loading the form <b>{0}</b>""" |
332 """<p>There was an error loading the form <b>{0}</b>""" |
329 """.</p><p>{1}</p>""").format(self.formFile, str(err))) |
333 """.</p><p>{1}</p>""").format(self.formFile, str(err))) |
330 |
334 |
388 "impl_pyqt.py.tmpl") |
392 "impl_pyqt.py.tmpl") |
389 tmplFile = open(tmplName, 'r', encoding="utf-8") |
393 tmplFile = open(tmplName, 'r', encoding="utf-8") |
390 template = tmplFile.read() |
394 template = tmplFile.read() |
391 tmplFile.close() |
395 tmplFile.close() |
392 except IOError as why: |
396 except IOError as why: |
393 E5MessageBox.critical(self, |
397 E5MessageBox.critical( |
|
398 self, |
394 self.trUtf8("Code Generation"), |
399 self.trUtf8("Code Generation"), |
395 self.trUtf8( |
400 self.trUtf8( |
396 """<p>Could not open the code template file""" |
401 """<p>Could not open the code template file""" |
397 """ "{0}".</p><p>Reason: {1}</p>""")\ |
402 """ "{0}".</p><p>Reason: {1}</p>""")\ |
398 .format(tmplName, str(why))) |
403 .format(tmplName, str(why))) |
423 sourceImpl = srcFile.readlines() |
428 sourceImpl = srcFile.readlines() |
424 srcFile.close() |
429 srcFile.close() |
425 if not sourceImpl[-1].endswith("\n"): |
430 if not sourceImpl[-1].endswith("\n"): |
426 sourceImpl[-1] = "{0}{1}".format(sourceImpl[-1], "\n") |
431 sourceImpl[-1] = "{0}{1}".format(sourceImpl[-1], "\n") |
427 except IOError as why: |
432 except IOError as why: |
428 E5MessageBox.critical(self, |
433 E5MessageBox.critical( |
|
434 self, |
429 self.trUtf8("Code Generation"), |
435 self.trUtf8("Code Generation"), |
430 self.trUtf8( |
436 self.trUtf8( |
431 """<p>Could not open the source file "{0}".</p>""" |
437 """<p>Could not open the source file "{0}".</p>""" |
432 """<p>Reason: {1}</p>""")\ |
438 """<p>Reason: {1}</p>""")\ |
433 .format(self.srcFile, str(why))) |
439 .format(self.srcFile, str(why))) |
501 srcFile = open(self.filenameEdit.text(), 'w', encoding="utf-8", |
507 srcFile = open(self.filenameEdit.text(), 'w', encoding="utf-8", |
502 newline=newline) |
508 newline=newline) |
503 srcFile.write("".join(sourceImpl)) |
509 srcFile.write("".join(sourceImpl)) |
504 srcFile.close() |
510 srcFile.close() |
505 except IOError as why: |
511 except IOError as why: |
506 E5MessageBox.critical(self, |
512 E5MessageBox.critical( |
|
513 self, |
507 self.trUtf8("Code Generation"), |
514 self.trUtf8("Code Generation"), |
508 self.trUtf8("""<p>Could not write the source file "{0}".</p>""" |
515 self.trUtf8("""<p>Could not write the source file "{0}".</p>""" |
509 """<p>Reason: {1}</p>""")\ |
516 """<p>Reason: {1}</p>""")\ |
510 .format(self.filenameEdit.text(), str(why))) |
517 .format(self.filenameEdit.text(), str(why))) |
511 return |
518 return |