761 with open(ofn, "w", encoding="utf-8", newline=newline) as f: |
761 with open(ofn, "w", encoding="utf-8", newline=newline) as f: |
762 for line in self.buf.splitlines(): |
762 for line in self.buf.splitlines(): |
763 f.write(line + "\n") |
763 f.write(line + "\n") |
764 if self.compiledFile not in self.project.pdata["SOURCES"]: |
764 if self.compiledFile not in self.project.pdata["SOURCES"]: |
765 self.project.appendFile(ofn) |
765 self.project.appendFile(ofn) |
766 if not self.noDialog and not ui.notificationsEnabled(): |
|
767 E5MessageBox.information( |
|
768 self, |
|
769 self.tr("Form Compilation"), |
|
770 self.tr("The compilation of the form file" |
|
771 " was successful.")) |
|
772 else: |
|
773 ui.showNotification( |
|
774 UI.PixmapCache.getPixmap("designer48"), |
|
775 self.tr("Form Compilation"), |
|
776 self.tr("The compilation of the form file" |
|
777 " was successful.")) |
|
778 self.project.projectFormCompiled.emit(self.compiledFile) |
|
779 except OSError as msg: |
|
780 if not self.noDialog: |
|
781 E5MessageBox.information( |
|
782 self, |
|
783 self.tr("Form Compilation"), |
|
784 self.tr( |
|
785 "<p>The compilation of the form file failed.</p>" |
|
786 "<p>Reason: {0}</p>").format(str(msg))) |
|
787 else: |
|
788 ui.showNotification( |
|
789 UI.PixmapCache.getPixmap("designer48"), |
|
790 self.tr("Form Compilation"), |
|
791 self.tr( |
|
792 "<p>The compilation of the form file failed.</p>" |
|
793 "<p>Reason: {0}</p>").format(str(msg))) |
|
794 else: |
|
795 if not self.noDialog: |
|
796 E5MessageBox.information( |
|
797 self, |
|
798 self.tr("Form Compilation"), |
|
799 self.tr("The compilation of the form file failed.")) |
|
800 else: |
|
801 ui.showNotification( |
766 ui.showNotification( |
802 UI.PixmapCache.getPixmap("designer48"), |
767 UI.PixmapCache.getPixmap("designer48"), |
803 self.tr("Form Compilation"), |
768 self.tr("Form Compilation"), |
804 self.tr("The compilation of the form file failed.")) |
769 self.tr("The compilation of the form file" |
|
770 " was successful.")) |
|
771 self.project.projectFormCompiled.emit(self.compiledFile) |
|
772 except OSError as msg: |
|
773 ui.showNotification( |
|
774 UI.PixmapCache.getPixmap("designer48"), |
|
775 self.tr("Form Compilation"), |
|
776 self.tr( |
|
777 "<p>The compilation of the form file failed.</p>" |
|
778 "<p>Reason: {0}</p>").format(str(msg)), |
|
779 timeout=0) |
|
780 else: |
|
781 ui.showNotification( |
|
782 UI.PixmapCache.getPixmap("designer48"), |
|
783 self.tr("Form Compilation"), |
|
784 self.tr("The compilation of the form file failed."), |
|
785 timeout=0) |
805 self.compileProc = None |
786 self.compileProc = None |
806 |
787 |
807 def __compileUI(self, fn, noDialog=False, progress=None): |
788 def __compileUI(self, fn, noDialog=False, progress=None): |
808 """ |
789 """ |
809 Private method to compile a .ui file to a .py/.rb file. |
790 Private method to compile a .ui file to a .py/.rb file. |