diff -r e075c8fe07fd -r df7edc29cbfb src/eric7/UI/UserInterface.py --- a/src/eric7/UI/UserInterface.py Tue Oct 31 09:23:05 2023 +0100 +++ b/src/eric7/UI/UserInterface.py Wed Nov 29 14:23:36 2023 +0100 @@ -353,7 +353,7 @@ ) with contextlib.suppress(ImportError, AttributeError): - from eric7.EricWidgets.EricSpellCheckedTextEdit import ( # __IGNORE_WARNING__ + from eric7.EricWidgets.EricSpellCheckedTextEdit import ( # noqa: I101 SpellCheckMixin, ) @@ -579,6 +579,7 @@ # create the toolbar manager object self.toolbarManager = EricToolBarManager(self, self) self.toolbarManager.setMainWindow(self) + self.preferencesChanged.connect(self.toolbarManager.preferencesChanged) # Initialize the tool groups and list of started tools splash.showMessage(self.tr("Initializing Tools...")) @@ -825,9 +826,7 @@ if Preferences.getUI("ShowTemplateViewer"): # Create the template viewer part of the user interface logging.debug("Creating Template Viewer...") - from eric7.Templates.TemplateViewer import ( # __IGNORE_WARNING_I101__ - TemplateViewer, - ) + from eric7.Templates.TemplateViewer import TemplateViewer # noqa: I101 self.templateViewer = TemplateViewer(None, self.viewmanager) else: @@ -837,7 +836,7 @@ if Preferences.getUI("ShowFileBrowser"): # Create the file browser logging.debug("Creating File Browser...") - from .Browser import Browser # __IGNORE_WARNING_I101__ + from .Browser import Browser # noqa: I101 self.browser = Browser() else: @@ -847,7 +846,7 @@ if Preferences.getUI("ShowSymbolsViewer"): # Create the symbols viewer logging.debug("Creating Symbols Viewer...") - from .SymbolsWidget import SymbolsWidget # __IGNORE_WARNING_I101__ + from .SymbolsWidget import SymbolsWidget # noqa: I101 self.symbolsViewer = SymbolsWidget() else: @@ -857,9 +856,7 @@ if Preferences.getUI("ShowCodeDocumentationViewer"): # Create the code documentation viewer logging.debug("Creating Code Documentation Viewer...") - from .CodeDocumentationViewer import ( # __IGNORE_WARNING_I101__ - CodeDocumentationViewer, - ) + from .CodeDocumentationViewer import CodeDocumentationViewer # noqa: I101 self.codeDocumentationViewer = CodeDocumentationViewer(self) else: @@ -869,7 +866,7 @@ if Preferences.getUI("ShowPyPIPackageManager"): # Create the PyPI package manager logging.debug("Creating PyPI Package Manager...") - from eric7.PipInterface.PipPackagesWidget import ( # __IGNORE_WARNING__ + from eric7.PipInterface.PipPackagesWidget import ( # noqa: I101 PipPackagesWidget, ) @@ -881,7 +878,7 @@ if Preferences.getUI("ShowCondaPackageManager"): # Create the conda package manager logging.debug("Creating Conda Package Manager...") - from eric7.CondaInterface.CondaPackagesWidget import ( # __IGNORE_WARNING__ + from eric7.CondaInterface.CondaPackagesWidget import ( # noqa: I101 CondaPackagesWidget, ) @@ -893,9 +890,7 @@ if Preferences.getUI("ShowCooperation"): # Create the chat part of the user interface logging.debug("Creating Chat Widget...") - from eric7.Cooperation.ChatWidget import ( # __IGNORE_WARNING_I101__ - ChatWidget, - ) + from eric7.Cooperation.ChatWidget import ChatWidget # noqa: I101 self.cooperation = ChatWidget(self) else: @@ -905,7 +900,7 @@ if Preferences.getUI("ShowIrc"): # Create the IRC part of the user interface logging.debug("Creating IRC Widget...") - from eric7.Network.IRC.IrcWidget import IrcWidget # __IGNORE_WARNING_I101__ + from eric7.Network.IRC.IrcWidget import IrcWidget # noqa: I101 self.irc = IrcWidget(self) else: @@ -915,7 +910,7 @@ if Preferences.getUI("ShowMicroPython"): # Create the MicroPython part of the user interface logging.debug("Creating MicroPython Widget...") - from eric7.MicroPython.MicroPythonWidget import ( # __IGNORE_WARNING_I101__ + from eric7.MicroPython.MicroPythonWidget import ( # noqa: I101 MicroPythonWidget, ) @@ -927,7 +922,7 @@ if Preferences.getUI("ShowNumbersViewer"): # Create the numbers viewer logging.debug("Creating Numbers Viewer...") - from .NumbersWidget import NumbersWidget # __IGNORE_WARNING_I101__ + from .NumbersWidget import NumbersWidget # noqa: I101 self.numbersViewer = NumbersWidget() else: @@ -955,7 +950,7 @@ self.__replaceFileDialog = None if Preferences.getUI("ShowFindFileWidget"): # Create the find in files widget - from .FindFileWidget import FindFileWidget # __IGNORE_WARNING_I101__ + from .FindFileWidget import FindFileWidget # noqa: I101 self.__findFileWidget = FindFileWidget(self.project, self) self.__findFileWidget.sourceFile.connect(self.viewmanager.openSourceFile) @@ -971,9 +966,7 @@ self.__findLocationDialog = None if Preferences.getUI("ShowFindLocationWidget"): # Create the find location (file) widget - from .FindLocationWidget import ( # __IGNORE_WARNING_I101__ - FindLocationWidget, - ) + from .FindLocationWidget import FindLocationWidget # noqa: I101 self.__findLocationWidget = FindLocationWidget(self.project, self) self.__findLocationWidget.sourceFile.connect( @@ -997,9 +990,7 @@ ): # Create the embedded help viewer logging.debug("Creating Internal Help Viewer...") - from eric7.HelpViewer.HelpViewerWidget import ( # __IGNORE_WARNING_I101__ - HelpViewerWidget, - ) + from eric7.HelpViewer.HelpViewerWidget import HelpViewerWidget # noqa: I101 self.__helpViewerWidget = HelpViewerWidget(self) else: @@ -1612,83 +1603,49 @@ """ Public method to process the command line args passed to the UI. - @param args list of files to open<br /> - The args are processed one at a time. All arguments after a - '--' option are considered debug arguments to the program - for the debugger. All files named before the '--' option - are opened in a text editor, unless the argument ends in - .epj or .e4p, then it is opened as a project file. If it - ends in .emj, .e4m or .e5m, it is opened as a multi project. + @param args namespace object containing the parsed command line + parameters + @type argparse.Namespace """ # check and optionally read a crash session and ignore any arguments if self.__readCrashSession(): return - # no args, return - if args is None: - if self.__openAtStartup: - self.__openOnStartup() + if args.dd_args: + # store away any args we had + argsStr = " ".join(args.dd_args) + self.debuggerUI.setArgvHistory(argsStr) + + if args.start_file: + self.__openOnStartup("File") + return + elif args.start_multi: + self.__openOnStartup("MultiProject") + return + elif args.start_project: + self.__openOnStartup("Project") + return + elif args.start_session: + self.__openOnStartup("Session") return opens = 0 - - # holds space delimited list of command args, if any - argsStr = None - # flag indicating '--' options was found - ddseen = False - - argChars = ["-", "/"] if OSUtilities.isWindowsPlatform() else ["-"] - - for arg in args: - # handle a request to start with last session - if arg == "--start-file": - self.__openOnStartup("File") - # ignore all further arguments - return - elif arg == "--start-multi": - self.__openOnStartup("MultiProject") - # ignore all further arguments - return - elif arg == "--start-project": - self.__openOnStartup("Project") - # ignore all further arguments - return - elif arg == "--start-session": - self.__openOnStartup("Session") - # ignore all further arguments - return - - if arg == "--" and not ddseen: - ddseen = True - continue - - if arg[0] in argChars or ddseen: - if argsStr is None: - argsStr = arg - else: - argsStr = "{0} {1}".format(argsStr, arg) - continue - + for filename in args.file_or_project: try: - ext = os.path.splitext(arg)[1] - ext = os.path.normcase(ext) + ext = os.path.normcase(os.path.splitext(filename)[1]) except IndexError: ext = "" if ext in (".epj", ".e4p"): - self.project.openProject(arg) + self.project.openProject(filename) opens += 1 elif ext in (".emj", ".e4m", ".e5m"): - self.multiProject.openMultiProject(arg) + self.multiProject.openMultiProject(filename) opens += 1 else: - self.viewmanager.openFiles(arg) + self.viewmanager.openFiles(filename) opens += 1 - # store away any args we had - if argsStr is not None: - self.debuggerUI.setArgvHistory(argsStr) - if opens == 0 and self.__openAtStartup: # no files, project or multiproject was given self.__openOnStartup() @@ -3780,7 +3737,9 @@ """ self.__menus = {} mb = self.menuBar() - if OSUtilities.isLinuxPlatform() and not Preferences.getUI("UseNativeMenuBar"): + if ( + OSUtilities.isLinuxPlatform() or OSUtilities.isFreeBsdPlatform() + ) and not Preferences.getUI("UseNativeMenuBar"): mb.setNativeMenuBar(False) ############################################################## @@ -6948,6 +6907,8 @@ @return flag indicating a successful launch @rtype bool """ + from eric7.WebBrowser import WebBrowserArgumentsCreator + clientArgs = [] if searchWord: clientArgs.append("--search={0}".format(searchWord)) @@ -6996,7 +6957,8 @@ clientArgs.append("--newtab={0}".format(home)) if clientArgs and self.__webBrowserClient: - self.__webBrowserClient.processArgs(clientArgs, disconnect=False) + args = WebBrowserArgumentsCreator.createArgparseNamespace(clientArgs) + self.__webBrowserClient.processArgs(args, disconnect=False) return True @@ -7056,7 +7018,10 @@ """ Private method to shut down the web browser. """ - self.__webBrowserClient.processArgs(["--shutdown"], disconnect=False) + from eric7.WebBrowser import WebBrowserArgumentsCreator + + args = WebBrowserArgumentsCreator.createArgparseNamespace(["--shutdown"]) + self.__webBrowserClient.processArgs(args, disconnect=False) def __helpViewer(self): """ @@ -7210,7 +7175,7 @@ ) with contextlib.suppress(ImportError, AttributeError): - from eric7.EricWidgets.EricSpellCheckedTextEdit import ( # __IGNORE_WARNING__ + from eric7.EricWidgets.EricSpellCheckedTextEdit import ( # noqa: I101 SpellCheckMixin, ) @@ -7260,7 +7225,7 @@ Preferences.convertPasswords(oldPassword, newPassword) variant = Globals.getWebBrowserSupport() if variant == "QtWebEngine": - from eric7.WebBrowser.Passwords.PasswordManager import ( # __IGNORE_WARNING__ + from eric7.WebBrowser.Passwords.PasswordManager import ( # noqa: I101 PasswordManager, ) @@ -8135,6 +8100,8 @@ self.__astViewer.hide() + self.shell.closeShell() + if not self.project.closeProject(shutdown=True): return False @@ -8158,8 +8125,6 @@ self.__astViewer.shutdown() - self.shell.closeShell() - self.__writeTasks() if self.templateViewer is not None: