eric6/WebBrowser/WebBrowserView.py

Sat, 04 May 2019 11:10:44 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 04 May 2019 11:10:44 +0200
branch
maintenance
changeset 6989
8b8cadf8d7e9
parent 6923
WebBrowser/WebBrowserView.py@d062df8f1d9f
parent 6942
WebBrowser/WebBrowserView.py@2602857055c5
child 7286
7eb04391adf7
permissions
-rw-r--r--

Merged with default branch to prepare release 19.5.

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
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6591
diff changeset
3 # Copyright (c) 2008 - 2019 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, \
6839
4f6234f34dfd WebBrowserView: added support to go one page back by pressing the backspace key.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6797
diff changeset
23 QContextMenuEvent, QPixmap, QCursor
6662
0002926e71d3 Web Browser (NG): added support to select a client SSL certificate (as of Qt 5.12).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6656
diff changeset
24 from PyQt5.QtWidgets import qApp, QStyle, QMenu, QApplication, QDialog
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
6221
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6155
diff changeset
98 self.__tabWidget = parent
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.__isLoading = False
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 629
diff changeset
100 self.__progress = 0
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
101 self.__siteIconLoader = None
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
102 self.__siteIcon = QIcon()
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
103 self.__menu = QMenu(self)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
104 self.__clickedPos = QPoint()
4781
15d416f1eca5 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4780
diff changeset
105 self.__firstLoad = False
4900
32f940762654 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4886
diff changeset
106 self.__preview = QPixmap()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.__currentZoom = 100
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
109 self.__zoomLevels = WebBrowserView.ZoomLevels[:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
111 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
112 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
113 self.page().linkHovered.connect(self.__linkHovered)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
115 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
116 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
117 self.loadFinished.connect(self.__loadFinished)
4903
10910764454a Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4900
diff changeset
118 self.renderProcessTerminated.connect(self.__renderProcessTerminated)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
120 self.__mw.openSearchManager().currentEngineChanged.connect(
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
121 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
122
cc3e2e5558e9 Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
123 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
124
1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1232
diff changeset
125 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
126
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
127 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
128
4752
a3bcc42a82a9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4745
diff changeset
129 self.__mw.personalInformationManager().connectPage(self.page())
4717
5841f229baf7 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4715
diff changeset
130
4781
15d416f1eca5 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4780
diff changeset
131 self.__inspector = None
15d416f1eca5 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4780
diff changeset
132 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
133
5784
362bbcc49ac1 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5740
diff changeset
134 self.__restoreData = None
362bbcc49ac1 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5740
diff changeset
135
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5721
diff changeset
136 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
137 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
138 self.parentWidget().installEventFilter(self)
6269
51a0f31bb240 WebBrowserView: added rwhvqt detection for Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6221
diff changeset
139
51a0f31bb240 WebBrowserView: added rwhvqt detection for Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6221
diff changeset
140 if qVersionTuple() >= (5, 8, 0) and qVersionTuple() < (5, 11, 0):
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
141 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
142 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
143 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
144 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
145
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
146 self.grabGesture(Qt.PinchGesture)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
148 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
149 """
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
150 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
151 """
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
152 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
153 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
154
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
155 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
156 self.__page.safeBrowsingBad.connect(self.safeBrowsingBad)
6656
273a2130adbe WebBrowserPage: added support for the printRequested signal as of Qt 5.12.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
157 self.__page.printPageRequested.connect(self.__printPage)
6410
98a5d0cd72f5 Webbrowser: finished upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6402
diff changeset
158 try:
98a5d0cd72f5 Webbrowser: finished upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6402
diff changeset
159 self.__page.quotaRequested.connect(self.__quotaRequested)
6695
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6692
diff changeset
160 # The registerProtocolHandlerRequested signal is handled in
0a51887c13cd Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6692
diff changeset
161 # WebBrowserPage.
6410
98a5d0cd72f5 Webbrowser: finished upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6402
diff changeset
162 except AttributeError:
98a5d0cd72f5 Webbrowser: finished upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6402
diff changeset
163 # pre Qt 5.11
98a5d0cd72f5 Webbrowser: finished upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6402
diff changeset
164 pass
6662
0002926e71d3 Web Browser (NG): added support to select a client SSL certificate (as of Qt 5.12).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6656
diff changeset
165 try:
0002926e71d3 Web Browser (NG): added support to select a client SSL certificate (as of Qt 5.12).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6656
diff changeset
166 self.__page.selectClientCertificate.connect(
0002926e71d3 Web Browser (NG): added support to select a client SSL certificate (as of Qt 5.12).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6656
diff changeset
167 self.__selectClientCertificate)
0002926e71d3 Web Browser (NG): added support to select a client SSL certificate (as of Qt 5.12).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6656
diff changeset
168 except AttributeError:
0002926e71d3 Web Browser (NG): added support to select a client SSL certificate (as of Qt 5.12).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6656
diff changeset
169 # pre Qt 5.12
0002926e71d3 Web Browser (NG): added support to select a client SSL certificate (as of Qt 5.12).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6656
diff changeset
170 pass
5829
d3448873ced3 Finished coding the safe browsing module of the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5797
diff changeset
171
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
172 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
173 """
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
174 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
175 """
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
176 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
177 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
178 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
179 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
180 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
181 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
182 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
183
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
184 def __currentEngineChanged(self):
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
185 """
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
186 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
187 """
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
188 if self.url().toString() == "eric:home":
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
189 self.reload()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
191 def mainWindow(self):
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
192 """
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
193 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
194
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
195 @return reference to the main window
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
196 @rtype WebBrowserWindow
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
197 """
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
198 return self.__mw
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
199
6221
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6155
diff changeset
200 def tabWidget(self):
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6155
diff changeset
201 """
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6155
diff changeset
202 Public method to get a reference to the tab widget containing this
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6155
diff changeset
203 view.
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6155
diff changeset
204
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6155
diff changeset
205 @return reference to the tab widget
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6155
diff changeset
206 @rtype WebBrowserTabWidget
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6155
diff changeset
207 """
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6155
diff changeset
208 return self.__tabWidget
35ec993034e1 Web Browser (NG): improvement of the download manager
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6155
diff changeset
209
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
210 def load(self, url):
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
211 """
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
212 Public method to load a web site.
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
213
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
214 @param url URL to be loaded
4913
e16573640cb8 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4910
diff changeset
215 @type QUrl
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
216 """
6141
f4cecd941096 WebBrowserView: Call acceptNavigationRequest() first in the load method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6126
diff changeset
217 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
218 not self.__page.acceptNavigationRequest(
f4cecd941096 WebBrowserView: Call acceptNavigationRequest() first in the load method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6126
diff changeset
219 url, QWebEnginePage.NavigationTypeTyped, True):
f4cecd941096 WebBrowserView: Call acceptNavigationRequest() first in the load method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6126
diff changeset
220 return
f4cecd941096 WebBrowserView: Call acceptNavigationRequest() first in the load method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6126
diff changeset
221
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
222 super(WebBrowserView, self).load(url)
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
223
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
224 if not self.__firstLoad:
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
225 self.__firstLoad = True
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
226 WebInspector.pushView(self)
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
227
4908
f1859c36d564 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4906
diff changeset
228 def setSource(self, name, newTab=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 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
231
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 @param name filename to be shown (QUrl)
4908
f1859c36d564 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4906
diff changeset
233 @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
234 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
235 if name is None or not name.isValid():
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237
4908
f1859c36d564 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4906
diff changeset
238 if newTab:
f1859c36d564 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4906
diff changeset
239 # open in a new tab
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
240 self.__mw.newTab(name)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242
5195
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
243 if not name.scheme():
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
244 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
245 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
246 else:
5195
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
247 if Utilities.isWindowsPlatform():
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
248 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
249 name.toString()))
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
250 else:
a282431c01fc Fixed the last change to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5194
diff changeset
251 name.setUrl("file://" + name.toString())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 if len(name.scheme()) == 1 or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 name.scheme() == "file":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 # name is a local file
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 if name.scheme() and len(name.scheme()) == 1:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 # it is a local path on win os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 name = QUrl.fromLocalFile(name.toString())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 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
261 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
262 self,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
263 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
264 self.tr(
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
265 """<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
266 .format(name.toLocalFile()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268
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
269 if name.toLocalFile().lower().endswith((".pdf", ".chm")):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 started = QDesktopServices.openUrl(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 if not started:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
272 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
273 self,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
274 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
275 self.tr(
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
276 """<p>Could not start a viewer"""
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
277 """ for file <b>{0}</b>.</p>""")
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
278 .format(name.path()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 return
278
c93823b96faa Added a handler for ftp: URLs to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 260
diff changeset
280 elif name.scheme() in ["mailto"]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 started = QDesktopServices.openUrl(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 if not started:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
283 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
284 self,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
285 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
286 self.tr(
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
287 """<p>Could not start an application"""
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
288 """ for URL <b>{0}</b>.</p>""")
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
289 .format(name.toString()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 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
292 if name.toString().lower().endswith((".pdf", ".chm")):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 started = QDesktopServices.openUrl(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 if not started:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
295 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
296 self,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
297 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
298 self.tr(
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
299 """<p>Could not start a viewer"""
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
300 """ for file <b>{0}</b>.</p>""")
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
301 .format(name.path()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303
4908
f1859c36d564 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4906
diff changeset
304 self.load(name)
0
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 def source(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 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
309
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 @return URL loaded in the help browser (QUrl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 return self.url()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 def documentTitle(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 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
317
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 @return title (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 return self.title()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 def backward(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 Public slot to move backwards in history.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
326 self.triggerPageAction(QWebEnginePage.Back)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 self.__urlChanged(self.history().currentItem().url())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 def forward(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 Public slot to move forward in history.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
333 self.triggerPageAction(QWebEnginePage.Forward)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 self.__urlChanged(self.history().currentItem().url())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 def home(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 Public slot to move to the first page loaded.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
340 homeUrl = QUrl(Preferences.getWebBrowser("HomePage"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 self.setSource(homeUrl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 self.__urlChanged(self.history().currentItem().url())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 def reload(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 Public slot to reload the current page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
348 self.triggerPageAction(QWebEnginePage.Reload)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349
4791
a1e53a9ffcf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
350 def reloadBypassingCache(self):
a1e53a9ffcf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
351 """
a1e53a9ffcf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
352 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
353 """
a1e53a9ffcf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
354 self.triggerPageAction(QWebEnginePage.ReloadAndBypassCache)
a1e53a9ffcf3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4790
diff changeset
355
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 def copy(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 Public slot to copy the selected text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
360 self.triggerPageAction(QWebEnginePage.Copy)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361
4727
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
362 def cut(self):
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
363 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
364 Public slot to cut the selected text.
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
365 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
366 self.triggerPageAction(QWebEnginePage.Cut)
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
367
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
368 def paste(self):
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
369 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
370 Public slot to paste text from the clipboard.
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
371 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
372 self.triggerPageAction(QWebEnginePage.Paste)
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
373
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
374 def undo(self):
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
375 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
376 Public slot to undo the last edit action.
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
377 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
378 self.triggerPageAction(QWebEnginePage.Undo)
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
379
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
380 def redo(self):
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
381 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
382 Public slot to redo the last edit action.
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
383 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
384 self.triggerPageAction(QWebEnginePage.Redo)
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
385
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
386 def selectAll(self):
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
387 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
388 Public slot to select all text.
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
389 """
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
390 self.triggerPageAction(QWebEnginePage.SelectAll)
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
391
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
392 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
393 """
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
394 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
395 """
5921
d4797da58218 Some more fixes for the web browser NG.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
396 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
397 self.triggerPageAction(QWebEnginePage.Unselect)
5921
d4797da58218 Some more fixes for the web browser NG.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
398 except AttributeError:
d4797da58218 Some more fixes for the web browser NG.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
399 # 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
400 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
401 "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
402 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
403
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 def isForwardAvailable(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 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
407
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 @return flag indicating move forward is possible (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 return self.history().canGoForward()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 def isBackwardAvailable(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 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
415
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 @return flag indicating move backwards is possible (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 return self.history().canGoBack()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 def __levelForZoom(self, zoom):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 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
423
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 @param zoom zoom factor (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 @return index of zoom factor (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 index = self.__zoomLevels.index(zoom)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 except ValueError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 for index in range(len(self.__zoomLevels)):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 if zoom <= self.__zoomLevels[index]:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 return index
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434
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
435 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
436 """
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
437 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
438
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
439 @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
440 @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
441 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
442 @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
443 """
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
444 if value != self.__currentZoom:
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
445 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
446 self.__currentZoom = value
4726
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
447 if saveValue and not self.__mw.isPrivate():
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
448 from .ZoomManager import ZoomManager
c26e2a2dc0cb Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4725
diff changeset
449 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
450 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
451
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
452 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
453 """
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
454 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
455
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
456 @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
457 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
458 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
459 return int(val)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 def zoomIn(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 Public slot to zoom into the page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 index = self.__levelForZoom(self.__currentZoom)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 if index < len(self.__zoomLevels) - 1:
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
467 self.setZoomValue(self.__zoomLevels[index + 1])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 def zoomOut(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 Public slot to zoom out of the page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 index = self.__levelForZoom(self.__currentZoom)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 if index > 0:
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
475 self.setZoomValue(self.__zoomLevels[index - 1])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
477 def zoomReset(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 Public method to reset the zoom factor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
481 index = self.__levelForZoom(WebBrowserView.ZoomLevelDefault)
4846
960e5e18894b Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4826
diff changeset
482 self.setZoomValue(self.__zoomLevels[index])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483
4925
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
484 def mapToViewport(self, pos):
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
485 """
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
486 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
487
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
488 @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
489 @type QPoint
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
490 @return viewport position
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
491 @rtype QPoint
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
492 """
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
493 return self.page().mapToViewport(pos)
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
494
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 def hasSelection(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 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
498
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 @return flag indicating text has been selected (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 return self.selectedText() != ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502
4881
c269212cceac Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4880
diff changeset
503 def findNextPrev(self, txt, case, backwards, callback):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 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
506
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 @param txt text to search for (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 @param case flag indicating a case sensitive search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 @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
510 @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
511 @type function(bool) or None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 """
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
513 findFlags = QWebEnginePage.FindFlags()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 if case:
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
515 findFlags |= QWebEnginePage.FindCaseSensitively
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 if backwards:
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
517 findFlags |= QWebEnginePage.FindBackward
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
519 if callback is None:
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
520 self.findText(txt, findFlags)
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
521 else:
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
522 self.findText(txt, findFlags, callback)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 def contextMenuEvent(self, evt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 """
4917
682750cc7bd5 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4913
diff changeset
526 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
527
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
528 This method is overridden from QWebEngineView.
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
529
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
530 @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
531 (QContextMenuEvent)
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
532 """
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
533 pos = evt.pos()
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
534 reason = evt.reason()
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
535 QTimer.singleShot(
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
536 0,
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
537 lambda: self._contextMenuEvent(QContextMenuEvent(reason, pos)))
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
538 # 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
539 # the main loop
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
540
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
541 def _contextMenuEvent(self, evt):
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
542 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 Protected method called to create a context menu.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4711
diff changeset
545 This method is overridden from QWebEngineView.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
547 @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
548 (QContextMenuEvent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 """
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
550 self.__menu.clear()
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
551
4728
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
552 hitTest = self.page().hitTestContent(evt.pos())
0367675d783d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4727
diff changeset
553
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
554 self.__createContextMenu(self.__menu, hitTest)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
555
4880
561f2bd9cfb9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4868
diff changeset
556 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
557 self.__menu.addSeparator()
4880
561f2bd9cfb9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4868
diff changeset
558 self.__menu.addAction(self.__mw.adBlockIcon().menuAction())
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
559
6402
bdc273bb66c5 WebInspector: adjusted the code to support the enhanced web inspector interface of Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6269
diff changeset
560 if qVersionTuple() >= (5, 11, 0) or \
bdc273bb66c5 WebInspector: adjusted the code to support the enhanced web inspector interface of Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6269
diff changeset
561 Preferences.getWebBrowser("WebInspectorEnabled"):
4782
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
562 self.__menu.addSeparator()
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
563 self.__menu.addAction(
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
564 UI.PixmapCache.getIcon("webInspector.png"),
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
565 self.tr("Inspect Element..."), self.__webInspector)
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
566
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
567 if not self.__menu.isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
568 pos = evt.globalPos()
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
569 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
570
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
571 def __createContextMenu(self, menu, hitTest):
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
572 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
573 Private method to populate the context menu.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
575 @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
576 @type QMenu
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
577 @param hitTest reference to the hit test object
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
578 @type WebHitTestResult
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
579 """
5530
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
580 spellCheckActionCount = 0
5921
d4797da58218 Some more fixes for the web browser NG.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5920
diff changeset
581 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
582 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
583 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
584
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
585 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
586 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
587 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
588 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
589
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
590 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
591 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
592 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
593 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
594 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
595
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
596 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
597 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
598
93f95c4b3153 Started upgrading the new web browser to the Qt 5.8 offerings.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
599 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
600 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
601
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
602 if not hitTest.linkUrl().isEmpty() and \
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
603 hitTest.linkUrl().scheme() != "javascript":
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
604 self.__createLinkContextMenu(menu, hitTest)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
605
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
606 if not hitTest.imageUrl().isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
607 self.__createImageContextMenu(menu, hitTest)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
608
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
609 if not hitTest.mediaUrl().isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
610 self.__createMediaContextMenu(menu, hitTest)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
611
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
612 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
613 # 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
614 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
615 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
616 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
617 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
618 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
619 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
620 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
621 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
622 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
623 menu, self, hitTest)
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
624
4731
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
625 if hitTest.tagName() == "input":
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
626 menu.addSeparator()
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
627 act = menu.addAction("")
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
628 act.setVisible(False)
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
629 self.__checkForForm(act, hitTest.pos())
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
630
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
631 if self.selectedText():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
632 self.__createSelectedTextContextMenu(menu, hitTest)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
633
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
634 if self.__menu.isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
635 self.__createPageContextMenu(menu)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
636
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
637 def __createLinkContextMenu(self, menu, hitTest):
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
638 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
639 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
640
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
641 @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
642 @type QMenu
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
643 @param hitTest reference to the hit test object
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
644 @type WebHitTestResult
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
645 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
646 if not menu.isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
647 menu.addSeparator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
648
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
649 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
650 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
651 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
652 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
653 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
654 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
655 act = menu.addAction(
4790
deeea3d64858 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4783
diff changeset
656 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
657 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
658 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
659 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
660 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
661 act = menu.addAction(
4790
deeea3d64858 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4783
diff changeset
662 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
663 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
664 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
665 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
666 lambda: self.__openLinkInNewPrivateWindow(act))
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
667 menu.addSeparator()
4885
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
668 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
669 UI.PixmapCache.getIcon("download.png"),
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
670 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
671 act = menu.addAction(
4732
5ac4fc1dfc20 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4731
diff changeset
672 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
673 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
674 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
675 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
676 lambda: self.__bookmarkLink(act))
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
677 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
678 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
679 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
680 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
681 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
682 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
683 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
684 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
685 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
686 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
687 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
688 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
689 lambda: self.__sendLink(act))
4753
8d2ea02ed785 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4752
diff changeset
690 if Preferences.getWebBrowser("VirusTotalEnabled") and \
8d2ea02ed785 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4752
diff changeset
691 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
692 act = menu.addAction(
4753
8d2ea02ed785 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4752
diff changeset
693 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
694 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
695 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
696 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
697 lambda: self.__virusTotal(act))
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
698
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
699 def __createImageContextMenu(self, menu, hitTest):
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
700 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
701 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
702
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
703 @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
704 @type QMenu
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
705 @param hitTest reference to the hit test object
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
706 @type WebHitTestResult
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
707 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
708 if not menu.isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
709 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
710
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
711 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
712 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
713 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
714 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
715 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
716 lambda: self.__openLinkInNewTab(act))
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
717 menu.addSeparator()
4885
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
718 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
719 UI.PixmapCache.getIcon("download.png"),
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
720 self.tr("Save Image"), self.__downloadImage)
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
721 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
722 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
723 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
724 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
725 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
726 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
727 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
728 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
729 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
730 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
731 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
732 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
733 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
734 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
735
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
736 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
737 menu.addSeparator()
1496516b0f2c Finished implementing the image search functionality for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4954
diff changeset
738 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
739 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
740 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
741 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
742 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
743 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
744 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
745 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
746 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
747 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
748 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
749 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
750 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
751 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
752 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
753 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
754 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
755 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
756 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
757 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
758
4880
561f2bd9cfb9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4868
diff changeset
759 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
760 act = menu.addAction(
4880
561f2bd9cfb9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4868
diff changeset
761 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
762 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
763 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
764 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
765 lambda: self.__blockImage(act))
4753
8d2ea02ed785 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4752
diff changeset
766 if Preferences.getWebBrowser("VirusTotalEnabled") and \
8d2ea02ed785 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4752
diff changeset
767 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
768 act = menu.addAction(
4753
8d2ea02ed785 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4752
diff changeset
769 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
770 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
771 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
772 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
773 lambda: self.__virusTotal(act))
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
774
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
775 def __createMediaContextMenu(self, menu, hitTest):
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
776 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
777 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
778
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
779 @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
780 @type QMenu
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
781 @param hitTest reference to the hit test object
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
782 @type WebHitTestResult
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
783 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
784 if not menu.isEmpty():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 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
786
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
787 if hitTest.mediaPaused():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
788 menu.addAction(
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
789 UI.PixmapCache.getIcon("mediaPlaybackStart.png"),
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
790 self.tr("Play"), self.__pauseMedia)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
791 else:
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
792 menu.addAction(
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
793 UI.PixmapCache.getIcon("mediaPlaybackPause.png"),
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
794 self.tr("Pause"), self.__pauseMedia)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
795 if hitTest.mediaMuted():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
796 menu.addAction(
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
797 UI.PixmapCache.getIcon("audioVolumeHigh.png"),
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
798 self.tr("Unmute"), self.__muteMedia)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
799 else:
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
800 menu.addAction(
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
801 UI.PixmapCache.getIcon("audioVolumeMuted.png"),
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
802 self.tr("Mute"), self.__muteMedia)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
803 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
804 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
805 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
806 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
807 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
808 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
809 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
810 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
811 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
812 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
813 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
814 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
815 lambda: self.__sendLink(act))
4885
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
816 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
817 UI.PixmapCache.getIcon("download.png"),
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
818 self.tr("Save Media"), self.__downloadMedia)
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
819
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
820 def __createSelectedTextContextMenu(self, menu, hitTest):
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
821 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
822 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
823
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
824 @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
825 @type QMenu
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
826 @param hitTest reference to the hit test object
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
827 @type WebHitTestResult
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
828 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
829 if not menu.isEmpty():
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
830 menu.addSeparator()
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
831
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
832 menu.addAction(self.__mw.copyAct)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
833 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
834 act = menu.addAction(
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
835 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
836 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
837 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
838 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
839 lambda: self.__sendLink(act))
4818
9afce2f09ac0 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4801
diff changeset
840
9afce2f09ac0 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4801
diff changeset
841 engineName = self.__mw.openSearchManager().currentEngineName()
9afce2f09ac0 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4801
diff changeset
842 if engineName:
4917
682750cc7bd5 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4913
diff changeset
843 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
844 self.__searchDefaultRequested)
4741
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
845
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
846 from .OpenSearch.OpenSearchEngineAction import \
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
847 OpenSearchEngineAction
4818
9afce2f09ac0 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4801
diff changeset
848
9afce2f09ac0 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4801
diff changeset
849 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
850 engineNames = self.__mw.openSearchManager().allEnginesNames()
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
851 for engineName in engineNames:
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
852 engine = self.__mw.openSearchManager().engine(engineName)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
853 act = OpenSearchEngineAction(engine, self.__searchMenu)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
854 act.setData(engineName)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
855 self.__searchMenu.addAction(act)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
856 self.__searchMenu.triggered.connect(self.__searchRequested)
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
857
f9e1adc69076 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
858 menu.addSeparator()
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
859
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
860 from .WebBrowserLanguagesDialog import WebBrowserLanguagesDialog
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
861 languages = Preferences.toList(
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
862 Preferences.Prefs.settings.value(
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
863 "WebBrowser/AcceptLanguages",
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
864 WebBrowserLanguagesDialog.defaultAcceptLanguages()))
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
865 if languages:
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
866 language = languages[0]
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
867 langCode = language.split("[")[1][:2]
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
868 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
869 "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
870 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
871 act = menu.addAction(
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
872 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
873 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
874 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
875 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
876 lambda: self.__openLinkInNewTab(act))
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
877 wiktionaryUrl = QUrl(
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
878 "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
879 .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
880 act = menu.addAction(
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
881 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
882 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
883 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
884 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
885 lambda: self.__openLinkInNewTab(act))
4754
1ff6d0ecb2fd Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4753
diff changeset
886 menu.addSeparator()
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
887
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
888 guessedUrl = QUrl.fromUserInput(self.selectedText().strip())
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
889 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
890 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
891 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
892 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
893 lambda: self.__openLinkInNewTab(act))
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
894
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
895 def __createPageContextMenu(self, menu):
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
896 """
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
897 Private method to populate the basic context menu.
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
898
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
899 @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
900 @type QMenu
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
901 """
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
902 menu.addAction(self.__mw.newTabAct)
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
903 menu.addAction(self.__mw.newAct)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
904 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
905 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
906 menu.addAction(self.__mw.saveAsAct)
6155
ae44225e7e7c PageScreen: Removed the action to save the whole web page as a screenshot because it is not supported by QWebEngine (and probably will not in the foreseeable future).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6147
diff changeset
907 menu.addAction(self.__mw.saveVisiblePageScreenAct)
ae44225e7e7c PageScreen: Removed the action to save the whole web page as a screenshot because it is not supported by QWebEngine (and probably will not in the foreseeable future).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6147
diff changeset
908 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
909
4885
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
910 if self.url().toString() == "eric:speeddial":
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
911 # special menu for the spedd dial page
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
912 menu.addAction(self.__mw.backAct)
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
913 menu.addAction(self.__mw.forwardAct)
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
914 menu.addSeparator()
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
915 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
916 UI.PixmapCache.getIcon("plus.png"),
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
917 self.tr("Add New Page"), self.__addSpeedDial)
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
918 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
919 UI.PixmapCache.getIcon("preferences-general.png"),
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
920 self.tr("Configure Speed Dial"), self.__configureSpeedDial)
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
921 menu.addSeparator()
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
922 menu.addAction(
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
923 UI.PixmapCache.getIcon("reload.png"),
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
924 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
925 menu.addSeparator()
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4925
diff changeset
926 menu.addAction(
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4925
diff changeset
927 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
928 return
362360f9a979 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4884
diff changeset
929
4732
5ac4fc1dfc20 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4731
diff changeset
930 menu.addAction(
5ac4fc1dfc20 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4731
diff changeset
931 UI.PixmapCache.getIcon("bookmark22.png"),
5ac4fc1dfc20 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4731
diff changeset
932 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
933 act = menu.addAction(
4727
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
934 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
935 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
936 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
937 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
938 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
939 act = menu.addAction(
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
940 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
941 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
942 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
943 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
944 lambda: self.__sendLink(act))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
945 menu.addSeparator()
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
946
4906
939ff20f712d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4905
diff changeset
947 from .UserAgent.UserAgentMenu import UserAgentMenu
939ff20f712d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4905
diff changeset
948 self.__userAgentMenu = UserAgentMenu(self.tr("User Agent"),
939ff20f712d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4905
diff changeset
949 url=self.url())
939ff20f712d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4905
diff changeset
950 menu.addMenu(self.__userAgentMenu)
939ff20f712d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4905
diff changeset
951 menu.addSeparator()
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
952 menu.addAction(self.__mw.backAct)
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
953 menu.addAction(self.__mw.forwardAct)
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
954 menu.addAction(self.__mw.homeAct)
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
955 menu.addAction(self.__mw.reloadAct)
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
956 menu.addAction(self.__mw.stopAct)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
957 menu.addSeparator()
4711
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
958 menu.addAction(self.__mw.zoomInAct)
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
959 menu.addAction(self.__mw.zoomResetAct)
0a9162801b8d Started with web browser view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4710
diff changeset
960 menu.addAction(self.__mw.zoomOutAct)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
961 menu.addSeparator()
4727
62b50a24fb59 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
962 menu.addAction(self.__mw.selectAllAct)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963 menu.addSeparator()
4729
fc8d00860717 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4728
diff changeset
964 menu.addAction(self.__mw.findAct)
4731
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
965 menu.addSeparator()
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
966 menu.addAction(self.__mw.pageSourceAct)
4783
7de17766a5df Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4782
diff changeset
967 menu.addSeparator()
7de17766a5df Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4782
diff changeset
968 menu.addAction(self.__mw.siteInfoAct)
4782
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
969 if self.url().scheme() in ["http", "https"]:
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
970 menu.addSeparator()
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
971
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
972 w3url = QUrl.fromEncoded(
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
973 b"http://validator.w3.org/check?uri=" +
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
974 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
975 act = menu.addAction(
4782
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
976 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
977 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
978 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
979 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
980 lambda: self.__openLinkInNewTab(act))
4782
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
981
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
982 from .WebBrowserLanguagesDialog import WebBrowserLanguagesDialog
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
983 languages = Preferences.toList(
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
984 Preferences.Prefs.settings.value(
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
985 "WebBrowser/AcceptLanguages",
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
986 WebBrowserLanguagesDialog.defaultAcceptLanguages()))
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
987 if languages:
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
988 language = languages[0]
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
989 langCode = language.split("[")[1][:2]
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
990 googleTranslatorUrl = QUrl.fromEncoded(
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
991 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
992 langCode.encode() +
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
993 b"&u=" +
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
994 QUrl.toPercentEncoding(
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
995 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
996 act = menu.addAction(
4782
4ad656e4ebec Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4781
diff changeset
997 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
998 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
999 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
1000 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
1001 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
1002
4731
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1003 def __checkForForm(self, act, pos):
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1004 """
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1005 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
1006
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1007 @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
1008 @type QAction
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1009 @param pos position to be tested
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1010 @type QPoint
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1011 """
4925
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
1012 self.__clickedPos = self.mapToViewport(pos)
4731
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1013
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1014 from .Tools import Scripts
4925
6534062014dc Mapped the webhit test position to the viewport.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4924
diff changeset
1015 script = Scripts.getFormData(self.__clickedPos)
4731
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1016 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
1017 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
1018 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
1019 lambda res: self.__checkForFormCallback(res, act))
4731
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1020
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1021 def __checkForFormCallback(self, res, act):
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1022 """
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1023 Private method handling the __checkForForm result.
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1024
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1025 @param res result dictionary generated by JavaScript
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1026 @type dict
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1027 @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
1028 @type QAction
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1029 """
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1030 if act is None or not bool(res):
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1031 return
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1032
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1033 url = QUrl(res["action"])
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1034 method = res["method"]
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1035
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1036 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
1037 act.setVisible(True)
67d861d9e492 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4729
diff changeset
1038 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
1039 act.triggered.connect(self.__addSearchEngine)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1040
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
1041 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
1042 """
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
1043 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
1044
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
1045 @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
1046 @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
1047 """
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
1048 return url.isValid() and \
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
1049 bool(url.host()) and \
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
1050 bool(url.scheme()) and \
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
1051 "." 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
1052
6122
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1053 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
1054 """
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
1055 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
1056
e7d98249f393 Completed coding in order to remove the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6081
diff changeset
1057 @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
1058 @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
1059 """