559 Private slot to handle the Preview translations action. |
559 Private slot to handle the Preview translations action. |
560 """ |
560 """ |
561 fileNames = [] |
561 fileNames = [] |
562 for itm in self.getSelectedItems(): |
562 for itm in self.getSelectedItems(): |
563 fileNames.append(itm.fileName()) |
563 fileNames.append(itm.fileName()) |
564 trfiles = sorted(self.project.pdata["TRANSLATIONS"][:]) |
564 trfiles = sorted(self.project.getProjectData(dataKey="TRANSLATIONS")[:]) |
565 fileNames.extend( |
565 fileNames.extend( |
566 [ |
566 [ |
567 os.path.join(self.project.ppath, trfile) |
567 os.path.join(self.project.ppath, trfile) |
568 for trfile in trfiles |
568 for trfile in trfiles |
569 if trfile.endswith(".qm") |
569 if trfile.endswith(".qm") |
784 None if self.project.useSystemEol() else self.project.getEolString() |
784 None if self.project.useSystemEol() else self.project.getEolString() |
785 ) |
785 ) |
786 with open(ofn, "w", encoding="utf-8", newline=newline) as f: |
786 with open(ofn, "w", encoding="utf-8", newline=newline) as f: |
787 for line in self.buf.splitlines(): |
787 for line in self.buf.splitlines(): |
788 f.write(line + "\n") |
788 f.write(line + "\n") |
789 if self.compiledFile not in self.project.pdata["SOURCES"]: |
789 if self.compiledFile not in self.project.getProjectData( |
|
790 dataKey="SOURCES" |
|
791 ): |
790 self.project.appendFile(ofn) |
792 self.project.appendFile(ofn) |
791 ui.showNotification( |
793 ui.showNotification( |
792 EricPixmapCache.getPixmap("designer48"), |
794 EricPixmapCache.getPixmap("designer48"), |
793 self.tr("Form Compilation"), |
795 self.tr("Form Compilation"), |
794 self.tr("The compilation of the form file" " was successful."), |
796 self.tr("The compilation of the form file" " was successful."), |
859 if Preferences.getQt("PyuicExecute"): |
861 if Preferences.getQt("PyuicExecute"): |
860 args.append("-x") |
862 args.append("-x") |
861 indentWidth = Preferences.getQt("PyuicIndent") |
863 indentWidth = Preferences.getQt("PyuicIndent") |
862 if indentWidth != self.Pyuic5IndentDefault: |
864 if indentWidth != self.Pyuic5IndentDefault: |
863 args.append("--indent={0}".format(indentWidth)) |
865 args.append("--indent={0}".format(indentWidth)) |
864 if "uic5" in uicompiler and self.project.pdata["UICPARAMS"]["Package"]: |
866 if ( |
|
867 "uic5" in uicompiler |
|
868 and self.project.getProjectData(dataKey="UICPARAMS")["Package"] |
|
869 ): |
865 args.append( |
870 args.append( |
866 "--import-from={0}".format( |
871 "--import-from={0}".format( |
867 self.project.pdata["UICPARAMS"]["Package"] |
872 self.project.getProjectData(dataKey="UICPARAMS")["Package"] |
868 ) |
873 ) |
869 ) |
874 ) |
870 elif Preferences.getQt("PyuicFromImports"): |
875 elif Preferences.getQt("PyuicFromImports"): |
871 args.append("--from-imports") |
876 args.append("--from-imports") |
872 if self.project.pdata["UICPARAMS"]["RcSuffix"]: |
877 if self.project.getProjectData(dataKey="UICPARAMS")["RcSuffix"]: |
873 args.append( |
878 args.append( |
874 "--resource-suffix={0}".format( |
879 "--resource-suffix={0}".format( |
875 self.project.pdata["UICPARAMS"]["RcSuffix"] |
880 self.project.getProjectData(dataKey="UICPARAMS")["RcSuffix"] |
876 ) |
881 ) |
877 ) |
882 ) |
878 elif self.project.getProjectLanguage() == "Ruby": |
883 elif self.project.getProjectLanguage() == "Ruby": |
879 self.compiledFile = ofn + ".rb" |
884 self.compiledFile = ofn + ".rb" |
880 args.append("-x") |
885 args.append("-x") |
947 def __compileAllForms(self): |
952 def __compileAllForms(self): |
948 """ |
953 """ |
949 Private method to compile all forms to source files. |
954 Private method to compile all forms to source files. |
950 """ |
955 """ |
951 if self.hooks["compileAllForms"] is not None: |
956 if self.hooks["compileAllForms"] is not None: |
952 self.hooks["compileAllForms"](self.project.pdata["FORMS"]) |
957 self.hooks["compileAllForms"](self.project.getProjectData(dataKey="FORMS")) |
953 else: |
958 else: |
954 numForms = len(self.project.pdata["FORMS"]) |
959 numForms = len(self.project.getProjectData(dataKey="FORMS")) |
955 progress = EricProgressDialog( |
960 progress = EricProgressDialog( |
956 self.tr("Compiling forms..."), |
961 self.tr("Compiling forms..."), |
957 self.tr("Abort"), |
962 self.tr("Abort"), |
958 0, |
963 0, |
959 numForms, |
964 numForms, |
962 ) |
967 ) |
963 progress.setModal(True) |
968 progress.setModal(True) |
964 progress.setMinimumDuration(0) |
969 progress.setMinimumDuration(0) |
965 progress.setWindowTitle(self.tr("Forms")) |
970 progress.setWindowTitle(self.tr("Forms")) |
966 |
971 |
967 for prog, fn in enumerate(self.project.pdata["FORMS"]): |
972 for prog, fn in enumerate(self.project.getProjectData(dataKey="FORMS")): |
968 progress.setValue(prog) |
973 progress.setValue(prog) |
969 if progress.wasCanceled(): |
974 if progress.wasCanceled(): |
970 break |
975 break |
971 |
976 |
972 proc = self.__compileUI(fn, True, progress) |
977 proc = self.__compileUI(fn, True, progress) |
1018 def compileChangedForms(self): |
1023 def compileChangedForms(self): |
1019 """ |
1024 """ |
1020 Public method to compile all changed forms to source files. |
1025 Public method to compile all changed forms to source files. |
1021 """ |
1026 """ |
1022 if self.hooks["compileChangedForms"] is not None: |
1027 if self.hooks["compileChangedForms"] is not None: |
1023 self.hooks["compileChangedForms"](self.project.pdata["FORMS"]) |
1028 self.hooks["compileChangedForms"]( |
|
1029 self.project.getProjectData(dataKey="FORMS") |
|
1030 ) |
1024 else: |
1031 else: |
1025 if self.project.getProjectType() not in [ |
1032 if self.project.getProjectType() not in [ |
1026 "PyQt5", |
1033 "PyQt5", |
1027 "PyQt6", |
1034 "PyQt6", |
1028 "E7Plugin", |
1035 "E7Plugin", |
1030 "PySide6", |
1037 "PySide6", |
1031 ]: |
1038 ]: |
1032 # ignore the request for non Qt GUI projects |
1039 # ignore the request for non Qt GUI projects |
1033 return |
1040 return |
1034 |
1041 |
1035 if len(self.project.pdata["FORMS"]) == 0: |
1042 if len(self.project.getProjectData(dataKey="FORMS")) == 0: |
1036 # The project does not contain form files. |
1043 # The project does not contain form files. |
1037 return |
1044 return |
1038 |
1045 |
1039 progress = EricProgressDialog( |
1046 progress = EricProgressDialog( |
1040 self.tr("Determining changed forms..."), |
1047 self.tr("Determining changed forms..."), |
1047 progress.setMinimumDuration(0) |
1054 progress.setMinimumDuration(0) |
1048 progress.setWindowTitle(self.tr("Forms")) |
1055 progress.setWindowTitle(self.tr("Forms")) |
1049 |
1056 |
1050 # get list of changed forms |
1057 # get list of changed forms |
1051 changedForms = [] |
1058 changedForms = [] |
1052 progress.setMaximum(len(self.project.pdata["FORMS"])) |
1059 progress.setMaximum(len(self.project.getProjectData(dataKey="FORMS"))) |
1053 for prog, fn in enumerate(self.project.pdata["FORMS"]): |
1060 for prog, fn in enumerate(self.project.getProjectData(dataKey="FORMS")): |
1054 progress.setValue(prog) |
1061 progress.setValue(prog) |
1055 QApplication.processEvents() |
1062 QApplication.processEvents() |
1056 |
1063 |
1057 ifn = os.path.join(self.project.ppath, fn) |
1064 ifn = os.path.join(self.project.ppath, fn) |
1058 if self.project.getProjectLanguage() == "Python3": |
1065 if self.project.getProjectLanguage() == "Python3": |
1063 if ( |
1070 if ( |
1064 not os.path.exists(ofn) |
1071 not os.path.exists(ofn) |
1065 or os.stat(ifn).st_mtime > os.stat(ofn).st_mtime |
1072 or os.stat(ifn).st_mtime > os.stat(ofn).st_mtime |
1066 ): |
1073 ): |
1067 changedForms.append(fn) |
1074 changedForms.append(fn) |
1068 progress.setValue(len(self.project.pdata["FORMS"])) |
1075 progress.setValue(len(self.project.getProjectData(dataKey="FORMS"))) |
1069 QApplication.processEvents() |
1076 QApplication.processEvents() |
1070 |
1077 |
1071 if changedForms: |
1078 if changedForms: |
1072 progress.setLabelText(self.tr("Compiling changed forms...")) |
1079 progress.setLabelText(self.tr("Compiling changed forms...")) |
1073 progress.setMaximum(len(changedForms)) |
1080 progress.setMaximum(len(changedForms)) |
1101 """ |
1108 """ |
1102 Private slot to configure some non-common uic compiler options. |
1109 Private slot to configure some non-common uic compiler options. |
1103 """ |
1110 """ |
1104 from .UicCompilerOptionsDialog import UicCompilerOptionsDialog |
1111 from .UicCompilerOptionsDialog import UicCompilerOptionsDialog |
1105 |
1112 |
1106 params = self.project.pdata["UICPARAMS"] |
1113 params = self.project.getProjectData(dataKey="UICPARAMS") |
1107 |
1114 |
1108 if self.project.getProjectType() in ["PyQt5", "PyQt6", "E7Plugin"]: |
1115 if self.project.getProjectType() in ["PyQt5", "PyQt6", "E7Plugin"]: |
1109 dlg = UicCompilerOptionsDialog(params, self.getUiCompiler()) |
1116 dlg = UicCompilerOptionsDialog(params, self.getUiCompiler()) |
1110 if dlg.exec() == QDialog.DialogCode.Accepted: |
1117 if dlg.exec() == QDialog.DialogCode.Accepted: |
1111 package, suffix, root = dlg.getData() |
1118 package, suffix, root = dlg.getData() |