Helpviewer/HelpBrowserWV.py

Thu, 03 Mar 2011 18:58:30 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 03 Mar 2011 18:58:30 +0100
changeset 923
e224bdbf88ad
parent 826
2e3e2055e715
child 945
8cd4d08fa9f6
child 1510
e75ecf2bd9dd
permissions
-rw-r--r--

Fixed an issue related to the non-availability of SSL.

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
791
9ec2ac20e54e Updated copyright notice.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 757
diff changeset
3 # Copyright (c) 2008 - 2011 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
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt4.QtCore import *
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt4.QtGui import *
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
13 from PyQt4 import QtWebKit
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from PyQt4.QtWebKit import QWebView, QWebPage, QWebSettings
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
15 try:
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
16 from PyQt4.QtWebKit import QWebElement
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
17 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
18 pass
96
9624a110667d Started to clean up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 38
diff changeset
19 from PyQt4.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
20 import sip
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
22 from E5Gui import E5MessageBox
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
23
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 import Preferences
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
26 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
27 from .JavaScriptResources import fetchLinks_js
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
28 from .HTMLResources import notFoundPage_html
923
e224bdbf88ad Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
29 try:
e224bdbf88ad Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
30 from .SslInfoDialog import SslInfoDialog
e224bdbf88ad Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
31 SSL_AVAILABLE = True
e224bdbf88ad Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
32 except ImportError:
e224bdbf88ad Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
33 SSL_AVAILABLE = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 import Helpviewer.HelpWindow
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
36 from .Network.NetworkAccessManagerProxy import NetworkAccessManagerProxy
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
38 from .OpenSearch.OpenSearchEngineAction import OpenSearchEngineAction
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
39 from .OpenSearch.OpenSearchEngine import OpenSearchEngine
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 ##########################################################################################
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 class JavaScriptExternalObject(QObject):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 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
46 """
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
47 def __init__(self, mw, parent = None):
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
48 """
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
49 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
50
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
51 @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
52 @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
53 """
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 QObject.__init__(self, parent)
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
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 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
57
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @pyqtSlot(str)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 def AddSearchProvider(self, url):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 Public slot to add a search provider.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 @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
64 """
826
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
65 self.__mw.openSearchManager().addEngine(QUrl(url))
0
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 class LinkedResource(object):
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 Class defining a data structure for linked resources.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 def __init__(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.rel = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.type_ = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.href = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.title = ""
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 ##########################################################################################
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 class JavaScriptEricObject(QObject):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 Class implementing an external javascript object to search via the startpage.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 # these must be in line with the strings used by the javascript part of the start page
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 translations = [
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 QT_TRANSLATE_NOOP("JavaScriptEricObject", "Welcome to Eric Web Browser!"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 QT_TRANSLATE_NOOP("JavaScriptEricObject", "Eric Web Browser"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 QT_TRANSLATE_NOOP("JavaScriptEricObject", "Search!"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 QT_TRANSLATE_NOOP("JavaScriptEricObject", "About Eric"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 ]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
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
94 def __init__(self, mw, parent = None):
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
95 """
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
96 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
97
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
98 @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
99 @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
100 """
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
101 QObject.__init__(self, parent)
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
102
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
103 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
104
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 @pyqtSlot(str, result = str)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 def translate(self, trans):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 Public method to translate the given string.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 @param trans string to be translated (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 @return translation (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 if trans == "QT_LAYOUT_DIRECTION":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 # special handling to detect layout direction
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 if qApp.isLeftToRight():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 return "LTR"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 return "RTL"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 return self.trUtf8(trans)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 @pyqtSlot(result = str)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 def providerString(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 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
126
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 @return string for the search provider (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 return self.trUtf8("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
130 .format(self.__mw.openSearchManager().currentEngineName())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 @pyqtSlot(str, result = str)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 def searchUrl(self, searchStr):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 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
136
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 @param searchStr search term (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @return search URL (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
140 return bytes(
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 self.__mw.openSearchManager().currentEngine()\
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
142 .searchUrl(searchStr).toEncoded()).decode()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 ##########################################################################################
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 class HelpWebPage(QWebPage):
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 Class implementing an enhanced web page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 def __init__(self, parent = None):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 @param parent parent widget of this window (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 QWebPage.__init__(self, parent)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 self.__lastRequest = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self.__lastRequestType = QWebPage.NavigationTypeOther
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 self.__proxy = NetworkAccessManagerProxy(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 self.__proxy.setWebPage(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 self.__proxy.setPrimaryNetworkAccessManager(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 Helpviewer.HelpWindow.HelpWindow.networkAccessManager())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 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
166
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
167 self.__sslInfo = None
747
48f13a14f754 Fixed a compatibility issue with latest PyQt4 snapshots.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 676
diff changeset
168 self.__proxy.finished.connect(self.__managerFinished)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 def acceptNavigationRequest(self, frame, request, type_):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 Protected method to determine, if a request may be accepted.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 @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
175 @param request reference to the request object (QNetworkRequest)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 @param type_ type of the navigation request (QWebPage.NavigationType)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 @return flag indicating acceptance (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 self.__lastRequest = request
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 self.__lastRequestType = type_
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
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
182 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
183 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
184 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
185 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
186
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
187 if type_ == QWebPage.NavigationTypeFormResubmitted:
747
48f13a14f754 Fixed a compatibility issue with latest PyQt4 snapshots.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 676
diff changeset
188 res = E5MessageBox.yesNo(self.view(),
48f13a14f754 Fixed a compatibility issue with latest PyQt4 snapshots.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 676
diff changeset
189 self.trUtf8("Resending POST request"),
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
190 self.trUtf8("""In order to display the site, the request along with"""
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
191 """ all the data must be sent once again, which may lead"""
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
192 """ to some unexpected behaviour of the site e.g. the"""
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
193 """ same action might be performed once again. Do you want"""
747
48f13a14f754 Fixed a compatibility issue with latest PyQt4 snapshots.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 676
diff changeset
194 """ to continue anyway?"""),
48f13a14f754 Fixed a compatibility issue with latest PyQt4 snapshots.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 676
diff changeset
195 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
196 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
197 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
198
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 return QWebPage.acceptNavigationRequest(self, frame, request, type_)
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 def populateNetworkRequest(self, request):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 Public method to add data to a network request.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 @param request reference to the network request object (QNetworkRequest)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 """
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
207 request.setAttribute(QNetworkRequest.User + 100, self)
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
208 request.setAttribute(QNetworkRequest.User + 101, self.__lastRequestType)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 def pageAttributeId(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 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
213
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 @return attribute id of the page attribute (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 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
217
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
218 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
219 """
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
220 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
221
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
222 @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
223 @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
224 """
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
225 try:
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
226 if extension == QWebPage.ErrorPageExtension:
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
227 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
228 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
229 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
230
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
231 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
232
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
233 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
234 """
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
235 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
236
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
237 @param extension extension to be executed (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
238 @param option provides input to the extension (QWebPage.ExtensionOption)
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
239 @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
240 @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
241 """
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
242 try:
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
243 if extension == QWebPage.ErrorPageExtension:
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
244 info = sip.cast(option, QWebPage.ErrorPageExtensionOption)
653
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 641
diff changeset
245 if info.error == 102:
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 641
diff changeset
246 # this is something of a hack; hopefully it will work in the future
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 641
diff changeset
247 return False
0540f3c52b46 Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 641
diff changeset
248
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
249 errorPage = sip.cast(output, QWebPage.ErrorPageExtensionReturn)
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
250 urlString = bytes(info.url.toEncoded()).decode()
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
251 html = notFoundPage_html
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
252 title = self.trUtf8("Error loading page: {0}").format(urlString)
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 pixmap = qApp.style()\
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 .standardIcon(QStyle.SP_MessageBoxWarning, None, self.parent())\
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 .pixmap(32, 32)
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 imageBuffer = QBuffer()
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 imageBuffer.open(QIODevice.ReadWrite)
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 if pixmap.save(imageBuffer, "PNG"):
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 html = html.replace("IMAGE_BINARY_DATA_HERE",
278
c93823b96faa Added a handler for ftp: URLs to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 260
diff changeset
260 str(imageBuffer.buffer().toBase64(), encoding="ascii"))
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 errorPage.content = QByteArray(html.format(
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
262 title,
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
263 info.errorString,
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 self.trUtf8("When connecting to: {0}.").format(urlString),
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 self.trUtf8("Check the address for errors such as "
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 "<b>ww</b>.example.org instead of "
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 "<b>www</b>.example.org"),
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 self.trUtf8("If the address is correct, try checking the network "
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 "connection."),
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 self.trUtf8("If your computer or network is protected by a firewall "
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 "or proxy, make sure that the browser is permitted to "
629
c88489b378fb Added configuration options for the web browser cache policy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
272 "access the network."),
c88489b378fb Added configuration options for the web browser cache policy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
273 self.trUtf8("If your cache policy is set to offline browsing,"
c88489b378fb Added configuration options for the web browser cache policy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
274 "only pages in the local cache are available.")
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
275 ).encode("utf8"))
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
276 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
277 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
278 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
279
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
280 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
281
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
282 def userAgent(self, resolveEmpty = False):
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
283 """
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
284 Public method to get the current user agent setting.
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
285
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
286 @param resolveEmpty flag indicating to resolve an empty
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
287 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
288 @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
289 """
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
290 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
291 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
292 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
293 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
294
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
295 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
296 """
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
297 Public method to set the current user agent string.
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
298
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
299 @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
300 """
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
301 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
302
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
303 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
304 """
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
305 Protected method to determine the user agent for the given URL.
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
306
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
307 @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
308 @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
309 """
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
310 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
311 if agent == "":
286de4e5179c Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 381
diff changeset
312 agent = QWebPage.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
313 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
314
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
315 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
316 """
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
317 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
318
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
319 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
320
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
321 @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
322 """
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
323 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
324 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
325 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
326 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
327
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
328 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
329
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
330 if mainFrameRequest 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
331 self.__sslInfo 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
332 reply.url() == self.mainFrame().url():
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
333 self.__sslInfo = 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
334
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
335 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
336 mainFrameRequest 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
337 self.__sslInfo is None and \
657
099d1ab9073e Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 656
diff changeset
338 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
339 reply.url() == self.mainFrame().url():
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
340 self.__sslInfo = reply.sslConfiguration().peerCertificate()
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
341 self.__sslInfo.url = QUrl(reply.url())
2f4496b1956f Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 653
diff changeset
342
657
099d1ab9073e Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 656
diff changeset
343 def getSslInfo(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
344 """
657
099d1ab9073e Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 656
diff changeset
345 Public method to get a reference to the SSL info object.
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
346
657
099d1ab9073e Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 656
diff changeset
347 @return reference to the SSL info (QSslCertificate)
099d1ab9073e Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 656
diff changeset
348 """
099d1ab9073e Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 656
diff changeset
349 return self.__sslInfo
658
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 657
diff changeset
350
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 657
diff changeset
351 def showSslInfo(self):
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 657
diff changeset
352 """
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 657
diff changeset
353 Public slot to show some SSL information for the loaded page.
2856f7ea6780 Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 657
diff changeset
354 """
923
e224bdbf88ad Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
355 if SSL_AVAILABLE and self.__sslInfo is not None:
659
b53e67ae2021 Added code to show certificate info for https URLs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 658
diff changeset
356 dlg = SslInfoDialog(self.__sslInfo, self.view())
b53e67ae2021 Added code to show certificate info for https URLs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 658
diff changeset
357 dlg.exec_()
664
3061f8bd826e Fixed a few issues on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 661
diff changeset
358 else:
3061f8bd826e Fixed a few issues on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 661
diff changeset
359 E5MessageBox.warning(self.view(),
3061f8bd826e Fixed a few issues on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 661
diff changeset
360 self.trUtf8("SSL Certificate Info"),
3061f8bd826e Fixed a few issues on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 661
diff changeset
361 self.trUtf8("""There is no SSL Certificate Info available."""))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 ##########################################################################################
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 class HelpBrowser(QWebView):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 Class implementing the helpbrowser widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 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
370 interface compatible with the QTextBrowser based variant.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371
501
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 487
diff changeset
372 @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
373 @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
374 @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
375 @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
376 @signal search(QUrl) emitted, when a search is requested
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 """
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
378 sourceChanged = pyqtSignal(QUrl)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
379 forwardAvailable = pyqtSignal(bool)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
380 backwardAvailable = pyqtSignal(bool)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
381 highlighted = pyqtSignal(str)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
382 search = pyqtSignal(QUrl)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
383
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 634
diff changeset
384 def __init__(self, mainWindow, parent = None, name = ""):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 634
diff changeset
388 @param mainWindow reference to the main window (HelpWindow)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 @param parent parent widget of this window (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 @param name name of this window (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 QWebView.__init__(self, parent)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 self.setObjectName(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 self.setWhatsThis(self.trUtf8(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 """<b>Help Window</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 """<p>This window displays the selected help information.</p>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 ))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 self.__page = HelpWebPage(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 self.setPage(self.__page)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 634
diff changeset
402 self.mw = mainWindow
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 self.ctrlPressed = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 self.__isLoading = False
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 629
diff changeset
405 self.__progress = 0
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 self.__currentZoom = 100
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 self.__zoomLevels = [
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 30, 50, 67, 80, 90,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 100,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 110, 120, 133, 150, 170, 200, 240, 300,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 ]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 self.__javaScriptBinding = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 self.__javaScriptEricObject = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
417 self.mw.zoomTextOnlyChanged.connect(self.__applyZoom)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 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
420 self.linkClicked.connect(self.setSource)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
422 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
423 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
424 self.page().linkHovered.connect(self.__linkHovered)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
426 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
427 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
428 self.loadFinished.connect(self.__loadFinished)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 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
431 self.page().unsupportedContent.connect(self.__unsupportedContent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
433 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
434 self.page().frameCreated.connect(self.__addExternalBinding)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 self.__addExternalBinding(self.page().mainFrame())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
437 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
438
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
439 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
440 self.__currentEngineChanged)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 def __addExternalBinding(self, frame = None):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 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
445
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 @param frame reference to the web frame (QWebFrame)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 """
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
448 if not hasattr(QtWebKit, 'QWebElement'):
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
449 # test this only for Qt < 4.6.0
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
450 if not QWebSettings.globalSettings()\
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
451 .testAttribute(QWebSettings.JavascriptEnabled):
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
452 return
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
453
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 self.page().settings().setAttribute(QWebSettings.JavascriptEnabled, True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 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
456 self.__javaScriptBinding = JavaScriptExternalObject(self.mw, self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 if frame is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 # called from QWebFrame.javaScriptWindowObjectCleared
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 frame = self.sender()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 if frame.url().scheme() == "pyrc" and frame.url().path() == "home":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 if self.__javaScriptEricObject 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
463 self.__javaScriptEricObject = JavaScriptEricObject(self.mw, self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 frame.addToJavaScriptWindowObject("eric", self.__javaScriptEricObject)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 # called from QWebPage.frameCreated
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
467 frame.javaScriptWindowObjectCleared.connect(self.__addExternalBinding)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 frame.addToJavaScriptWindowObject("external", self.__javaScriptBinding)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 def linkedResources(self, relation = ""):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 Public method to extract linked resources.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 @param relation relation to extract (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 @return list of linked resources (list of LinkedResource)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 resources = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478
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
479 if hasattr(QtWebKit, 'QWebElement'):
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
480 baseUrl = self.page().mainFrame().baseUrl()
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
481
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
482 linkElements = self.page().mainFrame().findAllElements("html > head > link")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483
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
484 for linkElement in linkElements.toList():
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
485 rel = linkElement.attribute("rel")
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
486 href = linkElement.attribute("href")
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
487 type_ = linkElement.attribute("type")
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
488 title = linkElement.attribute("title")
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
489
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
490 if href == "" or type_ == "":
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
491 continue
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
492 if relation and rel != relation:
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
493 continue
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
494
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
495 resource = LinkedResource()
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
496 resource.rel = rel
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
497 resource.type_ = type_
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
498 resource.href = baseUrl.resolved(QUrl.fromEncoded(href))
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
499 resource.title = title
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
500
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
501 resources.append(resource)
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
502 else:
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
503 baseUrlString = self.page().mainFrame().evaluateJavaScript("document.baseURI")
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
504 baseUrl = QUrl.fromEncoded(baseUrlString)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505
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
506 lst = self.page().mainFrame().evaluateJavaScript(fetchLinks_js)
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
507 for m in lst:
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
508 rel = m["rel"]
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
509 type_ = m["type"]
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
510 href = m["href"]
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
511 title = m["title"]
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
512
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
513 if href == "" or type_ == "":
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
514 continue
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
515 if relation and rel != relation:
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
516 continue
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
517
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
518 resource = LinkedResource()
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
519 resource.rel = rel
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
520 resource.type_ = type_
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
521 resource.href = baseUrl.resolved(QUrl.fromEncoded(href))
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
522 resource.title = title
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
523
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
524 resources.append(resource)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 return resources
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 def __currentEngineChanged(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 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
531 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 if self.url().toString() == "pyrc:home":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 self.reload()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 def setSource(self, name):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 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
538
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 @param name filename to be shown (QUrl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 if name is None or not name.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 if self.ctrlPressed:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 # open in a new window
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 self.mw.newTab(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 self.ctrlPressed = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 if not name.scheme():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 name.setUrl(Preferences.getHelp("DefaultScheme") + name.toString())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 if len(name.scheme()) == 1 or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 name.scheme() == "file":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 # name is a local file
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 if name.scheme() and len(name.scheme()) == 1:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 # it is a local path on win os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 name = QUrl.fromLocalFile(name.toString())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 if not QFileInfo(name.toLocalFile()).exists():
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
561 E5MessageBox.critical(self,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 self.trUtf8("Web Browser"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 self.trUtf8("""<p>The file <b>{0}</b> does not exist.</p>""")\
535
4b00d7336e19 Streamlined the use of QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
564 .format(name.toLocalFile()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 if name.toLocalFile().endswith(".pdf") or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 name.toLocalFile().endswith(".PDF") or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 name.toLocalFile().endswith(".chm") or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 name.toLocalFile().endswith(".CHM"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 started = QDesktopServices.openUrl(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 if not started:
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
573 E5MessageBox.critical(self,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574 self.trUtf8("Web Browser"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575 self.trUtf8("""<p>Could not start a viewer"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576 """ for file <b>{0}</b>.</p>""").format(name.path()))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 return
278
c93823b96faa Added a handler for ftp: URLs to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 260
diff changeset
578 elif name.scheme() in ["mailto"]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 started = QDesktopServices.openUrl(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580 if not started:
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
581 E5MessageBox.critical(self,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
582 self.trUtf8("Web Browser"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
583 self.trUtf8("""<p>Could not start an application"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 """ for URL <b>{0}</b>.</p>""").format(name.toString()))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 elif name.scheme() == "javascript":
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
587 scriptSource = QUrl.fromPercentEncoding(name.toString(
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
588 QUrl.FormattingOptions(QUrl.TolerantMode | QUrl.RemoveScheme)))
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
589 self.page().mainFrame().evaluateJavaScript(scriptSource)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
590 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 if name.toString().endswith(".pdf") or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 name.toString().endswith(".PDF") or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 name.toString().endswith(".chm") or \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595 name.toString().endswith(".CHM"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 started = QDesktopServices.openUrl(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 if not started:
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 535
diff changeset
598 E5MessageBox.critical(self,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599 self.trUtf8("Web Browser"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 self.trUtf8("""<p>Could not start a viewer"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
601 """ for file <b>{0}</b>.</p>""").format(name.path()))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
602 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
603
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
604 self.load(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
605
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
606 def source(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
607 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
608 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
609
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610 @return URL loaded in the help browser (QUrl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
611 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 return self.url()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
614 def documentTitle(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
616 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
617
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618 @return title (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620 return self.title()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622 def backward(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624 Public slot to move backwards in history.
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 self.triggerPageAction(QWebPage.Back)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 self.__urlChanged(self.history().currentItem().url())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 def forward(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 Public slot to move forward in history.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 self.triggerPageAction(QWebPage.Forward)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 self.__urlChanged(self.history().currentItem().url())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 def home(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 Public slot to move to the first page loaded.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
640 homeUrl = QUrl(Preferences.getHelp("HomePage"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
641 self.setSource(homeUrl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642 self.__urlChanged(self.history().currentItem().url())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 def reload(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
646 Public slot to reload the current page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
647 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
648 self.triggerPageAction(QWebPage.Reload)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
649
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
650 def copy(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
651 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652 Public slot to copy the selected text.
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 self.triggerPageAction(QWebPage.Copy)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656 def isForwardAvailable(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 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
659
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660 @return flag indicating move forward is possible (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 return self.history().canGoForward()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
663
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
664 def isBackwardAvailable(self):
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 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
667
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 @return flag indicating move backwards is possible (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670 return self.history().canGoBack()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
672 def __levelForZoom(self, zoom):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
674 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
675
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676 @param zoom zoom factor (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
677 @return index of zoom factor (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
678 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
679 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
680 index = self.__zoomLevels.index(zoom)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
681 except ValueError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
682 for index in range(len(self.__zoomLevels)):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
683 if zoom <= self.__zoomLevels[index]:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
684 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
685 return index
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
686
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
687 def __applyZoom(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
688 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
689 Private slot to apply the current zoom factor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
690 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
691 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692 self.setZoomFactor(self.__currentZoom / 100.0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
693 except AttributeError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
694 self.setTextSizeMultiplier(self.__currentZoom / 100.0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696 def zoomIn(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
697 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
698 Public slot to zoom into the page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
699 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
700 index = self.__levelForZoom(self.__currentZoom)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
701 if index < len(self.__zoomLevels) - 1:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
702 self.__currentZoom = self.__zoomLevels[index + 1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703 self.__applyZoom()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
704
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
705 def zoomOut(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
706 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
707 Public slot to zoom out of the page.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
708 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
709 index = self.__levelForZoom(self.__currentZoom)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
710 if index > 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711 self.__currentZoom = self.__zoomLevels[index - 1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
712 self.__applyZoom()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 def zoomReset(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716 Public method to reset the zoom factor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
717 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718 self.__currentZoom = 100
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719 self.__applyZoom()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
720
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
721 def wheelEvent(self, evt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
722 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
723 Protected method to handle wheel events.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
724
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725 @param evt reference to the wheel event (QWheelEvent)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727 if evt.modifiers() & Qt.ControlModifier:
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
728 degrees = evt.delta() // 8
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
729 steps = degrees // 15
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
730 self.__currentZoom += steps * 10
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
731 self.__applyZoom()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
732 evt.accept()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 QWebView.wheelEvent(self, evt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
737 def hasSelection(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739 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
740
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 @return flag indicating text has been selected (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
743 return self.selectedText() != ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
744
376
0c4c359c4870 Added option to highlight all occurences to the web browser search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 350
diff changeset
745 def findNextPrev(self, txt, case, backwards, wrap, highlightAll):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 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
748
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
749 @param txt text to search for (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 @param case flag indicating a case sensitive search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751 @param backwards flag indicating a backwards search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 @param wrap flag indicating to wrap around (boolean)
376
0c4c359c4870 Added option to highlight all occurences to the web browser search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 350
diff changeset
753 @param highlightAll flag indicating to highlight all occurrences (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755 findFlags = QWebPage.FindFlags()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 if case:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757 findFlags |= QWebPage.FindCaseSensitively
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758 if backwards:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759 findFlags |= QWebPage.FindBackward
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760 if wrap:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 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
762 try:
0c4c359c4870 Added option to highlight all occurences to the web browser search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 350
diff changeset
763 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
764 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
765 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
766 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 return self.findText(txt, findFlags)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
769
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
770 def contextMenuEvent(self, evt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
771 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772 Protected method called to create a context menu.
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 This method is overridden from QWebView.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776 @param evt reference to the context menu event object (QContextMenuEvent)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 menu = QMenu(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 hit = self.page().mainFrame().hitTestContent(evt.pos())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781 if not hit.linkUrl().isEmpty():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
782 act = menu.addAction(self.trUtf8("Open Link in New Tab\tCtrl+LMB"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 self.__openLinkInNewTab)
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
784 act.setData(hit.linkUrl())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 menu.addSeparator()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
786 menu.addAction(self.trUtf8("Save Lin&k"), self.__downloadLink)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787 act = menu.addAction(self.trUtf8("Bookmark this Link"), self.__bookmarkLink)
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
788 act.setData(hit.linkUrl())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
789 menu.addSeparator()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
790 menu.addAction(self.trUtf8("Copy Link to Clipboard"), self.__copyLink)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
791
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
792 if not hit.imageUrl().isEmpty():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
793 if not menu.isEmpty():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
794 menu.addSeparator()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
795 act = menu.addAction(self.trUtf8("Open Image in New Tab"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796 self.__openLinkInNewTab)
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
797 act.setData(hit.imageUrl())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798 menu.addSeparator()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799 menu.addAction(self.trUtf8("Save Image"), self.__downloadImage)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 menu.addAction(self.trUtf8("Copy Image to Clipboard"), self.__copyImage)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801 act = menu.addAction(self.trUtf8("Copy Image Location to Clipboard"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 self.__copyImageLocation)
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
803 act.setData(hit.imageUrl().toString())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 menu.addSeparator()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805 act = menu.addAction(self.trUtf8("Block Image"), self.__blockImage)
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
806 act.setData(hit.imageUrl().toString())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
807
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808 if not menu.isEmpty():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 menu.addSeparator()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 menu.addAction(self.mw.newTabAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811 menu.addAction(self.mw.newAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
812 menu.addSeparator()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
813 menu.addAction(self.mw.saveAsAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 menu.addSeparator()
661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 659
diff changeset
815 menu.addAction(self.trUtf8("Bookmark this Page"), self.addBookmark)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816 menu.addSeparator()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817 menu.addAction(self.mw.backAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
818 menu.addAction(self.mw.forwardAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
819 menu.addAction(self.mw.homeAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
820 menu.addSeparator()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
821 menu.addAction(self.mw.zoomInAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
822 menu.addAction(self.mw.zoomOutAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823 menu.addSeparator()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
824 if self.selectedText():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 menu.addAction(self.mw.copyAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826 menu.addAction(self.mw.findAct)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
827 menu.addSeparator()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828 if self.selectedText():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829 self.__searchMenu = menu.addMenu(self.trUtf8("Search with..."))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830
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
831 engineNames = self.mw.openSearchManager().allEnginesNames()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 for engineName in engineNames:
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
833 engine = self.mw.openSearchManager().engine(engineName)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
834 act = OpenSearchEngineAction(engine, self.__searchMenu)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 self.__searchMenu.addAction(act)
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
836 act.setData(engineName)
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
837 self.__searchMenu.triggered.connect(self.__searchRequested)
0
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 menu.addSeparator()
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
840
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
841 if hasattr(QtWebKit, 'QWebElement'):
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
842 element = hit.element()
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
843 if not element.isNull() and \
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
844 element.tagName().lower() == "input" and \
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
845 element.attribute("type", "text") == "text":
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
846 act = menu.addAction(self.trUtf8("Add to web search toolbar"),
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
847 self.__addSearchEngine)
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
848 act.setData(element)
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
849 menu.addSeparator()
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
850
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851 menu.addAction(self.trUtf8("Web Inspector..."), self.__webInspector)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 menu.exec_(evt.globalPos())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 def __openLinkInNewTab(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 Private method called by the context menu to open a link in a new window.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859 act = self.sender()
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
860 url = act.data()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 if url.isEmpty():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
864 self.ctrlPressed = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
865 self.setSource(url)
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
866 self.ctrlPressed = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 def __bookmarkLink(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
869 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870 Private slot to bookmark a link via the context menu.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 act = self.sender()
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
873 url = act.data()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
874 if url.isEmpty():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
875 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
876
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877 dlg = AddBookmarkDialog()
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
878 dlg.setUrl(bytes(url.toEncoded()).decode())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879 dlg.exec_()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
880
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
881 def __downloadLink(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
882 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
883 Private slot to download a link and save it to disk.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
884 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
885 self.pageAction(QWebPage.DownloadLinkToDisk).trigger()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
886
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
887 def __copyLink(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
888 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
889 Private slot to copy a link to the clipboard.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
890 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
891 self.pageAction(QWebPage.CopyLinkToClipboard).trigger()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
892
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
893 def __downloadImage(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
894 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
895 Private slot to download an image and save it to disk.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
896 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
897 self.pageAction(QWebPage.DownloadImageToDisk).trigger()
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 __copyImage(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 Private slot to copy an image to the clipboard.
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 self.pageAction(QWebPage.CopyImageToClipboard).trigger()
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 def __copyImageLocation(self):
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 Private slot to copy an image location to the clipboard.
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 act = self.sender()
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
910 url = act.data()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
911 QApplication.clipboard().setText(url)
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 def __blockImage(self):
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 Private slot to add a block rule for an image URL.
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 act = self.sender()
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
918 url = act.data()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
919 dlg = Helpviewer.HelpWindow.HelpWindow.adblockManager().showDialog()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
920 dlg.addCustomRule(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 __searchRequested(self, act):
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 Private slot to search for some text with a selected search engine.
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 @param act reference to the action that triggered this slot (QAction)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
927 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
928 searchText = self.selectedText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
929
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
930 if not searchText:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
931 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
932
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
933 engineName = act.data()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
934 if engineName:
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
935 engine = self.mw.openSearchManager().engine(engineName)
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
936 self.search.connect(engine.searchUrl(searchText))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
937
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
938 def __addSearchEngine(self):
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
939 """
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
940 Private slot to add a new search engine.
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
941 """
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
942 act = self.sender()
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
943 if act is None:
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
944 return
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
945
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
946 element = act.data()
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
947 elementName = element.attribute("name")
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
948 formElement = QWebElement(element)
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
949 while formElement.tagName().lower() != "form":
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
950 formElement = formElement.parent()
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
951
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
952 if formElement.isNull() or \
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
953 formElement.attribute("action") == "":
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
954 return
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
955
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
956 method = formElement.attribute("method", "get").lower()
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
957 if method != "get":
539
87f9bce38a44 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 538
diff changeset
958 E5MessageBox.warning(self,
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
959 self.trUtf8("Method not supported"),
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
960 self.trUtf8("""{0} method is not supported.""").format(method.upper()))
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
961 return
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
962
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
963 searchUrl = QUrl(self.page().mainFrame().baseUrl().resolved(
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
964 QUrl(formElement.attribute("action"))))
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
965 if searchUrl.scheme() != "http":
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
966 return
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
967
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
968 searchEngines = {}
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
969 inputFields = formElement.findAll("input")
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
970 for inputField in inputFields.toList():
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
971 type_ = inputField.attribute("type", "text")
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
972 name = inputField.attribute("name")
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
973 value = inputField.evaluateJavaScript("this.value")
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
974
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
975 if type_ == "submit":
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
976 searchEngines[value] = name
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
977 elif type_ == "text":
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
978 if inputField == element:
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
979 value = "{searchTerms}"
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
980 searchUrl.addQueryItem(name, value)
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
981 elif type_ == "checkbox" or type_ == "radio":
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
982 if inputField.evaluateJavaScript("this.checked"):
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
983 searchUrl.addQueryItem(name, value)
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
984 elif type_ == "hidden":
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
985 searchUrl.addQueryItem(name, value)
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
986
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
987 selectFields = formElement.findAll("select")
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
988 for selectField in selectFields.toList():
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
989 name = selectField.attribute("name")
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
990 selectedIndex = selectField.evaluateJavaScript("this.selectedIndex")
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
991 if selectedIndex == -1:
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
992 continue
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
993
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
994 options = selectField.findAll("option")
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
995 value = options.at(selectedIndex).toPlainText()
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
996 searchUrl.addQueryItem(name, value)
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
997
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
998 ok = True
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
999 if len(searchEngines) > 1:
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
1000 searchEngine, ok = QInputDialog.getItem(
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
1001 self,
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
1002 self.trUtf8("Search engine"),
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
1003 self.trUtf8("Choose the desired search engine"),
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
1004 sorted(searchEngines.keys()), 0, False)
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
1005
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
1006 if not ok:
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
1007 return
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
1008
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
1009 if searchEngines[searchEngine] != "":
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
1010 searchUrl.addQueryItem(searchEngines[searchEngine], searchEngine)
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
1011
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
1012 engineName = ""
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
1013 labels = formElement.findAll('label[for="{0}"]'.format(elementName))
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
1014 if labels.count() > 0:
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
1015 engineName = labels.at(0).toPlainText()
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
1016
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
1017 engineName, ok = QInputDialog.getText(
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
1018 self,
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
1019 self.trUtf8("Engine name"),
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
1020 self.trUtf8("Enter a name for the engine"),
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
1021 QLineEdit.Normal,
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
1022 engineName)
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
1023 if not ok:
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
1024 return
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
1025
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
1026 engine = OpenSearchEngine()
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
1027 engine.setName(engineName)
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
1028 engine.setDescription(engineName)
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
1029 engine.setSearchUrlTemplate(searchUrl.toString())
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
1030 engine.setImage(self.icon().pixmap(16, 16).toImage())
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
1031
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
1032 self.mw.openSearchManager().addEngine(engine)
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
1033
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1034 def __webInspector(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1035 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1036 Private slot to show the web inspector window.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1037 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1038 self.triggerPageAction(QWebPage.InspectElement)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1039
661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 659
diff changeset
1040 def addBookmark(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1041 """
661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 659
diff changeset
1042 Public slot to bookmark the current page.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1043 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1044 dlg = AddBookmarkDialog()
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
1045 dlg.setUrl(bytes(self.url().toEncoded()).decode())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1046 dlg.setTitle(self.title())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1047 dlg.exec_()
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 def keyPressEvent(self, evt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1050 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1051 Protected method called by a key press.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1052
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1053 This method is overridden from QTextBrowser.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1054
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1055 @param evt the key event (QKeyEvent)
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 self.ctrlPressed = (evt.key() == Qt.Key_Control)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1058 QWebView.keyPressEvent(self, evt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1059
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1060 def keyReleaseEvent(self, evt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1061 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1062 Protected method called by a key release.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1063
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1064 This method is overridden from QTextBrowser.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1065
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1066 @param evt the key event (QKeyEvent)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1067 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1068 self.ctrlPressed = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1069 QWebView.keyReleaseEvent(self, evt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1070
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1071 def clearHistory(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1072 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1073 Public slot to clear the history.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1074 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1075 self.history().clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1076 self.__urlChanged(self.history().currentItem().url())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1077
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1078 ############################################################################
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1079 ## Signal converters below
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1080 ############################################################################
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1081
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1082 def __urlChanged(self, url):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1083 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1084 Private slot to handle the urlChanged signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1085
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1086 @param url the new url (QUrl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1087 """
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
1088 self.sourceChanged.emit(url)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1089
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
1090 self.forwardAvailable.emit(self.isForwardAvailable())
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
1091 self.backwardAvailable.emit(self.isBackwardAvailable())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1092
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1093 def __statusBarMessage(self, text):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1094 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1095 Private slot to handle the statusBarMessage signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1096
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1097 @param text text to be shown in the status bar (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1098 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1099 self.mw.statusBar().showMessage(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1100
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1101 def __linkHovered(self, link, title, textContent):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1102 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1103 Private slot to handle the linkHovered signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1104
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1105 @param link the URL of the link (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1106 @param title the link title (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1107 @param textContent text content of the link (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1108 """
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 383
diff changeset
1109 self.highlighted.emit(link)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1110
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1111 ############################################################################
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1112 ## Signal handlers below
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1113 ############################################################################
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1114
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1115 def __loadStarted(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1116 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1117 Private method to handle the loadStarted signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1118 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1119 self.__isLoading = True
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 629
diff changeset
1120 self.__progress = 0
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1121
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1122 def __loadProgress(self, progress):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1123 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1124 Private method to handle the loadProgress signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1125
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1126 @param progress progress value (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1127 """
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 629
diff changeset
1128 self.__progress = progress
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1129
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1130 def __loadFinished(self, ok):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1131 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1132 Private method to handle the loadFinished signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1133
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1134 @param ok flag indicating the result (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1135 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1136 self.__isLoading = False
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 629
diff changeset
1137 self.__progress = 0
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1138
256
04083f42042d Some changes to the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
1139 if ok:
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
1140 self.mw.adblockManager().page().applyRulesToPage(self.page())
256
04083f42042d Some changes to the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
1141 self.mw.passwordManager().fill(self.page())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1142
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1143 def isLoading(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1144 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1145 Public method to get the loading state.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1146
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1147 @return flag indicating the loading state (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1148 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1149 return self.__isLoading
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1150
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 629
diff changeset
1151 def progress(self):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 629
diff changeset
1152 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 629
diff changeset
1153 Public method to get the load progress.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 629
diff changeset
1154 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 629
diff changeset
1155 return self.__progress
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 629
diff changeset
1156
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1157 def saveAs(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1158 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1159 Public method to save the current page to a file.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1160 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1161 url = self.url()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1162 if url.isEmpty():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1163 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1164
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 664
diff changeset
1165 self.mw.downloadManager().download(url, True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1166
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1167 def __unsupportedContent(self, reply, requestFilename = None, download = False):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1168 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1169 Private slot to handle the unsupportedContent signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1170
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1171 @param reply reference to the reply object (QNetworkReply)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1172 @keyparam requestFilename indicating to ask for a filename
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1173 (boolean or None). If it is None, the behavior is determined
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1174 by a configuration option.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1175 @keyparam download flag indicating a download operation (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1176 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1177 if reply is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1178 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1179
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1180 replyUrl = reply.url()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1181
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1182 if replyUrl.scheme() == "abp":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1183 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1184
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1185 if reply.error() == QNetworkReply.NoError:
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 664
diff changeset
1186 if reply.header(QNetworkRequest.ContentTypeHeader):
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 664
diff changeset
1187 self.mw.downloadManager().handleUnsupportedContent(
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 664
diff changeset
1188 reply, webPage = self.page())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1189 return
676
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1190
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1191 replyUrl = reply.url()
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1192 if replyUrl.isEmpty():
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1193 return
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1194
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1195 notFoundFrame = self.page().mainFrame()
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1196 if notFoundFrame is None:
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1197 return
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1198
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1199 if reply.header(QNetworkRequest.ContentTypeHeader):
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1200 data = reply.readAll()
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1201 if contentSniff(data):
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1202 notFoundFrame.setHtml(str(data, encoding = "utf-8"), replyUrl)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1203 return
676
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1204
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1205 html = notFoundPage_html
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1206 urlString = bytes(replyUrl.toEncoded()).decode()
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1207 title = self.trUtf8("Error loading page: {0}").format(urlString)
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1208 pixmap = qApp.style()\
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1209 .standardIcon(QStyle.SP_MessageBoxWarning, None, self)\
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1210 .pixmap(32, 32)
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1211 imageBuffer = QBuffer()
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1212 imageBuffer.open(QIODevice.ReadWrite)
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1213 if pixmap.save(imageBuffer, "PNG"):
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1214 html = html.replace("IMAGE_BINARY_DATA_HERE",
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1215 str(imageBuffer.buffer().toBase64(), encoding="ascii"))
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1216 html = html.format(
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1217 title,
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1218 reply.errorString(),
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1219 self.trUtf8("When connecting to: {0}.").format(urlString),
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1220 self.trUtf8("Check the address for errors such as <b>ww</b>.example.org "
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1221 "instead of <b>www</b>.example.org"),
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1222 self.trUtf8("If the address is correct, try checking the network "
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1223 "connection."),
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1224 self.trUtf8("If your computer or network is protected by a firewall or "
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1225 "proxy, make sure that the browser is permitted to access "
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1226 "the network."),
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1227 self.trUtf8("If your cache policy is set to offline browsing,"
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1228 "only pages in the local cache are available.")
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1229 )
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1230 notFoundFrame.setHtml(html, replyUrl)
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1231 self.mw.historyManager().removeHistoryEntry(replyUrl, self.title())
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1232 self.loadFinished.emit(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1233
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1234 def __downloadRequested(self, request):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1235 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1236 Private slot to handle a download request.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1237
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1238 @param request reference to the request object (QNetworkRequest)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1239 """
668
b0061a6f7484 Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 664
diff changeset
1240 self.mw.downloadManager().download(request)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1241
350
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1242 def __databaseQuotaExceeded(self, frame, databaseName):
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1243 """
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1244 Private slot to handle the case, where the database quota is exceeded.
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1245
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1246 @param frame reference to the frame (QWebFrame)
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1247 @param databaseName name of the web database (string)
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1248 """
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1249 securityOrigin = frame.securityOrigin()
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1250 if securityOrigin.databaseQuota() > 0 and \
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1251 securityOrigin.databaseUsage() == 0:
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1252 # cope with a strange behavior of Qt 4.6, if a database is
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1253 # accessed for the first time
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1254 return
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1255
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
1256 res = E5MessageBox.yesNo(self,
350
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1257 self.trUtf8("Web Database Quota"),
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1258 self.trUtf8("""<p>The database quota of <strong>{0}</strong> has"""
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1259 """ been exceeded while accessing database <strong>{1}"""
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1260 """</strong>.</p><p>Shall it be changed?</p>""")\
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1261 .format(self.__dataString(securityOrigin.databaseQuota()), databaseName),
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
1262 yesDefault = True)
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 539
diff changeset
1263 if res:
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 541
diff changeset
1264 newQuota, ok = QInputDialog.getInteger(
350
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1265 self,
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1266 self.trUtf8("New Web Database Quota"),
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1267 self.trUtf8("Enter the new quota in MB (current = {0}, used = {1}; "
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1268 "step size = 5 MB):"\
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1269 .format(self.__dataString(securityOrigin.databaseQuota()),
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1270 self.__dataString(securityOrigin.databaseUsage()))),
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1271 securityOrigin.databaseQuota() // (1024 * 1024), 0, 2147483647, 5)
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1272 if ok:
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1273 securityOrigin.setDatabaseQuota(newQuota * 1024 * 1024)
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1274
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1275 def __dataString(self, size):
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1276 """
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1277 Private method to generate a formatted data string.
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1278
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1279 @param size size to be formatted (integer)
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1280 @return formatted data string (string)
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1281 """
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1282 unit = ""
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1283 if size < 1024:
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1284 unit = self.trUtf8("bytes")
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1285 elif size < 1024 * 1024:
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1286 size /= 1024
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1287 unit = self.trUtf8("kB")
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1288 else:
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1289 size /= 1024 * 1024
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1290 unit = self.trUtf8("MB")
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1291 return "{0:.1f} {1}".format(size, unit)
db40effc5c65 Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 313
diff changeset
1292
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1293 ############################################################################
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1294 ## Miscellaneous methods below
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1295 ############################################################################
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1296
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1297 def createWindow(self, windowType):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1298 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1299 Protected method called, when a new window should be created.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1300
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1301 @param windowType type of the requested window (QWebPage.WebWindowType)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1302 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1303 self.mw.newTab()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1304 return self.mw.currentBrowser()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1305
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1306 def preferencesChanged(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1307 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1308 Public method to indicate a change of the settings.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1309 """
629
c88489b378fb Added configuration options for the web browser cache policy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
1310 self.reload()
676
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1311
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1312 def contentSniff(data):
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1313 """
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1314 Module function to do some content sniffing to check, if the data is HTML.
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1315
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1316 @return flag indicating HTML content (boolean)
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1317 """
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1318 if data.contains("<!doctype") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1319 data.contains("<script") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1320 data.contains("<html") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1321 data.contains("<!--") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1322 data.contains("<head") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1323 data.contains("<iframe") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1324 data.contains("<h1") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1325 data.contains("<div") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1326 data.contains("<font") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1327 data.contains("<table") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1328 data.contains("<a") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1329 data.contains("<style") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1330 data.contains("<title") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1331 data.contains("<b") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1332 data.contains("<body") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1333 data.contains("<br") or \
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1334 data.contains("<p"):
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1335 return True
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1336
6771da84fb0c Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 675
diff changeset
1337 return False

eric ide

mercurial