eric6/WebBrowser/WebBrowserWindow.py

changeset 7271
2cac5b7abcce
parent 7231
0dcb92a9687d
child 7356
d975331c5daa
--- a/eric6/WebBrowser/WebBrowserWindow.py	Wed Sep 25 19:00:09 2019 +0200
+++ b/eric6/WebBrowser/WebBrowserWindow.py	Wed Sep 25 19:11:13 2019 +0200
@@ -12,14 +12,19 @@
 import shutil
 import sys
 
-from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, \
-    QUrl, QTextCodec, QProcess, QEvent, QFileInfo
+from PyQt5.QtCore import (
+    pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, QUrl, QTextCodec,
+    QProcess, QEvent, QFileInfo
+)
 from PyQt5.QtGui import QDesktopServices, QKeySequence, QFont, QFontMetrics
-from PyQt5.QtWidgets import QWidget, QVBoxLayout, QSizePolicy, QDockWidget, \
-    QComboBox, QLabel, QMenu, QLineEdit, QApplication, \
-    QWhatsThis, QDialog, QHBoxLayout, QProgressBar, QInputDialog, QAction
-from PyQt5.QtWebEngineWidgets import QWebEngineSettings, QWebEnginePage, \
-    QWebEngineProfile, QWebEngineScript
+from PyQt5.QtWidgets import (
+    QWidget, QVBoxLayout, QSizePolicy, QDockWidget, QComboBox, QLabel, QMenu,
+    QLineEdit, QApplication, QWhatsThis, QDialog, QHBoxLayout, QProgressBar,
+    QInputDialog, QAction
+)
+from PyQt5.QtWebEngineWidgets import (
+    QWebEngineSettings, QWebEnginePage, QWebEngineProfile, QWebEngineScript
+)
 try:
     from PyQt5.QtHelp import QHelpEngine, QHelpEngineCore, QHelpSearchQuery
     QTHELP_AVAILABLE = True
@@ -162,10 +167,12 @@
         self.__eventMouseButtons = Qt.NoButton
         self.__eventKeyboardModifiers = Qt.NoModifier
         
-        if qVersionTuple() < (5, 11, 0) and \
-           Preferences.getWebBrowser("WebInspectorEnabled"):
-            os.environ["QTWEBENGINE_REMOTE_DEBUGGING"] = \
-                str(Preferences.getWebBrowser("WebInspectorPort"))
+        if (
+            qVersionTuple() < (5, 11, 0) and
+            Preferences.getWebBrowser("WebInspectorEnabled")
+        ):
+            os.environ["QTWEBENGINE_REMOTE_DEBUGGING"] = str(
+                Preferences.getWebBrowser("WebInspectorPort"))
         
         WebBrowserWindow.setUseQtHelp(qthelp or bool(searchWord))
         
@@ -287,8 +294,7 @@
             self.addDockWidget(Qt.LeftDockWidgetArea, self.__searchDock)
         
         # JavaScript Console window
-        from .WebBrowserJavaScriptConsole import \
-            WebBrowserJavaScriptConsole
+        from .WebBrowserJavaScriptConsole import WebBrowserJavaScriptConsole
         self.__javascriptConsole = WebBrowserJavaScriptConsole(self)
         self.__javascriptConsoleDock = QDockWidget(
             self.tr("JavaScript Console"))
@@ -344,21 +350,23 @@
         syncMgr.syncError.connect(self.statusBar().showMessage)
         
         restoreSessionData = {}
-        if WebBrowserWindow._performingStartup and not home and \
-                not WebBrowserWindow.isPrivate():
+        if (
+            WebBrowserWindow._performingStartup and
+            not home and
+            not WebBrowserWindow.isPrivate()
+        ):
             startupBehavior = Preferences.getWebBrowser("StartupBehavior")
             if not private and startupBehavior in [3, 4]:
                 if startupBehavior == 3:
                     # restore last session
-                    restoreSessionFile = \
+                    restoreSessionFile = (
                         self.sessionManager().lastActiveSessionFile()
+                    )
                 elif startupBehavior == 4:
                     # select session
-                    restoreSessionFile = \
-                        self.sessionManager().selectSession()
-                sessionData = \
-                    self.sessionManager().readSessionFromFile(
-                        restoreSessionFile)
+                    restoreSessionFile = self.sessionManager().selectSession()
+                sessionData = self.sessionManager().readSessionFromFile(
+                    restoreSessionFile)
                 if self.sessionManager().isValidSession(sessionData):
                     restoreSessionData = sessionData
                     restoreSession = True
