47 appendStderr = pyqtSignal(str) |
47 appendStderr = pyqtSignal(str) |
48 uipreview = pyqtSignal(str) |
48 uipreview = pyqtSignal(str) |
49 showMenu = pyqtSignal(str, QMenu) |
49 showMenu = pyqtSignal(str, QMenu) |
50 menusAboutToBeCreated = pyqtSignal() |
50 menusAboutToBeCreated = pyqtSignal() |
51 |
51 |
52 PyuicIndentDefault = 4 |
52 Pyuic5IndentDefault = 4 |
|
53 Pyuic6IndentDefault = 4 |
53 |
54 |
54 def __init__(self, project, parent=None): |
55 def __init__(self, project, parent=None): |
55 """ |
56 """ |
56 Constructor |
57 Constructor |
57 |
58 |
121 self.dirMenuActions = [] |
122 self.dirMenuActions = [] |
122 self.dirMultiMenuActions = [] |
123 self.dirMultiMenuActions = [] |
123 |
124 |
124 self.menusAboutToBeCreated.emit() |
125 self.menusAboutToBeCreated.emit() |
125 |
126 |
|
127 projectType = self.project.getProjectType() |
|
128 |
126 self.menu = QMenu(self) |
129 self.menu = QMenu(self) |
127 if self.project.getProjectType() in ["PyQt5", "E6Plugin", "PySide2"]: |
130 if projectType in ["PyQt5", "PyQt6", "E6Plugin", "PySide2"]: |
128 self.menu.addAction( |
131 self.menu.addAction( |
129 self.tr('Compile form'), self.__compileForm) |
132 self.tr('Compile form'), self.__compileForm) |
130 self.menu.addAction( |
133 self.menu.addAction( |
131 self.tr('Compile all forms'), |
134 self.tr('Compile all forms'), |
132 self.__compileAllForms) |
135 self.__compileAllForms) |
182 self.tr('Remove from project'), self._removeFile) |
185 self.tr('Remove from project'), self._removeFile) |
183 self.menuActions.append(act) |
186 self.menuActions.append(act) |
184 act = self.menu.addAction(self.tr('Delete'), self.__deleteFile) |
187 act = self.menu.addAction(self.tr('Delete'), self.__deleteFile) |
185 self.menuActions.append(act) |
188 self.menuActions.append(act) |
186 self.menu.addSeparator() |
189 self.menu.addSeparator() |
187 if self.project.getProjectType() in ["PyQt5", "E6Plugin", "PySide2"]: |
190 if projectType in ["PyQt5", "PyQt6", "E6Plugin", "PySide2"]: |
188 self.menu.addAction(self.tr('New form...'), self.__newForm) |
191 self.menu.addAction(self.tr('New form...'), self.__newForm) |
189 else: |
192 else: |
190 if self.hooks["newForm"] is not None: |
193 if self.hooks["newForm"] is not None: |
191 self.menu.addAction( |
194 self.menu.addAction( |
192 self.hooksMenuEntries.get( |
195 self.hooksMenuEntries.get( |
205 self.menu.addSeparator() |
208 self.menu.addSeparator() |
206 self.menu.addAction(self.tr('Configure...'), self._configure) |
209 self.menu.addAction(self.tr('Configure...'), self._configure) |
207 |
210 |
208 self.backMenu = QMenu(self) |
211 self.backMenu = QMenu(self) |
209 if ( |
212 if ( |
210 self.project.getProjectType() in [ |
213 projectType in ["PyQt5", "PyQt6", "E6Plugin", "PySide2"] or |
211 "PyQt5", "E6Plugin", "PySide2" |
|
212 ] or |
|
213 self.hooks["compileAllForms"] is not None |
214 self.hooks["compileAllForms"] is not None |
214 ): |
215 ): |
215 self.backMenu.addAction( |
216 self.backMenu.addAction( |
216 self.tr('Compile all forms'), self.__compileAllForms) |
217 self.tr('Compile all forms'), self.__compileAllForms) |
217 self.backMenu.addSeparator() |
218 self.backMenu.addSeparator() |
238 self.backMenu.addAction(self.tr('Configure...'), self._configure) |
239 self.backMenu.addAction(self.tr('Configure...'), self._configure) |
239 self.backMenu.setEnabled(False) |
240 self.backMenu.setEnabled(False) |
240 |
241 |
241 # create the menu for multiple selected files |
242 # create the menu for multiple selected files |
242 self.multiMenu = QMenu(self) |
243 self.multiMenu = QMenu(self) |
243 if self.project.getProjectType() in ["PyQt5", "E6Plugin", "PySide2"]: |
244 if projectType in ["PyQt5", "PyQt6", "E6Plugin", "PySide2"]: |
244 self.multiMenu.addAction( |
245 self.multiMenu.addAction( |
245 self.tr('Compile forms'), self.__compileSelectedForms) |
246 self.tr('Compile forms'), self.__compileSelectedForms) |
246 self.multiMenu.addSeparator() |
247 self.multiMenu.addSeparator() |
247 self.__pyuicMultiConfigAct = self.multiMenu.addAction( |
248 self.__pyuicMultiConfigAct = self.multiMenu.addAction( |
248 self.tr('Configure uic Compiler'), |
249 self.tr('Configure uic Compiler'), |
283 self.tr('Collapse all directories'), self._collapseAllDirs) |
284 self.tr('Collapse all directories'), self._collapseAllDirs) |
284 self.multiMenu.addSeparator() |
285 self.multiMenu.addSeparator() |
285 self.multiMenu.addAction(self.tr('Configure...'), self._configure) |
286 self.multiMenu.addAction(self.tr('Configure...'), self._configure) |
286 |
287 |
287 self.dirMenu = QMenu(self) |
288 self.dirMenu = QMenu(self) |
288 if self.project.getProjectType() in ["PyQt5", "E6Plugin", "PySide2"]: |
289 if projectType in ["PyQt5", "PyQt6", "E6Plugin", "PySide2"]: |
289 self.dirMenu.addAction( |
290 self.dirMenu.addAction( |
290 self.tr('Compile all forms'), self.__compileAllForms) |
291 self.tr('Compile all forms'), self.__compileAllForms) |
291 self.dirMenu.addSeparator() |
292 self.dirMenu.addSeparator() |
292 self.__pyuicDirConfigAct = self.dirMenu.addAction( |
293 self.__pyuicDirConfigAct = self.dirMenu.addAction( |
293 self.tr('Configure uic Compiler'), |
294 self.tr('Configure uic Compiler'), |
306 self.dirMenuActions.append(act) |
307 self.dirMenuActions.append(act) |
307 act = self.dirMenu.addAction( |
308 act = self.dirMenu.addAction( |
308 self.tr('Delete'), self._deleteDirectory) |
309 self.tr('Delete'), self._deleteDirectory) |
309 self.dirMenuActions.append(act) |
310 self.dirMenuActions.append(act) |
310 self.dirMenu.addSeparator() |
311 self.dirMenu.addSeparator() |
311 if self.project.getProjectType() in ["PyQt5", "E6Plugin", "PySide2"]: |
312 if projectType in ["PyQt5", "PyQt6", "E6Plugin", "PySide2"]: |
312 self.dirMenu.addAction(self.tr('New form...'), self.__newForm) |
313 self.dirMenu.addAction(self.tr('New form...'), self.__newForm) |
313 else: |
314 else: |
314 if self.hooks["newForm"] is not None: |
315 if self.hooks["newForm"] is not None: |
315 self.dirMenu.addAction( |
316 self.dirMenu.addAction( |
316 self.hooksMenuEntries.get( |
317 self.hooksMenuEntries.get( |
330 self.tr('Collapse all directories'), self._collapseAllDirs) |
331 self.tr('Collapse all directories'), self._collapseAllDirs) |
331 self.dirMenu.addSeparator() |
332 self.dirMenu.addSeparator() |
332 self.dirMenu.addAction(self.tr('Configure...'), self._configure) |
333 self.dirMenu.addAction(self.tr('Configure...'), self._configure) |
333 |
334 |
334 self.dirMultiMenu = QMenu(self) |
335 self.dirMultiMenu = QMenu(self) |
335 if self.project.getProjectType() in ["PyQt5", "E6Plugin", "PySide2"]: |
336 if projectType in ["PyQt5", "PyQt6", "E6Plugin", "PySide2"]: |
336 self.dirMultiMenu.addAction( |
337 self.dirMultiMenu.addAction( |
337 self.tr('Compile all forms'), self.__compileAllForms) |
338 self.tr('Compile all forms'), self.__compileAllForms) |
338 self.dirMultiMenu.addSeparator() |
339 self.dirMultiMenu.addSeparator() |
339 self.__pyuicDirMultiConfigAct = self.dirMultiMenu.addAction( |
340 self.__pyuicDirMultiConfigAct = self.dirMultiMenu.addAction( |
340 self.tr('Configure uic Compiler'), |
341 self.tr('Configure uic Compiler'), |
375 @param coord the position of the mouse pointer (QPoint) |
376 @param coord the position of the mouse pointer (QPoint) |
376 """ |
377 """ |
377 if not self.project.isOpen(): |
378 if not self.project.isOpen(): |
378 return |
379 return |
379 |
380 |
380 enable = self.project.getProjectType() in ("PyQt5", "E6Plugin") |
381 enable = ( |
|
382 self.project.getProjectType() in ("PyQt5", "PyQt6", "E6Plugin") |
|
383 ) |
381 self.__pyuicConfigAct.setEnabled(enable) |
384 self.__pyuicConfigAct.setEnabled(enable) |
382 self.__pyuicMultiConfigAct.setEnabled(enable) |
385 self.__pyuicMultiConfigAct.setEnabled(enable) |
383 self.__pyuicDirConfigAct.setEnabled(enable) |
386 self.__pyuicDirConfigAct.setEnabled(enable) |
384 self.__pyuicDirMultiConfigAct.setEnabled(enable) |
387 self.__pyuicDirMultiConfigAct.setEnabled(enable) |
385 self.__pyuicBackConfigAct.setEnabled(enable) |
388 self.__pyuicBackConfigAct.setEnabled(enable) |
563 |
566 |
564 if self.hooks["newForm"] is not None: |
567 if self.hooks["newForm"] is not None: |
565 self.hooks["newForm"](path) |
568 self.hooks["newForm"](path) |
566 else: |
569 else: |
567 if self.project.getProjectType() in [ |
570 if self.project.getProjectType() in [ |
568 "PyQt5", "E6Plugin", "PySide2" |
571 "PyQt5", "PyQt6", "E6Plugin", "PySide2" |
569 ]: |
572 ]: |
570 self.__newUiForm(path) |
573 self.__newUiForm(path) |
571 |
574 |
572 def __newUiForm(self, path): |
575 def __newUiForm(self, path): |
573 """ |
576 """ |
679 |
682 |
680 if self.project.getProjectLanguage() == "Python3": |
683 if self.project.getProjectLanguage() == "Python3": |
681 if self.project.getProjectType() in ["PyQt5"]: |
684 if self.project.getProjectType() in ["PyQt5"]: |
682 self.__uicompiler = Utilities.generatePyQtToolPath( |
685 self.__uicompiler = Utilities.generatePyQtToolPath( |
683 'pyuic5', ["py3uic5"]) |
686 'pyuic5', ["py3uic5"]) |
|
687 elif self.project.getProjectType() in ["PyQt6"]: |
|
688 self.__uicompiler = Utilities.generatePyQtToolPath( |
|
689 'pyuic6') |
684 elif self.project.getProjectType() in ["E6Plugin"]: |
690 elif self.project.getProjectType() in ["E6Plugin"]: |
685 self.__uicompiler = Utilities.generatePyQtToolPath( |
691 self.__uicompiler = Utilities.generatePyQtToolPath( |
686 'pyuic5', ["py3uic5"]) |
692 'pyuic5', ["py3uic5"]) |
687 elif self.project.getProjectType() == "PySide2": |
693 elif self.project.getProjectType() == "PySide2": |
688 self.__uicompiler = Utilities.generatePySideToolPath( |
694 self.__uicompiler = Utilities.generatePySideToolPath( |
701 return self.__uicompiler |
707 return self.__uicompiler |
702 |
708 |
703 def __readStdout(self): |
709 def __readStdout(self): |
704 """ |
710 """ |
705 Private slot to handle the readyReadStandardOutput signal of the |
711 Private slot to handle the readyReadStandardOutput signal of the |
706 pyuic5/pyside2-uic process. |
712 pyuic5/pyuic6/pyside2-uic process. |
707 """ |
713 """ |
708 if self.compileProc is None: |
714 if self.compileProc is None: |
709 return |
715 return |
710 self.compileProc.setReadChannel(QProcess.StandardOutput) |
716 self.compileProc.setReadChannel(QProcess.StandardOutput) |
711 |
717 |
714 "utf-8", 'replace') |
720 "utf-8", 'replace') |
715 |
721 |
716 def __readStderr(self): |
722 def __readStderr(self): |
717 """ |
723 """ |
718 Private slot to handle the readyReadStandardError signal of the |
724 Private slot to handle the readyReadStandardError signal of the |
719 pyuic5/pyside2-uic process. |
725 pyuic5/pyuic6/pyside2-uic process. |
720 """ |
726 """ |
721 if self.compileProc is None: |
727 if self.compileProc is None: |
722 return |
728 return |
723 |
729 |
724 ioEncoding = Preferences.getSystem("IOEncoding") |
730 ioEncoding = Preferences.getSystem("IOEncoding") |
820 |
826 |
821 if self.project.getProjectType() == "PySide2": |
827 if self.project.getProjectType() == "PySide2": |
822 # PySide2 |
828 # PySide2 |
823 if Preferences.getQt("PySide2FromImports"): |
829 if Preferences.getQt("PySide2FromImports"): |
824 args.append("--from-imports") |
830 args.append("--from-imports") |
|
831 elif self.project.getProjectType() == "PyQt6": |
|
832 # PyQt6 |
|
833 if Preferences.getQt("Pyuic6Execute"): |
|
834 args.append("-x") |
|
835 indentWidth = Preferences.getQt("Pyuic6Indent") |
|
836 if indentWidth != self.Pyuic6IndentDefault: |
|
837 args.append("--indent={0}".format(indentWidth)) |
825 else: |
838 else: |
826 # PyQt5 |
839 # PyQt5 |
827 if Preferences.getQt("PyuicExecute"): |
840 if Preferences.getQt("PyuicExecute"): |
828 args.append("-x") |
841 args.append("-x") |
829 indentWidth = Preferences.getQt("PyuicIndent") |
842 indentWidth = Preferences.getQt("PyuicIndent") |
830 if indentWidth != self.PyuicIndentDefault: |
843 if indentWidth != self.Pyuic5IndentDefault: |
831 args.append("--indent={0}".format(indentWidth)) |
844 args.append("--indent={0}".format(indentWidth)) |
832 if ( |
845 if ( |
833 'uic5' in uicompiler and |
846 'uic5' in uicompiler and |
834 self.project.pdata["UICPARAMS"]["Package"] |
847 self.project.pdata["UICPARAMS"]["Package"] |
835 ): |
848 ): |
985 """ |
998 """ |
986 if self.hooks["compileChangedForms"] is not None: |
999 if self.hooks["compileChangedForms"] is not None: |
987 self.hooks["compileChangedForms"](self.project.pdata["FORMS"]) |
1000 self.hooks["compileChangedForms"](self.project.pdata["FORMS"]) |
988 else: |
1001 else: |
989 if self.project.getProjectType() not in [ |
1002 if self.project.getProjectType() not in [ |
990 "PyQt5", "E6Plugin", "PySide2" |
1003 "PyQt5", "PyQt6", "E6Plugin", "PySide2" |
991 ]: |
1004 ]: |
992 # ignore the request for non Qt GUI projects |
1005 # ignore the request for non Qt GUI projects |
993 return |
1006 return |
994 |
1007 |
995 progress = E5ProgressDialog( |
1008 progress = E5ProgressDialog( |
1059 """ |
1072 """ |
1060 from .UicCompilerOptionsDialog import UicCompilerOptionsDialog |
1073 from .UicCompilerOptionsDialog import UicCompilerOptionsDialog |
1061 |
1074 |
1062 params = self.project.pdata["UICPARAMS"] |
1075 params = self.project.pdata["UICPARAMS"] |
1063 |
1076 |
1064 if self.project.getProjectType() in ["PyQt5", "E6Plugin"]: |
1077 if self.project.getProjectType() in ["PyQt5", "PyQt6", "E6Plugin"]: |
1065 dlg = UicCompilerOptionsDialog(params, self.getUiCompiler()) |
1078 dlg = UicCompilerOptionsDialog(params, self.getUiCompiler()) |
1066 if dlg.exec() == QDialog.Accepted: |
1079 if dlg.exec() == QDialog.Accepted: |
1067 package, suffix, root = dlg.getData() |
1080 package, suffix, root = dlg.getData() |
1068 if package != params["Package"]: |
1081 if package != params["Package"]: |
1069 params["Package"] = package |
1082 params["Package"] = package |