eric6/WebBrowser/WebBrowserWindow.py

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

eric ide

mercurial