"Fossies" - the Fresh Open Source Software Archive

Member "eric6-20.9/eric/eric6/WebBrowser/WebBrowserWindow.py" (2 May 2020, 193436 Bytes) of package /linux/misc/eric6-20.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "WebBrowserWindow.py" see the Fossies "Dox" file reference documentation.

    1 # -*- coding: utf-8 -*-
    2 
    3 # Copyright (c) 2002 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
    4 #
    5 
    6 """
    7 Module implementing the web browser main window.
    8 """
    9 
   10 
   11 import os
   12 import shutil
   13 import sys
   14 
   15 from PyQt5.QtCore import (
   16     pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, QUrl, QTextCodec,
   17     QProcess, QEvent, QFileInfo
   18 )
   19 from PyQt5.QtGui import QDesktopServices, QKeySequence, QFont, QFontMetrics
   20 from PyQt5.QtWidgets import (
   21     QWidget, QVBoxLayout, QSizePolicy, QDockWidget, QComboBox, QLabel, QMenu,
   22     QLineEdit, QApplication, QWhatsThis, QDialog, QHBoxLayout, QProgressBar,
   23     QInputDialog, QAction
   24 )
   25 from PyQt5.QtWebEngineWidgets import (
   26     QWebEngineSettings, QWebEnginePage, QWebEngineProfile, QWebEngineScript
   27 )
   28 try:
   29     from PyQt5.QtHelp import QHelpEngine, QHelpEngineCore, QHelpSearchQuery
   30     QTHELP_AVAILABLE = True
   31 except ImportError:
   32     QTHELP_AVAILABLE = False
   33 
   34 from E5Gui.E5Action import E5Action
   35 from E5Gui import E5MessageBox, E5FileDialog, E5ErrorMessage
   36 from E5Gui.E5MainWindow import E5MainWindow
   37 from E5Gui.E5Application import e5App
   38 from E5Gui.E5ZoomWidget import E5ZoomWidget
   39 
   40 from E5Network.E5NetworkIcon import E5NetworkIcon
   41 
   42 import Preferences
   43 from Preferences import Shortcuts
   44 
   45 import Utilities
   46 import Globals
   47 from Globals import qVersionTuple
   48 
   49 import UI.PixmapCache
   50 import UI.Config
   51 from UI.Info import Version
   52 
   53 from .data import icons_rc          # __IGNORE_WARNING__
   54 from .data import html_rc           # __IGNORE_WARNING__
   55 from .data import javascript_rc     # __IGNORE_WARNING__
   56 
   57 
   58 from .Tools import Scripts, WebBrowserTools, WebIconProvider
   59 
   60 from .ZoomManager import ZoomManager
   61 
   62 from .WebBrowserSingleApplication import WebBrowserSingleApplicationServer
   63 
   64 from eric6config import getConfig
   65 
   66 
   67 class WebBrowserWindow(E5MainWindow):
   68     """
   69     Class implementing the web browser main window.
   70     
   71     @signal webBrowserWindowOpened(window) emitted after a new web browser
   72         window was opened
   73     @signal webBrowserWindowClosed(window) emitted after the window was
   74         requested to close
   75     @signal webBrowserOpened(browser) emitted after a new web browser tab was
   76         created
   77     @signal webBrowserClosed(browser) emitted after a web browser tab was
   78         closed
   79     """
   80     webBrowserWindowClosed = pyqtSignal(E5MainWindow)
   81     webBrowserWindowOpened = pyqtSignal(E5MainWindow)
   82     webBrowserOpened = pyqtSignal(QWidget)
   83     webBrowserClosed = pyqtSignal(QWidget)
   84     
   85     BrowserWindows = []
   86 
   87     _useQtHelp = QTHELP_AVAILABLE
   88     _isPrivate = False
   89     
   90     _webProfile = None
   91     _networkManager = None
   92     _cookieJar = None
   93     _helpEngine = None
   94     _bookmarksManager = None
   95     _historyManager = None
   96     _passwordManager = None
   97     _adblockManager = None
   98     _downloadManager = None
   99     _feedsManager = None
  100     _userAgentsManager = None
  101     _syncManager = None
  102     _speedDial = None
  103     _personalInformationManager = None
  104     _greaseMonkeyManager = None
  105     _notification = None
  106     _featurePermissionManager = None
  107     _flashCookieManager = None
  108     _imageSearchEngine = None
  109     _autoScroller = None
  110     _tabManager = None
  111     _sessionManager = None
  112     _safeBrowsingManager = None
  113     _protocolHandlerManager = None
  114     
  115     _performingStartup = True
  116     _performingShutdown = False
  117     _lastActiveWindow = None
  118     
  119     def __init__(self, home, path, parent, name,
  120                  searchWord=None, private=False, qthelp=False, settingsDir="",
  121                  restoreSession=False, single=False, saname=""):
  122         """
  123         Constructor
  124         
  125         @param home the URL to be shown
  126         @type str
  127         @param path the path of the working dir (usually '.')
  128         @type str
  129         @param parent parent widget of this window
  130         @type QWidget
  131         @param name name of this window
  132         @type str
  133         @param searchWord word to search for
  134         @type str
  135         @param private flag indicating a private browsing window
  136         @type bool
  137         @param qthelp flag indicating to enable the QtHelp support
  138         @type bool
  139         @param settingsDir directory to be used for the settings files
  140         @type str
  141         @param restoreSession flag indicating a restore session action
  142         @type bool
  143         @param single flag indicating to start in single application mode
  144         @type bool
  145         @param saname name to be used for the single application server
  146         @type str
  147         """
  148         self.__hideNavigationTimer = None
  149         
  150         super(WebBrowserWindow, self).__init__(parent)
  151         self.setObjectName(name)
  152         if private:
  153             self.setWindowTitle(self.tr("eric6 Web Browser (Private Mode)"))
  154         else:
  155             self.setWindowTitle(self.tr("eric6 Web Browser"))
  156         
  157         self.__settingsDir = settingsDir
  158         self.setWindowIcon(UI.PixmapCache.getIcon("ericWeb"))
  159 
  160         self.__mHistory = []
  161         self.__lastConfigurationPageName = ""
  162         
  163         WebBrowserWindow._isPrivate = private
  164         
  165         self.__shortcutsDialog = None
  166         
  167         self.__eventMouseButtons = Qt.NoButton
  168         self.__eventKeyboardModifiers = Qt.NoModifier
  169         
  170         if (
  171             qVersionTuple() < (5, 11, 0) and
  172             Preferences.getWebBrowser("WebInspectorEnabled")
  173         ):
  174             os.environ["QTWEBENGINE_REMOTE_DEBUGGING"] = str(
  175                 Preferences.getWebBrowser("WebInspectorPort"))
  176         
  177         WebBrowserWindow.setUseQtHelp(qthelp or bool(searchWord))
  178         
  179         self.webProfile(private)
  180         self.networkManager()
  181         
  182         self.__htmlFullScreen = False
  183         self.__windowStates = Qt.WindowNoState
  184         self.__isClosing = False
  185         
  186         from .SearchWidget import SearchWidget
  187         from .QtHelp.HelpTocWidget import HelpTocWidget
  188         from .QtHelp.HelpIndexWidget import HelpIndexWidget
  189         from .QtHelp.HelpSearchWidget import HelpSearchWidget
  190         from .WebBrowserView import WebBrowserView
  191         from .WebBrowserTabWidget import WebBrowserTabWidget
  192         from .AdBlock.AdBlockIcon import AdBlockIcon
  193         from .StatusBar.JavaScriptIcon import JavaScriptIcon
  194         from .StatusBar.ImagesIcon import ImagesIcon
  195         from .VirusTotal.VirusTotalApi import VirusTotalAPI
  196         from .Navigation.NavigationBar import NavigationBar
  197         from .Navigation.NavigationContainer import NavigationContainer
  198         from .Bookmarks.BookmarksToolBar import BookmarksToolBar
  199         
  200         self.setStyle(Preferences.getUI("Style"),
  201                       Preferences.getUI("StyleSheet"))
  202         
  203         # initialize some SSL stuff
  204         from E5Network.E5SslUtilities import initSSL
  205         initSSL()
  206         
  207         if WebBrowserWindow._useQtHelp:
  208             self.__helpEngine = QHelpEngine(
  209                 WebBrowserWindow.getQtHelpCollectionFileName(),
  210                 self)
  211             self.__removeOldDocumentation()
  212             self.__helpEngine.warning.connect(self.__warning)
  213         else:
  214             self.__helpEngine = None
  215         self.__helpInstaller = None
  216         
  217         self.__zoomWidget = E5ZoomWidget(
  218             UI.PixmapCache.getPixmap("zoomOut"),
  219             UI.PixmapCache.getPixmap("zoomIn"),
  220             UI.PixmapCache.getPixmap("zoomReset"), self)
  221         self.statusBar().addPermanentWidget(self.__zoomWidget)
  222         self.__zoomWidget.setMapping(
  223             WebBrowserView.ZoomLevels, WebBrowserView.ZoomLevelDefault)
  224         self.__zoomWidget.valueChanged.connect(self.__zoomValueChanged)
  225         
  226         self.__tabWidget = WebBrowserTabWidget(self)
  227         self.__tabWidget.currentChanged[int].connect(self.__currentChanged)
  228         self.__tabWidget.titleChanged.connect(self.__titleChanged)
  229         self.__tabWidget.showMessage.connect(self.statusBar().showMessage)
  230         self.__tabWidget.browserZoomValueChanged.connect(
  231             self.__zoomWidget.setValue)
  232         self.__tabWidget.browserClosed.connect(self.webBrowserClosed)
  233         self.__tabWidget.browserOpened.connect(self.webBrowserOpened)
  234         
  235         self.__searchWidget = SearchWidget(self, self)
  236         
  237         self.__setIconDatabasePath()
  238         
  239         bookmarksModel = self.bookmarksManager().bookmarksModel()
  240         self.__bookmarksToolBar = BookmarksToolBar(self, bookmarksModel,
  241                                                    self)
  242         self.__bookmarksToolBar.setIconSize(UI.Config.ToolBarIconSize)
  243         self.__bookmarksToolBar.openUrl.connect(self.openUrl)
  244         self.__bookmarksToolBar.newTab.connect(self.openUrlNewTab)
  245         self.__bookmarksToolBar.newWindow.connect(self.openUrlNewWindow)
  246         
  247         self.__navigationBar = NavigationBar(self)
  248         
  249         self.__navigationContainer = NavigationContainer(self)
  250         self.__navigationContainer.addWidget(self.__navigationBar)
  251         self.__navigationContainer.addWidget(self.__bookmarksToolBar)
  252         
  253         centralWidget = QWidget()
  254         layout = QVBoxLayout()
  255         layout.setContentsMargins(1, 1, 1, 1)
  256         layout.setSpacing(0)
  257         layout.addWidget(self.__navigationContainer)
  258         layout.addWidget(self.__tabWidget)
  259         layout.addWidget(self.__searchWidget)
  260         self.__tabWidget.setSizePolicy(
  261             QSizePolicy.Preferred, QSizePolicy.Expanding)
  262         centralWidget.setLayout(layout)
  263         self.setCentralWidget(centralWidget)
  264         self.__searchWidget.hide()
  265         
  266         if WebBrowserWindow._useQtHelp:
  267             # setup the TOC widget
  268             self.__tocWindow = HelpTocWidget(self.__helpEngine)
  269             self.__tocDock = QDockWidget(self.tr("Contents"), self)
  270             self.__tocDock.setObjectName("TocWindow")
  271             self.__tocDock.setWidget(self.__tocWindow)
  272             self.addDockWidget(Qt.LeftDockWidgetArea, self.__tocDock)
  273             
  274             # setup the index widget
  275             self.__indexWindow = HelpIndexWidget(self.__helpEngine)
  276             self.__indexDock = QDockWidget(self.tr("Index"), self)
  277             self.__indexDock.setObjectName("IndexWindow")
  278             self.__indexDock.setWidget(self.__indexWindow)
  279             self.addDockWidget(Qt.LeftDockWidgetArea, self.__indexDock)
  280             
  281             # setup the search widget
  282             self.__searchWord = searchWord
  283             self.__indexing = False
  284             self.__indexingProgress = None
  285             self.__searchEngine = self.__helpEngine.searchEngine()
  286             self.__searchEngine.indexingStarted.connect(
  287                 self.__indexingStarted)
  288             self.__searchEngine.indexingFinished.connect(
  289                 self.__indexingFinished)
  290             self.__searchWindow = HelpSearchWidget(self.__searchEngine)
  291             self.__searchDock = QDockWidget(self.tr("Search"), self)
  292             self.__searchDock.setObjectName("SearchWindow")
  293             self.__searchDock.setWidget(self.__searchWindow)
  294             self.addDockWidget(Qt.LeftDockWidgetArea, self.__searchDock)
  295         
  296         # JavaScript Console window
  297         from .WebBrowserJavaScriptConsole import WebBrowserJavaScriptConsole
  298         self.__javascriptConsole = WebBrowserJavaScriptConsole(self)
  299         self.__javascriptConsoleDock = QDockWidget(
  300             self.tr("JavaScript Console"))
  301         self.__javascriptConsoleDock.setObjectName("JavascriptConsole")
  302         self.__javascriptConsoleDock.setAllowedAreas(
  303             Qt.BottomDockWidgetArea | Qt.TopDockWidgetArea)
  304         self.__javascriptConsoleDock.setWidget(self.__javascriptConsole)
  305         self.addDockWidget(Qt.BottomDockWidgetArea,
  306                            self.__javascriptConsoleDock)
  307         
  308         if Preferences.getWebBrowser("SaveGeometry"):
  309             g = Preferences.getGeometry("WebBrowserGeometry")
  310         else:
  311             g = QByteArray()
  312         if g.isEmpty():
  313             s = QSize(800, 800)
  314             self.resize(s)
  315         else:
  316             self.restoreGeometry(g)
  317         
  318         WebBrowserWindow.BrowserWindows.append(self)
  319         
  320         self.__initWebEngineSettings()
  321         
  322         # initialize some of our class objects
  323         self.passwordManager()
  324         self.historyManager()
  325         self.greaseMonkeyManager()
  326         self.protocolHandlerManager()
  327         
  328         # initialize the actions
  329         self.__initActions()
  330         
  331         # initialize the menus
  332         self.__initMenus()
  333         self.__initSuperMenu()
  334         if Preferences.getWebBrowser("MenuBarVisible"):
  335             self.__navigationBar.superMenuButton().hide()
  336         else:
  337             self.menuBar().hide()
  338         
  339         # save references to toolbars in order to hide them
  340         # when going full screen
  341         self.__toolbars = {}
  342         # initialize toolbars
  343         if Preferences.getWebBrowser("ShowToolbars"):
  344             self.__initToolbars()
  345         self.__bookmarksToolBar.setVisible(
  346             Preferences.getWebBrowser("BookmarksToolBarVisible"))
  347         
  348         syncMgr = self.syncManager()
  349         syncMgr.syncMessage.connect(self.statusBar().showMessage)
  350         syncMgr.syncError.connect(self.statusBar().showMessage)
  351         
  352         restoreSessionData = {}
  353         if (
  354             WebBrowserWindow._performingStartup and
  355             not home and
  356             not WebBrowserWindow.isPrivate()
  357         ):
  358             startupBehavior = Preferences.getWebBrowser("StartupBehavior")
  359             if not private and startupBehavior in [3, 4]:
  360                 if startupBehavior == 3:
  361                     # restore last session
  362                     restoreSessionFile = (
  363                         self.sessionManager().lastActiveSessionFile()
  364                     )
  365                 elif startupBehavior == 4:
  366                     # select session
  367                     restoreSessionFile = self.sessionManager().selectSession()
  368                 sessionData = self.sessionManager().readSessionFromFile(
  369                     restoreSessionFile)
  370                 if self.sessionManager().isValidSession(sessionData):
  371                     restoreSessionData = sessionData
  372                     restoreSession = True
  373             else:
  374                 if Preferences.getWebBrowser("StartupBehavior") == 0:
  375                     home = "about:blank"
  376                 elif Preferences.getWebBrowser("StartupBehavior") == 1:
  377                     home = Preferences.getWebBrowser("HomePage")
  378                 elif Preferences.getWebBrowser("StartupBehavior") == 2:
  379                     home = "eric:speeddial"
  380         
  381         if not restoreSession:
  382             self.__tabWidget.newBrowser(QUrl.fromUserInput(home))
  383             self.__tabWidget.currentBrowser().setFocus()
  384         WebBrowserWindow._performingStartup = False
  385         
  386         self.__imagesIcon = ImagesIcon(self)
  387         self.statusBar().addPermanentWidget(self.__imagesIcon)
  388         self.__javaScriptIcon = JavaScriptIcon(self)
  389         self.statusBar().addPermanentWidget(self.__javaScriptIcon)
  390         
  391         self.__adBlockIcon = AdBlockIcon(self)
  392         self.statusBar().addPermanentWidget(self.__adBlockIcon)
  393         self.__adBlockIcon.setEnabled(
  394             Preferences.getWebBrowser("AdBlockEnabled"))
  395         self.__tabWidget.currentChanged[int].connect(
  396             self.__adBlockIcon.currentChanged)
  397         self.__tabWidget.sourceChanged.connect(
  398             self.__adBlockIcon.sourceChanged)
  399         
  400         self.__tabManagerIcon = self.tabManager().createStatusBarIcon()
  401         self.statusBar().addPermanentWidget(self.__tabManagerIcon)
  402         
  403         self.networkIcon = E5NetworkIcon(self)
  404         self.statusBar().addPermanentWidget(self.networkIcon)
  405         
  406         if not Preferences.getWebBrowser("StatusBarVisible"):
  407             self.statusBar().hide()
  408         
  409         if len(WebBrowserWindow.BrowserWindows):
  410             QDesktopServices.setUrlHandler(
  411                 "http", WebBrowserWindow.BrowserWindows[0].urlHandler)
  412             QDesktopServices.setUrlHandler(
  413                 "https", WebBrowserWindow.BrowserWindows[0].urlHandler)
  414         
  415         # setup connections
  416         self.__activating = False
  417         if WebBrowserWindow._useQtHelp:
  418             # TOC window
  419             self.__tocWindow.escapePressed.connect(
  420                 self.__activateCurrentBrowser)
  421             self.__tocWindow.openUrl.connect(self.openUrl)
  422             self.__tocWindow.newTab.connect(self.openUrlNewTab)
  423             self.__tocWindow.newBackgroundTab.connect(
  424                 self.openUrlNewBackgroundTab)
  425             self.__tocWindow.newWindow.connect(self.openUrlNewWindow)
  426             
  427             # index window
  428             self.__indexWindow.escapePressed.connect(
  429                 self.__activateCurrentBrowser)
  430             self.__indexWindow.openUrl.connect(self.openUrl)
  431             self.__indexWindow.newTab.connect(self.openUrlNewTab)
  432             self.__indexWindow.newBackgroundTab.connect(
  433                 self.openUrlNewBackgroundTab)
  434             self.__indexWindow.newWindow.connect(self.openUrlNewWindow)
  435             
  436             # search window
  437             self.__searchWindow.escapePressed.connect(
  438                 self.__activateCurrentBrowser)
  439             self.__searchWindow.openUrl.connect(self.openUrl)
  440             self.__searchWindow.newTab.connect(self.openUrlNewTab)
  441             self.__searchWindow.newBackgroundTab.connect(
  442                 self.openUrlNewBackgroundTab)
  443             self.__searchWindow.newWindow.connect(self.openUrlNewWindow)
  444         
  445         state = Preferences.getWebBrowser("WebBrowserState")
  446         self.restoreState(state)
  447         
  448         self.__initHelpDb()
  449         
  450         self.__virusTotal = VirusTotalAPI(self)
  451         self.__virusTotal.submitUrlError.connect(
  452             self.__virusTotalSubmitUrlError)
  453         self.__virusTotal.urlScanReport.connect(
  454             self.__virusTotalUrlScanReport)
  455         self.__virusTotal.fileScanReport.connect(
  456             self.__virusTotalFileScanReport)
  457         
  458         self.flashCookieManager()
  459         
  460         e5App().focusChanged.connect(self.__appFocusChanged)
  461         
  462         self.__toolbarStates = self.saveState()
  463         
  464         if single:
  465             self.SAServer = WebBrowserSingleApplicationServer(saname)
  466             self.SAServer.loadUrl.connect(self.__saLoadUrl)
  467             self.SAServer.newTab.connect(self.__saNewTab)
  468             self.SAServer.search.connect(self.__saSearchWord)
  469             self.SAServer.shutdown.connect(self.shutdown)
  470         else:
  471             self.SAServer = None
  472         
  473         self.__hideNavigationTimer = QTimer(self)
  474         self.__hideNavigationTimer.setInterval(1000)
  475         self.__hideNavigationTimer.setSingleShot(True)
  476         self.__hideNavigationTimer.timeout.connect(self.__hideNavigation)
  477         
  478         self.__forcedClose = False
  479         
  480         if restoreSessionData and not WebBrowserWindow.isPrivate():
  481             self.sessionManager().restoreSessionFromData(
  482                 self, restoreSessionData)
  483         
  484         if not WebBrowserWindow.isPrivate():
  485             self.sessionManager().activateTimer()
  486         
  487         QTimer.singleShot(0, syncMgr.loadSettings)
  488         
  489         if WebBrowserWindow._useQtHelp:
  490             QTimer.singleShot(50, self.__lookForNewDocumentation)
  491             if self.__searchWord is not None:
  492                 QTimer.singleShot(0, self.__searchForWord)
  493     
  494     def __del__(self):
  495         """
  496         Special method called during object destruction.
  497         
  498         Note: This empty variant seems to get rid of the Qt message
  499         'Warning: QBasicTimer::start: QBasicTimer can only be used with
  500         threads started with QThread'
  501         """
  502         pass
  503     
  504     def tabWidget(self):
  505         """
  506         Public method to get a reference to the tab widget.
  507         
  508         @return reference to the tab widget
  509         @rtype WebBrowserTabWidget
  510         """
  511         return self.__tabWidget
  512     
  513     def __setIconDatabasePath(self, enable=True):
  514         """
  515         Private method to set the favicons path.
  516         
  517         @param enable flag indicating to enabled icon storage (boolean)
  518         """
  519         if enable:
  520             iconDatabasePath = os.path.join(Utilities.getConfigDir(),
  521                                             "web_browser", "favicons")
  522             if not os.path.exists(iconDatabasePath):
  523                 os.makedirs(iconDatabasePath)
  524         else:
  525             iconDatabasePath = ""   # setting an empty path disables it
  526         
  527         WebIconProvider.instance().setIconDatabasePath(iconDatabasePath)
  528         
  529     def __initWebEngineSettings(self):
  530         """
  531         Private method to set the global web settings.
  532         """
  533         settings = self.webSettings()
  534         
  535         settings.setFontFamily(
  536             QWebEngineSettings.StandardFont,
  537             Preferences.getWebBrowser("StandardFontFamily"))
  538         settings.setFontFamily(
  539             QWebEngineSettings.FixedFont,
  540             Preferences.getWebBrowser("FixedFontFamily"))
  541         settings.setFontFamily(
  542             QWebEngineSettings.SerifFont,
  543             Preferences.getWebBrowser("SerifFontFamily"))
  544         settings.setFontFamily(
  545             QWebEngineSettings.SansSerifFont,
  546             Preferences.getWebBrowser("SansSerifFontFamily"))
  547         settings.setFontFamily(
  548             QWebEngineSettings.CursiveFont,
  549             Preferences.getWebBrowser("CursiveFontFamily"))
  550         settings.setFontFamily(
  551             QWebEngineSettings.FantasyFont,
  552             Preferences.getWebBrowser("FantasyFontFamily"))
  553         
  554         settings.setFontSize(
  555             QWebEngineSettings.DefaultFontSize,
  556             Preferences.getWebBrowser("DefaultFontSize"))
  557         settings.setFontSize(
  558             QWebEngineSettings.DefaultFixedFontSize,
  559             Preferences.getWebBrowser("DefaultFixedFontSize"))
  560         settings.setFontSize(
  561             QWebEngineSettings.MinimumFontSize,
  562             Preferences.getWebBrowser("MinimumFontSize"))
  563         settings.setFontSize(
  564             QWebEngineSettings.MinimumLogicalFontSize,
  565             Preferences.getWebBrowser("MinimumLogicalFontSize"))
  566         
  567         styleSheet = Preferences.getWebBrowser("UserStyleSheet")
  568         self.__setUserStyleSheet(styleSheet)
  569         
  570         settings.setAttribute(
  571             QWebEngineSettings.AutoLoadImages,
  572             Preferences.getWebBrowser("AutoLoadImages"))
  573         settings.setAttribute(
  574             QWebEngineSettings.JavascriptEnabled,
  575             Preferences.getWebBrowser("JavaScriptEnabled"))
  576         # JavaScript is needed for the web browser functionality
  577         settings.setAttribute(
  578             QWebEngineSettings.JavascriptCanOpenWindows,
  579             Preferences.getWebBrowser("JavaScriptCanOpenWindows"))
  580         settings.setAttribute(
  581             QWebEngineSettings.JavascriptCanAccessClipboard,
  582             Preferences.getWebBrowser("JavaScriptCanAccessClipboard"))
  583         settings.setAttribute(
  584             QWebEngineSettings.PluginsEnabled,
  585             Preferences.getWebBrowser("PluginsEnabled"))
  586         
  587         if self.isPrivate():
  588             settings.setAttribute(
  589                 QWebEngineSettings.LocalStorageEnabled, False)
  590         else:
  591             settings.setAttribute(
  592                 QWebEngineSettings.LocalStorageEnabled,
  593                 Preferences.getWebBrowser("LocalStorageEnabled"))
  594         settings.setDefaultTextEncoding(
  595             Preferences.getWebBrowser("DefaultTextEncoding"))
  596         
  597         settings.setAttribute(
  598             QWebEngineSettings.SpatialNavigationEnabled,
  599             Preferences.getWebBrowser("SpatialNavigationEnabled"))
  600         settings.setAttribute(
  601             QWebEngineSettings.LinksIncludedInFocusChain,
  602             Preferences.getWebBrowser("LinksIncludedInFocusChain"))
  603         settings.setAttribute(
  604             QWebEngineSettings.LocalContentCanAccessRemoteUrls,
  605             Preferences.getWebBrowser("LocalContentCanAccessRemoteUrls"))
  606         settings.setAttribute(
  607             QWebEngineSettings.LocalContentCanAccessFileUrls,
  608             Preferences.getWebBrowser("LocalContentCanAccessFileUrls"))
  609         settings.setAttribute(
  610             QWebEngineSettings.XSSAuditingEnabled,
  611             Preferences.getWebBrowser("XSSAuditingEnabled"))
  612         settings.setAttribute(
  613             QWebEngineSettings.ScrollAnimatorEnabled,
  614             Preferences.getWebBrowser("ScrollAnimatorEnabled"))
  615         settings.setAttribute(
  616             QWebEngineSettings.ErrorPageEnabled,
  617             Preferences.getWebBrowser("ErrorPageEnabled"))
  618         settings.setAttribute(
  619             QWebEngineSettings.FullScreenSupportEnabled,
  620             Preferences.getWebBrowser("FullScreenSupportEnabled"))
  621         
  622         try:
  623             # Qt 5.7
  624             settings.setAttribute(
  625                 QWebEngineSettings.ScreenCaptureEnabled,
  626                 Preferences.getWebBrowser("ScreenCaptureEnabled"))
  627             settings.setAttribute(
  628                 QWebEngineSettings.WebGLEnabled,
  629                 Preferences.getWebBrowser("WebGLEnabled"))
  630         except (AttributeError, KeyError):
  631             pass
  632         
  633         try:
  634             # Qt 5.8
  635             settings.setAttribute(
  636                 QWebEngineSettings.FocusOnNavigationEnabled,
  637                 Preferences.getWebBrowser("FocusOnNavigationEnabled"))
  638             settings.setAttribute(
  639                 QWebEngineSettings.PrintElementBackgrounds,
  640                 Preferences.getWebBrowser("PrintElementBackgrounds"))
  641             settings.setAttribute(
  642                 QWebEngineSettings.AllowRunningInsecureContent,
  643                 Preferences.getWebBrowser("AllowRunningInsecureContent"))
  644         except (AttributeError, KeyError):
  645             pass
  646         
  647         try:
  648             # Qt 5.9
  649             settings.setAttribute(
  650                 QWebEngineSettings.AllowGeolocationOnInsecureOrigins,
  651                 Preferences.getWebBrowser("AllowGeolocationOnInsecureOrigins"))
  652         except (AttributeError, KeyError):
  653             pass
  654         
  655         try:
  656             # Qt 5.10
  657             settings.setAttribute(
  658                 QWebEngineSettings.AllowWindowActivationFromJavaScript,
  659                 Preferences.getWebBrowser(
  660                     "AllowWindowActivationFromJavaScript"))
  661             settings.setAttribute(
  662                 QWebEngineSettings.ShowScrollBars,
  663                 Preferences.getWebBrowser("ShowScrollBars"))
  664         except (AttributeError, KeyError):
  665             pass
  666         
  667         try:
  668             # Qt 5.11
  669             settings.setAttribute(
  670                 QWebEngineSettings.PlaybackRequiresUserGesture,
  671                 Preferences.getWebBrowser(
  672                     "PlaybackRequiresUserGesture"))
  673             settings.setAttribute(
  674                 QWebEngineSettings.JavascriptCanPaste,
  675                 Preferences.getWebBrowser(
  676                     "JavaScriptCanPaste"))
  677             settings.setAttribute(
  678                 QWebEngineSettings.WebRTCPublicInterfacesOnly,
  679                 Preferences.getWebBrowser(
  680                     "WebRTCPublicInterfacesOnly"))
  681         except (AttributeError, KeyError):
  682             pass
  683         
  684         try:
  685             # Qt 5.12
  686             settings.setAttribute(
  687                 QWebEngineSettings.DnsPrefetchEnabled,
  688                 Preferences.getWebBrowser(
  689                     "DnsPrefetchEnabled"))
  690         except (AttributeError, KeyError):
  691             pass
  692         
  693         try:
  694             # Qt 5.13
  695             settings.setAttribute(
  696                 QWebEngineSettings.PdfViewerEnabled,
  697                 Preferences.getWebBrowser(
  698                     "PdfViewerEnabled"))
  699         except (AttributeError, KeyError):
  700             pass
  701     
  702     def __initActions(self):
  703         """
  704         Private method to define the user interface actions.
  705         """
  706         # list of all actions
  707         self.__actions = []
  708         
  709         self.newTabAct = E5Action(
  710             self.tr('New Tab'),
  711             UI.PixmapCache.getIcon("tabNew"),
  712             self.tr('&New Tab'),
  713             QKeySequence(self.tr("Ctrl+T", "File|New Tab")),
  714             0, self, 'webbrowser_file_new_tab')
  715         self.newTabAct.setStatusTip(self.tr('Open a new web browser tab'))
  716         self.newTabAct.setWhatsThis(self.tr(
  717             """<b>New Tab</b>"""
  718             """<p>This opens a new web browser tab.</p>"""
  719         ))
  720         self.newTabAct.triggered.connect(self.newTab)
  721         self.__actions.append(self.newTabAct)
  722         
  723         self.newAct = E5Action(
  724             self.tr('New Window'),
  725             UI.PixmapCache.getIcon("newWindow"),
  726             self.tr('New &Window'),
  727             QKeySequence(self.tr("Ctrl+N", "File|New Window")),
  728             0, self, 'webbrowser_file_new_window')
  729         self.newAct.setStatusTip(self.tr('Open a new web browser window'))
  730         self.newAct.setWhatsThis(self.tr(
  731             """<b>New Window</b>"""
  732             """<p>This opens a new web browser window in the current"""
  733             """ privacy mode.</p>"""
  734         ))
  735         self.newAct.triggered.connect(self.newWindow)
  736         self.__actions.append(self.newAct)
  737         
  738         self.newPrivateAct = E5Action(
  739             self.tr('New Private Window'),
  740             UI.PixmapCache.getIcon("privateMode"),
  741             self.tr('New &Private Window'),
  742             QKeySequence(self.tr("Ctrl+Shift+P", "File|New Private Window")),
  743             0, self, 'webbrowser_file_new_private_window')
  744         self.newPrivateAct.setStatusTip(self.tr(
  745             'Open a new private web browser window'))
  746         self.newPrivateAct.setWhatsThis(self.tr(
  747             """<b>New Private Window</b>"""
  748             """<p>This opens a new private web browser window by starting"""
  749             """ a new web browser instance in private mode.</p>"""
  750         ))
  751         self.newPrivateAct.triggered.connect(self.newPrivateWindow)
  752         self.__actions.append(self.newPrivateAct)
  753         
  754         self.openAct = E5Action(
  755             self.tr('Open File'),
  756             UI.PixmapCache.getIcon("open"),
  757             self.tr('&Open File'),
  758             QKeySequence(self.tr("Ctrl+O", "File|Open")),
  759             0, self, 'webbrowser_file_open')
  760         self.openAct.setStatusTip(self.tr('Open a file for display'))
  761         self.openAct.setWhatsThis(self.tr(
  762             """<b>Open File</b>"""
  763             """<p>This opens a new file for display."""
  764             """ It pops up a file selection dialog.</p>"""
  765         ))
  766         self.openAct.triggered.connect(self.__openFile)
  767         self.__actions.append(self.openAct)
  768         
  769         self.openTabAct = E5Action(
  770             self.tr('Open File in New Tab'),
  771             UI.PixmapCache.getIcon("openNewTab"),
  772             self.tr('Open File in New &Tab'),
  773             QKeySequence(self.tr("Shift+Ctrl+O", "File|Open in new tab")),
  774             0, self, 'webbrowser_file_open_tab')
  775         self.openTabAct.setStatusTip(
  776             self.tr('Open a file for display in a new tab'))
  777         self.openTabAct.setWhatsThis(self.tr(
  778             """<b>Open File in New Tab</b>"""
  779             """<p>This opens a new file for display in a new tab."""
  780             """ It pops up a file selection dialog.</p>"""
  781         ))
  782         self.openTabAct.triggered.connect(self.__openFileNewTab)
  783         self.__actions.append(self.openTabAct)
  784         
  785         if hasattr(QWebEnginePage, "SavePage"):
  786             self.saveAsAct = E5Action(
  787                 self.tr('Save As'),
  788                 UI.PixmapCache.getIcon("fileSaveAs"),
  789                 self.tr('&Save As...'),
  790                 QKeySequence(self.tr("Shift+Ctrl+S", "File|Save As")),
  791                 0, self, 'webbrowser_file_save_as')
  792             self.saveAsAct.setStatusTip(
  793                 self.tr('Save the current page to disk'))
  794             self.saveAsAct.setWhatsThis(self.tr(
  795                 """<b>Save As...</b>"""
  796                 """<p>Saves the current page to disk.</p>"""
  797             ))
  798             self.saveAsAct.triggered.connect(self.__savePageAs)
  799             self.__actions.append(self.saveAsAct)
  800         else:
  801             self.saveAsAct = None
  802         
  803         self.saveVisiblePageScreenAct = E5Action(
  804             self.tr('Save Page Screen'),
  805             UI.PixmapCache.getIcon("fileSavePixmap"),
  806             self.tr('Save Page Screen...'),
  807             0, 0, self, 'webbrowser_file_save_visible_page_screen')
  808         self.saveVisiblePageScreenAct.setStatusTip(
  809             self.tr('Save the visible part of the current page as a'
  810                     ' screen shot'))
  811         self.saveVisiblePageScreenAct.setWhatsThis(self.tr(
  812             """<b>Save Page Screen...</b>"""
  813             """<p>Saves the visible part of the current page as a"""
  814             """ screen shot.</p>"""
  815         ))
  816         self.saveVisiblePageScreenAct.triggered.connect(
  817             self.__saveVisiblePageScreen)
  818         self.__actions.append(self.saveVisiblePageScreenAct)
  819         
  820         bookmarksManager = self.bookmarksManager()
  821         self.importBookmarksAct = E5Action(
  822             self.tr('Import Bookmarks'),
  823             self.tr('&Import Bookmarks...'),
  824             0, 0, self, 'webbrowser_file_import_bookmarks')
  825         self.importBookmarksAct.setStatusTip(
  826             self.tr('Import bookmarks from other browsers'))
  827         self.importBookmarksAct.setWhatsThis(self.tr(
  828             """<b>Import Bookmarks</b>"""
  829             """<p>Import bookmarks from other browsers.</p>"""
  830         ))
  831         self.importBookmarksAct.triggered.connect(
  832             bookmarksManager.importBookmarks)
  833         self.__actions.append(self.importBookmarksAct)
  834         
  835         self.exportBookmarksAct = E5Action(
  836             self.tr('Export Bookmarks'),
  837             self.tr('&Export Bookmarks...'),
  838             0, 0, self, 'webbrowser_file_export_bookmarks')
  839         self.exportBookmarksAct.setStatusTip(
  840             self.tr('Export the bookmarks into a file'))
  841         self.exportBookmarksAct.setWhatsThis(self.tr(
  842             """<b>Export Bookmarks</b>"""
  843             """<p>Export the bookmarks into a file.</p>"""
  844         ))
  845         self.exportBookmarksAct.triggered.connect(
  846             bookmarksManager.exportBookmarks)
  847         self.__actions.append(self.exportBookmarksAct)
  848         
  849         self.printAct = E5Action(
  850             self.tr('Print'),
  851             UI.PixmapCache.getIcon("print"),
  852             self.tr('&Print'),
  853             QKeySequence(self.tr("Ctrl+P", "File|Print")),
  854             0, self, 'webbrowser_file_print')
  855         self.printAct.setStatusTip(self.tr('Print the displayed help'))
  856         self.printAct.setWhatsThis(self.tr(
  857             """<b>Print</b>"""
  858             """<p>Print the displayed help text.</p>"""
  859         ))
  860         self.printAct.triggered.connect(self.__tabWidget.printBrowser)
  861         self.__actions.append(self.printAct)
  862         
  863         self.printPdfAct = E5Action(
  864             self.tr('Print as PDF'),
  865             UI.PixmapCache.getIcon("printPdf"),
  866             self.tr('Print as PDF'),
  867             0, 0, self, 'webbrowser_file_print_pdf')
  868         self.printPdfAct.setStatusTip(self.tr(
  869             'Print the displayed help as PDF'))
  870         self.printPdfAct.setWhatsThis(self.tr(
  871             """<b>Print as PDF</b>"""
  872             """<p>Print the displayed help text as a PDF file.</p>"""
  873         ))
  874         self.printPdfAct.triggered.connect(
  875             self.__tabWidget.printBrowserPdf)
  876         self.__actions.append(self.printPdfAct)
  877         
  878         self.printPreviewAct = E5Action(
  879             self.tr('Print Preview'),
  880             UI.PixmapCache.getIcon("printPreview"),
  881             self.tr('Print Preview'),
  882             0, 0, self, 'webbrowser_file_print_preview')
  883         self.printPreviewAct.setStatusTip(self.tr(
  884             'Print preview of the displayed help'))
  885         self.printPreviewAct.setWhatsThis(self.tr(
  886             """<b>Print Preview</b>"""
  887             """<p>Print preview of the displayed help text.</p>"""
  888         ))
  889         self.printPreviewAct.triggered.connect(
  890             self.__tabWidget.printPreviewBrowser)
  891         self.__actions.append(self.printPreviewAct)
  892         
  893         self.sendPageLinkAct = E5Action(
  894             self.tr('Send Page Link'),
  895             UI.PixmapCache.getIcon("mailSend"),
  896             self.tr('Send Page Link'),
  897             0, 0, self, 'webbrowser_send_page_link')
  898         self.sendPageLinkAct.setStatusTip(self.tr(
  899             'Send the link of the current page via email'))
  900         self.sendPageLinkAct.setWhatsThis(self.tr(
  901             """<b>Send Page Link</b>"""
  902             """<p>Send the link of the current page via email.</p>"""
  903         ))
  904         self.sendPageLinkAct.triggered.connect(self.__sendPageLink)
  905         self.__actions.append(self.sendPageLinkAct)
  906         
  907         self.closeAct = E5Action(
  908             self.tr('Close'),
  909             UI.PixmapCache.getIcon("close"),
  910             self.tr('&Close'),
  911             QKeySequence(self.tr("Ctrl+W", "File|Close")),
  912             0, self, 'webbrowser_file_close')
  913         self.closeAct.setStatusTip(self.tr(
  914             'Close the current help window'))
  915         self.closeAct.setWhatsThis(self.tr(
  916             """<b>Close</b>"""
  917             """<p>Closes the current web browser window.</p>"""
  918         ))
  919         self.closeAct.triggered.connect(self.__tabWidget.closeBrowser)
  920         self.__actions.append(self.closeAct)
  921         
  922         self.closeAllAct = E5Action(
  923             self.tr('Close All'),
  924             self.tr('Close &All'),
  925             0, 0, self, 'webbrowser_file_close_all')
  926         self.closeAllAct.setStatusTip(self.tr('Close all help windows'))
  927         self.closeAllAct.setWhatsThis(self.tr(
  928             """<b>Close All</b>"""
  929             """<p>Closes all web browser windows except the first one.</p>"""
  930         ))
  931         self.closeAllAct.triggered.connect(
  932             self.__tabWidget.closeAllBrowsers)
  933         self.__actions.append(self.closeAllAct)
  934         
  935         self.exitAct = E5Action(
  936             self.tr('Quit'),
  937             UI.PixmapCache.getIcon("exit"),
  938             self.tr('&Quit'),
  939             QKeySequence(self.tr("Ctrl+Q", "File|Quit")),
  940             0, self, 'webbrowser_file_quit')
  941         self.exitAct.setStatusTip(self.tr('Quit the eric6 Web Browser'))
  942         self.exitAct.setWhatsThis(self.tr(
  943             """<b>Quit</b>"""
  944             """<p>Quit the eric6 Web Browser.</p>"""
  945         ))
  946         self.exitAct.triggered.connect(self.shutdown)
  947         self.__actions.append(self.exitAct)
  948         
  949         self.backAct = E5Action(
  950             self.tr('Backward'),
  951             UI.PixmapCache.getIcon("back"),
  952             self.tr('&Backward'),
  953             QKeySequence(self.tr("Alt+Left", "Go|Backward")),
  954             0, self, 'webbrowser_go_backward')
  955         self.backAct.setStatusTip(self.tr('Move one screen backward'))
  956         self.backAct.setWhatsThis(self.tr(
  957             """<b>Backward</b>"""
  958             """<p>Moves one screen backward. If none is"""
  959             """ available, this action is disabled.</p>"""
  960         ))
  961         self.backAct.triggered.connect(self.__backward)
  962         self.__actions.append(self.backAct)
  963         
  964         self.forwardAct = E5Action(
  965             self.tr('Forward'),
  966             UI.PixmapCache.getIcon("forward"),
  967             self.tr('&Forward'),
  968             QKeySequence(self.tr("Alt+Right", "Go|Forward")),
  969             0, self, 'webbrowser_go_foreward')
  970         self.forwardAct.setStatusTip(self.tr(
  971             'Move one screen forward'))
  972         self.forwardAct.setWhatsThis(self.tr(
  973             """<b>Forward</b>"""
  974             """<p>Moves one screen forward. If none is"""
  975             """ available, this action is disabled.</p>"""
  976         ))
  977         self.forwardAct.triggered.connect(self.__forward)
  978         self.__actions.append(self.forwardAct)
  979         
  980         self.homeAct = E5Action(
  981             self.tr('Home'),
  982             UI.PixmapCache.getIcon("home"),
  983             self.tr('&Home'),
  984             QKeySequence(self.tr("Ctrl+Home", "Go|Home")),
  985             0, self, 'webbrowser_go_home')
  986         self.homeAct.setStatusTip(self.tr(
  987             'Move to the initial screen'))
  988         self.homeAct.setWhatsThis(self.tr(
  989             """<b>Home</b>"""
  990             """<p>Moves to the initial screen.</p>"""
  991         ))
  992         self.homeAct.triggered.connect(self.__home)
  993         self.__actions.append(self.homeAct)
  994         
  995         self.reloadAct = E5Action(
  996             self.tr('Reload'),
  997             UI.PixmapCache.getIcon("reload"),
  998             self.tr('&Reload'),
  999             QKeySequence(self.tr("Ctrl+R", "Go|Reload")),
 1000             QKeySequence(self.tr("F5", "Go|Reload")),
 1001             self, 'webbrowser_go_reload')
 1002         self.reloadAct.setStatusTip(self.tr(
 1003             'Reload the current screen'))
 1004         self.reloadAct.setWhatsThis(self.tr(
 1005             """<b>Reload</b>"""
 1006             """<p>Reloads the current screen.</p>"""
 1007         ))
 1008         self.reloadAct.triggered.connect(self.__reload)
 1009         self.__actions.append(self.reloadAct)
 1010         
 1011         self.stopAct = E5Action(
 1012             self.tr('Stop'),
 1013             UI.PixmapCache.getIcon("stopLoading"),
 1014             self.tr('&Stop'),
 1015             QKeySequence(self.tr("Ctrl+.", "Go|Stop")),
 1016             QKeySequence(self.tr("Esc", "Go|Stop")),
 1017             self, 'webbrowser_go_stop')
 1018         self.stopAct.setStatusTip(self.tr('Stop loading'))
 1019         self.stopAct.setWhatsThis(self.tr(
 1020             """<b>Stop</b>"""
 1021             """<p>Stops loading of the current tab.</p>"""
 1022         ))
 1023         self.stopAct.triggered.connect(self.__stopLoading)
 1024         self.__actions.append(self.stopAct)
 1025         
 1026         self.copyAct = E5Action(
 1027             self.tr('Copy'),
 1028             UI.PixmapCache.getIcon("editCopy"),
 1029             self.tr('&Copy'),
 1030             QKeySequence(self.tr("Ctrl+C", "Edit|Copy")),
 1031             0, self, 'webbrowser_edit_copy')
 1032         self.copyAct.setStatusTip(self.tr('Copy the selected text'))
 1033         self.copyAct.setWhatsThis(self.tr(
 1034             """<b>Copy</b>"""
 1035             """<p>Copy the selected text to the clipboard.</p>"""
 1036         ))
 1037         self.copyAct.triggered.connect(self.__copy)
 1038         self.__actions.append(self.copyAct)
 1039         
 1040         self.cutAct = E5Action(
 1041             self.tr('Cut'),
 1042             UI.PixmapCache.getIcon("editCut"),
 1043             self.tr('Cu&t'),
 1044             QKeySequence(self.tr("Ctrl+X", "Edit|Cut")),
 1045             0, self, 'webbrowser_edit_cut')
 1046         self.cutAct.setStatusTip(self.tr('Cut the selected text'))
 1047         self.cutAct.setWhatsThis(self.tr(
 1048             """<b>Cut</b>"""
 1049             """<p>Cut the selected text to the clipboard.</p>"""
 1050         ))
 1051         self.cutAct.triggered.connect(self.__cut)
 1052         self.__actions.append(self.cutAct)
 1053         
 1054         self.pasteAct = E5Action(
 1055             self.tr('Paste'),
 1056             UI.PixmapCache.getIcon("editPaste"),
 1057             self.tr('&Paste'),
 1058             QKeySequence(self.tr("Ctrl+V", "Edit|Paste")),
 1059             0, self, 'webbrowser_edit_paste')
 1060         self.pasteAct.setStatusTip(self.tr('Paste text from the clipboard'))
 1061         self.pasteAct.setWhatsThis(self.tr(
 1062             """<b>Paste</b>"""
 1063             """<p>Paste some text from the clipboard.</p>"""
 1064         ))
 1065         self.pasteAct.triggered.connect(self.__paste)
 1066         self.__actions.append(self.pasteAct)
 1067         
 1068         self.undoAct = E5Action(
 1069             self.tr('Undo'),
 1070             UI.PixmapCache.getIcon("editUndo"),
 1071             self.tr('&Undo'),
 1072             QKeySequence(self.tr("Ctrl+Z", "Edit|Undo")),
 1073             0, self, 'webbrowser_edit_undo')
 1074         self.undoAct.setStatusTip(self.tr('Undo the last edit action'))
 1075         self.undoAct.setWhatsThis(self.tr(
 1076             """<b>Undo</b>"""
 1077             """<p>Undo the last edit action.</p>"""
 1078         ))
 1079         self.undoAct.triggered.connect(self.__undo)
 1080         self.__actions.append(self.undoAct)
 1081         
 1082         self.redoAct = E5Action(
 1083             self.tr('Redo'),
 1084             UI.PixmapCache.getIcon("editRedo"),
 1085             self.tr('&Redo'),
 1086             QKeySequence(self.tr("Ctrl+Shift+Z", "Edit|Redo")),
 1087             0, self, 'webbrowser_edit_redo')
 1088         self.redoAct.setStatusTip(self.tr('Redo the last edit action'))
 1089         self.redoAct.setWhatsThis(self.tr(
 1090             """<b>Redo</b>"""
 1091             """<p>Redo the last edit action.</p>"""
 1092         ))
 1093         self.redoAct.triggered.connect(self.__redo)
 1094         self.__actions.append(self.redoAct)
 1095         
 1096         self.selectAllAct = E5Action(
 1097             self.tr('Select All'),
 1098             UI.PixmapCache.getIcon("editSelectAll"),
 1099             self.tr('&Select All'),
 1100             QKeySequence(self.tr("Ctrl+A", "Edit|Select All")),
 1101             0, self, 'webbrowser_edit_select_all')
 1102         self.selectAllAct.setStatusTip(self.tr('Select all text'))
 1103         self.selectAllAct.setWhatsThis(self.tr(
 1104             """<b>Select All</b>"""
 1105             """<p>Select all text of the current browser.</p>"""
 1106         ))
 1107         self.selectAllAct.triggered.connect(self.__selectAll)
 1108         self.__actions.append(self.selectAllAct)
 1109         
 1110         self.unselectAct = E5Action(
 1111             self.tr('Unselect'),
 1112             self.tr('Unselect'),
 1113             QKeySequence(self.tr("Alt+Ctrl+A", "Edit|Unselect")),
 1114             0, self, 'webbrowser_edit_unselect')
 1115         self.unselectAct.setStatusTip(self.tr('Clear current selection'))
 1116         self.unselectAct.setWhatsThis(self.tr(
 1117             """<b>Unselect</b>"""
 1118             """<p>Clear the selection of the current browser.</p>"""
 1119         ))
 1120         self.unselectAct.triggered.connect(self.__unselect)
 1121         self.__actions.append(self.unselectAct)
 1122         
 1123         self.findAct = E5Action(
 1124             self.tr('Find...'),
 1125             UI.PixmapCache.getIcon("find"),
 1126             self.tr('&Find...'),
 1127             QKeySequence(self.tr("Ctrl+F", "Edit|Find")),
 1128             0, self, 'webbrowser_edit_find')
 1129         self.findAct.setStatusTip(self.tr('Find text in page'))
 1130         self.findAct.setWhatsThis(self.tr(
 1131             """<b>Find</b>"""
 1132             """<p>Find text in the current page.</p>"""
 1133         ))
 1134         self.findAct.triggered.connect(self.__find)
 1135         self.__actions.append(self.findAct)
 1136         
 1137         self.findNextAct = E5Action(
 1138             self.tr('Find next'),
 1139             UI.PixmapCache.getIcon("findNext"),
 1140             self.tr('Find &next'),
 1141             QKeySequence(self.tr("F3", "Edit|Find next")),
 1142             0, self, 'webbrowser_edit_find_next')
 1143         self.findNextAct.setStatusTip(self.tr(
 1144             'Find next occurrence of text in page'))
 1145         self.findNextAct.setWhatsThis(self.tr(
 1146             """<b>Find next</b>"""
 1147             """<p>Find the next occurrence of text in the current page.</p>"""
 1148         ))
 1149         self.findNextAct.triggered.connect(self.__searchWidget.findNext)
 1150         self.__actions.append(self.findNextAct)
 1151         
 1152         self.findPrevAct = E5Action(
 1153             self.tr('Find previous'),
 1154             UI.PixmapCache.getIcon("findPrev"),
 1155             self.tr('Find &previous'),
 1156             QKeySequence(self.tr("Shift+F3", "Edit|Find previous")),
 1157             0, self, 'webbrowser_edit_find_previous')
 1158         self.findPrevAct.setStatusTip(
 1159             self.tr('Find previous occurrence of text in page'))
 1160         self.findPrevAct.setWhatsThis(self.tr(
 1161             """<b>Find previous</b>"""
 1162             """<p>Find the previous occurrence of text in the current"""
 1163             """ page.</p>"""
 1164         ))
 1165         self.findPrevAct.triggered.connect(
 1166             self.__searchWidget.findPrevious)
 1167         self.__actions.append(self.findPrevAct)
 1168         
 1169         self.bookmarksManageAct = E5Action(
 1170             self.tr('Manage Bookmarks'),
 1171             self.tr('&Manage Bookmarks...'),
 1172             QKeySequence(self.tr("Ctrl+Shift+B", "Help|Manage bookmarks")),
 1173             0, self, 'webbrowser_bookmarks_manage')
 1174         self.bookmarksManageAct.setStatusTip(self.tr(
 1175             'Open a dialog to manage the bookmarks.'))
 1176         self.bookmarksManageAct.setWhatsThis(self.tr(
 1177             """<b>Manage Bookmarks...</b>"""
 1178             """<p>Open a dialog to manage the bookmarks.</p>"""
 1179         ))
 1180         self.bookmarksManageAct.triggered.connect(
 1181             self.__showBookmarksDialog)
 1182         self.__actions.append(self.bookmarksManageAct)
 1183         
 1184         self.bookmarksAddAct = E5Action(
 1185             self.tr('Add Bookmark'),
 1186             UI.PixmapCache.getIcon("addBookmark"),
 1187             self.tr('Add &Bookmark...'),
 1188             QKeySequence(self.tr("Ctrl+D", "Help|Add bookmark")),
 1189             0, self, 'webbrowser_bookmark_add')
 1190         self.bookmarksAddAct.setIconVisibleInMenu(False)
 1191         self.bookmarksAddAct.setStatusTip(self.tr(
 1192             'Open a dialog to add a bookmark.'))
 1193         self.bookmarksAddAct.setWhatsThis(self.tr(
 1194             """<b>Add Bookmark</b>"""
 1195             """<p>Open a dialog to add the current URL as a bookmark.</p>"""
 1196         ))
 1197         self.bookmarksAddAct.triggered.connect(self.__addBookmark)
 1198         self.__actions.append(self.bookmarksAddAct)
 1199         
 1200         self.bookmarksAddFolderAct = E5Action(
 1201             self.tr('Add Folder'),
 1202             self.tr('Add &Folder...'),
 1203             0, 0, self, 'webbrowser_bookmark_show_all')
 1204         self.bookmarksAddFolderAct.setStatusTip(self.tr(
 1205             'Open a dialog to add a new bookmarks folder.'))
 1206         self.bookmarksAddFolderAct.setWhatsThis(self.tr(
 1207             """<b>Add Folder...</b>"""
 1208             """<p>Open a dialog to add a new bookmarks folder.</p>"""
 1209         ))
 1210         self.bookmarksAddFolderAct.triggered.connect(
 1211             self.__addBookmarkFolder)
 1212         self.__actions.append(self.bookmarksAddFolderAct)
 1213         
 1214         self.bookmarksAllTabsAct = E5Action(
 1215             self.tr('Bookmark All Tabs'),
 1216             self.tr('Bookmark All Tabs...'),
 1217             0, 0, self, 'webbrowser_bookmark_all_tabs')
 1218         self.bookmarksAllTabsAct.setStatusTip(self.tr(
 1219             'Bookmark all open tabs.'))
 1220         self.bookmarksAllTabsAct.setWhatsThis(self.tr(
 1221             """<b>Bookmark All Tabs...</b>"""
 1222             """<p>Open a dialog to add a new bookmarks folder for"""
 1223             """ all open tabs.</p>"""
 1224         ))
 1225         self.bookmarksAllTabsAct.triggered.connect(self.bookmarkAll)
 1226         self.__actions.append(self.bookmarksAllTabsAct)
 1227         
 1228         self.whatsThisAct = E5Action(
 1229             self.tr('What\'s This?'),
 1230             UI.PixmapCache.getIcon("whatsThis"),
 1231             self.tr('&What\'s This?'),
 1232             QKeySequence(self.tr("Shift+F1", "Help|What's This?'")),
 1233             0, self, 'webbrowser_help_whats_this')
 1234         self.whatsThisAct.setStatusTip(self.tr('Context sensitive help'))
 1235         self.whatsThisAct.setWhatsThis(self.tr(
 1236             """<b>Display context sensitive help</b>"""
 1237             """<p>In What's This? mode, the mouse cursor shows an arrow"""
 1238             """ with a question mark, and you can click on the interface"""
 1239             """ elements to get a short description of what they do and how"""
 1240             """ to use them. In dialogs, this feature can be accessed using"""
 1241             """ the context help button in the titlebar.</p>"""
 1242         ))
 1243         self.whatsThisAct.triggered.connect(self.__whatsThis)
 1244         self.__actions.append(self.whatsThisAct)
 1245         
 1246         self.aboutAct = E5Action(
 1247             self.tr('About'),
 1248             self.tr('&About'),
 1249             0, 0, self, 'webbrowser_help_about')
 1250         self.aboutAct.setStatusTip(self.tr(
 1251             'Display information about this software'))
 1252         self.aboutAct.setWhatsThis(self.tr(
 1253             """<b>About</b>"""
 1254             """<p>Display some information about this software.</p>"""
 1255         ))
 1256         self.aboutAct.triggered.connect(self.__about)
 1257         self.__actions.append(self.aboutAct)
 1258         
 1259         self.aboutQtAct = E5Action(
 1260             self.tr('About Qt'),
 1261             self.tr('About &Qt'),
 1262             0, 0, self, 'webbrowser_help_about_qt')
 1263         self.aboutQtAct.setStatusTip(
 1264             self.tr('Display information about the Qt toolkit'))
 1265         self.aboutQtAct.setWhatsThis(self.tr(
 1266             """<b>About Qt</b>"""
 1267             """<p>Display some information about the Qt toolkit.</p>"""
 1268         ))
 1269         self.aboutQtAct.triggered.connect(self.__aboutQt)
 1270         self.__actions.append(self.aboutQtAct)
 1271         
 1272         self.zoomInAct = E5Action(
 1273             self.tr('Zoom in'),
 1274             UI.PixmapCache.getIcon("zoomIn"),
 1275             self.tr('Zoom &in'),
 1276             QKeySequence(self.tr("Ctrl++", "View|Zoom in")),
 1277             QKeySequence(self.tr("Zoom In", "View|Zoom in")),
 1278             self, 'webbrowser_view_zoom_in')
 1279         self.zoomInAct.setStatusTip(self.tr('Zoom in on the web page'))
 1280         self.zoomInAct.setWhatsThis(self.tr(
 1281             """<b>Zoom in</b>"""
 1282             """<p>Zoom in on the web page."""
 1283             """ This makes the web page bigger.</p>"""
 1284         ))
 1285         self.zoomInAct.triggered.connect(self.__zoomIn)
 1286         self.__actions.append(self.zoomInAct)
 1287         
 1288         self.zoomOutAct = E5Action(
 1289             self.tr('Zoom out'),
 1290             UI.PixmapCache.getIcon("zoomOut"),
 1291             self.tr('Zoom &out'),
 1292             QKeySequence(self.tr("Ctrl+-", "View|Zoom out")),
 1293             QKeySequence(self.tr("Zoom Out", "View|Zoom out")),
 1294             self, 'webbrowser_view_zoom_out')
 1295         self.zoomOutAct.setStatusTip(self.tr('Zoom out on the web page'))
 1296         self.zoomOutAct.setWhatsThis(self.tr(
 1297             """<b>Zoom out</b>"""
 1298             """<p>Zoom out on the web page."""
 1299             """ This makes the web page smaller.</p>"""
 1300         ))
 1301         self.zoomOutAct.triggered.connect(self.__zoomOut)
 1302         self.__actions.append(self.zoomOutAct)
 1303         
 1304         self.zoomResetAct = E5Action(
 1305             self.tr('Zoom reset'),
 1306             UI.PixmapCache.getIcon("zoomReset"),
 1307             self.tr('Zoom &reset'),
 1308             QKeySequence(self.tr("Ctrl+0", "View|Zoom reset")),
 1309             0, self, 'webbrowser_view_zoom_reset')
 1310         self.zoomResetAct.setStatusTip(self.tr(
 1311             'Reset the zoom of the web page'))
 1312         self.zoomResetAct.setWhatsThis(self.tr(
 1313             """<b>Zoom reset</b>"""
 1314             """<p>Reset the zoom of the web page. """
 1315             """This sets the zoom factor to 100%.</p>"""
 1316         ))
 1317         self.zoomResetAct.triggered.connect(self.__zoomReset)
 1318         self.__actions.append(self.zoomResetAct)
 1319         
 1320         self.pageSourceAct = E5Action(
 1321             self.tr('Show page source'),
 1322             self.tr('Show page source'),
 1323             QKeySequence(self.tr('Ctrl+U')), 0,
 1324             self, 'webbrowser_show_page_source')
 1325         self.pageSourceAct.setStatusTip(self.tr(
 1326             'Show the page source in an editor'))
 1327         self.pageSourceAct.setWhatsThis(self.tr(
 1328             """<b>Show page source</b>"""
 1329             """<p>Show the page source in an editor.</p>"""
 1330         ))
 1331         self.pageSourceAct.triggered.connect(self.__showPageSource)
 1332         self.__actions.append(self.pageSourceAct)
 1333         self.addAction(self.pageSourceAct)
 1334         
 1335         self.fullScreenAct = E5Action(
 1336             self.tr('Full Screen'),
 1337             UI.PixmapCache.getIcon("windowFullscreen"),
 1338             self.tr('&Full Screen'),
 1339             0, 0,
 1340             self, 'webbrowser_view_full_screen')
 1341         if Globals.isMacPlatform():
 1342             self.fullScreenAct.setShortcut(
 1343                 QKeySequence(self.tr("Meta+Ctrl+F")))
 1344         else:
 1345             self.fullScreenAct.setShortcut(QKeySequence(self.tr('F11')))
 1346         self.fullScreenAct.triggered.connect(self.toggleFullScreen)
 1347         self.__actions.append(self.fullScreenAct)
 1348         self.addAction(self.fullScreenAct)
 1349         
 1350         self.nextTabAct = E5Action(
 1351             self.tr('Show next tab'),
 1352             self.tr('Show next tab'),
 1353             QKeySequence(self.tr('Ctrl+Alt+Tab')), 0,
 1354             self, 'webbrowser_view_next_tab')
 1355         self.nextTabAct.triggered.connect(self.__nextTab)
 1356         self.__actions.append(self.nextTabAct)
 1357         self.addAction(self.nextTabAct)
 1358         
 1359         self.prevTabAct = E5Action(
 1360             self.tr('Show previous tab'),
 1361             self.tr('Show previous tab'),
 1362             QKeySequence(self.tr('Shift+Ctrl+Alt+Tab')), 0,
 1363             self, 'webbrowser_view_previous_tab')
 1364         self.prevTabAct.triggered.connect(self.__prevTab)
 1365         self.__actions.append(self.prevTabAct)
 1366         self.addAction(self.prevTabAct)
 1367         
 1368         self.switchTabAct = E5Action(
 1369             self.tr('Switch between tabs'),
 1370             self.tr('Switch between tabs'),
 1371             QKeySequence(self.tr('Ctrl+1')), 0,
 1372             self, 'webbrowser_switch_tabs')
 1373         self.switchTabAct.triggered.connect(self.__switchTab)
 1374         self.__actions.append(self.switchTabAct)
 1375         self.addAction(self.switchTabAct)
 1376         
 1377         self.prefAct = E5Action(
 1378             self.tr('Preferences'),
 1379             UI.PixmapCache.getIcon("configure"),
 1380             self.tr('&Preferences...'), 0, 0, self, 'webbrowser_preferences')
 1381         self.prefAct.setStatusTip(self.tr(
 1382             'Set the prefered configuration'))
 1383         self.prefAct.setWhatsThis(self.tr(
 1384             """<b>Preferences</b>"""
 1385             """<p>Set the configuration items of the application"""
 1386             """ with your prefered values.</p>"""
 1387         ))
 1388         self.prefAct.triggered.connect(self.__showPreferences)
 1389         self.__actions.append(self.prefAct)
 1390         
 1391         self.acceptedLanguagesAct = E5Action(
 1392             self.tr('Languages'),
 1393             UI.PixmapCache.getIcon("flag"),
 1394             self.tr('&Languages...'), 0, 0,
 1395             self, 'webbrowser_accepted_languages')
 1396         self.acceptedLanguagesAct.setStatusTip(self.tr(
 1397             'Configure the accepted languages for web pages'))
 1398         self.acceptedLanguagesAct.setWhatsThis(self.tr(
 1399             """<b>Languages</b>"""
 1400             """<p>Configure the accepted languages for web pages.</p>"""
 1401         ))
 1402         self.acceptedLanguagesAct.triggered.connect(
 1403             self.__showAcceptedLanguages)
 1404         self.__actions.append(self.acceptedLanguagesAct)
 1405         
 1406         self.cookiesAct = E5Action(
 1407             self.tr('Cookies'),
 1408             UI.PixmapCache.getIcon("cookie"),
 1409             self.tr('C&ookies...'), 0, 0, self, 'webbrowser_cookies')
 1410         self.cookiesAct.setStatusTip(self.tr(
 1411             'Configure cookies handling'))
 1412         self.cookiesAct.setWhatsThis(self.tr(
 1413             """<b>Cookies</b>"""
 1414             """<p>Configure cookies handling.</p>"""
 1415         ))
 1416         self.cookiesAct.triggered.connect(
 1417             self.__showCookiesConfiguration)
 1418         self.__actions.append(self.cookiesAct)
 1419         
 1420         self.flashCookiesAct = E5Action(
 1421             self.tr('Flash Cookies'),
 1422             UI.PixmapCache.getIcon("flashCookie"),
 1423             self.tr('&Flash Cookies...'), 0, 0, self,
 1424             'webbrowser_flash_cookies')
 1425         self.flashCookiesAct.setStatusTip(self.tr(
 1426             'Manage flash cookies'))
 1427         self.flashCookiesAct.setWhatsThis(self.tr(
 1428             """<b>Flash Cookies</b>"""
 1429             """<p>Show a dialog to manage the flash cookies.</p>"""
 1430         ))
 1431         self.flashCookiesAct.triggered.connect(
 1432             self.__showFlashCookiesManagement)
 1433         self.__actions.append(self.flashCookiesAct)
 1434         
 1435         self.personalDataAct = E5Action(
 1436             self.tr('Personal Information'),
 1437             UI.PixmapCache.getIcon("pim"),
 1438             self.tr('Personal Information...'),
 1439             0, 0,
 1440             self, 'webbrowser_personal_information')
 1441         self.personalDataAct.setStatusTip(self.tr(
 1442             'Configure personal information for completing form fields'))
 1443         self.personalDataAct.setWhatsThis(self.tr(
 1444             """<b>Personal Information...</b>"""
 1445             """<p>Opens a dialog to configure the personal information"""
 1446             """ used for completing form fields.</p>"""
 1447         ))
 1448         self.personalDataAct.triggered.connect(
 1449             self.__showPersonalInformationDialog)
 1450         self.__actions.append(self.personalDataAct)
 1451         
 1452         self.greaseMonkeyAct = E5Action(
 1453             self.tr('GreaseMonkey Scripts'),
 1454             UI.PixmapCache.getIcon("greaseMonkey"),
 1455             self.tr('GreaseMonkey Scripts...'),
 1456             0, 0,
 1457             self, 'webbrowser_greasemonkey')
 1458         self.greaseMonkeyAct.setStatusTip(self.tr(
 1459             'Configure the GreaseMonkey Scripts'))
 1460         self.greaseMonkeyAct.setWhatsThis(self.tr(
 1461             """<b>GreaseMonkey Scripts...</b>"""
 1462             """<p>Opens a dialog to configure the available GreaseMonkey"""
 1463             """ Scripts.</p>"""
 1464         ))
 1465         self.greaseMonkeyAct.triggered.connect(
 1466             self.__showGreaseMonkeyConfigDialog)
 1467         self.__actions.append(self.greaseMonkeyAct)
 1468         
 1469         self.editMessageFilterAct = E5Action(
 1470             self.tr('Edit Message Filters'),
 1471             UI.PixmapCache.getIcon("warning"),
 1472             self.tr('Edit Message Filters...'), 0, 0, self,
 1473             'webbrowser_manage_message_filters')
 1474         self.editMessageFilterAct.setStatusTip(self.tr(
 1475             'Edit the message filters used to suppress unwanted messages'))
 1476         self.editMessageFilterAct.setWhatsThis(self.tr(
 1477             """<b>Edit Message Filters</b>"""
 1478             """<p>Opens a dialog to edit the message filters used to"""
 1479             """ suppress unwanted messages been shown in an error"""
 1480             """ window.</p>"""
 1481         ))
 1482         self.editMessageFilterAct.triggered.connect(
 1483             E5ErrorMessage.editMessageFilters)
 1484         self.__actions.append(self.editMessageFilterAct)
 1485         
 1486         self.featurePermissionAct = E5Action(
 1487             self.tr('Edit HTML5 Feature Permissions'),
 1488             UI.PixmapCache.getIcon("featurePermission"),
 1489             self.tr('Edit HTML5 Feature Permissions...'), 0, 0, self,
 1490             'webbrowser_edit_feature_permissions')
 1491         self.featurePermissionAct.setStatusTip(self.tr(
 1492             'Edit the remembered HTML5 feature permissions'))
 1493         self.featurePermissionAct.setWhatsThis(self.tr(
 1494             """<b>Edit HTML5 Feature Permissions</b>"""
 1495             """<p>Opens a dialog to edit the remembered HTML5"""
 1496             """ feature permissions.</p>"""
 1497         ))
 1498         self.featurePermissionAct.triggered.connect(
 1499             self.__showFeaturePermissionDialog)
 1500         self.__actions.append(self.featurePermissionAct)
 1501         
 1502         if WebBrowserWindow._useQtHelp:
 1503             self.syncTocAct = E5Action(
 1504                 self.tr('Sync with Table of Contents'),
 1505                 UI.PixmapCache.getIcon("syncToc"),
 1506                 self.tr('Sync with Table of Contents'),
 1507                 0, 0, self, 'webbrowser_sync_toc')
 1508             self.syncTocAct.setStatusTip(self.tr(
 1509                 'Synchronizes the table of contents with current page'))
 1510             self.syncTocAct.setWhatsThis(self.tr(
 1511                 """<b>Sync with Table of Contents</b>"""
 1512                 """<p>Synchronizes the table of contents with current"""
 1513                 """ page.</p>"""
 1514             ))
 1515             self.syncTocAct.triggered.connect(self.__syncTOC)
 1516             self.__actions.append(self.syncTocAct)
 1517             
 1518             self.showTocAct = E5Action(
 1519                 self.tr('Table of Contents'),
 1520                 self.tr('Table of Contents'),
 1521                 0, 0, self, 'webbrowser_show_toc')
 1522             self.showTocAct.setStatusTip(self.tr(
 1523                 'Shows the table of contents window'))
 1524             self.showTocAct.setWhatsThis(self.tr(
 1525                 """<b>Table of Contents</b>"""
 1526                 """<p>Shows the table of contents window.</p>"""
 1527             ))
 1528             self.showTocAct.triggered.connect(self.__showTocWindow)
 1529             self.__actions.append(self.showTocAct)
 1530             
 1531             self.showIndexAct = E5Action(
 1532                 self.tr('Index'),
 1533                 self.tr('Index'),
 1534                 0, 0, self, 'webbrowser_show_index')
 1535             self.showIndexAct.setStatusTip(self.tr(
 1536                 'Shows the index window'))
 1537             self.showIndexAct.setWhatsThis(self.tr(
 1538                 """<b>Index</b>"""
 1539                 """<p>Shows the index window.</p>"""
 1540             ))
 1541             self.showIndexAct.triggered.connect(self.__showIndexWindow)
 1542             self.__actions.append(self.showIndexAct)
 1543             
 1544             self.showSearchAct = E5Action(
 1545                 self.tr('Search'),
 1546                 self.tr('Search'),
 1547                 0, 0, self, 'webbrowser_show_search')
 1548             self.showSearchAct.setStatusTip(self.tr(
 1549                 'Shows the search window'))
 1550             self.showSearchAct.setWhatsThis(self.tr(
 1551                 """<b>Search</b>"""
 1552                 """<p>Shows the search window.</p>"""
 1553             ))
 1554             self.showSearchAct.triggered.connect(
 1555                 self.__showSearchWindow)
 1556             self.__actions.append(self.showSearchAct)
 1557             
 1558             self.manageQtHelpDocsAct = E5Action(
 1559                 self.tr('Manage QtHelp Documents'),
 1560                 self.tr('Manage QtHelp &Documents'),
 1561                 0, 0, self, 'webbrowser_qthelp_documents')
 1562             self.manageQtHelpDocsAct.setStatusTip(self.tr(
 1563                 'Shows a dialog to manage the QtHelp documentation set'))
 1564             self.manageQtHelpDocsAct.setWhatsThis(self.tr(
 1565                 """<b>Manage QtHelp Documents</b>"""
 1566                 """<p>Shows a dialog to manage the QtHelp documentation"""
 1567                 """ set.</p>"""
 1568             ))
 1569             self.manageQtHelpDocsAct.triggered.connect(
 1570                 self.__manageQtHelpDocumentation)
 1571             self.__actions.append(self.manageQtHelpDocsAct)
 1572             
 1573             self.reindexDocumentationAct = E5Action(
 1574                 self.tr('Reindex Documentation'),
 1575                 self.tr('&Reindex Documentation'),
 1576                 0, 0, self, 'webbrowser_qthelp_reindex')
 1577             self.reindexDocumentationAct.setStatusTip(self.tr(
 1578                 'Reindexes the documentation set'))
 1579             self.reindexDocumentationAct.setWhatsThis(self.tr(
 1580                 """<b>Reindex Documentation</b>"""
 1581                 """<p>Reindexes the documentation set.</p>"""
 1582             ))
 1583             self.reindexDocumentationAct.triggered.connect(
 1584                 self.__searchEngine.reindexDocumentation)
 1585             self.__actions.append(self.reindexDocumentationAct)
 1586         
 1587         self.clearPrivateDataAct = E5Action(
 1588             self.tr('Clear private data'),
 1589             UI.PixmapCache.getIcon("clearPrivateData"),
 1590             self.tr('Clear private data'),
 1591             0, 0,
 1592             self, 'webbrowser_clear_private_data')
 1593         self.clearPrivateDataAct.setStatusTip(self.tr(
 1594             'Clear private data'))
 1595         self.clearPrivateDataAct.setWhatsThis(self.tr(
 1596             """<b>Clear private data</b>"""
 1597             """<p>Clears the private data like browsing history, search"""
 1598             """ history or the favicons database.</p>"""
 1599         ))
 1600         self.clearPrivateDataAct.triggered.connect(
 1601             self.__clearPrivateData)
 1602         self.__actions.append(self.clearPrivateDataAct)
 1603         
 1604         self.clearIconsAct = E5Action(
 1605             self.tr('Clear icons database'),
 1606             self.tr('Clear &icons database'),
 1607             0, 0,
 1608             self, 'webbrowser_clear_icons_db')
 1609         self.clearIconsAct.setStatusTip(self.tr(
 1610             'Clear the database of favicons'))
 1611         self.clearIconsAct.setWhatsThis(self.tr(
 1612             """<b>Clear icons database</b>"""
 1613             """<p>Clears the database of favicons of previously visited"""
 1614             """ URLs.</p>"""
 1615         ))
 1616         self.clearIconsAct.triggered.connect(self.__clearIconsDatabase)
 1617         self.__actions.append(self.clearIconsAct)
 1618         
 1619         self.manageIconsAct = E5Action(
 1620             self.tr('Manage saved Favicons'),
 1621             UI.PixmapCache.getIcon("icons"),
 1622             self.tr('Manage saved Favicons'),
 1623             0, 0,
 1624             self, 'webbrowser_manage_icons_db')
 1625         self.manageIconsAct.setStatusTip(self.tr(
 1626             'Show a dialog to manage the saved favicons'))
 1627         self.manageIconsAct.setWhatsThis(self.tr(
 1628             """<b>Manage saved Favicons</b>"""
 1629             """<p>This shows a dialog to manage the saved favicons of"""
 1630             """ previously visited URLs.</p>"""
 1631         ))
 1632         self.manageIconsAct.triggered.connect(self.__showWebIconsDialog)
 1633         self.__actions.append(self.manageIconsAct)
 1634         
 1635         self.searchEnginesAct = E5Action(
 1636             self.tr('Configure Search Engines'),
 1637             self.tr('Configure Search &Engines...'),
 1638             0, 0,
 1639             self, 'webbrowser_search_engines')
 1640         self.searchEnginesAct.setStatusTip(self.tr(
 1641             'Configure the available search engines'))
 1642         self.searchEnginesAct.setWhatsThis(self.tr(
 1643             """<b>Configure Search Engines...</b>"""
 1644             """<p>Opens a dialog to configure the available search"""
 1645             """ engines.</p>"""
 1646         ))
 1647         self.searchEnginesAct.triggered.connect(
 1648             self.__showEnginesConfigurationDialog)
 1649         self.__actions.append(self.searchEnginesAct)
 1650         
 1651         self.passwordsAct = E5Action(
 1652             self.tr('Manage Saved Passwords'),
 1653             UI.PixmapCache.getIcon("passwords"),
 1654             self.tr('Manage Saved Passwords...'),
 1655             0, 0,
 1656             self, 'webbrowser_manage_passwords')
 1657         self.passwordsAct.setStatusTip(self.tr(
 1658             'Manage the saved passwords'))
 1659         self.passwordsAct.setWhatsThis(self.tr(
 1660             """<b>Manage Saved Passwords...</b>"""
 1661             """<p>Opens a dialog to manage the saved passwords.</p>"""
 1662         ))
 1663         self.passwordsAct.triggered.connect(self.__showPasswordsDialog)
 1664         self.__actions.append(self.passwordsAct)
 1665         
 1666         self.adblockAct = E5Action(
 1667             self.tr('Ad Block'),
 1668             UI.PixmapCache.getIcon("adBlockPlus"),
 1669             self.tr('&Ad Block...'),
 1670             0, 0,
 1671             self, 'webbrowser_adblock')
 1672         self.adblockAct.setStatusTip(self.tr(
 1673             'Configure AdBlock subscriptions and rules'))
 1674         self.adblockAct.setWhatsThis(self.tr(
 1675             """<b>Ad Block...</b>"""
 1676             """<p>Opens a dialog to configure AdBlock subscriptions and"""
 1677             """ rules.</p>"""
 1678         ))
 1679         self.adblockAct.triggered.connect(self.__showAdBlockDialog)
 1680         self.__actions.append(self.adblockAct)
 1681         
 1682         self.certificateErrorsAct = E5Action(
 1683             self.tr('Manage SSL Certificate Errors'),
 1684             UI.PixmapCache.getIcon("certificates"),
 1685             self.tr('Manage SSL Certificate Errors...'),
 1686             0, 0,
 1687             self, 'webbrowser_manage_certificate_errors')
 1688         self.certificateErrorsAct.setStatusTip(self.tr(
 1689             'Manage the accepted SSL certificate Errors'))
 1690         self.certificateErrorsAct.setWhatsThis(self.tr(
 1691             """<b>Manage SSL Certificate Errors...</b>"""
 1692             """<p>Opens a dialog to manage the accepted SSL"""
 1693             """ certificate errors.</p>"""
 1694         ))
 1695         self.certificateErrorsAct.triggered.connect(
 1696             self.__showCertificateErrorsDialog)
 1697         self.__actions.append(self.certificateErrorsAct)
 1698         
 1699         self.safeBrowsingAct = E5Action(
 1700             self.tr('Manage Safe Browsing'),
 1701             UI.PixmapCache.getIcon("safeBrowsing"),
 1702             self.tr('Manage Safe Browsing...'), 0, 0, self,
 1703             'webbrowser_manage_safe_browsing')
 1704         self.safeBrowsingAct.setStatusTip(self.tr(
 1705             'Configure Safe Browsing and manage local cache'))
 1706         self.safeBrowsingAct.setWhatsThis(self.tr(
 1707             """<b>Manage Safe Browsing</b>"""
 1708             """<p>This opens a dialog to configure Safe Browsing and"""
 1709             """ to manage the local cache.</p>"""
 1710         ))
 1711         self.safeBrowsingAct.triggered.connect(
 1712             self.__showSafeBrowsingDialog)
 1713         self.__actions.append(self.safeBrowsingAct)
 1714         
 1715         self.showDownloadManagerAct = E5Action(
 1716             self.tr('Downloads'),
 1717             self.tr('Downloads'),
 1718             0, 0, self, 'webbrowser_show_downloads')
 1719         self.showDownloadManagerAct.setStatusTip(self.tr(
 1720             'Shows the downloads window'))
 1721         self.showDownloadManagerAct.setWhatsThis(self.tr(
 1722             """<b>Downloads</b>"""
 1723             """<p>Shows the downloads window.</p>"""
 1724         ))
 1725         self.showDownloadManagerAct.triggered.connect(
 1726             self.__showDownloadsWindow)
 1727         self.__actions.append(self.showDownloadManagerAct)
 1728         
 1729         self.feedsManagerAct = E5Action(
 1730             self.tr('RSS Feeds Dialog'),
 1731             UI.PixmapCache.getIcon("rss22"),
 1732             self.tr('&RSS Feeds Dialog...'),
 1733             QKeySequence(self.tr("Ctrl+Shift+F", "Help|RSS Feeds Dialog")),
 1734             0, self, 'webbrowser_rss_feeds')
 1735         self.feedsManagerAct.setStatusTip(self.tr(
 1736             'Open a dialog showing the configured RSS feeds.'))
 1737         self.feedsManagerAct.setWhatsThis(self.tr(
 1738             """<b>RSS Feeds Dialog...</b>"""
 1739             """<p>Open a dialog to show the configured RSS feeds."""
 1740             """ It can be used to mange the feeds and to show their"""
 1741             """ contents.</p>"""
 1742         ))
 1743         self.feedsManagerAct.triggered.connect(self.__showFeedsManager)
 1744         self.__actions.append(self.feedsManagerAct)
 1745         
 1746         self.siteInfoAct = E5Action(
 1747             self.tr('Siteinfo Dialog'),
 1748             UI.PixmapCache.getIcon("helpAbout"),
 1749             self.tr('&Siteinfo Dialog...'),
 1750             QKeySequence(self.tr("Ctrl+Shift+I", "Help|Siteinfo Dialog")),
 1751             0, self, 'webbrowser_siteinfo')
 1752         self.siteInfoAct.setStatusTip(self.tr(
 1753             'Open a dialog showing some information about the current site.'))
 1754         self.siteInfoAct.setWhatsThis(self.tr(
 1755             """<b>Siteinfo Dialog...</b>"""
 1756             """<p>Opens a dialog showing some information about the current"""
 1757             """ site.</p>"""
 1758         ))
 1759         self.siteInfoAct.triggered.connect(self.__showSiteinfoDialog)
 1760         self.__actions.append(self.siteInfoAct)
 1761         
 1762         self.userAgentManagerAct = E5Action(
 1763             self.tr('Manage User Agent Settings'),
 1764             self.tr('Manage &User Agent Settings'),
 1765             0, 0, self, 'webbrowser_user_agent_settings')
 1766         self.userAgentManagerAct.setStatusTip(self.tr(
 1767             'Shows a dialog to manage the User Agent settings'))
 1768         self.userAgentManagerAct.setWhatsThis(self.tr(
 1769             """<b>Manage User Agent Settings</b>"""
 1770             """<p>Shows a dialog to manage the User Agent settings.</p>"""
 1771         ))
 1772         self.userAgentManagerAct.triggered.connect(
 1773             self.__showUserAgentsDialog)
 1774         self.__actions.append(self.userAgentManagerAct)
 1775         
 1776         self.synchronizationAct = E5Action(
 1777             self.tr('Synchronize data'),
 1778             UI.PixmapCache.getIcon("sync"),
 1779             self.tr('&Synchronize Data...'),
 1780             0, 0, self, 'webbrowser_synchronize_data')
 1781         self.synchronizationAct.setStatusTip(self.tr(
 1782             'Shows a dialog to synchronize data via the network'))
 1783         self.synchronizationAct.setWhatsThis(self.tr(
 1784             """<b>Synchronize Data...</b>"""
 1785             """<p>This shows a dialog to synchronize data via the"""
 1786             """ network.</p>"""
 1787         ))
 1788         self.synchronizationAct.triggered.connect(
 1789             self.__showSyncDialog)
 1790         self.__actions.append(self.synchronizationAct)
 1791         
 1792         self.zoomValuesAct = E5Action(
 1793             self.tr('Manage Saved Zoom Values'),
 1794             UI.PixmapCache.getIcon("zoomReset"),
 1795             self.tr('Manage Saved Zoom Values...'),
 1796             0, 0,
 1797             self, 'webbrowser_manage_zoom_values')
 1798         self.zoomValuesAct.setStatusTip(self.tr(
 1799             'Manage the saved zoom values'))
 1800         self.zoomValuesAct.setWhatsThis(self.tr(
 1801             """<b>Manage Saved Zoom Values...</b>"""
 1802             """<p>Opens a dialog to manage the saved zoom values.</p>"""
 1803         ))
 1804         self.zoomValuesAct.triggered.connect(self.__showZoomValuesDialog)
 1805         self.__actions.append(self.zoomValuesAct)
 1806         
 1807         self.showJavaScriptConsoleAct = E5Action(
 1808             self.tr('JavaScript Console'),
 1809             self.tr('JavaScript Console'),
 1810             0, 0, self, 'webbrowser_show_javascript_console')
 1811         self.showJavaScriptConsoleAct.setStatusTip(self.tr(
 1812             'Toggle the JavaScript console window'))
 1813         self.showJavaScriptConsoleAct.setWhatsThis(self.tr(
 1814             """<b>JavaScript Console</b>"""
 1815             """<p>This toggles the JavaScript console window.</p>"""
 1816         ))
 1817         self.showJavaScriptConsoleAct.triggered.connect(
 1818             self.__toggleJavaScriptConsole)
 1819         self.__actions.append(self.showJavaScriptConsoleAct)
 1820         
 1821         self.showTabManagerAct = E5Action(
 1822             self.tr('Tab Manager'),
 1823             self.tr('Tab Manager'),
 1824             0, 0, self, 'webbrowser_show_tab_manager')
 1825         self.showTabManagerAct.setStatusTip(self.tr(
 1826             'Shows the tab manager window'))
 1827         self.showTabManagerAct.setWhatsThis(self.tr(
 1828             """<b>Tab Manager</b>"""
 1829             """<p>Shows the tab manager window.</p>"""
 1830         ))
 1831         self.showTabManagerAct.triggered.connect(
 1832             lambda: self.__showTabManager(self.showTabManagerAct))
 1833         self.__actions.append(self.showTabManagerAct)
 1834         
 1835         self.showSessionsManagerAct = E5Action(
 1836             self.tr('Session Manager'),
 1837             self.tr('Session Manager...'),
 1838             0, 0, self, 'webbrowser_show_session_manager')
 1839         self.showSessionsManagerAct.setStatusTip(self.tr(
 1840             'Shows the session manager window'))
 1841         self.showSessionsManagerAct.setWhatsThis(self.tr(
 1842             """<b>Session Manager</b>"""
 1843             """<p>Shows the session manager window.</p>"""
 1844         ))
 1845         self.showSessionsManagerAct.triggered.connect(
 1846             self.__showSessionManagerDialog)
 1847         self.__actions.append(self.showSessionsManagerAct)
 1848         
 1849         self.virustotalScanCurrentAct = E5Action(
 1850             self.tr("Scan current site"),
 1851             UI.PixmapCache.getIcon("virustotal"),
 1852             self.tr("Scan current site"),
 1853             0, 0,
 1854             self, 'webbrowser_virustotal_scan_site')
 1855         self.virustotalScanCurrentAct.triggered.connect(
 1856             self.__virusTotalScanCurrentSite)
 1857         self.__actions.append(self.virustotalScanCurrentAct)
 1858         
 1859         self.virustotalIpReportAct = E5Action(
 1860             self.tr("IP Address Report"),
 1861             UI.PixmapCache.getIcon("virustotal"),
 1862             self.tr("IP Address Report"),
 1863             0, 0,
 1864             self, 'webbrowser_virustotal_ip_report')
 1865         self.virustotalIpReportAct.triggered.connect(
 1866             self.__virusTotalIpAddressReport)
 1867         self.__actions.append(self.virustotalIpReportAct)
 1868         
 1869         self.virustotalDomainReportAct = E5Action(
 1870             self.tr("Domain Report"),
 1871             UI.PixmapCache.getIcon("virustotal"),
 1872             self.tr("Domain Report"),
 1873             0, 0,
 1874             self, 'webbrowser_virustotal_domain_report')
 1875         self.virustotalDomainReportAct.triggered.connect(
 1876             self.__virusTotalDomainReport)
 1877         self.__actions.append(self.virustotalDomainReportAct)
 1878         
 1879         if (
 1880             not Preferences.getWebBrowser("VirusTotalEnabled") or
 1881             Preferences.getWebBrowser("VirusTotalServiceKey") == ""
 1882         ):
 1883             self.virustotalScanCurrentAct.setEnabled(False)
 1884             self.virustotalIpReportAct.setEnabled(False)
 1885             self.virustotalDomainReportAct.setEnabled(False)
 1886 
 1887         self.shortcutsAct = E5Action(
 1888             self.tr('Keyboard Shortcuts'),
 1889             UI.PixmapCache.getIcon("configureShortcuts"),
 1890             self.tr('Keyboard &Shortcuts...'),
 1891             0, 0,
 1892             self, 'webbrowser_keyboard_shortcuts')
 1893         self.shortcutsAct.setStatusTip(self.tr(
 1894             'Set the keyboard shortcuts'))
 1895         self.shortcutsAct.setWhatsThis(self.tr(
 1896             """<b>Keyboard Shortcuts</b>"""
 1897             """<p>Set the keyboard shortcuts of the application"""
 1898             """ with your prefered values.</p>"""
 1899         ))
 1900         self.shortcutsAct.triggered.connect(self.__configShortcuts)
 1901         self.__actions.append(self.shortcutsAct)
 1902 
 1903         self.exportShortcutsAct = E5Action(
 1904             self.tr('Export Keyboard Shortcuts'),
 1905             UI.PixmapCache.getIcon("exportShortcuts"),
 1906             self.tr('&Export Keyboard Shortcuts...'),
 1907             0, 0, self, 'export_keyboard_shortcuts')
 1908         self.exportShortcutsAct.setStatusTip(self.tr(
 1909             'Export the keyboard shortcuts'))
 1910         self.exportShortcutsAct.setWhatsThis(self.tr(
 1911             """<b>Export Keyboard Shortcuts</b>"""
 1912             """<p>Export the keyboard shortcuts of the application.</p>"""
 1913         ))
 1914         self.exportShortcutsAct.triggered.connect(self.__exportShortcuts)
 1915         self.__actions.append(self.exportShortcutsAct)
 1916 
 1917         self.importShortcutsAct = E5Action(
 1918             self.tr('Import Keyboard Shortcuts'),
 1919             UI.PixmapCache.getIcon("importShortcuts"),
 1920             self.tr('&Import Keyboard Shortcuts...'),
 1921             0, 0, self, 'import_keyboard_shortcuts')
 1922         self.importShortcutsAct.setStatusTip(self.tr(
 1923             'Import the keyboard shortcuts'))
 1924         self.importShortcutsAct.setWhatsThis(self.tr(
 1925             """<b>Import Keyboard Shortcuts</b>"""
 1926             """<p>Import the keyboard shortcuts of the application.</p>"""
 1927         ))
 1928         self.importShortcutsAct.triggered.connect(self.__importShortcuts)
 1929         self.__actions.append(self.importShortcutsAct)
 1930         
 1931         self.showProtocolHandlerManagerAct = E5Action(
 1932             self.tr('Protocol Handler Manager'),
 1933             self.tr('Protocol Handler Manager...'),
 1934             0, 0, self, 'webbrowser_show_protocol_handler_manager')
 1935         self.showProtocolHandlerManagerAct.setStatusTip(self.tr(
 1936             'Shows the protocol handler manager window'))
 1937         self.showProtocolHandlerManagerAct.setWhatsThis(self.tr(
 1938             """<b>Protocol Handler Manager</b>"""
 1939             """<p>Shows the protocol handler manager window.</p>"""
 1940         ))
 1941         self.showProtocolHandlerManagerAct.triggered.connect(
 1942             self.__showProtocolHandlerManagerDialog)
 1943         self.__actions.append(self.showProtocolHandlerManagerAct)
 1944         
 1945         self.backAct.setEnabled(False)
 1946         self.forwardAct.setEnabled(False)
 1947         
 1948         # now read the keyboard shortcuts for the actions
 1949         Shortcuts.readShortcuts(helpViewer=self)
 1950     
 1951     def getActions(self):
 1952         """
 1953         Public method to get a list of all actions.
 1954         
 1955         @return list of all actions (list of E5Action)
 1956         """
 1957         return self.__actions[:]
 1958     
 1959     def getActionsCategory(self):
 1960         """
 1961         Public method to get the category of the defined actions.
 1962         
 1963         @return category of the actions
 1964         @rtype str
 1965         """
 1966         return "WebBrowser"
 1967     
 1968     def __initMenus(self):
 1969         """
 1970         Private method to create the menus.
 1971         """
 1972         mb = self.menuBar()
 1973         
 1974         menu = mb.addMenu(self.tr('&File'))
 1975         menu.addAction(self.newTabAct)
 1976         menu.addAction(self.newAct)
 1977         menu.addAction(self.newPrivateAct)
 1978         menu.addAction(self.openAct)
 1979         menu.addAction(self.openTabAct)
 1980         menu.addSeparator()
 1981         if not self.isPrivate():
 1982             sessionsMenu = menu.addMenu(self.tr("Sessions"))
 1983             sessionsMenu.aboutToShow.connect(
 1984                 lambda: self.sessionManager().aboutToShowSessionsMenu(
 1985                     sessionsMenu))
 1986             menu.addAction(self.showSessionsManagerAct)
 1987             menu.addSeparator()
 1988         if self.saveAsAct is not None:
 1989             menu.addAction(self.saveAsAct)
 1990         menu.addAction(self.saveVisiblePageScreenAct)
 1991         menu.addSeparator()
 1992         if self.printPreviewAct:
 1993             menu.addAction(self.printPreviewAct)
 1994         if self.printAct:
 1995             menu.addAction(self.printAct)
 1996         if self.printPdfAct:
 1997             menu.addAction(self.printPdfAct)
 1998         menu.addAction(self.sendPageLinkAct)
 1999         menu.addSeparator()
 2000         menu.addAction(self.closeAct)
 2001         menu.addAction(self.closeAllAct)
 2002         menu.addSeparator()
 2003         menu.addAction(self.exitAct)
 2004         self.addActions(menu.actions())
 2005         
 2006         menu = mb.addMenu(self.tr('&Edit'))
 2007         menu.addAction(self.undoAct)
 2008         menu.addAction(self.redoAct)
 2009         menu.addSeparator()
 2010         menu.addAction(self.copyAct)
 2011         menu.addAction(self.cutAct)
 2012         menu.addAction(self.pasteAct)
 2013         menu.addSeparator()
 2014         menu.addAction(self.selectAllAct)
 2015         menu.addAction(self.unselectAct)
 2016         menu.addSeparator()
 2017         menu.addAction(self.findAct)
 2018         menu.addAction(self.findNextAct)
 2019         menu.addAction(self.findPrevAct)
 2020         self.addActions(menu.actions())
 2021         
 2022         menu = mb.addMenu(self.tr('&View'))
 2023         menu.addAction(self.stopAct)
 2024         menu.addAction(self.reloadAct)
 2025         if WebBrowserWindow._useQtHelp:
 2026             menu.addSeparator()
 2027             menu.addAction(self.syncTocAct)
 2028         menu.addSeparator()
 2029         menu.addAction(self.zoomInAct)
 2030         menu.addAction(self.zoomResetAct)
 2031         menu.addAction(self.zoomOutAct)
 2032         menu.addSeparator()
 2033         self.__textEncodingMenu = menu.addMenu(
 2034             self.tr("Text Encoding"))
 2035         self.__textEncodingMenu.aboutToShow.connect(
 2036             self.__aboutToShowTextEncodingMenu)
 2037         self.__textEncodingMenu.triggered.connect(self.__setTextEncoding)
 2038         menu.addSeparator()
 2039         menu.addAction(self.pageSourceAct)
 2040         menu.addAction(self.fullScreenAct)
 2041         self.addActions(menu.actions())
 2042         
 2043         from .History.HistoryMenu import HistoryMenu
 2044         self.historyMenu = HistoryMenu(self, self.__tabWidget)
 2045         self.historyMenu.setTitle(self.tr('H&istory'))
 2046         self.historyMenu.openUrl.connect(self.openUrl)
 2047         self.historyMenu.newTab.connect(self.openUrlNewTab)
 2048         self.historyMenu.newBackgroundTab.connect(self.openUrlNewBackgroundTab)
 2049         self.historyMenu.newWindow.connect(self.openUrlNewWindow)
 2050         self.historyMenu.newPrivateWindow.connect(self.openUrlNewPrivateWindow)
 2051         mb.addMenu(self.historyMenu)
 2052         
 2053         historyActions = []
 2054         historyActions.append(self.backAct)
 2055         historyActions.append(self.forwardAct)
 2056         historyActions.append(self.homeAct)
 2057         self.historyMenu.setInitialActions(historyActions)
 2058         self.addActions(historyActions)
 2059         
 2060         from .Bookmarks.BookmarksMenu import BookmarksMenuBarMenu
 2061         self.bookmarksMenu = BookmarksMenuBarMenu(self)
 2062         self.bookmarksMenu.setTitle(self.tr('&Bookmarks'))
 2063         self.bookmarksMenu.openUrl.connect(self.openUrl)
 2064         self.bookmarksMenu.newTab.connect(self.openUrlNewTab)
 2065         self.bookmarksMenu.newWindow.connect(self.openUrlNewWindow)
 2066         mb.addMenu(self.bookmarksMenu)
 2067         
 2068         bookmarksActions = []
 2069         bookmarksActions.append(self.bookmarksManageAct)
 2070         bookmarksActions.append(self.bookmarksAddAct)
 2071         bookmarksActions.append(self.bookmarksAllTabsAct)
 2072         bookmarksActions.append(self.bookmarksAddFolderAct)
 2073         bookmarksActions.append("--SEPARATOR--")
 2074         bookmarksActions.append(self.importBookmarksAct)
 2075         bookmarksActions.append(self.exportBookmarksAct)
 2076         self.bookmarksMenu.setInitialActions(bookmarksActions)
 2077         
 2078         menu = mb.addMenu(self.tr('&Settings'))
 2079         menu.addAction(self.prefAct)
 2080         menu.addSeparator()
 2081         menu.addAction(self.shortcutsAct)
 2082         menu.addAction(self.exportShortcutsAct)
 2083         menu.addAction(self.importShortcutsAct)
 2084         menu.addSeparator()
 2085         menu.addAction(self.acceptedLanguagesAct)
 2086         menu.addAction(self.cookiesAct)
 2087         menu.addAction(self.flashCookiesAct)
 2088         menu.addAction(self.personalDataAct)
 2089         menu.addAction(self.greaseMonkeyAct)
 2090         menu.addAction(self.featurePermissionAct)
 2091         menu.addSeparator()
 2092         menu.addAction(self.editMessageFilterAct)
 2093         menu.addSeparator()
 2094         menu.addAction(self.searchEnginesAct)
 2095         menu.addSeparator()
 2096         menu.addAction(self.passwordsAct)
 2097         menu.addAction(self.certificateErrorsAct)
 2098         menu.addSeparator()
 2099         menu.addAction(self.zoomValuesAct)
 2100         menu.addAction(self.manageIconsAct)
 2101         menu.addSeparator()
 2102         menu.addAction(self.adblockAct)
 2103         menu.addSeparator()
 2104         menu.addAction(self.safeBrowsingAct)
 2105         menu.addSeparator()
 2106         self.__settingsMenu = menu
 2107         self.__settingsMenu.aboutToShow.connect(
 2108             self.__aboutToShowSettingsMenu)
 2109         
 2110         from .UserAgent.UserAgentMenu import UserAgentMenu
 2111         self.__userAgentMenu = UserAgentMenu(self.tr("Global User Agent"))
 2112         menu.addMenu(self.__userAgentMenu)
 2113         menu.addAction(self.userAgentManagerAct)
 2114         menu.addSeparator()
 2115         
 2116         if WebBrowserWindow._useQtHelp:
 2117             menu.addAction(self.manageQtHelpDocsAct)
 2118             menu.addAction(self.reindexDocumentationAct)
 2119             menu.addSeparator()
 2120         menu.addAction(self.clearPrivateDataAct)
 2121         menu.addAction(self.clearIconsAct)
 2122         
 2123         menu = mb.addMenu(self.tr("&Tools"))
 2124         menu.addAction(self.feedsManagerAct)
 2125         menu.addAction(self.siteInfoAct)
 2126         menu.addSeparator()
 2127         menu.addAction(self.synchronizationAct)
 2128         menu.addSeparator()
 2129         vtMenu = menu.addMenu(UI.PixmapCache.getIcon("virustotal"),
 2130                               self.tr("&VirusTotal"))
 2131         vtMenu.addAction(self.virustotalScanCurrentAct)
 2132         vtMenu.addAction(self.virustotalIpReportAct)
 2133         vtMenu.addAction(self.virustotalDomainReportAct)
 2134         
 2135         menu = mb.addMenu(self.tr("&Windows"))
 2136         menu.addAction(self.showDownloadManagerAct)
 2137         menu.addAction(self.showJavaScriptConsoleAct)
 2138         menu.addAction(self.showTabManagerAct)
 2139         menu.addAction(self.showProtocolHandlerManagerAct)
 2140         if WebBrowserWindow._useQtHelp:
 2141             menu.addSeparator()
 2142             menu.addAction(self.showTocAct)
 2143             menu.addAction(self.showIndexAct)
 2144             menu.addAction(self.showSearchAct)
 2145         menu.addSeparator()
 2146         self.__toolbarsMenu = menu.addMenu(self.tr("&Toolbars"))
 2147         self.__toolbarsMenu.aboutToShow.connect(self.__showToolbarsMenu)
 2148         self.__toolbarsMenu.triggered.connect(self.__TBMenuTriggered)
 2149         
 2150         mb.addSeparator()
 2151         
 2152         menu = mb.addMenu(self.tr('&Help'))
 2153         menu.addAction(self.aboutAct)
 2154         menu.addAction(self.aboutQtAct)
 2155         menu.addSeparator()
 2156         menu.addAction(self.whatsThisAct)
 2157         self.addActions(menu.actions())
 2158     
 2159     def __initSuperMenu(self):
 2160         """
 2161         Private method to create the super menu and attach it to the super
 2162         menu button.
 2163         """
 2164         self.__superMenu = QMenu(self)
 2165         
 2166         self.__superMenu.addAction(self.newTabAct)
 2167         self.__superMenu.addAction(self.newAct)
 2168         self.__superMenu.addAction(self.newPrivateAct)
 2169         self.__superMenu.addAction(self.openAct)
 2170         self.__superMenu.addAction(self.openTabAct)
 2171         self.__superMenu.addSeparator()
 2172         
 2173         if not self.isPrivate():
 2174             sessionsMenu = self.__superMenu.addMenu(self.tr("Sessions"))
 2175             sessionsMenu.aboutToShow.connect(
 2176                 lambda: self.sessionManager().aboutToShowSessionsMenu(
 2177                     sessionsMenu))
 2178             self.__superMenu.addAction(self.showSessionsManagerAct)
 2179             self.__superMenu.addSeparator()
 2180         
 2181         menu = self.__superMenu.addMenu(self.tr("Save"))
 2182         if self.saveAsAct:
 2183             menu.addAction(self.saveAsAct)
 2184         menu.addAction(self.saveVisiblePageScreenAct)
 2185         
 2186         if self.printPreviewAct or self.printAct or self.printPdfAct:
 2187             menu = self.__superMenu.addMenu(self.tr("Print"))
 2188             if self.printPreviewAct:
 2189                 menu.addAction(self.printPreviewAct)
 2190             if self.printAct:
 2191                 menu.addAction(self.printAct)
 2192             if self.printPdfAct:
 2193                 menu.addAction(self.printPdfAct)
 2194         
 2195         self.__superMenu.addAction(self.sendPageLinkAct)
 2196         self.__superMenu.addSeparator()
 2197         self.__superMenu.addAction(self.selectAllAct)
 2198         self.__superMenu.addAction(self.findAct)
 2199         self.__superMenu.addSeparator()
 2200         act = self.__superMenu.addAction(UI.PixmapCache.getIcon("history"),
 2201                                          self.tr("Show All History..."))
 2202         act.triggered.connect(self.historyMenu.showHistoryDialog)
 2203         self.__superMenu.addAction(self.bookmarksManageAct)
 2204         self.__superMenu.addSeparator()
 2205         self.__superMenu.addAction(self.prefAct)
 2206         
 2207         menu = self.__superMenu.addMenu(self.tr('Settings'))
 2208         menu.addAction(self.shortcutsAct)
 2209         menu.addAction(self.exportShortcutsAct)
 2210         menu.addAction(self.importShortcutsAct)
 2211         menu.addSeparator()
 2212         menu.addAction(self.acceptedLanguagesAct)
 2213         menu.addAction(self.cookiesAct)
 2214         menu.addAction(self.flashCookiesAct)
 2215         menu.addAction(self.personalDataAct)
 2216         menu.addAction(self.greaseMonkeyAct)
 2217         menu.addAction(self.featurePermissionAct)
 2218         menu.addSeparator()
 2219         menu.addAction(self.editMessageFilterAct)
 2220         menu.addSeparator()
 2221         menu.addAction(self.searchEnginesAct)
 2222         menu.addSeparator()
 2223         menu.addAction(self.passwordsAct)
 2224         menu.addAction(self.certificateErrorsAct)
 2225         menu.addSeparator()
 2226         menu.addAction(self.zoomValuesAct)
 2227         menu.addAction(self.manageIconsAct)
 2228         menu.addSeparator()
 2229         menu.addAction(self.adblockAct)
 2230         menu.addSeparator()
 2231         menu.addAction(self.safeBrowsingAct)
 2232         menu.addSeparator()
 2233         menu.addMenu(self.__userAgentMenu)
 2234         menu.addAction(self.userAgentManagerAct)
 2235         menu.addSeparator()
 2236         if WebBrowserWindow._useQtHelp:
 2237             menu.addAction(self.manageQtHelpDocsAct)
 2238             menu.addAction(self.reindexDocumentationAct)
 2239             menu.addSeparator()
 2240         menu.addAction(self.clearPrivateDataAct)
 2241         menu.addAction(self.clearIconsAct)
 2242         menu.aboutToShow.connect(
 2243             self.__aboutToShowSettingsMenu)
 2244 
 2245         self.__superMenu.addSeparator()
 2246         
 2247         menu = self.__superMenu.addMenu(self.tr('&View'))
 2248         menu.addMenu(self.__toolbarsMenu)
 2249         windowsMenu = menu.addMenu(self.tr("&Windows"))
 2250         windowsMenu.addAction(self.showDownloadManagerAct)
 2251         windowsMenu.addAction(self.showJavaScriptConsoleAct)
 2252         windowsMenu.addAction(self.showTabManagerAct)
 2253         windowsMenu.addAction(self.showProtocolHandlerManagerAct)
 2254         if WebBrowserWindow._useQtHelp:
 2255             windowsMenu.addSeparator()
 2256             windowsMenu.addAction(self.showTocAct)
 2257             windowsMenu.addAction(self.showIndexAct)
 2258             windowsMenu.addAction(self.showSearchAct)
 2259         menu.addSeparator()
 2260         menu.addAction(self.stopAct)
 2261         menu.addAction(self.reloadAct)
 2262         if WebBrowserWindow._useQtHelp:
 2263             menu.addSeparator()
 2264             menu.addAction(self.syncTocAct)
 2265         menu.addSeparator()
 2266         menu.addAction(self.zoomInAct)
 2267         menu.addAction(self.zoomResetAct)
 2268         menu.addAction(self.zoomOutAct)
 2269         menu.addSeparator()
 2270         menu.addMenu(self.__textEncodingMenu)
 2271         menu.addSeparator()
 2272         menu.addAction(self.pageSourceAct)
 2273         menu.addAction(self.fullScreenAct)
 2274         
 2275         self.__superMenu.addMenu(self.historyMenu)
 2276         self.__superMenu.addMenu(self.bookmarksMenu)
 2277         
 2278         menu = self.__superMenu.addMenu(self.tr("&Tools"))
 2279         menu.addAction(self.feedsManagerAct)
 2280         menu.addAction(self.siteInfoAct)
 2281         menu.addSeparator()
 2282         menu.addAction(self.synchronizationAct)
 2283         menu.addSeparator()
 2284         vtMenu = menu.addMenu(UI.PixmapCache.getIcon("virustotal"),
 2285                               self.tr("&VirusTotal"))
 2286         vtMenu.addAction(self.virustotalScanCurrentAct)
 2287         vtMenu.addAction(self.virustotalIpReportAct)
 2288         vtMenu.addAction(self.virustotalDomainReportAct)
 2289         
 2290         self.__superMenu.addSeparator()
 2291         self.__superMenu.addAction(self.aboutAct)
 2292         self.__superMenu.addAction(self.aboutQtAct)
 2293         self.__superMenu.addSeparator()
 2294         self.__superMenu.addAction(self.exitAct)
 2295         
 2296         self.__navigationBar.superMenuButton().setMenu(self.__superMenu)
 2297     
 2298     def __initToolbars(self):
 2299         """
 2300         Private method to create the toolbars.
 2301         """
 2302         filetb = self.addToolBar(self.tr("File"))
 2303         filetb.setObjectName("FileToolBar")
 2304         filetb.setIconSize(UI.Config.ToolBarIconSize)
 2305         filetb.addAction(self.newTabAct)
 2306         filetb.addAction(self.newAct)
 2307         filetb.addAction(self.newPrivateAct)
 2308         filetb.addAction(self.openAct)
 2309         filetb.addAction(self.openTabAct)
 2310         filetb.addSeparator()
 2311         if self.saveAsAct is not None:
 2312             filetb.addAction(self.saveAsAct)
 2313         filetb.addAction(self.saveVisiblePageScreenAct)
 2314         filetb.addSeparator()
 2315         if self.printPreviewAct:
 2316             filetb.addAction(self.printPreviewAct)
 2317         if self.printAct:
 2318             filetb.addAction(self.printAct)
 2319         if self.printPdfAct:
 2320             filetb.addAction(self.printPdfAct)
 2321         if self.printPreviewAct or self.printAct or self.printPdfAct:
 2322             filetb.addSeparator()
 2323         filetb.addAction(self.closeAct)
 2324         filetb.addAction(self.exitAct)
 2325         self.__toolbars["file"] = (filetb.windowTitle(), filetb)
 2326         
 2327         edittb = self.addToolBar(self.tr("Edit"))
 2328         edittb.setObjectName("EditToolBar")
 2329         edittb.setIconSize(UI.Config.ToolBarIconSize)
 2330         edittb.addAction(self.undoAct)
 2331         edittb.addAction(self.redoAct)
 2332         edittb.addSeparator()
 2333         edittb.addAction(self.copyAct)
 2334         edittb.addAction(self.cutAct)
 2335         edittb.addAction(self.pasteAct)
 2336         edittb.addSeparator()
 2337         edittb.addAction(self.selectAllAct)
 2338         self.__toolbars["edit"] = (edittb.windowTitle(), edittb)
 2339         
 2340         viewtb = self.addToolBar(self.tr("View"))
 2341         viewtb.setObjectName("ViewToolBar")
 2342         viewtb.setIconSize(UI.Config.ToolBarIconSize)
 2343         viewtb.addAction(self.zoomInAct)
 2344         viewtb.addAction(self.zoomResetAct)
 2345         viewtb.addAction(self.zoomOutAct)
 2346         viewtb.addSeparator()
 2347         viewtb.addAction(self.fullScreenAct)
 2348         self.__toolbars["view"] = (viewtb.windowTitle(), viewtb)
 2349         
 2350         findtb = self.addToolBar(self.tr("Find"))
 2351         findtb.setObjectName("FindToolBar")
 2352         findtb.setIconSize(UI.Config.ToolBarIconSize)
 2353         findtb.addAction(self.findAct)
 2354         findtb.addAction(self.findNextAct)
 2355         findtb.addAction(self.findPrevAct)
 2356         self.__toolbars["find"] = (findtb.windowTitle(), findtb)
 2357         
 2358         if WebBrowserWindow._useQtHelp:
 2359             filtertb = self.addToolBar(self.tr("Filter"))
 2360             filtertb.setObjectName("FilterToolBar")
 2361             self.filterCombo = QComboBox()
 2362             try:
 2363                 comboWidth = QFontMetrics(QFont()).horizontalAdvance(
 2364                     "ComboBoxWithEnoughWidth")
 2365             except AttributeError:
 2366                 comboWidth = QFontMetrics(QFont()).width(
 2367                     "ComboBoxWithEnoughWidth")
 2368             self.filterCombo.setMinimumWidth(comboWidth)
 2369             filtertb.addWidget(QLabel(self.tr("Filtered by: ")))
 2370             filtertb.addWidget(self.filterCombo)
 2371             self.__helpEngine.setupFinished.connect(self.__setupFilterCombo)
 2372             self.filterCombo.activated[str].connect(
 2373                 self.__filterQtHelpDocumentation)
 2374             self.__setupFilterCombo()
 2375             self.__toolbars["filter"] = (filtertb.windowTitle(), filtertb)
 2376         
 2377         settingstb = self.addToolBar(self.tr("Settings"))
 2378         settingstb.setObjectName("SettingsToolBar")
 2379         settingstb.setIconSize(UI.Config.ToolBarIconSize)
 2380         settingstb.addAction(self.prefAct)
 2381         settingstb.addAction(self.shortcutsAct)
 2382         settingstb.addAction(self.acceptedLanguagesAct)
 2383         settingstb.addAction(self.cookiesAct)
 2384         settingstb.addAction(self.flashCookiesAct)
 2385         settingstb.addAction(self.personalDataAct)
 2386         settingstb.addAction(self.greaseMonkeyAct)
 2387         settingstb.addAction(self.featurePermissionAct)
 2388         self.__toolbars["settings"] = (settingstb.windowTitle(), settingstb)
 2389         
 2390         toolstb = self.addToolBar(self.tr("Tools"))
 2391         toolstb.setObjectName("ToolsToolBar")
 2392         toolstb.setIconSize(UI.Config.ToolBarIconSize)
 2393         toolstb.addAction(self.feedsManagerAct)
 2394         toolstb.addAction(self.siteInfoAct)
 2395         toolstb.addSeparator()
 2396         toolstb.addAction(self.synchronizationAct)
 2397         self.__toolbars["tools"] = (toolstb.windowTitle(), toolstb)
 2398         
 2399         helptb = self.addToolBar(self.tr("Help"))
 2400         helptb.setObjectName("HelpToolBar")
 2401         helptb.setIconSize(UI.Config.ToolBarIconSize)
 2402         helptb.addAction(self.whatsThisAct)
 2403         self.__toolbars["help"] = (helptb.windowTitle(), helptb)
 2404         
 2405         self.addToolBarBreak()
 2406         vttb = self.addToolBar(self.tr("VirusTotal"))
 2407         vttb.setObjectName("VirusTotalToolBar")
 2408         vttb.setIconSize(UI.Config.ToolBarIconSize)
 2409         vttb.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
 2410         vttb.addAction(self.virustotalScanCurrentAct)
 2411         vttb.addAction(self.virustotalIpReportAct)
 2412         vttb.addAction(self.virustotalDomainReportAct)
 2413         self.__toolbars["virustotal"] = (vttb.windowTitle(), vttb)
 2414         
 2415     def __nextTab(self):
 2416         """
 2417         Private slot used to show the next tab.
 2418         """
 2419         fwidget = QApplication.focusWidget()
 2420         while fwidget and not hasattr(fwidget, 'nextTab'):
 2421             fwidget = fwidget.parent()
 2422         if fwidget:
 2423             fwidget.nextTab()
 2424         
 2425     def __prevTab(self):
 2426         """
 2427         Private slot used to show the previous tab.
 2428         """
 2429         fwidget = QApplication.focusWidget()
 2430         while fwidget and not hasattr(fwidget, 'prevTab'):
 2431             fwidget = fwidget.parent()
 2432         if fwidget:
 2433             fwidget.prevTab()
 2434         
 2435     def __switchTab(self):
 2436         """
 2437         Private slot used to switch between the current and the previous
 2438         current tab.
 2439         """
 2440         fwidget = QApplication.focusWidget()
 2441         while fwidget and not hasattr(fwidget, 'switchTab'):
 2442             fwidget = fwidget.parent()
 2443         if fwidget:
 2444             fwidget.switchTab()
 2445         
 2446     def __whatsThis(self):
 2447         """
 2448         Private slot called in to enter Whats This mode.
 2449         """
 2450         QWhatsThis.enterWhatsThisMode()
 2451         
 2452     def __titleChanged(self, browser, title):
 2453         """
 2454         Private slot called to handle a change of a browser's title.
 2455         
 2456         @param browser reference to the browser (WebBrowserView)
 2457         @param title new title (string)
 2458         """
 2459         self.historyManager().updateHistoryEntry(
 2460             browser.url().toString(), title)
 2461     
 2462     @pyqtSlot()
 2463     def newTab(self, link=None, addNextTo=None, background=False):
 2464         """
 2465         Public slot called to open a new web browser tab.
 2466         
 2467         @param link file to be displayed in the new window (string or QUrl)
 2468         @param addNextTo reference to the browser to open the tab after
 2469             (WebBrowserView)
 2470         @keyparam background flag indicating to open the tab in the
 2471             background (bool)
 2472         @return reference to the new browser
 2473         @rtype WebBrowserView
 2474         """
 2475         if addNextTo:
 2476             return self.__tabWidget.newBrowserAfter(
 2477                 addNextTo, link, background=background)
 2478         else:
 2479             return self.__tabWidget.newBrowser(link, background=background)
 2480     
 2481     @pyqtSlot()
 2482     def newWindow(self, link=None, restoreSession=False):
 2483         """
 2484         Public slot called to open a new web browser window.
 2485         
 2486         @param link URL to be displayed in the new window
 2487         @type str or QUrl
 2488         @param restoreSession flag indicating a restore session action
 2489         @type bool
 2490         @return reference to the new window
 2491         @rtype WebBrowserWindow
 2492         """
 2493         if link is None:
 2494             linkName = ""
 2495         elif isinstance(link, QUrl):
 2496             linkName = link.toString()
 2497         else:
 2498             linkName = link
 2499         h = WebBrowserWindow(linkName, ".", self.parent(), "webbrowser",
 2500                              private=self.isPrivate(),
 2501                              restoreSession=restoreSession)
 2502         h.show()
 2503         
 2504         self.webBrowserWindowOpened.emit(h)
 2505         
 2506         return h
 2507     
 2508     @pyqtSlot()
 2509     def newPrivateWindow(self, link=None):
 2510         """
 2511         Public slot called to open a new private web browser window.
 2512         
 2513         @param link URL to be displayed in the new window
 2514         @type str or QUrl
 2515         """
 2516         if link is None:
 2517             linkName = ""
 2518         elif isinstance(link, QUrl):
 2519             linkName = link.toString()
 2520         else:
 2521             linkName = link
 2522         
 2523         applPath = os.path.join(getConfig("ericDir"), "eric6_browser.py")
 2524         args = []
 2525         args.append(applPath)
 2526         args.append("--config={0}".format(Utilities.getConfigDir()))
 2527         if self.__settingsDir:
 2528             args.append("--settings={0}".format(self.__settingsDir))
 2529         args.append("--private")
 2530         if linkName:
 2531             args.append(linkName)
 2532         
 2533         if (
 2534             not os.path.isfile(applPath) or
 2535             not QProcess.startDetached(sys.executable, args)
 2536         ):
 2537             E5MessageBox.critical(
 2538                 self,
 2539                 self.tr('New Private Window'),
 2540                 self.tr(
 2541                     '<p>Could not start the process.<br>'
 2542                     'Ensure that it is available as <b>{0}</b>.</p>'
 2543                 ).format(applPath),
 2544                 self.tr('OK'))
 2545     
 2546     def __openFile(self):
 2547         """
 2548         Private slot called to open a file.
 2549         """
 2550         fn = E5FileDialog.getOpenFileName(
 2551             self,
 2552             self.tr("Open File"),
 2553             "",
 2554             self.tr("HTML Files (*.html *.htm *.mhtml *.mht);;"
 2555                     "PDF Files (*.pdf);;"
 2556                     "CHM Files (*.chm);;"
 2557                     "All Files (*)"
 2558                     ))
 2559         if fn:
 2560             if Utilities.isWindowsPlatform():
 2561                 url = "file:///" + Utilities.fromNativeSeparators(fn)
 2562             else:
 2563                 url = "file://" + fn
 2564             self.currentBrowser().setSource(QUrl(url))
 2565         
 2566     def __openFileNewTab(self):
 2567         """
 2568         Private slot called to open a file in a new tab.
 2569         """
 2570         fn = E5FileDialog.getOpenFileName(
 2571             self,
 2572             self.tr("Open File"),
 2573             "",
 2574             self.tr("HTML Files (*.html *.htm *.mhtml *.mht);;"
 2575                     "PDF Files (*.pdf);;"
 2576                     "CHM Files (*.chm);;"
 2577                     "All Files (*)"
 2578                     ))
 2579         if fn:
 2580             if Utilities.isWindowsPlatform():
 2581                 url = "file:///" + Utilities.fromNativeSeparators(fn)
 2582             else:
 2583                 url = "file://" + fn
 2584             self.newTab(url)
 2585         
 2586     def __savePageAs(self):
 2587         """
 2588         Private slot to save the current page.
 2589         """
 2590         browser = self.currentBrowser()
 2591         if browser is not None:
 2592             browser.saveAs()
 2593     
 2594     @pyqtSlot()
 2595     def __saveVisiblePageScreen(self):
 2596         """
 2597         Private slot to save the visible part of the current page as a screen
 2598         shot.
 2599         """
 2600         from .PageScreenDialog import PageScreenDialog
 2601         self.__pageScreen = PageScreenDialog(self.currentBrowser())
 2602         self.__pageScreen.show()
 2603         
 2604     def __about(self):
 2605         """
 2606         Private slot to show the about information.
 2607         """
 2608         chromeVersion, webengineVersion = (
 2609             WebBrowserTools.getWebEngineVersions()
 2610         )
 2611         E5MessageBox.about(
 2612             self,
 2613             self.tr("eric6 Web Browser"),
 2614             self.tr(
 2615                 """<b>eric6 Web Browser - {0}</b>"""
 2616                 """<p>The eric6 Web Browser is a combined help file and HTML"""
 2617                 """ browser. It is part of the eric6 development"""
 2618                 """ toolset.</p>"""
 2619                 """<p>It is based on QtWebEngine {1} and Chrome {2}.</p>"""
 2620             ).format(Version, webengineVersion, chromeVersion))
 2621         
 2622     def __aboutQt(self):
 2623         """
 2624         Private slot to show info about Qt.
 2625         """
 2626         E5MessageBox.aboutQt(self, self.tr("eric6 Web Browser"))
 2627 
 2628     def setBackwardAvailable(self, b):
 2629         """
 2630         Public slot called when backward references are available.
 2631         
 2632         @param b flag indicating availability of the backwards action (boolean)
 2633         """
 2634         self.backAct.setEnabled(b)
 2635         self.__navigationBar.backButton().setEnabled(b)
 2636         
 2637     def setForwardAvailable(self, b):
 2638         """
 2639         Public slot called when forward references are available.
 2640         
 2641         @param b flag indicating the availability of the forwards action
 2642             (boolean)
 2643         """
 2644         self.forwardAct.setEnabled(b)
 2645         self.__navigationBar.forwardButton().setEnabled(b)
 2646         
 2647     def setLoadingActions(self, b):
 2648         """
 2649         Public slot to set the loading dependent actions.
 2650         
 2651         @param b flag indicating the loading state to consider (boolean)
 2652         """
 2653         self.reloadAct.setEnabled(not b)
 2654         self.stopAct.setEnabled(b)
 2655         
 2656         self.__navigationBar.reloadStopButton().setLoading(b)
 2657         
 2658     def __addBookmark(self):
 2659         """
 2660         Private slot called to add the displayed file to the bookmarks.
 2661         """
 2662         from .WebBrowserPage import WebBrowserPage
 2663         
 2664         view = self.currentBrowser()
 2665         view.addBookmark()
 2666         urlStr = bytes(view.url().toEncoded()).decode()
 2667         title = view.title()
 2668         
 2669         script = Scripts.getAllMetaAttributes()
 2670         view.page().runJavaScript(
 2671             script,
 2672             WebBrowserPage.SafeJsWorld,
 2673             lambda res: self.__addBookmarkCallback(urlStr, title, res))
 2674     
 2675     def __addBookmarkCallback(self, url, title, res):
 2676         """
 2677         Private callback method of __addBookmark().
 2678         
 2679         @param url URL for the bookmark
 2680         @type str
 2681         @param title title for the bookmark
 2682         @type str
 2683         @param res result of the JavaScript
 2684         @type list
 2685         """
 2686         description = ""
 2687         for meta in res:
 2688             if meta["name"] == "description":
 2689                 description = meta["content"]
 2690         
 2691         from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog
 2692         dlg = AddBookmarkDialog()
 2693         dlg.setUrl(url)
 2694         dlg.setTitle(title)
 2695         dlg.setDescription(description)
 2696         menu = self.bookmarksManager().menu()
 2697         idx = self.bookmarksManager().bookmarksModel().nodeIndex(menu)
 2698         dlg.setCurrentIndex(idx)
 2699         dlg.exec_()
 2700         
 2701     def __addBookmarkFolder(self):
 2702         """
 2703         Private slot to add a new bookmarks folder.
 2704         """
 2705         from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog
 2706         dlg = AddBookmarkDialog()
 2707         menu = self.bookmarksManager().menu()
 2708         idx = self.bookmarksManager().bookmarksModel().nodeIndex(menu)
 2709         dlg.setCurrentIndex(idx)
 2710         dlg.setFolder(True)
 2711         dlg.exec_()
 2712         
 2713     def __showBookmarksDialog(self):
 2714         """
 2715         Private slot to show the bookmarks dialog.
 2716         """
 2717         from .Bookmarks.BookmarksDialog import BookmarksDialog
 2718         self.__bookmarksDialog = BookmarksDialog(self)
 2719         self.__bookmarksDialog.openUrl.connect(self.openUrl)
 2720         self.__bookmarksDialog.newTab.connect(self.openUrlNewTab)
 2721         self.__bookmarksDialog.newBackgroundTab.connect(
 2722             self.openUrlNewBackgroundTab)
 2723         self.__bookmarksDialog.show()
 2724         
 2725     def bookmarkAll(self):
 2726         """
 2727         Public slot to bookmark all open tabs.
 2728         """
 2729         from .WebBrowserPage import WebBrowserPage
 2730         from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog
 2731         
 2732         dlg = AddBookmarkDialog()
 2733         dlg.setFolder(True)
 2734         dlg.setTitle(self.tr("Saved Tabs"))
 2735         dlg.exec_()
 2736         
 2737         folder = dlg.addedNode()
 2738         if folder is None:
 2739             return
 2740         
 2741         for view in self.__tabWidget.browsers():
 2742             urlStr = bytes(view.url().toEncoded()).decode()
 2743             title = view.title()
 2744             
 2745             script = Scripts.getAllMetaAttributes()
 2746             view.page().runJavaScript(
 2747                 script,
 2748                 WebBrowserPage.SafeJsWorld,
 2749                 lambda res: self.__bookmarkAllCallback(folder, urlStr,
 2750                                                        title, res))
 2751     
 2752     def __bookmarkAllCallback(self, folder, url, title, res):
 2753         """
 2754         Private callback method of __addBookmark().
 2755         
 2756         @param folder reference to the bookmarks folder
 2757         @type BookmarkNode
 2758         @param url URL for the bookmark
 2759         @type str
 2760         @param title title for the bookmark
 2761         @type str
 2762         @param res result of the JavaScript
 2763         @type list
 2764         """
 2765         description = ""
 2766         for meta in res:
 2767             if meta["name"] == "description":
 2768                 description = meta["content"]
 2769         
 2770         from .Bookmarks.BookmarkNode import BookmarkNode
 2771         bookmark = BookmarkNode(BookmarkNode.Bookmark)
 2772         bookmark.url = url
 2773         bookmark.title = title
 2774         bookmark.desc = description
 2775         
 2776         self.bookmarksManager().addBookmark(folder, bookmark)
 2777         
 2778     def __find(self):
 2779         """
 2780         Private slot to handle the find action.
 2781         
 2782         It opens the search dialog in order to perform the various
 2783         search actions and to collect the various search info.
 2784         """
 2785         self.__searchWidget.showFind()
 2786         
 2787     def forceClose(self):
 2788         """
 2789         Public method to force closing the window.
 2790         """
 2791         self.__forcedClose = True
 2792         self.close()
 2793     
 2794     def closeEvent(self, e):
 2795         """
 2796         Protected event handler for the close event.
 2797         
 2798         @param e the close event (QCloseEvent)
 2799             <br />This event is simply accepted after the history has been
 2800             saved and all window references have been deleted.
 2801         """
 2802         res = self.__shutdownWindow()
 2803         
 2804         if res:
 2805             e.accept()
 2806             self.webBrowserWindowClosed.emit(self)
 2807         else:
 2808             e.ignore()
 2809     
 2810     def isClosing(self):
 2811         """
 2812         Public method to test, if the window is closing.
 2813         
 2814         @return flag indicating that the window is closing
 2815         @rtype bool
 2816         """
 2817         return self.__isClosing
 2818     
 2819     def __shutdownWindow(self):
 2820         """
 2821         Private method to shut down a web browser window.
 2822         
 2823         @return flag indicating successful shutdown (boolean)
 2824         """
 2825         if not WebBrowserWindow._performingShutdown and not self.__forcedClose:
 2826             if not self.__tabWidget.shallShutDown():
 2827                 return False
 2828         
 2829         self.__isClosing = True
 2830         
 2831         if (
 2832             not WebBrowserWindow._performingShutdown and
 2833             len(WebBrowserWindow.BrowserWindows) == 1 and
 2834             not WebBrowserWindow.isPrivate()
 2835         ):
 2836             # shut down the session manager in case the last window is
 2837             # about to be closed
 2838             self.sessionManager().shutdown()
 2839         
 2840         self.__bookmarksToolBar.setModel(None)
 2841         
 2842         self.__virusTotal.close()
 2843         
 2844         self.__navigationBar.searchEdit().openSearchManager().close()
 2845         
 2846         if WebBrowserWindow._useQtHelp:
 2847             self.__searchEngine.cancelIndexing()
 2848             self.__searchEngine.cancelSearching()
 2849             
 2850             if self.__helpInstaller:
 2851                 self.__helpInstaller.stop()
 2852         
 2853         self.__navigationBar.searchEdit().saveSearches()
 2854         
 2855         self.__tabWidget.closeAllBrowsers(shutdown=True)
 2856         
 2857         state = self.saveState()
 2858         Preferences.setWebBrowser("WebBrowserState", state)
 2859 
 2860         if Preferences.getWebBrowser("SaveGeometry"):
 2861             if not self.isFullScreen():
 2862                 Preferences.setGeometry("WebBrowserGeometry",
 2863                                         self.saveGeometry())
 2864         else:
 2865             Preferences.setGeometry("WebBrowserGeometry", QByteArray())
 2866         
 2867         try:
 2868             browserIndex = WebBrowserWindow.BrowserWindows.index(self)
 2869             if len(WebBrowserWindow.BrowserWindows):
 2870                 if browserIndex == 0:
 2871                     if len(WebBrowserWindow.BrowserWindows) > 1:
 2872                         # first window will be deleted
 2873                         QDesktopServices.setUrlHandler(
 2874                             "http",
 2875                             WebBrowserWindow.BrowserWindows[1].urlHandler)
 2876                         QDesktopServices.setUrlHandler(
 2877                             "https",
 2878                             WebBrowserWindow.BrowserWindows[1].urlHandler)
 2879                     else:
 2880                         QDesktopServices.unsetUrlHandler("http")
 2881                         QDesktopServices.unsetUrlHandler("https")
 2882             if len(WebBrowserWindow.BrowserWindows) > 0:
 2883                 del WebBrowserWindow.BrowserWindows[browserIndex]
 2884         except ValueError:
 2885             pass
 2886         
 2887         Preferences.syncPreferences()
 2888         if (
 2889             not WebBrowserWindow._performingShutdown and
 2890             len(WebBrowserWindow.BrowserWindows) == 0
 2891         ):
 2892             # shut down the browser in case the last window was
 2893             # simply closed
 2894             self.shutdown()
 2895         
 2896         return True
 2897     
 2898     def __shallShutDown(self):
 2899         """
 2900         Private method to check, if the application should be shut down.
 2901         
 2902         @return flag indicating a shut down
 2903         @rtype bool
 2904         """
 2905         if Preferences.getWebBrowser("WarnOnMultipleClose"):
 2906             windowCount = len(WebBrowserWindow.BrowserWindows)
 2907             tabCount = 0
 2908             for browser in WebBrowserWindow.BrowserWindows:
 2909                 tabCount += browser.tabWidget().count()
 2910             
 2911             if windowCount > 1 or tabCount > 1:
 2912                 mb = E5MessageBox.E5MessageBox(
 2913                     E5MessageBox.Information,
 2914                     self.tr("Are you sure you want to close the web browser?"),
 2915                     self.tr("""Are you sure you want to close the web"""
 2916                             """ browser?\n"""
 2917                             """You have {0} windows with {1} tabs open.""")
 2918                     .format(windowCount, tabCount),
 2919                     modal=True,
 2920                     parent=self)
 2921                 quitButton = mb.addButton(
 2922                     self.tr("&Quit"), E5MessageBox.AcceptRole)
 2923                 quitButton.setIcon(UI.PixmapCache.getIcon("exit"))
 2924                 mb.addButton(E5MessageBox.Cancel)
 2925                 mb.exec_()
 2926                 return mb.clickedButton() == quitButton
 2927         
 2928         return True
 2929     
 2930     def shutdown(self):
 2931         """
 2932         Public method to shut down the web browser.
 2933         
 2934         @return flag indicating successful shutdown (boolean)
 2935         """
 2936         if not self.__shallShutDown():
 2937             return False
 2938         
 2939         if (
 2940             WebBrowserWindow._downloadManager is not None and
 2941             not self.downloadManager().allowQuit()
 2942         ):
 2943             return False
 2944         
 2945         WebBrowserWindow._performingShutdown = True
 2946         
 2947         if not WebBrowserWindow.isPrivate():
 2948             self.sessionManager().shutdown()
 2949         
 2950         if WebBrowserWindow._downloadManager is not None:
 2951             self.downloadManager().shutdown()
 2952         
 2953         self.cookieJar().close()
 2954         
 2955         self.bookmarksManager().close()
 2956         
 2957         self.historyManager().close()
 2958         
 2959         self.passwordManager().close()
 2960         
 2961         self.adBlockManager().close()
 2962         
 2963         self.userAgentsManager().close()
 2964         
 2965         self.speedDial().close()
 2966         
 2967         self.syncManager().close()
 2968         
 2969         ZoomManager.instance().close()
 2970         
 2971         WebIconProvider.instance().close()
 2972         
 2973         self.flashCookieManager().shutdown()
 2974         
 2975         if len(WebBrowserWindow.BrowserWindows) == 1:
 2976             # it is the last window
 2977             self.tabManager().close()
 2978         
 2979         self.networkManager().shutdown()
 2980         
 2981         if WebBrowserWindow._safeBrowsingManager:
 2982             self.safeBrowsingManager().close()
 2983         
 2984         for browser in WebBrowserWindow.BrowserWindows:
 2985             if browser != self:
 2986                 browser.close()
 2987         self.close()
 2988         
 2989         return True
 2990 
 2991     def __backward(self):
 2992         """
 2993         Private slot called to handle the backward action.
 2994         """
 2995         self.currentBrowser().backward()
 2996     
 2997     def __forward(self):
 2998         """
 2999         Private slot called to handle the forward action.
 3000         """
 3001         self.currentBrowser().forward()
 3002     
 3003     def __home(self):
 3004         """
 3005         Private slot called to handle the home action.
 3006         """
 3007         self.currentBrowser().home()
 3008     
 3009     def __reload(self):
 3010         """
 3011         Private slot called to handle the reload action.
 3012         """
 3013         self.currentBrowser().reloadBypassingCache()
 3014     
 3015     def __stopLoading(self):
 3016         """
 3017         Private slot called to handle loading of the current page.
 3018         """
 3019         self.currentBrowser().stop()
 3020     
 3021     def __zoomValueChanged(self, value):
 3022         """
 3023         Private slot to handle value changes of the zoom widget.
 3024         
 3025         @param value zoom value (integer)
 3026         """
 3027         self.currentBrowser().setZoomValue(value)
 3028     
 3029     def __zoomIn(self):
 3030         """
 3031         Private slot called to handle the zoom in action.
 3032         """
 3033         self.currentBrowser().zoomIn()
 3034         self.__zoomWidget.setValue(self.currentBrowser().zoomValue())
 3035     
 3036     def __zoomOut(self):
 3037         """
 3038         Private slot called to handle the zoom out action.
 3039         """
 3040         self.currentBrowser().zoomOut()
 3041         self.__zoomWidget.setValue(self.currentBrowser().zoomValue())
 3042     
 3043     def __zoomReset(self):
 3044         """
 3045         Private slot called to handle the zoom reset action.
 3046         """
 3047         self.currentBrowser().zoomReset()
 3048         self.__zoomWidget.setValue(self.currentBrowser().zoomValue())
 3049     
 3050     def toggleFullScreen(self):
 3051         """
 3052         Public slot called to toggle the full screen mode.
 3053         """
 3054         if self.__htmlFullScreen:
 3055             self.currentBrowser().triggerPageAction(
 3056                 QWebEnginePage.ExitFullScreen)
 3057             return
 3058         
 3059         if self.isFullScreen():
 3060             # switch back to normal
 3061             self.showNormal()
 3062         else:
 3063             # switch to full screen
 3064             self.showFullScreen()
 3065     
 3066     def enterHtmlFullScreen(self):
 3067         """
 3068         Public method to switch to full screen initiated by the
 3069         HTML page.
 3070         """
 3071         self.showFullScreen()
 3072         self.__htmlFullScreen = True
 3073     
 3074     def isFullScreenNavigationVisible(self):
 3075         """
 3076         Public method to check, if full screen navigation is active.
 3077         
 3078         @return flag indicating visibility of the navigation container in full
 3079             screen mode
 3080         @rtype bool
 3081         """
 3082         return self.isFullScreen() and self.__navigationContainer.isVisible()
 3083     
 3084     def showFullScreenNavigation(self):
 3085         """
 3086         Public slot to show full screen navigation.
 3087         """
 3088         if self.__htmlFullScreen:
 3089             return
 3090         
 3091         if self.__hideNavigationTimer.isActive():
 3092             self.__hideNavigationTimer.stop()
 3093         
 3094         self.__navigationContainer.show()
 3095         self.__tabWidget.tabBar().show()
 3096     
 3097     def hideFullScreenNavigation(self):
 3098         """
 3099         Public slot to hide full screen navigation.
 3100         """
 3101         if not self.__hideNavigationTimer.isActive():
 3102             self.__hideNavigationTimer.start()
 3103     
 3104     def __hideNavigation(self):
 3105         """
 3106         Private slot to hide full screen navigation by timer.
 3107         """
 3108         browser = self.currentBrowser()
 3109         mouseInBrowser = browser and browser.underMouse()
 3110         
 3111         if self.isFullScreen() and mouseInBrowser:
 3112             self.__navigationContainer.hide()
 3113             self.__tabWidget.tabBar().hide()
 3114     
 3115     def __copy(self):
 3116         """
 3117         Private slot called to handle the copy action.
 3118         """
 3119         self.currentBrowser().copy()
 3120     
 3121     def __cut(self):
 3122         """
 3123         Private slot called to handle the cut action.
 3124         """
 3125         self.currentBrowser().cut()
 3126     
 3127     def __paste(self):
 3128         """
 3129         Private slot called to handle the paste action.
 3130         """
 3131         self.currentBrowser().paste()
 3132     
 3133     def __undo(self):
 3134         """
 3135         Private slot to handle the undo action.
 3136         """
 3137         self.currentBrowser().undo()
 3138     
 3139     def __redo(self):
 3140         """
 3141         Private slot to handle the redo action.
 3142         """
 3143         self.currentBrowser().redo()
 3144     
 3145     def __selectAll(self):
 3146         """
 3147         Private slot to handle the select all action.
 3148         """
 3149         self.currentBrowser().selectAll()
 3150     
 3151     def __unselect(self):
 3152         """
 3153         Private slot to clear the selection of the current browser.
 3154         """
 3155         self.currentBrowser().unselect()
 3156     
 3157     @classmethod
 3158     def isPrivate(cls):
 3159         """
 3160         Class method to check the private browsing mode.
 3161         
 3162         @return flag indicating private browsing mode
 3163         @rtype bool
 3164         """
 3165         return cls._isPrivate
 3166     
 3167     def closeCurrentBrowser(self):
 3168         """
 3169         Public method to close the current web browser.
 3170         """
 3171         self.__tabWidget.closeBrowser()
 3172     
 3173     def closeBrowser(self, browser):
 3174         """
 3175         Public method to close the given browser.
 3176         
 3177         @param browser reference to the web browser view to be closed
 3178         @type WebBrowserView
 3179         """
 3180         self.__tabWidget.closeBrowserView(browser)
 3181     
 3182     def currentBrowser(self):
 3183         """
 3184         Public method to get a reference to the current web browser.
 3185         
 3186         @return reference to the current help browser (WebBrowserView)
 3187         """
 3188         return self.__tabWidget.currentBrowser()
 3189     
 3190     def browserAt(self, index):
 3191         """
 3192         Public method to get a reference to the web browser with the given
 3193         index.
 3194         
 3195         @param index index of the browser to get (integer)
 3196         @return reference to the indexed web browser (WebBrowserView)
 3197         """
 3198         return self.__tabWidget.browserAt(index)
 3199     
 3200     def browsers(self):
 3201         """
 3202         Public method to get a list of references to all web browsers.
 3203         
 3204         @return list of references to web browsers (list of WebBrowserView)
 3205         """
 3206         return self.__tabWidget.browsers()
 3207     
 3208     def __currentChanged(self, index):
 3209         """
 3210         Private slot to handle the currentChanged signal.
 3211         
 3212         @param index index of the current tab (integer)
 3213         """
 3214         if index > -1:
 3215             cb = self.currentBrowser()
 3216             if cb is not None:
 3217                 self.setForwardAvailable(cb.isForwardAvailable())
 3218                 self.setBackwardAvailable(cb.isBackwardAvailable())
 3219                 self.setLoadingActions(cb.isLoading())
 3220                 
 3221                 # set value of zoom widget
 3222                 self.__zoomWidget.setValue(cb.zoomValue())
 3223     
 3224     def __showPreferences(self):
 3225         """
 3226         Private slot to set the preferences.
 3227         """
 3228         from Preferences.ConfigurationDialog import ConfigurationDialog
 3229         dlg = ConfigurationDialog(
 3230             self, 'Configuration', True, fromEric=False,
 3231             displayMode=ConfigurationDialog.WebBrowserMode)
 3232         dlg.preferencesChanged.connect(self.preferencesChanged)
 3233         dlg.masterPasswordChanged.connect(
 3234             lambda old, new: self.masterPasswordChanged(old, new, local=True))
 3235         dlg.show()
 3236         if self.__lastConfigurationPageName:
 3237             dlg.showConfigurationPageByName(self.__lastConfigurationPageName)
 3238         else:
 3239             dlg.showConfigurationPageByName("empty")
 3240         dlg.exec_()
 3241         QApplication.processEvents()
 3242         if dlg.result() == QDialog.Accepted:
 3243             dlg.setPreferences()
 3244             Preferences.syncPreferences()
 3245             self.preferencesChanged()
 3246         self.__lastConfigurationPageName = dlg.getConfigurationPageName()
 3247     
 3248     def preferencesChanged(self):
 3249         """
 3250         Public slot to handle a change of preferences.
 3251         """
 3252         self.setStyle(Preferences.getUI("Style"),
 3253                       Preferences.getUI("StyleSheet"))
 3254         
 3255         self.__initWebEngineSettings()
 3256         
 3257         self.networkManager().preferencesChanged()
 3258         
 3259         self.historyManager().preferencesChanged()
 3260         
 3261         self.__tabWidget.preferencesChanged()
 3262         
 3263         self.__navigationBar.searchEdit().preferencesChanged()
 3264         
 3265         self.autoScroller().preferencesChanged()
 3266         
 3267         profile = self.webProfile()
 3268         if not self.isPrivate():
 3269             if Preferences.getWebBrowser("DiskCacheEnabled"):
 3270                 profile.setHttpCacheType(QWebEngineProfile.DiskHttpCache)
 3271                 profile.setHttpCacheMaximumSize(
 3272                     Preferences.getWebBrowser("DiskCacheSize") * 1024 * 1024)
 3273             else:
 3274                 profile.setHttpCacheType(QWebEngineProfile.MemoryHttpCache)
 3275                 profile.setHttpCacheMaximumSize(0)
 3276         
 3277         try:
 3278             profile.setSpellCheckEnabled(
 3279                 Preferences.getWebBrowser("SpellCheckEnabled"))
 3280             profile.setSpellCheckLanguages(
 3281                 Preferences.getWebBrowser("SpellCheckLanguages"))
 3282         except AttributeError:
 3283             # not yet supported
 3284             pass
 3285         
 3286         self.__virusTotal.preferencesChanged()
 3287         if (
 3288             not Preferences.getWebBrowser("VirusTotalEnabled") or
 3289             Preferences.getWebBrowser("VirusTotalServiceKey") == ""
 3290         ):
 3291             self.virustotalScanCurrentAct.setEnabled(False)
 3292             self.virustotalIpReportAct.setEnabled(False)
 3293             self.virustotalDomainReportAct.setEnabled(False)
 3294         else:
 3295             self.virustotalScanCurrentAct.setEnabled(True)
 3296             self.virustotalIpReportAct.setEnabled(True)
 3297             self.virustotalDomainReportAct.setEnabled(True)
 3298         
 3299         self.__javaScriptIcon.preferencesChanged()
 3300         
 3301         if not WebBrowserWindow.isPrivate():
 3302             self.sessionManager().preferencesChanged()
 3303     
 3304     def masterPasswordChanged(self, oldPassword, newPassword, local=False):
 3305         """
 3306         Public slot to handle the change of the master password.
 3307         
 3308         @param oldPassword current master password
 3309         @type str
 3310         @param newPassword new master password
 3311         @type str
 3312         @param local flag indicating being called from the local configuration
 3313             dialog
 3314         @type bool
 3315         """
 3316         self.passwordManager().masterPasswordChanged(oldPassword, newPassword)
 3317         if local:
 3318             # we were called from our local configuration dialog
 3319             Preferences.convertPasswords(oldPassword, newPassword)
 3320             Utilities.crypto.changeRememberedMaster(newPassword)
 3321     
 3322     def __showAcceptedLanguages(self):
 3323         """
 3324         Private slot to configure the accepted languages for web pages.
 3325         """
 3326         from .WebBrowserLanguagesDialog import WebBrowserLanguagesDialog
 3327         dlg = WebBrowserLanguagesDialog(self)
 3328         dlg.exec_()
 3329         self.networkManager().languagesChanged()
 3330     
 3331     def __showCookiesConfiguration(self):
 3332         """
 3333         Private slot to configure the cookies handling.
 3334         """
 3335         from .CookieJar.CookiesConfigurationDialog import (
 3336             CookiesConfigurationDialog
 3337         )
 3338         dlg = CookiesConfigurationDialog(self)
 3339         dlg.exec_()
 3340     
 3341     def __showFlashCookiesManagement(self):
 3342         """
 3343         Private slot to show the flash cookies management dialog.
 3344         """
 3345         self.flashCookieManager().showFlashCookieManagerDialog()
 3346     
 3347     @classmethod
 3348     def setUseQtHelp(cls, use):
 3349         """
 3350         Class method to set the QtHelp usage.
 3351         
 3352         @param use flag indicating usage (boolean)
 3353         """
 3354         if use:
 3355             cls._useQtHelp = use and QTHELP_AVAILABLE
 3356         else:
 3357             cls._useQtHelp = False
 3358     
 3359     @classmethod
 3360     def helpEngine(cls):
 3361         """
 3362         Class method to get a reference to the help engine.
 3363         
 3364         @return reference to the help engine (QHelpEngine)
 3365         """
 3366         if cls._useQtHelp:
 3367             if cls._helpEngine is None:
 3368                 cls._helpEngine = QHelpEngine(
 3369                     WebBrowserWindow.getQtHelpCollectionFileName())
 3370             return cls._helpEngine
 3371         else:
 3372             return None
 3373     
 3374     @classmethod
 3375     def getQtHelpCollectionFileName(cls):
 3376         """
 3377         Class method to determine the name of the QtHelp collection file.
 3378         
 3379         @return path of the QtHelp collection file
 3380         @rtype str
 3381         """
 3382         qthelpDir = os.path.join(Utilities.getConfigDir(), "qthelp")
 3383         if not os.path.exists(qthelpDir):
 3384             os.makedirs(qthelpDir)
 3385         return os.path.join(qthelpDir, "eric6help.qhc")
 3386     
 3387     @classmethod
 3388     def networkManager(cls):
 3389         """
 3390         Class method to get a reference to the network manager object.
 3391         
 3392         @return reference to the network access manager (NetworkManager)
 3393         """
 3394         if cls._networkManager is None:
 3395             from .Network.NetworkManager import NetworkManager
 3396             cls._networkManager = NetworkManager(cls.helpEngine())
 3397         
 3398         return cls._networkManager
 3399     
 3400     @classmethod
 3401     def cookieJar(cls):
 3402         """
 3403         Class method to get a reference to the cookie jar.
 3404         
 3405         @return reference to the cookie jar (CookieJar)
 3406         """
 3407         if cls._cookieJar is None:
 3408             from .CookieJar.CookieJar import CookieJar
 3409             cls._cookieJar = CookieJar()
 3410         
 3411         return cls._cookieJar
 3412         
 3413     def __clearIconsDatabase(self):
 3414         """
 3415         Private slot to clear the favicons databse.
 3416         """
 3417         WebIconProvider.instance().clear()
 3418     
 3419     def __showWebIconsDialog(self):
 3420         """
 3421         Private slot to show a dialog to manage the favicons database.
 3422         """
 3423         WebIconProvider.instance().showWebIconDialog()
 3424         
 3425     @pyqtSlot(QUrl)
 3426     def urlHandler(self, url):
 3427         """
 3428         Public slot used as desktop URL handler.
 3429         
 3430         @param url URL to be handled
 3431         @type QUrl
 3432         """
 3433         self.__linkActivated(url)
 3434     
 3435     @pyqtSlot(QUrl)
 3436     def __linkActivated(self, url):
 3437         """
 3438         Private slot to handle the selection of a link.
 3439         
 3440         @param url URL to be shown
 3441         @type QUrl
 3442         """
 3443         if not self.__activating:
 3444             self.__activating = True
 3445             cb = self.currentBrowser()
 3446             if cb is None:
 3447                 self.newTab(url)
 3448             else:
 3449                 cb.setUrl(url)
 3450             self.__activating = False
 3451     
 3452     def __activateCurrentBrowser(self):
 3453         """
 3454         Private slot to activate the current browser.
 3455         """
 3456         self.currentBrowser().setFocus()
 3457         
 3458     def __syncTOC(self):
 3459         """
 3460         Private slot to synchronize the TOC with the currently shown page.
 3461         """
 3462         if WebBrowserWindow._useQtHelp:
 3463             QApplication.setOverrideCursor(Qt.WaitCursor)
 3464             url = self.currentBrowser().source()
 3465             self.__showTocWindow()
 3466             if not self.__tocWindow.syncToContent(url):
 3467                 self.statusBar().showMessage(
 3468                     self.tr("Could not find an associated content."), 5000)
 3469             QApplication.restoreOverrideCursor()
 3470         
 3471     def __showTocWindow(self):
 3472         """
 3473         Private method to show the table of contents window.
 3474         """
 3475         if WebBrowserWindow._useQtHelp:
 3476             self.__activateDock(self.__tocWindow)
 3477         
 3478     def __showIndexWindow(self):
 3479         """
 3480         Private method to show the index window.
 3481         """
 3482         if WebBrowserWindow._useQtHelp:
 3483             self.__activateDock(self.__indexWindow)
 3484         
 3485     def __showSearchWindow(self):
 3486         """
 3487         Private method to show the search window.
 3488         """
 3489         if WebBrowserWindow._useQtHelp:
 3490             self.__activateDock(self.__searchWindow)
 3491         
 3492     def __activateDock(self, widget):
 3493         """
 3494         Private method to activate the dock widget of the given widget.
 3495         
 3496         @param widget reference to the widget to be activated (QWidget)
 3497         """
 3498         widget.parent().show()
 3499         widget.parent().raise_()
 3500         widget.setFocus()
 3501         
 3502     def __setupFilterCombo(self):
 3503         """
 3504         Private slot to setup the filter combo box.
 3505         """
 3506         if WebBrowserWindow._useQtHelp:
 3507             curFilter = self.filterCombo.currentText()
 3508             if not curFilter:
 3509                 curFilter = self.__helpEngine.currentFilter()
 3510             self.filterCombo.clear()
 3511             self.filterCombo.addItems(self.__helpEngine.customFilters())
 3512             idx = self.filterCombo.findText(curFilter)
 3513             if idx < 0:
 3514                 idx = 0
 3515             self.filterCombo.setCurrentIndex(idx)
 3516         
 3517     def __filterQtHelpDocumentation(self, customFilter):
 3518         """
 3519         Private slot to filter the QtHelp documentation.
 3520         
 3521         @param customFilter name of filter to be applied (string)
 3522         """
 3523         if self.__helpEngine:
 3524             self.__helpEngine.setCurrentFilter(customFilter)
 3525         
 3526     def __manageQtHelpDocumentation(self):
 3527         """
 3528         Private slot to manage the QtHelp documentation database.
 3529         """
 3530         if WebBrowserWindow._useQtHelp:
 3531             from .QtHelp.QtHelpDocumentationDialog import (
 3532                 QtHelpDocumentationDialog
 3533             )
 3534             dlg = QtHelpDocumentationDialog(self.__helpEngine, self)
 3535             dlg.exec_()
 3536             if dlg.hasDocumentationChanges():
 3537                 for i in sorted(dlg.getTabsToClose(), reverse=True):
 3538                     self.__tabWidget.closeBrowserAt(i)
 3539                 self.__searchEngine.reindexDocumentation()
 3540         
 3541     def getSourceFileList(self):
 3542         """
 3543         Public method to get a list of all opened source files.
 3544         
 3545         @return dictionary with tab id as key and host/namespace as value
 3546         """
 3547         return self.__tabWidget.getSourceFileList()
 3548     
 3549     def __indexingStarted(self):
 3550         """
 3551         Private slot to handle the start of the indexing process.
 3552         """
 3553         if WebBrowserWindow._useQtHelp:
 3554             self.__indexing = True
 3555             if self.__indexingProgress is None:
 3556                 self.__indexingProgress = QWidget()
 3557                 layout = QHBoxLayout(self.__indexingProgress)
 3558                 layout.setContentsMargins(0, 0, 0, 0)
 3559                 sizePolicy = QSizePolicy(QSizePolicy.Preferred,
 3560                                          QSizePolicy.Maximum)
 3561                 
 3562                 label = QLabel(self.tr("Updating search index"))
 3563                 label.setSizePolicy(sizePolicy)
 3564                 layout.addWidget(label)
 3565                 
 3566                 progressBar = QProgressBar()
 3567                 progressBar.setRange(0, 0)
 3568                 progressBar.setTextVisible(False)
 3569                 progressBar.setFixedHeight(16)
 3570                 progressBar.setSizePolicy(sizePolicy)
 3571                 layout.addWidget(progressBar)
 3572                 
 3573                 self.statusBar().insertPermanentWidget(
 3574                     0, self.__indexingProgress)
 3575         
 3576     def __indexingFinished(self):
 3577         """
 3578         Private slot to handle the start of the indexing process.
 3579         """
 3580         if WebBrowserWindow._useQtHelp:
 3581             self.statusBar().removeWidget(self.__indexingProgress)
 3582             self.__indexingProgress = None
 3583             self.__indexing = False
 3584             if self.__searchWord is not None:
 3585                 self.__searchForWord()
 3586         
 3587     def __searchForWord(self):
 3588         """
 3589         Private slot to search for a word.
 3590         """
 3591         if (
 3592             WebBrowserWindow._useQtHelp and
 3593             not self.__indexing and
 3594             self.__searchWord is not None
 3595         ):
 3596             self.__searchDock.show()
 3597             self.__searchDock.raise_()
 3598             query = QHelpSearchQuery(QHelpSearchQuery.DEFAULT,
 3599                                      [self.__searchWord])
 3600             self.__searchEngine.search([query])
 3601             self.__searchWord = None
 3602         
 3603     def search(self, word):
 3604         """
 3605         Public method to search for a word.
 3606         
 3607         @param word word to search for (string)
 3608         """
 3609         if WebBrowserWindow._useQtHelp:
 3610             self.__searchWord = word
 3611             self.__searchForWord()
 3612         
 3613     def __removeOldDocumentation(self):
 3614         """
 3615         Private slot to remove non-existing documentation from the help engine.
 3616         """
 3617         if WebBrowserWindow._useQtHelp:
 3618             for namespace in self.__helpEngine.registeredDocumentations():
 3619                 docFile = self.__helpEngine.documentationFileName(namespace)
 3620                 if not os.path.exists(docFile):
 3621                     self.__helpEngine.unregisterDocumentation(namespace)
 3622         
 3623     def __lookForNewDocumentation(self):
 3624         """
 3625         Private slot to look for new documentation to be loaded into the
 3626         help database.
 3627         """
 3628         if WebBrowserWindow._useQtHelp:
 3629             from .QtHelp.HelpDocsInstaller import HelpDocsInstaller
 3630             self.__helpInstaller = HelpDocsInstaller(
 3631                 self.__helpEngine.collectionFile())
 3632             self.__helpInstaller.errorMessage.connect(
 3633                 self.__showInstallationError)
 3634             self.__helpInstaller.docsInstalled.connect(self.__docsInstalled)
 3635             
 3636             self.statusBar().showMessage(
 3637                 self.tr("Looking for Documentation..."))
 3638             self.__helpInstaller.installDocs()
 3639         
 3640     def __showInstallationError(self, message):
 3641         """
 3642         Private slot to show installation errors.
 3643         
 3644         @param message message to be shown (string)
 3645         """
 3646         E5MessageBox.warning(
 3647             self,
 3648             self.tr("eric6 Web Browser"),
 3649             message)
 3650         
 3651     def __docsInstalled(self, installed):
 3652         """
 3653         Private slot handling the end of documentation installation.
 3654         
 3655         @param installed flag indicating that documents were installed
 3656             (boolean)
 3657         """
 3658         if WebBrowserWindow._useQtHelp:
 3659             self.statusBar().clearMessage()
 3660         
 3661     def __initHelpDb(self):
 3662         """
 3663         Private slot to initialize the documentation database.
 3664         """
 3665         if WebBrowserWindow._useQtHelp:
 3666             unfiltered = self.tr("Unfiltered")
 3667             if unfiltered not in self.__helpEngine.customFilters():
 3668                 hc = QHelpEngineCore(self.__helpEngine.collectionFile())
 3669                 hc.addCustomFilter(unfiltered, [])
 3670                 hc = None
 3671                 del hc
 3672                 
 3673                 self.__helpEngine.blockSignals(True)
 3674                 self.__helpEngine.setCurrentFilter(unfiltered)
 3675                 self.__helpEngine.blockSignals(False)
 3676         
 3677     def __warning(self, msg):
 3678         """
 3679         Private slot handling warnings from the help engine.
 3680         
 3681         @param msg message sent by the help  engine (string)
 3682         """
 3683         E5MessageBox.warning(
 3684             self,
 3685             self.tr("Help Engine"), msg)
 3686         
 3687     def __aboutToShowSettingsMenu(self):
 3688         """
 3689         Private slot to show the Settings menu.
 3690         """
 3691         self.editMessageFilterAct.setEnabled(
 3692             E5ErrorMessage.messageHandlerInstalled())
 3693         
 3694     def __clearPrivateData(self):
 3695         """
 3696         Private slot to clear the private data.
 3697         """
 3698         from .WebBrowserClearPrivateDataDialog import (
 3699             WebBrowserClearPrivateDataDialog
 3700         )
 3701         dlg = WebBrowserClearPrivateDataDialog(self)
 3702         if dlg.exec_() == QDialog.Accepted:
 3703             # browsing history, search history, favicons, disk cache, cookies,
 3704             # passwords, web databases, downloads, Flash cookies
 3705             (history, searches, favicons, cache, cookies,
 3706              passwords, databases, downloads, flashCookies, zoomValues,
 3707              sslExceptions, historyPeriod) = dlg.getData()
 3708             if history:
 3709                 self.historyManager().clear(historyPeriod)
 3710                 self.__tabWidget.clearClosedTabsList()
 3711                 self.webProfile().clearAllVisitedLinks()
 3712             if searches:
 3713                 self.__navigationBar.searchEdit().clear()
 3714             if downloads:
 3715                 self.downloadManager().cleanup()
 3716                 self.downloadManager().hide()
 3717             if favicons:
 3718                 self.__clearIconsDatabase()
 3719             if cache:
 3720                 try:
 3721                     self.webProfile().clearHttpCache()
 3722                 except AttributeError:
 3723                     cachePath = self.webProfile().cachePath()
 3724                     if cachePath:
 3725                         shutil.rmtree(cachePath)
 3726             if cookies:
 3727                 self.cookieJar().clear()
 3728                 self.webProfile().cookieStore().deleteAllCookies()
 3729             if passwords:
 3730                 self.passwordManager().clear()
 3731             if flashCookies:
 3732                 self.flashCookieManager().removeAllCookies()
 3733             if zoomValues:
 3734                 ZoomManager.instance().clear()
 3735             if sslExceptions:
 3736                 self.networkManager().clearSslExceptions()
 3737         
 3738     def __showEnginesConfigurationDialog(self):
 3739         """
 3740         Private slot to show the search engines configuration dialog.
 3741         """
 3742         from .OpenSearch.OpenSearchDialog import OpenSearchDialog
 3743         
 3744         dlg = OpenSearchDialog(self)
 3745         dlg.exec_()
 3746         
 3747     def searchEnginesAction(self):
 3748         """
 3749         Public method to get a reference to the search engines configuration
 3750         action.
 3751         
 3752         @return reference to the search engines configuration action (QAction)
 3753         """
 3754         return self.searchEnginesAct
 3755         
 3756     def __showPasswordsDialog(self):
 3757         """
 3758         Private slot to show the passwords management dialog.
 3759         """
 3760         from .Passwords.PasswordsDialog import PasswordsDialog
 3761         
 3762         dlg = PasswordsDialog(self)
 3763         dlg.exec_()
 3764     
 3765     def __showCertificateErrorsDialog(self):
 3766         """
 3767         Private slot to show the certificate errors management dialog.
 3768         """
 3769         self.networkManager().showSslErrorExceptionsDialog()
 3770     
 3771     def __showAdBlockDialog(self):
 3772         """
 3773         Private slot to show the AdBlock configuration dialog.
 3774         """
 3775         self.adBlockManager().showDialog()
 3776         
 3777     def __showPersonalInformationDialog(self):
 3778         """
 3779         Private slot to show the Personal Information configuration dialog.
 3780         """
 3781         self.personalInformationManager().showConfigurationDialog()
 3782         
 3783     def __showGreaseMonkeyConfigDialog(self):
 3784         """
 3785         Private slot to show the GreaseMonkey scripts configuration dialog.
 3786         """
 3787         self.greaseMonkeyManager().showConfigurationDialog()
 3788         
 3789     def __showFeaturePermissionDialog(self):
 3790         """
 3791         Private slot to show the feature permission dialog.
 3792         """
 3793         self.featurePermissionManager().showFeaturePermissionsDialog()
 3794         
 3795     def __showZoomValuesDialog(self):
 3796         """
 3797         Private slot to show the zoom values management dialog.
 3798         """
 3799         from .ZoomManager.ZoomValuesDialog import ZoomValuesDialog
 3800         
 3801         dlg = ZoomValuesDialog(self)
 3802         dlg.exec_()
 3803     
 3804     def __showDownloadsWindow(self):
 3805         """
 3806         Private slot to show the downloads dialog.
 3807         """
 3808         self.downloadManager().show()
 3809         
 3810     def __showPageSource(self):
 3811         """
 3812         Private slot to show the source of the current page in an editor.
 3813         """
 3814         self.currentBrowser().page().toHtml(self.__showPageSourceCallback)
 3815         
 3816     def __showPageSourceCallback(self, src):
 3817         """
 3818         Private method to show the source of the current page in an editor.
 3819         
 3820         @param src source of the web page
 3821         @type str
 3822         """
 3823         from QScintilla.MiniEditor import MiniEditor
 3824         editor = MiniEditor(parent=self)
 3825         editor.setText(src, "Html")
 3826         editor.setLanguage("dummy.html")
 3827         editor.show()
 3828     
 3829     def __toggleJavaScriptConsole(self):
 3830         """
 3831         Private slot to toggle the JavaScript console.
 3832         """
 3833         if self.__javascriptConsoleDock.isVisible():
 3834             self.__javascriptConsoleDock.hide()
 3835         else:
 3836             self.__javascriptConsoleDock.show()
 3837     
 3838     def javascriptConsole(self):
 3839         """
 3840         Public method to get a reference to the JavaScript console widget.
 3841         
 3842         @return reference to the JavaScript console
 3843         @rtype WebBrowserJavaScriptConsole
 3844         """
 3845         return self.__javascriptConsole
 3846     
 3847     @classmethod
 3848     def icon(cls, url):
 3849         """
 3850         Class method to get the icon for an URL.
 3851         
 3852         @param url URL to get icon for (QUrl)
 3853         @return icon for the URL (QIcon)
 3854         """
 3855         return WebIconProvider.instance().iconForUrl(url)
 3856 
 3857     @classmethod
 3858     def bookmarksManager(cls):
 3859         """
 3860         Class method to get a reference to the bookmarks manager.
 3861         
 3862         @return reference to the bookmarks manager (BookmarksManager)
 3863         """
 3864         if cls._bookmarksManager is None:
 3865             from .Bookmarks.BookmarksManager import BookmarksManager
 3866             cls._bookmarksManager = BookmarksManager()
 3867         
 3868         return cls._bookmarksManager
 3869     
 3870     def openUrl(self, url, title=None):
 3871         """
 3872         Public slot to load a URL in the current tab.
 3873         
 3874         @param url URL to be opened (QUrl)
 3875         @param title title of the bookmark (string)
 3876         """
 3877         self.__linkActivated(url)
 3878     
 3879     def openUrlNewTab(self, url, title=None):
 3880         """
 3881         Public slot to load a URL in a new tab.
 3882         
 3883         @param url URL to be opened (QUrl)
 3884         @param title title of the bookmark (string)
 3885         """
 3886         self.newTab(url)
 3887     
 3888     def openUrlNewBackgroundTab(self, url, title=None):
 3889         """
 3890         Public slot to load a URL in a new background tab.
 3891         
 3892         @param url URL to be opened (QUrl)
 3893         @param title title of the bookmark (string)
 3894         """
 3895         self.newTab(url, background=True)
 3896     
 3897     def openUrlNewWindow(self, url, title=None):
 3898         """
 3899         Public slot to load a URL in a new window.
 3900         
 3901         @param url URL to be opened (QUrl)
 3902         @param title title of the bookmark (string)
 3903         """
 3904         self.newWindow(url)
 3905     
 3906     def openUrlNewPrivateWindow(self, url, title=None):
 3907         """
 3908         Public slot to load a URL in a new private window.
 3909         
 3910         @param url URL to be opened (QUrl)
 3911         @param title title of the bookmark (string)
 3912         """
 3913         self.newPrivateWindow(url)
 3914     
 3915     def __sendPageLink(self):
 3916         """
 3917         Private slot to send the link of the current page via email.
 3918         """
 3919         url = self.currentBrowser().url()
 3920         if not url.isEmpty():
 3921             urlStr = url.toString()
 3922             QDesktopServices.openUrl(QUrl("mailto:?body=" + urlStr))
 3923     
 3924     @classmethod
 3925     def historyManager(cls):
 3926         """
 3927         Class method to get a reference to the history manager.
 3928         
 3929         @return reference to the history manager (HistoryManager)
 3930         """
 3931         if cls._historyManager is None:
 3932             from .History.HistoryManager import HistoryManager
 3933             cls._historyManager = HistoryManager()
 3934         
 3935         return cls._historyManager
 3936         
 3937     @classmethod
 3938     def passwordManager(cls):
 3939         """
 3940         Class method to get a reference to the password manager.
 3941         
 3942         @return reference to the password manager (PasswordManager)
 3943         """
 3944         if cls._passwordManager is None:
 3945             from .Passwords.PasswordManager import PasswordManager
 3946             cls._passwordManager = PasswordManager()
 3947         
 3948         return cls._passwordManager
 3949     
 3950     @classmethod
 3951     def adBlockManager(cls):
 3952         """
 3953         Class method to get a reference to the AdBlock manager.
 3954         
 3955         @return reference to the AdBlock manager (AdBlockManager)
 3956         """
 3957         if cls._adblockManager is None:
 3958             from .AdBlock.AdBlockManager import AdBlockManager
 3959             cls._adblockManager = AdBlockManager()
 3960         
 3961         return cls._adblockManager
 3962     
 3963     def adBlockIcon(self):
 3964         """
 3965         Public method to get a reference to the AdBlock icon.
 3966         
 3967         @return reference to the AdBlock icon (AdBlockIcon)
 3968         """
 3969         return self.__adBlockIcon
 3970     
 3971     @classmethod
 3972     def downloadManager(cls):
 3973         """
 3974         Class method to get a reference to the download manager.
 3975         
 3976         @return reference to the download manager (DownloadManager)
 3977         """
 3978         if cls._downloadManager is None:
 3979             from .Download.DownloadManager import DownloadManager
 3980             cls._downloadManager = DownloadManager()
 3981         
 3982         return cls._downloadManager
 3983         
 3984     @classmethod
 3985     def personalInformationManager(cls):
 3986         """
 3987         Class method to get a reference to the personal information manager.
 3988         
 3989         @return reference to the personal information manager
 3990             (PersonalInformationManager)
 3991         """
 3992         if cls._personalInformationManager is None:
 3993             from .PersonalInformationManager import PersonalInformationManager
 3994             cls._personalInformationManager = (
 3995                 PersonalInformationManager.PersonalInformationManager()
 3996             )
 3997         
 3998         return cls._personalInformationManager
 3999         
 4000     @classmethod
 4001     def greaseMonkeyManager(cls):
 4002         """
 4003         Class method to get a reference to the GreaseMonkey manager.
 4004         
 4005         @return reference to the GreaseMonkey manager (GreaseMonkeyManager)
 4006         """
 4007         if cls._greaseMonkeyManager is None:
 4008             from .GreaseMonkey.GreaseMonkeyManager import GreaseMonkeyManager
 4009             cls._greaseMonkeyManager = GreaseMonkeyManager()
 4010         
 4011         return cls._greaseMonkeyManager
 4012         
 4013     @classmethod
 4014     def featurePermissionManager(cls):
 4015         """
 4016         Class method to get a reference to the feature permission manager.
 4017         
 4018         @return reference to the feature permission manager
 4019         @rtype FeaturePermissionManager
 4020         """
 4021         if cls._featurePermissionManager is None:
 4022             from .FeaturePermissions.FeaturePermissionManager import (
 4023                 FeaturePermissionManager
 4024             )
 4025             cls._featurePermissionManager = FeaturePermissionManager()
 4026         
 4027         return cls._featurePermissionManager
 4028         
 4029     @classmethod
 4030     def flashCookieManager(cls):
 4031         """
 4032         Class method to get a reference to the flash cookies manager.
 4033         
 4034         @return reference to the flash cookies manager
 4035         @rtype FlashCookieManager
 4036         """
 4037         if cls._flashCookieManager is None:
 4038             from .FlashCookieManager.FlashCookieManager import (
 4039                 FlashCookieManager
 4040             )
 4041             cls._flashCookieManager = FlashCookieManager()
 4042         
 4043         return cls._flashCookieManager
 4044         
 4045     @classmethod
 4046     def imageSearchEngine(cls):
 4047         """
 4048         Class method to get a reference to the image search engine.
 4049         
 4050         @return reference to the image finder object
 4051         @rtype ImageSearchEngine
 4052         """
 4053         if cls._imageSearchEngine is None:
 4054             from .ImageSearch.ImageSearchEngine import (
 4055                 ImageSearchEngine
 4056             )
 4057             cls._imageSearchEngine = ImageSearchEngine()
 4058         
 4059         return cls._imageSearchEngine
 4060         
 4061     @classmethod
 4062     def autoScroller(cls):
 4063         """
 4064         Class method to get a reference to the auto scroller.
 4065         
 4066         @return reference to the auto scroller object
 4067         @rtype AutoScroller
 4068         """
 4069         if cls._autoScroller is None:
 4070             from .AutoScroll.AutoScroller import AutoScroller
 4071             cls._autoScroller = AutoScroller()
 4072         
 4073         return cls._autoScroller
 4074         
 4075     @classmethod
 4076     def tabManager(cls):
 4077         """
 4078         Class method to get a reference to the tab manager widget.
 4079         
 4080         @return reference to the tab manager widget
 4081         @rtype TabManagerWidget
 4082         """
 4083         if cls._tabManager is None:
 4084             from .TabManager.TabManagerWidget import TabManagerWidget
 4085             cls._tabManager = TabManagerWidget(cls.mainWindow())
 4086             
 4087             # do the connections
 4088             for window in cls.mainWindows():
 4089                 cls._tabManager.mainWindowCreated(window, False)
 4090             
 4091             cls._tabManager.delayedRefreshTree()
 4092         
 4093         return cls._tabManager
 4094     
 4095     def __showTabManager(self, act):
 4096         """
 4097         Private method to show the tab manager window.
 4098         
 4099         @param act reference to the act that triggered
 4100         @type QAction
 4101         """
 4102         self.tabManager().raiseTabManager(act)
 4103     
 4104     @classmethod
 4105     def mainWindow(cls):
 4106         """
 4107         Class method to get a reference to the main window.
 4108         
 4109         @return reference to the main window (WebBrowserWindow)
 4110         """
 4111         if cls.BrowserWindows:
 4112             return cls.BrowserWindows[0]
 4113         else:
 4114             return None
 4115     
 4116     @classmethod
 4117     def mainWindows(cls):
 4118         """
 4119         Class method to get references to all main windows.
 4120         
 4121         @return references to all main window (list of WebBrowserWindow)
 4122         """
 4123         return cls.BrowserWindows
 4124     
 4125     @pyqtSlot()
 4126     def __appFocusChanged(self):
 4127         """
 4128         Private slot to handle a change of the focus.
 4129         """
 4130         focusWindow = e5App().activeWindow()
 4131         if isinstance(focusWindow, WebBrowserWindow):
 4132             WebBrowserWindow._lastActiveWindow = focusWindow
 4133     
 4134     @classmethod
 4135     def getWindow(cls):
 4136         """
 4137         Class method to get a reference to the most recent active
 4138         web browser window.
 4139         
 4140         @return reference to most recent web browser window
 4141         @rtype WebBrowserWindow
 4142         """
 4143         if cls._lastActiveWindow:
 4144             return cls._lastActiveWindow
 4145         
 4146         return cls.mainWindow()
 4147     
 4148     def openSearchManager(self):
 4149         """
 4150         Public method to get a reference to the opensearch manager object.
 4151         
 4152         @return reference to the opensearch manager object (OpenSearchManager)
 4153         """
 4154         return self.__navigationBar.searchEdit().openSearchManager()
 4155     
 4156     def __createTextEncodingAction(self, codec, defaultCodec, parentMenu):
 4157         """
 4158         Private method to create an action for the text encoding menu.
 4159         
 4160         @param codec name of the codec to create an action for
 4161         @type str
 4162         @param defaultCodec name of the default codec
 4163         @type str
 4164         @param parentMenu reference to the parent menu
 4165         @type QMenu
 4166         """
 4167         act = QAction(codec, parentMenu)
 4168         act.setData(codec)
 4169         act.setCheckable(True)
 4170         if defaultCodec == codec:
 4171             act.setChecked(True)
 4172         
 4173         parentMenu.addAction(act)
 4174     
 4175     def __createTextEncodingSubmenu(self, title, codecNames, parentMenu):
 4176         """
 4177         Private method to create a text encoding sub menu.
 4178         
 4179         @param title title of the menu
 4180         @type str
 4181         @param codecNames list of codec names for the menu
 4182         @type list of str
 4183         @param parentMenu reference to the parent menu
 4184         @type QMenu
 4185         """
 4186         if codecNames:
 4187             defaultCodec = self.webSettings().defaultTextEncoding().lower()
 4188             
 4189             menu = QMenu(title, parentMenu)
 4190             for codec in codecNames:
 4191                 self.__createTextEncodingAction(codec, defaultCodec, menu)
 4192             
 4193             parentMenu.addMenu(menu)
 4194     
 4195     def __aboutToShowTextEncodingMenu(self):
 4196         """
 4197         Private slot to populate the text encoding menu.
 4198         """
 4199         self.__textEncodingMenu.clear()
 4200         
 4201         codecs = []
 4202         for mib in QTextCodec.availableMibs():
 4203             codec = str(QTextCodec.codecForMib(mib).name(),
 4204                         encoding="utf-8").lower()
 4205             if codec not in codecs:
 4206                 codecs.append(codec)
 4207         codecs.sort()
 4208         
 4209         defaultTextEncoding = self.webSettings().defaultTextEncoding().lower()
 4210         if defaultTextEncoding in codecs:
 4211             currentCodec = defaultTextEncoding
 4212         else:
 4213             currentCodec = "system"
 4214         
 4215         isoCodecs = []
 4216         winCodecs = []
 4217         isciiCodecs = []
 4218         uniCodecs = []
 4219         ibmCodecs = []
 4220         otherCodecs = []
 4221         
 4222         for codec in codecs:
 4223             if codec.startswith(("iso", "latin")):
 4224                 isoCodecs.append(codec)
 4225             elif codec.startswith(("windows")):
 4226                 winCodecs.append(codec)
 4227             elif codec.startswith("iscii"):
 4228                 isciiCodecs.append(codec)
 4229             elif codec.startswith("utf"):
 4230                 uniCodecs.append(codec)
 4231             elif codec.startswith(("ibm")):
 4232                 ibmCodecs.append(codec)
 4233             elif codec == "system":
 4234                 self.__createTextEncodingAction(codec, currentCodec,
 4235                                                 self.__textEncodingMenu)
 4236             else:
 4237                 otherCodecs.append(codec)
 4238         
 4239         if not self.__textEncodingMenu.isEmpty():
 4240             self.__textEncodingMenu.addSeparator()
 4241         self.__createTextEncodingSubmenu(self.tr("ISO"), isoCodecs,
 4242                                          self.__textEncodingMenu)
 4243         self.__createTextEncodingSubmenu(self.tr("Unicode"), uniCodecs,
 4244                                          self.__textEncodingMenu)
 4245         self.__createTextEncodingSubmenu(self.tr("Windows"), winCodecs,
 4246                                          self.__textEncodingMenu)
 4247         self.__createTextEncodingSubmenu(self.tr("ISCII"), isciiCodecs,
 4248                                          self.__textEncodingMenu)
 4249         self.__createTextEncodingSubmenu(self.tr("IBM"), ibmCodecs,
 4250                                          self.__textEncodingMenu)
 4251         self.__createTextEncodingSubmenu(self.tr("Other"), otherCodecs,
 4252                                          self.__textEncodingMenu)
 4253     
 4254     def __setTextEncoding(self, act):
 4255         """
 4256         Private slot to set the selected text encoding as the default for
 4257         this session.
 4258         
 4259         @param act reference to the selected action (QAction)
 4260         """
 4261         codec = act.data()
 4262         if codec == "":
 4263             self.webSettings().setDefaultTextEncoding("")
 4264         else:
 4265             self.webSettings().setDefaultTextEncoding(codec)
 4266     
 4267     def __populateToolbarsMenu(self, menu):
 4268         """
 4269         Private method to populate the toolbars menu.
 4270         
 4271         @param menu reference to the menu to be populated
 4272         @type QMenu
 4273         """
 4274         menu.clear()
 4275         
 4276         act = menu.addAction(self.tr("Menu Bar"))
 4277         act.setCheckable(True)
 4278         act.setChecked(not self.menuBar().isHidden())
 4279         act.setData("menubar")
 4280         
 4281         act = menu.addAction(self.tr("Bookmarks"))
 4282         act.setCheckable(True)
 4283         act.setChecked(not self.__bookmarksToolBar.isHidden())
 4284         act.setData("bookmarks")
 4285         
 4286         act = menu.addAction(self.tr("Status Bar"))
 4287         act.setCheckable(True)
 4288         act.setChecked(not self.statusBar().isHidden())
 4289         act.setData("statusbar")
 4290         
 4291         if Preferences.getWebBrowser("ShowToolbars"):
 4292             menu.addSeparator()
 4293             for name, (text, tb) in sorted(self.__toolbars.items(),
 4294                                            key=lambda t: t[1][0]):
 4295                 act = menu.addAction(text)
 4296                 act.setCheckable(True)
 4297                 act.setChecked(not tb.isHidden())
 4298                 act.setData(name)
 4299             menu.addSeparator()
 4300             act = menu.addAction(self.tr("&Show all"))
 4301             act.setData("__SHOW__")
 4302             act = menu.addAction(self.tr("&Hide all"))
 4303             act.setData("__HIDE__")
 4304     
 4305     def createPopupMenu(self):
 4306         """
 4307         Public method to create the toolbars menu for Qt.
 4308         
 4309         @return toolbars menu
 4310         @rtype QMenu
 4311         """
 4312         menu = QMenu(self)
 4313         menu.triggered.connect(self.__TBMenuTriggered)
 4314         
 4315         self.__populateToolbarsMenu(menu)
 4316         
 4317         return menu
 4318 
 4319     def __showToolbarsMenu(self):
 4320         """
 4321         Private slot to display the Toolbars menu.
 4322         """
 4323         self.__populateToolbarsMenu(self.__toolbarsMenu)
 4324 
 4325     def __TBMenuTriggered(self, act):
 4326         """
 4327         Private method to handle the toggle of a toolbar via the Window->
 4328         Toolbars submenu or the toolbars popup menu.
 4329         
 4330         @param act reference to the action that was triggered
 4331         @type QAction
 4332         """
 4333         name = act.data()
 4334         if name:
 4335             if name == "bookmarks":
 4336                 # special handling of bookmarks toolbar
 4337                 self.__setBookmarksToolbarVisibility(act.isChecked())
 4338             
 4339             elif name == "menubar":
 4340                 # special treatment of the menu bar
 4341                 self.__setMenuBarVisibility(act.isChecked())
 4342             
 4343             elif name == "statusbar":
 4344                 # special treatment of the status bar
 4345                 self.__setStatusBarVisible(act.isChecked())
 4346             
 4347             elif name == "__SHOW__":
 4348                 for _text, tb in list(self.__toolbars.values()):
 4349                     tb.show()
 4350             
 4351             elif name == "__HIDE__":
 4352                 for _text, tb in list(self.__toolbars.values()):
 4353                     tb.hide()
 4354             
 4355             else:
 4356                 tb = self.__toolbars[name][1]
 4357                 if act.isChecked():
 4358                     tb.show()
 4359                 else:
 4360                     tb.hide()
 4361     
 4362     def __setBookmarksToolbarVisibility(self, visible):
 4363         """
 4364         Private method to set the visibility of the bookmarks toolbar.
 4365         
 4366         @param visible flag indicating the toolbar visibility
 4367         @type bool
 4368         """
 4369         if visible:
 4370             self.__bookmarksToolBar.show()
 4371         else:
 4372             self.__bookmarksToolBar.hide()
 4373         
 4374         # save state for next invokation
 4375         Preferences.setWebBrowser("BookmarksToolBarVisible", visible)
 4376     
 4377     def __setMenuBarVisibility(self, visible):
 4378         """
 4379         Private method to set the visibility of the menu bar.
 4380         
 4381         @param visible flag indicating the menu bar visibility
 4382         @type bool
 4383         """
 4384         if visible:
 4385             self.menuBar().show()
 4386             self.__navigationBar.superMenuButton().hide()
 4387         else:
 4388             self.menuBar().hide()
 4389             self.__navigationBar.superMenuButton().show()
 4390         
 4391         Preferences.setWebBrowser("MenuBarVisible", visible)
 4392     
 4393     def __setStatusBarVisible(self, visible):
 4394         """
 4395         Private method to set the visibility of the status bar.
 4396         
 4397         @param visible flag indicating the status bar visibility
 4398         @type bool
 4399         """
 4400         self.statusBar().setVisible(visible)
 4401         
 4402         Preferences.setWebBrowser("StatusBarVisible", visible)
 4403     
 4404     def eventMouseButtons(self):
 4405         """
 4406         Public method to get the last recorded mouse buttons.
 4407         
 4408         @return mouse buttons (Qt.MouseButtons)
 4409         """
 4410         return self.__eventMouseButtons
 4411     
 4412     def eventKeyboardModifiers(self):
 4413         """
 4414         Public method to get the last recorded keyboard modifiers.
 4415         
 4416         @return keyboard modifiers (Qt.KeyboardModifiers)
 4417         """
 4418         return self.__eventKeyboardModifiers
 4419     
 4420     def setEventMouseButtons(self, buttons):
 4421         """
 4422         Public method to record mouse buttons.
 4423         
 4424         @param buttons mouse buttons to record (Qt.MouseButtons)
 4425         """
 4426         self.__eventMouseButtons = buttons
 4427     
 4428     def setEventKeyboardModifiers(self, modifiers):
 4429         """
 4430         Public method to record keyboard modifiers.
 4431         
 4432         @param modifiers keyboard modifiers to record (Qt.KeyboardModifiers)
 4433         """
 4434         self.__eventKeyboardModifiers = modifiers
 4435     
 4436     def mousePressEvent(self, evt):
 4437         """
 4438         Protected method called by a mouse press event.
 4439         
 4440         @param evt reference to the mouse event (QMouseEvent)
 4441         """
 4442         if evt.button() == Qt.XButton1:
 4443             self.currentBrowser().triggerPageAction(QWebEnginePage.Back)
 4444         elif evt.button() == Qt.XButton2:
 4445             self.currentBrowser().triggerPageAction(QWebEnginePage.Forward)
 4446         else:
 4447             super(WebBrowserWindow, self).mousePressEvent(evt)
 4448     
 4449     @classmethod
 4450     def feedsManager(cls):
 4451         """
 4452         Class method to get a reference to the RSS feeds manager.
 4453         
 4454         @return reference to the RSS feeds manager (FeedsManager)
 4455         """
 4456         if cls._feedsManager is None:
 4457             from .Feeds.FeedsManager import FeedsManager
 4458             cls._feedsManager = FeedsManager()
 4459         
 4460         return cls._feedsManager
 4461     
 4462     def __showFeedsManager(self):
 4463         """
 4464         Private slot to show the feeds manager dialog.
 4465         """
 4466         feedsManager = self.feedsManager()
 4467         feedsManager.openUrl.connect(self.openUrl)
 4468         feedsManager.newTab.connect(self.openUrlNewTab)
 4469         feedsManager.newBackgroundTab.connect(self.openUrlNewBackgroundTab)
 4470         feedsManager.newWindow.connect(self.openUrlNewWindow)
 4471         feedsManager.newPrivateWindow.connect(self.openUrlNewPrivateWindow)
 4472         feedsManager.rejected.connect(
 4473             lambda fm: self.__feedsManagerClosed(fm))
 4474         feedsManager.show()
 4475     
 4476     def __feedsManagerClosed(self, feedsManager):
 4477         """
 4478         Private slot to handle closing the feeds manager dialog.
 4479         
 4480         @param feedsManager reference to the feeds manager object
 4481         @type FeedsManager
 4482         """
 4483         feedsManager.openUrl.disconnect(self.openUrl)
 4484         feedsManager.newTab.disconnect(self.openUrlNewTab)
 4485         feedsManager.newBackgroundTab.disconnect(self.openUrlNewBackgroundTab)
 4486         feedsManager.newWindow.disconnect(self.openUrlNewWindow)
 4487         feedsManager.newPrivateWindow.disconnect(self.openUrlNewPrivateWindow)
 4488         feedsManager.rejected.disconnect()
 4489     
 4490     def __showSiteinfoDialog(self):
 4491         """
 4492         Private slot to show the site info dialog.
 4493         """
 4494         from .SiteInfo.SiteInfoDialog import SiteInfoDialog
 4495         self.__siteinfoDialog = SiteInfoDialog(self.currentBrowser(), self)
 4496         self.__siteinfoDialog.show()
 4497 
 4498     @classmethod
 4499     def userAgentsManager(cls):
 4500         """
 4501         Class method to get a reference to the user agents manager.
 4502         
 4503         @return reference to the user agents manager (UserAgentManager)
 4504         """
 4505         if cls._userAgentsManager is None:
 4506             from .UserAgent.UserAgentManager import UserAgentManager
 4507             cls._userAgentsManager = UserAgentManager()
 4508         
 4509         return cls._userAgentsManager
 4510     
 4511     def __showUserAgentsDialog(self):
 4512         """
 4513         Private slot to show the user agents management dialog.
 4514         """
 4515         from .UserAgent.UserAgentsDialog import UserAgentsDialog
 4516         
 4517         dlg = UserAgentsDialog(self)
 4518         dlg.exec_()
 4519     
 4520     @classmethod
 4521     def syncManager(cls):
 4522         """
 4523         Class method to get a reference to the data synchronization manager.
 4524         
 4525         @return reference to the data synchronization manager (SyncManager)
 4526         """
 4527         if cls._syncManager is None:
 4528             from .Sync.SyncManager import SyncManager
 4529             cls._syncManager = SyncManager()
 4530         
 4531         return cls._syncManager
 4532     
 4533     def __showSyncDialog(self):
 4534         """
 4535         Private slot to show the synchronization dialog.
 4536         """
 4537         self.syncManager().showSyncDialog()
 4538     
 4539     @classmethod
 4540     def speedDial(cls):
 4541         """
 4542         Class method to get a reference to the speed dial.
 4543         
 4544         @return reference to the speed dial (SpeedDial)
 4545         """
 4546         if cls._speedDial is None:
 4547             from .SpeedDial.SpeedDial import SpeedDial
 4548             cls._speedDial = SpeedDial()
 4549         
 4550         return cls._speedDial
 4551     
 4552     def keyPressEvent(self, evt):
 4553         """
 4554         Protected method to handle key presses.
 4555         
 4556         @param evt reference to the key press event (QKeyEvent)
 4557         """
 4558         number = -1
 4559         key = evt.key()
 4560         
 4561         if key == Qt.Key_1:
 4562             number = 1
 4563         elif key == Qt.Key_2:
 4564             number = 2
 4565         elif key == Qt.Key_3:
 4566             number = 3
 4567         elif key == Qt.Key_4:
 4568             number = 4
 4569         elif key == Qt.Key_5:
 4570             number = 5
 4571         elif key == Qt.Key_6:
 4572             number = 6
 4573         elif key == Qt.Key_7:
 4574             number = 7
 4575         elif key == Qt.Key_8:
 4576             number = 8
 4577         elif key == Qt.Key_9:
 4578             number = 9
 4579         elif key == Qt.Key_0:
 4580             number = 10
 4581         
 4582         if number != -1:
 4583             if evt.modifiers() == Qt.KeyboardModifiers(Qt.AltModifier):
 4584                 if number == 10:
 4585                     number = self.__tabWidget.count()
 4586                 self.__tabWidget.setCurrentIndex(number - 1)
 4587                 return
 4588             
 4589             if evt.modifiers() == Qt.KeyboardModifiers(Qt.MetaModifier):
 4590                 url = self.speedDial().urlForShortcut(number - 1)
 4591                 if url.isValid():
 4592                     self.__linkActivated(url)
 4593                     return
 4594         
 4595         super(WebBrowserWindow, self).keyPressEvent(evt)
 4596     
 4597     def event(self, evt):
 4598         """
 4599         Public method handling events.
 4600         
 4601         @param evt reference to the event
 4602         @type QEvent
 4603         @return flag indicating a handled event
 4604         @rtype bool
 4605         """
 4606         if evt.type() == QEvent.WindowStateChange:
 4607             if (
 4608                 not bool(evt.oldState() & Qt.WindowFullScreen) and
 4609                 bool(self.windowState() & Qt.WindowFullScreen)
 4610             ):
 4611                 # enter full screen mode
 4612                 self.__windowStates = evt.oldState()
 4613                 self.__toolbarStates = self.saveState()
 4614                 self.menuBar().hide()
 4615                 self.statusBar().hide()
 4616                 self.__searchWidget.hide()
 4617                 self.__tabWidget.tabBar().hide()
 4618                 if Preferences.getWebBrowser("ShowToolbars"):
 4619                     for _title, toolbar in self.__toolbars.values():
 4620                         if toolbar is not self.__bookmarksToolBar:
 4621                             toolbar.hide()
 4622                 self.__navigationBar.exitFullScreenButton().setVisible(True)
 4623                 self.__navigationContainer.hide()
 4624             
 4625             elif (
 4626                 bool(evt.oldState() & Qt.WindowFullScreen) and
 4627                 not bool(self.windowState() & Qt.WindowFullScreen)
 4628             ):
 4629                 # leave full screen mode
 4630                 self.setWindowState(self.__windowStates)
 4631                 self.__htmlFullScreen = False
 4632                 if Preferences.getWebBrowser("MenuBarVisible"):
 4633                     self.menuBar().show()
 4634                 if Preferences.getWebBrowser("StatusBarVisible"):
 4635                     self.statusBar().show()
 4636                 self.restoreState(self.__toolbarStates)
 4637                 self.__tabWidget.tabBar().show()
 4638                 self.__navigationBar.exitFullScreenButton().setVisible(False)
 4639                 self.__navigationContainer.show()
 4640             
 4641             if self.__hideNavigationTimer:
 4642                 self.__hideNavigationTimer.stop()
 4643         
 4644         return super(WebBrowserWindow, self).event(evt)
 4645     
 4646     ###########################################################################
 4647     ## Interface to VirusTotal below                                         ##
 4648     ###########################################################################
 4649     
 4650     def __virusTotalScanCurrentSite(self):
 4651         """
 4652         Private slot to ask VirusTotal for a scan of the URL of the current
 4653         browser.
 4654         """
 4655         cb = self.currentBrowser()
 4656         if cb is not None:
 4657             url = cb.url()
 4658             if url.scheme() in ["http", "https", "ftp"]:
 4659                 self.requestVirusTotalScan(url)
 4660     
 4661     def requestVirusTotalScan(self, url):
 4662         """
 4663         Public method to submit a request to scan an URL by VirusTotal.
 4664         
 4665         @param url URL to be scanned (QUrl)
 4666         """
 4667         self.__virusTotal.submitUrl(url)
 4668     
 4669     def __virusTotalSubmitUrlError(self, msg):
 4670         """
 4671         Private slot to handle an URL scan submission error.
 4672         
 4673         @param msg error message (str)
 4674         """
 4675         E5MessageBox.critical(
 4676             self,
 4677             self.tr("VirusTotal Scan"),
 4678             self.tr("""<p>The VirusTotal scan could not be"""
 4679                     """ scheduled.<p>\n<p>Reason: {0}</p>""").format(msg))
 4680     
 4681     def __virusTotalUrlScanReport(self, url):
 4682         """
 4683         Private slot to initiate the display of the URL scan report page.
 4684         
 4685         @param url URL of the URL scan report page (string)
 4686         """
 4687         self.newTab(url)
 4688     
 4689     def __virusTotalFileScanReport(self, url):
 4690         """
 4691         Private slot to initiate the display of the file scan report page.
 4692         
 4693         @param url URL of the file scan report page (string)
 4694         """
 4695         self.newTab(url)
 4696     
 4697     def __virusTotalIpAddressReport(self):
 4698         """
 4699         Private slot to retrieve an IP address report.
 4700         """
 4701         ip, ok = QInputDialog.getText(
 4702             self,
 4703             self.tr("IP Address Report"),
 4704             self.tr("Enter a valid IPv4 address in dotted quad notation:"),
 4705             QLineEdit.Normal)
 4706         if ok and ip:
 4707             if ip.count(".") == 3:
 4708                 self.__virusTotal.getIpAddressReport(ip)
 4709             else:
 4710                 E5MessageBox.information(
 4711                     self,
 4712                     self.tr("IP Address Report"),
 4713                     self.tr("""The given IP address is not in dotted quad"""
 4714                             """ notation."""))
 4715     
 4716     def __virusTotalDomainReport(self):
 4717         """
 4718         Private slot to retrieve a domain report.
 4719         """
 4720         domain, ok = QInputDialog.getText(
 4721             self,
 4722             self.tr("Domain Report"),
 4723             self.tr("Enter a valid domain name:"),
 4724             QLineEdit.Normal)
 4725         if ok and domain:
 4726             self.__virusTotal.getDomainReport(domain)
 4727     
 4728     ###########################################################################
 4729     ## Style sheet handling below                                            ##
 4730     ###########################################################################
 4731     
 4732     def reloadUserStyleSheet(self):
 4733         """
 4734         Public method to reload the user style sheet.
 4735         """
 4736         styleSheet = Preferences.getWebBrowser("UserStyleSheet")
 4737         self.__setUserStyleSheet(styleSheet)
 4738     
 4739     def __setUserStyleSheet(self, styleSheetFile):
 4740         """
 4741         Private method to set a user style sheet.
 4742         
 4743         @param styleSheetFile name of the user style sheet file (string)
 4744         """
 4745         name = "_eric_userstylesheet"
 4746         userStyle = ""
 4747         
 4748         userStyle += (
 4749             WebBrowserTools.readAllFileContents(styleSheetFile)
 4750             .replace("\n", "")
 4751         )
 4752         
 4753         oldScript = self.webProfile().scripts().findScript(name)
 4754         if not oldScript.isNull():
 4755             self.webProfile().scripts().remove(oldScript)
 4756         
 4757         if userStyle:
 4758             from .WebBrowserPage import WebBrowserPage
 4759 
 4760             script = QWebEngineScript()
 4761             script.setName(name)
 4762             script.setInjectionPoint(QWebEngineScript.DocumentCreation)
 4763             script.setWorldId(WebBrowserPage.SafeJsWorld)
 4764             script.setRunsOnSubFrames(True)
 4765             script.setSourceCode(Scripts.setStyleSheet(userStyle))
 4766             self.webProfile().scripts().insert(script)
 4767     
 4768     ##########################################
 4769     ## Support for desktop notifications below
 4770     ##########################################
 4771     
 4772     @classmethod
 4773     def showNotification(cls, icon, heading, text, timeout=None):
 4774         """
 4775         Class method to show a desktop notification.
 4776         
 4777         @param icon icon to be shown in the notification
 4778         @type QPixmap
 4779         @param heading heading of the notification
 4780         @type str
 4781         @param text text of the notification
 4782         @type str
 4783         @param timeout time in seconds the notification should be shown
 4784             (None = use configured timeout, 0 = indefinitely)
 4785         @type int
 4786         """
 4787         if Preferences.getUI("NotificationsEnabled"):
 4788             if cls._notification is None:
 4789                 from UI.NotificationWidget import NotificationWidget
 4790                 cls._notification = NotificationWidget()
 4791             cls._notification.setPixmap(icon)
 4792             cls._notification.setHeading(heading)
 4793             cls._notification.setText(text)
 4794             if timeout is None:
 4795                 timeout = Preferences.getUI("NotificationTimeout")
 4796             cls._notification.setTimeout(timeout)
 4797             cls._notification.move(
 4798                 Preferences.getUI("NotificationPosition"))
 4799             cls._notification.show()
 4800     
 4801     @classmethod
 4802     def notificationsEnabled(cls):
 4803         """
 4804         Class method to check, if notifications are enabled.
 4805         
 4806         @return flag indicating, if notifications are enabled (boolean)
 4807         """
 4808         return Preferences.getUI("NotificationsEnabled")
 4809     
 4810     ######################################
 4811     ## Support for global status bar below
 4812     ######################################
 4813     
 4814     @classmethod
 4815     def globalStatusBar(cls):
 4816         """
 4817         Class method to get a reference to a global status bar.
 4818         
 4819         The global status bar is the status bar of the main window. If
 4820         no such window exists and the web browser was called from the eric IDE,
 4821         the status bar of the IDE is returned.
 4822         
 4823         @return reference to the global status bar
 4824         @rtype QStatusBar
 4825         """
 4826         if cls.BrowserWindows:
 4827             return cls.BrowserWindows[0].statusBar()
 4828         else:
 4829             return None
 4830     
 4831     ###################################
 4832     ## Support for download files below
 4833     ###################################
 4834     
 4835     @classmethod
 4836     def downloadRequested(cls, download):
 4837         """
 4838         Class method to handle a download request.
 4839         
 4840         @param download reference to the download data
 4841         @type QWebEngineDownloadItem
 4842         """
 4843         cls.downloadManager().download(download)
 4844     
 4845     ########################################
 4846     ## Support for web engine profiles below
 4847     ########################################
 4848     
 4849     @classmethod
 4850     def webProfile(cls, private=False):
 4851         """
 4852         Class method handling the web engine profile.
 4853         
 4854         @param private flag indicating the privacy mode
 4855         @type bool
 4856         @return reference to the web profile object
 4857         @rtype QWebEngineProfile
 4858         """
 4859         if cls._webProfile is None:
 4860             if private:
 4861                 cls._webProfile = QWebEngineProfile()
 4862             else:
 4863                 cls._webProfile = QWebEngineProfile.defaultProfile()
 4864             cls._webProfile.downloadRequested.connect(
 4865                 cls.downloadRequested)
 4866             
 4867             # add the default user agent string
 4868             userAgent = cls._webProfile.httpUserAgent()
 4869             cls._webProfile.defaultUserAgent = userAgent
 4870             
 4871             if not private:
 4872                 if Preferences.getWebBrowser("DiskCacheEnabled"):
 4873                     cls._webProfile.setHttpCacheType(
 4874                         QWebEngineProfile.DiskHttpCache)
 4875                     cls._webProfile.setHttpCacheMaximumSize(
 4876                         Preferences.getWebBrowser("DiskCacheSize") *
 4877                         1024 * 1024)
 4878                     cls._webProfile.setCachePath(os.path.join(
 4879                         Utilities.getConfigDir(), "web_browser"))
 4880                 else:
 4881                     cls._webProfile.setHttpCacheType(
 4882                         QWebEngineProfile.MemoryHttpCache)
 4883                     cls._webProfile.setHttpCacheMaximumSize(0)
 4884                 cls._webProfile.setPersistentStoragePath(os.path.join(
 4885                     Utilities.getConfigDir(), "web_browser",
 4886                     "persistentstorage"))
 4887                 cls._webProfile.setPersistentCookiesPolicy(
 4888                     QWebEngineProfile.AllowPersistentCookies)
 4889             
 4890             try:
 4891                 cls._webProfile.setSpellCheckEnabled(
 4892                     Preferences.getWebBrowser("SpellCheckEnabled"))
 4893                 cls._webProfile.setSpellCheckLanguages(
 4894                     Preferences.getWebBrowser("SpellCheckLanguages"))
 4895             except AttributeError:
 4896                 # not yet supported
 4897                 pass
 4898             
 4899             # Setup QWebChannel user scripts
 4900             from .WebBrowserPage import WebBrowserPage
 4901             
 4902             # WebChannel for SafeJsWorld
 4903             script = QWebEngineScript()
 4904             script.setName("_eric_webchannel")
 4905             script.setInjectionPoint(QWebEngineScript.DocumentCreation)
 4906             script.setWorldId(WebBrowserPage.SafeJsWorld)
 4907             script.setRunsOnSubFrames(True)
 4908             script.setSourceCode(Scripts.setupWebChannel(script.worldId()))
 4909             cls._webProfile.scripts().insert(script)
 4910             
 4911             # WebChannel for UnsafeJsWorld
 4912             script2 = QWebEngineScript()
 4913             script2.setName("_eric_webchannel2")
 4914             script2.setInjectionPoint(QWebEngineScript.DocumentCreation)
 4915             script2.setWorldId(WebBrowserPage.UnsafeJsWorld)
 4916             script2.setRunsOnSubFrames(True)
 4917             script2.setSourceCode(Scripts.setupWebChannel(script2.worldId()))
 4918             cls._webProfile.scripts().insert(script2)
 4919             
 4920             # document.window object addons
 4921             script3 = QWebEngineScript()
 4922             script3.setName("_eric_window_object")
 4923             script3.setInjectionPoint(QWebEngineScript.DocumentCreation)
 4924             script3.setWorldId(WebBrowserPage.UnsafeJsWorld)
 4925             script3.setRunsOnSubFrames(True)
 4926             script3.setSourceCode(Scripts.setupWindowObject())
 4927             cls._webProfile.scripts().insert(script3)
 4928         
 4929         return cls._webProfile
 4930     
 4931     @classmethod
 4932     def webSettings(cls):
 4933         """
 4934         Class method to get the web settings of the current profile.
 4935         
 4936         @return web settings of the current profile
 4937         @rtype QWebEngineSettings
 4938         """
 4939         return cls.webProfile().settings()
 4940     
 4941     ####################################################
 4942     ## Methods below implement session related functions
 4943     ####################################################
 4944     
 4945     @classmethod
 4946     def sessionManager(cls):
 4947         """
 4948         Class method to get a reference to the session manager.
 4949         
 4950         @return reference to the session manager
 4951         @rtype SessionManager
 4952         """
 4953         if cls._sessionManager is None and not cls._isPrivate:
 4954             from .Session.SessionManager import SessionManager
 4955             cls._sessionManager = SessionManager()
 4956         
 4957         return cls._sessionManager
 4958     
 4959     def __showSessionManagerDialog(self):
 4960         """
 4961         Private slot to show the session manager dialog.
 4962         """
 4963         self.sessionManager().showSessionManagerDialog()
 4964     
 4965     ##########################################################
 4966     ## Methods below implement safe browsing related functions
 4967     ##########################################################
 4968     
 4969     @classmethod
 4970     def safeBrowsingManager(cls):
 4971         """
 4972         Class method to get a reference to the safe browsing interface.
 4973         
 4974         @return reference to the safe browsing manager
 4975         @rtype SafeBrowsingManager
 4976         """
 4977         if cls._safeBrowsingManager is None:
 4978             from .SafeBrowsing.SafeBrowsingManager import SafeBrowsingManager
 4979             cls._safeBrowsingManager = SafeBrowsingManager()
 4980         
 4981         return cls._safeBrowsingManager
 4982     
 4983     def __showSafeBrowsingDialog(self):
 4984         """
 4985         Private slot to show the safe browsing management dialog.
 4986         """
 4987         self.safeBrowsingManager().showSafeBrowsingDialog()
 4988     
 4989     #############################################################
 4990     ## Methods below implement protocol handler related functions
 4991     #############################################################
 4992     
 4993     @classmethod
 4994     def protocolHandlerManager(cls):
 4995         """
 4996         Class method to get a reference to the protocol handler manager.
 4997         
 4998         @return reference to the protocol handler manager
 4999         @rtype ProtocolHandlerManager
 5000         """
 5001         if cls._protocolHandlerManager is None:
 5002             from .Network.ProtocolHandlerManager import ProtocolHandlerManager
 5003             cls._protocolHandlerManager = ProtocolHandlerManager()
 5004         
 5005         return cls._protocolHandlerManager
 5006     
 5007     def __showProtocolHandlerManagerDialog(self):
 5008         """
 5009         Private slot to show the protocol handler manager dialog.
 5010         """
 5011         self.protocolHandlerManager().showProtocolHandlerManagerDialog()
 5012     
 5013     ###############################################################
 5014     ## Methods below implement single application related functions
 5015     ###############################################################
 5016     
 5017     @pyqtSlot(str)
 5018     def __saLoadUrl(self, urlStr):
 5019         """
 5020         Private slot to load an URL received via the single application
 5021         protocol.
 5022         
 5023         @param urlStr URL to be loaded
 5024         @type str
 5025         """
 5026         url = QUrl.fromUserInput(urlStr)
 5027         self.__linkActivated(url)
 5028         
 5029         self.raise_()
 5030         self.activateWindow()
 5031     
 5032     @pyqtSlot(str)
 5033     def __saNewTab(self, urlStr):
 5034         """
 5035         Private slot to load an URL received via the single application
 5036         protocol in a new tab.
 5037         
 5038         @param urlStr URL to be loaded
 5039         @type str
 5040         """
 5041         url = QUrl.fromUserInput(urlStr)
 5042         self.newTab(url)
 5043         
 5044         self.raise_()
 5045         self.activateWindow()
 5046     
 5047     @pyqtSlot(str)
 5048     def __saSearchWord(self, word):
 5049         """
 5050         Private slot to search for the given word.
 5051         
 5052         @param word word to be searched for
 5053         @type str
 5054         """
 5055         if WebBrowserWindow._useQtHelp:
 5056             self.__searchWord = word
 5057             self.__searchForWord()
 5058         
 5059         self.raise_()
 5060         self.activateWindow()
 5061     
 5062     ######################################################
 5063     ## Methods below implement shortcuts related functions
 5064     ######################################################
 5065     
 5066     def __configShortcuts(self):
 5067         """
 5068         Private slot to configure the keyboard shortcuts.
 5069         """
 5070         if self.__shortcutsDialog is None:
 5071             from Preferences.ShortcutsDialog import ShortcutsDialog
 5072             self.__shortcutsDialog = ShortcutsDialog(self)
 5073         self.__shortcutsDialog.populate(helpViewer=self)
 5074         self.__shortcutsDialog.show()
 5075     
 5076     def __exportShortcuts(self):
 5077         """
 5078         Private slot to export the keyboard shortcuts.
 5079         """
 5080         fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
 5081             None,
 5082             self.tr("Export Keyboard Shortcuts"),
 5083             "",
 5084             self.tr("Keyboard shortcut file (*.e4k)"),
 5085             "",
 5086             E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
 5087         
 5088         if not fn:
 5089             return
 5090         
 5091         ext = QFileInfo(fn).suffix()
 5092         if not ext:
 5093             ex = selectedFilter.split("(*")[1].split(")")[0]
 5094             if ex:
 5095                 fn += ex
 5096         
 5097         from Preferences import Shortcuts
 5098         Shortcuts.exportShortcuts(fn, helpViewer=self)
 5099 
 5100     def __importShortcuts(self):
 5101         """
 5102         Private slot to import the keyboard shortcuts.
 5103         """
 5104         fn = E5FileDialog.getOpenFileName(
 5105             None,
 5106             self.tr("Import Keyboard Shortcuts"),
 5107             "",
 5108             self.tr("Keyboard shortcut file (*.e4k)"))
 5109         
 5110         if fn:
 5111             from Preferences import Shortcuts
 5112             Shortcuts.importShortcuts(fn, helpViewer=self)