Mon, 30 Apr 2012 19:19:17 +0200
Added the capability to search in the recorded log of the log viewer.
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 | |
1509
c0b5e693b0eb
Updated copyright for 2012.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1506
diff
changeset
|
3 | # Copyright (c) 2008 - 2012 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 | |
1112
8a7d1b9d18db
Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
992
diff
changeset
|
11 | from PyQt4.QtCore import pyqtSlot, pyqtSignal, QObject, QT_TRANSLATE_NOOP, QUrl, \ |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
12 | QBuffer, QIODevice, QFileInfo, Qt, QTimer, QEvent, QRect, QFile |
1112
8a7d1b9d18db
Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
992
diff
changeset
|
13 | from PyQt4.QtGui import qApp, QDesktopServices, QStyle, QMenu, QApplication, \ |
8a7d1b9d18db
Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
992
diff
changeset
|
14 | QInputDialog, QLineEdit, QClipboard, QMouseEvent, QLabel, QToolTip, QColor, \ |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
15 | QPalette, QFrame, QPrinter, QPrintDialog, QDialog |
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
|
16 | from PyQt4 import QtWebKit |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | 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
|
18 | 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
|
19 | 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
|
20 | 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
|
21 | pass |
96
9624a110667d
Started to clean up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
38
diff
changeset
|
22 | 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
|
23 | import sip |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
535
diff
changeset
|
25 | from E5Gui import E5MessageBox |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
535
diff
changeset
|
26 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | import Preferences |
978
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
28 | import UI.PixmapCache |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
30 | from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog |
1731
56cf9c150dbf
Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1670
diff
changeset
|
31 | from .Bookmarks.BookmarkNode import BookmarkNode |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
32 | from .JavaScriptResources import fetchLinks_js |
923
e224bdbf88ad
Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
826
diff
changeset
|
33 | try: |
e224bdbf88ad
Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
826
diff
changeset
|
34 | from .SslInfoDialog import SslInfoDialog |
1558
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
35 | from PyQt4.QtNetwork import QSslCertificate |
923
e224bdbf88ad
Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
826
diff
changeset
|
36 | SSL_AVAILABLE = True |
e224bdbf88ad
Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
826
diff
changeset
|
37 | except ImportError: |
e224bdbf88ad
Fixed an issue related to the non-availability of SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
826
diff
changeset
|
38 | SSL_AVAILABLE = False |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | import Helpviewer.HelpWindow |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
40 | from .HelpLanguagesDialog import HelpLanguagesDialog |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
42 | from .Network.NetworkAccessManagerProxy import NetworkAccessManagerProxy |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
44 | 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
|
45 | from .OpenSearch.OpenSearchEngine import OpenSearchEngine |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | |
1651
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
47 | from .WebPlugins.WebPluginFactory import WebPluginFactory |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
48 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | ########################################################################################## |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
51 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | class JavaScriptExternalObject(QObject): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | 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
|
55 | """ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
56 | def __init__(self, mw, parent=None): |
142
94ce651735db
Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
96
diff
changeset
|
57 | """ |
94ce651735db
Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
96
diff
changeset
|
58 | 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
|
59 | |
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
|
60 | @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
|
61 | @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
|
62 | """ |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1112
diff
changeset
|
63 | super().__init__(parent) |
142
94ce651735db
Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
96
diff
changeset
|
64 | |
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
|
65 | 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
|
66 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | @pyqtSlot(str) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | def AddSearchProvider(self, url): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | Public slot to add a search provider. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | @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
|
73 | """ |
826
2e3e2055e715
Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
74 | self.__mw.openSearchManager().addEngine(QUrl(url)) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
76 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | class LinkedResource(object): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | Class defining a data structure for linked resources. |
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 | def __init__(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | Constructor |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | self.rel = "" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | self.type_ = "" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | self.href = "" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | self.title = "" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | ########################################################################################## |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
92 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | class JavaScriptEricObject(QObject): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | 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
|
96 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | # 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
|
98 | translations = [ |
1232
ed31e909cf2e
Harmonisation of some display strings related to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
99 | QT_TRANSLATE_NOOP("JavaScriptEricObject", "Welcome to eric5 Web Browser!"), |
ed31e909cf2e
Harmonisation of some display strings related to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
100 | QT_TRANSLATE_NOOP("JavaScriptEricObject", "eric5 Web Browser"), |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
101 | QT_TRANSLATE_NOOP("JavaScriptEricObject", "Search!"), |
1232
ed31e909cf2e
Harmonisation of some display strings related to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
102 | QT_TRANSLATE_NOOP("JavaScriptEricObject", "About eric5"), |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | ] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
105 | def __init__(self, mw, parent=None): |
142
94ce651735db
Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
96
diff
changeset
|
106 | """ |
94ce651735db
Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
96
diff
changeset
|
107 | Constructor |
94ce651735db
Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
96
diff
changeset
|
108 | |
94ce651735db
Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
96
diff
changeset
|
109 | @param mw reference to the main window 8HelpWindow) |
94ce651735db
Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
96
diff
changeset
|
110 | @param parent reference to the parent object (QObject) |
94ce651735db
Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
96
diff
changeset
|
111 | """ |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1112
diff
changeset
|
112 | super().__init__(parent) |
142
94ce651735db
Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
96
diff
changeset
|
113 | |
94ce651735db
Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
96
diff
changeset
|
114 | self.__mw = mw |
94ce651735db
Added code to (hopefully) fix the "Underlying C++ object deleted" issue in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
96
diff
changeset
|
115 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
116 | @pyqtSlot(str, result=str) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | def translate(self, trans): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | Public method to translate the given string. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | @param trans string to be translated (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | @return translation (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | if trans == "QT_LAYOUT_DIRECTION": |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | # special handling to detect layout direction |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | if qApp.isLeftToRight(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | return "LTR" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | return "RTL" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | return self.trUtf8(trans) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
133 | @pyqtSlot(result=str) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | def providerString(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
136 | Public method to get a string for the search provider. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | @return string for the search provider (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | 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
|
141 | .format(self.__mw.openSearchManager().currentEngineName()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
142 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
143 | @pyqtSlot(str, result=str) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | def searchUrl(self, searchStr): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
145 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | Public method to get the search URL for the given search term. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | @param searchStr search term (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | @return search URL (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | """ |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
151 | return bytes( |
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
|
152 | self.__mw.openSearchManager().currentEngine()\ |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
153 | .searchUrl(searchStr).toEncoded()).decode() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | |
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 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
157 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | class HelpWebPage(QWebPage): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | Class implementing an enhanced web page. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | """ |
1651
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
162 | _webPluginFactory = None |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
163 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
164 | def __init__(self, parent=None): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | Constructor |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | @param parent parent widget of this window (QWidget) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | """ |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1112
diff
changeset
|
170 | super().__init__(parent) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | |
1651
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
172 | self.setPluginFactory(self.webPluginFactory()) |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
173 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
174 | self.__lastRequest = None |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | self.__lastRequestType = QWebPage.NavigationTypeOther |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | self.__proxy = NetworkAccessManagerProxy(self) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | self.__proxy.setWebPage(self) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | self.__proxy.setPrimaryNetworkAccessManager( |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | Helpviewer.HelpWindow.HelpWindow.networkAccessManager()) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | 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
|
182 | |
1558
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
183 | self.__sslConfiguration = None |
747
48f13a14f754
Fixed a compatibility issue with latest PyQt4 snapshots.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
676
diff
changeset
|
184 | self.__proxy.finished.connect(self.__managerFinished) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | def acceptNavigationRequest(self, frame, request, type_): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | 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
|
189 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | @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
|
191 | @param request reference to the request object (QNetworkRequest) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | @param type_ type of the navigation request (QWebPage.NavigationType) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | @return flag indicating acceptance (boolean) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | self.__lastRequest = request |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | self.__lastRequestType = type_ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | |
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
|
198 | 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
|
199 | 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
|
200 | 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
|
201 | 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
|
202 | |
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
|
203 | if type_ == QWebPage.NavigationTypeFormResubmitted: |
747
48f13a14f754
Fixed a compatibility issue with latest PyQt4 snapshots.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
676
diff
changeset
|
204 | res = E5MessageBox.yesNo(self.view(), |
48f13a14f754
Fixed a compatibility issue with latest PyQt4 snapshots.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
676
diff
changeset
|
205 | 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
|
206 | 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
|
207 | """ 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
|
208 | """ 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
|
209 | """ 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
|
210 | """ to continue anyway?"""), |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
211 | 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
|
212 | 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
|
213 | 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
|
214 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | return QWebPage.acceptNavigationRequest(self, frame, request, type_) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | def populateNetworkRequest(self, request): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | Public method to add data to a network request. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | @param request reference to the network request object (QNetworkRequest) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | """ |
1593
470b03ae90e7
A fix for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1588
diff
changeset
|
223 | try: |
470b03ae90e7
A fix for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1588
diff
changeset
|
224 | request.setAttribute(QNetworkRequest.User + 100, self) |
470b03ae90e7
A fix for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1588
diff
changeset
|
225 | request.setAttribute(QNetworkRequest.User + 101, self.__lastRequestType) |
470b03ae90e7
A fix for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1588
diff
changeset
|
226 | except TypeError: |
470b03ae90e7
A fix for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1588
diff
changeset
|
227 | pass |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | def pageAttributeId(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | 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
|
232 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | @return attribute id of the page attribute (integer) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | 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
|
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 | 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
|
238 | """ |
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 | 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
|
240 | |
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 | @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
|
242 | @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
|
243 | """ |
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 | 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
|
245 | 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
|
246 | 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
|
247 | 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
|
248 | 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
|
249 | |
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 | 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
|
251 | |
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 | 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
|
253 | """ |
21f7999b7abe
Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
256
diff
changeset
|
254 | 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
|
255 | |
21f7999b7abe
Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
256
diff
changeset
|
256 | @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
|
257 | @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
|
258 | @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
|
259 | @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
|
260 | """ |
21f7999b7abe
Fixed an issue causing the web browser not to show an error page due to a changed Qt API (>= 4.6; needs a patch to PyQt4).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
256
diff
changeset
|
261 | try: |
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 | 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
|
263 | 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
|
264 | 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
|
265 | # 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
|
266 | return False |
0540f3c52b46
Changed the web browser to give it a more modern look.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
641
diff
changeset
|
267 | |
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
|
268 | 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
|
269 | urlString = bytes(info.url.toEncoded()).decode() |
1615
bf0fc9794f33
Changed the web browser error page to include a "try again" option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1596
diff
changeset
|
270 | errorPage.baseUrl = info.url |
1647
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
271 | if info.domain == QWebPage.QtNetwork and \ |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
272 | info.error == QNetworkReply.ContentAccessDenied and \ |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
273 | info.errorString.startswith("AdBlockRule:"): |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
274 | if info.frame != info.frame.page().mainFrame(): |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
275 | # content in <iframe> |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
276 | docElement = info.frame.page().mainFrame().documentElement() |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
277 | for element in docElement.findAll("iframe"): |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
278 | src = element.attribute("src") |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
279 | if src in info.url.toString(): |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
280 | element.setAttribute("style", "display:none;") |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
281 | return False |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
282 | else: |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
283 | # the whole page is blocked |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
284 | rule = info.errorString.replace("AdBlockRule:", "") |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
285 | title = self.trUtf8("Content blocked by AdBlock Plus") |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
286 | message = self.trUtf8("Blocked by rule: <i>{0}</i>").format(rule) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
287 | |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
288 | htmlFile = QFile(":/html/adblockPage.html") |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
289 | htmlFile.open(QFile.ReadOnly) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
290 | html = htmlFile.readAll() |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
291 | html = html.replace("@FAVICON@", "qrc:icons/adBlockPlus16.png") |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
292 | html = html.replace("@IMAGE@", "qrc:icons/adBlockPlus64.png") |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
293 | html = html.replace("@TITLE@", title.encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
294 | html = html.replace("@MESSAGE@", message.encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
295 | errorPage.content = html |
1647
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
296 | return True |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
297 | |
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
|
298 | title = self.trUtf8("Error loading page: {0}").format(urlString) |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
299 | htmlFile = QFile(":/html/notFoundPage.html") |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
300 | htmlFile.open(QFile.ReadOnly) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
301 | html = htmlFile.readAll() |
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
|
302 | pixmap = qApp.style()\ |
1670
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1665
diff
changeset
|
303 | .standardIcon(QStyle.SP_MessageBoxWarning).pixmap(48, 48) |
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
|
304 | 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
|
305 | 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
|
306 | if pixmap.save(imageBuffer, "PNG"): |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
307 | html = html.replace("@IMAGE@", imageBuffer.buffer().toBase64()) |
1647
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
308 | pixmap = qApp.style()\ |
1670
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1665
diff
changeset
|
309 | .standardIcon(QStyle.SP_MessageBoxWarning).pixmap(16, 16) |
1647
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
310 | imageBuffer = QBuffer() |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
311 | imageBuffer.open(QIODevice.ReadWrite) |
30be422ac04b
Enhanced the web browser error page a bit and included an error page for content blocked by AdBlock Plus.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1615
diff
changeset
|
312 | if pixmap.save(imageBuffer, "PNG"): |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
313 | html = html.replace("@FAVICON@", imageBuffer.buffer().toBase64()) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
314 | html = html.replace("@TITLE@", title.encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
315 | html = html.replace("@H1@", info.errorString.encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
316 | html = html.replace("@H2@", self.trUtf8("When connecting to: {0}.")\ |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
317 | .format(urlString).encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
318 | html = html.replace("@LI-1@", |
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
|
319 | 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
|
320 | "<b>ww</b>.example.org instead of " |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
321 | "<b>www</b>.example.org").encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
322 | html = html.replace("@LI-2@", |
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
|
323 | self.trUtf8("If the address is correct, try checking the network " |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
324 | "connection.").encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
325 | html = html.replace("@LI-3@", |
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
|
326 | 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
|
327 | "or proxy, make sure that the browser is permitted to " |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
328 | "access the network.").encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
329 | html = html.replace("@LI-4@", |
629
c88489b378fb
Added configuration options for the web browser cache policy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
564
diff
changeset
|
330 | self.trUtf8("If your cache policy is set to offline browsing," |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
331 | "only pages in the local cache are available.")\ |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
332 | .encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
333 | html = html.replace("@BUTTON@", self.trUtf8("Try Again").encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
334 | errorPage.content = html |
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
|
335 | 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
|
336 | 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
|
337 | 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
|
338 | |
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
|
339 | 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
|
340 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
341 | def userAgent(self, resolveEmpty=False): |
383
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
342 | """ |
1596
8d59e4f3c828
Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1593
diff
changeset
|
343 | Public method to get the global user agent setting. |
383
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
344 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
345 | @param resolveEmpty flag indicating to resolve an empty |
383
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
346 | 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
|
347 | @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
|
348 | """ |
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
349 | 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
|
350 | 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
|
351 | 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
|
352 | 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
|
353 | |
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
354 | 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
|
355 | """ |
1596
8d59e4f3c828
Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1593
diff
changeset
|
356 | Public method to set the global user agent string. |
383
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
357 | |
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
358 | @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
|
359 | """ |
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
360 | 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
|
361 | |
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
362 | 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
|
363 | """ |
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
364 | 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
|
365 | |
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
366 | @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
|
367 | @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
|
368 | """ |
1596
8d59e4f3c828
Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1593
diff
changeset
|
369 | agent = Helpviewer.HelpWindow.HelpWindow.userAgentsManager().userAgentForUrl(url) |
383
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
370 | if agent == "": |
1596
8d59e4f3c828
Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1593
diff
changeset
|
371 | # no agent string specified for the given host -> use global one |
8d59e4f3c828
Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1593
diff
changeset
|
372 | agent = Preferences.getHelp("UserAgent") |
8d59e4f3c828
Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1593
diff
changeset
|
373 | if agent == "": |
8d59e4f3c828
Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1593
diff
changeset
|
374 | # no global agent string specified -> use default one |
8d59e4f3c828
Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1593
diff
changeset
|
375 | agent = QWebPage.userAgentForUrl(self, url) |
383
286de4e5179c
Added capability to select the user agent string for the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
381
diff
changeset
|
376 | 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
|
377 | |
2f4496b1956f
Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
653
diff
changeset
|
378 | 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
|
379 | """ |
2f4496b1956f
Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
653
diff
changeset
|
380 | 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
|
381 | |
2f4496b1956f
Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
653
diff
changeset
|
382 | 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
|
383 | |
2f4496b1956f
Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
653
diff
changeset
|
384 | @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
|
385 | """ |
2f4496b1956f
Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
653
diff
changeset
|
386 | 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
|
387 | 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
|
388 | 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
|
389 | 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
|
390 | |
2f4496b1956f
Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
653
diff
changeset
|
391 | 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
|
392 | |
2f4496b1956f
Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
653
diff
changeset
|
393 | if mainFrameRequest and \ |
1558
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
394 | self.__sslConfiguration is not None and \ |
657
099d1ab9073e
Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
656
diff
changeset
|
395 | reply.url() == self.mainFrame().url(): |
1558
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
396 | self.__sslConfiguration = None |
656
2f4496b1956f
Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
653
diff
changeset
|
397 | |
2f4496b1956f
Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
653
diff
changeset
|
398 | 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
|
399 | mainFrameRequest and \ |
1558
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
400 | self.__sslConfiguration is None and \ |
657
099d1ab9073e
Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
656
diff
changeset
|
401 | 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
|
402 | reply.url() == self.mainFrame().url(): |
1558
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
403 | self.__sslConfiguration = reply.sslConfiguration() |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
404 | self.__sslConfiguration.url = QUrl(reply.url()) |
1731
56cf9c150dbf
Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1670
diff
changeset
|
405 | |
56cf9c150dbf
Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1670
diff
changeset
|
406 | if reply.error() == QNetworkReply.NoError and \ |
56cf9c150dbf
Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1670
diff
changeset
|
407 | mainFrameRequest and \ |
56cf9c150dbf
Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1670
diff
changeset
|
408 | reply.url() == self.mainFrame().url(): |
56cf9c150dbf
Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1670
diff
changeset
|
409 | modified = reply.header(QNetworkRequest.LastModifiedHeader) |
56cf9c150dbf
Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1670
diff
changeset
|
410 | if modified and modified.isValid(): |
56cf9c150dbf
Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1670
diff
changeset
|
411 | manager = Helpviewer.HelpWindow.HelpWindow.bookmarksManager() |
56cf9c150dbf
Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1670
diff
changeset
|
412 | for bookmark in manager.bookmarksForUrl(reply.url()): |
56cf9c150dbf
Added code to write the timestamps to the Netscape bookmarks file and to record a timestamp for the last modification.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1670
diff
changeset
|
413 | manager.setTimestamp(bookmark, BookmarkNode.TsModified, modified) |
656
2f4496b1956f
Started adding code to the web browser to extract SSL information from replies.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
653
diff
changeset
|
414 | |
657
099d1ab9073e
Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
656
diff
changeset
|
415 | 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
|
416 | """ |
657
099d1ab9073e
Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
656
diff
changeset
|
417 | 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
|
418 | |
657
099d1ab9073e
Added the SSL info label to the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
656
diff
changeset
|
419 | @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
|
420 | """ |
1561
fe54c9df80e8
Fixed an issue with the latest browser changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1558
diff
changeset
|
421 | if self.__sslConfiguration is None: |
fe54c9df80e8
Fixed an issue with the latest browser changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1558
diff
changeset
|
422 | return None |
fe54c9df80e8
Fixed an issue with the latest browser changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1558
diff
changeset
|
423 | |
1558
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
424 | sslInfo = self.__sslConfiguration.peerCertificate() |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
425 | sslInfo.url = QUrl(self.__sslConfiguration.url) |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
426 | return sslInfo |
658
2856f7ea6780
Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
657
diff
changeset
|
427 | |
2856f7ea6780
Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
657
diff
changeset
|
428 | def showSslInfo(self): |
2856f7ea6780
Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
657
diff
changeset
|
429 | """ |
2856f7ea6780
Started implementing the SSL info display.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
657
diff
changeset
|
430 | 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
|
431 | """ |
1558
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
432 | if SSL_AVAILABLE and self.__sslConfiguration is not None: |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
433 | dlg = SslInfoDialog(self.getSslInfo(), self.view()) |
659
b53e67ae2021
Added code to show certificate info for https URLs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
658
diff
changeset
|
434 | dlg.exec_() |
664
3061f8bd826e
Fixed a few issues on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
661
diff
changeset
|
435 | else: |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
436 | E5MessageBox.warning(self.view(), |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
437 | self.trUtf8("SSL Certificate Info"), |
664
3061f8bd826e
Fixed a few issues on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
661
diff
changeset
|
438 | self.trUtf8("""There is no SSL Certificate Info available.""")) |
1558
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
439 | |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
440 | def hasValidSslInfo(self): |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
441 | """ |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
442 | Public method to check, if the page has a valid SSL certificate. |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
443 | |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
444 | @return flag indicating a valid SSL certificate (boolean) |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
445 | """ |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
446 | if self.__sslConfiguration is None: |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
447 | return False |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
448 | |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
449 | certList = self.__sslConfiguration.peerCertificateChain() |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
450 | if not certList: |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
451 | return False |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
452 | |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
453 | certificateDict = Preferences.toDict( |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
454 | Preferences.Prefs.settings.value("Help/CaCertificatesDict")) |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
455 | for server in certificateDict: |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
456 | localCAList = QSslCertificate.fromData(certificateDict[server]) |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
457 | for cert in certList: |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
458 | if cert in localCAList: |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
459 | return True |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
460 | |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
461 | for cert in certList: |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
462 | if not cert.isValid(): |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
463 | return False |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
464 | |
754120837dd8
Extended the check for acceptable SSL certificates for indication via the URL entry field.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1518
diff
changeset
|
465 | return True |
1651
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
466 | |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
467 | @classmethod |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
468 | def webPluginFactory(cls): |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
469 | """ |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
470 | Class method to get a reference to the web plug-in factory instance. |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
471 | |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
472 | @return reference to the web plug-in factory instance (WebPluginFactory |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
473 | """ |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
474 | if cls._webPluginFactory is None: |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
475 | cls._webPluginFactory = WebPluginFactory() |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
476 | |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
477 | return cls._webPluginFactory |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
478 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
479 | ########################################################################################## |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
480 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
481 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
482 | class HelpBrowser(QWebView): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
483 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
484 | Class implementing the helpbrowser widget. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
485 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
486 | 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
|
487 | interface compatible with the QTextBrowser based variant. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
488 | |
501
5c615a85241a
Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
487
diff
changeset
|
489 | @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
|
490 | @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
|
491 | @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
|
492 | @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
|
493 | @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
|
494 | """ |
487
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
495 | sourceChanged = pyqtSignal(QUrl) |
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
496 | forwardAvailable = pyqtSignal(bool) |
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
497 | backwardAvailable = pyqtSignal(bool) |
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
498 | highlighted = pyqtSignal(str) |
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
499 | search = pyqtSignal(QUrl) |
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
500 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
501 | def __init__(self, mainWindow, parent=None, name=""): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
502 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
503 | Constructor |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
504 | |
638
265c31231d9d
Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
634
diff
changeset
|
505 | @param mainWindow reference to the main window (HelpWindow) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
506 | @param parent parent widget of this window (QWidget) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
507 | @param name name of this window (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
508 | """ |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1112
diff
changeset
|
509 | super().__init__(parent) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
510 | self.setObjectName(name) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
511 | self.setWhatsThis(self.trUtf8( |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
512 | """<b>Help Window</b>""" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
513 | """<p>This window displays the selected help information.</p>""" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
514 | )) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
515 | |
1670
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1665
diff
changeset
|
516 | self.__speedDial = Helpviewer.HelpWindow.HelpWindow.speedDial() |
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1665
diff
changeset
|
517 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
518 | self.__page = HelpWebPage(self) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
519 | self.setPage(self.__page) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
520 | |
638
265c31231d9d
Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
634
diff
changeset
|
521 | self.mw = mainWindow |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
522 | self.ctrlPressed = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
523 | self.__isLoading = False |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
629
diff
changeset
|
524 | self.__progress = 0 |
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 | self.__currentZoom = 100 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
527 | self.__zoomLevels = [ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
528 | 30, 50, 67, 80, 90, |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
529 | 100, |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
530 | 110, 120, 133, 150, 170, 200, 240, 300, |
0
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 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
533 | self.__javaScriptBinding = None |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
534 | self.__javaScriptEricObject = None |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
535 | |
487
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
536 | self.mw.zoomTextOnlyChanged.connect(self.__applyZoom) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
537 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
538 | 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
|
539 | self.linkClicked.connect(self.setSource) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
540 | |
487
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
541 | 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
|
542 | 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
|
543 | self.page().linkHovered.connect(self.__linkHovered) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
544 | |
487
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
545 | 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
|
546 | 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
|
547 | self.loadFinished.connect(self.__loadFinished) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
548 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
549 | 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
|
550 | self.page().unsupportedContent.connect(self.__unsupportedContent) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
551 | |
487
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
552 | 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
|
553 | self.page().frameCreated.connect(self.__addExternalBinding) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
554 | self.__addExternalBinding(self.page().mainFrame()) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
555 | |
487
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
556 | 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
|
557 | |
487
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
558 | 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
|
559 | self.__currentEngineChanged) |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
560 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
561 | self.setAcceptDrops(True) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
562 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
563 | if hasattr(QtWebKit, 'QWebElement'): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
564 | self.__enableAccessKeys = Preferences.getHelp("AccessKeysEnabled") |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
565 | self.__accessKeysPressed = False |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
566 | self.__accessKeyLabels = [] |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
567 | self.__accessKeyNodes = {} |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
568 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
569 | self.page().loadStarted.connect(self.__hideAccessKeys) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
570 | self.page().scrollRequested.connect(self.__hideAccessKeys) |
1415
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
571 | |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
572 | self.__rss = [] |
1518
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
573 | |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
574 | self.__clickedFrame = None |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
575 | |
1518
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
576 | self.grabGesture(Qt.PinchGesture) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
577 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
578 | def __addExternalBinding(self, frame=None): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
579 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
580 | 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
|
581 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
582 | @param frame reference to the web frame (QWebFrame) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
583 | """ |
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
|
584 | 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
|
585 | # 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
|
586 | 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
|
587 | .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
|
588 | 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
|
589 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
590 | self.page().settings().setAttribute(QWebSettings.JavascriptEnabled, True) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
591 | 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
|
592 | self.__javaScriptBinding = JavaScriptExternalObject(self.mw, self) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
593 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
594 | if frame is None: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
595 | # called from QWebFrame.javaScriptWindowObjectCleared |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
596 | frame = self.sender() |
1584
38c0907eeea1
A little fix for the help browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1561
diff
changeset
|
597 | if isinstance(frame, HelpWebPage): |
38c0907eeea1
A little fix for the help browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1561
diff
changeset
|
598 | frame = frame.mainFrame() |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
599 | if frame.url().scheme() == "eric" and frame.url().path() == "home": |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
600 | 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
|
601 | self.__javaScriptEricObject = JavaScriptEricObject(self.mw, self) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
602 | frame.addToJavaScriptWindowObject("eric", self.__javaScriptEricObject) |
1670
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1665
diff
changeset
|
603 | elif frame.url().scheme() == "eric" and frame.url().path() == "speeddial": |
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1665
diff
changeset
|
604 | frame.addToJavaScriptWindowObject("speeddial", self.__speedDial) |
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1665
diff
changeset
|
605 | self.__speedDial.addWebFrame(frame) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
606 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
607 | # 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
|
608 | frame.javaScriptWindowObjectCleared.connect(self.__addExternalBinding) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
609 | frame.addToJavaScriptWindowObject("external", self.__javaScriptBinding) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
610 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
611 | def linkedResources(self, relation=""): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
612 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
613 | Public method to extract linked resources. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
614 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
615 | @param relation relation to extract (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
616 | @return list of linked resources (list of LinkedResource) |
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 | resources = [] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
619 | |
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
|
620 | 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
|
621 | 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
|
622 | |
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
|
623 | linkElements = self.page().mainFrame().findAllElements("html > head > link") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
624 | |
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
|
625 | 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
|
626 | 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
|
627 | 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
|
628 | 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
|
629 | 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
|
630 | |
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
|
631 | 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
|
632 | 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
|
633 | 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
|
634 | 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
|
635 | |
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
|
636 | 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
|
637 | 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
|
638 | 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
|
639 | 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
|
640 | 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
|
641 | |
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
|
642 | 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
|
643 | 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
|
644 | 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
|
645 | baseUrl = QUrl.fromEncoded(baseUrlString) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
646 | |
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
|
647 | 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
|
648 | 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
|
649 | 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
|
650 | 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
|
651 | href = m["href"] |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
652 | title = m["title"] |
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
|
653 | |
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
|
654 | 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
|
655 | 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
|
656 | 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
|
657 | 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
|
658 | |
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
|
659 | 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
|
660 | 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
|
661 | 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
|
662 | 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
|
663 | 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
|
664 | |
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
|
665 | resources.append(resource) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
666 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
667 | return resources |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
668 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
669 | def __currentEngineChanged(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
670 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
671 | 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
|
672 | """ |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
673 | if self.url().toString() == "eric:home": |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
674 | self.reload() |
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 | def setSource(self, name): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
677 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
678 | 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
|
679 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
680 | @param name filename to be shown (QUrl) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
681 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
682 | if name is None or not name.isValid(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
683 | return |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
684 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
685 | if self.ctrlPressed: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
686 | # open in a new window |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
687 | self.mw.newTab(name) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
688 | self.ctrlPressed = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
689 | return |
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 | if not name.scheme(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
692 | name.setUrl(Preferences.getHelp("DefaultScheme") + name.toString()) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
693 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
694 | if len(name.scheme()) == 1 or \ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
695 | name.scheme() == "file": |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
696 | # name is a local file |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
697 | if name.scheme() and len(name.scheme()) == 1: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
698 | # it is a local path on win os |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
699 | name = QUrl.fromLocalFile(name.toString()) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
700 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
701 | 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
|
702 | E5MessageBox.critical(self, |
1232
ed31e909cf2e
Harmonisation of some display strings related to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
703 | self.trUtf8("eric5 Web Browser"), |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
704 | 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
|
705 | .format(name.toLocalFile())) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
706 | return |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
707 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
708 | if name.toLocalFile().endswith(".pdf") or \ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
709 | name.toLocalFile().endswith(".PDF") or \ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
710 | name.toLocalFile().endswith(".chm") or \ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
711 | name.toLocalFile().endswith(".CHM"): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
712 | started = QDesktopServices.openUrl(name) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
713 | if not started: |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
535
diff
changeset
|
714 | E5MessageBox.critical(self, |
1232
ed31e909cf2e
Harmonisation of some display strings related to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
715 | self.trUtf8("eric5 Web Browser"), |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
716 | self.trUtf8("""<p>Could not start a viewer""" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
717 | """ for file <b>{0}</b>.</p>""").format(name.path())) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
718 | return |
278
c93823b96faa
Added a handler for ftp: URLs to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
260
diff
changeset
|
719 | elif name.scheme() in ["mailto"]: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
720 | started = QDesktopServices.openUrl(name) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
721 | if not started: |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
535
diff
changeset
|
722 | E5MessageBox.critical(self, |
1232
ed31e909cf2e
Harmonisation of some display strings related to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
723 | self.trUtf8("eric5 Web Browser"), |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
724 | self.trUtf8("""<p>Could not start an application""" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
725 | """ for URL <b>{0}</b>.</p>""").format(name.toString())) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
726 | return |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
727 | 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
|
728 | 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
|
729 | 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
|
730 | self.page().mainFrame().evaluateJavaScript(scriptSource) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
731 | return |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
732 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
733 | if name.toString().endswith(".pdf") or \ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
734 | name.toString().endswith(".PDF") or \ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
735 | name.toString().endswith(".chm") or \ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
736 | name.toString().endswith(".CHM"): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
737 | started = QDesktopServices.openUrl(name) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
738 | if not started: |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
535
diff
changeset
|
739 | E5MessageBox.critical(self, |
1232
ed31e909cf2e
Harmonisation of some display strings related to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
740 | self.trUtf8("eric5 Web Browser"), |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
741 | self.trUtf8("""<p>Could not start a viewer""" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
742 | """ for file <b>{0}</b>.</p>""").format(name.path())) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
743 | return |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
744 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
745 | self.load(name) |
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 | def source(self): |
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 | 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
|
750 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
751 | @return URL loaded in the help browser (QUrl) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
752 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
753 | return self.url() |
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 | def documentTitle(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
756 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
757 | 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
|
758 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
759 | @return title (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
760 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
761 | return self.title() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
762 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
763 | def backward(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
764 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
765 | Public slot to move backwards in history. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
766 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
767 | self.triggerPageAction(QWebPage.Back) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
768 | self.__urlChanged(self.history().currentItem().url()) |
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 forward(self): |
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 | Public slot to move forward in history. |
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 | self.triggerPageAction(QWebPage.Forward) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
775 | self.__urlChanged(self.history().currentItem().url()) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
776 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
777 | def home(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
778 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
779 | Public slot to move to the first page loaded. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
780 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
781 | homeUrl = QUrl(Preferences.getHelp("HomePage")) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
782 | self.setSource(homeUrl) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
783 | self.__urlChanged(self.history().currentItem().url()) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
784 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
785 | def reload(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
786 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
787 | Public slot to reload the current page. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
788 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
789 | self.triggerPageAction(QWebPage.Reload) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
790 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
791 | def copy(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
792 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
793 | Public slot to copy the selected text. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
794 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
795 | self.triggerPageAction(QWebPage.Copy) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
796 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
797 | def isForwardAvailable(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
798 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
799 | 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
|
800 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
801 | @return flag indicating move forward is possible (boolean) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
802 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
803 | return self.history().canGoForward() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
804 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
805 | def isBackwardAvailable(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
806 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
807 | 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
|
808 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
809 | @return flag indicating move backwards is possible (boolean) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
810 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
811 | return self.history().canGoBack() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
812 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
813 | def __levelForZoom(self, zoom): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
814 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
815 | 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
|
816 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
817 | @param zoom zoom factor (integer) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
818 | @return index of zoom factor (integer) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
819 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
820 | try: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
821 | index = self.__zoomLevels.index(zoom) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
822 | except ValueError: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
823 | for index in range(len(self.__zoomLevels)): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
824 | if zoom <= self.__zoomLevels[index]: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
825 | break |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
826 | return index |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
827 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
828 | def __applyZoom(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
829 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
830 | Private slot to apply the current zoom factor. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
831 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
832 | try: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
833 | self.setZoomFactor(self.__currentZoom / 100.0) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
834 | except AttributeError: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
835 | self.setTextSizeMultiplier(self.__currentZoom / 100.0) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
836 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
837 | def zoomIn(self): |
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 | Public slot to zoom into the page. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
840 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
841 | index = self.__levelForZoom(self.__currentZoom) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
842 | if index < len(self.__zoomLevels) - 1: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
843 | self.__currentZoom = self.__zoomLevels[index + 1] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
844 | self.__applyZoom() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
845 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
846 | def zoomOut(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
847 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
848 | Public slot to zoom out of the page. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
849 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
850 | index = self.__levelForZoom(self.__currentZoom) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
851 | if index > 0: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
852 | self.__currentZoom = self.__zoomLevels[index - 1] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
853 | self.__applyZoom() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
854 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
855 | def zoomReset(self): |
0
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 | Public method to reset the zoom factor. |
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 | self.__currentZoom = 100 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
860 | self.__applyZoom() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
861 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
862 | def hasSelection(self): |
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 | 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
|
865 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
866 | @return flag indicating text has been selected (boolean) |
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 | return self.selectedText() != "" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
869 | |
376
0c4c359c4870
Added option to highlight all occurences to the web browser search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
350
diff
changeset
|
870 | def findNextPrev(self, txt, case, backwards, wrap, highlightAll): |
0
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 | 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
|
873 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
874 | @param txt text to search for (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
875 | @param case flag indicating a case sensitive search (boolean) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
876 | @param backwards flag indicating a backwards search (boolean) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
877 | @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
|
878 | @param highlightAll flag indicating to highlight all occurrences (boolean) |
1823
21d988eaf1bf
Added the capability to search in the recorded log of the log viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1733
diff
changeset
|
879 | @return flag indicating that a match was found (boolean) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
880 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
881 | findFlags = QWebPage.FindFlags() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
882 | if case: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
883 | findFlags |= QWebPage.FindCaseSensitively |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
884 | if backwards: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
885 | findFlags |= QWebPage.FindBackward |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
886 | if wrap: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
887 | 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
|
888 | try: |
0c4c359c4870
Added option to highlight all occurences to the web browser search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
350
diff
changeset
|
889 | 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
|
890 | 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
|
891 | 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
|
892 | pass |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
893 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
894 | return self.findText(txt, findFlags) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
895 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
896 | def contextMenuEvent(self, evt): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
897 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
898 | Protected method called to create a context menu. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
899 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
900 | This method is overridden from QWebView. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
901 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
902 | @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
|
903 | """ |
1596
8d59e4f3c828
Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1593
diff
changeset
|
904 | from .UserAgent.UserAgentMenu import UserAgentMenu |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
905 | menu = QMenu(self) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
906 | |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
907 | frameAtPos = self.page().frameAt(evt.pos()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
908 | hit = self.page().mainFrame().hitTestContent(evt.pos()) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
909 | if not hit.linkUrl().isEmpty(): |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
910 | menu.addAction(UI.PixmapCache.getIcon("openNewTab.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
911 | self.trUtf8("Open Link in New Tab\tCtrl+LMB"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
912 | self.__openLinkInNewTab).setData(hit.linkUrl()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
913 | menu.addSeparator() |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
914 | menu.addAction(UI.PixmapCache.getIcon("download.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
915 | self.trUtf8("Save Lin&k"), self.__downloadLink) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
916 | menu.addAction(UI.PixmapCache.getIcon("bookmark22.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
917 | self.trUtf8("Bookmark this Link"), self.__bookmarkLink)\ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
918 | .setData(hit.linkUrl()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
919 | menu.addSeparator() |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
920 | menu.addAction(UI.PixmapCache.getIcon("editCopy.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
921 | self.trUtf8("Copy Link to Clipboard"), self.__copyLink) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
922 | menu.addAction(UI.PixmapCache.getIcon("mailSend.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
923 | self.trUtf8("Send Link"), self.__sendLink).setData(hit.linkUrl()) |
978
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
924 | if Preferences.getHelp("VirusTotalEnabled") and \ |
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
925 | Preferences.getHelp("VirusTotalServiceKey") != "": |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
926 | menu.addAction(UI.PixmapCache.getIcon("virustotal.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
927 | self.trUtf8("Scan Link with VirusTotal"), self.__virusTotal)\ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
928 | .setData(hit.linkUrl()) |
0
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 hit.imageUrl().isEmpty(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
931 | if not menu.isEmpty(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
932 | menu.addSeparator() |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
933 | menu.addAction(UI.PixmapCache.getIcon("openNewTab.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
934 | self.trUtf8("Open Image in New Tab"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
935 | self.__openLinkInNewTab).setData(hit.imageUrl()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
936 | menu.addSeparator() |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
937 | menu.addAction(UI.PixmapCache.getIcon("download.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
938 | self.trUtf8("Save Image"), self.__downloadImage) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
939 | menu.addAction(self.trUtf8("Copy Image to Clipboard"), self.__copyImage) |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
940 | menu.addAction(UI.PixmapCache.getIcon("editCopy.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
941 | self.trUtf8("Copy Image Location to Clipboard"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
942 | self.__copyImageLocation).setData(hit.imageUrl().toString()) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
943 | menu.addAction(UI.PixmapCache.getIcon("mailSend.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
944 | self.trUtf8("Send Image Link"), self.__sendLink).setData(hit.imageUrl()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
945 | menu.addSeparator() |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
946 | menu.addAction(UI.PixmapCache.getIcon("adBlockPlus.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
947 | self.trUtf8("Block Image"), self.__blockImage)\ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
948 | .setData(hit.imageUrl().toString()) |
978
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
949 | if Preferences.getHelp("VirusTotalEnabled") and \ |
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
950 | Preferences.getHelp("VirusTotalServiceKey") != "": |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
951 | menu.addAction(UI.PixmapCache.getIcon("virustotal.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
952 | self.trUtf8("Scan Image with VirusTotal"), self.__virusTotal)\ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
953 | .setData(hit.imageUrl()) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
954 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
955 | element = hit.element() |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
956 | if not element.isNull() and \ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
957 | element.tagName().lower() in ["input", "textarea", "video", "audio"]: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
958 | if menu.isEmpty(): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
959 | self.page().createStandardContextMenu().exec_(evt.globalPos()) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
960 | return |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
961 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
962 | if not menu.isEmpty(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
963 | menu.addSeparator() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
964 | menu.addAction(self.mw.newTabAct) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
965 | menu.addAction(self.mw.newAct) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
966 | menu.addSeparator() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
967 | menu.addAction(self.mw.saveAsAct) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
968 | menu.addSeparator() |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
969 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
970 | if frameAtPos and self.page().mainFrame() != frameAtPos: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
971 | self.__clickedFrame = frameAtPos |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
972 | fmenu = QMenu(self.trUtf8("This Frame")) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
973 | frameUrl = self.__clickedFrame.url() |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
974 | if frameUrl.isValid(): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
975 | fmenu.addAction(self.trUtf8("Show &only this frame"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
976 | self.__loadClickedFrame) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
977 | fmenu.addAction(UI.PixmapCache.getIcon("openNewTab.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
978 | self.trUtf8("Show in new &tab"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
979 | self.__openLinkInNewTab).setData(self.__clickedFrame.url()) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
980 | fmenu.addSeparator() |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
981 | fmenu.addAction(UI.PixmapCache.getIcon("print.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
982 | self.trUtf8("&Print"), self.__printClickedFrame) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
983 | fmenu.addAction(UI.PixmapCache.getIcon("printPreview.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
984 | self.trUtf8("Print Preview"), self.__printPreviewClickedFrame) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
985 | fmenu.addAction(UI.PixmapCache.getIcon("printPdf.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
986 | self.trUtf8("Print as PDF"), self.__printPdfClickedFrame) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
987 | fmenu.addSeparator() |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
988 | fmenu.addAction(UI.PixmapCache.getIcon("zoomIn.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
989 | self.trUtf8("Zoom &in"), self.__zoomInClickedFrame) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
990 | fmenu.addAction(UI.PixmapCache.getIcon("zoomReset.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
991 | self.trUtf8("Zoom &reset"), self.__zoomResetClickedFrame) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
992 | fmenu.addAction(UI.PixmapCache.getIcon("zoomOut.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
993 | self.trUtf8("Zoom &out"), self.__zoomOutClickedFrame) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
994 | fmenu.addSeparator() |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
995 | fmenu.addAction(self.trUtf8("Show frame so&urce"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
996 | self.__showClickedFrameSource) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
997 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
998 | menu.addMenu(fmenu) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
999 | menu.addSeparator() |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1000 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1001 | menu.addAction(UI.PixmapCache.getIcon("bookmark22.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1002 | self.trUtf8("Bookmark this Page"), self.addBookmark) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1003 | menu.addAction(UI.PixmapCache.getIcon("mailSend.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1004 | self.trUtf8("Send Page Link"), self.__sendLink).setData(self.url()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1005 | menu.addSeparator() |
1596
8d59e4f3c828
Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1593
diff
changeset
|
1006 | self.__userAgentMenu = UserAgentMenu(self.trUtf8("User Agent"), url=self.url()) |
8d59e4f3c828
Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1593
diff
changeset
|
1007 | menu.addMenu(self.__userAgentMenu) |
8d59e4f3c828
Extended the User Agent handling to be able to set the string on a host basis (next to the global user agent string).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1593
diff
changeset
|
1008 | menu.addSeparator() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1009 | menu.addAction(self.mw.backAct) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1010 | menu.addAction(self.mw.forwardAct) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1011 | menu.addAction(self.mw.homeAct) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1012 | menu.addSeparator() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1013 | menu.addAction(self.mw.zoomInAct) |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1014 | menu.addAction(self.mw.zoomResetAct) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1015 | menu.addAction(self.mw.zoomOutAct) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1016 | menu.addSeparator() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1017 | if self.selectedText(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1018 | menu.addAction(self.mw.copyAct) |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1019 | menu.addAction(UI.PixmapCache.getIcon("mailSend.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1020 | self.trUtf8("Send Text"), self.__sendLink).setData(self.selectedText()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1021 | menu.addAction(self.mw.findAct) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1022 | menu.addSeparator() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1023 | if self.selectedText(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1024 | self.__searchMenu = menu.addMenu(self.trUtf8("Search with...")) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1025 | |
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
|
1026 | engineNames = self.mw.openSearchManager().allEnginesNames() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1027 | 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
|
1028 | engine = self.mw.openSearchManager().engine(engineName) |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1029 | self.__searchMenu.addAction( |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1030 | OpenSearchEngineAction(engine, self.__searchMenu).setData(engineName)) |
487
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
1031 | self.__searchMenu.triggered.connect(self.__searchRequested) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1032 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1033 | menu.addSeparator() |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1034 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1035 | languages = Preferences.toList( |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1036 | Preferences.Prefs.settings.value("Help/AcceptLanguages", |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1037 | HelpLanguagesDialog.defaultAcceptLanguages())) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1038 | if languages: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1039 | language = languages[0] |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1040 | langCode = language.split("[")[1][:2] |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1041 | googleTranslatorUrl = QUrl( |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1042 | "http://translate.google.com/#auto|{0}|{1}".format( |
1588
dccffd13be8d
Did some PEP-8 related corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1587
diff
changeset
|
1043 | langCode, self.selectedText())) |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1044 | menu.addAction(UI.PixmapCache.getIcon("translate.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1045 | self.trUtf8("Google Translate"), self.__openLinkInNewTab)\ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1046 | .setData(googleTranslatorUrl) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1047 | wiktionaryUrl = QUrl( |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1048 | "http://{0}.wiktionary.org/wiki/Special:Search?search={1}".format( |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1049 | langCode, self.selectedText())) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1050 | menu.addAction(UI.PixmapCache.getIcon("wikipedia.png"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1051 | self.trUtf8("Dictionary"), self.__openLinkInNewTab)\ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1052 | .setData(wiktionaryUrl) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1053 | menu.addSeparator() |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1054 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1055 | guessedUrl = QUrl.fromUserInput(self.selectedText().strip()) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1056 | if self.__isUrlValid(guessedUrl): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1057 | menu.addAction(self.trUtf8("Go to web address"), self.__openLinkInNewTab)\ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1058 | .setData(guessedUrl) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1059 | 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
|
1060 | |
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
|
1061 | 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
|
1062 | 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
|
1063 | 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
|
1064 | 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
|
1065 | element.attribute("type", "text") == "text": |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1066 | menu.addAction(self.trUtf8("Add to web search toolbar"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1067 | self.__addSearchEngine).setData(element) |
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
|
1068 | 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
|
1069 | |
1587
714a3627a089
Added an icon to the web browser context menu and added the forgotten icons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1586
diff
changeset
|
1070 | menu.addAction(UI.PixmapCache.getIcon("webInspector.png"), |
714a3627a089
Added an icon to the web browser context menu and added the forgotten icons.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1586
diff
changeset
|
1071 | self.trUtf8("Web Inspector..."), self.__webInspector) |
0
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 | menu.exec_(evt.globalPos()) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1074 | |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1075 | def __isUrlValid(self, url): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1076 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1077 | Private method to check a URL for validity. |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1078 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1079 | @param url URL to be checked (QUrl) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1080 | @return flag indicating a valid URL (boolean) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1081 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1082 | return url.isValid() and \ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1083 | bool(url.host()) and \ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1084 | bool(url.scheme()) and \ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1085 | "." in url.host() |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1086 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1087 | def __openLinkInNewTab(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1088 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1089 | 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
|
1090 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1091 | 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
|
1092 | url = act.data() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1093 | if url.isEmpty(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1094 | return |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1095 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1096 | self.ctrlPressed = True |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1097 | 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
|
1098 | self.ctrlPressed = False |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1099 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1100 | def __bookmarkLink(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1101 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1102 | 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
|
1103 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1104 | 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
|
1105 | url = act.data() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1106 | if url.isEmpty(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1107 | return |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1108 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1109 | dlg = AddBookmarkDialog() |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
1110 | dlg.setUrl(bytes(url.toEncoded()).decode()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1111 | dlg.exec_() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1112 | |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1113 | def __sendLink(self): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1114 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1115 | Private slot to send a link via email. |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1116 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1117 | act = self.sender() |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1118 | data = act.data() |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1119 | if isinstance(data, QUrl) and data.isEmpty(): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1120 | return |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1121 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1122 | if isinstance(data, QUrl): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1123 | data = data.toString() |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1124 | QDesktopServices.openUrl(QUrl("mailto:?body=" + data)) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1125 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1126 | def __downloadLink(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1127 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1128 | 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
|
1129 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1130 | self.pageAction(QWebPage.DownloadLinkToDisk).trigger() |
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 | def __copyLink(self): |
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 | Private slot to copy a link to the clipboard. |
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.pageAction(QWebPage.CopyLinkToClipboard).trigger() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1137 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1138 | def __downloadImage(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1139 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1140 | 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
|
1141 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1142 | self.pageAction(QWebPage.DownloadImageToDisk).trigger() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1143 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1144 | def __copyImage(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1145 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1146 | Private slot to copy an image to the clipboard. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1147 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1148 | self.pageAction(QWebPage.CopyImageToClipboard).trigger() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1149 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1150 | def __copyImageLocation(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1151 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1152 | 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
|
1153 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1154 | 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
|
1155 | url = act.data() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1156 | QApplication.clipboard().setText(url) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1157 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1158 | def __blockImage(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1159 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1160 | 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
|
1161 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1162 | 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
|
1163 | url = act.data() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1164 | dlg = Helpviewer.HelpWindow.HelpWindow.adblockManager().showDialog() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1165 | dlg.addCustomRule(url) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1166 | |
978
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
1167 | def __virusTotal(self): |
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
1168 | """ |
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
1169 | Private slot to scan the selected URL with VirusTotal. |
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
1170 | """ |
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
1171 | act = self.sender() |
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
1172 | url = act.data() |
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
1173 | self.mw.requestVirusTotalScan(url) |
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
1174 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1175 | def __searchRequested(self, act): |
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 | 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
|
1178 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1179 | @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
|
1180 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1181 | searchText = self.selectedText() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1182 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1183 | if not searchText: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1184 | return |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1185 | |
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
|
1186 | engineName = act.data() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1187 | 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
|
1188 | 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
|
1189 | self.search.connect(engine.searchUrl(searchText)) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1190 | |
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
|
1191 | 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
|
1192 | """ |
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
|
1193 | 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
|
1194 | """ |
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
|
1195 | 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
|
1196 | 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
|
1197 | 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
|
1198 | |
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
|
1199 | 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
|
1200 | 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
|
1201 | 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
|
1202 | 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
|
1203 | 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
|
1204 | |
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
|
1205 | 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
|
1206 | 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
|
1207 | 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
|
1208 | |
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
|
1209 | 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
|
1210 | if method != "get": |
539
87f9bce38a44
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
538
diff
changeset
|
1211 | 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
|
1212 | 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
|
1213 | 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
|
1214 | 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
|
1215 | |
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
|
1216 | 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
|
1217 | 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
|
1218 | 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
|
1219 | 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
|
1220 | |
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
|
1221 | 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
|
1222 | 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
|
1223 | 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
|
1224 | 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
|
1225 | 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
|
1226 | 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
|
1227 | |
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
|
1228 | 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
|
1229 | 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
|
1230 | 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
|
1231 | 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
|
1232 | 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
|
1233 | 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
|
1234 | 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
|
1235 | 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
|
1236 | 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
|
1237 | 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
|
1238 | 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
|
1239 | |
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
|
1240 | 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
|
1241 | 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
|
1242 | 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
|
1243 | 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
|
1244 | 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
|
1245 | 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
|
1246 | |
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
|
1247 | 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
|
1248 | 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
|
1249 | 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
|
1250 | |
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
|
1251 | 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
|
1252 | 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
|
1253 | searchEngine, ok = QInputDialog.getItem( |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
1254 | self, |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
1255 | self.trUtf8("Search engine"), |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
1256 | self.trUtf8("Choose the desired search engine"), |
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
|
1257 | 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
|
1258 | |
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
|
1259 | 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
|
1260 | 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
|
1261 | |
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
|
1262 | 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
|
1263 | 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
|
1264 | |
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
|
1265 | 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
|
1266 | 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
|
1267 | 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
|
1268 | 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
|
1269 | |
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
|
1270 | 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
|
1271 | 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
|
1272 | 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
|
1273 | 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
|
1274 | 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
|
1275 | 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
|
1276 | 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
|
1277 | 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
|
1278 | |
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
|
1279 | 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
|
1280 | 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
|
1281 | 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
|
1282 | 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
|
1283 | 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
|
1284 | |
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
|
1285 | 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
|
1286 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1287 | def __webInspector(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1288 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1289 | Private slot to show the web inspector window. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1290 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1291 | self.triggerPageAction(QWebPage.InspectElement) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1292 | |
661
f9d49e0c2522
Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
659
diff
changeset
|
1293 | def addBookmark(self): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1294 | """ |
661
f9d49e0c2522
Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
659
diff
changeset
|
1295 | Public slot to bookmark the current page. |
0
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 | dlg = AddBookmarkDialog() |
12
1d8dd9706f46
First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7
diff
changeset
|
1298 | dlg.setUrl(bytes(self.url().toEncoded()).decode()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1299 | dlg.setTitle(self.title()) |
1733
231e6f05d274
Added a dialog to edit bookmark properties and the description to the add bookmark dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1731
diff
changeset
|
1300 | meta = self.page().mainFrame().metaData() |
231e6f05d274
Added a dialog to edit bookmark properties and the description to the add bookmark dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1731
diff
changeset
|
1301 | if "description" in meta: |
231e6f05d274
Added a dialog to edit bookmark properties and the description to the add bookmark dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1731
diff
changeset
|
1302 | dlg.setDescription(meta["description"][0]) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1303 | dlg.exec_() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1304 | |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1305 | def dragEnterEvent(self, evt): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1306 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1307 | Protected method called by a drag enter event. |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1308 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1309 | @param evt reference to the drag enter event (QDragEnterEvent) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1310 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1311 | evt.acceptProposedAction() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1312 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1313 | def dragMoveEvent(self, evt): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1314 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1315 | Protected method called by a drag move event. |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1316 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1317 | @param evt reference to the drag move event (QDragMoveEvent) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1318 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1319 | evt.ignore() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1320 | if evt.source() != self: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1321 | if len(evt.mimeData().urls()) > 0: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1322 | evt.acceptProposedAction() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1323 | else: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1324 | url = QUrl(evt.mimeData().text()) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1325 | if url.isValid(): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1326 | evt.acceptProposedAction() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1327 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1328 | if not evt.isAccepted(): |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1112
diff
changeset
|
1329 | super().dragMoveEvent(evt) |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1330 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1331 | def dropEvent(self, evt): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1332 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1333 | Protected method called by a drop event. |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1334 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1335 | @param evt reference to the drop event (QDropEvent) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1336 | """ |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1112
diff
changeset
|
1337 | super().dropEvent(evt) |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1338 | if not evt.isAccepted() and \ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1339 | evt.source() != self and \ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1340 | evt.possibleActions() & Qt.CopyAction: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1341 | url = QUrl() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1342 | if len(evt.mimeData().urls()) > 0: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1343 | url = evt.mimeData().urls()[0] |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1344 | if not url.isValid(): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1345 | url = QUrl(evt.mimeData().text()) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1346 | if url.isValid(): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1347 | self.setSource(url) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1348 | evt.acceptProposedAction() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1349 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1350 | def mousePressEvent(self, evt): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1351 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1352 | Protected method called by a mouse press event. |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1353 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1354 | @param evt reference to the mouse event (QMouseEvent) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1355 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1356 | self.mw.setEventMouseButtons(evt.buttons()) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1357 | self.mw.setEventKeyboardModifiers(evt.modifiers()) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1358 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1359 | if evt.button() == Qt.XButton1: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1360 | self.pageAction(QWebPage.Back).trigger() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1361 | elif evt.button() == Qt.XButton2: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1362 | self.pageAction(QWebPage.Forward).trigger() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1363 | else: |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1112
diff
changeset
|
1364 | super().mousePressEvent(evt) |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1365 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1366 | def mouseReleaseEvent(self, evt): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1367 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1368 | Protected method called by a mouse release event. |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1369 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1370 | @param evt reference to the mouse event (QMouseEvent) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1371 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1372 | accepted = evt.isAccepted() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1373 | self.__page.event(evt) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1374 | if not evt.isAccepted() and \ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1375 | self.mw.eventMouseButtons() & Qt.MidButton: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1376 | url = QUrl(QApplication.clipboard().text(QClipboard.Selection)) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1377 | if not url.isEmpty() and \ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1378 | url.isValid() and \ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1379 | url.scheme() != "": |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1380 | self.mw.setEventMouseButtons(Qt.NoButton) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1381 | self.mw.setEventKeyboardModifiers(Qt.NoModifier) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1382 | self.setSource(url) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1383 | evt.setAccepted(accepted) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1384 | |
1518
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1385 | def wheelEvent(self, evt): |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1386 | """ |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1387 | Protected method to handle wheel events. |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1388 | |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1389 | @param evt reference to the wheel event (QWheelEvent) |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1390 | """ |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1391 | if evt.modifiers() & Qt.ControlModifier: |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1392 | degrees = evt.delta() // 8 |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1393 | steps = degrees // 15 |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1394 | self.__currentZoom += steps * 10 |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1395 | self.__applyZoom() |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1396 | evt.accept() |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1397 | return |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1398 | |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1399 | if evt.modifiers() & Qt.ShiftModifier: |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1400 | if evt.delta() < 0: |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1401 | self.backward() |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1402 | else: |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1403 | self.forward() |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1404 | evt.accept() |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1405 | return |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1406 | |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1407 | super().wheelEvent(evt) |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1408 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1409 | def keyPressEvent(self, evt): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1410 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1411 | Protected method called by a key press. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1412 | |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1413 | @param evt reference to the key event (QKeyEvent) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1414 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1415 | if hasattr(QtWebKit, 'QWebElement'): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1416 | if self.__enableAccessKeys: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1417 | self.__accessKeysPressed = ( |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1418 | evt.modifiers() == Qt.ControlModifier and \ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1419 | evt.key() == Qt.Key_Control) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1420 | if not self.__accessKeysPressed: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1421 | if self.__checkForAccessKey(evt): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1422 | self.__hideAccessKeys() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1423 | evt.accept() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1424 | return |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1425 | self.__hideAccessKeys() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1426 | else: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1427 | QTimer.singleShot(300, self.__accessKeyShortcut) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1428 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1429 | self.ctrlPressed = (evt.key() == Qt.Key_Control) |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1112
diff
changeset
|
1430 | super().keyPressEvent(evt) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1431 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1432 | def keyReleaseEvent(self, evt): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1433 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1434 | Protected method called by a key release. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1435 | |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1436 | @param evt reference to the key event (QKeyEvent) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1437 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1438 | if hasattr(QtWebKit, 'QWebElement'): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1439 | if self.__enableAccessKeys: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1440 | self.__accessKeysPressed = evt.key() == Qt.Key_Control |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1441 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1442 | self.ctrlPressed = False |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1112
diff
changeset
|
1443 | super().keyReleaseEvent(evt) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1444 | |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1445 | def focusOutEvent(self, evt): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1446 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1447 | Protected method called by a focus out event. |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1448 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1449 | @param evt reference to the focus event (QFocusEvent) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1450 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1451 | if hasattr(QtWebKit, 'QWebElement'): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1452 | if self.__accessKeysPressed: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1453 | self.__hideAccessKeys() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1454 | self.__accessKeysPressed = False |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1455 | |
1131
7781e396c903
Changed the code to use super() to access the superclass.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1112
diff
changeset
|
1456 | super().focusOutEvent(evt) |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1457 | |
1518
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1458 | def event(self, evt): |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1459 | """ |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1460 | Protected method handling events. |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1461 | |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1462 | @param evt reference to the event (QEvent) |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1463 | @return flag indicating, if the event was handled (boolean) |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1464 | """ |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1465 | if evt.type() == QEvent.Gesture: |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1466 | self.gestureEvent(evt) |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1467 | return True |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1468 | |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1469 | return super().event(evt) |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1470 | |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1471 | def gestureEvent(self, evt): |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1472 | """ |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1473 | Protected method handling gesture events. |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1474 | |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1475 | @param evt reference to the gesture event (QGestureEvent |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1476 | """ |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1477 | pinch = evt.gesture(Qt.PinchGesture) |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1478 | if pinch: |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1479 | if pinch.state() == Qt.GestureStarted: |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1480 | pinch.setScaleFactor(self.__currentZoom / 100.0) |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1481 | else: |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1482 | scaleFactor = pinch.scaleFactor() |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1483 | self.__currentZoom = int(scaleFactor * 100) |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1484 | self.__applyZoom() |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1485 | evt.accept() |
e6e21910210d
Added capability to zoom by a pinch gesture to the editor, the shell, the terminal, the web browser and various graphics related windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
1486 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1487 | def clearHistory(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1488 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1489 | Public slot to clear the history. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1490 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1491 | self.history().clear() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1492 | self.__urlChanged(self.history().currentItem().url()) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1493 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1494 | ############################################################################ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1495 | ## Signal converters below |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1496 | ############################################################################ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1497 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1498 | def __urlChanged(self, url): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1499 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1500 | Private slot to handle the urlChanged signal. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1501 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1502 | @param url the new url (QUrl) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1503 | """ |
487
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
1504 | self.sourceChanged.emit(url) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1505 | |
487
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
1506 | 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
|
1507 | self.backwardAvailable.emit(self.isBackwardAvailable()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1508 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1509 | def __statusBarMessage(self, text): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1510 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1511 | Private slot to handle the statusBarMessage signal. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1512 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1513 | @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
|
1514 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1515 | self.mw.statusBar().showMessage(text) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1516 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1517 | def __linkHovered(self, link, title, textContent): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1518 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1519 | Private slot to handle the linkHovered signal. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1520 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1521 | @param link the URL of the link (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1522 | @param title the link title (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1523 | @param textContent text content of the link (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1524 | """ |
487
4d41d03d3d00
Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
383
diff
changeset
|
1525 | self.highlighted.emit(link) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1526 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1527 | ############################################################################ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1528 | ## Signal handlers below |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1529 | ############################################################################ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1530 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1531 | def __loadStarted(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1532 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1533 | Private method to handle the loadStarted signal. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1534 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1535 | self.__isLoading = True |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
629
diff
changeset
|
1536 | self.__progress = 0 |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1537 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1538 | def __loadProgress(self, progress): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1539 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1540 | Private method to handle the loadProgress signal. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1541 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1542 | @param progress progress value (integer) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1543 | """ |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
629
diff
changeset
|
1544 | self.__progress = progress |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1545 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1546 | def __loadFinished(self, ok): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1547 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1548 | Private method to handle the loadFinished signal. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1549 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1550 | @param ok flag indicating the result (boolean) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1551 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1552 | self.__isLoading = False |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
629
diff
changeset
|
1553 | self.__progress = 0 |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1554 | |
1651
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
1555 | if Preferences.getHelp("ClickToFlashEnabled"): |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
1556 | # this is a hack to make the ClickToFlash button appear |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
1557 | self.zoomIn() |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
1558 | self.zoomOut() |
bc68f24d5658
Added the ClickToFlash plug-in to (temporarily) block Flash and related content.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1647
diff
changeset
|
1559 | |
256
04083f42042d
Some changes to the eric web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
168
diff
changeset
|
1560 | 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
|
1561 | 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
|
1562 | self.mw.passwordManager().fill(self.page()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1563 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1564 | def isLoading(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1565 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1566 | Public method to get the loading state. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1567 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1568 | @return flag indicating the loading state (boolean) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1569 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1570 | return self.__isLoading |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1571 | |
634
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
629
diff
changeset
|
1572 | def progress(self): |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
629
diff
changeset
|
1573 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
629
diff
changeset
|
1574 | 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
|
1575 | """ |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
629
diff
changeset
|
1576 | return self.__progress |
7b84cbd2f752
Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
629
diff
changeset
|
1577 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1578 | def saveAs(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1579 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1580 | 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
|
1581 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1582 | url = self.url() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1583 | if url.isEmpty(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1584 | return |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1585 | |
978
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
1586 | self.mw.downloadManager().download(url, True, mainWindow=self.mw) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1587 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
1588 | def __unsupportedContent(self, reply, requestFilename=None, download=False): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1589 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1590 | Private slot to handle the unsupportedContent signal. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1591 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1592 | @param reply reference to the reply object (QNetworkReply) |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
1593 | @keyparam requestFilename indicating to ask for a filename |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1594 | (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
|
1595 | by a configuration option. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1596 | @keyparam download flag indicating a download operation (boolean) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1597 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1598 | if reply is None: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1599 | return |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1600 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1601 | replyUrl = reply.url() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1602 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1603 | if replyUrl.scheme() == "abp": |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1604 | return |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1605 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1606 | 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
|
1607 | if reply.header(QNetworkRequest.ContentTypeHeader): |
b0061a6f7484
Added a download manager to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
664
diff
changeset
|
1608 | self.mw.downloadManager().handleUnsupportedContent( |
978
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
1609 | reply, webPage=self.page(), mainWindow=self.mw) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1610 | return |
676
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1611 | |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1612 | replyUrl = reply.url() |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1613 | if replyUrl.isEmpty(): |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1614 | return |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1615 | |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1616 | notFoundFrame = self.page().mainFrame() |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1617 | if notFoundFrame is None: |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1618 | return |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1619 | |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1620 | if reply.header(QNetworkRequest.ContentTypeHeader): |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1621 | data = reply.readAll() |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1622 | if contentSniff(data): |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
1623 | notFoundFrame.setHtml(str(data, encoding="utf-8"), replyUrl) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1624 | return |
676
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1625 | |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1626 | urlString = bytes(replyUrl.toEncoded()).decode() |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1627 | title = self.trUtf8("Error loading page: {0}").format(urlString) |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1628 | htmlFile = QFile(":/html/notFoundPage.html") |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1629 | htmlFile.open(QFile.ReadOnly) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1630 | html = htmlFile.readAll() |
676
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1631 | pixmap = qApp.style()\ |
1670
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1665
diff
changeset
|
1632 | .standardIcon(QStyle.SP_MessageBoxWarning).pixmap(48, 48) |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1633 | imageBuffer = QBuffer() |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1634 | imageBuffer.open(QIODevice.ReadWrite) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1635 | if pixmap.save(imageBuffer, "PNG"): |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1636 | html = html.replace("@IMAGE@", imageBuffer.buffer().toBase64()) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1637 | pixmap = qApp.style()\ |
1670
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1665
diff
changeset
|
1638 | .standardIcon(QStyle.SP_MessageBoxWarning).pixmap(16, 16) |
676
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1639 | imageBuffer = QBuffer() |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1640 | imageBuffer.open(QIODevice.ReadWrite) |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1641 | if pixmap.save(imageBuffer, "PNG"): |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1642 | html = html.replace("@FAVICON@", imageBuffer.buffer().toBase64()) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1643 | html = html.replace("@TITLE@", title.encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1644 | html = html.replace("@H1@", reply.errorString().encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1645 | html = html.replace("@H2@", self.trUtf8("When connecting to: {0}.")\ |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1646 | .format(urlString).encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1647 | html = html.replace("@LI-1@", |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1648 | self.trUtf8("Check the address for errors such as " |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1649 | "<b>ww</b>.example.org instead of " |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1650 | "<b>www</b>.example.org").encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1651 | html = html.replace("@LI-2@", |
676
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1652 | self.trUtf8("If the address is correct, try checking the network " |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1653 | "connection.").encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1654 | html = html.replace("@LI-3@", |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1655 | self.trUtf8("If your computer or network is protected by a firewall " |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1656 | "or proxy, make sure that the browser is permitted to " |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1657 | "access the network.").encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1658 | html = html.replace("@LI-4@", |
676
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1659 | self.trUtf8("If your cache policy is set to offline browsing," |
1665
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1660 | "only pages in the local cache are available.")\ |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1661 | .encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1662 | html = html.replace("@BUTTON@", self.trUtf8("Try Again").encode("utf8")) |
b248526d3a1b
Reworked some stuff in the web browser to use Qt resources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1651
diff
changeset
|
1663 | notFoundFrame.setHtml(bytes(html).decode("utf8"), replyUrl) |
676
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
1664 | 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
|
1665 | self.loadFinished.emit(False) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1666 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1667 | def __downloadRequested(self, request): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1668 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1669 | Private slot to handle a download request. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1670 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1671 | @param request reference to the request object (QNetworkRequest) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1672 | """ |
978
11f8adbcac97
Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
952
diff
changeset
|
1673 | self.mw.downloadManager().download(request, mainWindow=self.mw) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1674 | |
350
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1675 | 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
|
1676 | """ |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1677 | 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
|
1678 | |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1679 | @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
|
1680 | @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
|
1681 | """ |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1682 | securityOrigin = frame.securityOrigin() |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1683 | 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
|
1684 | securityOrigin.databaseUsage() == 0: |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1685 | # 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
|
1686 | # 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
|
1687 | return |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1688 | |
541
00e1a5d060c5
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
539
diff
changeset
|
1689 | 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
|
1690 | 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
|
1691 | 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
|
1692 | """ 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
|
1693 | """</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
|
1694 | .format(self.__dataString(securityOrigin.databaseQuota()), databaseName), |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
1695 | yesDefault=True) |
541
00e1a5d060c5
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
539
diff
changeset
|
1696 | if res: |
564
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
541
diff
changeset
|
1697 | 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
|
1698 | self, |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1699 | 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
|
1700 | 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
|
1701 | "step size = 5 MB):"\ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
1702 | .format(self.__dataString(securityOrigin.databaseQuota()), |
350
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1703 | 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
|
1704 | 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
|
1705 | if ok: |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1706 | 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
|
1707 | |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1708 | 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
|
1709 | """ |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1710 | 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
|
1711 | |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1712 | @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
|
1713 | @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
|
1714 | """ |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1715 | unit = "" |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1716 | if size < 1024: |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1717 | 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
|
1718 | 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
|
1719 | size /= 1024 |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1720 | 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
|
1721 | else: |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1722 | size /= 1024 * 1024 |
db40effc5c65
Added support for Web SQL Databases to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
313
diff
changeset
|
1723 | 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
|
1724 | 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
|
1725 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1726 | ############################################################################ |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1727 | ## Access key related methods below |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1728 | ############################################################################ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1729 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1730 | def __accessKeyShortcut(self): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1731 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1732 | Private slot to switch the display of access keys. |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1733 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1734 | if not self.hasFocus() or \ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1735 | not self.__accessKeysPressed or \ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1736 | not self.__enableAccessKeys: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1737 | return |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1738 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1739 | if self.__accessKeyLabels: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1740 | self.__hideAccessKeys() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1741 | else: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1742 | self.__showAccessKeys() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1743 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1744 | self.__accessKeysPressed = False |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1745 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1746 | def __checkForAccessKey(self, evt): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1747 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1748 | Private method to check the existence of an access key and activate the |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1749 | corresponding link. |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1750 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1751 | @param evt reference to the key event (QKeyEvent) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1752 | @return flag indicating, if the event was handled (boolean) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1753 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1754 | if not self.__accessKeyLabels: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1755 | return False |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1756 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1757 | text = evt.text() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1758 | if not text: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1759 | return False |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1760 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1761 | key = text[0].upper() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1762 | handled = False |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1763 | if key in self.__accessKeyNodes: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1764 | element = self.__accessKeyNodes[key] |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1765 | p = element.geometry().center() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1766 | frame = element.webFrame() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1767 | p -= frame.scrollPosition() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1768 | frame = frame.parentFrame() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1769 | while frame and frame != self.page().mainFrame(): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1770 | p -= frame.scrollPosition() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1771 | frame = frame.parentFrame() |
992
566e87428fc8
Fixed a few PEP-8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
978
diff
changeset
|
1772 | pevent = QMouseEvent(QEvent.MouseButtonPress, p, Qt.LeftButton, |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1773 | Qt.MouseButtons(Qt.NoButton), Qt.KeyboardModifiers(Qt.NoModifier)) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1774 | qApp.sendEvent(self, pevent) |
992
566e87428fc8
Fixed a few PEP-8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
978
diff
changeset
|
1775 | revent = QMouseEvent(QEvent.MouseButtonRelease, p, Qt.LeftButton, |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1776 | Qt.MouseButtons(Qt.NoButton), Qt.KeyboardModifiers(Qt.NoModifier)) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1777 | qApp.sendEvent(self, revent) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1778 | handled = True |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1779 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1780 | return handled |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1781 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1782 | def __hideAccessKeys(self): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1783 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1784 | Private slot to hide the access key labels. |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1785 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1786 | if self.__accessKeyLabels: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1787 | for label in self.__accessKeyLabels: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1788 | label.hide() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1789 | label.deleteLater() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1790 | self.__accessKeyLabels = [] |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1791 | self.__accessKeyNodes = {} |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1792 | self.update() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1793 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1794 | def __showAccessKeys(self): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1795 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1796 | Private method to show the access key labels. |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1797 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1798 | supportedElements = [ |
992
566e87428fc8
Fixed a few PEP-8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
978
diff
changeset
|
1799 | "input", "a", "area", "button", "label", "legend", "textarea", |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1800 | ] |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1801 | unusedKeys = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z" \ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1802 | " 0 1 2 3 4 5 6 7 8 9".split() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1803 | |
992
566e87428fc8
Fixed a few PEP-8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
978
diff
changeset
|
1804 | viewport = QRect(self.__page.mainFrame().scrollPosition(), |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1805 | self.__page.viewportSize()) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1806 | # Priority first goes to elements with accesskey attributes |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1807 | alreadyLabeled = [] |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1808 | for elementType in supportedElements: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1809 | result = self.page().mainFrame().findAllElements(elementType).toList() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1810 | for element in result: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1811 | geometry = element.geometry() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1812 | if geometry.size().isEmpty() or \ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1813 | not viewport.contains(geometry.topLeft()): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1814 | continue |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1815 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1816 | accessKeyAttribute = element.attribute("accesskey").upper() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1817 | if not accessKeyAttribute: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1818 | continue |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1819 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1820 | accessKey = "" |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1821 | i = 0 |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1822 | while i < len(accessKeyAttribute): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1823 | if accessKeyAttribute[i] in unusedKeys: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1824 | accessKey = accessKeyAttribute[i] |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1825 | break |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1826 | i += 2 |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1827 | if accessKey == "": |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1828 | continue |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1829 | unusedKeys.remove(accessKey) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1830 | self.__makeAccessLabel(accessKey, element) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1831 | alreadyLabeled.append(element) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1832 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1833 | # Pick an access key first from the letters in the text and then from the |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1834 | # list of unused access keys |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1835 | for elementType in supportedElements: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1836 | result = self.page().mainFrame().findAllElements(elementType).toList() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1837 | for element in result: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1838 | geometry = element.geometry() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1839 | if not unusedKeys or \ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1840 | element in alreadyLabeled or \ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1841 | geometry.size().isEmpty() or \ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1842 | not viewport.contains(geometry.topLeft()): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1843 | continue |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1844 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1845 | accessKey = "" |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1846 | text = element.toPlainText().upper() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1847 | for c in text: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1848 | if c in unusedKeys: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1849 | accessKey = c |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1850 | break |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1851 | if accessKey == "": |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1852 | accessKey = unusedKeys[0] |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1853 | unusedKeys.remove(accessKey) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1854 | self.__makeAccessLabel(accessKey, element) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1855 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1856 | def __makeAccessLabel(self, accessKey, element): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1857 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1858 | Private method to generate the access label for an element. |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1859 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1860 | @param accessKey access key to generate the label for (str) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1861 | @param element reference to the web element to create the label for |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1862 | (QWebElement) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1863 | """ |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1864 | label = QLabel(self) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1865 | label.setText("<qt><b>{0}</b></qt>".format(accessKey)) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1866 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1867 | p = QToolTip.palette() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1868 | color = QColor(Qt.yellow).lighter(150) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1869 | color.setAlpha(175) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1870 | p.setColor(QPalette.Window, color) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1871 | label.setPalette(p) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1872 | label.setAutoFillBackground(True) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1873 | label.setFrameStyle(QFrame.Box | QFrame.Plain) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1874 | point = element.geometry().center() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1875 | point -= self.__page.mainFrame().scrollPosition() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1876 | label.move(point) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1877 | label.show() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1878 | point.setX(point.x() - label.width() // 2) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1879 | label.move(point) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1880 | self.__accessKeyLabels.append(label) |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1881 | self.__accessKeyNodes[accessKey] = element |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1882 | |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1883 | ############################################################################ |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1884 | ## Miscellaneous methods below |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1885 | ############################################################################ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1886 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1887 | def createWindow(self, windowType): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1888 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1889 | 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
|
1890 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1891 | @param windowType type of the requested window (QWebPage.WebWindowType) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1892 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1893 | self.mw.newTab() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1894 | return self.mw.currentBrowser() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1895 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1896 | def preferencesChanged(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1897 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1898 | Public method to indicate a change of the settings. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1899 | """ |
952
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1900 | if hasattr(QtWebKit, 'QWebElement'): |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1901 | self.__enableAccessKeys = Preferences.getHelp("AccessKeysEnabled") |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1902 | if not self.__enableAccessKeys: |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1903 | self.__hideAccessKeys() |
cc3e2e5558e9
Added support for access keys and drag & drop to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
1904 | |
629
c88489b378fb
Added configuration options for the web browser cache policy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
564
diff
changeset
|
1905 | self.reload() |
1415
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1906 | |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1907 | ############################################################################ |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1908 | ## RSS related methods below |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1909 | ############################################################################ |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1910 | |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1911 | def checkRSS(self): |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1912 | """ |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1913 | Public method to check, if the loaded page contains feed links. |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1914 | |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1915 | @return flag indicating the existence of feed links (boolean) |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1916 | """ |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1917 | self.__rss = [] |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1918 | |
1474
1eaec11a0078
Fixed a few PEP-8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1415
diff
changeset
|
1919 | frame = self.page().mainFrame() |
1415
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1920 | linkElementsList = frame.findAllElements("link").toList() |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1921 | |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1922 | for linkElement in linkElementsList: |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1923 | # only atom+xml and rss+xml will be processed |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1924 | if linkElement.attribute("rel") != "alternate" or \ |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1925 | (linkElement.attribute("type") != "application/rss+xml" and \ |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1926 | linkElement.attribute("type") != "application/atom+xml"): |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1927 | continue |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1928 | |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1929 | title = linkElement.attribute("title") |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1930 | href = linkElement.attribute("href") |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1931 | if href == "" or title == "": |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1932 | continue |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1933 | self.__rss.append((title, href)) |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1934 | |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1935 | return len(self.__rss) > 0 |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1936 | |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1937 | def getRSS(self): |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1938 | """ |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1939 | Public method to get the extracted RSS feeds. |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1940 | |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1941 | @return list of RSS feeds (list of tuples of two strings) |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1942 | """ |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1943 | return self.__rss |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1944 | |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1945 | def hasRSS(self): |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1946 | """ |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1947 | Public method to check, if the loaded page has RSS links. |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1948 | |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1949 | @return flag indicating the presence of RSS links (boolean) |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1950 | """ |
28fa9633d57e
Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1232
diff
changeset
|
1951 | return len(self.__rss) > 0 |
1586
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1952 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1953 | ############################################################################ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1954 | ## Clicked Frame slots |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1955 | ############################################################################ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1956 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1957 | def __loadClickedFrame(self): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1958 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1959 | Private slot to load the selected frame only. |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1960 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1961 | self.setSource(self.__clickedFrame.url()) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1962 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1963 | def __printClickedFrame(self): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1964 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1965 | Private slot to print the selected frame. |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1966 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1967 | printer = QPrinter(mode=QPrinter.HighResolution) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1968 | if Preferences.getPrinter("ColorMode"): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1969 | printer.setColorMode(QPrinter.Color) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1970 | else: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1971 | printer.setColorMode(QPrinter.GrayScale) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1972 | if Preferences.getPrinter("FirstPageFirst"): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1973 | printer.setPageOrder(QPrinter.FirstPageFirst) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1974 | else: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1975 | printer.setPageOrder(QPrinter.LastPageFirst) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1976 | printer.setPageMargins( |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1977 | Preferences.getPrinter("LeftMargin") * 10, |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1978 | Preferences.getPrinter("TopMargin") * 10, |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1979 | Preferences.getPrinter("RightMargin") * 10, |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1980 | Preferences.getPrinter("BottomMargin") * 10, |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1981 | QPrinter.Millimeter |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1982 | ) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1983 | printer.setPrinterName(Preferences.getPrinter("PrinterName")) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1984 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1985 | printDialog = QPrintDialog(printer, self) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1986 | if printDialog.exec_() == QDialog.Accepted: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1987 | try: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1988 | self.__clickedFrame.print_(printer) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1989 | except AttributeError: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1990 | E5MessageBox.critical(self, |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1991 | self.trUtf8("eric5 Web Browser"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1992 | self.trUtf8("""<p>Printing is not available due to a bug in PyQt4.""" |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1993 | """Please upgrade.</p>""")) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1994 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1995 | def __printPreviewClickedFrame(self): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1996 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1997 | Private slot to show a print preview of the clicked frame. |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1998 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
1999 | from PyQt4.QtGui import QPrintPreviewDialog |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2000 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2001 | printer = QPrinter(mode=QPrinter.HighResolution) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2002 | if Preferences.getPrinter("ColorMode"): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2003 | printer.setColorMode(QPrinter.Color) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2004 | else: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2005 | printer.setColorMode(QPrinter.GrayScale) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2006 | if Preferences.getPrinter("FirstPageFirst"): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2007 | printer.setPageOrder(QPrinter.FirstPageFirst) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2008 | else: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2009 | printer.setPageOrder(QPrinter.LastPageFirst) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2010 | printer.setPageMargins( |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2011 | Preferences.getPrinter("LeftMargin") * 10, |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2012 | Preferences.getPrinter("TopMargin") * 10, |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2013 | Preferences.getPrinter("RightMargin") * 10, |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2014 | Preferences.getPrinter("BottomMargin") * 10, |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2015 | QPrinter.Millimeter |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2016 | ) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2017 | printer.setPrinterName(Preferences.getPrinter("PrinterName")) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2018 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2019 | preview = QPrintPreviewDialog(printer, self) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2020 | preview.paintRequested.connect(self.__generatePrintPreviewClickedFrame) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2021 | preview.exec_() |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2022 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2023 | def __generatePrintPreviewClickedFrame(self, printer): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2024 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2025 | Private slot to generate a print preview of the clicked frame. |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2026 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2027 | @param printer reference to the printer object (QPrinter) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2028 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2029 | try: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2030 | self.__clickedFrame.print_(printer) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2031 | except AttributeError: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2032 | E5MessageBox.critical(self, |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2033 | self.trUtf8("eric5 Web Browser"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2034 | self.trUtf8("""<p>Printing is not available due to a bug in PyQt4.""" |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2035 | """Please upgrade.</p>""")) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2036 | return |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2037 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2038 | def __printPdfClickedFrame(self): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2039 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2040 | Private slot to print the selected frame to PDF. |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2041 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2042 | printer = QPrinter(mode=QPrinter.HighResolution) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2043 | if Preferences.getPrinter("ColorMode"): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2044 | printer.setColorMode(QPrinter.Color) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2045 | else: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2046 | printer.setColorMode(QPrinter.GrayScale) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2047 | printer.setPrinterName(Preferences.getPrinter("PrinterName")) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2048 | printer.setOutputFormat(QPrinter.PdfFormat) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2049 | name = self.__clickedFrame.url().path().rsplit('/', 1)[-1] |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2050 | if name: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2051 | name = name.rsplit('.', 1)[0] |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2052 | name += '.pdf' |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2053 | printer.setOutputFileName(name) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2054 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2055 | printDialog = QPrintDialog(printer, self) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2056 | if printDialog.exec_() == QDialog.Accepted: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2057 | try: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2058 | self.__clickedFrame.print_(printer) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2059 | except AttributeError: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2060 | E5MessageBox.critical(self, |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2061 | self.trUtf8("eric5 Web Browser"), |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2062 | self.trUtf8("""<p>Printing is not available due to a bug in PyQt4.""" |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2063 | """Please upgrade.</p>""")) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2064 | return |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2065 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2066 | def __zoomInClickedFrame(self): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2067 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2068 | Private slot to zoom into the clicked frame. |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2069 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2070 | index = self.__levelForZoom(int(self.__clickedFrame.zoomFactor() * 100)) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2071 | if index < len(self.__zoomLevels) - 1: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2072 | self.__clickedFrame.setZoomFactor(self.__zoomLevels[index + 1] / 100) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2073 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2074 | def __zoomResetClickedFrame(self): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2075 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2076 | Private slot to reset the zoom factor of the clicked frame. |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2077 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2078 | self.__clickedFrame.setZoomFactor(self.__currentZoom / 100) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2079 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2080 | def __zoomOutClickedFrame(self): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2081 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2082 | Private slot to zoom out of the clicked frame. |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2083 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2084 | index = self.__levelForZoom(int(self.__clickedFrame.zoomFactor() * 100)) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2085 | if index > 0: |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2086 | self.__clickedFrame.setZoomFactor(self.__zoomLevels[index - 1] / 100) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2087 | |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2088 | def __showClickedFrameSource(self): |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2089 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2090 | Private slot to show the source of the clicked frame. |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2091 | """ |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2092 | from QScintilla.MiniEditor import MiniEditor |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2093 | src = self.__clickedFrame.toHtml() |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2094 | editor = MiniEditor(parent=self) |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2095 | editor.setText(src, "Html") |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2096 | editor.setLanguage("dummy.html") |
b3e34806b734
Extended the web page context menu by several entries to send links or the selected text, handling the clicked frame, translate the selected text with Google Translate and search it in Wictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1584
diff
changeset
|
2097 | editor.show() |
676
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2098 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
923
diff
changeset
|
2099 | |
676
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2100 | def contentSniff(data): |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2101 | """ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2102 | 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
|
2103 | |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2104 | @return flag indicating HTML content (boolean) |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2105 | """ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2106 | if data.contains("<!doctype") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2107 | data.contains("<script") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2108 | data.contains("<html") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2109 | data.contains("<!--") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2110 | data.contains("<head") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2111 | data.contains("<iframe") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2112 | data.contains("<h1") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2113 | data.contains("<div") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2114 | data.contains("<font") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2115 | data.contains("<table") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2116 | data.contains("<a") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2117 | data.contains("<style") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2118 | data.contains("<title") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2119 | data.contains("<b") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2120 | data.contains("<body") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2121 | data.contains("<br") or \ |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2122 | data.contains("<p"): |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2123 | return True |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2124 | |
6771da84fb0c
Did some refinesments to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
675
diff
changeset
|
2125 | return False |