eric6/WebBrowser/WebBrowserView.py

Thu, 03 Oct 2019 11:12:10 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 03 Oct 2019 11:12:10 +0200
branch
maintenance
changeset 7286
7eb04391adf7
parent 6989
8b8cadf8d7e9
parent 7271
2cac5b7abcce
child 7362
028bf21bb5a2
permissions
-rw-r--r--

Merged with default branch to prepare a new release.

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