WebBrowser/WebBrowserView.py

Tue, 13 Feb 2018 19:54:17 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 13 Feb 2018 19:54:17 +0100
changeset 6147
0ea1f1e72463
parent 6142
304a469455c8
child 6155
ae44225e7e7c
permissions
-rw-r--r--

WebBrowserView: Added a custom title() method.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6048
82ad8ec9548c Updated copyright for 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5921
diff changeset
3 # Copyright (c) 2008 - 2018 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
8 Module implementing the web browser using QWebEngineView.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3080
diff changeset
11 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2432
diff changeset
12 try:
5624
cdd346d8858b Removed a bunch of __IGNORE_WARNING_M131__ markers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
13 str = unicode # __IGNORE_EXCEPTION__
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3178 3190
diff changeset
14 except NameError:
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2432
diff changeset
15 pass
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2432
diff changeset
16
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
17 import os
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
18
6142
304a469455c8 Added support for printing from within a web page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6141
diff changeset
19 from PyQt5.QtCore import pyqtSignal, pyqtSlot, PYQT_VERSION, Qt, QUrl, \
304a469455c8 Added support for printing from within a web page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6141
diff changeset
20 QFileInfo, QTimer, QEvent, QPoint, QPointF, QDateTime, QStandardPaths, \
304a469455c8 Added support for printing from within a web page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6141
diff changeset
21 QByteArray, QIODevice, QDataStream
4913
e16573640cb8 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4910
diff changeset
22 from PyQt5.QtGui import QDesktopServices, QClipboard, QIcon, \
e16573640cb8 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4910
diff changeset
23 QContextMenuEvent, QPixmap
e16573640cb8 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4910
diff changeset
24 from PyQt5.QtWidgets import qApp, QStyle, QMenu, QApplication
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
25 from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, \
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
26 QWebEngineDownloadItem
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
28 from E5Gui import E5MessageBox, E5FileDialog
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
29
4958
ef400197e7d5 Implemented the auto scroller for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4956
diff changeset
30 from WebBrowser.WebBrowserWindow import WebBrowserWindow
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
31 from .WebBrowserPage import WebBrowserPage
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4353
diff changeset
32
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
33 from .Tools.WebIconLoader import WebIconLoader
4913
e16573640cb8 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4910
diff changeset
34 from .Tools import Scripts
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
35
4781
15d416f1eca5 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4780
diff changeset
36 from . import WebInspector
4903
10910764454a Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4900
diff changeset
37 from .Tools.WebBrowserTools import readAllFileContents, pixmapToDataUrl
4781
15d416f1eca5 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4780
diff changeset
38
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 import Preferences
978
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 952
diff changeset
40 import UI.PixmapCache
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
41 import Utilities
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5721
diff changeset
42 from Globals import qVersionTuple
1960
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
43
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
44
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
45 class WebBrowserView(QWebEngineView):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
47 Class implementing the web browser view widget.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
501
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 487
diff changeset
49 @signal sourceChanged(QUrl) emitted after the current URL has changed
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 @signal forwardAvailable(bool) emitted after the current URL has changed
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 @signal backwardAvailable(bool) emitted after the current URL has changed
501
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 487
diff changeset
52 @signal highlighted(str) emitted, when the mouse hovers over a link
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 487
diff changeset
53 @signal search(QUrl) emitted, when a search is requested
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
54 @signal zoomValueChanged(int) emitted to signal a change of the zoom value
5039
200f12184a43 Renamed the iconChanged signal of WebBrowserView to faviconChanged in order to get rid of a name clash with Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5038
diff changeset
55 @signal faviconChanged() emitted to signal a changed web site icon
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
56 @signal safeBrowsingAbort() emitted to indicate an abort due to a safe
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
57 browsing event
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
58 @signal safeBrowsingBad(threatType, threatMessages) emitted to indicate a
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
59 malicious web site as determined by safe browsing
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
61 sourceChanged = pyqtSignal(QUrl)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
62 forwardAvailable = pyqtSignal(bool)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
63 backwardAvailable = pyqtSignal(bool)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
64 highlighted = pyqtSignal(str)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
65 search = pyqtSignal(QUrl)
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
66 zoomValueChanged = pyqtSignal(int)
5039
200f12184a43 Renamed the iconChanged signal of WebBrowserView to faviconChanged in order to get rid of a name clash with Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5038
diff changeset
67 faviconChanged = pyqtSignal()
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
68 safeBrowsingAbort = pyqtSignal()
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
69 safeBrowsingBad = pyqtSignal(str, str)
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
70
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
71 ZoomLevels = [
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
72 30, 40, 50, 67, 80, 90,
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
73 100,
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
74 110, 120, 133, 150, 170, 200, 220, 233, 250, 270, 285, 300,
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
75 ]
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
76 ZoomLevelDefault = 100
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
77
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
78 def __init__(self, mainWindow, parent=None, name=""):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
82 @param mainWindow reference to the main window (WebBrowserWindow)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @param parent parent widget of this window (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @param name name of this window (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
86 super(WebBrowserView, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.setObjectName(name)
4717
5841f229baf7 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4715
diff changeset
88
5841f229baf7 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4715
diff changeset
89 self.__rwhvqt = None
5841f229baf7 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4715
diff changeset
90 self.installEventFilter(self)
4731
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
91
4868
985d275502c8 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4865
diff changeset
92 self.__speedDial = WebBrowserWindow.speedDial()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
94 self.__page = None
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
95 self.__createNewPage()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
97 self.__mw = mainWindow
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.__isLoading = False
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 629
diff changeset
99 self.__progress = 0
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
100 self.__siteIconLoader = None
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
101 self.__siteIcon = QIcon()
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
102 self.__menu = QMenu(self)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
103 self.__clickedPos = QPoint()
4781
15d416f1eca5 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4780
diff changeset
104 self.__firstLoad = False
4900
32f940762654 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
105 self.__preview = QPixmap()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.__currentZoom = 100
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
108 self.__zoomLevels = WebBrowserView.ZoomLevels[:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
110 self.iconUrlChanged.connect(self.__iconUrlChanged)
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
111 self.urlChanged.connect(self.__urlChanged)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
112 self.page().linkHovered.connect(self.__linkHovered)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
114 self.loadStarted.connect(self.__loadStarted)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
115 self.loadProgress.connect(self.__loadProgress)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
116 self.loadFinished.connect(self.__loadFinished)
4903
10910764454a Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4900
diff changeset
117 self.renderProcessTerminated.connect(self.__renderProcessTerminated)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
119 self.__mw.openSearchManager().currentEngineChanged.connect(
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
120 self.__currentEngineChanged)
952
cc3e2e5558e9 Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
121
cc3e2e5558e9 Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
122 self.setAcceptDrops(True)
cc3e2e5558e9 Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
123
1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1232
diff changeset
124 self.__rss = []
1518
e6e21910210d Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
125
1586
b3e34806b734 Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1584
diff changeset
126 self.__clickedFrame = None
b3e34806b734 Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1584
diff changeset
127
4752
a3bcc42a82a9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
128 self.__mw.personalInformationManager().connectPage(self.page())
4717
5841f229baf7 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4715
diff changeset
129
4781
15d416f1eca5 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4780
diff changeset
130 self.__inspector = None
15d416f1eca5 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4780
diff changeset
131 WebInspector.registerView(self)
4341
1ff0929aab09 Added our own web inspector window to overcome a Qt weekness.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4326
diff changeset
132
5784
362bbcc49ac1 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5740
diff changeset
133 self.__restoreData = None
362bbcc49ac1 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5740
diff changeset
134
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5721
diff changeset
135 if qVersionTuple() >= (5, 8, 0):
5719
73bbb3a8ee41 Fixed exiting the full screen mode using ESC key in the web browser NG.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5707
diff changeset
136 if self.parentWidget() is not None:
73bbb3a8ee41 Fixed exiting the full screen mode using ESC key in the web browser NG.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5707
diff changeset
137 self.parentWidget().installEventFilter(self)
73bbb3a8ee41 Fixed exiting the full screen mode using ESC key in the web browser NG.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5707
diff changeset
138
5630
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
139 lay = self.layout()
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
140 lay.currentChanged.connect(
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
141 lambda: QTimer.singleShot(0, self.__setRwhvqt))
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
142 self.__setRwhvqt()
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
143
1518
e6e21910210d Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
144 self.grabGesture(Qt.PinchGesture)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
146 def __createNewPage(self):
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
147 """
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
148 Private method to create a new page object.
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
149 """
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
150 self.__page = WebBrowserPage(self)
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
151 self.setPage(self.__page)
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
152
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
153 self.__page.safeBrowsingAbort.connect(self.safeBrowsingAbort)
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
154 self.__page.safeBrowsingBad.connect(self.safeBrowsingBad)
6142
304a469455c8 Added support for printing from within a web page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6141
diff changeset
155 self.__page.printRequested.connect(self.__printPage)
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
156
5630
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
157 def __setRwhvqt(self):
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
158 """
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
159 Private slot to set widget that receives input events.
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
160 """
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
161 self.grabGesture(Qt.PinchGesture)
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
162 self.__rwhvqt = self.focusProxy()
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
163 if self.__rwhvqt:
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
164 self.__rwhvqt.grabGesture(Qt.PinchGesture)
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
165 self.__rwhvqt.installEventFilter(self)
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
166 else:
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
167 print("Focus proxy is null!") # __IGNORE_WARNING_M801__
11670490db05 Implemented the detection of the widget receiving input event for the new web browser for Qt >= 5.8.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5626
diff changeset
168
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
169 def __currentEngineChanged(self):
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
170 """
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
171 Private slot to track a change of the current search engine.
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
172 """
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
173 if self.url().toString() == "eric:home":
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
174 self.reload()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
176 def mainWindow(self):
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
177 """
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
178 Public method to get a reference to the main window.
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
179
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
180 @return reference to the main window
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
181 @rtype WebBrowserWindow
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
182 """
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
183 return self.__mw
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
184
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
185 def load(self, url):
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
186 """
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
187 Public method to load a web site.
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
188
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
189 @param url URL to be loaded
4913
e16573640cb8 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4910
diff changeset
190 @type QUrl
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
191 """
6141
f4cecd941096 WebBrowserView: Call acceptNavigationRequest() first in the load method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6126
diff changeset
192 if self.__page is not None and \
f4cecd941096 WebBrowserView: Call acceptNavigationRequest() first in the load method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6126
diff changeset
193 not self.__page.acceptNavigationRequest(
f4cecd941096 WebBrowserView: Call acceptNavigationRequest() first in the load method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6126
diff changeset
194 url, QWebEnginePage.NavigationTypeTyped, True):
f4cecd941096 WebBrowserView: Call acceptNavigationRequest() first in the load method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6126
diff changeset
195 return
f4cecd941096 WebBrowserView: Call acceptNavigationRequest() first in the load method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6126
diff changeset
196
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
197 super(WebBrowserView, self).load(url)
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
198
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
199 if not self.__firstLoad:
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
200 self.__firstLoad = True
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
201 WebInspector.pushView(self)
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
202
4908
f1859c36d564 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4906
diff changeset
203 def setSource(self, name, newTab=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 Public method used to set the source to be displayed.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 @param name filename to be shown (QUrl)
4908
f1859c36d564 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4906
diff changeset
208 @param newTab flag indicating to open the URL in a new tab (bool)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
210 if name is None or not name.isValid():
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212
4908
f1859c36d564 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4906
diff changeset
213 if newTab:
f1859c36d564 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4906
diff changeset
214 # open in a new tab
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
215 self.__mw.newTab(name)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217
5195
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
218 if not name.scheme():
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
219 if not os.path.exists(name.toString()):
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
220 name.setScheme(Preferences.getWebBrowser("DefaultScheme"))
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
221 else:
5195
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
222 if Utilities.isWindowsPlatform():
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
223 name.setUrl("file:///" + Utilities.fromNativeSeparators(
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
224 name.toString()))
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
225 else:
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
226 name.setUrl("file://" + name.toString())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 if len(name.scheme()) == 1 or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 name.scheme() == "file":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 # name is a local file
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 if name.scheme() and len(name.scheme()) == 1:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 # it is a local path on win os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 name = QUrl.fromLocalFile(name.toString())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 if not QFileInfo(name.toLocalFile()).exists():
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
236 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
237 self,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
238 self.tr("eric6 Web Browser"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
239 self.tr(
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
240 """<p>The file <b>{0}</b> does not exist.</p>""")
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
241 .format(name.toLocalFile()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
244 if name.toLocalFile().lower().endswith((".pdf", ".chm")):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 started = QDesktopServices.openUrl(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 if not started:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
247 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
248 self,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
249 self.tr("eric6 Web Browser"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
250 self.tr(
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
251 """<p>Could not start a viewer"""
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
252 """ for file <b>{0}</b>.</p>""")
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
253 .format(name.path()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 return
278
c93823b96faa Added a handler for ftp: URLs to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 260
diff changeset
255 elif name.scheme() in ["mailto"]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 started = QDesktopServices.openUrl(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 if not started:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
258 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
259 self,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
260 self.tr("eric6 Web Browser"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
261 self.tr(
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
262 """<p>Could not start an application"""
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
263 """ for URL <b>{0}</b>.</p>""")
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
264 .format(name.toString()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 else:
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
267 if name.toString().lower().endswith((".pdf", ".chm")):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 started = QDesktopServices.openUrl(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 if not started:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
270 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
271 self,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
272 self.tr("eric6 Web Browser"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
273 self.tr(
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
274 """<p>Could not start a viewer"""
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
275 """ for file <b>{0}</b>.</p>""")
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
276 .format(name.path()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278
4908
f1859c36d564 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4906
diff changeset
279 self.load(name)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 def source(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 Public method to return the URL of the loaded page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 @return URL loaded in the help browser (QUrl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 return self.url()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 def documentTitle(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 Public method to return the title of the loaded page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 @return title (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 return self.title()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 def backward(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 Public slot to move backwards in history.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
301 self.triggerPageAction(QWebEnginePage.Back)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 self.__urlChanged(self.history().currentItem().url())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 def forward(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 Public slot to move forward in history.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
308 self.triggerPageAction(QWebEnginePage.Forward)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 self.__urlChanged(self.history().currentItem().url())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 def home(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 Public slot to move to the first page loaded.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
315 homeUrl = QUrl(Preferences.getWebBrowser("HomePage"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 self.setSource(homeUrl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 self.__urlChanged(self.history().currentItem().url())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 def reload(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 Public slot to reload the current page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
323 self.triggerPageAction(QWebEnginePage.Reload)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324
4791
a1e53a9ffcf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
325 def reloadBypassingCache(self):
a1e53a9ffcf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
326 """
a1e53a9ffcf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
327 Public slot to reload the current page bypassing the cache.
a1e53a9ffcf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
328 """
a1e53a9ffcf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
329 self.triggerPageAction(QWebEnginePage.ReloadAndBypassCache)
a1e53a9ffcf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
330
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 def copy(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 Public slot to copy the selected text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
335 self.triggerPageAction(QWebEnginePage.Copy)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336
4727
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
337 def cut(self):
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
338 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
339 Public slot to cut the selected text.
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
340 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
341 self.triggerPageAction(QWebEnginePage.Cut)
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
342
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
343 def paste(self):
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
344 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
345 Public slot to paste text from the clipboard.
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
346 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
347 self.triggerPageAction(QWebEnginePage.Paste)
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
348
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
349 def undo(self):
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
350 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
351 Public slot to undo the last edit action.
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
352 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
353 self.triggerPageAction(QWebEnginePage.Undo)
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
354
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
355 def redo(self):
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
356 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
357 Public slot to redo the last edit action.
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
358 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
359 self.triggerPageAction(QWebEnginePage.Redo)
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
360
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
361 def selectAll(self):
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
362 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
363 Public slot to select all text.
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
364 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
365 self.triggerPageAction(QWebEnginePage.SelectAll)
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
366
5038
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
367 def unselect(self):
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
368 """
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
369 Public slot to clear the current selection.
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
370 """
5921
d4797da58218 Some more fixes for the web browser NG.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
371 try:
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
372 self.triggerPageAction(QWebEnginePage.Unselect)
5921
d4797da58218 Some more fixes for the web browser NG.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
373 except AttributeError:
d4797da58218 Some more fixes for the web browser NG.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
374 # prior to 5.7.0
5194
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
375 self.page().runJavaScript(
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
376 "window.getSelection().empty()",
4750c83cc718 Added an 'unselect' alternative for Qt < 5.7.0 to the new web browser and added possibility to save the current page in various formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
377 WebBrowserPage.SafeJsWorld)
5038
df7103c3f2a6 Added capabilities to open links in a new background tab, and several other link open actions to various context menus of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5033
diff changeset
378
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 def isForwardAvailable(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 Public method to determine, if a forward move in history is possible.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 @return flag indicating move forward is possible (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 return self.history().canGoForward()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 def isBackwardAvailable(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 Public method to determine, if a backwards move in history is possible.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 @return flag indicating move backwards is possible (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 return self.history().canGoBack()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 def __levelForZoom(self, zoom):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 Private method determining the zoom level index given a zoom factor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 @param zoom zoom factor (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 @return index of zoom factor (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 index = self.__zoomLevels.index(zoom)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 except ValueError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 for index in range(len(self.__zoomLevels)):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 if zoom <= self.__zoomLevels[index]:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 return index
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409
4612
c9982bcd00f8 Added capability to remember the zoom values for each site (incl. a dialog to manage these).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4357
diff changeset
410 def setZoomValue(self, value, saveValue=True):
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
411 """
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
412 Public method to set the zoom value.
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
413
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
414 @param value zoom value (integer)
4612
c9982bcd00f8 Added capability to remember the zoom values for each site (incl. a dialog to manage these).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4357
diff changeset
415 @keyparam saveValue flag indicating to save the zoom value with the
c9982bcd00f8 Added capability to remember the zoom values for each site (incl. a dialog to manage these).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4357
diff changeset
416 zoom manager
c9982bcd00f8 Added capability to remember the zoom values for each site (incl. a dialog to manage these).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4357
diff changeset
417 @type bool
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
418 """
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
419 if value != self.__currentZoom:
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
420 self.setZoomFactor(value / 100.0)
4612
c9982bcd00f8 Added capability to remember the zoom values for each site (incl. a dialog to manage these).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4357
diff changeset
421 self.__currentZoom = value
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
422 if saveValue and not self.__mw.isPrivate():
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
423 from .ZoomManager import ZoomManager
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
424 ZoomManager.instance().setZoomValue(self.url(), value)
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
425 self.zoomValueChanged.emit(value)
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
426
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
427 def zoomValue(self):
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
428 """
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
429 Public method to get the current zoom value.
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
430
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
431 @return zoom value (integer)
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
432 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
433 val = self.zoomFactor() * 100
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
434 return int(val)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 def zoomIn(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 Public slot to zoom into the page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 index = self.__levelForZoom(self.__currentZoom)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 if index < len(self.__zoomLevels) - 1:
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
442 self.setZoomValue(self.__zoomLevels[index + 1])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 def zoomOut(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 Public slot to zoom out of the page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 index = self.__levelForZoom(self.__currentZoom)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 if index > 0:
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
450 self.setZoomValue(self.__zoomLevels[index - 1])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
452 def zoomReset(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 Public method to reset the zoom factor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
456 index = self.__levelForZoom(WebBrowserView.ZoomLevelDefault)
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
457 self.setZoomValue(self.__zoomLevels[index])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458
4925
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
459 def mapToViewport(self, pos):
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
460 """
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
461 Public method to map a position to the viewport.
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
462
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
463 @param pos position to be mapped
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
464 @type QPoint
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
465 @return viewport position
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
466 @rtype QPoint
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
467 """
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
468 return self.page().mapToViewport(pos)
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
469
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 def hasSelection(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 Public method to determine, if there is some text selected.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 @return flag indicating text has been selected (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 return self.selectedText() != ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477
4881
c269212cceac Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4880
diff changeset
478 def findNextPrev(self, txt, case, backwards, callback):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 Public slot to find the next occurrence of a text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 @param txt text to search for (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 @param case flag indicating a case sensitive search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 @param backwards flag indicating a backwards search (boolean)
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
485 @param callback reference to a function with a bool parameter
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
486 @type function(bool) or None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 """
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
488 findFlags = QWebEnginePage.FindFlags()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 if case:
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
490 findFlags |= QWebEnginePage.FindCaseSensitively
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 if backwards:
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
492 findFlags |= QWebEnginePage.FindBackward
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
494 if callback is None:
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
495 self.findText(txt, findFlags)
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
496 else:
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
497 self.findText(txt, findFlags, callback)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 def contextMenuEvent(self, evt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 """
4917
682750cc7bd5 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4913
diff changeset
501 Protected method called to create a context menu.
4728
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
502
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
503 This method is overridden from QWebEngineView.
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
504
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
505 @param evt reference to the context menu event object
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
506 (QContextMenuEvent)
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
507 """
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
508 pos = evt.pos()
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
509 reason = evt.reason()
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
510 QTimer.singleShot(
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
511 0,
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
512 lambda: self._contextMenuEvent(QContextMenuEvent(reason, pos)))
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
513 # needs to be done this way because contextMenuEvent is blocking
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
514 # the main loop
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
515
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
516 def _contextMenuEvent(self, evt):
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
517 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518 Protected method called to create a context menu.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
520 This method is overridden from QWebEngineView.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
522 @param evt reference to the context menu event object
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
523 (QContextMenuEvent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 """
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
525 self.__menu.clear()
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
526
4728
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
527 hitTest = self.page().hitTestContent(evt.pos())
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
528
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
529 self.__createContextMenu(self.__menu, hitTest)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
530
4880
561f2bd9cfb9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4868
diff changeset
531 if not hitTest.isContentEditable() and not hitTest.isContentSelected():
4885
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
532 self.__menu.addSeparator()
4880
561f2bd9cfb9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4868
diff changeset
533 self.__menu.addAction(self.__mw.adBlockIcon().menuAction())
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
534
4782
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
535 if Preferences.getWebBrowser("WebInspectorEnabled"):
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
536 self.__menu.addSeparator()
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
537 self.__menu.addAction(
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
538 UI.PixmapCache.getIcon("webInspector.png"),
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
539 self.tr("Inspect Element..."), self.__webInspector)
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
540
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
541 if not self.__menu.isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
542 pos = evt.globalPos()
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
543 self.__menu.popup(QPoint(pos.x(), pos.y() + 1))
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
544
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
545 def __createContextMenu(self, menu, hitTest):
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
546 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
547 Private method to populate the context menu.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
549 @param menu reference to the menu to be populated
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
550 @type QMenu
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
551 @param hitTest reference to the hit test object
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
552 @type WebHitTestResult
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
553 """
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
554 spellCheckActionCount = 0
5921
d4797da58218 Some more fixes for the web browser NG.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
555 if qVersionTuple() >= (5, 7, 0) and PYQT_VERSION >= 0x50700:
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
556 contextMenuData = self.page().contextMenuData()
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
557 hitTest.updateWithContextMenuData(contextMenuData)
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
558
5920
e47dd106c3d6 Fixed a few issues in the QWebEngine based web browser detected on Ubuntu 17.10.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5867
diff changeset
559 if qVersionTuple() >= (5, 8, 0) and PYQT_VERSION >= 0x50800 and \
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
560 bool(contextMenuData.misspelledWord()):
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
561 boldFont = menu.font()
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
562 boldFont.setBold(True)
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
563
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
564 for suggestion in contextMenuData.spellCheckerSuggestions():
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
565 act = menu.addAction(suggestion)
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
566 act.setFont(boldFont)
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
567 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
568 lambda: self.__replaceMisspelledWord)(act)
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
569
5867
099008539886 Fixed an issue causing an unwanted entry in the context menu of the web browser NG.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5829
diff changeset
570 if not bool(menu.actions()):
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
571 menu.addAction(self.tr("No suggestions")).setEnabled(False)
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
572
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
573 menu.addSeparator()
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
574 spellCheckActionCount = len(menu.actions())
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
575
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
576 if not hitTest.linkUrl().isEmpty() and \
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
577 hitTest.linkUrl().scheme() != "javascript":
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
578 self.__createLinkContextMenu(menu, hitTest)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
579
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
580 if not hitTest.imageUrl().isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
581 self.__createImageContextMenu(menu, hitTest)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
582
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
583 if not hitTest.mediaUrl().isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
584 self.__createMediaContextMenu(menu, hitTest)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
585
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
586 if hitTest.isContentEditable():
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
587 # check, if only spell checker actions were added
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
588 if len(menu.actions()) == spellCheckActionCount:
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
589 menu.addAction(self.__mw.undoAct)
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
590 menu.addAction(self.__mw.redoAct)
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
591 menu.addSeparator()
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
592 menu.addAction(self.__mw.cutAct)
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
593 menu.addAction(self.__mw.copyAct)
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
594 menu.addAction(self.__mw.pasteAct)
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
595 menu.addSeparator()
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
596 self.__mw.personalInformationManager().createSubMenu(
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
597 menu, self, hitTest)
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
598
4731
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
599 if hitTest.tagName() == "input":
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
600 menu.addSeparator()
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
601 act = menu.addAction("")
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
602 act.setVisible(False)
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
603 self.__checkForForm(act, hitTest.pos())
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
604
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
605 if self.selectedText():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
606 self.__createSelectedTextContextMenu(menu, hitTest)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
607
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
608 if self.__menu.isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
609 self.__createPageContextMenu(menu)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
610
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
611 def __createLinkContextMenu(self, menu, hitTest):
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
612 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
613 Private method to populate the context menu for URLs.
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
614
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
615 @param menu reference to the menu to be populated
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
616 @type QMenu
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
617 @param hitTest reference to the hit test object
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
618 @type WebHitTestResult
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
619 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
620 if not menu.isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
621 menu.addSeparator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
623 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
624 UI.PixmapCache.getIcon("openNewTab.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
625 self.tr("Open Link in New Tab\tCtrl+LMB"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
626 act.setData(hitTest.linkUrl())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
627 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
628 lambda: self.__openLinkInNewTab(act))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
629 act = menu.addAction(
4790
deeea3d64858 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4783
diff changeset
630 UI.PixmapCache.getIcon("newWindow.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
631 self.tr("Open Link in New Window"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
632 act.setData(hitTest.linkUrl())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
633 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
634 lambda: self.__openLinkInNewWindow(act))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
635 act = menu.addAction(
4790
deeea3d64858 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4783
diff changeset
636 UI.PixmapCache.getIcon("privateMode.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
637 self.tr("Open Link in New Private Window"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
638 act.setData(hitTest.linkUrl())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
639 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
640 lambda: self.__openLinkInNewPrivateWindow(act))
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
641 menu.addSeparator()
4885
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
642 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
643 UI.PixmapCache.getIcon("download.png"),
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
644 self.tr("Save Lin&k"), self.__downloadLink)
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
645 act = menu.addAction(
4732
5ac4fc1dfc20 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4731
diff changeset
646 UI.PixmapCache.getIcon("bookmark22.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
647 self.tr("Bookmark this Link"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
648 act.setData(hitTest.linkUrl())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
649 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
650 lambda: self.__bookmarkLink(act))
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
651 menu.addSeparator()
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
652 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
653 UI.PixmapCache.getIcon("editCopy.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
654 self.tr("Copy Link to Clipboard"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
655 act.setData(hitTest.linkUrl())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
656 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
657 lambda: self.__copyLink(act))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
658 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
659 UI.PixmapCache.getIcon("mailSend.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
660 self.tr("Send Link"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
661 act.setData(hitTest.linkUrl())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
662 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
663 lambda: self.__sendLink(act))
4753
8d2ea02ed785 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4752
diff changeset
664 if Preferences.getWebBrowser("VirusTotalEnabled") and \
8d2ea02ed785 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4752
diff changeset
665 Preferences.getWebBrowser("VirusTotalServiceKey") != "":
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
666 act = menu.addAction(
4753
8d2ea02ed785 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4752
diff changeset
667 UI.PixmapCache.getIcon("virustotal.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
668 self.tr("Scan Link with VirusTotal"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
669 act.setData(hitTest.linkUrl())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
670 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
671 lambda: self.__virusTotal(act))
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
672
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
673 def __createImageContextMenu(self, menu, hitTest):
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
674 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
675 Private method to populate the context menu for images.
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
676
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
677 @param menu reference to the menu to be populated
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
678 @type QMenu
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
679 @param hitTest reference to the hit test object
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
680 @type WebHitTestResult
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
681 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
682 if not menu.isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
683 menu.addSeparator()
1586
b3e34806b734 Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1584
diff changeset
684
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
685 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
686 UI.PixmapCache.getIcon("openNewTab.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
687 self.tr("Open Image in New Tab"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
688 act.setData(hitTest.imageUrl())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
689 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
690 lambda: self.__openLinkInNewTab(act))
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
691 menu.addSeparator()
4885
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
692 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
693 UI.PixmapCache.getIcon("download.png"),
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
694 self.tr("Save Image"), self.__downloadImage)
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
695 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
696 self.tr("Copy Image to Clipboard"), self.__copyImage)
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
697 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
698 UI.PixmapCache.getIcon("editCopy.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
699 self.tr("Copy Image Location to Clipboard"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
700 act.setData(hitTest.imageUrl())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
701 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
702 lambda: self.__copyLink(act))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
703 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
704 UI.PixmapCache.getIcon("mailSend.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
705 self.tr("Send Image Link"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
706 act.setData(hitTest.imageUrl())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
707 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
708 lambda: self.__sendLink(act))
4956
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
709
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
710 if hitTest.imageUrl().scheme() in ["http", "https"]:
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
711 menu.addSeparator()
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
712 engine = WebBrowserWindow.imageSearchEngine()
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
713 searchEngineName = engine.searchEngine()
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
714 act = menu.addAction(
4956
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
715 UI.PixmapCache.getIcon("{0}.png".format(
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
716 searchEngineName.lower())),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
717 self.tr("Search image in {0}").format(searchEngineName))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
718 act.setData(engine.getSearchQuery(hitTest.imageUrl()))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
719 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
720 lambda: self.__searchImage(act))
4956
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
721 self.__imageSearchMenu = menu.addMenu(
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
722 self.tr("Search image with..."))
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
723 for searchEngineName in engine.searchEngineNames():
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
724 act = self.__imageSearchMenu.addAction(
4956
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
725 UI.PixmapCache.getIcon("{0}.png".format(
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
726 searchEngineName.lower())),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
727 self.tr("Search image in {0}").format(searchEngineName))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
728 act.setData(engine.getSearchQuery(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
729 hitTest.imageUrl(), searchEngineName))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
730 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
731 lambda: self.__searchImage(act))
4956
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
732
4880
561f2bd9cfb9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4868
diff changeset
733 menu.addSeparator()
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
734 act = menu.addAction(
4880
561f2bd9cfb9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4868
diff changeset
735 UI.PixmapCache.getIcon("adBlockPlus.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
736 self.tr("Block Image"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
737 act.setData(hitTest.imageUrl().toString())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
738 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
739 lambda: self.__blockImage(act))
4753
8d2ea02ed785 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4752
diff changeset
740 if Preferences.getWebBrowser("VirusTotalEnabled") and \
8d2ea02ed785 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4752
diff changeset
741 Preferences.getWebBrowser("VirusTotalServiceKey") != "":
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
742 act = menu.addAction(
4753
8d2ea02ed785 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4752
diff changeset
743 UI.PixmapCache.getIcon("virustotal.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
744 self.tr("Scan Image with VirusTotal"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
745 act.setData(hitTest.imageUrl())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
746 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
747 lambda: self.__virusTotal(act))
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
748
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
749 def __createMediaContextMenu(self, menu, hitTest):
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
750 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
751 Private method to populate the context menu for media elements.
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
752
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
753 @param menu reference to the menu to be populated
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
754 @type QMenu
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
755 @param hitTest reference to the hit test object
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
756 @type WebHitTestResult
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
757 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758 if not menu.isEmpty():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759 menu.addSeparator()
1945
47016f5af3b8 Enhanced the web browser by adding a personal information manager to assist in completing form fields through field context menu entries or by pressing Ctrl+Return/Ctrl+Enter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1934
diff changeset
760
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
761 if hitTest.mediaPaused():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
762 menu.addAction(
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
763 UI.PixmapCache.getIcon("mediaPlaybackStart.png"),
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
764 self.tr("Play"), self.__pauseMedia)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
765 else:
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
766 menu.addAction(
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
767 UI.PixmapCache.getIcon("mediaPlaybackPause.png"),
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
768 self.tr("Pause"), self.__pauseMedia)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
769 if hitTest.mediaMuted():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
770 menu.addAction(
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
771 UI.PixmapCache.getIcon("audioVolumeHigh.png"),
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
772 self.tr("Unmute"), self.__muteMedia)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
773 else:
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
774 menu.addAction(
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
775 UI.PixmapCache.getIcon("audioVolumeMuted.png"),
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
776 self.tr("Mute"), self.__muteMedia)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
777 menu.addSeparator()
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
778 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
779 UI.PixmapCache.getIcon("editCopy.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
780 self.tr("Copy Media Address to Clipboard"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
781 act.setData(hitTest.mediaUrl())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
782 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
783 lambda: self.__copyLink(act))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
784 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
785 UI.PixmapCache.getIcon("mailSend.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
786 self.tr("Send Media Address"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
787 act.setData(hitTest.mediaUrl())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
788 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
789 lambda: self.__sendLink(act))
4885
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
790 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
791 UI.PixmapCache.getIcon("download.png"),
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
792 self.tr("Save Media"), self.__downloadMedia)
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
793
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
794 def __createSelectedTextContextMenu(self, menu, hitTest):
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
795 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
796 Private method to populate the context menu for selected text.
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
797
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
798 @param menu reference to the menu to be populated
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
799 @type QMenu
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
800 @param hitTest reference to the hit test object
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
801 @type WebHitTestResult
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
802 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
803 if not menu.isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
804 menu.addSeparator()
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
805
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
806 menu.addAction(self.__mw.copyAct)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
807 menu.addSeparator()
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
808 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
809 UI.PixmapCache.getIcon("mailSend.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
810 self.tr("Send Text"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
811 act.setData(self.selectedText())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
812 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
813 lambda: self.__sendLink(act))
4818
9afce2f09ac0 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4801
diff changeset
814
9afce2f09ac0 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4801
diff changeset
815 engineName = self.__mw.openSearchManager().currentEngineName()
9afce2f09ac0 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4801
diff changeset
816 if engineName:
4917
682750cc7bd5 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4913
diff changeset
817 menu.addAction(self.tr("Search with '{0}'").format(engineName),
4818
9afce2f09ac0 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4801
diff changeset
818 self.__searchDefaultRequested)
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
819
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
820 from .OpenSearch.OpenSearchEngineAction import \
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
821 OpenSearchEngineAction
4818
9afce2f09ac0 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4801
diff changeset
822
9afce2f09ac0 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4801
diff changeset
823 self.__searchMenu = menu.addMenu(self.tr("Search with..."))
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
824 engineNames = self.__mw.openSearchManager().allEnginesNames()
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
825 for engineName in engineNames:
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
826 engine = self.__mw.openSearchManager().engine(engineName)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
827 act = OpenSearchEngineAction(engine, self.__searchMenu)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
828 act.setData(engineName)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
829 self.__searchMenu.addAction(act)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
830 self.__searchMenu.triggered.connect(self.__searchRequested)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
831
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
832 menu.addSeparator()
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
833
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
834 from .WebBrowserLanguagesDialog import WebBrowserLanguagesDialog
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
835 languages = Preferences.toList(
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
836 Preferences.Prefs.settings.value(
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
837 "WebBrowser/AcceptLanguages",
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
838 WebBrowserLanguagesDialog.defaultAcceptLanguages()))
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
839 if languages:
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
840 language = languages[0]
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
841 langCode = language.split("[")[1][:2]
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
842 googleTranslatorUrl = QUrl(
5920
e47dd106c3d6 Fixed a few issues in the QWebEngine based web browser detected on Ubuntu 17.10.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5867
diff changeset
843 "http://translate.google.com/#auto/{0}/{1}".format(
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
844 langCode, self.selectedText()))
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
845 act = menu.addAction(
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
846 UI.PixmapCache.getIcon("translate.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
847 self.tr("Google Translate"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
848 act.setData(googleTranslatorUrl)
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
849 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
850 lambda: self.__openLinkInNewTab(act))
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
851 wiktionaryUrl = QUrl(
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
852 "http://{0}.wiktionary.org/wiki/Special:Search?search={1}"
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
853 .format(langCode, self.selectedText()))
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
854 act = menu.addAction(
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
855 UI.PixmapCache.getIcon("wikipedia.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
856 self.tr("Dictionary"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
857 act.setData(wiktionaryUrl)
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
858 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
859 lambda: self.__openLinkInNewTab(act))
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
860 menu.addSeparator()
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
861
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
862 guessedUrl = QUrl.fromUserInput(self.selectedText().strip())
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
863 if self.__isUrlValid(guessedUrl):
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
864 act = menu.addAction(self.tr("Go to web address"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
865 act.setData(guessedUrl)
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
866 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
867 lambda: self.__openLinkInNewTab(act))
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
868
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
869 def __createPageContextMenu(self, menu):
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
870 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
871 Private method to populate the basic context menu.
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
872
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
873 @param menu reference to the menu to be populated
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
874 @type QMenu
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
875 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
876 menu.addAction(self.__mw.newTabAct)
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
877 menu.addAction(self.__mw.newAct)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
878 menu.addSeparator()
5033
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5015
diff changeset
879 if self.__mw.saveAsAct is not None:
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5015
diff changeset
880 menu.addAction(self.__mw.saveAsAct)
d1c2651060ec Added the 'Save as' functionality to the new web browser (for Qt 5.7+)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5015
diff changeset
881 menu.addSeparator()
1586
b3e34806b734 Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1584
diff changeset
882
4885
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
883 if self.url().toString() == "eric:speeddial":
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
884 # special menu for the spedd dial page
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
885 menu.addAction(self.__mw.backAct)
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
886 menu.addAction(self.__mw.forwardAct)
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
887 menu.addSeparator()
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
888 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
889 UI.PixmapCache.getIcon("plus.png"),
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
890 self.tr("Add New Page"), self.__addSpeedDial)
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
891 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
892 UI.PixmapCache.getIcon("preferences-general.png"),
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
893 self.tr("Configure Speed Dial"), self.__configureSpeedDial)
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
894 menu.addSeparator()
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
895 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
896 UI.PixmapCache.getIcon("reload.png"),
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
897 self.tr("Reload All Dials"), self.__reloadAllSpeedDials)
4954
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4925
diff changeset
898 menu.addSeparator()
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4925
diff changeset
899 menu.addAction(
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4925
diff changeset
900 self.tr("Reset to Default Dials"), self.__resetSpeedDials)
4885
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
901 return
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
902
4732
5ac4fc1dfc20 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4731
diff changeset
903 menu.addAction(
5ac4fc1dfc20 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4731
diff changeset
904 UI.PixmapCache.getIcon("bookmark22.png"),
5ac4fc1dfc20 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4731
diff changeset
905 self.tr("Bookmark this Page"), self.addBookmark)
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
906 act = menu.addAction(
4727
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
907 UI.PixmapCache.getIcon("editCopy.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
908 self.tr("Copy Page Link"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
909 act.setData(self.url())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
910 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
911 lambda: self.__copyLink(act))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
912 act = menu.addAction(
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
913 UI.PixmapCache.getIcon("mailSend.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
914 self.tr("Send Page Link"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
915 act.setData(self.url())
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
916 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
917 lambda: self.__sendLink(act))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
918 menu.addSeparator()
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
919
4906
939ff20f712d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4905
diff changeset
920 from .UserAgent.UserAgentMenu import UserAgentMenu
939ff20f712d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4905
diff changeset
921 self.__userAgentMenu = UserAgentMenu(self.tr("User Agent"),
939ff20f712d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4905
diff changeset
922 url=self.url())
939ff20f712d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4905
diff changeset
923 menu.addMenu(self.__userAgentMenu)
939ff20f712d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4905
diff changeset
924 menu.addSeparator()
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
925 menu.addAction(self.__mw.backAct)
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
926 menu.addAction(self.__mw.forwardAct)
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
927 menu.addAction(self.__mw.homeAct)
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
928 menu.addAction(self.__mw.reloadAct)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
929 menu.addAction(self.__mw.stopAct)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
930 menu.addSeparator()
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
931 menu.addAction(self.__mw.zoomInAct)
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
932 menu.addAction(self.__mw.zoomResetAct)
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
933 menu.addAction(self.__mw.zoomOutAct)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
934 menu.addSeparator()
4727
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
935 menu.addAction(self.__mw.selectAllAct)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
936 menu.addSeparator()
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
937 menu.addAction(self.__mw.findAct)
4731
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
938 menu.addSeparator()
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
939 menu.addAction(self.__mw.pageSourceAct)
4783
7de17766a5df Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4782
diff changeset
940 menu.addSeparator()
7de17766a5df Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4782
diff changeset
941 menu.addAction(self.__mw.siteInfoAct)
4782
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
942 if self.url().scheme() in ["http", "https"]:
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
943 menu.addSeparator()
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
944
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
945 w3url = QUrl.fromEncoded(
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
946 b"http://validator.w3.org/check?uri=" +
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
947 QUrl.toPercentEncoding(bytes(self.url().toEncoded()).decode()))
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
948 act = menu.addAction(
4782
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
949 UI.PixmapCache.getIcon("w3.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
950 self.tr("Validate Page"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
951 act.setData(w3url)
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
952 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
953 lambda: self.__openLinkInNewTab(act))
4782
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
954
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
955 from .WebBrowserLanguagesDialog import WebBrowserLanguagesDialog
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
956 languages = Preferences.toList(
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
957 Preferences.Prefs.settings.value(
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
958 "WebBrowser/AcceptLanguages",
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
959 WebBrowserLanguagesDialog.defaultAcceptLanguages()))
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
960 if languages:
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
961 language = languages[0]
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
962 langCode = language.split("[")[1][:2]
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
963 googleTranslatorUrl = QUrl.fromEncoded(
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
964 b"http://translate.google.com/translate?sl=auto&tl=" +
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
965 langCode.encode() +
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
966 b"&u=" +
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
967 QUrl.toPercentEncoding(
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
968 bytes(self.url().toEncoded()).decode()))
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
969 act = menu.addAction(
4782
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
970 UI.PixmapCache.getIcon("translate.png"),
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
971 self.tr("Google Translate"))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
972 act.setData(googleTranslatorUrl)
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
973 act.triggered.connect(
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
974 lambda: self.__openLinkInNewTab(act))
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
975
4731
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
976 def __checkForForm(self, act, pos):
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
977 """
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
978 Private method to check the given position for an open search form.
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
979
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
980 @param act reference to the action to be populated upon success
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
981 @type QAction
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
982 @param pos position to be tested
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
983 @type QPoint
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
984 """
4925
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
985 self.__clickedPos = self.mapToViewport(pos)
4731
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
986
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
987 from .Tools import Scripts
4925
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
988 script = Scripts.getFormData(self.__clickedPos)
4731
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
989 self.page().runJavaScript(
5001
08eaee907686 Prepared the QWebEingine based web browser for the new runJavaScript() method as of Qt 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4958
diff changeset
990 script,
08eaee907686 Prepared the QWebEingine based web browser for the new runJavaScript() method as of Qt 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4958
diff changeset
991 WebBrowserPage.SafeJsWorld,
08eaee907686 Prepared the QWebEingine based web browser for the new runJavaScript() method as of Qt 5.7.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4958
diff changeset
992 lambda res: self.__checkForFormCallback(res, act))
4731
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
993
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
994 def __checkForFormCallback(self, res, act):
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
995 """
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
996 Private method handling the __checkForForm result.
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
997
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
998 @param res result dictionary generated by JavaScript
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
999 @type dict
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1000 @param act reference to the action to be populated upon success
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1001 @type QAction
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1002 """
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1003 if act is None or not bool(res):
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1004 return
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1005
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1006 url = QUrl(res["action"])
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1007 method = res["method"]
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1008
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1009 if not url.isEmpty() and method in ["get", "post"]:
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1010 act.setVisible(True)
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1011 act.setText(self.tr("Add to web search toolbar"))
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1012 act.triggered.connect(self.__addSearchEngine)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1013
1586
b3e34806b734 Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1584
diff changeset
1014 def __isUrlValid(self, url):
b3e34806b734 Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1584
diff changeset
1015 """
b3e34806b734 Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1584
diff changeset
1016 Private method to check a URL for validity.
b3e34806b734 Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1584
diff changeset
1017
b3e34806b734 Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1584
diff changeset
1018 @param url URL to be checked (QUrl)
b3e34806b734 Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1584
diff changeset
1019 @return flag indicating a valid URL (boolean)
b3e34806b734 Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1584
diff changeset
1020 """
b3e34806b734 Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1584
diff changeset
1021 return url.isValid() and \
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
1022 bool(url.host()) and \
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
1023 bool(url.scheme()) and \
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
1024 "." in url.host()
1586
b3e34806b734 Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1584
diff changeset
1025
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1026 def __replaceMisspelledWord(self, act):
5532
3a7c5deab9b7 Added support for new functionality provided by Qt 5.8.0 to the QtWebEngine based web browser (including spell checking).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
1027 """
3a7c5deab9b7 Added support for new functionality provided by Qt 5.8.0 to the QtWebEngine based web browser (including spell checking).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
1028 Private slot to replace a misspelled word under the context menu.
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1029
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1030 @param act reference to the action that triggered
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1031 @type QAction
5532
3a7c5deab9b7 Added support for new functionality provided by Qt 5.8.0 to the QtWebEngine based web browser (including spell checking).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
1032 """
3a7c5deab9b7 Added support for new functionality provided by Qt 5.8.0 to the QtWebEngine based web browser (including spell checking).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
1033 suggestion = act.text()
3a7c5deab9b7 Added support for new functionality provided by Qt 5.8.0 to the QtWebEngine based web browser (including spell checking).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
1034 self.page().replaceMisspelledWord(suggestion)
3a7c5deab9b7 Added support for new functionality provided by Qt 5.8.0 to the QtWebEngine based web browser (including spell checking).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5530
diff changeset
1035
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1036 def __openLinkInNewTab(self, act):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1037 """
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
1038 Private method called by the context menu to open a link in a new
4790
deeea3d64858 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4783
diff changeset
1039 tab.
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1040
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1041 @param act reference to the action that triggered
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1042 @type QAction
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1043 """
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
1044 url = act.data()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1045 if url.isEmpty():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1046 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1047
4908
f1859c36d564 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4906
diff changeset
1048 self.setSource(url, newTab=True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1049
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1050 def __openLinkInNewWindow(self, act):
4790
deeea3d64858 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4783
diff changeset
1051 """
deeea3d64858 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4783
diff changeset
1052 Private slot called by the context menu to open a link in a new
deeea3d64858 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4783
diff changeset
1053 window.
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1054
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1055 @param act reference to the action that triggered
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1056 @type QAction
4790
deeea3d64858 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4783
diff changeset
1057 """
deeea3d64858 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4783
diff changeset
1058 url = act.data()
deeea3d64858 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4783
diff changeset
1059 if url.isEmpty():
deeea3d64858 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4783
diff changeset
1060 return
deeea3d64858 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4783
diff changeset
1061
deeea3d64858 Continued porting the web browser.
Detlev Offenbach&