1024 QApplication.processEvents() |
1025 QApplication.processEvents() |
1025 else: |
1026 else: |
1026 break |
1027 break |
1027 progress.setValue(numForms) |
1028 progress.setValue(numForms) |
1028 |
1029 |
1029 def compileChangedForms(self): |
1030 def __compileChangedForms(self): |
1030 """ |
1031 """ |
1031 Public method to compile all changed forms to source files. |
1032 Private method to compile all changed forms to source files. |
1032 """ |
1033 """ |
1033 if self.hooks["compileChangedForms"] is not None: |
1034 if Preferences.getProject("AutoCompileForms"): |
1034 self.hooks["compileChangedForms"]( |
1035 if self.hooks["compileChangedForms"] is not None: |
1035 self.project.getProjectData(dataKey="FORMS") |
1036 self.hooks["compileChangedForms"]( |
1036 ) |
1037 self.project.getProjectData(dataKey="FORMS") |
1037 else: |
1038 ) |
1038 if self.project.getProjectType() not in [ |
1039 else: |
1039 "PyQt5", |
1040 if self.project.getProjectType() not in [ |
1040 "PyQt6", |
1041 "PyQt5", |
1041 "E7Plugin", |
1042 "PyQt6", |
1042 "PySide2", |
1043 "E7Plugin", |
1043 "PySide6", |
1044 "PySide2", |
1044 ]: |
1045 "PySide6", |
1045 # ignore the request for non Qt GUI projects |
1046 ]: |
1046 return |
1047 # ignore the request for non Qt GUI projects |
1047 |
1048 return |
1048 if len(self.project.getProjectData(dataKey="FORMS")) == 0: |
1049 |
1049 # The project does not contain form files. |
1050 if len(self.project.getProjectData(dataKey="FORMS")) == 0: |
1050 return |
1051 # The project does not contain form files. |
1051 |
1052 return |
1052 progress = EricProgressDialog( |
1053 |
1053 self.tr("Determining changed forms..."), |
1054 progress = EricProgressDialog( |
1054 self.tr("Abort"), |
1055 self.tr("Determining changed forms..."), |
1055 0, |
1056 self.tr("Abort"), |
1056 100, |
1057 0, |
1057 self.tr("%v/%m Forms"), |
1058 100, |
1058 self, |
1059 self.tr("%v/%m Forms"), |
1059 ) |
1060 self, |
1060 progress.setMinimumDuration(0) |
1061 ) |
1061 progress.setWindowTitle(self.tr("Forms")) |
1062 progress.setMinimumDuration(0) |
1062 |
1063 progress.setWindowTitle(self.tr("Forms")) |
1063 # get list of changed forms |
1064 |
1064 changedForms = [] |
1065 # get list of changed forms |
1065 progress.setMaximum(len(self.project.getProjectData(dataKey="FORMS"))) |
1066 changedForms = [] |
1066 for prog, fn in enumerate(self.project.getProjectData(dataKey="FORMS")): |
1067 progress.setMaximum(len(self.project.getProjectData(dataKey="FORMS"))) |
1067 progress.setValue(prog) |
1068 for prog, fn in enumerate(self.project.getProjectData(dataKey="FORMS")): |
|
1069 progress.setValue(prog) |
|
1070 QApplication.processEvents() |
|
1071 |
|
1072 ifn = os.path.join(self.project.ppath, fn) |
|
1073 if self.project.getProjectLanguage() == "Python3": |
|
1074 dirname, filename = os.path.split(os.path.splitext(ifn)[0]) |
|
1075 ofn = os.path.join(dirname, "Ui_" + filename + ".py") |
|
1076 elif self.project.getProjectLanguage() == "Ruby": |
|
1077 ofn = os.path.splitext(ifn)[0] + ".rb" |
|
1078 if ( |
|
1079 not os.path.exists(ofn) |
|
1080 or os.stat(ifn).st_mtime > os.stat(ofn).st_mtime |
|
1081 ): |
|
1082 changedForms.append(fn) |
|
1083 progress.setValue(len(self.project.getProjectData(dataKey="FORMS"))) |
1068 QApplication.processEvents() |
1084 QApplication.processEvents() |
1069 |
1085 |
1070 ifn = os.path.join(self.project.ppath, fn) |
1086 if changedForms: |
1071 if self.project.getProjectLanguage() == "Python3": |
1087 progress.setLabelText(self.tr("Compiling changed forms...")) |
1072 dirname, filename = os.path.split(os.path.splitext(ifn)[0]) |
1088 progress.setMaximum(len(changedForms)) |
1073 ofn = os.path.join(dirname, "Ui_" + filename + ".py") |
|
1074 elif self.project.getProjectLanguage() == "Ruby": |
|
1075 ofn = os.path.splitext(ifn)[0] + ".rb" |
|
1076 if ( |
|
1077 not os.path.exists(ofn) |
|
1078 or os.stat(ifn).st_mtime > os.stat(ofn).st_mtime |
|
1079 ): |
|
1080 changedForms.append(fn) |
|
1081 progress.setValue(len(self.project.getProjectData(dataKey="FORMS"))) |
|
1082 QApplication.processEvents() |
|
1083 |
|
1084 if changedForms: |
|
1085 progress.setLabelText(self.tr("Compiling changed forms...")) |
|
1086 progress.setMaximum(len(changedForms)) |
|
1087 progress.setValue(prog) |
|
1088 QApplication.processEvents() |
|
1089 for prog, fn in enumerate(changedForms): |
|
1090 progress.setValue(prog) |
1089 progress.setValue(prog) |
1091 if progress.wasCanceled(): |
1090 QApplication.processEvents() |
1092 break |
1091 for prog, fn in enumerate(changedForms): |
1093 |
1092 progress.setValue(prog) |
1094 proc = self.__compileUI(fn, True, progress) |
1093 if progress.wasCanceled(): |
1095 if proc is not None: |
1094 break |
1096 while proc.state() == QProcess.ProcessState.Running: |
1095 |
1097 QApplication.processEvents() |
1096 proc = self.__compileUI(fn, True, progress) |
1098 QThread.msleep(300) |
1097 if proc is not None: |
1099 QApplication.processEvents() |
1098 while proc.state() == QProcess.ProcessState.Running: |
1100 else: |
1099 QApplication.processEvents() |
1101 break |
1100 QThread.msleep(300) |
1102 progress.setValue(len(changedForms)) |
1101 QApplication.processEvents() |
1103 QApplication.processEvents() |
1102 else: |
|
1103 break |
|
1104 progress.setValue(len(changedForms)) |
|
1105 QApplication.processEvents() |
1104 |
1106 |
1105 def handlePreferencesChanged(self): |
1107 def handlePreferencesChanged(self): |
1106 """ |
1108 """ |
1107 Public slot used to handle the preferencesChanged signal. |
1109 Public slot used to handle the preferencesChanged signal. |
1108 """ |
1110 """ |