diff -r 866adc8c315b -r 0acf98cd089a eric6/Project/ProjectFormsBrowser.py --- a/eric6/Project/ProjectFormsBrowser.py Sun Jan 17 13:53:08 2021 +0100 +++ b/eric6/Project/ProjectFormsBrowser.py Mon Feb 01 10:38:16 2021 +0100 @@ -25,6 +25,8 @@ from .ProjectBaseBrowser import ProjectBaseBrowser import UI.PixmapCache +from UI.NotificationWidget import NotificationTypes + import Preferences import Utilities @@ -49,7 +51,8 @@ showMenu = pyqtSignal(str, QMenu) menusAboutToBeCreated = pyqtSignal() - PyuicIndentDefault = 4 + Pyuic5IndentDefault = 4 + Pyuic6IndentDefault = 4 def __init__(self, project, parent=None): """ @@ -123,8 +126,10 @@ self.menusAboutToBeCreated.emit() + projectType = self.project.getProjectType() + self.menu = QMenu(self) - if self.project.getProjectType() in ["PyQt5", "E6Plugin", "PySide2"]: + if projectType in ["PyQt5", "PyQt6", "E6Plugin", "PySide2", "PySide6"]: self.menu.addAction( self.tr('Compile form'), self.__compileForm) self.menu.addAction( @@ -184,7 +189,7 @@ act = self.menu.addAction(self.tr('Delete'), self.__deleteFile) self.menuActions.append(act) self.menu.addSeparator() - if self.project.getProjectType() in ["PyQt5", "E6Plugin", "PySide2"]: + if projectType in ["PyQt5", "PyQt6", "E6Plugin", "PySide2", "PySide6"]: self.menu.addAction(self.tr('New form...'), self.__newForm) else: if self.hooks["newForm"] is not None: @@ -207,10 +212,9 @@ self.backMenu = QMenu(self) if ( - self.project.getProjectType() in [ - "PyQt5", "E6Plugin", "PySide2" - ] or - self.hooks["compileAllForms"] is not None + projectType in [ + "PyQt5", "PyQt6", "E6Plugin", "PySide2", "PySide6" + ] or self.hooks["compileAllForms"] is not None ): self.backMenu.addAction( self.tr('Compile all forms'), self.__compileAllForms) @@ -240,7 +244,7 @@ # create the menu for multiple selected files self.multiMenu = QMenu(self) - if self.project.getProjectType() in ["PyQt5", "E6Plugin", "PySide2"]: + if projectType in ["PyQt5", "PyQt6", "E6Plugin", "PySide2", "PySide6"]: self.multiMenu.addAction( self.tr('Compile forms'), self.__compileSelectedForms) self.multiMenu.addSeparator() @@ -285,7 +289,7 @@ self.multiMenu.addAction(self.tr('Configure...'), self._configure) self.dirMenu = QMenu(self) - if self.project.getProjectType() in ["PyQt5", "E6Plugin", "PySide2"]: + if projectType in ["PyQt5", "PyQt6", "E6Plugin", "PySide2", "PySide6"]: self.dirMenu.addAction( self.tr('Compile all forms'), self.__compileAllForms) self.dirMenu.addSeparator() @@ -308,7 +312,7 @@ self.tr('Delete'), self._deleteDirectory) self.dirMenuActions.append(act) self.dirMenu.addSeparator() - if self.project.getProjectType() in ["PyQt5", "E6Plugin", "PySide2"]: + if projectType in ["PyQt5", "PyQt6", "E6Plugin", "PySide2", "PySide6"]: self.dirMenu.addAction(self.tr('New form...'), self.__newForm) else: if self.hooks["newForm"] is not None: @@ -332,7 +336,7 @@ self.dirMenu.addAction(self.tr('Configure...'), self._configure) self.dirMultiMenu = QMenu(self) - if self.project.getProjectType() in ["PyQt5", "E6Plugin", "PySide2"]: + if projectType in ["PyQt5", "PyQt6", "E6Plugin", "PySide2", "PySide6"]: self.dirMultiMenu.addAction( self.tr('Compile all forms'), self.__compileAllForms) self.dirMultiMenu.addSeparator() @@ -377,7 +381,9 @@ if not self.project.isOpen(): return - enable = self.project.getProjectType() in ("PyQt5", "E6Plugin") + enable = ( + self.project.getProjectType() in ("PyQt5", "PyQt6", "E6Plugin") + ) self.__pyuicConfigAct.setEnabled(enable) self.__pyuicMultiConfigAct.setEnabled(enable) self.__pyuicDirConfigAct.setEnabled(enable) @@ -565,7 +571,7 @@ self.hooks["newForm"](path) else: if self.project.getProjectType() in [ - "PyQt5", "E6Plugin", "PySide2" + "PyQt5", "PyQt6", "E6Plugin", "PySide2", "PySide6" ]: self.__newUiForm(path) @@ -681,12 +687,18 @@ if self.project.getProjectType() in ["PyQt5"]: self.__uicompiler = Utilities.generatePyQtToolPath( 'pyuic5', ["py3uic5"]) + elif self.project.getProjectType() in ["PyQt6"]: + self.__uicompiler = Utilities.generatePyQtToolPath( + 'pyuic6') elif self.project.getProjectType() in ["E6Plugin"]: self.__uicompiler = Utilities.generatePyQtToolPath( 'pyuic5', ["py3uic5"]) elif self.project.getProjectType() == "PySide2": self.__uicompiler = Utilities.generatePySideToolPath( - 'pyside2-uic') + 'pyside2-uic', variant=2) + elif self.project.getProjectType() == "PySide6": + self.__uicompiler = Utilities.generatePySideToolPath( + 'pyside6-uic', variant=6) def getUiCompiler(self): """ @@ -703,7 +715,7 @@ def __readStdout(self): """ Private slot to handle the readyReadStandardOutput signal of the - pyuic5/pyside2-uic process. + pyuic5/pyuic6/pyside2-uic/pyside6-uic process. """ if self.compileProc is None: return @@ -716,7 +728,7 @@ def __readStderr(self): """ Private slot to handle the readyReadStandardError signal of the - pyuic5/pyside2-uic process. + pyuic5/pyuic6/pyside2-uic/pyside6-uic process. """ if self.compileProc is None: return @@ -753,45 +765,28 @@ f.write(line + "\n") if self.compiledFile not in self.project.pdata["SOURCES"]: self.project.appendFile(ofn) - if not self.noDialog and not ui.notificationsEnabled(): - E5MessageBox.information( - self, - self.tr("Form Compilation"), - self.tr("The compilation of the form file" - " was successful.")) - else: - ui.showNotification( - UI.PixmapCache.getPixmap("designer48"), - self.tr("Form Compilation"), - self.tr("The compilation of the form file" - " was successful.")) + ui.showNotification( + UI.PixmapCache.getPixmap("designer48"), + self.tr("Form Compilation"), + self.tr("The compilation of the form file" + " was successful.")) self.project.projectFormCompiled.emit(self.compiledFile) except OSError as msg: - if not self.noDialog: - E5MessageBox.information( - self, - self.tr("Form Compilation"), - self.tr( - "<p>The compilation of the form file failed.</p>" - "<p>Reason: {0}</p>").format(str(msg))) - else: - ui.showNotification( - UI.PixmapCache.getPixmap("designer48"), - self.tr("Form Compilation"), - self.tr( - "<p>The compilation of the form file failed.</p>" - "<p>Reason: {0}</p>").format(str(msg))) - else: - if not self.noDialog: - E5MessageBox.information( - self, - self.tr("Form Compilation"), - self.tr("The compilation of the form file failed.")) - else: ui.showNotification( UI.PixmapCache.getPixmap("designer48"), self.tr("Form Compilation"), - self.tr("The compilation of the form file failed.")) + self.tr( + "<p>The compilation of the form file failed.</p>" + "<p>Reason: {0}</p>").format(str(msg)), + kind=NotificationTypes.Critical, + timeout=0) + else: + ui.showNotification( + UI.PixmapCache.getPixmap("designer48"), + self.tr("Form Compilation"), + self.tr("The compilation of the form file failed."), + kind=NotificationTypes.Critical, + timeout=0) self.compileProc = None def __compileUI(self, fn, noDialog=False, progress=None): @@ -822,12 +817,23 @@ # PySide2 if Preferences.getQt("PySide2FromImports"): args.append("--from-imports") + elif self.project.getProjectType() == "PySide6": + # PySide6 + if Preferences.getQt("PySide6FromImports"): + args.append("--from-imports") + elif self.project.getProjectType() == "PyQt6": + # PyQt6 + if Preferences.getQt("Pyuic6Execute"): + args.append("-x") + indentWidth = Preferences.getQt("Pyuic6Indent") + if indentWidth != self.Pyuic6IndentDefault: + args.append("--indent={0}".format(indentWidth)) else: # PyQt5 if Preferences.getQt("PyuicExecute"): args.append("-x") indentWidth = Preferences.getQt("PyuicIndent") - if indentWidth != self.PyuicIndentDefault: + if indentWidth != self.Pyuic5IndentDefault: args.append("--indent={0}".format(indentWidth)) if ( 'uic5' in uicompiler and @@ -987,7 +993,7 @@ self.hooks["compileChangedForms"](self.project.pdata["FORMS"]) else: if self.project.getProjectType() not in [ - "PyQt5", "E6Plugin", "PySide2" + "PyQt5", "PyQt6", "E6Plugin", "PySide2", "PySide6" ]: # ignore the request for non Qt GUI projects return @@ -1061,7 +1067,7 @@ params = self.project.pdata["UICPARAMS"] - if self.project.getProjectType() in ["PyQt5", "E6Plugin"]: + if self.project.getProjectType() in ["PyQt5", "PyQt6", "E6Plugin"]: dlg = UicCompilerOptionsDialog(params, self.getUiCompiler()) if dlg.exec() == QDialog.Accepted: package, suffix, root = dlg.getData()