eric6/WebBrowser/StatusBar/JavaScriptIcon.py

Sun, 14 Apr 2019 15:09:21 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 14 Apr 2019 15:09:21 +0200
changeset 6942
2602857055c5
parent 6645
WebBrowser/StatusBar/JavaScriptIcon.py@ad476851d7e0
child 7229
53054eb5b15a
permissions
-rw-r--r--

Major restructuring of the source tree to get prepared for a setup.py based installation.

4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6151
diff changeset
3 # Copyright (c) 2016 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the JavaScript status bar icon.
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 #
4966
d246d8568d6c Corrected a typo.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4965
diff changeset
11 # This is modeled after the code found in Qupzilla
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 # Copyright (C) 2014 David Rosca <nowrep@gmail.com>
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 #
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from __future__ import unicode_literals
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
6151
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6149
diff changeset
17 from PyQt5.QtCore import pyqtSlot, Qt, QPoint, QTimer
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from PyQt5.QtWidgets import QGraphicsColorizeEffect, QMenu, QDialog
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from PyQt5.QtWebEngineWidgets import QWebEngineSettings
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 from .StatusBarIcon import StatusBarIcon
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 import UI.PixmapCache
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 class JavaScriptIcon(StatusBarIcon):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 Class implementing the JavaScript status bar icon.
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 def __init__(self, window):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Constructor
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param window reference to the web browser window
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @type WebBrowserWindow
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 super(JavaScriptIcon, self).__init__(window)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.setToolTip(self.tr("Modify JavaScript settings temporarily for"
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 " a site or globally"))
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__icon = UI.PixmapCache.getPixmap("fileJavascript").scaled(16, 16)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.setPixmap(self.__icon)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
6144
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
44 self.__settings = {}
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
45
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self._window.tabWidget().currentChanged.connect(self.__updateIcon)
4965
a9a4b632fe48 Some enhancements for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4964
diff changeset
47 self._window.tabWidget().currentUrlChanged.connect(self.__updateIcon)
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.clicked.connect(self.__showMenu)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.__updateIcon()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 def preferencesChanged(self):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 Public method to handle changes of the settings.
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.__updateIcon()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @pyqtSlot(QPoint)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 def __showMenu(self, pos):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 Private slot to show the menu.
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 @param pos position to show the menu at
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 @type QPoint
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 boldFont = self.font()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 boldFont.setBold(True)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 menu = QMenu()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 menu.addAction(self.tr("Current Page Settings")).setFont(boldFont)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 if self._testCurrentPageWebAttribute(
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 QWebEngineSettings.JavascriptEnabled):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 act = menu.addAction(self.tr("Disable JavaScript (temporarily)"),
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.__toggleJavaScript)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 else:
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 act = menu.addAction(self.tr("Enable JavaScript (temporarily)"),
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.__toggleJavaScript)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 if self._currentPage() is not None and \
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self._currentPage().url().scheme() == "eric":
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 # JavaScript is needed for eric: scheme
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 act.setEnabled(False)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 menu.addSeparator()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 menu.addAction(self.tr("Global Settings")).setFont(boldFont)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 menu.addAction(self.tr("Manage JavaScript Settings"),
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.__showJavaScriptSettingsDialog)
5040
73c784b7b3bc Fixed a few issues pointed out by a user.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4966
diff changeset
88 menu.exec_(pos)
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 @pyqtSlot()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 def __updateIcon(self):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 Private slot to update the icon.
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 if self._testCurrentPageWebAttribute(
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 QWebEngineSettings.JavascriptEnabled):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.setGraphicsEffect(None)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 else:
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 effect = QGraphicsColorizeEffect(self)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 effect.setColor(Qt.gray)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.setGraphicsEffect(effect)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 @pyqtSlot()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 def __toggleJavaScript(self):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 Private slot to toggle the JavaScript setting.
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
6144
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
108 page = self._currentPage()
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
109 if page is None:
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 return
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 current = self._testCurrentPageWebAttribute(
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 QWebEngineSettings.JavascriptEnabled)
6136
dfef226f9c7f Removed WebBrowserPage.setJavaScriptEnabled().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
114 self._setCurrentPageWebAttribute(QWebEngineSettings.JavascriptEnabled,
dfef226f9c7f Removed WebBrowserPage.setJavaScriptEnabled().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
115 not current)
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116
6144
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
117 self.__settings[page] = not current
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
118 page.navigationRequestAccepted.connect(
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
119 lambda u, t, mf: self.__navigationRequestAccepted(u, t, mf, page))
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
120
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 self._window.currentBrowser().reload()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.__updateIcon()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 @pyqtSlot()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 def __showJavaScriptSettingsDialog(self):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 Private slot to show the JavaScript settings dialog.
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 Note: This is the JavaScript subset of the web browser configuration
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 page.
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 from .JavaScriptSettingsDialog import JavaScriptSettingsDialog
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 dlg = JavaScriptSettingsDialog(self._window)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 if dlg.exec_() == QDialog.Accepted:
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 self._window.preferencesChanged()
6151
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6149
diff changeset
137 QTimer.singleShot(500, self.__updateIcon)
6144
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
138
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
139 def __navigationRequestAccepted(self, url, navigationType, isMainFrame,
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
140 page):
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
141 """
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
142 Private method to handle the navigationRequestAccepted signal.
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
143
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
144 @param url URL being loaded
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
145 @type QUrl
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
146 @param navigationType type of navigation request
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
147 @type QWebEnginePage.NavigationType
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
148 @param isMainFrame flag indicating a navigation request of the
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
149 main frame
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
150 @type bool
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
151 @param page reference to the web page
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
152 @type WebBrowserPage
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
153 """
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
154 if url.scheme() in ("eric", "qthelp"):
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
155 enable = True
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
156 else:
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
157 enable = self.__settings[page]
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
158 if isMainFrame:
00c723b11d4d JavaScriptIcon: Made it work with per page settings and override settings on internal schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6136
diff changeset
159 page.settings().setAttribute(QWebEngineSettings.JavascriptEnabled,
6149
e611e45a17d6 Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6144
diff changeset
160 enable)

eric ide

mercurial