WebBrowser/StatusBar/JavaScriptSettingsDialog.py

Fri, 16 Feb 2018 20:11:36 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 16 Feb 2018 20:11:36 +0100
changeset 6151
29564aad2f97
parent 6048
82ad8ec9548c
child 6397
473d410076e9
permissions
-rw-r--r--

JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.

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
6048
82ad8ec9548c Updated copyright for 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5526
diff changeset
3 # Copyright (c) 2016 - 2018 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 settings dialog.
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
4977
f824f4e8a024 Corrected the JavaScript settings dialog to add the __futures__ import statement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4965
diff changeset
10 from __future__ import unicode_literals
f824f4e8a024 Corrected the JavaScript settings dialog to add the __futures__ import statement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4965
diff changeset
11
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtCore import pyqtSlot
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt5.QtWidgets import QDialog
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 .Ui_JavaScriptSettingsDialog import Ui_JavaScriptSettingsDialog
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import Preferences
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
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 class JavaScriptSettingsDialog(QDialog, Ui_JavaScriptSettingsDialog):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Class implementing the JavaScript settings dialog.
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 Note: it contains the JavaScript part of the web browser configuration
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 dialog.
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 def __init__(self, parent=None):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 Constructor
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param parent reference to the parent widget
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @type QWidget
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 super(JavaScriptSettingsDialog, self).__init__(parent)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.setupUi(self)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
6151
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
37 self.javaScriptGroup.setChecked(
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
38 Preferences.getWebBrowser("JavaScriptEnabled"))
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.jsOpenWindowsCheckBox.setChecked(
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 Preferences.getWebBrowser("JavaScriptCanOpenWindows"))
6151
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
41 try:
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
42 # Qt 5.10
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
43 self.jsActivateWindowsCheckBox.setChecked(
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
44 Preferences.getWebBrowser(
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
45 "AllowWindowActivationFromJavaScript"))
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
46 except KeyError:
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
47 self.jsActivateWindowsCheckBox.setEnabled(False)
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.jsClipboardCheckBox.setChecked(
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Preferences.getWebBrowser("JavaScriptCanAccessClipboard"))
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
4965
a9a4b632fe48 Some enhancements for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4964
diff changeset
51 msh = self.minimumSizeHint()
a9a4b632fe48 Some enhancements for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4964
diff changeset
52 self.resize(max(self.width(), msh.width()), msh.height())
4964
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 @pyqtSlot()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 def accept(self):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 Public slot to accept the dialog.
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 Preferences.setWebBrowser(
6151
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
60 "JavaScriptEnabled",
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
61 self.javaScriptGroup.isChecked())
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
62 Preferences.setWebBrowser(
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 "JavaScriptCanOpenWindows",
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.jsOpenWindowsCheckBox.isChecked())
6151
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
65 if self.jsActivateWindowsCheckBox.isEnabled():
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
66 Preferences.setWebBrowser(
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
67 "AllowWindowActivationFromJavaScript",
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
68 self.jsActivateWindowsCheckBox.isChecked())
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 Preferences.setWebBrowser(
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 "JavaScriptCanAccessClipboard",
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.jsClipboardCheckBox.isChecked())
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 Preferences.syncPreferences()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 super(JavaScriptSettingsDialog, self).accept()

eric ide

mercurial