eric6/Helpviewer/HelpWindow.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
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 helpviewer main window.
8 """
9
10 from __future__ import unicode_literals
11 try:
12 str = unicode
13 except NameError:
14 pass
15
16 import os
17
18 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QByteArray, QSize, QTimer, \
19 QUrl, QThread, QTextCodec, QFileInfo
20 from PyQt5.QtGui import QDesktopServices, QKeySequence, QFont, QFontMetrics, \
21 QIcon
22 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QSizePolicy, QDockWidget, \
23 QComboBox, QLabel, QSplitter, QMenu, QToolButton, QLineEdit, \
24 QApplication, QWhatsThis, QDialog, QHBoxLayout, QProgressBar, QAction, \
25 QInputDialog
26 from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest
27 from PyQt5.QtWebKit import QWebSettings, QWebDatabase, QWebSecurityOrigin
28 from PyQt5.QtWebKitWidgets import QWebPage
29 try:
30 from PyQt5.QtHelp import QHelpEngine, QHelpEngineCore, QHelpSearchQuery
31 QTHELP_AVAILABLE = True
32 except ImportError:
33 QTHELP_AVAILABLE = False
34
35 from .Network.NetworkAccessManager import SSL_AVAILABLE
36
37 from .data import icons_rc # __IGNORE_WARNING__
38 from .data import html_rc # __IGNORE_WARNING__
39 from .data import javascript_rc # __IGNORE_WARNING__
40
41 from E5Gui.E5Action import E5Action
42 from E5Gui import E5MessageBox, E5FileDialog, E5ErrorMessage
43 from E5Gui.E5MainWindow import E5MainWindow
44 from E5Gui.E5Application import e5App
45 from E5Gui.E5ZoomWidget import E5ZoomWidget
46
47 from E5Network.E5NetworkIcon import E5NetworkIcon
48
49 import Preferences
50 from Preferences import Shortcuts
51
52 import Utilities
53 import Globals
54
55 import UI.PixmapCache
56 import UI.Config
57 from UI.Info import Version
58
59 from .HelpSingleApplication import HelpSingleApplicationServer
60
61
62 class HelpWindow(E5MainWindow):
63 """
64 Class implementing the web browser main window.
65
66 @signal helpClosed() emitted after the window was requested to close down
67 @signal zoomTextOnlyChanged(bool) emitted after the zoom text only setting
68 was changed
69 @signal privacyChanged(bool) emitted to indicate a new privacy mode
70 """
71 zoomTextOnlyChanged = pyqtSignal(bool)
72 helpClosed = pyqtSignal()
73 privacyChanged = pyqtSignal(bool)
74
75 helpwindows = []
76
77 _useQtHelp = QTHELP_AVAILABLE
78
79 _networkAccessManager = None
80 _cookieJar = None
81 _helpEngine = None
82 _bookmarksManager = None
83 _historyManager = None
84 _passwordManager = None
85 _adblockManager = None
86 _downloadManager = None
87 _feedsManager = None
88 _userAgentsManager = None
89 _syncManager = None
90 _speedDial = None
91 _personalInformationManager = None
92 _greaseMonkeyManager = None
93 _notification = None
94 _featurePermissionManager = None
95 _flashCookieManager = None
96 _zoomManager = None
97
98 def __init__(self, home, path, parent, name,
99 searchWord=None, qthelp=False, single=False, saname=""):
100 """
101 Constructor
102
103 @param home the URL to be shown
104 @type str
105 @param path the path of the working dir (usually '.')
106 @type str
107 @param parent parent widget of this window
108 @type QWidget
109 @param name name of this window
110 @type str
111 @param searchWord word to search for
112 @type str
113 @param qthelp flag indicating to enable the QtHelp support
114 @type bool
115 @param single flag indicating to start in single application mode
116 @type bool
117 @param saname name to be used for the single application server
118 @type str
119 """
120 super(HelpWindow, self).__init__(parent)
121 self.setObjectName(name)
122 self.setWindowTitle(self.tr("eric6 Web Browser"))
123
124 self.setWindowIcon(UI.PixmapCache.getIcon("ericWeb.png"))
125
126 self.mHistory = []
127 self.__lastConfigurationPageName = ""
128 self.__lastActiveWindow = None
129
130 self.__shortcutsDialog = None
131
132 self.__eventMouseButtons = Qt.NoButton
133 self.__eventKeyboardModifiers = Qt.NoModifier
134
135 HelpWindow.setUseQtHelp(qthelp or bool(searchWord))
136
137 from .SearchWidget import SearchWidget
138 from .HelpTocWidget import HelpTocWidget
139 from .HelpIndexWidget import HelpIndexWidget
140 from .HelpSearchWidget import HelpSearchWidget
141 from .HelpBrowserWV import HelpBrowser
142 from .HelpTabWidget import HelpTabWidget
143 from .AdBlock.AdBlockIcon import AdBlockIcon
144 from .VirusTotal.VirusTotalApi import VirusTotalAPI
145
146 self.setStyle(Preferences.getUI("Style"),
147 Preferences.getUI("StyleSheet"))
148
149 # initialize some SSL stuff
150 from E5Network.E5SslUtilities import initSSL
151 initSSL()
152
153 if HelpWindow._useQtHelp:
154 self.__helpEngine = QHelpEngine(
155 HelpWindow.getQtHelpCollectionFileName(),
156 self)
157 self.__removeOldDocumentation()
158 self.__helpEngine.warning.connect(self.__warning)
159 else:
160 self.__helpEngine = None
161 self.__helpInstaller = None
162
163 self.__zoomWidget = E5ZoomWidget(
164 UI.PixmapCache.getPixmap("zoomOut.png"),
165 UI.PixmapCache.getPixmap("zoomIn.png"),
166 UI.PixmapCache.getPixmap("zoomReset.png"), self)
167 self.statusBar().addPermanentWidget(self.__zoomWidget)
168 self.__zoomWidget.setMapping(
169 HelpBrowser.ZoomLevels, HelpBrowser.ZoomLevelDefault)
170 self.__zoomWidget.valueChanged.connect(self.__zoomValueChanged)
171
172 self.tabWidget = HelpTabWidget(self)
173 self.tabWidget.currentChanged[int].connect(self.__currentChanged)
174 self.tabWidget.titleChanged.connect(self.__titleChanged)
175 self.tabWidget.showMessage.connect(self.statusBar().showMessage)
176 self.tabWidget.browserZoomValueChanged.connect(
177 self.__zoomWidget.setValue)
178
179 self.findDlg = SearchWidget(self, self)
180 centralWidget = QWidget()
181 layout = QVBoxLayout()
182 layout.setContentsMargins(1, 1, 1, 1)
183 layout.addWidget(self.tabWidget)
184 layout.addWidget(self.findDlg)
185 self.tabWidget.setSizePolicy(
186 QSizePolicy.Preferred, QSizePolicy.Expanding)
187 centralWidget.setLayout(layout)
188 self.setCentralWidget(centralWidget)
189 self.findDlg.hide()
190
191 if HelpWindow._useQtHelp:
192 # setup the TOC widget
193 self.__tocWindow = HelpTocWidget(self.__helpEngine, self)
194 self.__tocDock = QDockWidget(self.tr("Contents"), self)
195 self.__tocDock.setObjectName("TocWindow")
196 self.__tocDock.setWidget(self.__tocWindow)
197 self.addDockWidget(Qt.LeftDockWidgetArea, self.__tocDock)
198
199 # setup the index widget
200 self.__indexWindow = HelpIndexWidget(self.__helpEngine, self)
201 self.__indexDock = QDockWidget(self.tr("Index"), self)
202 self.__indexDock.setObjectName("IndexWindow")
203 self.__indexDock.setWidget(self.__indexWindow)
204 self.addDockWidget(Qt.LeftDockWidgetArea, self.__indexDock)
205
206 # setup the search widget
207 self.__searchWord = searchWord
208 self.__indexing = False
209 self.__indexingProgress = None
210 self.__searchEngine = self.__helpEngine.searchEngine()
211 self.__searchEngine.indexingStarted.connect(
212 self.__indexingStarted)
213 self.__searchEngine.indexingFinished.connect(
214 self.__indexingFinished)
215 self.__searchWindow = HelpSearchWidget(
216 self.__searchEngine, self)
217 self.__searchDock = QDockWidget(self.tr("Search"), self)
218 self.__searchDock.setObjectName("SearchWindow")
219 self.__searchDock.setWidget(self.__searchWindow)
220 self.addDockWidget(Qt.LeftDockWidgetArea, self.__searchDock)
221
222 if Preferences.getHelp("SaveGeometry"):
223 g = Preferences.getGeometry("HelpViewerGeometry")
224 else:
225 g = QByteArray()
226 if g.isEmpty():
227 s = QSize(800, 800)
228 self.resize(s)
229 else:
230 self.restoreGeometry(g)
231
232 self.__setIconDatabasePath()
233 self.__initWebSettings()
234
235 self.__initActions()
236 self.__initMenus()
237 self.__initToolbars()
238
239 self.historyManager()
240
241 syncMgr = self.syncManager()
242 syncMgr.syncMessage.connect(self.statusBar().showMessage)
243 syncMgr.syncError.connect(self.statusBar().showMessage)
244
245 self.tabWidget.newBrowser(home)
246 self.tabWidget.currentBrowser().setFocus()
247
248 self.__class__.helpwindows.append(self)
249
250 self.__adBlockIcon = AdBlockIcon(self)
251 self.statusBar().addPermanentWidget(self.__adBlockIcon)
252 self.__adBlockIcon.setEnabled(
253 Preferences.getHelp("AdBlockEnabled"))
254 self.tabWidget.currentChanged[int].connect(
255 self.__adBlockIcon.currentChanged)
256 self.tabWidget.sourceChanged.connect(
257 self.__adBlockIcon.sourceChanged)
258
259 self.networkIcon = E5NetworkIcon(self)
260 self.statusBar().addPermanentWidget(self.networkIcon)
261
262 if len(HelpWindow.helpwindows):
263 QDesktopServices.setUrlHandler(
264 "http", HelpWindow.helpwindows[0].urlHandler)
265 QDesktopServices.setUrlHandler(
266 "https", HelpWindow.helpwindows[0].urlHandler)
267
268 # setup connections
269 self.__activating = False
270 if HelpWindow._useQtHelp:
271 # TOC window
272 self.__tocWindow.linkActivated.connect(self.__linkActivated)
273 self.__tocWindow.escapePressed.connect(
274 self.__activateCurrentBrowser)
275
276 # index window
277 self.__indexWindow.linkActivated.connect(self.__linkActivated)
278 self.__indexWindow.linksActivated.connect(
279 self.__linksActivated)
280 self.__indexWindow.escapePressed.connect(
281 self.__activateCurrentBrowser)
282
283 # search window
284 self.__searchWindow.linkActivated.connect(
285 self.__linkActivated)
286 self.__searchWindow.escapePressed.connect(
287 self.__activateCurrentBrowser)
288
289 state = Preferences.getHelp("HelpViewerState")
290 self.restoreState(state)
291
292 self.__initHelpDb()
293
294 self.__virusTotal = VirusTotalAPI(self)
295 self.__virusTotal.submitUrlError.connect(
296 self.__virusTotalSubmitUrlError)
297 self.__virusTotal.urlScanReport.connect(
298 self.__virusTotalUrlScanReport)
299 self.__virusTotal.fileScanReport.connect(
300 self.__virusTotalFileScanReport)
301
302 self.__shutdownCalled = False
303
304 self.flashCookieManager()
305
306 if single:
307 self.SAServer = HelpSingleApplicationServer(saname)
308 self.SAServer.loadUrl.connect(self.__saLoadUrl)
309 self.SAServer.newTab.connect(self.__saNewTab)
310 self.SAServer.search.connect(self.__saSearchWord)
311 self.SAServer.shutdown.connect(self.shutdown)
312 else:
313 self.SAServer = None
314
315 if HelpWindow._useQtHelp:
316 QTimer.singleShot(50, self.__lookForNewDocumentation)
317 if self.__searchWord is not None:
318 QTimer.singleShot(0, self.__searchForWord)
319
320 e5App().focusChanged.connect(self.__appFocusChanged)
321
322 QTimer.singleShot(0, syncMgr.loadSettings)
323
324 def __del__(self):
325 """
326 Special method called during object destruction.
327
328 Note: This empty variant seems to get rid of the Qt message
329 'Warning: QBasicTimer::start: QBasicTimer can only be used with
330 threads started with QThread'
331 """
332 pass
333
334 def __setIconDatabasePath(self, enable=True):
335 """
336 Private method to set the favicons path.
337
338 @param enable flag indicating to enabled icon storage (boolean)
339 """
340 if enable:
341 iconDatabasePath = os.path.join(Utilities.getConfigDir(),
342 "browser", "favicons")
343 if not os.path.exists(iconDatabasePath):
344 os.makedirs(iconDatabasePath)
345 else:
346 iconDatabasePath = "" # setting an empty path disables it
347 QWebSettings.setIconDatabasePath(iconDatabasePath)
348
349 def __initWebSettings(self):
350 """
351 Private method to set the global web settings.
352 """
353 standardFont = Preferences.getHelp("StandardFont")
354 fixedFont = Preferences.getHelp("FixedFont")
355
356 settings = QWebSettings.globalSettings()
357 settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
358
359 settings.setFontFamily(QWebSettings.StandardFont,
360 standardFont.family())
361 settings.setFontSize(QWebSettings.DefaultFontSize,
362 standardFont.pointSize())
363 settings.setFontFamily(QWebSettings.FixedFont, fixedFont.family())
364 settings.setFontSize(QWebSettings.DefaultFixedFontSize,
365 fixedFont.pointSize())
366
367 styleSheet = Preferences.getHelp("UserStyleSheet")
368 settings.setUserStyleSheetUrl(self.__userStyleSheet(styleSheet))
369
370 settings.setAttribute(
371 QWebSettings.AutoLoadImages,
372 Preferences.getHelp("AutoLoadImages"))
373 settings.setAttribute(
374 QWebSettings.JavaEnabled,
375 Preferences.getHelp("JavaEnabled"))
376 settings.setAttribute(
377 QWebSettings.JavascriptEnabled,
378 Preferences.getHelp("JavaScriptEnabled"))
379 settings.setAttribute(
380 QWebSettings.JavascriptCanOpenWindows,
381 Preferences.getHelp("JavaScriptCanOpenWindows"))
382 settings.setAttribute(
383 QWebSettings.JavascriptCanAccessClipboard,
384 Preferences.getHelp("JavaScriptCanAccessClipboard"))
385 settings.setAttribute(
386 QWebSettings.PluginsEnabled,
387 Preferences.getHelp("PluginsEnabled"))
388
389 if hasattr(QWebSettings, "PrintElementBackgrounds"):
390 settings.setAttribute(
391 QWebSettings.PrintElementBackgrounds,
392 Preferences.getHelp("PrintBackgrounds"))
393
394 if hasattr(QWebSettings, "setOfflineStoragePath"):
395 settings.setAttribute(
396 QWebSettings.OfflineStorageDatabaseEnabled,
397 Preferences.getHelp("OfflineStorageDatabaseEnabled"))
398 webDatabaseDir = os.path.join(
399 Utilities.getConfigDir(), "browser", "webdatabases")
400 if not os.path.exists(webDatabaseDir):
401 os.makedirs(webDatabaseDir)
402 settings.setOfflineStoragePath(webDatabaseDir)
403 settings.setOfflineStorageDefaultQuota(
404 Preferences.getHelp("OfflineStorageDatabaseQuota") *
405 1024 * 1024)
406
407 if hasattr(QWebSettings, "OfflineWebApplicationCacheEnabled"):
408 settings.setAttribute(
409 QWebSettings.OfflineWebApplicationCacheEnabled,
410 Preferences.getHelp("OfflineWebApplicationCacheEnabled"))
411 appCacheDir = os.path.join(
412 Utilities.getConfigDir(), "browser", "webappcaches")
413 if not os.path.exists(appCacheDir):
414 os.makedirs(appCacheDir)
415 settings.setOfflineWebApplicationCachePath(appCacheDir)
416 settings.setOfflineWebApplicationCacheQuota(
417 Preferences.getHelp("OfflineWebApplicationCacheQuota") *
418 1024 * 1024)
419
420 if hasattr(QWebSettings, "LocalStorageEnabled"):
421 settings.setAttribute(
422 QWebSettings.LocalStorageEnabled,
423 Preferences.getHelp("LocalStorageEnabled"))
424 localStorageDir = os.path.join(
425 Utilities.getConfigDir(), "browser", "weblocalstorage")
426 if not os.path.exists(localStorageDir):
427 os.makedirs(localStorageDir)
428 settings.setLocalStoragePath(localStorageDir)
429
430 if hasattr(QWebSettings, "DnsPrefetchEnabled"):
431 settings.setAttribute(
432 QWebSettings.DnsPrefetchEnabled,
433 Preferences.getHelp("DnsPrefetchEnabled"))
434
435 if hasattr(QWebSettings, "defaultTextEncoding"):
436 settings.setDefaultTextEncoding(
437 Preferences.getHelp("DefaultTextEncoding"))
438
439 if hasattr(QWebSettings, "SpatialNavigationEnabled"):
440 settings.setAttribute(
441 QWebSettings.SpatialNavigationEnabled,
442 Preferences.getHelp("SpatialNavigationEnabled"))
443 if hasattr(QWebSettings, "LinksIncludedInFocusChain"):
444 settings.setAttribute(
445 QWebSettings.LinksIncludedInFocusChain,
446 Preferences.getHelp("LinksIncludedInFocusChain"))
447 if hasattr(QWebSettings, "LocalContentCanAccessRemoteUrls"):
448 settings.setAttribute(
449 QWebSettings.LocalContentCanAccessRemoteUrls,
450 Preferences.getHelp("LocalContentCanAccessRemoteUrls"))
451 if hasattr(QWebSettings, "LocalContentCanAccessFileUrls"):
452 settings.setAttribute(
453 QWebSettings.LocalContentCanAccessFileUrls,
454 Preferences.getHelp("LocalContentCanAccessFileUrls"))
455 if hasattr(QWebSettings, "XSSAuditingEnabled"):
456 settings.setAttribute(
457 QWebSettings.XSSAuditingEnabled,
458 Preferences.getHelp("XSSAuditingEnabled"))
459 if hasattr(QWebSettings, "SiteSpecificQuirksEnabled"):
460 settings.setAttribute(
461 QWebSettings.SiteSpecificQuirksEnabled,
462 Preferences.getHelp("SiteSpecificQuirksEnabled"))
463
464 QWebSecurityOrigin.addLocalScheme("eric")
465
466 def __initActions(self):
467 """
468 Private method to define the user interface actions.
469 """
470 # list of all actions
471 self.__actions = []
472
473 self.newTabAct = E5Action(
474 self.tr('New Tab'),
475 UI.PixmapCache.getIcon("tabNew.png"),
476 self.tr('&New Tab'),
477 QKeySequence(self.tr("Ctrl+T", "File|New Tab")),
478 0, self, 'help_file_new_tab')
479 self.newTabAct.setStatusTip(self.tr('Open a new help window tab'))
480 self.newTabAct.setWhatsThis(self.tr(
481 """<b>New Tab</b>"""
482 """<p>This opens a new help window tab.</p>"""
483 ))
484 self.newTabAct.triggered.connect(self.newTab)
485 self.__actions.append(self.newTabAct)
486
487 self.newAct = E5Action(
488 self.tr('New Window'),
489 UI.PixmapCache.getIcon("newWindow.png"),
490 self.tr('New &Window'),
491 QKeySequence(self.tr("Ctrl+N", "File|New Window")),
492 0, self, 'help_file_new_window')
493 self.newAct.setStatusTip(self.tr('Open a new help browser window'))
494 self.newAct.setWhatsThis(self.tr(
495 """<b>New Window</b>"""
496 """<p>This opens a new help browser window.</p>"""
497 ))
498 self.newAct.triggered.connect(self.newWindow)
499 self.__actions.append(self.newAct)
500
501 self.openAct = E5Action(
502 self.tr('Open File'),
503 UI.PixmapCache.getIcon("open.png"),
504 self.tr('&Open File'),
505 QKeySequence(self.tr("Ctrl+O", "File|Open")),
506 0, self, 'help_file_open')
507 self.openAct.setStatusTip(self.tr('Open a help file for display'))
508 self.openAct.setWhatsThis(self.tr(
509 """<b>Open File</b>"""
510 """<p>This opens a new help file for display."""
511 """ It pops up a file selection dialog.</p>"""
512 ))
513 self.openAct.triggered.connect(self.__openFile)
514 self.__actions.append(self.openAct)
515
516 self.openTabAct = E5Action(
517 self.tr('Open File in New Tab'),
518 UI.PixmapCache.getIcon("openNewTab.png"),
519 self.tr('Open File in New &Tab'),
520 QKeySequence(self.tr("Shift+Ctrl+O", "File|Open in new tab")),
521 0, self, 'help_file_open_tab')
522 self.openTabAct.setStatusTip(
523 self.tr('Open a help file for display in a new tab'))
524 self.openTabAct.setWhatsThis(self.tr(
525 """<b>Open File in New Tab</b>"""
526 """<p>This opens a new help file for display in a new tab."""
527 """ It pops up a file selection dialog.</p>"""
528 ))
529 self.openTabAct.triggered.connect(self.__openFileNewTab)
530 self.__actions.append(self.openTabAct)
531
532 self.saveAsAct = E5Action(
533 self.tr('Save As'),
534 UI.PixmapCache.getIcon("fileSaveAs.png"),
535 self.tr('&Save As...'),
536 QKeySequence(self.tr("Shift+Ctrl+S", "File|Save As")),
537 0, self, 'help_file_save_as')
538 self.saveAsAct.setStatusTip(
539 self.tr('Save the current page to disk'))
540 self.saveAsAct.setWhatsThis(self.tr(
541 """<b>Save As...</b>"""
542 """<p>Saves the current page to disk.</p>"""
543 ))
544 self.saveAsAct.triggered.connect(self.__savePageAs)
545 self.__actions.append(self.saveAsAct)
546
547 self.savePageScreenAct = E5Action(
548 self.tr('Save Page Screen'),
549 UI.PixmapCache.getIcon("fileSavePixmap.png"),
550 self.tr('Save Page Screen...'),
551 0, 0, self, 'help_file_save_page_screen')
552 self.savePageScreenAct.setStatusTip(
553 self.tr('Save the current page as a screen shot'))
554 self.savePageScreenAct.setWhatsThis(self.tr(
555 """<b>Save Page Screen...</b>"""
556 """<p>Saves the current page as a screen shot.</p>"""
557 ))
558 self.savePageScreenAct.triggered.connect(self.__savePageScreen)
559 self.__actions.append(self.savePageScreenAct)
560
561 self.saveVisiblePageScreenAct = E5Action(
562 self.tr('Save Visible Page Screen'),
563 UI.PixmapCache.getIcon("fileSaveVisiblePixmap.png"),
564 self.tr('Save Visible Page Screen...'),
565 0, 0, self, 'help_file_save_visible_page_screen')
566 self.saveVisiblePageScreenAct.setStatusTip(
567 self.tr('Save the visible part of the current page as a'
568 ' screen shot'))
569 self.saveVisiblePageScreenAct.setWhatsThis(self.tr(
570 """<b>Save Visible Page Screen...</b>"""
571 """<p>Saves the visible part of the current page as a"""
572 """ screen shot.</p>"""
573 ))
574 self.saveVisiblePageScreenAct.triggered.connect(
575 self.__saveVisiblePageScreen)
576 self.__actions.append(self.saveVisiblePageScreenAct)
577
578 bookmarksManager = self.bookmarksManager()
579 self.importBookmarksAct = E5Action(
580 self.tr('Import Bookmarks'),
581 self.tr('&Import Bookmarks...'),
582 0, 0, self, 'help_file_import_bookmarks')
583 self.importBookmarksAct.setStatusTip(
584 self.tr('Import bookmarks from other browsers'))
585 self.importBookmarksAct.setWhatsThis(self.tr(
586 """<b>Import Bookmarks</b>"""
587 """<p>Import bookmarks from other browsers.</p>"""
588 ))
589 self.importBookmarksAct.triggered.connect(
590 bookmarksManager.importBookmarks)
591 self.__actions.append(self.importBookmarksAct)
592
593 self.exportBookmarksAct = E5Action(
594 self.tr('Export Bookmarks'),
595 self.tr('&Export Bookmarks...'),
596 0, 0, self, 'help_file_export_bookmarks')
597 self.exportBookmarksAct.setStatusTip(
598 self.tr('Export the bookmarks into a file'))
599 self.exportBookmarksAct.setWhatsThis(self.tr(
600 """<b>Export Bookmarks</b>"""
601 """<p>Export the bookmarks into a file.</p>"""
602 ))
603 self.exportBookmarksAct.triggered.connect(
604 bookmarksManager.exportBookmarks)
605 self.__actions.append(self.exportBookmarksAct)
606
607 self.printAct = E5Action(
608 self.tr('Print'),
609 UI.PixmapCache.getIcon("print.png"),
610 self.tr('&Print'),
611 QKeySequence(self.tr("Ctrl+P", "File|Print")),
612 0, self, 'help_file_print')
613 self.printAct.setStatusTip(self.tr('Print the displayed help'))
614 self.printAct.setWhatsThis(self.tr(
615 """<b>Print</b>"""
616 """<p>Print the displayed help text.</p>"""
617 ))
618 self.printAct.triggered.connect(self.tabWidget.printBrowser)
619 self.__actions.append(self.printAct)
620
621 if Globals.isLinuxPlatform():
622 self.printPdfAct = E5Action(
623 self.tr('Print as PDF'),
624 UI.PixmapCache.getIcon("printPdf.png"),
625 self.tr('Print as PDF'),
626 0, 0, self, 'help_file_print_pdf')
627 self.printPdfAct.setStatusTip(self.tr(
628 'Print the displayed help as PDF'))
629 self.printPdfAct.setWhatsThis(self.tr(
630 """<b>Print as PDF</b>"""
631 """<p>Print the displayed help text as a PDF file.</p>"""
632 ))
633 self.printPdfAct.triggered.connect(
634 self.tabWidget.printBrowserPdf)
635 self.__actions.append(self.printPdfAct)
636 else:
637 self.printPdfAct = None
638
639 self.printPreviewAct = E5Action(
640 self.tr('Print Preview'),
641 UI.PixmapCache.getIcon("printPreview.png"),
642 self.tr('Print Preview'),
643 0, 0, self, 'help_file_print_preview')
644 self.printPreviewAct.setStatusTip(self.tr(
645 'Print preview of the displayed help'))
646 self.printPreviewAct.setWhatsThis(self.tr(
647 """<b>Print Preview</b>"""
648 """<p>Print preview of the displayed help text.</p>"""
649 ))
650 self.printPreviewAct.triggered.connect(
651 self.tabWidget.printPreviewBrowser)
652 self.__actions.append(self.printPreviewAct)
653
654 self.closeAct = E5Action(
655 self.tr('Close'),
656 UI.PixmapCache.getIcon("close.png"),
657 self.tr('&Close'),
658 QKeySequence(self.tr("Ctrl+W", "File|Close")),
659 0, self, 'help_file_close')
660 self.closeAct.setStatusTip(self.tr(
661 'Close the current help window'))
662 self.closeAct.setWhatsThis(self.tr(
663 """<b>Close</b>"""
664 """<p>Closes the current help window.</p>"""
665 ))
666 self.closeAct.triggered.connect(self.tabWidget.closeBrowser)
667 self.__actions.append(self.closeAct)
668
669 self.closeAllAct = E5Action(
670 self.tr('Close All'),
671 self.tr('Close &All'),
672 0, 0, self, 'help_file_close_all')
673 self.closeAllAct.setStatusTip(self.tr('Close all help windows'))
674 self.closeAllAct.setWhatsThis(self.tr(
675 """<b>Close All</b>"""
676 """<p>Closes all help windows except the first one.</p>"""
677 ))
678 self.closeAllAct.triggered.connect(
679 self.tabWidget.closeAllBrowsers)
680 self.__actions.append(self.closeAllAct)
681
682 self.privateBrowsingAct = E5Action(
683 self.tr('Private Browsing'),
684 UI.PixmapCache.getIcon("privateBrowsing.png"),
685 self.tr('Private &Browsing'),
686 0, 0, self, 'help_file_private_browsing')
687 self.privateBrowsingAct.setStatusTip(self.tr('Private Browsing'))
688 self.privateBrowsingAct.setWhatsThis(self.tr(
689 """<b>Private Browsing</b>"""
690 """<p>Enables private browsing. In this mode no history is"""
691 """ recorded anymore.</p>"""
692 ))
693 self.privateBrowsingAct.triggered.connect(
694 self.__privateBrowsing)
695 self.privateBrowsingAct.setCheckable(True)
696 self.__actions.append(self.privateBrowsingAct)
697
698 self.exitAct = E5Action(
699 self.tr('Quit'),
700 UI.PixmapCache.getIcon("exit.png"),
701 self.tr('&Quit'),
702 QKeySequence(self.tr("Ctrl+Q", "File|Quit")),
703 0, self, 'help_file_quit')
704 self.exitAct.setStatusTip(self.tr('Quit the eric6 Web Browser'))
705 self.exitAct.setWhatsThis(self.tr(
706 """<b>Quit</b>"""
707 """<p>Quit the eric6 Web Browser.</p>"""
708 ))
709 self.exitAct.triggered.connect(self.__closeAllWindows)
710 self.__actions.append(self.exitAct)
711
712 self.backAct = E5Action(
713 self.tr('Backward'),
714 UI.PixmapCache.getIcon("back.png"),
715 self.tr('&Backward'),
716 QKeySequence(self.tr("Alt+Left", "Go|Backward")),
717 QKeySequence(self.tr("Backspace", "Go|Backward")),
718 self, 'help_go_backward')
719 self.backAct.setStatusTip(self.tr('Move one help screen backward'))
720 self.backAct.setWhatsThis(self.tr(
721 """<b>Backward</b>"""
722 """<p>Moves one help screen backward. If none is"""
723 """ available, this action is disabled.</p>"""
724 ))
725 self.backAct.triggered.connect(self.__backward)
726 self.__actions.append(self.backAct)
727
728 self.forwardAct = E5Action(
729 self.tr('Forward'),
730 UI.PixmapCache.getIcon("forward.png"),
731 self.tr('&Forward'),
732 QKeySequence(self.tr("Alt+Right", "Go|Forward")),
733 QKeySequence(self.tr("Shift+Backspace", "Go|Forward")),
734 self, 'help_go_foreward')
735 self.forwardAct.setStatusTip(self.tr(
736 'Move one help screen forward'))
737 self.forwardAct.setWhatsThis(self.tr(
738 """<b>Forward</b>"""
739 """<p>Moves one help screen forward. If none is"""
740 """ available, this action is disabled.</p>"""
741 ))
742 self.forwardAct.triggered.connect(self.__forward)
743 self.__actions.append(self.forwardAct)
744
745 self.homeAct = E5Action(
746 self.tr('Home'),
747 UI.PixmapCache.getIcon("home.png"),
748 self.tr('&Home'),
749 QKeySequence(self.tr("Ctrl+Home", "Go|Home")),
750 0, self, 'help_go_home')
751 self.homeAct.setStatusTip(self.tr(
752 'Move to the initial help screen'))
753 self.homeAct.setWhatsThis(self.tr(
754 """<b>Home</b>"""
755 """<p>Moves to the initial help screen.</p>"""
756 ))
757 self.homeAct.triggered.connect(self.__home)
758 self.__actions.append(self.homeAct)
759
760 self.reloadAct = E5Action(
761 self.tr('Reload'),
762 UI.PixmapCache.getIcon("reload.png"),
763 self.tr('&Reload'),
764 QKeySequence(self.tr("Ctrl+R", "Go|Reload")),
765 QKeySequence(self.tr("F5", "Go|Reload")),
766 self, 'help_go_reload')
767 self.reloadAct.setStatusTip(self.tr(
768 'Reload the current help screen'))
769 self.reloadAct.setWhatsThis(self.tr(
770 """<b>Reload</b>"""
771 """<p>Reloads the current help screen.</p>"""
772 ))
773 self.reloadAct.triggered.connect(self.__reload)
774 self.__actions.append(self.reloadAct)
775
776 self.stopAct = E5Action(
777 self.tr('Stop'),
778 UI.PixmapCache.getIcon("stopLoading.png"),
779 self.tr('&Stop'),
780 QKeySequence(self.tr("Ctrl+.", "Go|Stop")),
781 QKeySequence(self.tr("Esc", "Go|Stop")),
782 self, 'help_go_stop')
783 self.stopAct.setStatusTip(self.tr('Stop loading'))
784 self.stopAct.setWhatsThis(self.tr(
785 """<b>Stop</b>"""
786 """<p>Stops loading of the current tab.</p>"""
787 ))
788 self.stopAct.triggered.connect(self.__stopLoading)
789 self.__actions.append(self.stopAct)
790
791 self.copyAct = E5Action(
792 self.tr('Copy'),
793 UI.PixmapCache.getIcon("editCopy.png"),
794 self.tr('&Copy'),
795 QKeySequence(self.tr("Ctrl+C", "Edit|Copy")),
796 0, self, 'help_edit_copy')
797 self.copyAct.setStatusTip(self.tr('Copy the selected text'))
798 self.copyAct.setWhatsThis(self.tr(
799 """<b>Copy</b>"""
800 """<p>Copy the selected text to the clipboard.</p>"""
801 ))
802 self.copyAct.triggered.connect(self.__copy)
803 self.__actions.append(self.copyAct)
804
805 self.findAct = E5Action(
806 self.tr('Find...'),
807 UI.PixmapCache.getIcon("find.png"),
808 self.tr('&Find...'),
809 QKeySequence(self.tr("Ctrl+F", "Edit|Find")),
810 0, self, 'help_edit_find')
811 self.findAct.setStatusTip(self.tr('Find text in page'))
812 self.findAct.setWhatsThis(self.tr(
813 """<b>Find</b>"""
814 """<p>Find text in the current page.</p>"""
815 ))
816 self.findAct.triggered.connect(self.__find)
817 self.__actions.append(self.findAct)
818
819 self.findNextAct = E5Action(
820 self.tr('Find next'),
821 UI.PixmapCache.getIcon("findNext.png"),
822 self.tr('Find &next'),
823 QKeySequence(self.tr("F3", "Edit|Find next")),
824 0, self, 'help_edit_find_next')
825 self.findNextAct.setStatusTip(self.tr(
826 'Find next occurrence of text in page'))
827 self.findNextAct.setWhatsThis(self.tr(
828 """<b>Find next</b>"""
829 """<p>Find the next occurrence of text in the current page.</p>"""
830 ))
831 self.findNextAct.triggered.connect(self.findDlg.findNext)
832 self.__actions.append(self.findNextAct)
833
834 self.findPrevAct = E5Action(
835 self.tr('Find previous'),
836 UI.PixmapCache.getIcon("findPrev.png"),
837 self.tr('Find &previous'),
838 QKeySequence(self.tr("Shift+F3", "Edit|Find previous")),
839 0, self, 'help_edit_find_previous')
840 self.findPrevAct.setStatusTip(
841 self.tr('Find previous occurrence of text in page'))
842 self.findPrevAct.setWhatsThis(self.tr(
843 """<b>Find previous</b>"""
844 """<p>Find the previous occurrence of text in the current"""
845 """ page.</p>"""
846 ))
847 self.findPrevAct.triggered.connect(self.findDlg.findPrevious)
848 self.__actions.append(self.findPrevAct)
849
850 self.bookmarksManageAct = E5Action(
851 self.tr('Manage Bookmarks'),
852 self.tr('&Manage Bookmarks...'),
853 QKeySequence(self.tr("Ctrl+Shift+B", "Help|Manage bookmarks")),
854 0, self, 'help_bookmarks_manage')
855 self.bookmarksManageAct.setStatusTip(self.tr(
856 'Open a dialog to manage the bookmarks.'))
857 self.bookmarksManageAct.setWhatsThis(self.tr(
858 """<b>Manage Bookmarks...</b>"""
859 """<p>Open a dialog to manage the bookmarks.</p>"""
860 ))
861 self.bookmarksManageAct.triggered.connect(
862 self.__showBookmarksDialog)
863 self.__actions.append(self.bookmarksManageAct)
864
865 self.bookmarksAddAct = E5Action(
866 self.tr('Add Bookmark'),
867 UI.PixmapCache.getIcon("addBookmark.png"),
868 self.tr('Add &Bookmark...'),
869 QKeySequence(self.tr("Ctrl+D", "Help|Add bookmark")),
870 0, self, 'help_bookmark_add')
871 self.bookmarksAddAct.setIconVisibleInMenu(False)
872 self.bookmarksAddAct.setStatusTip(self.tr(
873 'Open a dialog to add a bookmark.'))
874 self.bookmarksAddAct.setWhatsThis(self.tr(
875 """<b>Add Bookmark</b>"""
876 """<p>Open a dialog to add the current URL as a bookmark.</p>"""
877 ))
878 self.bookmarksAddAct.triggered.connect(self.__addBookmark)
879 self.__actions.append(self.bookmarksAddAct)
880
881 self.bookmarksAddFolderAct = E5Action(
882 self.tr('Add Folder'),
883 self.tr('Add &Folder...'),
884 0, 0, self, 'help_bookmark_show_all')
885 self.bookmarksAddFolderAct.setStatusTip(self.tr(
886 'Open a dialog to add a new bookmarks folder.'))
887 self.bookmarksAddFolderAct.setWhatsThis(self.tr(
888 """<b>Add Folder...</b>"""
889 """<p>Open a dialog to add a new bookmarks folder.</p>"""
890 ))
891 self.bookmarksAddFolderAct.triggered.connect(
892 self.__addBookmarkFolder)
893 self.__actions.append(self.bookmarksAddFolderAct)
894
895 self.bookmarksAllTabsAct = E5Action(
896 self.tr('Bookmark All Tabs'),
897 self.tr('Bookmark All Tabs...'),
898 0, 0, self, 'help_bookmark_all_tabs')
899 self.bookmarksAllTabsAct.setStatusTip(self.tr(
900 'Bookmark all open tabs.'))
901 self.bookmarksAllTabsAct.setWhatsThis(self.tr(
902 """<b>Bookmark All Tabs...</b>"""
903 """<p>Open a dialog to add a new bookmarks folder for"""
904 """ all open tabs.</p>"""
905 ))
906 self.bookmarksAllTabsAct.triggered.connect(self.bookmarkAll)
907 self.__actions.append(self.bookmarksAllTabsAct)
908
909 self.whatsThisAct = E5Action(
910 self.tr('What\'s This?'),
911 UI.PixmapCache.getIcon("whatsThis.png"),
912 self.tr('&What\'s This?'),
913 QKeySequence(self.tr("Shift+F1", "Help|What's This?'")),
914 0, self, 'help_help_whats_this')
915 self.whatsThisAct.setStatusTip(self.tr('Context sensitive help'))
916 self.whatsThisAct.setWhatsThis(self.tr(
917 """<b>Display context sensitive help</b>"""
918 """<p>In What's This? mode, the mouse cursor shows an arrow"""
919 """ with a question mark, and you can click on the interface"""
920 """ elements to get a short description of what they do and how"""
921 """ to use them. In dialogs, this feature can be accessed using"""
922 """ the context help button in the titlebar.</p>"""
923 ))
924 self.whatsThisAct.triggered.connect(self.__whatsThis)
925 self.__actions.append(self.whatsThisAct)
926
927 self.aboutAct = E5Action(
928 self.tr('About'),
929 self.tr('&About'),
930 0, 0, self, 'help_help_about')
931 self.aboutAct.setStatusTip(self.tr(
932 'Display information about this software'))
933 self.aboutAct.setWhatsThis(self.tr(
934 """<b>About</b>"""
935 """<p>Display some information about this software.</p>"""
936 ))
937 self.aboutAct.triggered.connect(self.__about)
938 self.__actions.append(self.aboutAct)
939
940 self.aboutQtAct = E5Action(
941 self.tr('About Qt'),
942 self.tr('About &Qt'),
943 0, 0, self, 'help_help_about_qt')
944 self.aboutQtAct.setStatusTip(
945 self.tr('Display information about the Qt toolkit'))
946 self.aboutQtAct.setWhatsThis(self.tr(
947 """<b>About Qt</b>"""
948 """<p>Display some information about the Qt toolkit.</p>"""
949 ))
950 self.aboutQtAct.triggered.connect(self.__aboutQt)
951 self.__actions.append(self.aboutQtAct)
952
953 self.zoomInAct = E5Action(
954 self.tr('Zoom in'),
955 UI.PixmapCache.getIcon("zoomIn.png"),
956 self.tr('Zoom &in'),
957 QKeySequence(self.tr("Ctrl++", "View|Zoom in")),
958 QKeySequence(self.tr("Zoom In", "View|Zoom in")),
959 self, 'help_view_zoom_in')
960 self.zoomInAct.setStatusTip(self.tr('Zoom in on the text'))
961 self.zoomInAct.setWhatsThis(self.tr(
962 """<b>Zoom in</b>"""
963 """<p>Zoom in on the text. This makes the text bigger.</p>"""
964 ))
965 self.zoomInAct.triggered.connect(self.__zoomIn)
966 self.__actions.append(self.zoomInAct)
967
968 self.zoomOutAct = E5Action(
969 self.tr('Zoom out'),
970 UI.PixmapCache.getIcon("zoomOut.png"),
971 self.tr('Zoom &out'),
972 QKeySequence(self.tr("Ctrl+-", "View|Zoom out")),
973 QKeySequence(self.tr("Zoom Out", "View|Zoom out")),
974 self, 'help_view_zoom_out')
975 self.zoomOutAct.setStatusTip(self.tr('Zoom out on the text'))
976 self.zoomOutAct.setWhatsThis(self.tr(
977 """<b>Zoom out</b>"""
978 """<p>Zoom out on the text. This makes the text smaller.</p>"""
979 ))
980 self.zoomOutAct.triggered.connect(self.__zoomOut)
981 self.__actions.append(self.zoomOutAct)
982
983 self.zoomResetAct = E5Action(
984 self.tr('Zoom reset'),
985 UI.PixmapCache.getIcon("zoomReset.png"),
986 self.tr('Zoom &reset'),
987 QKeySequence(self.tr("Ctrl+0", "View|Zoom reset")),
988 0, self, 'help_view_zoom_reset')
989 self.zoomResetAct.setStatusTip(self.tr(
990 'Reset the zoom of the text'))
991 self.zoomResetAct.setWhatsThis(self.tr(
992 """<b>Zoom reset</b>"""
993 """<p>Reset the zoom of the text. """
994 """This sets the zoom factor to 100%.</p>"""
995 ))
996 self.zoomResetAct.triggered.connect(self.__zoomReset)
997 self.__actions.append(self.zoomResetAct)
998
999 if hasattr(QWebSettings, 'ZoomTextOnly'):
1000 self.zoomTextOnlyAct = E5Action(
1001 self.tr('Zoom text only'),
1002 self.tr('Zoom &text only'),
1003 0, 0, self, 'help_view_zoom_text_only')
1004 self.zoomTextOnlyAct.setCheckable(True)
1005 self.zoomTextOnlyAct.setStatusTip(self.tr(
1006 'Zoom text only; pictures remain constant'))
1007 self.zoomTextOnlyAct.setWhatsThis(self.tr(
1008 """<b>Zoom text only</b>"""
1009 """<p>Zoom text only; pictures remain constant.</p>"""
1010 ))
1011 self.zoomTextOnlyAct.triggered[bool].connect(
1012 self.__zoomTextOnly)
1013 self.__actions.append(self.zoomTextOnlyAct)
1014 else:
1015 self.zoomTextOnlyAct = None
1016
1017 self.pageSourceAct = E5Action(
1018 self.tr('Show page source'),
1019 self.tr('Show page source'),
1020 QKeySequence(self.tr('Ctrl+U')), 0,
1021 self, 'help_show_page_source')
1022 self.pageSourceAct.setStatusTip(self.tr(
1023 'Show the page source in an editor'))
1024 self.pageSourceAct.setWhatsThis(self.tr(
1025 """<b>Show page source</b>"""
1026 """<p>Show the page source in an editor.</p>"""
1027 ))
1028 self.pageSourceAct.triggered.connect(self.__showPageSource)
1029 self.__actions.append(self.pageSourceAct)
1030 self.addAction(self.pageSourceAct)
1031
1032 self.fullScreenAct = E5Action(
1033 self.tr('Full Screen'),
1034 UI.PixmapCache.getIcon("windowFullscreen.png"),
1035 self.tr('&Full Screen'),
1036 QKeySequence(self.tr('F11')), 0,
1037 self, 'help_view_full_scree')
1038 self.fullScreenAct.triggered.connect(self.__viewFullScreen)
1039 self.__actions.append(self.fullScreenAct)
1040 self.addAction(self.fullScreenAct)
1041
1042 self.nextTabAct = E5Action(
1043 self.tr('Show next tab'),
1044 self.tr('Show next tab'),
1045 QKeySequence(self.tr('Ctrl+Alt+Tab')), 0,
1046 self, 'help_view_next_tab')
1047 self.nextTabAct.triggered.connect(self.__nextTab)
1048 self.__actions.append(self.nextTabAct)
1049 self.addAction(self.nextTabAct)
1050
1051 self.prevTabAct = E5Action(
1052 self.tr('Show previous tab'),
1053 self.tr('Show previous tab'),
1054 QKeySequence(self.tr('Shift+Ctrl+Alt+Tab')), 0,
1055 self, 'help_view_previous_tab')
1056 self.prevTabAct.triggered.connect(self.__prevTab)
1057 self.__actions.append(self.prevTabAct)
1058 self.addAction(self.prevTabAct)
1059
1060 self.switchTabAct = E5Action(
1061 self.tr('Switch between tabs'),
1062 self.tr('Switch between tabs'),
1063 QKeySequence(self.tr('Ctrl+1')), 0,
1064 self, 'help_switch_tabs')
1065 self.switchTabAct.triggered.connect(self.__switchTab)
1066 self.__actions.append(self.switchTabAct)
1067 self.addAction(self.switchTabAct)
1068
1069 self.prefAct = E5Action(
1070 self.tr('Preferences'),
1071 UI.PixmapCache.getIcon("configure.png"),
1072 self.tr('&Preferences...'), 0, 0, self, 'help_preferences')
1073 self.prefAct.setStatusTip(self.tr(
1074 'Set the prefered configuration'))
1075 self.prefAct.setWhatsThis(self.tr(
1076 """<b>Preferences</b>"""
1077 """<p>Set the configuration items of the application"""
1078 """ with your prefered values.</p>"""
1079 ))
1080 self.prefAct.triggered.connect(self.__showPreferences)
1081 self.__actions.append(self.prefAct)
1082
1083 self.acceptedLanguagesAct = E5Action(
1084 self.tr('Languages'),
1085 UI.PixmapCache.getIcon("flag.png"),
1086 self.tr('&Languages...'), 0, 0,
1087 self, 'help_accepted_languages')
1088 self.acceptedLanguagesAct.setStatusTip(self.tr(
1089 'Configure the accepted languages for web pages'))
1090 self.acceptedLanguagesAct.setWhatsThis(self.tr(
1091 """<b>Languages</b>"""
1092 """<p>Configure the accepted languages for web pages.</p>"""
1093 ))
1094 self.acceptedLanguagesAct.triggered.connect(
1095 self.__showAcceptedLanguages)
1096 self.__actions.append(self.acceptedLanguagesAct)
1097
1098 self.cookiesAct = E5Action(
1099 self.tr('Cookies'),
1100 UI.PixmapCache.getIcon("cookie.png"),
1101 self.tr('C&ookies...'), 0, 0, self, 'help_cookies')
1102 self.cookiesAct.setStatusTip(self.tr(
1103 'Configure cookies handling'))
1104 self.cookiesAct.setWhatsThis(self.tr(
1105 """<b>Cookies</b>"""
1106 """<p>Configure cookies handling.</p>"""
1107 ))
1108 self.cookiesAct.triggered.connect(
1109 self.__showCookiesConfiguration)
1110 self.__actions.append(self.cookiesAct)
1111
1112 self.flashCookiesAct = E5Action(
1113 self.tr('Flash Cookies'),
1114 UI.PixmapCache.getIcon("flashCookie.png"),
1115 self.tr('&Flash Cookies...'), 0, 0, self, 'help_flash_cookies')
1116 self.flashCookiesAct.setStatusTip(self.tr(
1117 'Manage flash cookies'))
1118 self.flashCookiesAct.setWhatsThis(self.tr(
1119 """<b>Flash Cookies</b>"""
1120 """<p>Show a dialog to manage the flash cookies.</p>"""
1121 ))
1122 self.flashCookiesAct.triggered.connect(
1123 self.__showFlashCookiesManagement)
1124 self.__actions.append(self.flashCookiesAct)
1125
1126 self.offlineStorageAct = E5Action(
1127 self.tr('Offline Storage'),
1128 UI.PixmapCache.getIcon("preferences-html5.png"),
1129 self.tr('Offline &Storage...'), 0, 0,
1130 self, 'help_offline_storage')
1131 self.offlineStorageAct.setStatusTip(self.tr(
1132 'Configure offline storage'))
1133 self.offlineStorageAct.setWhatsThis(self.tr(
1134 """<b>Offline Storage</b>"""
1135 """<p>Opens a dialog to configure offline storage.</p>"""
1136 ))
1137 self.offlineStorageAct.triggered.connect(
1138 self.__showOfflineStorageConfiguration)
1139 self.__actions.append(self.offlineStorageAct)
1140
1141 self.personalDataAct = E5Action(
1142 self.tr('Personal Information'),
1143 UI.PixmapCache.getIcon("pim.png"),
1144 self.tr('Personal Information...'),
1145 0, 0,
1146 self, 'help_personal_information')
1147 self.personalDataAct.setStatusTip(self.tr(
1148 'Configure personal information for completing form fields'))
1149 self.personalDataAct.setWhatsThis(self.tr(
1150 """<b>Personal Information...</b>"""
1151 """<p>Opens a dialog to configure the personal information"""
1152 """ used for completing form fields.</p>"""
1153 ))
1154 self.personalDataAct.triggered.connect(
1155 self.__showPersonalInformationDialog)
1156 self.__actions.append(self.personalDataAct)
1157
1158 self.greaseMonkeyAct = E5Action(
1159 self.tr('GreaseMonkey Scripts'),
1160 UI.PixmapCache.getIcon("greaseMonkey.png"),
1161 self.tr('GreaseMonkey Scripts...'),
1162 0, 0,
1163 self, 'help_greasemonkey')
1164 self.greaseMonkeyAct.setStatusTip(self.tr(
1165 'Configure the GreaseMonkey Scripts'))
1166 self.greaseMonkeyAct.setWhatsThis(self.tr(
1167 """<b>GreaseMonkey Scripts...</b>"""
1168 """<p>Opens a dialog to configure the available GreaseMonkey"""
1169 """ Scripts.</p>"""
1170 ))
1171 self.greaseMonkeyAct.triggered.connect(
1172 self.__showGreaseMonkeyConfigDialog)
1173 self.__actions.append(self.greaseMonkeyAct)
1174
1175 self.editMessageFilterAct = E5Action(
1176 self.tr('Edit Message Filters'),
1177 UI.PixmapCache.getIcon("warning.png"),
1178 self.tr('Edit Message Filters...'), 0, 0, self,
1179 'help_manage_message_filters')
1180 self.editMessageFilterAct.setStatusTip(self.tr(
1181 'Edit the message filters used to suppress unwanted messages'))
1182 self.editMessageFilterAct.setWhatsThis(self.tr(
1183 """<b>Edit Message Filters</b>"""
1184 """<p>Opens a dialog to edit the message filters used to"""
1185 """ suppress unwanted messages been shown in an error"""
1186 """ window.</p>"""
1187 ))
1188 self.editMessageFilterAct.triggered.connect(
1189 E5ErrorMessage.editMessageFilters)
1190 self.__actions.append(self.editMessageFilterAct)
1191
1192 self.featurePermissionAct = E5Action(
1193 self.tr('Edit HTML5 Feature Permissions'),
1194 UI.PixmapCache.getIcon("featurePermission.png"),
1195 self.tr('Edit HTML5 Feature Permissions...'), 0, 0, self,
1196 'help_edit_feature_permissions')
1197 self.featurePermissionAct.setStatusTip(self.tr(
1198 'Edit the remembered HTML5 feature permissions'))
1199 self.featurePermissionAct.setWhatsThis(self.tr(
1200 """<b>Edit HTML5 Feature Permissions</b>"""
1201 """<p>Opens a dialog to edit the remembered HTML5"""
1202 """ feature permissions.</p>"""
1203 ))
1204 self.featurePermissionAct.triggered.connect(
1205 self.__showFeaturePermissionDialog)
1206 self.__actions.append(self.featurePermissionAct)
1207
1208 if HelpWindow._useQtHelp:
1209 self.syncTocAct = E5Action(
1210 self.tr('Sync with Table of Contents'),
1211 UI.PixmapCache.getIcon("syncToc.png"),
1212 self.tr('Sync with Table of Contents'),
1213 0, 0, self, 'help_sync_toc')
1214 self.syncTocAct.setStatusTip(self.tr(
1215 'Synchronizes the table of contents with current page'))
1216 self.syncTocAct.setWhatsThis(self.tr(
1217 """<b>Sync with Table of Contents</b>"""
1218 """<p>Synchronizes the table of contents with current"""
1219 """ page.</p>"""
1220 ))
1221 self.syncTocAct.triggered.connect(self.__syncTOC)
1222 self.__actions.append(self.syncTocAct)
1223
1224 self.showTocAct = E5Action(
1225 self.tr('Table of Contents'),
1226 self.tr('Table of Contents'),
1227 0, 0, self, 'help_show_toc')
1228 self.showTocAct.setStatusTip(self.tr(
1229 'Shows the table of contents window'))
1230 self.showTocAct.setWhatsThis(self.tr(
1231 """<b>Table of Contents</b>"""
1232 """<p>Shows the table of contents window.</p>"""
1233 ))
1234 self.showTocAct.triggered.connect(self.__showTocWindow)
1235 self.__actions.append(self.showTocAct)
1236
1237 self.showIndexAct = E5Action(
1238 self.tr('Index'),
1239 self.tr('Index'),
1240 0, 0, self, 'help_show_index')
1241 self.showIndexAct.setStatusTip(self.tr(
1242 'Shows the index window'))
1243 self.showIndexAct.setWhatsThis(self.tr(
1244 """<b>Index</b>"""
1245 """<p>Shows the index window.</p>"""
1246 ))
1247 self.showIndexAct.triggered.connect(self.__showIndexWindow)
1248 self.__actions.append(self.showIndexAct)
1249
1250 self.showSearchAct = E5Action(
1251 self.tr('Search'),
1252 self.tr('Search'),
1253 0, 0, self, 'help_show_search')
1254 self.showSearchAct.setStatusTip(self.tr(
1255 'Shows the search window'))
1256 self.showSearchAct.setWhatsThis(self.tr(
1257 """<b>Search</b>"""
1258 """<p>Shows the search window.</p>"""
1259 ))
1260 self.showSearchAct.triggered.connect(
1261 self.__showSearchWindow)
1262 self.__actions.append(self.showSearchAct)
1263
1264 self.manageQtHelpDocsAct = E5Action(
1265 self.tr('Manage QtHelp Documents'),
1266 self.tr('Manage QtHelp &Documents'),
1267 0, 0, self, 'help_qthelp_documents')
1268 self.manageQtHelpDocsAct.setStatusTip(self.tr(
1269 'Shows a dialog to manage the QtHelp documentation set'))
1270 self.manageQtHelpDocsAct.setWhatsThis(self.tr(
1271 """<b>Manage QtHelp Documents</b>"""
1272 """<p>Shows a dialog to manage the QtHelp documentation"""
1273 """ set.</p>"""
1274 ))
1275 self.manageQtHelpDocsAct.triggered.connect(
1276 self.__manageQtHelpDocumentation)
1277 self.__actions.append(self.manageQtHelpDocsAct)
1278
1279 self.manageQtHelpFiltersAct = E5Action(
1280 self.tr('Manage QtHelp Filters'),
1281 self.tr('Manage QtHelp &Filters'),
1282 0, 0, self, 'help_qthelp_filters')
1283 self.manageQtHelpFiltersAct.setStatusTip(self.tr(
1284 'Shows a dialog to manage the QtHelp filters'))
1285 self.manageQtHelpFiltersAct.setWhatsThis(self.tr(
1286 """<b>Manage QtHelp Filters</b>"""
1287 """<p>Shows a dialog to manage the QtHelp filters.</p>"""
1288 ))
1289 self.manageQtHelpFiltersAct.triggered.connect(
1290 self.__manageQtHelpFilters)
1291 self.__actions.append(self.manageQtHelpFiltersAct)
1292
1293 self.reindexDocumentationAct = E5Action(
1294 self.tr('Reindex Documentation'),
1295 self.tr('&Reindex Documentation'),
1296 0, 0, self, 'help_qthelp_reindex')
1297 self.reindexDocumentationAct.setStatusTip(self.tr(
1298 'Reindexes the documentation set'))
1299 self.reindexDocumentationAct.setWhatsThis(self.tr(
1300 """<b>Reindex Documentation</b>"""
1301 """<p>Reindexes the documentation set.</p>"""
1302 ))
1303 self.reindexDocumentationAct.triggered.connect(
1304 self.__searchEngine.reindexDocumentation)
1305 self.__actions.append(self.reindexDocumentationAct)
1306
1307 self.clearPrivateDataAct = E5Action(
1308 self.tr('Clear private data'),
1309 UI.PixmapCache.getIcon("clearPrivateData.png"),
1310 self.tr('Clear private data'),
1311 0, 0,
1312 self, 'help_clear_private_data')
1313 self.clearPrivateDataAct.setStatusTip(self.tr(
1314 'Clear private data'))
1315 self.clearPrivateDataAct.setWhatsThis(self.tr(
1316 """<b>Clear private data</b>"""
1317 """<p>Clears the private data like browsing history, search"""
1318 """ history or the favicons database.</p>"""
1319 ))
1320 self.clearPrivateDataAct.triggered.connect(
1321 self.__clearPrivateData)
1322 self.__actions.append(self.clearPrivateDataAct)
1323
1324 self.clearIconsAct = E5Action(
1325 self.tr('Clear icons database'),
1326 self.tr('Clear &icons database'),
1327 0, 0,
1328 self, 'help_clear_icons_db')
1329 self.clearIconsAct.setStatusTip(self.tr(
1330 'Clear the database of favicons'))
1331 self.clearIconsAct.setWhatsThis(self.tr(
1332 """<b>Clear icons database</b>"""
1333 """<p>Clears the database of favicons of previously visited"""
1334 """ URLs.</p>"""
1335 ))
1336 self.clearIconsAct.triggered.connect(self.__clearIconsDatabase)
1337 self.__actions.append(self.clearIconsAct)
1338
1339 self.searchEnginesAct = E5Action(
1340 self.tr('Configure Search Engines'),
1341 self.tr('Configure Search &Engines...'),
1342 0, 0,
1343 self, 'help_search_engines')
1344 self.searchEnginesAct.setStatusTip(self.tr(
1345 'Configure the available search engines'))
1346 self.searchEnginesAct.setWhatsThis(self.tr(
1347 """<b>Configure Search Engines...</b>"""
1348 """<p>Opens a dialog to configure the available search"""
1349 """ engines.</p>"""
1350 ))
1351 self.searchEnginesAct.triggered.connect(
1352 self.__showEnginesConfigurationDialog)
1353 self.__actions.append(self.searchEnginesAct)
1354
1355 self.passwordsAct = E5Action(
1356 self.tr('Manage Saved Passwords'),
1357 UI.PixmapCache.getIcon("passwords.png"),
1358 self.tr('Manage Saved Passwords...'),
1359 0, 0,
1360 self, 'help_manage_passwords')
1361 self.passwordsAct.setStatusTip(self.tr(
1362 'Manage the saved passwords'))
1363 self.passwordsAct.setWhatsThis(self.tr(
1364 """<b>Manage Saved Passwords...</b>"""
1365 """<p>Opens a dialog to manage the saved passwords.</p>"""
1366 ))
1367 self.passwordsAct.triggered.connect(self.__showPasswordsDialog)
1368 self.__actions.append(self.passwordsAct)
1369
1370 self.adblockAct = E5Action(
1371 self.tr('Ad Block'),
1372 UI.PixmapCache.getIcon("adBlockPlus.png"),
1373 self.tr('&Ad Block...'),
1374 0, 0,
1375 self, 'help_adblock')
1376 self.adblockAct.setStatusTip(self.tr(
1377 'Configure AdBlock subscriptions and rules'))
1378 self.adblockAct.setWhatsThis(self.tr(
1379 """<b>Ad Block...</b>"""
1380 """<p>Opens a dialog to configure AdBlock subscriptions and"""
1381 """ rules.</p>"""
1382 ))
1383 self.adblockAct.triggered.connect(self.__showAdBlockDialog)
1384 self.__actions.append(self.adblockAct)
1385
1386 self.flashblockAct = E5Action(
1387 self.tr('ClickToFlash'),
1388 UI.PixmapCache.getIcon("flashBlock.png"),
1389 self.tr('&ClickToFlash...'),
1390 0, 0,
1391 self, 'help_flashblock')
1392 self.flashblockAct.setStatusTip(self.tr(
1393 'Configure ClickToFlash whitelist'))
1394 self.flashblockAct.setWhatsThis(self.tr(
1395 """<b>ClickToFlash...</b>"""
1396 """<p>Opens a dialog to configure the ClickToFlash"""
1397 """ whitelist.</p>"""
1398 ))
1399 self.flashblockAct.triggered.connect(
1400 self.__showClickToFlashDialog)
1401 self.__actions.append(self.flashblockAct)
1402
1403 if SSL_AVAILABLE:
1404 self.certificatesAct = E5Action(
1405 self.tr('Manage SSL Certificates'),
1406 UI.PixmapCache.getIcon("certificates.png"),
1407 self.tr('Manage SSL Certificates...'),
1408 0, 0,
1409 self, 'help_manage_certificates')
1410 self.certificatesAct.setStatusTip(self.tr(
1411 'Manage the saved SSL certificates'))
1412 self.certificatesAct.setWhatsThis(self.tr(
1413 """<b>Manage SSL Certificates...</b>"""
1414 """<p>Opens a dialog to manage the saved SSL"""
1415 """ certificates.</p>"""
1416 ))
1417 self.certificatesAct.triggered.connect(
1418 self.__showCertificatesDialog)
1419 self.__actions.append(self.certificatesAct)
1420
1421 self.toolsMonitorAct = E5Action(
1422 self.tr('Network Monitor'),
1423 self.tr('&Network Monitor...'),
1424 0, 0,
1425 self, 'help_tools_network_monitor')
1426 self.toolsMonitorAct.setStatusTip(self.tr(
1427 'Show the network monitor dialog'))
1428 self.toolsMonitorAct.setWhatsThis(self.tr(
1429 """<b>Network Monitor...</b>"""
1430 """<p>Shows the network monitor dialog.</p>"""
1431 ))
1432 self.toolsMonitorAct.triggered.connect(
1433 self.__showNetworkMonitor)
1434 self.__actions.append(self.toolsMonitorAct)
1435
1436 self.showDownloadManagerAct = E5Action(
1437 self.tr('Downloads'),
1438 self.tr('Downloads'),
1439 0, 0, self, 'help_show_downloads')
1440 self.showDownloadManagerAct.setStatusTip(self.tr(
1441 'Shows the downloads window'))
1442 self.showDownloadManagerAct.setWhatsThis(self.tr(
1443 """<b>Downloads</b>"""
1444 """<p>Shows the downloads window.</p>"""
1445 ))
1446 self.showDownloadManagerAct.triggered.connect(
1447 self.__showDownloadsWindow)
1448 self.__actions.append(self.showDownloadManagerAct)
1449
1450 self.feedsManagerAct = E5Action(
1451 self.tr('RSS Feeds Dialog'),
1452 UI.PixmapCache.getIcon("rss22.png"),
1453 self.tr('&RSS Feeds Dialog...'),
1454 QKeySequence(self.tr("Ctrl+Shift+F", "Help|RSS Feeds Dialog")),
1455 0, self, 'help_rss_feeds')
1456 self.feedsManagerAct.setStatusTip(self.tr(
1457 'Open a dialog showing the configured RSS feeds.'))
1458 self.feedsManagerAct.setWhatsThis(self.tr(
1459 """<b>RSS Feeds Dialog...</b>"""
1460 """<p>Open a dialog to show the configured RSS feeds."""
1461 """ It can be used to mange the feeds and to show their"""
1462 """ contents.</p>"""
1463 ))
1464 self.feedsManagerAct.triggered.connect(self.__showFeedsManager)
1465 self.__actions.append(self.feedsManagerAct)
1466
1467 self.siteInfoAct = E5Action(
1468 self.tr('Siteinfo Dialog'),
1469 UI.PixmapCache.getIcon("helpAbout.png"),
1470 self.tr('&Siteinfo Dialog...'),
1471 QKeySequence(self.tr("Ctrl+Shift+I", "Help|Siteinfo Dialog")),
1472 0, self, 'help_siteinfo')
1473 self.siteInfoAct.setStatusTip(self.tr(
1474 'Open a dialog showing some information about the current site.'))
1475 self.siteInfoAct.setWhatsThis(self.tr(
1476 """<b>Siteinfo Dialog...</b>"""
1477 """<p>Opens a dialog showing some information about the current"""
1478 """ site.</p>"""
1479 ))
1480 self.siteInfoAct.triggered.connect(self.__showSiteinfoDialog)
1481 self.__actions.append(self.siteInfoAct)
1482
1483 self.userAgentManagerAct = E5Action(
1484 self.tr('Manage User Agent Settings'),
1485 self.tr('Manage &User Agent Settings'),
1486 0, 0, self, 'help_user_agent_settings')
1487 self.userAgentManagerAct.setStatusTip(self.tr(
1488 'Shows a dialog to manage the User Agent settings'))
1489 self.userAgentManagerAct.setWhatsThis(self.tr(
1490 """<b>Manage User Agent Settings</b>"""
1491 """<p>Shows a dialog to manage the User Agent settings.</p>"""
1492 ))
1493 self.userAgentManagerAct.triggered.connect(
1494 self.__showUserAgentsDialog)
1495 self.__actions.append(self.userAgentManagerAct)
1496
1497 self.synchronizationAct = E5Action(
1498 self.tr('Synchronize data'),
1499 UI.PixmapCache.getIcon("sync.png"),
1500 self.tr('&Synchronize Data...'),
1501 0, 0, self, 'help_synchronize_data')
1502 self.synchronizationAct.setStatusTip(self.tr(
1503 'Shows a dialog to synchronize data via the network'))
1504 self.synchronizationAct.setWhatsThis(self.tr(
1505 """<b>Synchronize Data...</b>"""
1506 """<p>This shows a dialog to synchronize data via the"""
1507 """ network.</p>"""
1508 ))
1509 self.synchronizationAct.triggered.connect(
1510 self.__showSyncDialog)
1511 self.__actions.append(self.synchronizationAct)
1512
1513 self.zoomValuesAct = E5Action(
1514 self.tr('Manage Saved Zoom Values'),
1515 UI.PixmapCache.getIcon("zoomReset.png"),
1516 self.tr('Manage Saved Zoom Values...'),
1517 0, 0,
1518 self, 'help_manage_zoom_values')
1519 self.zoomValuesAct.setStatusTip(self.tr(
1520 'Manage the saved zoom values'))
1521 self.zoomValuesAct.setWhatsThis(self.tr(
1522 """<b>Manage Saved Zoom Values...</b>"""
1523 """<p>Opens a dialog to manage the saved zoom values.</p>"""
1524 ))
1525 self.zoomValuesAct.triggered.connect(self.__showZoomValuesDialog)
1526 self.__actions.append(self.zoomValuesAct)
1527
1528 self.shortcutsAct = E5Action(
1529 self.tr('Keyboard Shortcuts'),
1530 UI.PixmapCache.getIcon("configureShortcuts.png"),
1531 self.tr('Keyboard &Shortcuts...'),
1532 0, 0,
1533 self, 'webbrowser_keyboard_shortcuts')
1534 self.shortcutsAct.setStatusTip(self.tr(
1535 'Set the keyboard shortcuts'))
1536 self.shortcutsAct.setWhatsThis(self.tr(
1537 """<b>Keyboard Shortcuts</b>"""
1538 """<p>Set the keyboard shortcuts of the application"""
1539 """ with your prefered values.</p>"""
1540 ))
1541 self.shortcutsAct.triggered.connect(self.__configShortcuts)
1542 self.__actions.append(self.shortcutsAct)
1543
1544 self.exportShortcutsAct = E5Action(
1545 self.tr('Export Keyboard Shortcuts'),
1546 UI.PixmapCache.getIcon("exportShortcuts.png"),
1547 self.tr('&Export Keyboard Shortcuts...'),
1548 0, 0, self, 'export_keyboard_shortcuts')
1549 self.exportShortcutsAct.setStatusTip(self.tr(
1550 'Export the keyboard shortcuts'))
1551 self.exportShortcutsAct.setWhatsThis(self.tr(
1552 """<b>Export Keyboard Shortcuts</b>"""
1553 """<p>Export the keyboard shortcuts of the application.</p>"""
1554 ))
1555 self.exportShortcutsAct.triggered.connect(self.__exportShortcuts)
1556 self.__actions.append(self.exportShortcutsAct)
1557
1558 self.importShortcutsAct = E5Action(
1559 self.tr('Import Keyboard Shortcuts'),
1560 UI.PixmapCache.getIcon("importShortcuts.png"),
1561 self.tr('&Import Keyboard Shortcuts...'),
1562 0, 0, self, 'import_keyboard_shortcuts')
1563 self.importShortcutsAct.setStatusTip(self.tr(
1564 'Import the keyboard shortcuts'))
1565 self.importShortcutsAct.setWhatsThis(self.tr(
1566 """<b>Import Keyboard Shortcuts</b>"""
1567 """<p>Import the keyboard shortcuts of the application.</p>"""
1568 ))
1569 self.importShortcutsAct.triggered.connect(self.__importShortcuts)
1570 self.__actions.append(self.importShortcutsAct)
1571
1572 self.backAct.setEnabled(False)
1573 self.forwardAct.setEnabled(False)
1574
1575 # now read the keyboard shortcuts for the actions
1576 Shortcuts.readShortcuts(helpViewer=self)
1577
1578 def getActions(self):
1579 """
1580 Public method to get a list of all actions.
1581
1582 @return list of all actions (list of E5Action)
1583 """
1584 return self.__actions[:]
1585
1586 def getActionsCategory(self):
1587 """
1588 Public method to get the category of the defined actions.
1589
1590 @return category of the actions
1591 @rtype str
1592 """
1593 return "HelpViewer"
1594
1595 def __initMenus(self):
1596 """
1597 Private method to create the menus.
1598 """
1599 mb = self.menuBar()
1600
1601 menu = mb.addMenu(self.tr('&File'))
1602 menu.setTearOffEnabled(True)
1603 menu.addAction(self.newTabAct)
1604 menu.addAction(self.newAct)
1605 menu.addAction(self.openAct)
1606 menu.addAction(self.openTabAct)
1607 menu.addSeparator()
1608 menu.addAction(self.saveAsAct)
1609 menu.addAction(self.savePageScreenAct)
1610 menu.addAction(self.saveVisiblePageScreenAct)
1611 menu.addSeparator()
1612 menu.addAction(self.printPreviewAct)
1613 menu.addAction(self.printAct)
1614 if self.printPdfAct:
1615 menu.addAction(self.printPdfAct)
1616 menu.addSeparator()
1617 menu.addAction(self.closeAct)
1618 menu.addAction(self.closeAllAct)
1619 menu.addSeparator()
1620 menu.addAction(self.privateBrowsingAct)
1621 menu.addSeparator()
1622 menu.addAction(self.exitAct)
1623
1624 menu = mb.addMenu(self.tr('&Edit'))
1625 menu.setTearOffEnabled(True)
1626 menu.addAction(self.copyAct)
1627 menu.addSeparator()
1628 menu.addAction(self.findAct)
1629 menu.addAction(self.findNextAct)
1630 menu.addAction(self.findPrevAct)
1631
1632 menu = mb.addMenu(self.tr('&View'))
1633 menu.setTearOffEnabled(True)
1634 menu.addAction(self.zoomInAct)
1635 menu.addAction(self.zoomResetAct)
1636 menu.addAction(self.zoomOutAct)
1637 if self.zoomTextOnlyAct is not None:
1638 menu.addAction(self.zoomTextOnlyAct)
1639 menu.addSeparator()
1640 menu.addAction(self.pageSourceAct)
1641 menu.addAction(self.fullScreenAct)
1642 if hasattr(QWebSettings, 'defaultTextEncoding'):
1643 self.__textEncodingMenu = menu.addMenu(
1644 self.tr("Text Encoding"))
1645 self.__textEncodingMenu.aboutToShow.connect(
1646 self.__aboutToShowTextEncodingMenu)
1647 self.__textEncodingMenu.triggered.connect(self.__setTextEncoding)
1648
1649 menu = mb.addMenu(self.tr('&Go'))
1650 menu.setTearOffEnabled(True)
1651 menu.addAction(self.backAct)
1652 menu.addAction(self.forwardAct)
1653 menu.addAction(self.homeAct)
1654 menu.addSeparator()
1655 menu.addAction(self.stopAct)
1656 menu.addAction(self.reloadAct)
1657 if HelpWindow._useQtHelp:
1658 menu.addSeparator()
1659 menu.addAction(self.syncTocAct)
1660
1661 from .History.HistoryMenu import HistoryMenu
1662 self.historyMenu = HistoryMenu(self, self.tabWidget)
1663 self.historyMenu.setTearOffEnabled(True)
1664 self.historyMenu.setTitle(self.tr('H&istory'))
1665 self.historyMenu.openUrl.connect(self.openUrl)
1666 self.historyMenu.newUrl.connect(self.openUrlNewTab)
1667 mb.addMenu(self.historyMenu)
1668
1669 from .Bookmarks.BookmarksMenu import BookmarksMenuBarMenu
1670 self.bookmarksMenu = BookmarksMenuBarMenu(self)
1671 self.bookmarksMenu.setTearOffEnabled(True)
1672 self.bookmarksMenu.setTitle(self.tr('&Bookmarks'))
1673 self.bookmarksMenu.openUrl.connect(self.openUrl)
1674 self.bookmarksMenu.newUrl.connect(self.openUrlNewTab)
1675 mb.addMenu(self.bookmarksMenu)
1676
1677 bookmarksActions = []
1678 bookmarksActions.append(self.bookmarksManageAct)
1679 bookmarksActions.append(self.bookmarksAddAct)
1680 bookmarksActions.append(self.bookmarksAllTabsAct)
1681 bookmarksActions.append(self.bookmarksAddFolderAct)
1682 bookmarksActions.append("--SEPARATOR--")
1683 bookmarksActions.append(self.importBookmarksAct)
1684 bookmarksActions.append(self.exportBookmarksAct)
1685 self.bookmarksMenu.setInitialActions(bookmarksActions)
1686
1687 menu = mb.addMenu(self.tr('&Settings'))
1688 menu.setTearOffEnabled(True)
1689 menu.addAction(self.prefAct)
1690 menu.addSeparator()
1691 menu.addAction(self.shortcutsAct)
1692 menu.addAction(self.exportShortcutsAct)
1693 menu.addAction(self.importShortcutsAct)
1694 menu.addSeparator()
1695 menu.addAction(self.acceptedLanguagesAct)
1696 menu.addAction(self.cookiesAct)
1697 menu.addAction(self.flashCookiesAct)
1698 menu.addAction(self.offlineStorageAct)
1699 menu.addAction(self.personalDataAct)
1700 menu.addAction(self.greaseMonkeyAct)
1701 menu.addAction(self.featurePermissionAct)
1702 menu.addSeparator()
1703 menu.addAction(self.editMessageFilterAct)
1704 menu.addSeparator()
1705 menu.addAction(self.searchEnginesAct)
1706 menu.addSeparator()
1707 menu.addAction(self.passwordsAct)
1708 if SSL_AVAILABLE:
1709 menu.addAction(self.certificatesAct)
1710 menu.addSeparator()
1711 menu.addAction(self.zoomValuesAct)
1712 menu.addSeparator()
1713 menu.addAction(self.adblockAct)
1714 menu.addAction(self.flashblockAct)
1715 menu.addSeparator()
1716 self.__settingsMenu = menu
1717 self.__settingsMenu.aboutToShow.connect(
1718 self.__aboutToShowSettingsMenu)
1719
1720 from .UserAgent.UserAgentMenu import UserAgentMenu
1721 self.__userAgentMenu = UserAgentMenu(self.tr("Global User Agent"))
1722 menu.addMenu(self.__userAgentMenu)
1723 menu.addAction(self.userAgentManagerAct)
1724 menu.addSeparator()
1725
1726 if HelpWindow._useQtHelp:
1727 menu.addAction(self.manageQtHelpDocsAct)
1728 menu.addAction(self.manageQtHelpFiltersAct)
1729 menu.addAction(self.reindexDocumentationAct)
1730 menu.addSeparator()
1731 menu.addAction(self.clearPrivateDataAct)
1732 menu.addAction(self.clearIconsAct)
1733
1734 menu = mb.addMenu(self.tr("&Tools"))
1735 menu.setTearOffEnabled(True)
1736 menu.addAction(self.feedsManagerAct)
1737 menu.addAction(self.siteInfoAct)
1738 menu.addSeparator()
1739 menu.addAction(self.synchronizationAct)
1740 menu.addSeparator()
1741 menu.addAction(self.toolsMonitorAct)
1742
1743 menu = mb.addMenu(self.tr("&Window"))
1744 menu.setTearOffEnabled(True)
1745 menu.addAction(self.showDownloadManagerAct)
1746 if HelpWindow._useQtHelp:
1747 menu.addSeparator()
1748 menu.addAction(self.showTocAct)
1749 menu.addAction(self.showIndexAct)
1750 menu.addAction(self.showSearchAct)
1751
1752 mb.addSeparator()
1753
1754 menu = mb.addMenu(self.tr('&Help'))
1755 menu.setTearOffEnabled(True)
1756 menu.addAction(self.aboutAct)
1757 menu.addAction(self.aboutQtAct)
1758 menu.addSeparator()
1759 menu.addAction(self.whatsThisAct)
1760
1761 def __initToolbars(self):
1762 """
1763 Private method to create the toolbars.
1764 """
1765 filetb = self.addToolBar(self.tr("File"))
1766 filetb.setObjectName("FileToolBar")
1767 filetb.setIconSize(UI.Config.ToolBarIconSize)
1768 filetb.addAction(self.newTabAct)
1769 filetb.addAction(self.newAct)
1770 filetb.addAction(self.openAct)
1771 filetb.addAction(self.openTabAct)
1772 filetb.addSeparator()
1773 filetb.addAction(self.saveAsAct)
1774 filetb.addAction(self.savePageScreenAct)
1775 filetb.addSeparator()
1776 filetb.addAction(self.printPreviewAct)
1777 filetb.addAction(self.printAct)
1778 if self.printPdfAct:
1779 filetb.addAction(self.printPdfAct)
1780 filetb.addSeparator()
1781 filetb.addAction(self.closeAct)
1782 filetb.addAction(self.exitAct)
1783
1784 self.savePageScreenMenu = QMenu(self)
1785 self.savePageScreenMenu.addAction(self.savePageScreenAct)
1786 self.savePageScreenMenu.addAction(self.saveVisiblePageScreenAct)
1787 savePageScreenButton = filetb.widgetForAction(self.savePageScreenAct)
1788 savePageScreenButton.setMenu(self.savePageScreenMenu)
1789 savePageScreenButton.setPopupMode(QToolButton.MenuButtonPopup)
1790
1791 edittb = self.addToolBar(self.tr("Edit"))
1792 edittb.setObjectName("EditToolBar")
1793 edittb.setIconSize(UI.Config.ToolBarIconSize)
1794 edittb.addAction(self.copyAct)
1795
1796 viewtb = self.addToolBar(self.tr("View"))
1797 viewtb.setObjectName("ViewToolBar")
1798 viewtb.setIconSize(UI.Config.ToolBarIconSize)
1799 viewtb.addAction(self.zoomInAct)
1800 viewtb.addAction(self.zoomResetAct)
1801 viewtb.addAction(self.zoomOutAct)
1802 viewtb.addSeparator()
1803 viewtb.addAction(self.fullScreenAct)
1804
1805 findtb = self.addToolBar(self.tr("Find"))
1806 findtb.setObjectName("FindToolBar")
1807 findtb.setIconSize(UI.Config.ToolBarIconSize)
1808 findtb.addAction(self.findAct)
1809 findtb.addAction(self.findNextAct)
1810 findtb.addAction(self.findPrevAct)
1811
1812 if HelpWindow._useQtHelp:
1813 filtertb = self.addToolBar(self.tr("Filter"))
1814 filtertb.setObjectName("FilterToolBar")
1815 self.filterCombo = QComboBox()
1816 self.filterCombo.setMinimumWidth(
1817 QFontMetrics(QFont()).width("ComboBoxWithEnoughWidth"))
1818 filtertb.addWidget(QLabel(self.tr("Filtered by: ")))
1819 filtertb.addWidget(self.filterCombo)
1820 self.__helpEngine.setupFinished.connect(self.__setupFilterCombo)
1821 self.filterCombo.activated[str].connect(
1822 self.__filterQtHelpDocumentation)
1823 self.__setupFilterCombo()
1824
1825 settingstb = self.addToolBar(self.tr("Settings"))
1826 settingstb.setObjectName("SettingsToolBar")
1827 settingstb.setIconSize(UI.Config.ToolBarIconSize)
1828 settingstb.addAction(self.prefAct)
1829 settingstb.addAction(self.shortcutsAct)
1830 settingstb.addAction(self.acceptedLanguagesAct)
1831 settingstb.addAction(self.cookiesAct)
1832 settingstb.addAction(self.flashCookiesAct)
1833 settingstb.addAction(self.offlineStorageAct)
1834 settingstb.addAction(self.personalDataAct)
1835 settingstb.addAction(self.greaseMonkeyAct)
1836 settingstb.addAction(self.featurePermissionAct)
1837
1838 toolstb = self.addToolBar(self.tr("Tools"))
1839 toolstb.setObjectName("ToolsToolBar")
1840 toolstb.setIconSize(UI.Config.ToolBarIconSize)
1841 toolstb.addAction(self.feedsManagerAct)
1842 toolstb.addAction(self.siteInfoAct)
1843 toolstb.addSeparator()
1844 toolstb.addAction(self.synchronizationAct)
1845
1846 helptb = self.addToolBar(self.tr("Help"))
1847 helptb.setObjectName("HelpToolBar")
1848 helptb.setIconSize(UI.Config.ToolBarIconSize)
1849 helptb.addAction(self.whatsThisAct)
1850
1851 self.addToolBarBreak()
1852
1853 gotb = self.addToolBar(self.tr("Go"))
1854 gotb.setObjectName("GoToolBar")
1855 gotb.setIconSize(UI.Config.ToolBarIconSize)
1856 gotb.addAction(self.backAct)
1857 gotb.addAction(self.forwardAct)
1858 gotb.addAction(self.reloadAct)
1859 gotb.addAction(self.stopAct)
1860 gotb.addAction(self.homeAct)
1861 gotb.addSeparator()
1862
1863 self.__navigationSplitter = QSplitter(gotb)
1864 self.__navigationSplitter.addWidget(self.tabWidget.stackedUrlBar())
1865
1866 from .HelpWebSearchWidget import HelpWebSearchWidget
1867 self.searchEdit = HelpWebSearchWidget(self)
1868 sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
1869 sizePolicy.setHorizontalStretch(2)
1870 sizePolicy.setVerticalStretch(0)
1871 self.searchEdit.setSizePolicy(sizePolicy)
1872 self.searchEdit.search.connect(self.__linkActivated)
1873 self.__navigationSplitter.addWidget(self.searchEdit)
1874 gotb.addWidget(self.__navigationSplitter)
1875
1876 self.__navigationSplitter.setSizePolicy(
1877 QSizePolicy.Expanding, QSizePolicy.Maximum)
1878 self.__navigationSplitter.setCollapsible(0, False)
1879
1880 self.backMenu = QMenu(self)
1881 self.backMenu.aboutToShow.connect(self.__showBackMenu)
1882 self.backMenu.triggered.connect(self.__navigationMenuActionTriggered)
1883 backButton = gotb.widgetForAction(self.backAct)
1884 backButton.setMenu(self.backMenu)
1885 backButton.setPopupMode(QToolButton.MenuButtonPopup)
1886
1887 self.forwardMenu = QMenu(self)
1888 self.forwardMenu.aboutToShow.connect(self.__showForwardMenu)
1889 self.forwardMenu.triggered.connect(
1890 self.__navigationMenuActionTriggered)
1891 forwardButton = gotb.widgetForAction(self.forwardAct)
1892 forwardButton.setMenu(self.forwardMenu)
1893 forwardButton.setPopupMode(QToolButton.MenuButtonPopup)
1894
1895 from .Bookmarks.BookmarksToolBar import BookmarksToolBar
1896 bookmarksModel = self.bookmarksManager().bookmarksModel()
1897 self.bookmarksToolBar = BookmarksToolBar(self, bookmarksModel, self)
1898 self.bookmarksToolBar.setObjectName("BookmarksToolBar")
1899 self.bookmarksToolBar.setIconSize(UI.Config.ToolBarIconSize)
1900 self.bookmarksToolBar.openUrl.connect(self.openUrl)
1901 self.bookmarksToolBar.newUrl.connect(self.openUrlNewTab)
1902 self.addToolBarBreak()
1903 self.addToolBar(self.bookmarksToolBar)
1904
1905 self.addToolBarBreak()
1906 vttb = self.addToolBar(self.tr("VirusTotal"))
1907 vttb.setObjectName("VirusTotalToolBar")
1908 vttb.setIconSize(UI.Config.ToolBarIconSize)
1909 vttb.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
1910 self.virustotalScanCurrentAct = vttb.addAction(
1911 UI.PixmapCache.getIcon("virustotal.png"),
1912 self.tr("Scan current site"),
1913 self.__virusTotalScanCurrentSite)
1914 self.virustotalIpReportAct = vttb.addAction(
1915 UI.PixmapCache.getIcon("virustotal.png"),
1916 self.tr("IP Address Report"),
1917 self.__virusTotalIpAddressReport)
1918 self.virustotalDomainReportAct = vttb.addAction(
1919 UI.PixmapCache.getIcon("virustotal.png"),
1920 self.tr("Domain Report"),
1921 self.__virusTotalDomainReport)
1922 if not Preferences.getHelp("VirusTotalEnabled") or \
1923 Preferences.getHelp("VirusTotalServiceKey") == "":
1924 self.virustotalScanCurrentAct.setEnabled(False)
1925 self.virustotalIpReportAct.setEnabled(False)
1926 self.virustotalDomainReportAct.setEnabled(False)
1927
1928 def __nextTab(self):
1929 """
1930 Private slot used to show the next tab.
1931 """
1932 fwidget = QApplication.focusWidget()
1933 while fwidget and not hasattr(fwidget, 'nextTab'):
1934 fwidget = fwidget.parent()
1935 if fwidget:
1936 fwidget.nextTab()
1937
1938 def __prevTab(self):
1939 """
1940 Private slot used to show the previous tab.
1941 """
1942 fwidget = QApplication.focusWidget()
1943 while fwidget and not hasattr(fwidget, 'prevTab'):
1944 fwidget = fwidget.parent()
1945 if fwidget:
1946 fwidget.prevTab()
1947
1948 def __switchTab(self):
1949 """
1950 Private slot used to switch between the current and the previous
1951 current tab.
1952 """
1953 fwidget = QApplication.focusWidget()
1954 while fwidget and not hasattr(fwidget, 'switchTab'):
1955 fwidget = fwidget.parent()
1956 if fwidget:
1957 fwidget.switchTab()
1958
1959 def __whatsThis(self):
1960 """
1961 Private slot called in to enter Whats This mode.
1962 """
1963 QWhatsThis.enterWhatsThisMode()
1964
1965 def __titleChanged(self, browser, title):
1966 """
1967 Private slot called to handle a change of s browser's title.
1968
1969 @param browser reference to the browser (HelpBrowser)
1970 @param title new title (string)
1971 """
1972 self.historyManager().updateHistoryEntry(
1973 browser.url().toString(), title)
1974
1975 @pyqtSlot()
1976 def newTab(self, link=None, requestData=None, addNextTo=None):
1977 """
1978 Public slot called to open a new help window tab.
1979
1980 @param link file to be displayed in the new window (string or QUrl)
1981 @param requestData tuple containing the request data (QNetworkRequest,
1982 QNetworkAccessManager.Operation, QByteArray)
1983 @param addNextTo reference to the browser to open the tab after
1984 (HelpBrowser)
1985 """
1986 if addNextTo:
1987 self.tabWidget.newBrowserAfter(addNextTo, link, requestData)
1988 else:
1989 self.tabWidget.newBrowser(link, requestData)
1990
1991 @pyqtSlot()
1992 def newWindow(self, link=None):
1993 """
1994 Public slot called to open a new help browser dialog.
1995
1996 @param link file to be displayed in the new window (string or QUrl)
1997 """
1998 if link is None:
1999 linkName = ""
2000 elif isinstance(link, QUrl):
2001 linkName = link.toString()
2002 else:
2003 linkName = link
2004 h = HelpWindow(linkName, ".", self.parent(), "qbrowser")
2005 h.show()
2006
2007 def __openFile(self):
2008 """
2009 Private slot called to open a file.
2010 """
2011 fn = E5FileDialog.getOpenFileName(
2012 self,
2013 self.tr("Open File"),
2014 "",
2015 self.tr("Help Files (*.html *.htm);;"
2016 "PDF Files (*.pdf);;"
2017 "CHM Files (*.chm);;"
2018 "All Files (*)"
2019 ))
2020 if fn:
2021 if Utilities.isWindowsPlatform():
2022 url = "file:///" + Utilities.fromNativeSeparators(fn)
2023 else:
2024 url = "file://" + fn
2025 self.currentBrowser().setSource(QUrl(url))
2026
2027 def __openFileNewTab(self):
2028 """
2029 Private slot called to open a file in a new tab.
2030 """
2031 fn = E5FileDialog.getOpenFileName(
2032 self,
2033 self.tr("Open File"),
2034 "",
2035 self.tr("Help Files (*.html *.htm);;"
2036 "PDF Files (*.pdf);;"
2037 "CHM Files (*.chm);;"
2038 "All Files (*)"
2039 ))
2040 if fn:
2041 if Utilities.isWindowsPlatform():
2042 url = "file:///" + Utilities.fromNativeSeparators(fn)
2043 else:
2044 url = "file://" + fn
2045 self.newTab(url)
2046
2047 def __savePageAs(self):
2048 """
2049 Private slot to save the current page.
2050 """
2051 browser = self.currentBrowser()
2052 if browser is not None:
2053 browser.saveAs()
2054
2055 @pyqtSlot()
2056 def __savePageScreen(self, visibleOnly=False):
2057 """
2058 Private slot to save the current page as a screen shot.
2059
2060 @param visibleOnly flag indicating to just save the visible part
2061 of the page (boolean)
2062 """
2063 from .PageScreenDialog import PageScreenDialog
2064 self.__pageScreen = PageScreenDialog(
2065 self.currentBrowser(), visibleOnly=visibleOnly)
2066 self.__pageScreen.show()
2067
2068 def __saveVisiblePageScreen(self):
2069 """
2070 Private slot to save the visible part of the current page as a screen
2071 shot.
2072 """
2073 self.__savePageScreen(visibleOnly=True)
2074
2075 def __about(self):
2076 """
2077 Private slot to show the about information.
2078 """
2079 E5MessageBox.about(
2080 self,
2081 self.tr("eric6 Web Browser"),
2082 self.tr(
2083 """<b>eric6 Web Browser - {0}</b>"""
2084 """<p>The eric6 Web Browser is a combined help file and HTML"""
2085 """ browser. It is part of the eric6 development"""
2086 """ toolset.</p>"""
2087 ).format(Version))
2088
2089 def __aboutQt(self):
2090 """
2091 Private slot to show info about Qt.
2092 """
2093 E5MessageBox.aboutQt(self, self.tr("eric6 Web Browser"))
2094
2095 def setBackwardAvailable(self, b):
2096 """
2097 Public slot called when backward references are available.
2098
2099 @param b flag indicating availability of the backwards action (boolean)
2100 """
2101 self.backAct.setEnabled(b)
2102
2103 def setForwardAvailable(self, b):
2104 """
2105 Public slot called when forward references are available.
2106
2107 @param b flag indicating the availability of the forwards action
2108 (boolean)
2109 """
2110 self.forwardAct.setEnabled(b)
2111
2112 def setLoadingActions(self, b):
2113 """
2114 Public slot to set the loading dependent actions.
2115
2116 @param b flag indicating the loading state to consider (boolean)
2117 """
2118 self.reloadAct.setEnabled(not b)
2119 self.stopAct.setEnabled(b)
2120
2121 def __addBookmark(self):
2122 """
2123 Private slot called to add the displayed file to the bookmarks.
2124 """
2125 view = self.currentBrowser()
2126 url = bytes(view.url().toEncoded()).decode()
2127 title = view.title()
2128 description = ""
2129 meta = view.page().mainFrame().metaData()
2130 if "description" in meta:
2131 description = meta["description"][0]
2132
2133 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog
2134 dlg = AddBookmarkDialog()
2135 dlg.setUrl(url)
2136 dlg.setTitle(title)
2137 dlg.setDescription(description)
2138 menu = self.bookmarksManager().menu()
2139 idx = self.bookmarksManager().bookmarksModel().nodeIndex(menu)
2140 dlg.setCurrentIndex(idx)
2141 dlg.exec_()
2142
2143 def __addBookmarkFolder(self):
2144 """
2145 Private slot to add a new bookmarks folder.
2146 """
2147 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog
2148 dlg = AddBookmarkDialog()
2149 menu = self.bookmarksManager().menu()
2150 idx = self.bookmarksManager().bookmarksModel().nodeIndex(menu)
2151 dlg.setCurrentIndex(idx)
2152 dlg.setFolder(True)
2153 dlg.exec_()
2154
2155 def __showBookmarksDialog(self):
2156 """
2157 Private slot to show the bookmarks dialog.
2158 """
2159 from .Bookmarks.BookmarksDialog import BookmarksDialog
2160 self.__bookmarksDialog = BookmarksDialog(self)
2161 self.__bookmarksDialog.openUrl.connect(self.openUrl)
2162 self.__bookmarksDialog.newUrl.connect(self.openUrlNewTab)
2163 self.__bookmarksDialog.show()
2164
2165 def bookmarkAll(self):
2166 """
2167 Public slot to bookmark all open tabs.
2168 """
2169 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog
2170 dlg = AddBookmarkDialog()
2171 dlg.setFolder(True)
2172 dlg.setTitle(self.tr("Saved Tabs"))
2173 dlg.exec_()
2174
2175 folder = dlg.addedNode()
2176 if folder is None:
2177 return
2178
2179 from .Bookmarks.BookmarkNode import BookmarkNode
2180 for browser in self.tabWidget.browsers():
2181 bookmark = BookmarkNode(BookmarkNode.Bookmark)
2182 bookmark.url = bytes(browser.url().toEncoded()).decode()
2183 bookmark.title = browser.title()
2184 meta = browser.page().mainFrame().metaData()
2185 if "description" in meta:
2186 bookmark.desc = meta["description"][0]
2187
2188 self.bookmarksManager().addBookmark(folder, bookmark)
2189
2190 def __find(self):
2191 """
2192 Private slot to handle the find action.
2193
2194 It opens the search dialog in order to perform the various
2195 search actions and to collect the various search info.
2196 """
2197 self.findDlg.showFind()
2198
2199 def __closeAllWindows(self):
2200 """
2201 Private slot to close all windows.
2202 """
2203 for browser in HelpWindow.helpwindows:
2204 if browser != self:
2205 browser.close()
2206 self.close()
2207
2208 def closeEvent(self, e):
2209 """
2210 Protected event handler for the close event.
2211
2212 @param e the close event (QCloseEvent)
2213 <br />This event is simply accepted after the history has been
2214 saved and all window references have been deleted.
2215 """
2216 if not self.__shutdownCalled:
2217 res = self.shutdown()
2218
2219 if res:
2220 e.accept()
2221 self.helpClosed.emit()
2222 else:
2223 e.ignore()
2224 else:
2225 e.accept()
2226
2227 def shutdown(self):
2228 """
2229 Public method to shut down the web browser.
2230
2231 @return flag indicating successful shutdown (boolean)
2232 """
2233 if not self.tabWidget.shallShutDown():
2234 return False
2235
2236 if not self.downloadManager().allowQuit():
2237 return False
2238
2239 self.downloadManager().shutdown()
2240
2241 self.__closeNetworkMonitor()
2242
2243 self.cookieJar().close()
2244
2245 self.bookmarksToolBar.setModel(None)
2246 self.bookmarksManager().close()
2247
2248 self.historyManager().close()
2249
2250 self.passwordManager().close()
2251
2252 self.adBlockManager().close()
2253
2254 self.userAgentsManager().close()
2255
2256 self.speedDial().close()
2257
2258 self.syncManager().close()
2259
2260 self.zoomManager().close()
2261
2262 self.__virusTotal.close()
2263
2264 self.flashCookieManager().shutdown()
2265
2266 self.searchEdit.openSearchManager().close()
2267
2268 if HelpWindow._useQtHelp:
2269 self.__searchEngine.cancelIndexing()
2270 self.__searchEngine.cancelSearching()
2271
2272 if self.__helpInstaller:
2273 self.__helpInstaller.stop()
2274
2275 self.searchEdit.saveSearches()
2276
2277 self.tabWidget.closeAllBrowsers()
2278
2279 state = self.saveState()
2280 Preferences.setHelp("HelpViewerState", state)
2281
2282 if Preferences.getHelp("SaveGeometry"):
2283 if not self.__isFullScreen():
2284 Preferences.setGeometry("HelpViewerGeometry",
2285 self.saveGeometry())
2286 else:
2287 Preferences.setGeometry("HelpViewerGeometry", QByteArray())
2288
2289 try:
2290 browserIndex = HelpWindow.helpwindows.index(self)
2291 if len(HelpWindow.helpwindows):
2292 if browserIndex == 0:
2293 if len(HelpWindow.helpwindows) > 1:
2294 # first window will be deleted
2295 QDesktopServices.setUrlHandler(
2296 "http",
2297 HelpWindow.helpwindows[1].urlHandler)
2298 QDesktopServices.setUrlHandler(
2299 "https",
2300 HelpWindow.helpwindows[1].urlHandler)
2301 else:
2302 QDesktopServices.unsetUrlHandler("http")
2303 QDesktopServices.unsetUrlHandler("https")
2304 if len(HelpWindow.helpwindows) > 0:
2305 del HelpWindow.helpwindows[browserIndex]
2306 except ValueError:
2307 pass
2308
2309 Preferences.syncPreferences()
2310
2311 self.__shutdownCalled = True
2312 return True
2313
2314 def __backward(self):
2315 """
2316 Private slot called to handle the backward action.
2317 """
2318 self.currentBrowser().backward()
2319
2320 def __forward(self):
2321 """
2322 Private slot called to handle the forward action.
2323 """
2324 self.currentBrowser().forward()
2325
2326 def __home(self):
2327 """
2328 Private slot called to handle the home action.
2329 """
2330 self.currentBrowser().home()
2331
2332 def __reload(self):
2333 """
2334 Private slot called to handle the reload action.
2335 """
2336 self.currentBrowser().reload()
2337
2338 def __stopLoading(self):
2339 """
2340 Private slot called to handle loading of the current page.
2341 """
2342 self.currentBrowser().stop()
2343
2344 def __zoomValueChanged(self, value):
2345 """
2346 Private slot to handle value changes of the zoom widget.
2347
2348 @param value zoom value (integer)
2349 """
2350 self.currentBrowser().setZoomValue(value)
2351
2352 def __zoomIn(self):
2353 """
2354 Private slot called to handle the zoom in action.
2355 """
2356 self.currentBrowser().zoomIn()
2357 self.__zoomWidget.setValue(self.currentBrowser().zoomValue())
2358
2359 def __zoomOut(self):
2360 """
2361 Private slot called to handle the zoom out action.
2362 """
2363 self.currentBrowser().zoomOut()
2364 self.__zoomWidget.setValue(self.currentBrowser().zoomValue())
2365
2366 def __zoomReset(self):
2367 """
2368 Private slot called to handle the zoom reset action.
2369 """
2370 self.currentBrowser().zoomReset()
2371 self.__zoomWidget.setValue(self.currentBrowser().zoomValue())
2372
2373 def __zoomTextOnly(self, textOnly):
2374 """
2375 Private slot called to handle the zoom text only action.
2376
2377 @param textOnly flag indicating to zoom text only (boolean)
2378 """
2379 QWebSettings.globalSettings().setAttribute(
2380 QWebSettings.ZoomTextOnly, textOnly)
2381 self.zoomTextOnlyChanged.emit(textOnly)
2382
2383 def __viewFullScreen(self):
2384 """
2385 Private slot called to toggle fullscreen mode.
2386 """
2387 if self.__isFullScreen():
2388 # switch back to normal
2389 self.setWindowState(self.windowState() & ~Qt.WindowFullScreen)
2390 self.menuBar().show()
2391 self.fullScreenAct.setIcon(
2392 UI.PixmapCache.getIcon("windowFullscreen.png"))
2393 self.fullScreenAct.setIconText(self.tr('Full Screen'))
2394 else:
2395 # switch to full screen
2396 self.setWindowState(self.windowState() | Qt.WindowFullScreen)
2397 self.menuBar().hide()
2398 self.fullScreenAct.setIcon(
2399 UI.PixmapCache.getIcon("windowRestore.png"))
2400 self.fullScreenAct.setIconText(self.tr('Restore Window'))
2401
2402 def __isFullScreen(self):
2403 """
2404 Private method to determine, if the window is in full screen mode.
2405
2406 @return flag indicating full screen mode (boolean)
2407 """
2408 return self.windowState() & Qt.WindowFullScreen
2409
2410 def __copy(self):
2411 """
2412 Private slot called to handle the copy action.
2413 """
2414 self.currentBrowser().copy()
2415
2416 def __privateBrowsing(self):
2417 """
2418 Private slot to switch private browsing.
2419 """
2420 settings = QWebSettings.globalSettings()
2421 pb = settings.testAttribute(QWebSettings.PrivateBrowsingEnabled)
2422 if not pb:
2423 txt = self.tr(
2424 """<b>Are you sure you want to turn on private"""
2425 """ browsing?</b><p>When private browsing is turned on,"""
2426 """ web pages are not added to the history, searches"""
2427 """ are not added to the list of recent searches and"""
2428 """ web site icons and cookies are not stored."""
2429 """ HTML5 offline storage will be deactivated."""
2430 """ Until you close the window, you can still click"""
2431 """ the Back and Forward buttons to return to the"""
2432 """ web pages you have opened.</p>""")
2433 res = E5MessageBox.yesNo(self, "", txt)
2434 if res:
2435 self.setPrivateMode(True)
2436 else:
2437 self.setPrivateMode(False)
2438
2439 def setPrivateMode(self, on):
2440 """
2441 Public method to set the privacy mode.
2442
2443 @param on flag indicating the privacy state (boolean)
2444 """
2445 QWebSettings.globalSettings().setAttribute(
2446 QWebSettings.PrivateBrowsingEnabled, on)
2447 if on:
2448 self.__setIconDatabasePath(False)
2449 else:
2450 self.__setIconDatabasePath(True)
2451 self.privateBrowsingAct.setChecked(on)
2452 self.privacyChanged.emit(on)
2453
2454 def currentBrowser(self):
2455 """
2456 Public method to get a reference to the current help browser.
2457
2458 @return reference to the current help browser (HelpBrowser)
2459 """
2460 return self.tabWidget.currentBrowser()
2461
2462 def browserAt(self, index):
2463 """
2464 Public method to get a reference to the help browser with the given
2465 index.
2466
2467 @param index index of the browser to get (integer)
2468 @return reference to the indexed help browser (HelpBrowser)
2469 """
2470 return self.tabWidget.browserAt(index)
2471
2472 def browsers(self):
2473 """
2474 Public method to get a list of references to all help browsers.
2475
2476 @return list of references to help browsers (list of HelpBrowser)
2477 """
2478 return self.tabWidget.browsers()
2479
2480 def __currentChanged(self, index):
2481 """
2482 Private slot to handle the currentChanged signal.
2483
2484 @param index index of the current tab (integer)
2485 """
2486 if index > -1:
2487 cb = self.currentBrowser()
2488 if cb is not None:
2489 self.setForwardAvailable(cb.isForwardAvailable())
2490 self.setBackwardAvailable(cb.isBackwardAvailable())
2491 self.setLoadingActions(cb.isLoading())
2492
2493 # set value of zoom widget
2494 self.__zoomWidget.setValue(cb.zoomValue())
2495
2496 def __showPreferences(self):
2497 """
2498 Private slot to set the preferences.
2499 """
2500 from Preferences.ConfigurationDialog import ConfigurationDialog
2501 dlg = ConfigurationDialog(
2502 self, 'Configuration', True, fromEric=False,
2503 displayMode=ConfigurationDialog.HelpBrowserMode)
2504 dlg.preferencesChanged.connect(self.preferencesChanged)
2505 dlg.masterPasswordChanged.connect(
2506 lambda old, new: self.masterPasswordChanged(old, new, local=True))
2507 dlg.show()
2508 if self.__lastConfigurationPageName:
2509 dlg.showConfigurationPageByName(self.__lastConfigurationPageName)
2510 else:
2511 dlg.showConfigurationPageByName("empty")
2512 dlg.exec_()
2513 QApplication.processEvents()
2514 if dlg.result() == QDialog.Accepted:
2515 dlg.setPreferences()
2516 Preferences.syncPreferences()
2517 self.preferencesChanged()
2518 self.__lastConfigurationPageName = dlg.getConfigurationPageName()
2519
2520 def preferencesChanged(self):
2521 """
2522 Public slot to handle a change of preferences.
2523 """
2524 self.setStyle(Preferences.getUI("Style"),
2525 Preferences.getUI("StyleSheet"))
2526
2527 self.__initWebSettings()
2528
2529 self.networkAccessManager().preferencesChanged()
2530
2531 self.historyManager().preferencesChanged()
2532
2533 self.tabWidget.preferencesChanged()
2534
2535 self.searchEdit.preferencesChanged()
2536
2537 self.__virusTotal.preferencesChanged()
2538 if not Preferences.getHelp("VirusTotalEnabled") or \
2539 Preferences.getHelp("VirusTotalServiceKey") == "":
2540 self.virustotalScanCurrentAct.setEnabled(False)
2541 self.virustotalIpReportAct.setEnabled(False)
2542 self.virustotalDomainReportAct.setEnabled(False)
2543 else:
2544 self.virustotalScanCurrentAct.setEnabled(True)
2545 self.virustotalIpReportAct.setEnabled(True)
2546 self.virustotalDomainReportAct.setEnabled(True)
2547
2548 def masterPasswordChanged(self, oldPassword, newPassword, local=False):
2549 """
2550 Public slot to handle the change of the master password.
2551
2552 @param oldPassword current master password
2553 @type str
2554 @param newPassword new master password
2555 @type str
2556 @param local flag indicating being called from the local configuration
2557 dialog
2558 @type bool
2559 """
2560 self.passwordManager().masterPasswordChanged(oldPassword, newPassword)
2561 if local:
2562 # we were called from our local configuration dialog
2563 Preferences.convertPasswords(oldPassword, newPassword)
2564 Utilities.crypto.changeRememberedMaster(newPassword)
2565
2566 def __showAcceptedLanguages(self):
2567 """
2568 Private slot to configure the accepted languages for web pages.
2569 """
2570 from .HelpLanguagesDialog import HelpLanguagesDialog
2571 dlg = HelpLanguagesDialog(self)
2572 dlg.exec_()
2573 self.networkAccessManager().languagesChanged()
2574
2575 def __showCookiesConfiguration(self):
2576 """
2577 Private slot to configure the cookies handling.
2578 """
2579 from .CookieJar.CookiesConfigurationDialog import \
2580 CookiesConfigurationDialog
2581 dlg = CookiesConfigurationDialog(self)
2582 dlg.exec_()
2583
2584 def __showFlashCookiesManagement(self):
2585 """
2586 Private slot to show the flash cookies management dialog.
2587 """
2588 self.flashCookieManager().showFlashCookieManagerDialog()
2589
2590 def __showOfflineStorageConfiguration(self):
2591 """
2592 Private slot to configure the offline storage.
2593 """
2594 from .OfflineStorage.OfflineStorageConfigDialog import \
2595 OfflineStorageConfigDialog
2596 dlg = OfflineStorageConfigDialog(self)
2597 if dlg.exec_() == QDialog.Accepted:
2598 dlg.storeData()
2599 self.__initWebSettings()
2600
2601 @classmethod
2602 def setUseQtHelp(cls, use):
2603 """
2604 Class method to set the QtHelp usage.
2605
2606 @param use flag indicating usage (boolean)
2607 """
2608 if use:
2609 cls._useQtHelp = use and QTHELP_AVAILABLE
2610 else:
2611 cls._useQtHelp = False
2612
2613 @classmethod
2614 def helpEngine(cls):
2615 """
2616 Class method to get a reference to the help engine.
2617
2618 @return reference to the help engine (QHelpEngine)
2619 """
2620 if cls._useQtHelp:
2621 if cls._helpEngine is None:
2622 cls._helpEngine = QHelpEngine(
2623 HelpWindow.getQtHelpCollectionFileName())
2624 return cls._helpEngine
2625 else:
2626 return None
2627
2628 @classmethod
2629 def getQtHelpCollectionFileName(cls):
2630 """
2631 Class method to determine the name of the QtHelp collection file.
2632
2633 @return path of the QtHelp collection file
2634 @rtype str
2635 """
2636 qthelpDir = os.path.join(Utilities.getConfigDir(), "qthelp")
2637 if not os.path.exists(qthelpDir):
2638 os.makedirs(qthelpDir)
2639 return os.path.join(qthelpDir, "eric6help.qhc")
2640
2641 @classmethod
2642 def networkAccessManager(cls):
2643 """
2644 Class method to get a reference to the network access manager.
2645
2646 @return reference to the network access manager (NetworkAccessManager)
2647 """
2648 if cls._networkAccessManager is None:
2649 from .Network.NetworkAccessManager import NetworkAccessManager
2650 from .CookieJar.CookieJar import CookieJar
2651 cls._networkAccessManager = \
2652 NetworkAccessManager(cls.helpEngine())
2653 cls._cookieJar = CookieJar()
2654 cls._networkAccessManager.setCookieJar(cls._cookieJar)
2655
2656 return cls._networkAccessManager
2657
2658 @classmethod
2659 def cookieJar(cls):
2660 """
2661 Class method to get a reference to the cookie jar.
2662
2663 @return reference to the cookie jar (CookieJar)
2664 """
2665 return cls.networkAccessManager().cookieJar()
2666
2667 def __clearIconsDatabase(self):
2668 """
2669 Private slot to clear the icons databse.
2670 """
2671 QWebSettings.clearIconDatabase()
2672
2673 @pyqtSlot(QUrl)
2674 def urlHandler(self, url):
2675 """
2676 Public slot used as desktop URL handler.
2677
2678 @param url URL to be handled
2679 @type QUrl
2680 """
2681 self.__linkActivated(url)
2682
2683 @pyqtSlot(QUrl)
2684 def __linkActivated(self, url):
2685 """
2686 Private slot to handle the selection of a link in the TOC window.
2687
2688 @param url URL to be shown
2689 @type QUrl
2690 """
2691 if not self.__activating:
2692 self.__activating = True
2693 req = QNetworkRequest(url)
2694 req.setRawHeader(b"X-Eric6-UserLoadAction", b"1")
2695 cb = self.currentBrowser()
2696 if cb is None:
2697 self.newTab(
2698 None, (req, QNetworkAccessManager.GetOperation, b""))
2699 else:
2700 cb.setSource(
2701 None, (req, QNetworkAccessManager.GetOperation, b""))
2702 self.__activating = False
2703
2704 def __linksActivated(self, links, keyword):
2705 """
2706 Private slot to select a topic to be shown.
2707
2708 @param links dictionary with help topic as key (string) and
2709 URL as value (QUrl)
2710 @param keyword keyword for the link set (string)
2711 """
2712 if not self.__activating:
2713 from .HelpTopicDialog import HelpTopicDialog
2714 self.__activating = True
2715 dlg = HelpTopicDialog(self, keyword, links)
2716 if dlg.exec_() == QDialog.Accepted:
2717 self.currentBrowser().setSource(dlg.link())
2718 self.__activating = False
2719
2720 def __activateCurrentBrowser(self):
2721 """
2722 Private slot to activate the current browser.
2723 """
2724 self.currentBrowser().setFocus()
2725
2726 def __syncTOC(self):
2727 """
2728 Private slot to synchronize the TOC with the currently shown page.
2729 """
2730 if HelpWindow._useQtHelp:
2731 QApplication.setOverrideCursor(Qt.WaitCursor)
2732 url = self.currentBrowser().source()
2733 self.__showTocWindow()
2734 if not self.__tocWindow.syncToContent(url):
2735 self.statusBar().showMessage(
2736 self.tr("Could not find an associated content."), 5000)
2737 QApplication.restoreOverrideCursor()
2738
2739 def __showTocWindow(self):
2740 """
2741 Private method to show the table of contents window.
2742 """
2743 if HelpWindow._useQtHelp:
2744 self.__activateDock(self.__tocWindow)
2745
2746 def __hideTocWindow(self):
2747 """
2748 Private method to hide the table of contents window.
2749 """
2750 if HelpWindow._useQtHelp:
2751 self.__tocDock.hide()
2752
2753 def __showIndexWindow(self):
2754 """
2755 Private method to show the index window.
2756 """
2757 if HelpWindow._useQtHelp:
2758 self.__activateDock(self.__indexWindow)
2759
2760 def __hideIndexWindow(self):
2761 """
2762 Private method to hide the index window.
2763 """
2764 if HelpWindow._useQtHelp:
2765 self.__indexDock.hide()
2766
2767 def __showSearchWindow(self):
2768 """
2769 Private method to show the search window.
2770 """
2771 if HelpWindow._useQtHelp:
2772 self.__activateDock(self.__searchWindow)
2773
2774 def __hideSearchWindow(self):
2775 """
2776 Private method to hide the search window.
2777 """
2778 if HelpWindow._useQtHelp:
2779 self.__searchDock.hide()
2780
2781 def __activateDock(self, widget):
2782 """
2783 Private method to activate the dock widget of the given widget.
2784
2785 @param widget reference to the widget to be activated (QWidget)
2786 """
2787 widget.parent().show()
2788 widget.parent().raise_()
2789 widget.setFocus()
2790
2791 def __setupFilterCombo(self):
2792 """
2793 Private slot to setup the filter combo box.
2794 """
2795 if HelpWindow._useQtHelp:
2796 curFilter = self.filterCombo.currentText()
2797 if not curFilter:
2798 curFilter = self.__helpEngine.currentFilter()
2799 self.filterCombo.clear()
2800 self.filterCombo.addItems(self.__helpEngine.customFilters())
2801 idx = self.filterCombo.findText(curFilter)
2802 if idx < 0:
2803 idx = 0
2804 self.filterCombo.setCurrentIndex(idx)
2805
2806 def __filterQtHelpDocumentation(self, customFilter):
2807 """
2808 Private slot to filter the QtHelp documentation.
2809
2810 @param customFilter name of filter to be applied (string)
2811 """
2812 if self.__helpEngine:
2813 self.__helpEngine.setCurrentFilter(customFilter)
2814
2815 def __manageQtHelpDocumentation(self):
2816 """
2817 Private slot to manage the QtHelp documentation database.
2818 """
2819 if HelpWindow._useQtHelp:
2820 from .QtHelpDocumentationDialog import QtHelpDocumentationDialog
2821 dlg = QtHelpDocumentationDialog(self.__helpEngine, self)
2822 dlg.exec_()
2823 if dlg.hasChanges():
2824 for i in sorted(dlg.getTabsToClose(), reverse=True):
2825 self.tabWidget.closeBrowserAt(i)
2826 self.__helpEngine.setupData()
2827
2828 def getSourceFileList(self):
2829 """
2830 Public method to get a list of all opened source files.
2831
2832 @return dictionary with tab id as key and host/namespace as value
2833 """
2834 return self.tabWidget.getSourceFileList()
2835
2836 def __manageQtHelpFilters(self):
2837 """
2838 Private slot to manage the QtHelp filters.
2839 """
2840 if HelpWindow._useQtHelp:
2841 from .QtHelpFiltersDialog import QtHelpFiltersDialog
2842 dlg = QtHelpFiltersDialog(self.__helpEngine, self)
2843 dlg.exec_()
2844
2845 def __indexingStarted(self):
2846 """
2847 Private slot to handle the start of the indexing process.
2848 """
2849 if HelpWindow._useQtHelp:
2850 self.__indexing = True
2851 if self.__indexingProgress is None:
2852 self.__indexingProgress = QWidget()
2853 layout = QHBoxLayout(self.__indexingProgress)
2854 layout.setContentsMargins(0, 0, 0, 0)
2855 sizePolicy = QSizePolicy(QSizePolicy.Preferred,
2856 QSizePolicy.Maximum)
2857
2858 label = QLabel(self.tr("Updating search index"))
2859 label.setSizePolicy(sizePolicy)
2860 layout.addWidget(label)
2861
2862 progressBar = QProgressBar()
2863 progressBar.setRange(0, 0)
2864 progressBar.setTextVisible(False)
2865 progressBar.setFixedHeight(16)
2866 progressBar.setSizePolicy(sizePolicy)
2867 layout.addWidget(progressBar)
2868
2869 self.statusBar().insertPermanentWidget(
2870 0, self.__indexingProgress)
2871
2872 def __indexingFinished(self):
2873 """
2874 Private slot to handle the start of the indexing process.
2875 """
2876 if HelpWindow._useQtHelp:
2877 self.statusBar().removeWidget(self.__indexingProgress)
2878 self.__indexingProgress = None
2879 self.__indexing = False
2880 if self.__searchWord is not None:
2881 self.__searchForWord()
2882
2883 def __searchForWord(self):
2884 """
2885 Private slot to search for a word.
2886 """
2887 if HelpWindow._useQtHelp and not self.__indexing and \
2888 self.__searchWord is not None:
2889 self.__searchDock.show()
2890 self.__searchDock.raise_()
2891 query = QHelpSearchQuery(QHelpSearchQuery.DEFAULT,
2892 [self.__searchWord])
2893 self.__searchEngine.search([query])
2894 self.__searchWord = None
2895
2896 def search(self, word):
2897 """
2898 Public method to search for a word.
2899
2900 @param word word to search for (string)
2901 """
2902 if HelpWindow._useQtHelp:
2903 self.__searchWord = word
2904 self.__searchForWord()
2905
2906 def __removeOldDocumentation(self):
2907 """
2908 Private slot to remove non-existing documentation from the help engine.
2909 """
2910 if HelpWindow._useQtHelp:
2911 for namespace in self.__helpEngine.registeredDocumentations():
2912 docFile = self.__helpEngine.documentationFileName(namespace)
2913 if not os.path.exists(docFile):
2914 self.__helpEngine.unregisterDocumentation(namespace)
2915
2916 def __lookForNewDocumentation(self):
2917 """
2918 Private slot to look for new documentation to be loaded into the
2919 help database.
2920 """
2921 if HelpWindow._useQtHelp:
2922 from .HelpDocsInstaller import HelpDocsInstaller
2923 self.__helpInstaller = HelpDocsInstaller(
2924 self.__helpEngine.collectionFile())
2925 self.__helpInstaller.errorMessage.connect(
2926 self.__showInstallationError)
2927 self.__helpInstaller.docsInstalled.connect(self.__docsInstalled)
2928
2929 self.statusBar().showMessage(
2930 self.tr("Looking for Documentation..."))
2931 self.__helpInstaller.installDocs()
2932
2933 def __showInstallationError(self, message):
2934 """
2935 Private slot to show installation errors.
2936
2937 @param message message to be shown (string)
2938 """
2939 E5MessageBox.warning(
2940 self,
2941 self.tr("eric6 Web Browser"),
2942 message)
2943
2944 def __docsInstalled(self, installed):
2945 """
2946 Private slot handling the end of documentation installation.
2947
2948 @param installed flag indicating that documents were installed
2949 (boolean)
2950 """
2951 if HelpWindow._useQtHelp:
2952 if installed:
2953 self.__helpEngine.setupData()
2954 self.statusBar().clearMessage()
2955
2956 def __initHelpDb(self):
2957 """
2958 Private slot to initialize the documentation database.
2959 """
2960 if HelpWindow._useQtHelp:
2961 if not self.__helpEngine.setupData():
2962 return
2963
2964 unfiltered = self.tr("Unfiltered")
2965 if unfiltered not in self.__helpEngine.customFilters():
2966 hc = QHelpEngineCore(self.__helpEngine.collectionFile())
2967 hc.setupData()
2968 hc.addCustomFilter(unfiltered, [])
2969 hc = None
2970 del hc
2971
2972 self.__helpEngine.blockSignals(True)
2973 self.__helpEngine.setCurrentFilter(unfiltered)
2974 self.__helpEngine.blockSignals(False)
2975 self.__helpEngine.setupData()
2976
2977 def __warning(self, msg):
2978 """
2979 Private slot handling warnings from the help engine.
2980
2981 @param msg message sent by the help engine (string)
2982 """
2983 E5MessageBox.warning(
2984 self,
2985 self.tr("Help Engine"), msg)
2986
2987 def __aboutToShowSettingsMenu(self):
2988 """
2989 Private slot to show the Settings menu.
2990 """
2991 self.editMessageFilterAct.setEnabled(
2992 E5ErrorMessage.messageHandlerInstalled())
2993
2994 def __showBackMenu(self):
2995 """
2996 Private slot showing the backwards navigation menu.
2997 """
2998 self.backMenu.clear()
2999 history = self.currentBrowser().history()
3000 historyCount = history.count()
3001 backItems = history.backItems(historyCount)
3002 for index in range(len(backItems) - 1, -1, -1):
3003 item = backItems[index]
3004 act = QAction(self)
3005 act.setData(-1 * (index + 1))
3006 icon = HelpWindow.__getWebIcon(item.url())
3007 act.setIcon(icon)
3008 act.setText(item.title())
3009 self.backMenu.addAction(act)
3010
3011 def __showForwardMenu(self):
3012 """
3013 Private slot showing the forwards navigation menu.
3014 """
3015 self.forwardMenu.clear()
3016 history = self.currentBrowser().history()
3017 historyCount = history.count()
3018 forwardItems = history.forwardItems(historyCount)
3019 for index in range(len(forwardItems)):
3020 item = forwardItems[index]
3021 act = QAction(self)
3022 act.setData(index + 1)
3023 icon = HelpWindow.__getWebIcon(item.url())
3024 act.setIcon(icon)
3025 act.setText(item.title())
3026 self.forwardMenu.addAction(act)
3027
3028 def __navigationMenuActionTriggered(self, act):
3029 """
3030 Private slot to go to the selected page.
3031
3032 @param act reference to the action selected in the navigation menu
3033 (QAction)
3034 """
3035 offset = act.data()
3036 history = self.currentBrowser().history()
3037 historyCount = history.count()
3038 if offset < 0:
3039 # go back
3040 history.goToItem(history.backItems(historyCount)[-1 * offset - 1])
3041 else:
3042 # go forward
3043 history.goToItem(history.forwardItems(historyCount)[offset - 1])
3044
3045 def __clearPrivateData(self):
3046 """
3047 Private slot to clear the private data.
3048 """
3049 from .HelpClearPrivateDataDialog import HelpClearPrivateDataDialog
3050 dlg = HelpClearPrivateDataDialog(self)
3051 if dlg.exec_() == QDialog.Accepted:
3052 # browsing history, search history, favicons, disk cache, cookies,
3053 # passwords, web databases, downloads, Flash cookies
3054 (history, searches, favicons, cache, cookies,
3055 passwords, databases, downloads, flashCookies, zoomValues,
3056 historyPeriod) = dlg.getData()
3057 if history:
3058 self.historyManager().clear(historyPeriod)
3059 self.tabWidget.clearClosedTabsList()
3060 if searches:
3061 self.searchEdit.clear()
3062 if downloads:
3063 self.downloadManager().cleanup()
3064 self.downloadManager().hide()
3065 if favicons:
3066 self.__clearIconsDatabase()
3067 if cache:
3068 try:
3069 self.networkAccessManager().cache().clear()
3070 except AttributeError:
3071 pass
3072 if cookies:
3073 self.cookieJar().clear()
3074 if passwords:
3075 self.passwordManager().clear()
3076 if databases:
3077 if hasattr(QWebDatabase, "removeAllDatabases"):
3078 QWebDatabase.removeAllDatabases()
3079 else:
3080 for securityOrigin in QWebSecurityOrigin.allOrigins():
3081 for database in securityOrigin.databases():
3082 QWebDatabase.removeDatabase(database)
3083 if flashCookies:
3084 from .HelpLanguagesDialog import HelpLanguagesDialog
3085 languages = Preferences.toList(
3086 Preferences.Prefs.settings.value(
3087 "Help/AcceptLanguages",
3088 HelpLanguagesDialog.defaultAcceptLanguages()))
3089 if languages:
3090 language = languages[0]
3091 langCode = language.split("[")[1][:2]
3092 self.newTab(
3093 "http://www.macromedia.com/support/documentation/"
3094 "{0}/flashplayer/help/settings_manager07.html".format(
3095 langCode))
3096 if zoomValues:
3097 self.zoomManager().clear()
3098
3099 def __showEnginesConfigurationDialog(self):
3100 """
3101 Private slot to show the search engines configuration dialog.
3102 """
3103 from .OpenSearch.OpenSearchDialog import OpenSearchDialog
3104
3105 dlg = OpenSearchDialog(self)
3106 dlg.exec_()
3107
3108 def searchEnginesAction(self):
3109 """
3110 Public method to get a reference to the search engines configuration
3111 action.
3112
3113 @return reference to the search engines configuration action (QAction)
3114 """
3115 return self.searchEnginesAct
3116
3117 def __showPasswordsDialog(self):
3118 """
3119 Private slot to show the passwords management dialog.
3120 """
3121 from .Passwords.PasswordsDialog import PasswordsDialog
3122
3123 dlg = PasswordsDialog(self)
3124 dlg.exec_()
3125
3126 def __showCertificatesDialog(self):
3127 """
3128 Private slot to show the certificates management dialog.
3129 """
3130 from E5Network.E5SslCertificatesDialog import E5SslCertificatesDialog
3131
3132 dlg = E5SslCertificatesDialog(self)
3133 dlg.exec_()
3134
3135 def __showAdBlockDialog(self):
3136 """
3137 Private slot to show the AdBlock configuration dialog.
3138 """
3139 self.adBlockManager().showDialog()
3140
3141 def __showClickToFlashDialog(self):
3142 """
3143 Private slot to open the ClickToFlash whitelist configuration dialog.
3144 """
3145 from .HelpBrowserWV import HelpWebPage
3146 HelpWebPage.webPluginFactory().plugin("ClickToFlash").configure()
3147
3148 def __showPersonalInformationDialog(self):
3149 """
3150 Private slot to show the Personal Information configuration dialog.
3151 """
3152 self.personalInformationManager().showConfigurationDialog()
3153
3154 def __showGreaseMonkeyConfigDialog(self):
3155 """
3156 Private slot to show the GreaseMonkey scripts configuration dialog.
3157 """
3158 self.greaseMonkeyManager().showConfigurationDialog()
3159
3160 def __showFeaturePermissionDialog(self):
3161 """
3162 Private slot to show the feature permission dialog.
3163 """
3164 self.featurePermissionManager().showFeaturePermissionsDialog()
3165
3166 def __showZoomValuesDialog(self):
3167 """
3168 Private slot to show the zoom values management dialog.
3169 """
3170 from .ZoomManager.ZoomValuesDialog import ZoomValuesDialog
3171
3172 dlg = ZoomValuesDialog(self)
3173 dlg.exec_()
3174
3175 def __showNetworkMonitor(self):
3176 """
3177 Private slot to show the network monitor dialog.
3178 """
3179 from E5Network.E5NetworkMonitor import E5NetworkMonitor
3180 monitor = E5NetworkMonitor.instance(self.networkAccessManager())
3181 monitor.show()
3182
3183 def __showDownloadsWindow(self):
3184 """
3185 Private slot to show the downloads dialog.
3186 """
3187 self.downloadManager().show()
3188
3189 def __closeNetworkMonitor(self):
3190 """
3191 Private slot to close the network monitor dialog.
3192 """
3193 from E5Network.E5NetworkMonitor import E5NetworkMonitor
3194 E5NetworkMonitor.closeMonitor()
3195
3196 def __showPageSource(self):
3197 """
3198 Private slot to show the source of the current page in an editor.
3199 """
3200 from QScintilla.MiniEditor import MiniEditor
3201 src = self.currentBrowser().page().mainFrame().toHtml()
3202 editor = MiniEditor(parent=self)
3203 editor.setText(src, "Html")
3204 editor.setLanguage("dummy.html")
3205 editor.show()
3206
3207 @classmethod
3208 def icon(cls, url):
3209 """
3210 Class method to get the icon for an URL.
3211
3212 @param url URL to get icon for (QUrl)
3213 @return icon for the URL (QIcon)
3214 """
3215 icon = HelpWindow.__getWebIcon(url)
3216 if icon.isNull():
3217 hostUrl = QUrl()
3218 hostUrl.setScheme(url.scheme())
3219 hostUrl.setHost(url.host())
3220 icon = HelpWindow.__getWebIcon(hostUrl)
3221
3222 if icon.isNull():
3223 pixmap = QWebSettings.webGraphic(
3224 QWebSettings.DefaultFrameIconGraphic)
3225 if pixmap.isNull():
3226 pixmap = UI.PixmapCache.getPixmap("defaultIcon.png")
3227 QWebSettings.setWebGraphic(
3228 QWebSettings.DefaultFrameIconGraphic, pixmap)
3229 return QIcon(pixmap)
3230
3231 return icon
3232
3233 @staticmethod
3234 def __getWebIcon(url):
3235 """
3236 Private static method to fetch the icon for a URL.
3237
3238 @param url URL to get icon for (QUrl)
3239 @return icon for the URL (QIcon)
3240 """
3241 scheme = url.scheme()
3242 if scheme in ["eric", "about"]:
3243 return UI.PixmapCache.getIcon("ericWeb.png")
3244 elif scheme == "qthelp" and QTHELP_AVAILABLE:
3245 return UI.PixmapCache.getIcon("qthelp.png")
3246 elif scheme == "file":
3247 return UI.PixmapCache.getIcon("fileMisc.png")
3248 elif scheme == "abp":
3249 return UI.PixmapCache.getIcon("adBlockPlus.png")
3250
3251 icon = QWebSettings.iconForUrl(url)
3252 if icon.isNull():
3253 # try again
3254 QThread.usleep(10)
3255 icon = QWebSettings.iconForUrl(url)
3256 if not icon.isNull():
3257 icon = QIcon(icon.pixmap(22, 22))
3258 return icon
3259
3260 @classmethod
3261 def bookmarksManager(cls):
3262 """
3263 Class method to get a reference to the bookmarks manager.
3264
3265 @return reference to the bookmarks manager (BookmarksManager)
3266 """
3267 if cls._bookmarksManager is None:
3268 from .Bookmarks.BookmarksManager import BookmarksManager
3269 cls._bookmarksManager = BookmarksManager()
3270
3271 return cls._bookmarksManager
3272
3273 def openUrl(self, url, title):
3274 """
3275 Public slot to load a URL from the bookmarks menu or bookmarks toolbar
3276 in the current tab.
3277
3278 @param url url to be opened (QUrl)
3279 @param title title of the bookmark (string)
3280 """
3281 self.__linkActivated(url)
3282
3283 def openUrlNewTab(self, url, title):
3284 """
3285 Public slot to load a URL from the bookmarks menu or bookmarks toolbar
3286 in a new tab.
3287
3288 @param url url to be opened (QUrl)
3289 @param title title of the bookmark (string)
3290 """
3291 req = QNetworkRequest(url)
3292 req.setRawHeader(b"X-Eric6-UserLoadAction", b"1")
3293 self.newTab(None, (req, QNetworkAccessManager.GetOperation, b""))
3294
3295 @classmethod
3296 def historyManager(cls):
3297 """
3298 Class method to get a reference to the history manager.
3299
3300 @return reference to the history manager (HistoryManager)
3301 """
3302 if cls._historyManager is None:
3303 from .History.HistoryManager import HistoryManager
3304 cls._historyManager = HistoryManager()
3305
3306 return cls._historyManager
3307
3308 @classmethod
3309 def passwordManager(cls):
3310 """
3311 Class method to get a reference to the password manager.
3312
3313 @return reference to the password manager (PasswordManager)
3314 """
3315 if cls._passwordManager is None:
3316 from .Passwords.PasswordManager import PasswordManager
3317 cls._passwordManager = PasswordManager()
3318
3319 return cls._passwordManager
3320
3321 @classmethod
3322 def adBlockManager(cls):
3323 """
3324 Class method to get a reference to the AdBlock manager.
3325
3326 @return reference to the AdBlock manager (AdBlockManager)
3327 """
3328 if cls._adblockManager is None:
3329 from .AdBlock.AdBlockManager import AdBlockManager
3330 cls._adblockManager = AdBlockManager()
3331
3332 return cls._adblockManager
3333
3334 def adBlockIcon(self):
3335 """
3336 Public method to get a reference to the AdBlock icon.
3337
3338 @return reference to the AdBlock icon (AdBlockIcon)
3339 """
3340 return self.__adBlockIcon
3341
3342 @classmethod
3343 def downloadManager(cls):
3344 """
3345 Class method to get a reference to the download manager.
3346
3347 @return reference to the password manager (DownloadManager)
3348 """
3349 if cls._downloadManager is None:
3350 from .Download.DownloadManager import DownloadManager
3351 cls._downloadManager = DownloadManager()
3352
3353 return cls._downloadManager
3354
3355 @classmethod
3356 def personalInformationManager(cls):
3357 """
3358 Class method to get a reference to the personal information manager.
3359
3360 @return reference to the personal information manager
3361 (PersonalInformationManager)
3362 """
3363 if cls._personalInformationManager is None:
3364 from .PersonalInformationManager.PersonalInformationManager \
3365 import PersonalInformationManager
3366 cls._personalInformationManager = PersonalInformationManager()
3367
3368 return cls._personalInformationManager
3369
3370 @classmethod
3371 def greaseMonkeyManager(cls):
3372 """
3373 Class method to get a reference to the GreaseMonkey manager.
3374
3375 @return reference to the GreaseMonkey manager (GreaseMonkeyManager)
3376 """
3377 if cls._greaseMonkeyManager is None:
3378 from .GreaseMonkey.GreaseMonkeyManager import GreaseMonkeyManager
3379 cls._greaseMonkeyManager = GreaseMonkeyManager()
3380
3381 return cls._greaseMonkeyManager
3382
3383 @classmethod
3384 def featurePermissionManager(cls):
3385 """
3386 Class method to get a reference to the feature permission manager.
3387
3388 @return reference to the feature permission manager
3389 @rtype FeaturePermissionManager
3390 """
3391 if cls._featurePermissionManager is None:
3392 from .FeaturePermissions.FeaturePermissionManager import \
3393 FeaturePermissionManager
3394 cls._featurePermissionManager = FeaturePermissionManager()
3395
3396 return cls._featurePermissionManager
3397
3398 @classmethod
3399 def flashCookieManager(cls):
3400 """
3401 Class method to get a reference to the flash cookies manager.
3402
3403 @return reference to the flash cookies manager
3404 @rtype FlashCookieManager
3405 """
3406 if cls._flashCookieManager is None:
3407 from .FlashCookieManager.FlashCookieManager import \
3408 FlashCookieManager
3409 cls._flashCookieManager = FlashCookieManager()
3410
3411 return cls._flashCookieManager
3412
3413 @classmethod
3414 def zoomManager(cls):
3415 """
3416 Class method to get a reference to the zoom values manager.
3417
3418 @return reference to the zoom values manager
3419 @rtype ZoomManager
3420 """
3421 if cls._zoomManager is None:
3422 from .ZoomManager.ZoomManager import ZoomManager
3423 cls._zoomManager = ZoomManager()
3424
3425 return cls._zoomManager
3426
3427 @classmethod
3428 def mainWindow(cls):
3429 """
3430 Class method to get a reference to the main window.
3431
3432 @return reference to the main window (HelpWindow)
3433 """
3434 if cls.helpwindows:
3435 return cls.helpwindows[0]
3436 else:
3437 return None
3438
3439 @classmethod
3440 def mainWindows(cls):
3441 """
3442 Class method to get references to all main windows.
3443
3444 @return references to all main window (list of HelpWindow)
3445 """
3446 return cls.helpwindows
3447
3448 def __appFocusChanged(self, old, now):
3449 """
3450 Private slot to handle a change of the focus.
3451
3452 @param old reference to the widget, that lost focus (QWidget or None)
3453 @param now reference to the widget having the focus (QWidget or None)
3454 """
3455 if isinstance(now, HelpWindow):
3456 self.__lastActiveWindow = now
3457
3458 def getWindow(self):
3459 """
3460 Public method to get a reference to the most recent active help window.
3461
3462 @return reference to most recent help window
3463 @rtype HelpWindow
3464 """
3465 if self.__lastActiveWindow:
3466 return self.__lastActiveWindow
3467
3468 return self.mainWindow()
3469
3470 def openSearchManager(self):
3471 """
3472 Public method to get a reference to the opensearch manager object.
3473
3474 @return reference to the opensearch manager object (OpenSearchManager)
3475 """
3476 return self.searchEdit.openSearchManager()
3477
3478 def __createTextEncodingAction(self, codec, defaultCodec, parentMenu):
3479 """
3480 Private method to create an action for the text encoding menu.
3481
3482 @param codec name of the codec to create an action for
3483 @type str
3484 @param defaultCodec name of the default codec
3485 @type str
3486 @param parentMenu reference to the parent menu
3487 @type QMenu
3488 """
3489 act = QAction(codec, parentMenu)
3490 act.setData(codec)
3491 act.setCheckable(True)
3492 if defaultCodec == codec:
3493 act.setChecked(True)
3494
3495 parentMenu.addAction(act)
3496
3497 def __createTextEncodingSubmenu(self, title, codecNames, parentMenu):
3498 """
3499 Private method to create a text encoding sub menu.
3500
3501 @param title title of the menu
3502 @type str
3503 @param codecNames list of codec names for the menu
3504 @type list of str
3505 @param parentMenu reference to the parent menu
3506 @type QMenu
3507 """
3508 if codecNames:
3509 defaultCodec = \
3510 QWebSettings.globalSettings().defaultTextEncoding().lower()
3511
3512 menu = QMenu(title, parentMenu)
3513 for codec in codecNames:
3514 self.__createTextEncodingAction(codec, defaultCodec, menu)
3515
3516 parentMenu.addMenu(menu)
3517
3518 def __aboutToShowTextEncodingMenu(self):
3519 """
3520 Private slot to populate the text encoding menu.
3521 """
3522 self.__textEncodingMenu.clear()
3523
3524 codecs = []
3525 for mib in QTextCodec.availableMibs():
3526 codec = str(QTextCodec.codecForMib(mib).name(),
3527 encoding="utf-8").lower()
3528 if codec not in codecs:
3529 codecs.append(codec)
3530 codecs.sort()
3531
3532 defaultTextEncoding = \
3533 QWebSettings.globalSettings().defaultTextEncoding().lower()
3534 if defaultTextEncoding in codecs:
3535 currentCodec = defaultTextEncoding
3536 else:
3537 currentCodec = "system"
3538
3539 isoCodecs = []
3540 winCodecs = []
3541 isciiCodecs = []
3542 uniCodecs = []
3543 ibmCodecs = []
3544 otherCodecs = []
3545
3546 for codec in codecs:
3547 if codec.startswith(("iso", "latin")):
3548 isoCodecs.append(codec)
3549 elif codec.startswith(("windows")):
3550 winCodecs.append(codec)
3551 elif codec.startswith("iscii"):
3552 isciiCodecs.append(codec)
3553 elif codec.startswith("utf"):
3554 uniCodecs.append(codec)
3555 elif codec.startswith(("ibm")):
3556 ibmCodecs.append(codec)
3557 elif codec == "system":
3558 self.__createTextEncodingAction(codec, currentCodec,
3559 self.__textEncodingMenu)
3560 else:
3561 otherCodecs.append(codec)
3562
3563 self.__createTextEncodingSubmenu(self.tr("ISO"), isoCodecs,
3564 self.__textEncodingMenu)
3565 self.__createTextEncodingSubmenu(self.tr("Unicode"), uniCodecs,
3566 self.__textEncodingMenu)
3567 self.__createTextEncodingSubmenu(self.tr("Windows"), winCodecs,
3568 self.__textEncodingMenu)
3569 self.__createTextEncodingSubmenu(self.tr("ISCII"), isciiCodecs,
3570 self.__textEncodingMenu)
3571 self.__createTextEncodingSubmenu(self.tr("IBM"), ibmCodecs,
3572 self.__textEncodingMenu)
3573 self.__createTextEncodingSubmenu(self.tr("Other"), otherCodecs,
3574 self.__textEncodingMenu)
3575
3576 def __setTextEncoding(self, act):
3577 """
3578 Private slot to set the selected text encoding as the default for
3579 this session.
3580
3581 @param act reference to the selected action (QAction)
3582 """
3583 codec = act.data()
3584 if codec == "":
3585 QWebSettings.globalSettings().setDefaultTextEncoding("")
3586 else:
3587 QWebSettings.globalSettings().setDefaultTextEncoding(codec)
3588
3589 def eventMouseButtons(self):
3590 """
3591 Public method to get the last recorded mouse buttons.
3592
3593 @return mouse buttons (Qt.MouseButtons)
3594 """
3595 return self.__eventMouseButtons
3596
3597 def eventKeyboardModifiers(self):
3598 """
3599 Public method to get the last recorded keyboard modifiers.
3600
3601 @return keyboard modifiers (Qt.KeyboardModifiers)
3602 """
3603 return self.__eventKeyboardModifiers
3604
3605 def setEventMouseButtons(self, buttons):
3606 """
3607 Public method to record mouse buttons.
3608
3609 @param buttons mouse buttons to record (Qt.MouseButtons)
3610 """
3611 self.__eventMouseButtons = buttons
3612
3613 def setEventKeyboardModifiers(self, modifiers):
3614 """
3615 Public method to record keyboard modifiers.
3616
3617 @param modifiers keyboard modifiers to record (Qt.KeyboardModifiers)
3618 """
3619 self.__eventKeyboardModifiers = modifiers
3620
3621 def mousePressEvent(self, evt):
3622 """
3623 Protected method called by a mouse press event.
3624
3625 @param evt reference to the mouse event (QMouseEvent)
3626 """
3627 if evt.button() == Qt.XButton1:
3628 self.currentBrowser().pageAction(QWebPage.Back).trigger()
3629 elif evt.button() == Qt.XButton2:
3630 self.currentBrowser().pageAction(QWebPage.Forward).trigger()
3631 else:
3632 super(HelpWindow, self).mousePressEvent(evt)
3633
3634 @classmethod
3635 def feedsManager(cls):
3636 """
3637 Class method to get a reference to the RSS feeds manager.
3638
3639 @return reference to the RSS feeds manager (FeedsManager)
3640 """
3641 if cls._feedsManager is None:
3642 from .Feeds.FeedsManager import FeedsManager
3643 cls._feedsManager = FeedsManager()
3644
3645 return cls._feedsManager
3646
3647 def __showFeedsManager(self):
3648 """
3649 Private slot to show the feeds manager dialog.
3650 """
3651 feedsManager = self.feedsManager()
3652 feedsManager.openUrl.connect(self.openUrl)
3653 feedsManager.newUrl.connect(self.openUrlNewTab)
3654 feedsManager.rejected.connect(
3655 lambda fm: self.__feedsManagerClosed(fm))
3656 feedsManager.show()
3657
3658 def __feedsManagerClosed(self, feedsManager):
3659 """
3660 Private slot to handle closing the feeds manager dialog.
3661
3662 @param feedsManager reference to the feeds manager object
3663 @type FeedsManager
3664 """
3665 feedsManager.openUrl.disconnect(self.openUrl)
3666 feedsManager.newUrl.disconnect(self.openUrlNewTab)
3667 feedsManager.rejected.disconnect()
3668
3669 def __showSiteinfoDialog(self):
3670 """
3671 Private slot to show the site info dialog.
3672 """
3673 from .SiteInfo.SiteInfoDialog import SiteInfoDialog
3674 self.__siteinfoDialog = SiteInfoDialog(self.currentBrowser(), self)
3675 self.__siteinfoDialog.show()
3676
3677 @classmethod
3678 def userAgentsManager(cls):
3679 """
3680 Class method to get a reference to the user agents manager.
3681
3682 @return reference to the user agents manager (UserAgentManager)
3683 """
3684 if cls._userAgentsManager is None:
3685 from .UserAgent.UserAgentManager import UserAgentManager
3686 cls._userAgentsManager = UserAgentManager()
3687
3688 return cls._userAgentsManager
3689
3690 def __showUserAgentsDialog(self):
3691 """
3692 Private slot to show the user agents management dialog.
3693 """
3694 from .UserAgent.UserAgentsDialog import UserAgentsDialog
3695
3696 dlg = UserAgentsDialog(self)
3697 dlg.exec_()
3698
3699 @classmethod
3700 def syncManager(cls):
3701 """
3702 Class method to get a reference to the data synchronization manager.
3703
3704 @return reference to the data synchronization manager (SyncManager)
3705 """
3706 if cls._syncManager is None:
3707 from .Sync.SyncManager import SyncManager
3708 cls._syncManager = SyncManager()
3709
3710 return cls._syncManager
3711
3712 def __showSyncDialog(self):
3713 """
3714 Private slot to show the synchronization dialog.
3715 """
3716 self.syncManager().showSyncDialog()
3717
3718 @classmethod
3719 def speedDial(cls):
3720 """
3721 Class methdo to get a reference to the speed dial.
3722
3723 @return reference to the speed dial (SpeedDial)
3724 """
3725 if cls._speedDial is None:
3726 from .SpeedDial.SpeedDial import SpeedDial
3727 cls._speedDial = SpeedDial()
3728
3729 return cls._speedDial
3730
3731 def keyPressEvent(self, evt):
3732 """
3733 Protected method to handle key presses.
3734
3735 @param evt reference to the key press event (QKeyEvent)
3736 """
3737 number = -1
3738 key = evt.key()
3739
3740 if key == Qt.Key_1:
3741 number = 1
3742 elif key == Qt.Key_2:
3743 number = 2
3744 elif key == Qt.Key_3:
3745 number = 3
3746 elif key == Qt.Key_4:
3747 number = 4
3748 elif key == Qt.Key_5:
3749 number = 5
3750 elif key == Qt.Key_6:
3751 number = 6
3752 elif key == Qt.Key_7:
3753 number = 7
3754 elif key == Qt.Key_8:
3755 number = 8
3756 elif key == Qt.Key_9:
3757 number = 9
3758 elif key == Qt.Key_0:
3759 number = 10
3760
3761 if number != -1:
3762 if evt.modifiers() == Qt.KeyboardModifiers(Qt.AltModifier):
3763 if number == 10:
3764 number = self.tabWidget.count()
3765 self.tabWidget.setCurrentIndex(number - 1)
3766 return
3767
3768 if evt.modifiers() == Qt.KeyboardModifiers(Qt.MetaModifier):
3769 url = self.speedDial().urlForShortcut(number - 1)
3770 if url.isValid():
3771 self.__linkActivated(url)
3772 return
3773
3774 super(HelpWindow, self).keyPressEvent(evt)
3775
3776 ###########################################################################
3777 ## Interface to VirusTotal below ##
3778 ###########################################################################
3779
3780 def __virusTotalScanCurrentSite(self):
3781 """
3782 Private slot to ask VirusTotal for a scan of the URL of the current
3783 browser.
3784 """
3785 cb = self.currentBrowser()
3786 if cb is not None:
3787 url = cb.url()
3788 if url.scheme() in ["http", "https", "ftp"]:
3789 self.requestVirusTotalScan(url)
3790
3791 def requestVirusTotalScan(self, url):
3792 """
3793 Public method to submit a request to scan an URL by VirusTotal.
3794
3795 @param url URL to be scanned (QUrl)
3796 """
3797 self.__virusTotal.submitUrl(url)
3798
3799 def __virusTotalSubmitUrlError(self, msg):
3800 """
3801 Private slot to handle an URL scan submission error.
3802
3803 @param msg error message (str)
3804 """
3805 E5MessageBox.critical(
3806 self,
3807 self.tr("VirusTotal Scan"),
3808 self.tr("""<p>The VirusTotal scan could not be"""
3809 """ scheduled.<p>\n<p>Reason: {0}</p>""").format(msg))
3810
3811 def __virusTotalUrlScanReport(self, url):
3812 """
3813 Private slot to initiate the display of the URL scan report page.
3814
3815 @param url URL of the URL scan report page (string)
3816 """
3817 self.newTab(url)
3818
3819 def __virusTotalFileScanReport(self, url):
3820 """
3821 Private slot to initiate the display of the file scan report page.
3822
3823 @param url URL of the file scan report page (string)
3824 """
3825 self.newTab(url)
3826
3827 def __virusTotalIpAddressReport(self):
3828 """
3829 Private slot to retrieve an IP address report.
3830 """
3831 ip, ok = QInputDialog.getText(
3832 self,
3833 self.tr("IP Address Report"),
3834 self.tr("Enter a valid IPv4 address in dotted quad notation:"),
3835 QLineEdit.Normal)
3836 if ok and ip:
3837 if ip.count(".") == 3:
3838 self.__virusTotal.getIpAddressReport(ip)
3839 else:
3840 E5MessageBox.information(
3841 self,
3842 self.tr("IP Address Report"),
3843 self.tr("""The given IP address is not in dotted quad"""
3844 """ notation."""))
3845
3846 def __virusTotalDomainReport(self):
3847 """
3848 Private slot to retrieve a domain report.
3849 """
3850 domain, ok = QInputDialog.getText(
3851 self,
3852 self.tr("Domain Report"),
3853 self.tr("Enter a valid domain name:"),
3854 QLineEdit.Normal)
3855 if ok and domain:
3856 self.__virusTotal.getDomainReport(domain)
3857
3858 ###########################################################################
3859 ## Style sheet handling below ##
3860 ###########################################################################
3861
3862 def reloadUserStyleSheet(self):
3863 """
3864 Public method to reload the user style sheet.
3865 """
3866 settings = QWebSettings.globalSettings()
3867 styleSheet = Preferences.getHelp("UserStyleSheet")
3868 settings.setUserStyleSheetUrl(self.__userStyleSheet(styleSheet))
3869
3870 def __userStyleSheet(self, styleSheetFile):
3871 """
3872 Private method to generate the user style sheet.
3873
3874 @param styleSheetFile name of the user style sheet file (string)
3875 @return style sheet (QUrl)
3876 """
3877 userStyle = self.adBlockManager().elementHidingRules() + \
3878 "{display:none !important;}"
3879
3880 if styleSheetFile:
3881 try:
3882 f = open(styleSheetFile, "r")
3883 fileData = f.read()
3884 f.close()
3885 fileData = fileData.replace("\n", "")
3886 userStyle += fileData
3887 except IOError:
3888 pass
3889
3890 encodedStyle = bytes(QByteArray(userStyle.encode("utf-8")).toBase64())\
3891 .decode()
3892 dataString = "data:text/css;charset=utf-8;base64,{0}".format(
3893 encodedStyle)
3894
3895 return QUrl(dataString)
3896
3897 ##########################################
3898 ## Support for desktop notifications below
3899 ##########################################
3900
3901 @classmethod
3902 def showNotification(cls, icon, heading, text):
3903 """
3904 Class method to show a desktop notification.
3905
3906 @param icon icon to be shown in the notification (QPixmap)
3907 @param heading heading of the notification (string)
3908 @param text text of the notification (string)
3909 """
3910 if Preferences.getUI("NotificationsEnabled"):
3911 if cls._notification is None:
3912 from UI.NotificationWidget import NotificationWidget
3913 cls._notification = NotificationWidget()
3914 cls._notification.setPixmap(icon)
3915 cls._notification.setHeading(heading)
3916 cls._notification.setText(text)
3917 cls._notification.setTimeout(
3918 Preferences.getUI("NotificationTimeout"))
3919 cls._notification.move(
3920 Preferences.getUI("NotificationPosition"))
3921 cls._notification.show()
3922
3923 @classmethod
3924 def notificationsEnabled(cls):
3925 """
3926 Class method to check, if notifications are enabled.
3927
3928 @return flag indicating, if notifications are enabled (boolean)
3929 """
3930 return Preferences.getUI("NotificationsEnabled")
3931
3932 ###############################################################
3933 ## Methods below implement single application related functions
3934 ###############################################################
3935
3936 @pyqtSlot(str)
3937 def __saLoadUrl(self, urlStr):
3938 """
3939 Private slot to load an URL received via the single application
3940 protocol.
3941
3942 @param urlStr URL to be loaded
3943 @type str
3944 """
3945 url = QUrl.fromUserInput(urlStr)
3946 self.__linkActivated(url)
3947
3948 @pyqtSlot(str)
3949 def __saNewTab(self, urlStr):
3950 """
3951 Private slot to load an URL received via the single application
3952 protocol in a new tab.
3953
3954 @param urlStr URL to be loaded
3955 @type str
3956 """
3957 url = QUrl.fromUserInput(urlStr)
3958 self.newTab(url)
3959
3960 @pyqtSlot(str)
3961 def __saSearchWord(self, word):
3962 """
3963 Private slot to search for the given word.
3964
3965 @param word word to be searched for
3966 @type str
3967 """
3968 if HelpWindow._useQtHelp:
3969 self.__searchWord = word
3970 self.__searchForWord()
3971
3972 ######################################################
3973 ## Methods below implement shortcuts related functions
3974 ######################################################
3975
3976 def __configShortcuts(self):
3977 """
3978 Private slot to configure the keyboard shortcuts.
3979 """
3980 if self.__shortcutsDialog is None:
3981 from Preferences.ShortcutsDialog import ShortcutsDialog
3982 self.__shortcutsDialog = ShortcutsDialog(self)
3983 self.__shortcutsDialog.populate(helpViewer=self)
3984 self.__shortcutsDialog.show()
3985
3986 def __exportShortcuts(self):
3987 """
3988 Private slot to export the keyboard shortcuts.
3989 """
3990 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
3991 None,
3992 self.tr("Export Keyboard Shortcuts"),
3993 "",
3994 self.tr("Keyboard shortcut file (*.e4k)"),
3995 "",
3996 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
3997
3998 if not fn:
3999 return
4000
4001 ext = QFileInfo(fn).suffix()
4002 if not ext:
4003 ex = selectedFilter.split("(*")[1].split(")")[0]
4004 if ex:
4005 fn += ex
4006
4007 from Preferences import Shortcuts
4008 Shortcuts.exportShortcuts(fn, helpViewer=self)
4009
4010 def __importShortcuts(self):
4011 """
4012 Private slot to import the keyboard shortcuts.
4013 """
4014 fn = E5FileDialog.getOpenFileName(
4015 None,
4016 self.tr("Import Keyboard Shortcuts"),
4017 "",
4018 self.tr("Keyboard shortcut file (*.e4k)"))
4019
4020 if fn:
4021 from Preferences import Shortcuts
4022 Shortcuts.importShortcuts(fn, helpViewer=self)

eric ide

mercurial