15 import contextlib |
15 import contextlib |
16 |
16 |
17 from PyQt6.QtCore import pyqtSignal, QProcess |
17 from PyQt6.QtCore import pyqtSignal, QProcess |
18 from PyQt6.QtWidgets import QDialog, QMenu |
18 from PyQt6.QtWidgets import QDialog, QMenu |
19 |
19 |
20 from E5Gui import E5MessageBox |
20 from E5Gui import EricMessageBox |
21 from E5Gui.E5Application import e5App |
21 from E5Gui.EricApplication import ericApp |
22 |
22 |
23 from .ProjectBrowserModel import ( |
23 from .ProjectBrowserModel import ( |
24 ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem, |
24 ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem, |
25 ProjectBrowserDirectoryItem, ProjectBrowserTranslationType |
25 ProjectBrowserDirectoryItem, ProjectBrowserTranslationType |
26 ) |
26 ) |
786 langs = [lang for lang in self.project.pdata["TRANSLATIONS"] |
786 langs = [lang for lang in self.project.pdata["TRANSLATIONS"] |
787 if fnmatch.fnmatch(lang, pattern)] |
787 if fnmatch.fnmatch(lang, pattern)] |
788 except IndexError: |
788 except IndexError: |
789 langs = [] |
789 langs = [] |
790 if not langs: |
790 if not langs: |
791 E5MessageBox.warning( |
791 EricMessageBox.warning( |
792 self, |
792 self, |
793 self.tr("Write temporary project file"), |
793 self.tr("Write temporary project file"), |
794 self.tr("""No translation files (*.ts) selected.""")) |
794 self.tr("""No translation files (*.ts) selected.""")) |
795 return False |
795 return False |
796 |
796 |
828 [f.replace(os.sep, '/') for f in fileList])) |
828 [f.replace(os.sep, '/') for f in fileList])) |
829 pf.write('\n\n') |
829 pf.write('\n\n') |
830 |
830 |
831 self.__tmpProjects.append(outFile) |
831 self.__tmpProjects.append(outFile) |
832 except OSError: |
832 except OSError: |
833 E5MessageBox.critical( |
833 EricMessageBox.critical( |
834 self, |
834 self, |
835 self.tr("Write temporary project file"), |
835 self.tr("Write temporary project file"), |
836 self.tr( |
836 self.tr( |
837 "<p>The temporary project file <b>{0}</b> could not" |
837 "<p>The temporary project file <b>{0}</b> could not" |
838 " be written.</p>").format(outFile)) |
838 " be written.</p>").format(outFile)) |
934 @param exitCode exit code of the process |
934 @param exitCode exit code of the process |
935 @type int |
935 @type int |
936 @param exitStatus exit status of the process |
936 @param exitStatus exit status of the process |
937 @type QProcess.ExitStatus |
937 @type QProcess.ExitStatus |
938 """ |
938 """ |
939 ui = e5App().getObject("UserInterface") |
939 ui = ericApp().getObject("UserInterface") |
940 if exitStatus == QProcess.ExitStatus.NormalExit and exitCode == 0: |
940 if exitStatus == QProcess.ExitStatus.NormalExit and exitCode == 0: |
941 ui.showNotification( |
941 ui.showNotification( |
942 UI.PixmapCache.getPixmap("linguist48"), |
942 UI.PixmapCache.getPixmap("linguist48"), |
943 self.tr("Translation file generation"), |
943 self.tr("Translation file generation"), |
944 self.tr( |
944 self.tr( |
1081 procStarted = proc.waitForStarted() |
1081 procStarted = proc.waitForStarted() |
1082 if procStarted: |
1082 if procStarted: |
1083 self.pylupdateProcRunning = True |
1083 self.pylupdateProcRunning = True |
1084 self.__pylupdateProcesses.append((proc, "")) |
1084 self.__pylupdateProcesses.append((proc, "")) |
1085 else: |
1085 else: |
1086 E5MessageBox.critical( |
1086 EricMessageBox.critical( |
1087 self, |
1087 self, |
1088 self.tr('Process Generation Error'), |
1088 self.tr('Process Generation Error'), |
1089 self.tr( |
1089 self.tr( |
1090 'Could not start {0}.<br>' |
1090 'Could not start {0}.<br>' |
1091 'Ensure that it is in the search path.' |
1091 'Ensure that it is in the search path.' |
1117 procStarted = proc.waitForStarted() |
1117 procStarted = proc.waitForStarted() |
1118 if procStarted: |
1118 if procStarted: |
1119 self.pylupdateProcRunning = True |
1119 self.pylupdateProcRunning = True |
1120 self.__pylupdateProcesses.append((proc, tempProjectFile)) |
1120 self.__pylupdateProcesses.append((proc, tempProjectFile)) |
1121 else: |
1121 else: |
1122 E5MessageBox.critical( |
1122 EricMessageBox.critical( |
1123 self, |
1123 self, |
1124 self.tr('Process Generation Error'), |
1124 self.tr('Process Generation Error'), |
1125 self.tr( |
1125 self.tr( |
1126 'Could not start {0}.<br>' |
1126 'Could not start {0}.<br>' |
1127 'Ensure that it is in the search path.' |
1127 'Ensure that it is in the search path.' |
1178 @param exitCode exit code of the process |
1178 @param exitCode exit code of the process |
1179 @type int |
1179 @type int |
1180 @param exitStatus exit status of the process |
1180 @param exitStatus exit status of the process |
1181 @type QProcess.ExitStatus |
1181 @type QProcess.ExitStatus |
1182 """ |
1182 """ |
1183 ui = e5App().getObject("UserInterface") |
1183 ui = ericApp().getObject("UserInterface") |
1184 if exitStatus == QProcess.ExitStatus.NormalExit and exitCode == 0: |
1184 if exitStatus == QProcess.ExitStatus.NormalExit and exitCode == 0: |
1185 ui.showNotification( |
1185 ui.showNotification( |
1186 UI.PixmapCache.getPixmap("linguist48"), |
1186 UI.PixmapCache.getPixmap("linguist48"), |
1187 self.tr("Translation file release"), |
1187 self.tr("Translation file release"), |
1188 self.tr("The release of the translation files (*.qm)" |
1188 self.tr("The release of the translation files (*.qm)" |
1258 langs = [lang for lang in self.project.pdata["TRANSLATIONS"] |
1258 langs = [lang for lang in self.project.pdata["TRANSLATIONS"] |
1259 if fnmatch.fnmatch(lang, pattern)] |
1259 if fnmatch.fnmatch(lang, pattern)] |
1260 except IndexError: |
1260 except IndexError: |
1261 langs = [] |
1261 langs = [] |
1262 if not langs: |
1262 if not langs: |
1263 E5MessageBox.warning( |
1263 EricMessageBox.warning( |
1264 self, |
1264 self, |
1265 self.tr("Write temporary project file"), |
1265 self.tr("Write temporary project file"), |
1266 self.tr("""No translation files (*.ts) selected.""")) |
1266 self.tr("""No translation files (*.ts) selected.""")) |
1267 return |
1267 return |
1268 |
1268 |
1289 procStarted = proc.waitForStarted() |
1289 procStarted = proc.waitForStarted() |
1290 if procStarted: |
1290 if procStarted: |
1291 self.lreleaseProcRunning = True |
1291 self.lreleaseProcRunning = True |
1292 self.__lreleaseProcesses.append(proc) |
1292 self.__lreleaseProcesses.append(proc) |
1293 else: |
1293 else: |
1294 E5MessageBox.critical( |
1294 EricMessageBox.critical( |
1295 self, |
1295 self, |
1296 self.tr('Process Generation Error'), |
1296 self.tr('Process Generation Error'), |
1297 self.tr( |
1297 self.tr( |
1298 '<p>Could not start lrelease.<br>' |
1298 '<p>Could not start lrelease.<br>' |
1299 'Ensure that it is available as <b>{0}</b>.</p>' |
1299 'Ensure that it is available as <b>{0}</b>.</p>' |