WebBrowser/WebBrowserWindow.py

branch
maintenance
changeset 5730
6422afc7adc4
parent 5722
433187e73c0f
child 5734
d8b99b5fa673
equal deleted inserted replaced
5695:9a71bd9e2e37 5730:6422afc7adc4
19 19
20 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, \ 20 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, \
21 QUrl, QTextCodec, QProcess, QEvent, qVersion 21 QUrl, QTextCodec, QProcess, QEvent, qVersion
22 from PyQt5.QtGui import QDesktopServices, QKeySequence, QFont, QFontMetrics 22 from PyQt5.QtGui import QDesktopServices, QKeySequence, QFont, QFontMetrics
23 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QSizePolicy, QDockWidget, \ 23 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QSizePolicy, QDockWidget, \
24 QComboBox, QLabel, QSplitter, QMenu, QToolButton, QLineEdit, \ 24 QComboBox, QLabel, QMenu, QToolButton, QLineEdit, QApplication, \
25 QApplication, QWhatsThis, QDialog, QHBoxLayout, QProgressBar, QAction, \ 25 QWhatsThis, QDialog, QHBoxLayout, QProgressBar, QInputDialog
26 QInputDialog
27 from PyQt5.QtWebEngineWidgets import QWebEngineSettings, QWebEnginePage, \ 26 from PyQt5.QtWebEngineWidgets import QWebEngineSettings, QWebEnginePage, \
28 QWebEngineProfile, QWebEngineScript 27 QWebEngineProfile, QWebEngineScript
29 try: 28 try:
30 from PyQt5.QtHelp import QHelpEngine, QHelpEngineCore, QHelpSearchQuery 29 from PyQt5.QtHelp import QHelpEngine, QHelpEngineCore, QHelpSearchQuery
31 QTHELP_AVAILABLE = True 30 QTHELP_AVAILABLE = True
125 @keyparam searchWord word to search for (string) 124 @keyparam searchWord word to search for (string)
126 @keyparam private flag indicating a private browsing window (bool) 125 @keyparam private flag indicating a private browsing window (bool)
127 @keyparam qthelp flag indicating to enable the QtHelp support (bool) 126 @keyparam qthelp flag indicating to enable the QtHelp support (bool)
128 @keyparam settingsDir directory to be used for the settings files (str) 127 @keyparam settingsDir directory to be used for the settings files (str)
129 """ 128 """
129 self.__hideNavigationTimer = None
130
130 super(WebBrowserWindow, self).__init__(parent) 131 super(WebBrowserWindow, self).__init__(parent)
131 self.setObjectName(name) 132 self.setObjectName(name)
132 if private: 133 if private:
133 self.setWindowTitle(self.tr("eric6 Web Browser (Private Mode)")) 134 self.setWindowTitle(self.tr("eric6 Web Browser (Private Mode)"))
134 else: 135 else:
176 from .WebBrowserTabWidget import WebBrowserTabWidget 177 from .WebBrowserTabWidget import WebBrowserTabWidget
177 from .AdBlock.AdBlockIcon import AdBlockIcon 178 from .AdBlock.AdBlockIcon import AdBlockIcon
178 from .StatusBar.JavaScriptIcon import JavaScriptIcon 179 from .StatusBar.JavaScriptIcon import JavaScriptIcon
179 from .StatusBar.ImagesIcon import ImagesIcon 180 from .StatusBar.ImagesIcon import ImagesIcon
180 from .VirusTotal.VirusTotalApi import VirusTotalAPI 181 from .VirusTotal.VirusTotalApi import VirusTotalAPI
182 from .Navigation.NavigationBar import NavigationBar
183 from .Navigation.NavigationContainer import NavigationContainer
184 from .Bookmarks.BookmarksToolBar import BookmarksToolBar
181 185
182 if not self.__fromEric: 186 if not self.__fromEric:
183 self.setStyle(Preferences.getUI("Style"), 187 self.setStyle(Preferences.getUI("Style"),
184 Preferences.getUI("StyleSheet")) 188 Preferences.getUI("StyleSheet"))
185 189
214 self.__zoomWidget.setValue) 218 self.__zoomWidget.setValue)
215 self.__tabWidget.browserClosed.connect(self.webBrowserClosed) 219 self.__tabWidget.browserClosed.connect(self.webBrowserClosed)
216 self.__tabWidget.browserOpened.connect(self.webBrowserOpened) 220 self.__tabWidget.browserOpened.connect(self.webBrowserOpened)
217 221
218 self.__searchWidget = SearchWidget(self, self) 222 self.__searchWidget = SearchWidget(self, self)
223
224 self.__setIconDatabasePath()
225
226 bookmarksModel = self.bookmarksManager().bookmarksModel()
227 self.__bookmarksToolBar = BookmarksToolBar(self, bookmarksModel,
228 self)
229 self.__bookmarksToolBar.setIconSize(UI.Config.ToolBarIconSize)
230 self.__bookmarksToolBar.openUrl.connect(self.openUrl)
231 self.__bookmarksToolBar.newTab.connect(self.openUrlNewTab)
232 self.__bookmarksToolBar.newWindow.connect(self.openUrlNewWindow)
233
234 self.__navigationBar = NavigationBar(self)
235
236 self.__navigationContainer = NavigationContainer(self)
237 self.__navigationContainer.addWidget(self.__navigationBar)
238 self.__navigationContainer.addWidget(self.__bookmarksToolBar)
239
219 centralWidget = QWidget() 240 centralWidget = QWidget()
220 layout = QVBoxLayout() 241 layout = QVBoxLayout()
221 layout.setContentsMargins(1, 1, 1, 1) 242 layout.setContentsMargins(1, 1, 1, 1)
243 layout.setSpacing(0)
244 layout.addWidget(self.__navigationContainer)
222 layout.addWidget(self.__tabWidget) 245 layout.addWidget(self.__tabWidget)
223 layout.addWidget(self.__searchWidget) 246 layout.addWidget(self.__searchWidget)
224 self.__tabWidget.setSizePolicy( 247 self.__tabWidget.setSizePolicy(
225 QSizePolicy.Preferred, QSizePolicy.Expanding) 248 QSizePolicy.Preferred, QSizePolicy.Expanding)
226 centralWidget.setLayout(layout) 249 centralWidget.setLayout(layout)
280 else: 303 else:
281 self.restoreGeometry(g) 304 self.restoreGeometry(g)
282 305
283 WebBrowserWindow.BrowserWindows.append(self) 306 WebBrowserWindow.BrowserWindows.append(self)
284 307
285 self.__setIconDatabasePath()
286 self.__initWebEngineSettings() 308 self.__initWebEngineSettings()
287 309
288 # initialize some of our class objects 310 # initialize some of our class objects
289 self.passwordManager() 311 self.passwordManager()
290 self.historyManager() 312 self.historyManager()
376 if self.__searchWord is not None: 398 if self.__searchWord is not None:
377 QTimer.singleShot(0, self.__searchForWord) 399 QTimer.singleShot(0, self.__searchForWord)
378 400
379 e5App().focusChanged.connect(self.__appFocusChanged) 401 e5App().focusChanged.connect(self.__appFocusChanged)
380 402
403 self.__toolbarStates = self.saveState()
404
405 self.__hideNavigationTimer = QTimer(self)
406 self.__hideNavigationTimer.setInterval(1000)
407 self.__hideNavigationTimer.setSingleShot(True)
408 self.__hideNavigationTimer.timeout.connect(self.__hideNavigation)
409
381 QTimer.singleShot(0, syncMgr.loadSettings) 410 QTimer.singleShot(0, syncMgr.loadSettings)
382 411
383 def __del__(self): 412 def __del__(self):
384 """ 413 """
385 Special method called during object destruction. 414 Special method called during object destruction.
863 UI.PixmapCache.getIcon("home.png"), 892 UI.PixmapCache.getIcon("home.png"),
864 self.tr('&Home'), 893 self.tr('&Home'),
865 QKeySequence(self.tr("Ctrl+Home", "Go|Home")), 894 QKeySequence(self.tr("Ctrl+Home", "Go|Home")),
866 0, self, 'webbrowser_go_home') 895 0, self, 'webbrowser_go_home')
867 self.homeAct.setStatusTip(self.tr( 896 self.homeAct.setStatusTip(self.tr(
868 'Move to the initial help screen')) 897 'Move to the initial screen'))
869 self.homeAct.setWhatsThis(self.tr( 898 self.homeAct.setWhatsThis(self.tr(
870 """<b>Home</b>""" 899 """<b>Home</b>"""
871 """<p>Moves to the initial screen.</p>""" 900 """<p>Moves to the initial screen.</p>"""
872 )) 901 ))
873 if not self.__initShortcutsOnly: 902 if not self.__initShortcutsOnly:
1240 self.fullScreenAct = E5Action( 1269 self.fullScreenAct = E5Action(
1241 self.tr('Full Screen'), 1270 self.tr('Full Screen'),
1242 UI.PixmapCache.getIcon("windowFullscreen.png"), 1271 UI.PixmapCache.getIcon("windowFullscreen.png"),
1243 self.tr('&Full Screen'), 1272 self.tr('&Full Screen'),
1244 QKeySequence(self.tr('F11')), 0, 1273 QKeySequence(self.tr('F11')), 0,
1245 self, 'webbrowser_view_full_scree') 1274 self, 'webbrowser_view_full_screen')
1246 if not self.__initShortcutsOnly: 1275 if not self.__initShortcutsOnly:
1247 self.fullScreenAct.triggered.connect(self.__viewFullScreen) 1276 self.fullScreenAct.triggered.connect(self.toggleFullScreen)
1248 self.__actions.append(self.fullScreenAct) 1277 self.__actions.append(self.fullScreenAct)
1249 self.addAction(self.fullScreenAct) 1278 self.addAction(self.fullScreenAct)
1250 1279
1251 self.nextTabAct = E5Action( 1280 self.nextTabAct = E5Action(
1252 self.tr('Show next tab'), 1281 self.tr('Show next tab'),
1950 1979
1951 def __initToolbars(self): 1980 def __initToolbars(self):
1952 """ 1981 """
1953 Private method to create the toolbars. 1982 Private method to create the toolbars.
1954 """ 1983 """
1984 # save references to toolbars in order to hide them
1985 # when going full screen
1986 self.__toolbars = []
1987
1955 filetb = self.addToolBar(self.tr("File")) 1988 filetb = self.addToolBar(self.tr("File"))
1956 filetb.setObjectName("FileToolBar") 1989 filetb.setObjectName("FileToolBar")
1957 filetb.setIconSize(UI.Config.ToolBarIconSize) 1990 filetb.setIconSize(UI.Config.ToolBarIconSize)
1958 filetb.addAction(self.newTabAct) 1991 filetb.addAction(self.newTabAct)
1959 filetb.addAction(self.newAct) 1992 filetb.addAction(self.newAct)
1973 filetb.addAction(self.printPdfAct) 2006 filetb.addAction(self.printPdfAct)
1974 if self.printPreviewAct or self.printAct or self.printPdfAct: 2007 if self.printPreviewAct or self.printAct or self.printPdfAct:
1975 filetb.addSeparator() 2008 filetb.addSeparator()
1976 filetb.addAction(self.closeAct) 2009 filetb.addAction(self.closeAct)
1977 filetb.addAction(self.exitAct) 2010 filetb.addAction(self.exitAct)
2011 self.__toolbars.append(filetb)
1978 2012
1979 self.savePageScreenMenu = QMenu(self) 2013 self.savePageScreenMenu = QMenu(self)
1980 self.savePageScreenMenu.addAction(self.savePageScreenAct) 2014 self.savePageScreenMenu.addAction(self.savePageScreenAct)
1981 self.savePageScreenMenu.addAction(self.saveVisiblePageScreenAct) 2015 self.savePageScreenMenu.addAction(self.saveVisiblePageScreenAct)
1982 savePageScreenButton = filetb.widgetForAction(self.savePageScreenAct) 2016 savePageScreenButton = filetb.widgetForAction(self.savePageScreenAct)
1992 edittb.addAction(self.copyAct) 2026 edittb.addAction(self.copyAct)
1993 edittb.addAction(self.cutAct) 2027 edittb.addAction(self.cutAct)
1994 edittb.addAction(self.pasteAct) 2028 edittb.addAction(self.pasteAct)
1995 edittb.addSeparator() 2029 edittb.addSeparator()
1996 edittb.addAction(self.selectAllAct) 2030 edittb.addAction(self.selectAllAct)
2031 self.__toolbars.append(edittb)
1997 2032
1998 viewtb = self.addToolBar(self.tr("View")) 2033 viewtb = self.addToolBar(self.tr("View"))
1999 viewtb.setObjectName("ViewToolBar") 2034 viewtb.setObjectName("ViewToolBar")
2000 viewtb.setIconSize(UI.Config.ToolBarIconSize) 2035 viewtb.setIconSize(UI.Config.ToolBarIconSize)
2001 viewtb.addAction(self.zoomInAct) 2036 viewtb.addAction(self.zoomInAct)
2002 viewtb.addAction(self.zoomResetAct) 2037 viewtb.addAction(self.zoomResetAct)
2003 viewtb.addAction(self.zoomOutAct) 2038 viewtb.addAction(self.zoomOutAct)
2004 viewtb.addSeparator() 2039 viewtb.addSeparator()
2005 viewtb.addAction(self.fullScreenAct) 2040 viewtb.addAction(self.fullScreenAct)
2041 self.__toolbars.append(viewtb)
2006 2042
2007 findtb = self.addToolBar(self.tr("Find")) 2043 findtb = self.addToolBar(self.tr("Find"))
2008 findtb.setObjectName("FindToolBar") 2044 findtb.setObjectName("FindToolBar")
2009 findtb.setIconSize(UI.Config.ToolBarIconSize) 2045 findtb.setIconSize(UI.Config.ToolBarIconSize)
2010 findtb.addAction(self.findAct) 2046 findtb.addAction(self.findAct)
2011 findtb.addAction(self.findNextAct) 2047 findtb.addAction(self.findNextAct)
2012 findtb.addAction(self.findPrevAct) 2048 findtb.addAction(self.findPrevAct)
2049 self.__toolbars.append(findtb)
2013 2050
2014 if WebBrowserWindow._useQtHelp: 2051 if WebBrowserWindow._useQtHelp:
2015 filtertb = self.addToolBar(self.tr("Filter")) 2052 filtertb = self.addToolBar(self.tr("Filter"))
2016 filtertb.setObjectName("FilterToolBar") 2053 filtertb.setObjectName("FilterToolBar")
2017 self.filterCombo = QComboBox() 2054 self.filterCombo = QComboBox()
2021 filtertb.addWidget(self.filterCombo) 2058 filtertb.addWidget(self.filterCombo)
2022 self.__helpEngine.setupFinished.connect(self.__setupFilterCombo) 2059 self.__helpEngine.setupFinished.connect(self.__setupFilterCombo)
2023 self.filterCombo.activated[str].connect( 2060 self.filterCombo.activated[str].connect(
2024 self.__filterQtHelpDocumentation) 2061 self.__filterQtHelpDocumentation)
2025 self.__setupFilterCombo() 2062 self.__setupFilterCombo()
2063 self.__toolbars.append(filtertb)
2026 2064
2027 settingstb = self.addToolBar(self.tr("Settings")) 2065 settingstb = self.addToolBar(self.tr("Settings"))
2028 settingstb.setObjectName("SettingsToolBar") 2066 settingstb.setObjectName("SettingsToolBar")
2029 settingstb.setIconSize(UI.Config.ToolBarIconSize) 2067 settingstb.setIconSize(UI.Config.ToolBarIconSize)
2030 settingstb.addAction(self.prefAct) 2068 settingstb.addAction(self.prefAct)
2032 settingstb.addAction(self.cookiesAct) 2070 settingstb.addAction(self.cookiesAct)
2033 settingstb.addAction(self.flashCookiesAct) 2071 settingstb.addAction(self.flashCookiesAct)
2034 settingstb.addAction(self.personalDataAct) 2072 settingstb.addAction(self.personalDataAct)
2035 settingstb.addAction(self.greaseMonkeyAct) 2073 settingstb.addAction(self.greaseMonkeyAct)
2036 settingstb.addAction(self.featurePermissionAct) 2074 settingstb.addAction(self.featurePermissionAct)
2075 self.__toolbars.append(settingstb)
2037 2076
2038 toolstb = self.addToolBar(self.tr("Tools")) 2077 toolstb = self.addToolBar(self.tr("Tools"))
2039 toolstb.setObjectName("ToolsToolBar") 2078 toolstb.setObjectName("ToolsToolBar")
2040 toolstb.setIconSize(UI.Config.ToolBarIconSize) 2079 toolstb.setIconSize(UI.Config.ToolBarIconSize)
2041 toolstb.addAction(self.feedsManagerAct) 2080 toolstb.addAction(self.feedsManagerAct)
2042 toolstb.addAction(self.siteInfoAct) 2081 toolstb.addAction(self.siteInfoAct)
2043 toolstb.addSeparator() 2082 toolstb.addSeparator()
2044 toolstb.addAction(self.synchronizationAct) 2083 toolstb.addAction(self.synchronizationAct)
2084 self.__toolbars.append(toolstb)
2045 2085
2046 helptb = self.addToolBar(self.tr("Help")) 2086 helptb = self.addToolBar(self.tr("Help"))
2047 helptb.setObjectName("HelpToolBar") 2087 helptb.setObjectName("HelpToolBar")
2048 helptb.setIconSize(UI.Config.ToolBarIconSize) 2088 helptb.setIconSize(UI.Config.ToolBarIconSize)
2049 helptb.addAction(self.whatsThisAct) 2089 helptb.addAction(self.whatsThisAct)
2050 2090 self.__toolbars.append(helptb)
2051 self.addToolBarBreak()
2052
2053 gotb = self.addToolBar(self.tr("Go"))
2054 gotb.setObjectName("GoToolBar")
2055 gotb.setIconSize(UI.Config.ToolBarIconSize)
2056 gotb.addAction(self.backAct)
2057 gotb.addAction(self.forwardAct)
2058 gotb.addAction(self.reloadAct)
2059 gotb.addAction(self.stopAct)
2060 gotb.addAction(self.homeAct)
2061 gotb.addSeparator()
2062
2063 self.__navigationSplitter = QSplitter(gotb)
2064 self.__navigationSplitter.addWidget(self.__tabWidget.stackedUrlBar())
2065
2066 from .WebBrowserWebSearchWidget import WebBrowserWebSearchWidget
2067 self.searchEdit = WebBrowserWebSearchWidget(self)
2068 sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
2069 sizePolicy.setHorizontalStretch(2)
2070 sizePolicy.setVerticalStretch(0)
2071 self.searchEdit.setSizePolicy(sizePolicy)
2072 self.searchEdit.search.connect(self.__linkActivated)
2073 self.__navigationSplitter.addWidget(self.searchEdit)
2074 gotb.addWidget(self.__navigationSplitter)
2075
2076 self.__navigationSplitter.setSizePolicy(
2077 QSizePolicy.Expanding, QSizePolicy.Maximum)
2078 self.__navigationSplitter.setCollapsible(0, False)
2079
2080 self.backMenu = QMenu(self)
2081 self.backMenu.aboutToShow.connect(self.__showBackMenu)
2082 self.backMenu.triggered.connect(self.__navigationMenuActionTriggered)
2083 backButton = gotb.widgetForAction(self.backAct)
2084 backButton.setMenu(self.backMenu)
2085 backButton.setPopupMode(QToolButton.MenuButtonPopup)
2086
2087 self.forwardMenu = QMenu(self)
2088 self.forwardMenu.aboutToShow.connect(self.__showForwardMenu)
2089 self.forwardMenu.triggered.connect(
2090 self.__navigationMenuActionTriggered)
2091 forwardButton = gotb.widgetForAction(self.forwardAct)
2092 forwardButton.setMenu(self.forwardMenu)
2093 forwardButton.setPopupMode(QToolButton.MenuButtonPopup)
2094
2095 from .Bookmarks.BookmarksToolBar import BookmarksToolBar
2096 bookmarksModel = self.bookmarksManager().bookmarksModel()
2097 self.bookmarksToolBar = BookmarksToolBar(self, bookmarksModel, self)
2098 self.bookmarksToolBar.setObjectName("BookmarksToolBar")
2099 self.bookmarksToolBar.setIconSize(UI.Config.ToolBarIconSize)
2100 self.bookmarksToolBar.openUrl.connect(self.openUrl)
2101 self.bookmarksToolBar.newTab.connect(self.openUrlNewTab)
2102 self.bookmarksToolBar.newWindow.connect(self.openUrlNewWindow)
2103 self.addToolBarBreak()
2104 self.addToolBar(self.bookmarksToolBar)
2105 2091
2106 self.addToolBarBreak() 2092 self.addToolBarBreak()
2107 vttb = self.addToolBar(self.tr("VirusTotal")) 2093 vttb = self.addToolBar(self.tr("VirusTotal"))
2108 vttb.setObjectName("VirusTotalToolBar") 2094 vttb.setObjectName("VirusTotalToolBar")
2109 vttb.setIconSize(UI.Config.ToolBarIconSize) 2095 vttb.setIconSize(UI.Config.ToolBarIconSize)
2123 if not Preferences.getWebBrowser("VirusTotalEnabled") or \ 2109 if not Preferences.getWebBrowser("VirusTotalEnabled") or \
2124 Preferences.getWebBrowser("VirusTotalServiceKey") == "": 2110 Preferences.getWebBrowser("VirusTotalServiceKey") == "":
2125 self.virustotalScanCurrentAct.setEnabled(False) 2111 self.virustotalScanCurrentAct.setEnabled(False)
2126 self.virustotalIpReportAct.setEnabled(False) 2112 self.virustotalIpReportAct.setEnabled(False)
2127 self.virustotalDomainReportAct.setEnabled(False) 2113 self.virustotalDomainReportAct.setEnabled(False)
2114 self.__toolbars.append(vttb)
2128 2115
2129 def __nextTab(self): 2116 def __nextTab(self):
2130 """ 2117 """
2131 Private slot used to show the next tab. 2118 Private slot used to show the next tab.
2132 """ 2119 """
2349 Public slot called when backward references are available. 2336 Public slot called when backward references are available.
2350 2337
2351 @param b flag indicating availability of the backwards action (boolean) 2338 @param b flag indicating availability of the backwards action (boolean)
2352 """ 2339 """
2353 self.backAct.setEnabled(b) 2340 self.backAct.setEnabled(b)
2341 self.__navigationBar.backButton().setEnabled(b)
2354 2342
2355 def setForwardAvailable(self, b): 2343 def setForwardAvailable(self, b):
2356 """ 2344 """
2357 Public slot called when forward references are available. 2345 Public slot called when forward references are available.
2358 2346
2359 @param b flag indicating the availability of the forwards action 2347 @param b flag indicating the availability of the forwards action
2360 (boolean) 2348 (boolean)
2361 """ 2349 """
2362 self.forwardAct.setEnabled(b) 2350 self.forwardAct.setEnabled(b)
2351 self.__navigationBar.forwardButton().setEnabled(b)
2363 2352
2364 def setLoadingActions(self, b): 2353 def setLoadingActions(self, b):
2365 """ 2354 """
2366 Public slot to set the loading dependent actions. 2355 Public slot to set the loading dependent actions.
2367 2356
2368 @param b flag indicating the loading state to consider (boolean) 2357 @param b flag indicating the loading state to consider (boolean)
2369 """ 2358 """
2370 self.reloadAct.setEnabled(not b) 2359 self.reloadAct.setEnabled(not b)
2371 self.stopAct.setEnabled(b) 2360 self.stopAct.setEnabled(b)
2361
2362 self.__navigationBar.reloadButton().setEnabled(not b)
2363 self.__navigationBar.stopButton().setEnabled(b)
2372 2364
2373 def __addBookmark(self): 2365 def __addBookmark(self):
2374 """ 2366 """
2375 Private slot called to add the displayed file to the bookmarks. 2367 Private slot called to add the displayed file to the bookmarks.
2376 """ 2368 """
2541 2533
2542 self.downloadManager().shutdown() 2534 self.downloadManager().shutdown()
2543 2535
2544 self.cookieJar().close() 2536 self.cookieJar().close()
2545 2537
2546 self.bookmarksToolBar.setModel(None) 2538 self.__bookmarksToolBar.setModel(None)
2547 self.bookmarksManager().close() 2539 self.bookmarksManager().close()
2548 2540
2549 self.historyManager().close() 2541 self.historyManager().close()
2550 2542
2551 self.passwordManager().close() 2543 self.passwordManager().close()
2564 2556
2565 self.__virusTotal.close() 2557 self.__virusTotal.close()
2566 2558
2567 self.flashCookieManager().shutdown() 2559 self.flashCookieManager().shutdown()
2568 2560
2569 self.searchEdit.openSearchManager().close() 2561 self.__navigationBar.searchEdit().openSearchManager().close()
2570 2562
2571 if len(WebBrowserWindow.BrowserWindows) == 1: 2563 if len(WebBrowserWindow.BrowserWindows) == 1:
2572 # it is the last window 2564 # it is the last window
2573 self.tabManager().close() 2565 self.tabManager().close()
2574 2566
2577 self.__searchEngine.cancelSearching() 2569 self.__searchEngine.cancelSearching()
2578 2570
2579 if self.__helpInstaller: 2571 if self.__helpInstaller:
2580 self.__helpInstaller.stop() 2572 self.__helpInstaller.stop()
2581 2573
2582 self.searchEdit.saveSearches() 2574 self.__navigationBar.searchEdit().saveSearches()
2583 2575
2584 self.__tabWidget.closeAllBrowsers(shutdown=True) 2576 self.__tabWidget.closeAllBrowsers(shutdown=True)
2585 2577
2586 state = self.saveState() 2578 state = self.saveState()
2587 Preferences.setWebBrowser("WebBrowserState", state) 2579 Preferences.setWebBrowser("WebBrowserState", state)
2665 Private slot called to handle the zoom reset action. 2657 Private slot called to handle the zoom reset action.
2666 """ 2658 """
2667 self.currentBrowser().zoomReset() 2659 self.currentBrowser().zoomReset()
2668 self.__zoomWidget.setValue(self.currentBrowser().zoomValue()) 2660 self.__zoomWidget.setValue(self.currentBrowser().zoomValue())
2669 2661
2670 def __viewFullScreen(self): 2662 def toggleFullScreen(self):
2671 """ 2663 """
2672 Private slot called to toggle fullscreen mode. 2664 Public slot called to toggle the full screen mode.
2673 """ 2665 """
2674 if self.__htmlFullScreen: 2666 if self.__htmlFullScreen:
2675 self.currentBrowser().triggerPageAction( 2667 self.currentBrowser().triggerPageAction(
2676 QWebEnginePage.ExitFullScreen) 2668 QWebEnginePage.ExitFullScreen)
2677 return 2669 return
2678 2670
2679 if self.isFullScreen(): 2671 if self.isFullScreen():
2680 # switch back to normal 2672 # switch back to normal
2681 self.showNormal() 2673 self.showNormal()
2682 self.menuBar().show()
2683 self.fullScreenAct.setIcon(
2684 UI.PixmapCache.getIcon("windowFullscreen.png"))
2685 self.fullScreenAct.setIconText(self.tr('Full Screen'))
2686 else: 2674 else:
2687 # switch to full screen 2675 # switch to full screen
2688 self.showFullScreen() 2676 self.showFullScreen()
2689 self.menuBar().hide()
2690 self.fullScreenAct.setIcon(
2691 UI.PixmapCache.getIcon("windowRestore.png"))
2692 self.fullScreenAct.setIconText(self.tr('Restore Window'))
2693 2677
2694 def enterHtmlFullScreen(self): 2678 def enterHtmlFullScreen(self):
2695 """ 2679 """
2696 Public method to switch to full screen initiated by the 2680 Public method to switch to full screen initiated by the
2697 HTML page. 2681 HTML page.
2698 """ 2682 """
2699 self.showFullScreen() 2683 self.showFullScreen()
2700 self.__htmlFullScreen = True 2684 self.__htmlFullScreen = True
2685
2686 def isFullScreenNavigationVisible(self):
2687 """
2688 Public method to check, if full screen navigation is active.
2689
2690 @return flag indicating visibility of the navigation container in full
2691 screen mode
2692 @rtype bool
2693 """
2694 return self.isFullScreen() and self.__navigationContainer.isVisible()
2695
2696 def showFullScreenNavigation(self):
2697 """
2698 Public slot to show full screen navigation.
2699 """
2700 if self.__htmlFullScreen:
2701 return
2702
2703 if self.__hideNavigationTimer.isActive():
2704 self.__hideNavigationTimer.stop()
2705
2706 self.__navigationContainer.show()
2707
2708 def hideFullScreenNavigation(self):
2709 """
2710 Public slot to hide full screen navigation.
2711 """
2712 if not self.__hideNavigationTimer.isActive():
2713 self.__hideNavigationTimer.start()
2714
2715 def __hideNavigation(self):
2716 """
2717 Private slot to hide full screen navigation by timer.
2718 """
2719 browser = self.currentBrowser()
2720 mouseInBrowser = browser and browser.underMouse()
2721
2722 if self.isFullScreen() and mouseInBrowser:
2723 self.__navigationContainer.hide()
2701 2724
2702 def __copy(self): 2725 def __copy(self):
2703 """ 2726 """
2704 Private slot called to handle the copy action. 2727 Private slot called to handle the copy action.
2705 """ 2728 """
2830 2853
2831 self.historyManager().preferencesChanged() 2854 self.historyManager().preferencesChanged()
2832 2855
2833 self.__tabWidget.preferencesChanged() 2856 self.__tabWidget.preferencesChanged()
2834 2857
2835 self.searchEdit.preferencesChanged() 2858 self.__navigationBar.searchEdit().preferencesChanged()
2836 2859
2837 self.autoScroller().preferencesChanged() 2860 self.autoScroller().preferencesChanged()
2838 2861
2839 profile = self.webProfile() 2862 profile = self.webProfile()
2840 if not self.isPrivate(): 2863 if not self.isPrivate():
3248 Private slot to show the Settings menu. 3271 Private slot to show the Settings menu.
3249 """ 3272 """
3250 self.editMessageFilterAct.setEnabled( 3273 self.editMessageFilterAct.setEnabled(
3251 E5ErrorMessage.messageHandlerInstalled()) 3274 E5ErrorMessage.messageHandlerInstalled())
3252 3275
3253 def __showBackMenu(self):
3254 """
3255 Private slot showing the backwards navigation menu.
3256 """
3257 self.backMenu.clear()
3258 history = self.currentBrowser().history()
3259 historyCount = history.count()
3260 backItems = history.backItems(historyCount)
3261 for index in range(len(backItems) - 1, -1, -1):
3262 item = backItems[index]
3263 act = QAction(self)
3264 act.setData(-1 * (index + 1))
3265 icon = WebBrowserWindow.icon(item.url())
3266 act.setIcon(icon)
3267 act.setText(item.title())
3268 self.backMenu.addAction(act)
3269
3270 def __showForwardMenu(self):
3271 """
3272 Private slot showing the forwards navigation menu.
3273 """
3274 self.forwardMenu.clear()
3275 history = self.currentBrowser().history()
3276 historyCount = history.count()
3277 forwardItems = history.forwardItems(historyCount)
3278 for index in range(len(forwardItems)):
3279 item = forwardItems[index]
3280 act = QAction(self)
3281 act.setData(index + 1)
3282 icon = WebBrowserWindow.icon(item.url())
3283 act.setIcon(icon)
3284 act.setText(item.title())
3285 self.forwardMenu.addAction(act)
3286
3287 def __navigationMenuActionTriggered(self, act):
3288 """
3289 Private slot to go to the selected page.
3290
3291 @param act reference to the action selected in the navigation menu
3292 (QAction)
3293 """
3294 offset = act.data()
3295 history = self.currentBrowser().history()
3296 historyCount = history.count()
3297 if offset < 0:
3298 # go back
3299 history.goToItem(history.backItems(historyCount)[-1 * offset - 1])
3300 else:
3301 # go forward
3302 history.goToItem(history.forwardItems(historyCount)[offset - 1])
3303
3304 def __clearPrivateData(self): 3276 def __clearPrivateData(self):
3305 """ 3277 """
3306 Private slot to clear the private data. 3278 Private slot to clear the private data.
3307 """ 3279 """
3308 from .WebBrowserClearPrivateDataDialog import \ 3280 from .WebBrowserClearPrivateDataDialog import \
3317 if history: 3289 if history:
3318 self.historyManager().clear(historyPeriod) 3290 self.historyManager().clear(historyPeriod)
3319 self.__tabWidget.clearClosedTabsList() 3291 self.__tabWidget.clearClosedTabsList()
3320 self.webProfile().clearAllVisitedLinks() 3292 self.webProfile().clearAllVisitedLinks()
3321 if searches: 3293 if searches:
3322 self.searchEdit.clear() 3294 self.__navigationBar.searchEdit().clear()
3323 if downloads: 3295 if downloads:
3324 self.downloadManager().cleanup() 3296 self.downloadManager().cleanup()
3325 self.downloadManager().hide() 3297 self.downloadManager().hide()
3326 if favicons: 3298 if favicons:
3327 self.__clearIconsDatabase() 3299 self.__clearIconsDatabase()
3742 """ 3714 """
3743 Public method to get a reference to the opensearch manager object. 3715 Public method to get a reference to the opensearch manager object.
3744 3716
3745 @return reference to the opensearch manager object (OpenSearchManager) 3717 @return reference to the opensearch manager object (OpenSearchManager)
3746 """ 3718 """
3747 return self.searchEdit.openSearchManager() 3719 return self.__navigationBar.searchEdit().openSearchManager()
3748 3720
3749 def __aboutToShowTextEncodingMenu(self): 3721 def __aboutToShowTextEncodingMenu(self):
3750 """ 3722 """
3751 Private slot to populate the text encoding menu. 3723 Private slot to populate the text encoding menu.
3752 """ 3724 """
4019 if evt.type() == QEvent.WindowStateChange: 3991 if evt.type() == QEvent.WindowStateChange:
4020 if not bool(evt.oldState() & Qt.WindowFullScreen) and \ 3992 if not bool(evt.oldState() & Qt.WindowFullScreen) and \
4021 bool(self.windowState() & Qt.WindowFullScreen): 3993 bool(self.windowState() & Qt.WindowFullScreen):
4022 # enter full screen mode 3994 # enter full screen mode
4023 self.__windowStates = evt.oldState() 3995 self.__windowStates = evt.oldState()
3996 self.__toolbarStates = self.saveState()
3997 self.menuBar().hide()
3998 self.statusBar().hide()
3999 self.__searchWidget.hide()
4000 self.__tabWidget.tabBar().hide()
4001 for toolbar in self.__toolbars:
4002 toolbar.hide()
4003 self.__navigationBar.exitFullScreenButton().setVisible(True)
4004 self.__navigationContainer.hide()
4005
4024 elif bool(evt.oldState() & Qt.WindowFullScreen) and \ 4006 elif bool(evt.oldState() & Qt.WindowFullScreen) and \
4025 not bool(self.windowState() & Qt.WindowFullScreen): 4007 not bool(self.windowState() & Qt.WindowFullScreen):
4026 # leave full screen mode 4008 # leave full screen mode
4027 self.setWindowState(self.__windowStates) 4009 self.setWindowState(self.__windowStates)
4028 self.__htmlFullScreen = False 4010 self.__htmlFullScreen = False
4011 self.menuBar().show()
4012 self.statusBar().show()
4013 self.restoreState(self.__toolbarStates)
4014 self.__tabWidget.tabBar().show()
4015 self.__navigationBar.exitFullScreenButton().setVisible(False)
4016 self.__navigationContainer.show()
4017
4018 if self.__hideNavigationTimer:
4019 self.__hideNavigationTimer.stop()
4029 4020
4030 return super(WebBrowserWindow, self).event(evt) 4021 return super(WebBrowserWindow, self).event(evt)
4031 4022
4032 ########################################################################### 4023 ###########################################################################
4033 ## Interface to VirusTotal below ## 4024 ## Interface to VirusTotal below ##

eric ide

mercurial