eric6/WebBrowser/FeaturePermissions/FeaturePermissionBar.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).

4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
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) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the feature permission bar widget.
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
10 from PyQt5.QtCore import pyqtSlot, QUrl
4356
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
11 from PyQt5.QtWidgets import QLabel, QHBoxLayout, QPushButton
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
12 from PyQt5.QtWebEngineWidgets import QWebEnginePage
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from E5Gui.E5AnimatedWidget import E5AnimatedWidget
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import UI.PixmapCache
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 class FeaturePermissionBar(E5AnimatedWidget):
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 Class implementing the feature permission bar widget.
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 DefaultHeight = 30
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
25 def __init__(self, page, origin, feature, manager):
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Constructor
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
29 @param page reference to the web page
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @type QWebView
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
31 @param origin security origin requesting the feature
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
32 @type QUrl
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param feature requested feature
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @type QWebPage.Feature
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
35 @param manager reference to the feature permissions manager
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
36 @type FeaturePermissionManager
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
38 super(FeaturePermissionBar, self).__init__(parent=page.view())
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
40 self.__origin = QUrl(origin)
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__feature = feature
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
42 self.__page = page
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
43 self.__manager = manager
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.__permissionFeatureTexts = {
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
46 QWebEnginePage.Geolocation:
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
47 self.tr("{0} wants to use your position."),
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
48 QWebEnginePage.MediaAudioCapture:
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
49 self.tr("{0} wants to use your microphone."),
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
50 QWebEnginePage.MediaVideoCapture:
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
51 self.tr("{0} wants to use your camera."),
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
52 QWebEnginePage.MediaAudioVideoCapture:
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
53 self.tr("{0} wants to use your microphone and camera."),
4904
ea8f13f76d26 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4742
diff changeset
54 QWebEnginePage.MouseLock:
ea8f13f76d26 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4742
diff changeset
55 self.tr("{0} wants to lock your mouse."),
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 }
6084
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
57 try:
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
58 # these are defined as of Qt 5.10.0/PyQt 5.10.0
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
59 self.__permissionFeatureTexts.update({
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
60 QWebEnginePage.DesktopVideoCapture:
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
61 self.tr("{0} wants to capture video of your screen."),
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
62 QWebEnginePage.DesktopAudioVideoCapture:
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
63 self.tr("{0} wants to capture audio and video of your"
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
64 " screen."),
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
65 })
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
66 except AttributeError:
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
67 pass
7179
912bc70b5b01 WebBrowser: added support for the QWebEnginePage.Notifications as Qt 5.13.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
68 try:
912bc70b5b01 WebBrowser: added support for the QWebEnginePage.Notifications as Qt 5.13.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
69 # this was re-added in Qt 5.13.0
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
70 self.__permissionFeatureTexts[
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
71 QWebEnginePage.Notifications] = self.tr(
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
72 "{0} wants to use desktop notifications.")
7179
912bc70b5b01 WebBrowser: added support for the QWebEnginePage.Notifications as Qt 5.13.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
73 except AttributeError:
912bc70b5b01 WebBrowser: added support for the QWebEnginePage.Notifications as Qt 5.13.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
74 pass
6084
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
75
4356
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
76 self.__permissionFeatureIconNames = {
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
77 QWebEnginePage.Geolocation: "geolocation",
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
78 QWebEnginePage.MediaAudioCapture: "audiocapture",
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
79 QWebEnginePage.MediaVideoCapture: "camera",
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
80 QWebEnginePage.MediaAudioVideoCapture: "audio-video",
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
81 QWebEnginePage.MouseLock: "mouse",
4356
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
82 }
6084
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
83 try:
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
84 # these are defined as of Qt 5.10.0/PyQt 5.10.0
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
85 self.__permissionFeatureIconNames.update({
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
86 QWebEnginePage.DesktopVideoCapture: "desktopVideoCapture",
6084
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
87 QWebEnginePage.DesktopAudioVideoCapture:
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
88 "desktopAudioVideoCapture",
6084
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
89 })
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
90 except AttributeError:
c6f3f66bf7aa Added support for HTML5 "Desktop Video Capture" and "Desktop Audio and Video Capture" as of Qt 5.10.0/PyQt 5.10.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
91 pass
7179
912bc70b5b01 WebBrowser: added support for the QWebEnginePage.Notifications as Qt 5.13.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
92 try:
912bc70b5b01 WebBrowser: added support for the QWebEnginePage.Notifications as Qt 5.13.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
93 # this was re-added in Qt 5.13.0
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
94 self.__permissionFeatureIconNames[
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
95 QWebEnginePage.Notifications] = "notification"
7179
912bc70b5b01 WebBrowser: added support for the QWebEnginePage.Notifications as Qt 5.13.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
96 except AttributeError:
912bc70b5b01 WebBrowser: added support for the QWebEnginePage.Notifications as Qt 5.13.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
97 pass
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.setAutoFillBackground(True)
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 self.__layout = QHBoxLayout()
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.setLayout(self.__layout)
4356
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
102 self.__layout.setContentsMargins(9, 0, 0, 0)
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
103 self.__iconLabel = QLabel(self)
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
104 self.__layout.addWidget(self.__iconLabel)
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
105 self.__messageLabel = QLabel(self)
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 self.__layout.addWidget(self.__messageLabel)
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.__layout.addStretch()
4356
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
108 self.__rememberButton = QPushButton(self.tr("Remember"), self)
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
109 self.__rememberButton.setCheckable(True)
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.__allowButton = QPushButton(self.tr("Allow"), self)
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 self.__denyButton = QPushButton(self.tr("Deny"), self)
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
112 self.__discardButton = QPushButton(UI.PixmapCache.getIcon("close"),
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 "", self)
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 self.__allowButton.clicked.connect(self.__permissionGranted)
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 self.__denyButton.clicked.connect(self.__permissionDenied)
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.__discardButton.clicked.connect(self.__permissionUnknown)
4356
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
117 self.__layout.addWidget(self.__rememberButton)
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.__layout.addWidget(self.__allowButton)
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.__layout.addWidget(self.__denyButton)
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.__layout.addWidget(self.__discardButton)
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 try:
4356
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
123 self.__iconLabel.setPixmap(UI.PixmapCache.getPixmap(
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
124 self.__permissionFeatureIconNames[self.__feature]))
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
125 except KeyError:
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
126 pass
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
127
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
128 try:
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 self.__messageLabel.setText(
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.__permissionFeatureTexts[self.__feature].format(
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
131 self.__origin.host()))
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 except KeyError:
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 self.__messageLabel.setText(
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 self.tr("{0} wants to use an unknown feature.").format(
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
135 self.__origin.host()))
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
137 self.__page.loadStarted.connect(self.hide)
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
139 self.resize(self.__page.view().width(), self.height())
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 self.startAnimation()
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 @pyqtSlot()
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 def hide(self):
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 """
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 Public slot to hide the animated widget.
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 """
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
147 self.__page.loadStarted.disconnect(self.hide)
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 super(FeaturePermissionBar, self).hide()
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 def __permissionDenied(self):
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 Private slot handling the user pressing the deny button.
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 """
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
154 if self.__page is None or self.__manager is None:
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 return
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
157 self.__page.setFeaturePermission(
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
158 self.__origin, self.__feature,
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
159 QWebEnginePage.PermissionDeniedByUser)
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160
4356
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
161 if self.__rememberButton.isChecked():
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
162 self.__manager.rememberFeaturePermission(
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
163 self.__page.url().host(), self.__feature,
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
164 QWebEnginePage.PermissionDeniedByUser)
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 self.hide()
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 def __permissionGranted(self):
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 Private slot handling the user pressing the allow button.
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 """
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
172 if self.__page is None or self.__manager is None:
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 return
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
175 self.__page.setFeaturePermission(
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
176 self.__origin, self.__feature,
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
177 QWebEnginePage.PermissionGrantedByUser)
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178
4356
975993ebd7fb Finished implementing the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4355
diff changeset
179 if self.__rememberButton.isChecked():
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
180 self.__manager.rememberFeaturePermission(
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
181 self.__page.url().host(), self.__feature,
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
182 QWebEnginePage.PermissionGrantedByUser)
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 self.hide()
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 def __permissionUnknown(self):
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 """
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 Private slot handling the user closing the dialog without.
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 """
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
190 if self.__page is None or self.__manager is None:
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 return
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192
4742
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
193 self.__page.setFeaturePermission(
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
194 self.__origin, self.__feature,
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
195 QWebEnginePage.PermissionUnknown)
f9d1090f6ab9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
196
4355
40ec6bef4c22 Started to implement the HTML5 feature permission manager and associated dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 self.hide()

eric ide

mercurial