@@ -1859,8 +1867,10 @@
             self.__virusTotalDomainReport)
         self.__actions.append(self.virustotalDomainReportAct)
         
-        if not Preferences.getWebBrowser("VirusTotalEnabled") or \
-           Preferences.getWebBrowser("VirusTotalServiceKey") == "":
+        if (
+            not Preferences.getWebBrowser("VirusTotalEnabled") or
+            Preferences.getWebBrowser("VirusTotalServiceKey") == ""
+        ):
             self.virustotalScanCurrentAct.setEnabled(False)
             self.virustotalIpReportAct.setEnabled(False)
             self.virustotalDomainReportAct.setEnabled(False)
@@ -2506,8 +2516,10 @@
         if linkName:
             args.append(linkName)
         
-        if not os.path.isfile(applPath) or \
-                not QProcess.startDetached(sys.executable, args):
+        if (
+            not os.path.isfile(applPath) or
+            not QProcess.startDetached(sys.executable, args)
+        ):
             E5MessageBox.critical(
                 self,
                 self.tr('New Private Window'),
@@ -2579,8 +2591,9 @@
         """
         Private slot to show the about information.
         """
-        chromeVersion, webengineVersion = \
+        chromeVersion, webengineVersion = (
             WebBrowserTools.getWebEngineVersions()
+        )
         E5MessageBox.about(
             self,
             self.tr("eric6 Web Browser"),
@@ -2801,9 +2814,11 @@
         
         self.__isClosing = True
         
-        if not WebBrowserWindow._performingShutdown and \
-            len(WebBrowserWindow.BrowserWindows) == 1 and \
-                not WebBrowserWindow.isPrivate():
+        if (
+            not WebBrowserWindow._performingShutdown and
+            len(WebBrowserWindow.BrowserWindows) == 1 and
+            not WebBrowserWindow.isPrivate()
+        ):
             # shut down the session manager in case the last window is
             # about to be closed
             self.sessionManager().shutdown()
@@ -2856,8 +2871,10 @@
             pass
         
         Preferences.syncPreferences()
-        if not WebBrowserWindow._performingShutdown and \
-                len(WebBrowserWindow.BrowserWindows) == 0:
+        if (
+            not WebBrowserWindow._performingShutdown and
+            len(WebBrowserWindow.BrowserWindows) == 0
+        ):
             # shut down the browser in case the last window was
             # simply closed
             self.shutdown()
@@ -2905,8 +2922,10 @@
         if not self.__shallShutDown():
             return False
         
-        if WebBrowserWindow._downloadManager is not None and \
-                not self.downloadManager().allowQuit():
+        if (
+            WebBrowserWindow._downloadManager is not None and
+            not self.downloadManager().allowQuit()
+        ):
             return False
         
         WebBrowserWindow._performingShutdown = True
@@ -3251,8 +3270,10 @@
             pass
         
         self.__virusTotal.preferencesChanged()
-        if not Preferences.getWebBrowser("VirusTotalEnabled") or \
-           Preferences.getWebBrowser("VirusTotalServiceKey") == "":
+        if (
+            not Preferences.getWebBrowser("VirusTotalEnabled") or
+            Preferences.getWebBrowser("VirusTotalServiceKey") == ""
+        ):
             self.virustotalScanCurrentAct.setEnabled(False)
             self.virustotalIpReportAct.setEnabled(False)
             self.virustotalDomainReportAct.setEnabled(False)
@@ -3297,8 +3318,9 @@
         """
         Private slot to configure the cookies handling.
         """
-        from .CookieJar.CookiesConfigurationDialog import \
+        from .CookieJar.CookiesConfigurationDialog import (
             CookiesConfigurationDialog
+        )
         dlg = CookiesConfigurationDialog(self)
         dlg.exec_()
     
@@ -3492,8 +3514,9 @@
         Private slot to manage the QtHelp documentation database.
         """
         if WebBrowserWindow._useQtHelp:
-            from .QtHelp.QtHelpDocumentationDialog import \
+            from .QtHelp.QtHelpDocumentationDialog import (
                 QtHelpDocumentationDialog
+            )
             dlg = QtHelpDocumentationDialog(self.__helpEngine, self)
             dlg.exec_()
             if dlg.hasDocumentationChanges():
@@ -3551,8 +3574,11 @@
         """
         Private slot to search for a word.
         """
-        if WebBrowserWindow._useQtHelp and not self.__indexing and \
-                self.__searchWord is not None:
+        if (
+            WebBrowserWindow._useQtHelp and
+            not self.__indexing and
+            self.__searchWord is not None
+        ):
             self.__searchDock.show()
             self.__searchDock.raise_()
             query = QHelpSearchQuery(QHelpSearchQuery.DEFAULT,
@@ -3655,8 +3681,9 @@
         """
         Private slot to clear the private data.
         """
-        from .WebBrowserClearPrivateDataDialog import \
+        from .WebBrowserClearPrivateDataDialog import (
             WebBrowserClearPrivateDataDialog
+        )
         dlg = WebBrowserClearPrivateDataDialog(self)
         if dlg.exec_() == QDialog.Accepted:
             # browsing history, search history, favicons, disk cache, cookies,
@@ -3949,9 +3976,10 @@
             (PersonalInformationManager)
         """
         if cls._personalInformationManager is None:
-            from .PersonalInformationManager.PersonalInformationManager \
-                import PersonalInformationManager
-            cls._personalInformationManager = PersonalInformationManager()
+            from .PersonalInformationManager import PersonalInformationManager
+            cls._personalInformationManager = (
+                PersonalInformationManager.PersonalInformationManager()
+            )
         
         return cls._personalInformationManager
         
@@ -3977,8 +4005,9 @@
         @rtype FeaturePermissionManager
         """
         if cls._featurePermissionManager is None:
-            from .FeaturePermissions.FeaturePermissionManager import \
+            from .FeaturePermissions.FeaturePermissionManager import (
                 FeaturePermissionManager
+            )
             cls._featurePermissionManager = FeaturePermissionManager()
         
         return cls._featurePermissionManager
@@ -3992,8 +4021,9 @@
         @rtype FlashCookieManager
         """
         if cls._flashCookieManager is None:
-            from .FlashCookieManager.FlashCookieManager import \
+            from .FlashCookieManager.FlashCookieManager import (
                 FlashCookieManager
+            )
             cls._flashCookieManager = FlashCookieManager()
         
         return cls._flashCookieManager
@@ -4007,8 +4037,9 @@
         @rtype ImageSearchEngine
         """
         if cls._imageSearchEngine is None:
-            from .ImageSearch.ImageSearchEngine import \
+            from .ImageSearch.ImageSearchEngine import (
                 ImageSearchEngine
+            )
             cls._imageSearchEngine = ImageSearchEngine()
         
         return cls._imageSearchEngine
@@ -4139,8 +4170,7 @@
         @type QMenu
         """
         if codecNames:
-            defaultCodec = \
-                self.webSettings().defaultTextEncoding().lower()
+            defaultCodec = self.webSettings().defaultTextEncoding().lower()
             
             menu = QMenu(title, parentMenu)
             for codec in codecNames:
@@ -4560,8 +4590,10 @@
         @rtype bool
         """
         if evt.type() == QEvent.WindowStateChange:
-            if not bool(evt.oldState() & Qt.WindowFullScreen) and \
-               bool(self.windowState() & Qt.WindowFullScreen):
+            if (
+                not bool(evt.oldState() & Qt.WindowFullScreen) and
+                bool(self.windowState() & Qt.WindowFullScreen)
+            ):
                 # enter full screen mode
                 self.__windowStates = evt.oldState()
                 self.__toolbarStates = self.saveState()
@@ -4576,8 +4608,10 @@
                 self.__navigationBar.exitFullScreenButton().setVisible(True)
                 self.__navigationContainer.hide()
             
-            elif bool(evt.oldState() & Qt.WindowFullScreen) and \
-                    not bool(self.windowState() & Qt.WindowFullScreen):
+            elif (
+                bool(evt.oldState() & Qt.WindowFullScreen) and
+                not bool(self.windowState() & Qt.WindowFullScreen)
+            ):
                 # leave full screen mode
                 self.setWindowState(self.__windowStates)
                 self.__htmlFullScreen = False
@@ -4697,8 +4731,10 @@
         name = "_eric_userstylesheet"
         userStyle = ""
         
-        userStyle += WebBrowserTools.readAllFileContents(styleSheetFile)\
+        userStyle += (
+            WebBrowserTools.readAllFileContents(styleSheetFile)
             .replace("\n", "")
+        )
         
         oldScript = self.webProfile().scripts().findScript(name)
         if not oldScript.isNull():

eric ide

mercurial