459 @param coord the position of the mouse pointer (QPoint) |
460 @param coord the position of the mouse pointer (QPoint) |
460 """ |
461 """ |
461 if not self.project.isOpen(): |
462 if not self.project.isOpen(): |
462 return |
463 return |
463 |
464 |
464 try: |
465 with contextlib.suppress(Exception): |
465 categories = self.getSelectedItemsCountCategorized( |
466 categories = self.getSelectedItemsCountCategorized( |
466 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]) |
467 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]) |
467 cnt = categories["sum"] |
468 cnt = categories["sum"] |
468 if cnt <= 1: |
469 if cnt <= 1: |
469 index = self.indexAt(coord) |
470 index = self.indexAt(coord) |
487 self.dirMenu.popup(self.mapToGlobal(coord)) |
488 self.dirMenu.popup(self.mapToGlobal(coord)) |
488 else: |
489 else: |
489 self.backMenu.popup(self.mapToGlobal(coord)) |
490 self.backMenu.popup(self.mapToGlobal(coord)) |
490 else: |
491 else: |
491 self.backMenu.popup(self.mapToGlobal(coord)) |
492 self.backMenu.popup(self.mapToGlobal(coord)) |
492 except Exception: # secok |
|
493 pass |
|
494 |
493 |
495 def __showContextMenu(self): |
494 def __showContextMenu(self): |
496 """ |
495 """ |
497 Private slot called by the menu aboutToShow signal. |
496 Private slot called by the menu aboutToShow signal. |
498 """ |
497 """ |
709 for itm in itmList: |
708 for itm in itmList: |
710 if isinstance(itm, ProjectBrowserSimpleDirectoryItem): |
709 if isinstance(itm, ProjectBrowserSimpleDirectoryItem): |
711 dname = self.project.getRelativePath(itm.dirName()) |
710 dname = self.project.getRelativePath(itm.dirName()) |
712 trfiles = sorted(self.project.pdata["TRANSLATIONS"][:]) |
711 trfiles = sorted(self.project.pdata["TRANSLATIONS"][:]) |
713 for trfile in trfiles: |
712 for trfile in trfiles: |
714 if trfile.startswith(dname): |
713 if ( |
715 if trfile not in fileNames: |
714 trfile.startswith(dname) and |
716 fileNames.append( |
715 trfile not in fileNames |
717 os.path.join(self.project.ppath, trfile)) |
716 ): |
|
717 fileNames.append( |
|
718 os.path.join(self.project.ppath, trfile)) |
718 else: |
719 else: |
719 fn = itm.fileName() |
720 fn = itm.fileName() |
720 if fn not in fileNames: |
721 if fn not in fileNames: |
721 fileNames.append(os.path.join(self.project.ppath, fn)) |
722 fileNames.append(os.path.join(self.project.ppath, fn)) |
722 else: |
723 else: |
952 UI.PixmapCache.getPixmap("linguist48"), |
953 UI.PixmapCache.getPixmap("linguist48"), |
953 self.tr("Translation file generation"), |
954 self.tr("Translation file generation"), |
954 self.tr( |
955 self.tr( |
955 "The generation of the translation files (*.ts) has" |
956 "The generation of the translation files (*.ts) has" |
956 " failed.{0}").format(info), |
957 " failed.{0}").format(info), |
957 kind=NotificationTypes.Critical, |
958 kind=NotificationTypes.CRITICAL, |
958 timeout=0) |
959 timeout=0) |
959 |
960 |
960 for index in range(len(self.__pylupdateProcesses)): |
961 for index in range(len(self.__pylupdateProcesses)): |
961 if proc == self.__pylupdateProcesses[index][0]: |
962 if proc == self.__pylupdateProcesses[index][0]: |
962 tmpProjectFile = self.__pylupdateProcesses[index][1] |
963 tmpProjectFile = self.__pylupdateProcesses[index][1] |
963 if tmpProjectFile: |
964 if tmpProjectFile: |
964 try: |
965 with contextlib.suppress(OSError): |
965 self.__tmpProjects.remove(tmpProjectFile) |
966 self.__tmpProjects.remove(tmpProjectFile) |
966 os.remove(tmpProjectFile) |
967 os.remove(tmpProjectFile) |
967 except OSError: |
|
968 pass |
|
969 del self.__pylupdateProcesses[index] |
968 del self.__pylupdateProcesses[index] |
970 break |
969 break |
971 |
970 |
972 if not self.__pylupdateProcesses: |
971 if not self.__pylupdateProcesses: |
973 # all done |
972 # all done |
1024 if not ok: |
1020 if not ok: |
1025 return |
1021 return |
1026 else: |
1022 else: |
1027 return |
1023 return |
1028 |
1024 |
1029 if self.project.getProjectType() in ["PyQt5", "PyQt5C"]: |
1025 if self.project.getProjectType() in ["PyQt5", "PyQt5C", "E6Plugin"]: |
1030 self.pylupdate = Utilities.generatePyQtToolPath('pylupdate5') |
1026 self.pylupdate = Utilities.generatePyQtToolPath('pylupdate5') |
1031 elif self.project.getProjectType() in ["PyQt6", "PyQt6C"]: |
1027 elif self.project.getProjectType() in ["PyQt6", "PyQt6C"]: |
1032 self.pylupdate = Utilities.generatePyQtToolPath('pylupdate6') |
1028 self.pylupdate = Utilities.generatePyQtToolPath('pylupdate6') |
1033 elif self.project.getProjectType() in ["E6Plugin"]: |
|
1034 self.pylupdate = Utilities.generatePyQtToolPath('pylupdate5') |
|
1035 elif self.project.getProjectType() in ["PySide2", "PySide2C"]: |
1029 elif self.project.getProjectType() in ["PySide2", "PySide2C"]: |
1036 self.pylupdate = Utilities.generatePySideToolPath( |
1030 self.pylupdate = Utilities.generatePySideToolPath( |
1037 'pyside2-lupdate', variant=2) |
1031 'pyside2-lupdate', variant=2) |
1038 elif self.project.getProjectType() in ["PySide6", "PySide6C"]: |
1032 elif self.project.getProjectType() in ["PySide6", "PySide6C"]: |
1039 self.pylupdate = Utilities.generatePySideToolPath( |
1033 self.pylupdate = Utilities.generatePySideToolPath( |
1131 self.tr( |
1125 self.tr( |
1132 'Could not start {0}.<br>' |
1126 'Could not start {0}.<br>' |
1133 'Ensure that it is in the search path.' |
1127 'Ensure that it is in the search path.' |
1134 ).format(self.pylupdate)) |
1128 ).format(self.pylupdate)) |
1135 # cleanup |
1129 # cleanup |
1136 try: |
1130 with contextlib.suppress(OSError): |
1137 self.__tmpProjects.remove(tempProjectFile) |
1131 self.__tmpProjects.remove(tempProjectFile) |
1138 os.remove(tempProjectFile) |
1132 os.remove(tempProjectFile) |
1139 except OSError: |
|
1140 pass |
|
1141 |
1133 |
1142 def __generateAll(self): |
1134 def __generateAll(self): |
1143 """ |
1135 """ |
1144 Private method to generate all translation files (.ts) for Qt Linguist. |
1136 Private method to generate all translation files (.ts) for Qt Linguist. |
1145 |
1137 |
1209 ui.showNotification( |
1201 ui.showNotification( |
1210 UI.PixmapCache.getPixmap("linguist48"), |
1202 UI.PixmapCache.getPixmap("linguist48"), |
1211 self.tr("Translation file release"), |
1203 self.tr("Translation file release"), |
1212 self.tr( |
1204 self.tr( |
1213 "The release of the translation files (*.qm) has failed."), |
1205 "The release of the translation files (*.qm) has failed."), |
1214 kind=NotificationTypes.Critical, |
1206 kind=NotificationTypes.CRITICAL, |
1215 timeout=0) |
1207 timeout=0) |
1216 |
1208 |
1217 for index in range(len(self.__lreleaseProcesses)): |
1209 for index in range(len(self.__lreleaseProcesses)): |
1218 if proc == self.__lreleaseProcesses[index]: |
1210 if proc == self.__lreleaseProcesses[index]: |
1219 del self.__lreleaseProcesses[index] |
1211 del self.__lreleaseProcesses[index] |
1228 Private method to run lrelease to release the translation files (.qm). |
1220 Private method to run lrelease to release the translation files (.qm). |
1229 |
1221 |
1230 @param generateAll flag indicating whether all translations should be |
1222 @param generateAll flag indicating whether all translations should be |
1231 released (boolean) |
1223 released (boolean) |
1232 """ |
1224 """ |
1233 if generateAll: |
1225 langs = [] if generateAll else self.getSelectedItems() |
1234 langs = [] |
|
1235 else: |
|
1236 langs = self.getSelectedItems() |
|
1237 |
1226 |
1238 # Hooks support |
1227 # Hooks support |
1239 if generateAll: |
1228 if generateAll: |
1240 if self.hooks["releaseAll"] is not None: |
1229 if self.hooks["releaseAll"] is not None: |
1241 self.hooks["releaseAll"](self.project.pdata["TRANSLATIONS"]) |
1230 self.hooks["releaseAll"](self.project.pdata["TRANSLATIONS"]) |
1255 Utilities.getQtBinariesPath(), |
1244 Utilities.getQtBinariesPath(), |
1256 Utilities.generateQtToolName("lrelease")) |
1245 Utilities.generateQtToolName("lrelease")) |
1257 else: |
1246 else: |
1258 return |
1247 return |
1259 if Utilities.isWindowsPlatform(): |
1248 if Utilities.isWindowsPlatform(): |
1260 lrelease = lrelease + '.exe' |
1249 lrelease += '.exe' |
1261 |
1250 |
1262 if langs: |
1251 if langs: |
1263 langs = [self.project.getRelativePath(lang.fileName()) |
1252 langs = [self.project.getRelativePath(lang.fileName()) |
1264 for lang in langs if lang.fileName().endswith('.ts')] |
1253 for lang in langs if lang.fileName().endswith('.ts')] |
1265 else: |
1254 else: |