--- a/src/eric7/WebBrowser/WebBrowserSingleApplication.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/WebBrowser/WebBrowserSingleApplication.py Wed Jul 13 14:55:47 2022 +0200 @@ -11,9 +11,7 @@ from PyQt6.QtCore import pyqtSignal -from Toolbox.SingleApplication import ( - SingleApplicationClient, SingleApplicationServer -) +from Toolbox.SingleApplication import SingleApplicationClient, SingleApplicationServer import Globals @@ -24,43 +22,44 @@ SAFile = "eric7_browser" # define the protocol tokens -SALoadUrl = 'LoadUrl' -SANewTab = 'NewTab' -SASearch = 'Search' -SAShutdown = 'Shutdown' +SALoadUrl = "LoadUrl" +SANewTab = "NewTab" +SASearch = "Search" +SAShutdown = "Shutdown" class WebBrowserSingleApplicationServer(SingleApplicationServer): """ Class implementing the single application server embedded within the Web Browser. - + @signal loadUrl(str) emitted to load an URL @signal newTab(str) emitted to load an URL in a new tab @signal search(str) emitted to search for a given word @signal shutdown() emitted to shut down the browser """ + loadUrl = pyqtSignal(str) newTab = pyqtSignal(str) search = pyqtSignal(str) shutdown = pyqtSignal() - + def __init__(self, name=""): """ Constructor - + @param name name to be used by the single application server @type str """ if not name: name = SAFile - + SingleApplicationServer.__init__(self, name) def handleCommand(self, command, arguments): """ Public slot to handle the command sent by the client. - + @param command command sent by the client @type str @param arguments list of command arguments @@ -68,43 +67,43 @@ """ if command == SALoadUrl: self.__saLoadUrl(arguments[0]) - + elif command == SANewTab: self.__saNewTab(arguments[0]) - + elif command == SASearch: self.__saSearch(arguments[0]) - + elif command == SAShutdown: self.__saShutdown() - + def __saLoadUrl(self, url): """ Private method to load an URL in a new tab. - + @param url URL to be loaded @type str """ self.loadUrl.emit(url) - + def __saNewTab(self, url): """ Private method to load an URL . - + @param url URL to be loaded @type str """ self.newTab.emit(url) - + def __saSearch(self, word): """ Private method to search for a given word. - + @param word word to be searched for @type str """ self.search.emit(word) - + def __saShutdown(self): """ Private method to shut down the web browser. @@ -116,22 +115,23 @@ """ Class implementing the single application client of the web browser. """ + def __init__(self, name=""): """ Constructor - + @param name name to be used by the single application server @type str """ if not name: name = SAFile - + SingleApplicationClient.__init__(self, name) - + def processArgs(self, args, disconnect=True): """ Public method to process the command line args passed to the UI. - + @param args list of command line arguments @type list of str @param disconnect flag indicating to disconnect when done @@ -140,9 +140,9 @@ # no args, return if args is None: return - - argChars = ('-', '/') if Globals.isWindowsPlatform() else ('-', ) - + + argChars = ("-", "/") if Globals.isWindowsPlatform() else ("-",) + for arg in args: if arg.startswith("--search="): self.__search(arg.replace("--search=", "")) @@ -153,37 +153,37 @@ elif not arg.startswith(argChars): # it is an URL self.__loadUrl(arg) - + if disconnect: self.disconnect() - + def __loadUrl(self, url): """ Private method to send an URL to be loaded. - + @param url URL to be loaded @type str """ self.sendCommand(SALoadUrl, [url]) - + def __newTab(self, url): """ Private method to send an URL to be loaded in a new tab. - + @param url URL to be loaded @type str """ self.sendCommand(SANewTab, [url]) - + def __search(self, word): """ Private method to send a word to search for. - + @param word to to be searched for @type str """ self.sendCommand(SASearch, [word]) - + def __shutdown(self): """ Private method to signal a shutdown request to the browser.