eric6/WebBrowser/StatusBar/JavaScriptIcon.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

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
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2016 - 2021 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
6151
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6149
diff changeset
15 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
16 from PyQt5.QtWidgets import QGraphicsColorizeEffect, QMenu, QDialog
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from PyQt5.QtWebEngineWidgets import QWebEngineSettings
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from .StatusBarIcon import StatusBarIcon
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 import UI.PixmapCache
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
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 class JavaScriptIcon(StatusBarIcon):
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 implementing the JavaScript status bar icon.
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 def __init__(self, window):
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 Constructor
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 @param window reference to the web browser window
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @type WebBrowserWindow
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 super(JavaScriptIcon, self).__init__(window)
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 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
38 " a site or globally"))
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 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
40 self.setPixmap(self.__icon)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
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
42 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
43
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 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
45 self._window.tabWidget().currentUrlChanged.connect(self.__updateIcon)
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.clicked.connect(self.__showMenu)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.__updateIcon()
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 def preferencesChanged(self):
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 Public method to handle changes of the settings.
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 self.__updateIcon()
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 @pyqtSlot(QPoint)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 def __showMenu(self, pos):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 Private slot to show the menu.
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 @param pos position to show the menu at
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 @type QPoint
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 boldFont = self.font()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 boldFont.setBold(True)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 menu = QMenu()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 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
69
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 if self._testCurrentPageWebAttribute(
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 QWebEngineSettings.JavascriptEnabled):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 act = menu.addAction(self.tr("Disable JavaScript (temporarily)"),
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.__toggleJavaScript)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 else:
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 act = menu.addAction(self.tr("Enable JavaScript (temporarily)"),
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__toggleJavaScript)
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
77 if (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
78 self._currentPage() is not None and
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
79 self._currentPage().url().scheme() == "eric"
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
80 ):
4964
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)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
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)
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
135 if dlg.exec() == QDialog.Accepted:
4964
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