563 ex = selectedFilter.split("(*")[1].split(")")[0] |
563 ex = selectedFilter.split("(*")[1].split(")")[0] |
564 if ex: |
564 if ex: |
565 fname += ex |
565 fname += ex |
566 |
566 |
567 if os.path.exists(fname): |
567 if os.path.exists(fname): |
568 res = E5MessageBox.yesNo(self, |
568 res = E5MessageBox.yesNo( |
|
569 self, |
569 self.trUtf8("New Form"), |
570 self.trUtf8("New Form"), |
570 self.trUtf8("The file already exists! Overwrite it?"), |
571 self.trUtf8("The file already exists! Overwrite it?"), |
571 icon=E5MessageBox.Warning) |
572 icon=E5MessageBox.Warning) |
572 if not res: |
573 if not res: |
573 # user selected to not overwrite |
574 # user selected to not overwrite |
574 return |
575 return |
575 |
576 |
576 try: |
577 try: |
577 shutil.copy(templateFile, fname) |
578 shutil.copy(templateFile, fname) |
578 except IOError as e: |
579 except IOError as e: |
579 E5MessageBox.critical(self, |
580 E5MessageBox.critical( |
|
581 self, |
580 self.trUtf8("New Form"), |
582 self.trUtf8("New Form"), |
581 self.trUtf8( |
583 self.trUtf8( |
582 "<p>The new form file <b>{0}</b> could not be created.<br>" |
584 "<p>The new form file <b>{0}</b> could not be created.<br>" |
583 "Problem: {1}</p>").format(fname, str(e))) |
585 "Problem: {1}</p>").format(fname, str(e))) |
584 return |
586 return |
670 f.write(line + "\n") |
672 f.write(line + "\n") |
671 f.close() |
673 f.close() |
672 if self.compiledFile not in self.project.pdata["SOURCES"]: |
674 if self.compiledFile not in self.project.pdata["SOURCES"]: |
673 self.project.appendFile(ofn) |
675 self.project.appendFile(ofn) |
674 if not self.noDialog and not ui.notificationsEnabled(): |
676 if not self.noDialog and not ui.notificationsEnabled(): |
675 E5MessageBox.information(self, |
677 E5MessageBox.information( |
|
678 self, |
676 self.trUtf8("Form Compilation"), |
679 self.trUtf8("Form Compilation"), |
677 self.trUtf8("The compilation of the form file" |
680 self.trUtf8("The compilation of the form file" |
678 " was successful.")) |
681 " was successful.")) |
679 else: |
682 else: |
680 ui.showNotification( |
683 ui.showNotification( |
683 self.trUtf8("The compilation of the form file" |
686 self.trUtf8("The compilation of the form file" |
684 " was successful.")) |
687 " was successful.")) |
685 self.project.projectFormCompiled.emit(self.compiledFile) |
688 self.project.projectFormCompiled.emit(self.compiledFile) |
686 except IOError as msg: |
689 except IOError as msg: |
687 if not self.noDialog: |
690 if not self.noDialog: |
688 E5MessageBox.information(self, |
691 E5MessageBox.information( |
|
692 self, |
689 self.trUtf8("Form Compilation"), |
693 self.trUtf8("Form Compilation"), |
690 self.trUtf8( |
694 self.trUtf8( |
691 "<p>The compilation of the form file failed.</p>" |
695 "<p>The compilation of the form file failed.</p>" |
692 "<p>Reason: {0}</p>").format(str(msg))) |
696 "<p>Reason: {0}</p>").format(str(msg))) |
693 else: |
697 else: |
697 self.trUtf8( |
701 self.trUtf8( |
698 "<p>The compilation of the form file failed.</p>" |
702 "<p>The compilation of the form file failed.</p>" |
699 "<p>Reason: {0}</p>").format(str(msg))) |
703 "<p>Reason: {0}</p>").format(str(msg))) |
700 else: |
704 else: |
701 if not self.noDialog: |
705 if not self.noDialog: |
702 E5MessageBox.information(self, |
706 E5MessageBox.information( |
|
707 self, |
703 self.trUtf8("Form Compilation"), |
708 self.trUtf8("Form Compilation"), |
704 self.trUtf8("The compilation of the form file failed.")) |
709 self.trUtf8("The compilation of the form file failed.")) |
705 else: |
710 else: |
706 ui.showNotification(UI.PixmapCache.getPixmap("designer48.png"), |
711 ui.showNotification(UI.PixmapCache.getPixmap("designer48.png"), |
707 self.trUtf8("Form Compilation"), |
712 self.trUtf8("Form Compilation"), |
778 return self.compileProc |
783 return self.compileProc |
779 else: |
784 else: |
780 self.compileRunning = False |
785 self.compileRunning = False |
781 if progress is not None: |
786 if progress is not None: |
782 progress.cancel() |
787 progress.cancel() |
783 E5MessageBox.critical(self, |
788 E5MessageBox.critical( |
|
789 self, |
784 self.trUtf8('Process Generation Error'), |
790 self.trUtf8('Process Generation Error'), |
785 self.trUtf8( |
791 self.trUtf8( |
786 'Could not start {0}.<br>' |
792 'Could not start {0}.<br>' |
787 'Ensure that it is in the search path.' |
793 'Ensure that it is in the search path.' |
788 ).format(self.uicompiler)) |
794 ).format(self.uicompiler)) |