eric6/WebBrowser/StatusBar/JavaScriptSettingsDialog.py

Tue, 10 Sep 2019 19:30:07 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 10 Sep 2019 19:30:07 +0200
changeset 7229
53054eb5b15a
parent 6942
2602857055c5
child 7360
9190402e4505
permissions
-rw-r--r--

Removed obsolete "from __future__ import ..." statements.

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: 6398
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 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
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt5.QtCore import pyqtSlot
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtWidgets import QDialog
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 from .Ui_JavaScriptSettingsDialog import Ui_JavaScriptSettingsDialog
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import Preferences
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
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 class JavaScriptSettingsDialog(QDialog, Ui_JavaScriptSettingsDialog):
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 Class implementing the JavaScript settings dialog.
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 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
24 dialog.
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 def __init__(self, parent=None):
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 Constructor
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 @param parent reference to the parent widget
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @type QWidget
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 super(JavaScriptSettingsDialog, self).__init__(parent)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.setupUi(self)
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
6151
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
36 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
37 Preferences.getWebBrowser("JavaScriptEnabled"))
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.jsOpenWindowsCheckBox.setChecked(
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 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
40 try:
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
41 # 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
42 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
43 Preferences.getWebBrowser(
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
44 "AllowWindowActivationFromJavaScript"))
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
45 except KeyError:
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
46 self.jsActivateWindowsCheckBox.setEnabled(False)
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.jsClipboardCheckBox.setChecked(
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 Preferences.getWebBrowser("JavaScriptCanAccessClipboard"))
6398
caf724f53840 Webbrowser: continued upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6397
diff changeset
49 try:
caf724f53840 Webbrowser: continued upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6397
diff changeset
50 # Qt 5.11
caf724f53840 Webbrowser: continued upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6397
diff changeset
51 self.jsPasteCheckBox.setChecked(
caf724f53840 Webbrowser: continued upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6397
diff changeset
52 Preferences.getWebBrowser("JavaScriptCanPaste"))
caf724f53840 Webbrowser: continued upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6397
diff changeset
53 except KeyError:
caf724f53840 Webbrowser: continued upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6397
diff changeset
54 self.jsPasteCheckBox.setEnabled(False)
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
4965
a9a4b632fe48 Some enhancements for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4964
diff changeset
56 msh = self.minimumSizeHint()
a9a4b632fe48 Some enhancements for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4964
diff changeset
57 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
58
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 @pyqtSlot()
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 def accept(self):
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 Public slot to accept the dialog.
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 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
65 "JavaScriptEnabled",
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
66 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
67 Preferences.setWebBrowser(
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 "JavaScriptCanOpenWindows",
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 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
70 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
71 Preferences.setWebBrowser(
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
72 "AllowWindowActivationFromJavaScript",
29564aad2f97 JavaScriptEnabled: Added a configuration option to globally disable/enable JavaScript support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
73 self.jsActivateWindowsCheckBox.isChecked())
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 Preferences.setWebBrowser(
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 "JavaScriptCanAccessClipboard",
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.jsClipboardCheckBox.isChecked())
6398
caf724f53840 Webbrowser: continued upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6397
diff changeset
77 if self.jsPasteCheckBox.isEnabled():
caf724f53840 Webbrowser: continued upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6397
diff changeset
78 Preferences.setWebBrowser(
caf724f53840 Webbrowser: continued upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6397
diff changeset
79 "JavaScriptCanPaste",
caf724f53840 Webbrowser: continued upgrading to Qt 5.11.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6397
diff changeset
80 self.jsPasteCheckBox.isChecked())
4964
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
a894e8c92369 Implemented the JavaScript status bar icon.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 Preferences.syncPreferences()
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 super(JavaScriptSettingsDialog, self).accept()

eric ide

mercurial