Helpviewer/HelpBrowserWV.py

Sat, 18 Jul 2015 10:36:53 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 18 Jul 2015 10:36:53 +0200
changeset 4316
493891cbacee
parent 4275
3bed5f74d328
child 4326
e52318f11812
permissions
-rw-r--r--

Added support for feature permissions to the eric web browser.

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
4021
195a471c327b Updated copyright for 2015.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3991
diff changeset
3 # Copyright (c) 2008 - 2015 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 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 Module implementing the helpbrowser using QWebView.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3080
diff changeset
11 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2432
diff changeset
12 try:
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3178 3190
diff changeset
13 str = unicode
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3178 3190
diff changeset
14 except NameError:
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2432
diff changeset
15 pass
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2432
diff changeset
16
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3636
diff changeset
17 from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject, QT_TRANSLATE_NOOP, \
3776
ccb6eacb50e5 Started adding code to make eric6 usable with PyQt5 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3747
diff changeset
18 QUrl, QBuffer, QIODevice, QFileInfo, Qt, QTimer, QEvent, \
3747
2bc31e509810 Fixed an issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3734
diff changeset
19 QRect, QFile, QPoint, QByteArray, qVersion
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3636
diff changeset
20 from PyQt5.QtGui import QDesktopServices, QClipboard, QMouseEvent, QColor, \
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3636
diff changeset
21 QPalette
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3636
diff changeset
22 from PyQt5.QtWidgets import qApp, QStyle, QMenu, QApplication, QInputDialog, \
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3636
diff changeset
23 QLineEdit, QLabel, QToolTip, QFrame, QDialog
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3636
diff changeset
24 from PyQt5.QtPrintSupport import QPrinter, QPrintDialog
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3636
diff changeset
25 from PyQt5.QtWebKit import QWebSettings
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3636
diff changeset
26 from PyQt5.QtWebKitWidgets import QWebView, QWebPage
381
64ae9e09d8bc Extended the Ad-Blocker of the web browser and added capability to configure the text encoding of the web browser (needs Qt >= 4.6).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 376
diff changeset
27 try:
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3636
diff changeset
28 from PyQt5.QtWebKit import QWebElement
381
64ae9e09d8bc Extended the Ad-Blocker of the web browser and added capability to configure the text encoding of the web browser (needs Qt >= 4.6).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 376
diff changeset
29 except ImportError:
64ae9e09d8bc Extended the Ad-Blocker of the web browser and added capability to configure the text encoding of the web browser (needs Qt >= 4.6).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 376
diff changeset
30 pass
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3636
diff changeset
31 from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest
260
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
32 import sip
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
34 from E5Gui import E5MessageBox, E5FileDialog
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
35
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 import Preferences
978
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 952
diff changeset
37 import UI.PixmapCache
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
38 import Globals
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
923
e224bdbf88ad Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
40 try:
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3636
diff changeset
41 from PyQt5.QtNetwork import QSslCertificate
923
e224bdbf88ad Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
42 SSL_AVAILABLE = True
e224bdbf88ad Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
43 except ImportError:
e224bdbf88ad Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
44 SSL_AVAILABLE = False
1960
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
45
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
46 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
48
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 class JavaScriptExternalObject(QObject):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 Class implementing an external javascript object to add search providers.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
53 def __init__(self, mw, parent=None):
142
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
54 """
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
55 Constructor
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
56
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
57 @param mw reference to the main window 8HelpWindow)
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
58 @param parent reference to the parent object (QObject)
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
59 """
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
60 super(JavaScriptExternalObject, self).__init__(parent)
142
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
61
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
62 self.__mw = mw
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
63
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 @pyqtSlot(str)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 def AddSearchProvider(self, url):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 Public slot to add a search provider.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 @param url url of the XML file defining the search provider (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
826
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
71 self.__mw.openSearchManager().addEngine(QUrl(url))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
73
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 class LinkedResource(object):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 Class defining a data structure for linked resources.
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 def __init__(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.rel = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.type_ = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.href = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.title = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
87 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
89
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 class JavaScriptEricObject(QObject):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
92 Class implementing an external javascript object to search via the
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
93 startpage.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
95 # these must be in line with the strings used by the javascript part of
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
96 # the start page
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 translations = [
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
98 QT_TRANSLATE_NOOP("JavaScriptEricObject",
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
99 "Welcome to eric6 Web Browser!"),
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
100 QT_TRANSLATE_NOOP("JavaScriptEricObject", "eric6 Web Browser"),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
101 QT_TRANSLATE_NOOP("JavaScriptEricObject", "Search!"),
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
102 QT_TRANSLATE_NOOP("JavaScriptEricObject", "About eric6"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 ]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
105 def __init__(self, mw, parent=None):
142
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
106 """
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
107 Constructor
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
108
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
109 @param mw reference to the main window 8HelpWindow)
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
110 @param parent reference to the parent object (QObject)
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
111 """
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
112 super(JavaScriptEricObject, self).__init__(parent)
142
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
113
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
114 self.__mw = mw
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
115
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
116 @pyqtSlot(str, result=str)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 def translate(self, trans):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 Public method to translate the given string.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 @param trans string to be translated (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 @return translation (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 if trans == "QT_LAYOUT_DIRECTION":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 # special handling to detect layout direction
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 if qApp.isLeftToRight():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 return "LTR"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 return "RTL"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
131 return self.tr(trans)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
133 @pyqtSlot(result=str)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 def providerString(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 Public method to get a string for the search provider.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @return string for the search provider (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
140 return self.tr("Search results provided by {0}")\
142
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
141 .format(self.__mw.openSearchManager().currentEngineName())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
143 @pyqtSlot(str, result=str)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 def searchUrl(self, searchStr):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 Public method to get the search URL for the given search term.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 @param searchStr search term (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 @return search URL (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
151 return bytes(
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
152 self.__mw.openSearchManager().currentEngine()
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
153 .searchUrl(searchStr).toEncoded()).decode()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
155 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
157
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 class HelpWebPage(QWebPage):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 Class implementing an enhanced web page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 """
1651
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
162 _webPluginFactory = None
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
163
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
164 def __init__(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 @param parent parent widget of this window (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
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
170 super(HelpWebPage, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
1651
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
172 self.setPluginFactory(self.webPluginFactory())
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
173
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 self.__lastRequest = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 self.__lastRequestType = QWebPage.NavigationTypeOther
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
177 import Helpviewer.HelpWindow
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
178 from .Network.NetworkAccessManagerProxy import \
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
179 NetworkAccessManagerProxy
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 self.__proxy = NetworkAccessManagerProxy(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 self.__proxy.setWebPage(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 self.__proxy.setPrimaryNetworkAccessManager(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 Helpviewer.HelpWindow.HelpWindow.networkAccessManager())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 self.setNetworkAccessManager(self.__proxy)
656
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
185
1558
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
186 self.__sslConfiguration = None
747
48f13a14f754 Fixed a compatibility issue with latest PyQt4 snapshots.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 676
diff changeset
187 self.__proxy.finished.connect(self.__managerFinished)
1960
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
188
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
189 self.__adBlockedEntries = []
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
190 self.loadStarted.connect(self.__loadStarted)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 def acceptNavigationRequest(self, frame, request, type_):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3539
diff changeset
194 Public method to determine, if a request may be accepted.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 @param frame reference to the frame sending the request (QWebFrame)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 @param request reference to the request object (QNetworkRequest)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 @param type_ type of the navigation request (QWebPage.NavigationType)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 @return flag indicating acceptance (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 self.__lastRequest = request
1953
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
202 if self.__lastRequest.url() != request.url() or \
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
203 type_ != QWebPage.NavigationTypeOther:
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
204 self.__lastRequestType = type_
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205
757
d3daf1d8f058 Fixed the handling of 'javascript' schemes in the web browser and enhanced the download manager a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 748
diff changeset
206 scheme = request.url().scheme()
d3daf1d8f058 Fixed the handling of 'javascript' schemes in the web browser and enhanced the download manager a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 748
diff changeset
207 if scheme == "mailto":
d3daf1d8f058 Fixed the handling of 'javascript' schemes in the web browser and enhanced the download manager a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 748
diff changeset
208 QDesktopServices.openUrl(request.url())
d3daf1d8f058 Fixed the handling of 'javascript' schemes in the web browser and enhanced the download manager a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 748
diff changeset
209 return False
d3daf1d8f058 Fixed the handling of 'javascript' schemes in the web browser and enhanced the download manager a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 748
diff changeset
210
675
2f626dcab902 Added check for a form resubmission to the web page class of the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
211 if type_ == QWebPage.NavigationTypeFormResubmitted:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
212 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
213 self.view(),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
214 self.tr("Resending POST request"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
215 self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
216 """In order to display the site, the request along with"""
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
217 """ all the data must be sent once again, which may lead"""
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
218 """ to some unexpected behaviour of the site e.g. the"""
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
219 """ same action might be performed once again. Do you"""
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
220 """ want to continue anyway?"""),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
221 icon=E5MessageBox.Warning)
675
2f626dcab902 Added check for a form resubmission to the web page class of the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
222 if not res:
2f626dcab902 Added check for a form resubmission to the web page class of the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
223 return False
2f626dcab902 Added check for a form resubmission to the web page class of the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 668
diff changeset
224
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 return QWebPage.acceptNavigationRequest(self, frame, request, type_)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 def populateNetworkRequest(self, request):
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 to add data to a network request.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
231 @param request reference to the network request object
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
232 (QNetworkRequest)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 """
1593
470b03ae90e7 A fix for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1588
diff changeset
234 try:
470b03ae90e7 A fix for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1588
diff changeset
235 request.setAttribute(QNetworkRequest.User + 100, self)
1953
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
236 if self.__lastRequest.url() == request.url():
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
237 request.setAttribute(QNetworkRequest.User + 101,
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
238 self.__lastRequestType)
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
239 if self.__lastRequestType == \
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
240 QWebPage.NavigationTypeLinkClicked:
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
241 request.setRawHeader("X-Eric6-UserLoadAction",
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
242 QByteArray("1"))
1593
470b03ae90e7 A fix for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1588
diff changeset
243 except TypeError:
470b03ae90e7 A fix for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1588
diff changeset
244 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 def pageAttributeId(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 Public method to get the attribute id of the page attribute.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 @return attribute id of the page attribute (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 return QNetworkRequest.User + 100
260
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
253
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
254 def supportsExtension(self, extension):
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
255 """
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
256 Public method to check the support for an extension.
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
257
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
258 @param extension extension to test for (QWebPage.Extension)
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
259 @return flag indicating the support of extension (boolean)
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
260 """
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
261 try:
1952
af4103f0e93f Fixed an issue in HelpBrowserWV.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1950
diff changeset
262 if extension in [QWebPage.ErrorPageExtension,
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
263 QWebPage.ChooseMultipleFilesExtension]:
260
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
264 return True
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
265 except AttributeError:
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
266 pass
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
267
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
268 return QWebPage.supportsExtension(self, extension)
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
269
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
270 def extension(self, extension, option, output):
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
271 """
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
272 Public method to implement a specific extension.
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
273
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
274 @param extension extension to be executed (QWebPage.Extension)
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
275 @param option provides input to the extension
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
276 (QWebPage.ExtensionOption)
260
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
277 @param output stores the output results (QWebPage.ExtensionReturn)
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
278 @return flag indicating a successful call of the extension (boolean)
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
279 """
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
280 if extension == QWebPage.ChooseMultipleFilesExtension:
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
281 info = sip.cast(option,
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
282 QWebPage.ChooseMultipleFilesExtensionOption)
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
283 files = sip.cast(output,
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
284 QWebPage.ChooseMultipleFilesExtensionReturn)
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
285 if info is None or files is None:
3065
070b35dde35e Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
286 return super(HelpWebPage, self).extension(
070b35dde35e Fixed a bunch of indentation issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
287 extension, option, output)
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
288
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
289 suggestedFileName = ""
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
290 if info.suggestedFileNames:
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
291 suggestedFileName = info.suggestedFileNames[0]
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
292
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
293 files.fileNames = E5FileDialog.getOpenFileNames(
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
294 None,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
295 self.tr("Select files to upload..."),
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
296 suggestedFileName)
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
297 return True
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
298
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
299 if extension == QWebPage.ErrorPageExtension:
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
300 info = sip.cast(option, QWebPage.ErrorPageExtensionOption)
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
301
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
302 errorPage = sip.cast(output, QWebPage.ErrorPageExtensionReturn)
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
303 urlString = bytes(info.url.toEncoded()).decode()
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
304 errorPage.baseUrl = info.url
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
305 if info.domain == QWebPage.QtNetwork and \
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
306 info.error == QNetworkReply.ContentAccessDenied and \
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
307 info.errorString.startswith("AdBlockRule:"):
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
308 if info.frame != info.frame.page().mainFrame():
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
309 # content in <iframe>
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
310 docElement = info.frame.page().mainFrame()\
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
311 .documentElement()
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
312 for element in docElement.findAll("iframe"):
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
313 src = element.attribute("src")
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
314 if src in info.url.toString():
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
315 element.setAttribute("style", "display:none;")
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 641
diff changeset
316 return False
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
317 else:
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
318 # the whole page is blocked
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
319 rule = info.errorString.replace("AdBlockRule:", "")
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
320 title = self.tr("Content blocked by AdBlock Plus")
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
321 message = self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
322 "Blocked by rule: <i>{0}</i>").format(rule)
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
323
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
324 htmlFile = QFile(":/html/adblockPage.html")
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
325 htmlFile.open(QFile.ReadOnly)
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
326 html = htmlFile.readAll()
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
327 html = html.replace(
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
328 "@FAVICON@", "qrc:icons/adBlockPlus16.png")
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
329 html = html.replace(
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
330 "@IMAGE@", "qrc:icons/adBlockPlus64.png")
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
331 html = html.replace("@TITLE@", title.encode("utf8"))
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
332 html = html.replace("@MESSAGE@", message.encode("utf8"))
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
333 errorPage.content = html
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
334 return True
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
335
1950
4f004ec74b48 Fixed issues in the AdBlock code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1947
diff changeset
336 if info.domain == QWebPage.QtNetwork and \
4f004ec74b48 Fixed issues in the AdBlock code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1947
diff changeset
337 info.error == QNetworkReply.OperationCanceledError and \
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
338 info.errorString == "eric6:No Error":
1950
4f004ec74b48 Fixed issues in the AdBlock code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1947
diff changeset
339 return False
4f004ec74b48 Fixed issues in the AdBlock code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1947
diff changeset
340
3633
869c7cb9dc15 Added code to intercept the WebKit error 102 'Loading is handled by the media engine' in the web page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
341 if info.domain == QWebPage.WebKit and info.error == 203:
869c7cb9dc15 Added code to intercept the WebKit error 102 'Loading is handled by the media engine' in the web page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
342 # "Loading is handled by the media engine"
869c7cb9dc15 Added code to intercept the WebKit error 102 'Loading is handled by the media engine' in the web page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
343 return False
869c7cb9dc15 Added code to intercept the WebKit error 102 'Loading is handled by the media engine' in the web page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
344
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
345 title = self.tr("Error loading page: {0}").format(urlString)
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
346 htmlFile = QFile(":/html/notFoundPage.html")
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
347 htmlFile.open(QFile.ReadOnly)
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
348 html = htmlFile.readAll()
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
349 pixmap = qApp.style()\
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
350 .standardIcon(QStyle.SP_MessageBoxWarning).pixmap(48, 48)
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
351 imageBuffer = QBuffer()
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
352 imageBuffer.open(QIODevice.ReadWrite)
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
353 if pixmap.save(imageBuffer, "PNG"):
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
354 html = html.replace("@IMAGE@", imageBuffer.buffer().toBase64())
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
355 pixmap = qApp.style()\
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
356 .standardIcon(QStyle.SP_MessageBoxWarning).pixmap(16, 16)
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
357 imageBuffer = QBuffer()
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
358 imageBuffer.open(QIODevice.ReadWrite)
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
359 if pixmap.save(imageBuffer, "PNG"):
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
360 html = html.replace(
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
361 "@FAVICON@", imageBuffer.buffer().toBase64())
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
362 html = html.replace("@TITLE@", title.encode("utf8"))
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
363 html = html.replace("@H1@", info.errorString.encode("utf8"))
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
364 html = html.replace(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
365 "@H2@", self.tr("When connecting to: {0}.")
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
366 .format(urlString).encode("utf8"))
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
367 html = html.replace(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
368 "@LI-1@",
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
369 self.tr("Check the address for errors such as "
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
370 "<b>ww</b>.example.org instead of "
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
371 "<b>www</b>.example.org").encode("utf8"))
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
372 html = html.replace(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
373 "@LI-2@",
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
374 self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
375 "If the address is correct, try checking the network "
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
376 "connection.").encode("utf8"))
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
377 html = html.replace(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
378 "@LI-3@",
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
379 self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
380 "If your computer or network is protected by a firewall "
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
381 "or proxy, make sure that the browser is permitted to "
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
382 "access the network.").encode("utf8"))
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
383 html = html.replace(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
384 "@LI-4@",
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
385 self.tr("If your cache policy is set to offline browsing,"
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
386 "only pages in the local cache are available.")
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
387 .encode("utf8"))
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
388 html = html.replace(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
389 "@BUTTON@", self.tr("Try Again").encode("utf8"))
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
390 errorPage.content = html
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
391 return True
260
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
392
21f7999b7abe Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 256
diff changeset
393 return QWebPage.extension(self, extension, option, output)
383
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
394
1960
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
395 def __loadStarted(self):
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
396 """
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
397 Private method to handle the loadStarted signal.
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
398 """
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
399 self.__adBlockedEntries = []
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
400
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
401 def addAdBlockRule(self, rule, url):
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
402 """
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
403 Public slot to add an AdBlock rule to the page.
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
404
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
405 @param rule AdBlock rule to add (AdBlockRule)
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
406 @param url URL that matched the rule (QUrl)
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
407 """
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
408 from .AdBlock.AdBlockPage import AdBlockedPageEntry
1960
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
409 entry = AdBlockedPageEntry(rule, url)
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
410 if entry not in self.__adBlockedEntries:
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
411 self.__adBlockedEntries.append(entry)
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
412
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
413 def getAdBlockedPageEntries(self):
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
414 """
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
415 Public method to get the list of AdBlock page entries.
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
416
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
417 @return list of AdBlock page entries (list of AdBlockedPageEntry)
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
418 """
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
419 return self.__adBlockedEntries
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
420
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
421 def url(self):
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
422 """
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
423 Public method to get the URL of the page.
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
424
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
425 @return URL of the page (QUrl)
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
426 """
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
427 return self.mainFrame().url()
d8c45fe8a1b9 Reworked some of the AdBlock code to achieve some speed improvements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1953
diff changeset
428
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
429 def userAgent(self, resolveEmpty=False):
383
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
430 """
1596
8d59e4f3c828 Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1593
diff changeset
431 Public method to get the global user agent setting.
383
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
432
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
433 @param resolveEmpty flag indicating to resolve an empty
383
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
434 user agent (boolean)
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
435 @return user agent string (string)
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
436 """
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
437 agent = Preferences.getHelp("UserAgent")
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
438 if agent == "" and resolveEmpty:
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
439 agent = self.userAgentForUrl(QUrl())
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
440 return agent
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
441
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
442 def setUserAgent(self, agent):
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
443 """
1596
8d59e4f3c828 Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1593
diff changeset
444 Public method to set the global user agent string.
383
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
445
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
446 @param agent new current user agent string (string)
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
447 """
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
448 Preferences.setHelp("UserAgent", agent)
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
449
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
450 def userAgentForUrl(self, url):
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
451 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3539
diff changeset
452 Public method to determine the user agent for the given URL.
383
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
453
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
454 @param url URL to determine user agent for (QUrl)
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
455 @return user agent string (string)
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
456 """
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
457 import Helpviewer.HelpWindow
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
458 agent = Helpviewer.HelpWindow.HelpWindow.userAgentsManager()\
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
459 .userAgentForUrl(url)
383
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
460 if agent == "":
1596
8d59e4f3c828 Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1593
diff changeset
461 # no agent string specified for the given host -> use global one
8d59e4f3c828 Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1593
diff changeset
462 agent = Preferences.getHelp("UserAgent")
8d59e4f3c828 Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1593
diff changeset
463 if agent == "":
8d59e4f3c828 Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1593
diff changeset
464 # no global agent string specified -> use default one
8d59e4f3c828 Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1593
diff changeset
465 agent = QWebPage.userAgentForUrl(self, url)
383
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
466 return agent
656
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
467
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
468 def __managerFinished(self, reply):
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
469 """
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
470 Private slot to handle a finished reply.
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
471
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
472 This slot is used to get SSL related information for a reply.
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
473
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
474 @param reply reference to the finished reply (QNetworkReply)
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
475 """
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
476 try:
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
477 frame = reply.request().originatingObject()
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
478 except AttributeError:
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
479 frame = None
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
480
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
481 mainFrameRequest = frame == self.mainFrame()
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
482
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
483 if mainFrameRequest and \
1558
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
484 self.__sslConfiguration is not None and \
657
099d1ab9073e Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 656
diff changeset
485 reply.url() == self.mainFrame().url():
1558
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
486 self.__sslConfiguration = None
656
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
487
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
488 if reply.error() == QNetworkReply.NoError and \
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
489 mainFrameRequest and \
1558
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
490 self.__sslConfiguration is None and \
657
099d1ab9073e Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 656
diff changeset
491 reply.url().scheme().lower() == "https" and \
099d1ab9073e Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 656
diff changeset
492 reply.url() == self.mainFrame().url():
1558
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
493 self.__sslConfiguration = reply.sslConfiguration()
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
494 self.__sslConfiguration.url = QUrl(reply.url())
1731
56cf9c150dbf Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
495
56cf9c150dbf Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
496 if reply.error() == QNetworkReply.NoError and \
56cf9c150dbf Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
497 mainFrameRequest and \
56cf9c150dbf Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
498 reply.url() == self.mainFrame().url():
56cf9c150dbf Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
499 modified = reply.header(QNetworkRequest.LastModifiedHeader)
56cf9c150dbf Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
500 if modified and modified.isValid():
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
501 import Helpviewer.HelpWindow
1731
56cf9c150dbf Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
502 manager = Helpviewer.HelpWindow.HelpWindow.bookmarksManager()
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
503 from .Bookmarks.BookmarkNode import BookmarkNode
1731
56cf9c150dbf Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
504 for bookmark in manager.bookmarksForUrl(reply.url()):
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
505 manager.setTimestamp(bookmark, BookmarkNode.TsModified,
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
506 modified)
656
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
507
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
508 def getSslCertificate(self):
656
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
509 """
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
510 Public method to get a reference to the SSL certificate.
656
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
511
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
512 @return amended SSL certificate (QSslCertificate)
657
099d1ab9073e Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 656
diff changeset
513 """
1561
fe54c9df80e8 Fixed an issue with the latest browser changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1558
diff changeset
514 if self.__sslConfiguration is None:
fe54c9df80e8 Fixed an issue with the latest browser changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1558
diff changeset
515 return None
fe54c9df80e8 Fixed an issue with the latest browser changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1558
diff changeset
516
1558
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
517 sslInfo = self.__sslConfiguration.peerCertificate()
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
518 sslInfo.url = QUrl(self.__sslConfiguration.url)
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
519 return sslInfo
658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 657
diff changeset
520
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
521 def getSslCertificateChain(self):
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
522 """
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
523 Public method to get a reference to the SSL certificate chain.
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
524
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
525 @return SSL certificate chain (list of QSslCertificate)
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
526 """
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
527 if self.__sslConfiguration is None:
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
528 return []
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
529
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
530 chain = self.__sslConfiguration.peerCertificateChain()
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
531 return chain
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
532
2585
242d6d991ca1 Changed the SSL label to indicate an unencrypted connection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
533 def getSslConfiguration(self):
242d6d991ca1 Changed the SSL label to indicate an unencrypted connection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
534 """
242d6d991ca1 Changed the SSL label to indicate an unencrypted connection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
535 Public method to return a reference to the current SSL configuration.
242d6d991ca1 Changed the SSL label to indicate an unencrypted connection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
536
242d6d991ca1 Changed the SSL label to indicate an unencrypted connection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
537 @return reference to the SSL configuration in use (QSslConfiguration)
242d6d991ca1 Changed the SSL label to indicate an unencrypted connection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
538 """
242d6d991ca1 Changed the SSL label to indicate an unencrypted connection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
539 return self.__sslConfiguration
242d6d991ca1 Changed the SSL label to indicate an unencrypted connection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
540
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
541 def showSslInfo(self, pos):
658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 657
diff changeset
542 """
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 657
diff changeset
543 Public slot to show some SSL information for the loaded page.
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2585
diff changeset
544
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2585
diff changeset
545 @param pos position to show the info at (QPoint)
658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 657
diff changeset
546 """
1558
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
547 if SSL_AVAILABLE and self.__sslConfiguration is not None:
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
548 from E5Network.E5SslInfoWidget import E5SslInfoWidget
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
549 widget = E5SslInfoWidget(
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
550 self.mainFrame().url(), self.__sslConfiguration, self.view())
2432
b1a2f9054b28 Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
551 widget.showAt(pos)
664
3061f8bd826e Fixed a few issues on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 661
diff changeset
552 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
553 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
554 self.view(),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
555 self.tr("SSL Info"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
556 self.tr("""This site does not contain SSL information."""))
1558
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
557
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
558 def hasValidSslInfo(self):
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
559 """
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
560 Public method to check, if the page has a valid SSL certificate.
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
561
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
562 @return flag indicating a valid SSL certificate (boolean)
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
563 """
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
564 if self.__sslConfiguration is None:
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
565 return False
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
566
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
567 certList = self.__sslConfiguration.peerCertificateChain()
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
568 if not certList:
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
569 return False
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
570
4241
545629046c45 Fixed a bug in the message filter causing a traceback when no message filters are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
571 certificateDict = Globals.toDict(
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
572 Preferences.Prefs.settings.value("Ssl/CaCertificatesDict"))
1558
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
573 for server in certificateDict:
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
574 localCAList = QSslCertificate.fromData(certificateDict[server])
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
575 for cert in certList:
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
576 if cert in localCAList:
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
577 return True
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
578
2078
9f4a45741622 Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1970
diff changeset
579 if qVersion() >= "5.0.0":
9f4a45741622 Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1970
diff changeset
580 for cert in certList:
9f4a45741622 Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1970
diff changeset
581 if cert.isBlacklisted():
9f4a45741622 Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1970
diff changeset
582 return False
9f4a45741622 Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1970
diff changeset
583 else:
9f4a45741622 Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1970
diff changeset
584 for cert in certList:
9f4a45741622 Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1970
diff changeset
585 if not cert.isValid():
9f4a45741622 Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1970
diff changeset
586 return False
1558
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
587
754120837dd8 Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1518
diff changeset
588 return True
1651
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
589
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
590 @classmethod
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
591 def webPluginFactory(cls):
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
592 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3539
diff changeset
593 Class method to get a reference to the web plug-in factory
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3539
diff changeset
594 instance.
1651
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
595
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
596 @return reference to the web plug-in factory instance (WebPluginFactory
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
597 """
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
598 if cls._webPluginFactory is None:
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
599 from .WebPlugins.WebPluginFactory import WebPluginFactory
1651
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
600 cls._webPluginFactory = WebPluginFactory()
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
601
bc68f24d5658 Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1647
diff changeset
602 return cls._webPluginFactory
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
603
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
604 def event(self, evt):
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
605 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3539
diff changeset
606 Public method implementing the event handler.
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
607
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
608 @param evt reference to the event (QEvent)
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
609 @return flag indicating that the event was handled (boolean)
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
610 """
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
611 if evt.type() == QEvent.Leave:
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
612 # Fake a mouse move event just outside of the widget to trigger
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
613 # the WebKit event handler's mouseMoved function. This implements
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
614 # the interesting mouse-out behavior like invalidating scrollbars.
2127
6a7e4fb5e07e Reverted the QMouseEvent change due to corrections in PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2107
diff changeset
615 fakeEvent = QMouseEvent(QEvent.MouseMove, QPoint(0, -1),
6a7e4fb5e07e Reverted the QMouseEvent change due to corrections in PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2107
diff changeset
616 Qt.NoButton, Qt.NoButton, Qt.NoModifier)
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
617 return super(HelpWebPage, self).event(fakeEvent)
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
618
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
619 return super(HelpWebPage, self).event(evt)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
621 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
623
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624 class HelpBrowser(QWebView):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
625 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626 Class implementing the helpbrowser widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628 This is a subclass of the Qt QWebView to implement an
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 interface compatible with the QTextBrowser based variant.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630
501
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 487
diff changeset
631 @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
632 @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
633 @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
634 @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
635 @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
636 @signal zoomValueChanged(int) emitted to signal a change of the zoom value
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 """
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
638 sourceChanged = pyqtSignal(QUrl)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
639 forwardAvailable = pyqtSignal(bool)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
640 backwardAvailable = pyqtSignal(bool)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
641 highlighted = pyqtSignal(str)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
642 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
643 zoomValueChanged = pyqtSignal(int)
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
644
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
645 ZoomLevels = [
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
646 30, 50, 67, 80, 90,
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
647 100,
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
648 110, 120, 133, 150, 170, 200, 240, 300,
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
649 ]
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
650 ZoomLevelDefault = 100
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
651
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
652 def __init__(self, mainWindow, parent=None, name=""):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 634
diff changeset
656 @param mainWindow reference to the main window (HelpWindow)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657 @param parent parent widget of this window (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 @param name name of this window (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 """
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
660 super(HelpBrowser, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 self.setObjectName(name)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
662 self.setWhatsThis(self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
663 """<b>Help Window</b>"""
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
664 """<p>This window displays the selected help information.</p>"""
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665 ))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
666
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2359
diff changeset
667 import Helpviewer.HelpWindow
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1665
diff changeset
668 self.__speedDial = Helpviewer.HelpWindow.HelpWindow.speedDial()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1665
diff changeset
669
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670 self.__page = HelpWebPage(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671 self.setPage(self.__page)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
672
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 634
diff changeset
673 self.mw = mainWindow
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
674 self.ctrlPressed = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
675 self.__isLoading = False
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 629
diff changeset
676 self.__progress = 0
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
677
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
678 self.__currentZoom = 100
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
679 self.__zoomLevels = HelpBrowser.ZoomLevels[:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
680
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
681 self.__javaScriptBinding = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
682 self.__javaScriptEricObject = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
683
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
684 self.mw.zoomTextOnlyChanged.connect(self.__applyZoom)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
685
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
686 self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
687 self.linkClicked.connect(self.setSource)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
688
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
689 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
690 self.statusBarMessage.connect(self.__statusBarMessage)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
691 self.page().linkHovered.connect(self.__linkHovered)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
693 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
694 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
695 self.loadFinished.connect(self.__loadFinished)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
697 self.page().setForwardUnsupportedContent(True)
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
698 self.page().unsupportedContent.connect(self.__unsupportedContent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
699
4316
493891cbacee Added support for feature permissions to the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4275
diff changeset
700 self.__featurePermissionBar = None
493891cbacee Added support for feature permissions to the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4275
diff changeset
701 self.page().featurePermissionRequested.connect(
493891cbacee Added support for feature permissions to the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4275
diff changeset
702 self.__featurePermissionRequested)
493891cbacee Added support for feature permissions to the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4275
diff changeset
703 # discard the feature bar on new loads (if we navigate away or reload)
493891cbacee Added support for feature permissions to the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4275
diff changeset
704 self.page().loadStarted.connect(self.__featurePermissionBarDelete)
493891cbacee Added support for feature permissions to the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4275
diff changeset
705
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
706 self.page().downloadRequested.connect(self.__downloadRequested)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
707 self.page().frameCreated.connect(self.__addExternalBinding)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
708 self.__addExternalBinding(self.page().mainFrame())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
709
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
710 self.page().databaseQuotaExceeded.connect(self.__databaseQuotaExceeded)
350
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
711
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
712 self.mw.openSearchManager().currentEngineChanged.connect(
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
713 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
714
cc3e2e5558e9 Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
715 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
716
1947
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
717 self.__enableAccessKeys = Preferences.getHelp("AccessKeysEnabled")
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
718 self.__accessKeysPressed = False
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
719 self.__accessKeyLabels = []
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
720 self.__accessKeyNodes = {}
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
721
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
722 self.page().loadStarted.connect(self.__hideAccessKeys)
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
723 self.page().scrollRequested.connect(self.__hideAccessKeys)
1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1232
diff changeset
724
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1232
diff changeset
725 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
726
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
727 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
728
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
729 self.mw.personalInformationManager().connectPage(self.page())
1953
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
730 self.mw.greaseMonkeyManager().connectPage(self.page())
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
731
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
732 self.grabGesture(Qt.PinchGesture)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
734 def __addExternalBinding(self, frame=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 Private slot to add javascript bindings for adding search providers.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
737
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 @param frame reference to the web frame (QWebFrame)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739 """
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
740 self.page().settings().setAttribute(QWebSettings.JavascriptEnabled,
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
741 True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 if self.__javaScriptBinding is None:
142
94ce651735db Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
743 self.__javaScriptBinding = JavaScriptExternalObject(self.mw, self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
744
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
745 if frame is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746 # called from QWebFrame.javaScriptWindowObjectCleared
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 frame = self.sender()
1584
38c0907eeea1 A little fix for the help browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1561
diff changeset
748 if isinstance(frame, HelpWebPage):
38c0907eeea1 A little fix for the help browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1561
diff changeset
749 frame = frame.mainFrame()
1665
b248526d3a1b Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1651
diff changeset
750 if frame.url().scheme() == "eric" and frame.url().path() == "home":
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751 if self.__javaScriptEricObject is None:
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
752 self.__javaScriptEricObject = JavaScriptEricObject(
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
753 self.mw, self)
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
754 frame.addToJavaScriptWindowObject(
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
755 "eric", self.__javaScriptEricObject)
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
756 elif frame.url().scheme() == "eric" and \
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
757 frame.url().path() == "speeddial":
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
758 frame.addToJavaScriptWindowObject(
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
759 "speeddial", self.__speedDial)
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1665
diff changeset
760 self.__speedDial.addWebFrame(frame)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762 # called from QWebPage.frameCreated
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
763 frame.javaScriptWindowObjectCleared.connect(
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
764 self.__addExternalBinding)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
765 frame.addToJavaScriptWindowObject("external", self.__javaScriptBinding)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
767 def linkedResources(self, relation=""):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
769 Public method to extract linked resources.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
770
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
771 @param relation relation to extract (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772 @return list of linked resources (list of LinkedResource)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
773 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
774 resources = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775
1947
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
776 baseUrl = self.page().mainFrame().baseUrl()
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
777
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
778 linkElements = self.page().mainFrame().findAllElements(
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
779 "html > head > link")
1947
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
780
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
781 for linkElement in linkElements.toList():
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
782 rel = linkElement.attribute("rel")
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
783 href = linkElement.attribute("href")
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
784 type_ = linkElement.attribute("type")
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
785 title = linkElement.attribute("title")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
786
1947
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
787 if href == "" or type_ == "":
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
788 continue
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
789 if relation and rel != relation:
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
790 continue
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
791
1947
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
792 resource = LinkedResource()
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
793 resource.rel = rel
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
794 resource.type_ = type_
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
795 resource.href = baseUrl.resolved(QUrl.fromEncoded(href))
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
796 resource.title = title
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
797
84626f18f2c3 Simplified the code a little bit by deleting the checks for the existance of QWebElement because Qt 4.7 is the minimum requirement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1945
diff changeset
798 resources.append(resource)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 return resources
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 def __currentEngineChanged(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 Private slot to track a change of the current search engine.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805 """
1665
b248526d3a1b Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1651
diff changeset
806 if self.url().toString() == "eric:home":
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
807 self.reload()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808
1953
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
809 def setSource(self, name, requestData=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811 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
812
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
813 @param name filename to be shown (QUrl)
1953
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
814 @param requestData tuple containing the request data (QNetworkRequest,
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
815 QNetworkAccessManager.Operation, QByteArray)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816 """
1953
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
817 if (name is None or not name.isValid()) and requestData is None:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
818 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
819
1953
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
820 if name is None and requestData is not None:
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
821 name = requestData[0].url()
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
822
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823 if self.ctrlPressed:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
824 # open in a new window
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 self.mw.newTab(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826 self.ctrlPressed = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
827 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829 if not name.scheme():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830 name.setUrl(Preferences.getHelp("DefaultScheme") + name.toString())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 if len(name.scheme()) == 1 or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
833 name.scheme() == "file":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
834 # name is a local file
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 if name.scheme() and len(name.scheme()) == 1:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
836 # it is a local path on win os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
837 name = QUrl.fromLocalFile(name.toString())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
838
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
839 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
840 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
841 self,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
842 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
843 self.tr(
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
844 """<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
845 .format(name.toLocalFile()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
847
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848 if name.toLocalFile().endswith(".pdf") or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
849 name.toLocalFile().endswith(".PDF") or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
850 name.toLocalFile().endswith(".chm") or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851 name.toLocalFile().endswith(".CHM"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852 started = QDesktopServices.openUrl(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 if not started:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
854 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
855 self,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
856 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
857 self.tr(
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
858 """<p>Could not start a viewer"""
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
859 """ for file <b>{0}</b>.</p>""")
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
860 .format(name.path()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 return
278
c93823b96faa Added a handler for ftp: URLs to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 260
diff changeset
862 elif name.scheme() in ["mailto"]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863 started = QDesktopServices.openUrl(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
864 if not started:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
865 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
866 self,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
867 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
868 self.tr(
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
869 """<p>Could not start an application"""
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
870 """ for URL <b>{0}</b>.</p>""")
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
871 .format(name.toString()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
873 elif name.scheme() == "javascript":
2107
1690f30db6f3 Reverted the "ComponentFormattingOptions" changes done for Qt5 because PyQt4 has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2094
diff changeset
874 scriptSource = QUrl.fromPercentEncoding(name.toString(
1690f30db6f3 Reverted the "ComponentFormattingOptions" changes done for Qt5 because PyQt4 has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2094
diff changeset
875 QUrl.FormattingOptions(QUrl.TolerantMode | QUrl.RemoveScheme)))
757
d3daf1d8f058 Fixed the handling of 'javascript' schemes in the web browser and enhanced the download manager a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 748
diff changeset
876 self.page().mainFrame().evaluateJavaScript(scriptSource)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
878 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879 if name.toString().endswith(".pdf") or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
880 name.toString().endswith(".PDF") or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
881 name.toString().endswith(".chm") or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
882 name.toString().endswith(".CHM"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
883 started = QDesktopServices.openUrl(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
884 if not started:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
885 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
886 self,
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
887 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
888 self.tr(
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
889 """<p>Could not start a viewer"""
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
890 """ for file <b>{0}</b>.</p>""")
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
891 .format(name.path()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
892 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
893
1953
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
894 if requestData is not None:
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
895 self.load(*requestData)
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
896 else:
26aa6fd94dc2 Added support for GreaseMonkey scripts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1952
diff changeset
897 self.load(name)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
898
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
899 def source(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
900 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
901 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
902
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
903 @return URL loaded in the help browser (QUrl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
904 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
905 return self.url()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
906
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
907 def documentTitle(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
908 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
909 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
910
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
911 @return title (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
912 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
913 return self.title()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
914
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
915 def backward(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
916 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
917 Public slot to move backwards in history.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
918 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
919 self.triggerPageAction(QWebPage.Back)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
920 self.__urlChanged(self.history().currentItem().url())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
921
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
922 def forward(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
923 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
924 Public slot to move forward in history.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
925 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
926 self.triggerPageAction(QWebPage.Forward)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
927 self.__urlChanged(self.history().currentItem().url())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
928
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
929 def home(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
930 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
931 Public slot to move to the first page loaded.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
932 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
933 homeUrl = QUrl(Preferences.getHelp("HomePage"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
934 self.setSource(homeUrl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
935 self.__urlChanged(self.history().currentItem().url())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
936
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
937 def reload(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
938 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
939 Public slot to reload the current page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
940 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
941 self.triggerPageAction(QWebPage.Reload)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
942
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
943 def copy(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
944 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
945 Public slot to copy the selected text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
946 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
947 self.triggerPageAction(QWebPage.Copy)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
948
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
949 def isForwardAvailable(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
950 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
951 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
952
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
953 @return flag indicating move forward is possible (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
954 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
955 return self.history().canGoForward()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
956
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
957 def isBackwardAvailable(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
959 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
960
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
961 @return flag indicating move backwards is possible (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
962 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963 return self.history().canGoBack()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
964
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
965 def __levelForZoom(self, zoom):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
967 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
968
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
969 @param zoom zoom factor (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
970 @return index of zoom factor (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
971 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
972 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
973 index = self.__zoomLevels.index(zoom)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
974 except ValueError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
975 for index in range(len(self.__zoomLevels)):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 if zoom <= self.__zoomLevels[index]:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
977 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
978 return index
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
979
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
980 def __applyZoom(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
981 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
982 Private slot to apply the current zoom factor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
983 """
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
984 self.setZoomValue(self.__currentZoom)
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
985
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
986 def setZoomValue(self, value):
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
987 """
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
988 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
989
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
990 @param value 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
991 """
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
992 if value != self.zoomValue():
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
993 try:
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
994 self.setZoomFactor(value / 100.0)
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
995 except AttributeError:
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
996 self.setTextSizeMultiplier(value / 100.0)
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
997 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
998
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
999 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
1000 """
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1001 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
1002
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1003 @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
1004 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1005 try:
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1006 val = self.zoomFactor() * 100
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1007 except AttributeError:
2334
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1008 val = self.textSizeMultiplier() * 100
fc69ad77e18a Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1009 return int(val)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1010
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1011 def zoomIn(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1012 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1013 Public slot to zoom into the page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1014 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1015 index = self.__levelForZoom(self.__currentZoom)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1016 if index < len(self.__zoomLevels) - 1:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1017 self.__currentZoom = self.__zoomLevels[index + 1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1018 self.__applyZoom()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1019
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1020 def zoomOut(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1021 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1022 Public slot to zoom out of the page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1023 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1024 index = self.__levelForZoom(self.__currentZoom)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1025 if index > 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1026 self.__currentZoom = self.__zoomLevels[index - 1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1027 self.__applyZoom()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 923
diff changeset
1029 def zoomReset(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1030 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1031 Public method to reset the zoom factor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1032 """
4275
3bed5f74d328 Fixed an issue in the web browser causing a traceback when resetting the zoom factor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
1033 index = self.__levelForZoom(HelpBrowser.ZoomLevelDefault)
3bed5f74d328 Fixed an issue in the web browser causing a traceback when resetting the zoom factor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4241
diff changeset
1034 self.__currentZoom = self.__zoomLevels[index]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1035 self.__applyZoom()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1036
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1037 def hasSelection(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1038 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1039 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
1040
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1041 @return flag indicating text has been selected (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1042 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1043 return self.selectedText() != ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1044
376
0c4c359c4870 Added option to highlight all occurences to the web browser search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 350
diff changeset
1045 def findNextPrev(self, txt, case, backwards, wrap, highlightAll):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1046 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1047 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
1048
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1049 @param txt text to search for (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1050 @param case flag indicating a case sensitive search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1051 @param backwards flag indicating a backwards search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1052 @param wrap flag indicating to wrap around (boolean)
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
1053 @param highlightAll flag indicating to highlight all occurrences
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
1054 (boolean)
1823
21d988eaf1bf Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1733
diff changeset
1055 @return flag indicating that a match was found (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1056 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1057 findFlags = QWebPage.FindFlags()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1058 if case:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1059 findFlags |= QWebPage.FindCaseSensitively
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1060 if backwards:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1061 findFlags |= QWebPage.FindBackward
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1062 if wrap:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1063 findFlags |= QWebPage.FindWrapsAroundDocument
376
0c4c359c4870 Added option to highlight all occurences to the web browser search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 350
diff changeset
1064 try:
0c4c359c4870 Added option to highlight all occurences to the web browser search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 350
diff changeset
1065 if highlightAll:
0c4c359c4870 Added option to highlight all occurences to the web browser search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 350
diff changeset
1066 findFlags |= QWebPage.HighlightAllOccurrences
0c4c359c4870 Added option to highlight all occurences to the web browser search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 350
diff changeset
1067 except AttributeError:
0c4c359c4870 Added option to highlight all occurences to the web browser search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 350
diff changeset
1068 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1069
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1070 return self.findText(txt, findFlags)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1071
1934
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
1072 def __isMediaElement(self, element):
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
1073 """
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
1074 Private method to check, if the given element is a media element.
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
1075
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
1076 @param element element to be checked (QWebElement)
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
1077 @return flag indicating a media element (boolean)
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
1078 """
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
1079 return element.tagName().lower() in ["video", "audio"]
ad6b7c30fb9f Added context menu entries for HTML5 media elements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1823
diff changeset
1080
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1081 def contextMenuEvent(self, evt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1082 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1083 Protected method called to create a context menu.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1084
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1085 This method is overridden from QWebView.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1086