18 |
18 |
19 |
19 |
20 class FeaturePermissionBar(EricAnimatedWidget): |
20 class FeaturePermissionBar(EricAnimatedWidget): |
21 """ |
21 """ |
22 Class implementing the feature permission bar widget. |
22 Class implementing the feature permission bar widget. |
|
23 |
|
24 Note: This is not needed for Qt 6.8+. |
23 """ |
25 """ |
24 |
26 |
25 DefaultHeight = 30 |
27 DefaultHeight = 30 |
26 |
28 |
27 def __init__(self, page, origin, feature, manager): |
29 def __init__(self, page, origin, feature, manager): |
55 "{0} wants to use your camera." |
57 "{0} wants to use your camera." |
56 ), |
58 ), |
57 QWebEnginePage.Feature.MediaAudioVideoCapture: self.tr( |
59 QWebEnginePage.Feature.MediaAudioVideoCapture: self.tr( |
58 "{0} wants to use your microphone and camera." |
60 "{0} wants to use your microphone and camera." |
59 ), |
61 ), |
60 QWebEnginePage.Feature.MouseLock: self.tr("{0} wants to lock your mouse."), |
62 QWebEnginePage.Feature.MouseLock: self.tr( |
|
63 "{0} wants to lock your mouse." |
|
64 ), |
61 QWebEnginePage.Feature.DesktopVideoCapture: self.tr( |
65 QWebEnginePage.Feature.DesktopVideoCapture: self.tr( |
62 "{0} wants to capture video of your screen." |
66 "{0} wants to capture video of your screen." |
63 ), |
67 ), |
64 QWebEnginePage.Feature.DesktopAudioVideoCapture: self.tr( |
68 QWebEnginePage.Feature.DesktopAudioVideoCapture: self.tr( |
65 "{0} wants to capture audio and video of your screen." |
69 "{0} wants to capture audio and video of your screen." |
74 QWebEnginePage.Feature.MediaAudioCapture: "audiocapture", |
78 QWebEnginePage.Feature.MediaAudioCapture: "audiocapture", |
75 QWebEnginePage.Feature.MediaVideoCapture: "camera", |
79 QWebEnginePage.Feature.MediaVideoCapture: "camera", |
76 QWebEnginePage.Feature.MediaAudioVideoCapture: "audio-video", |
80 QWebEnginePage.Feature.MediaAudioVideoCapture: "audio-video", |
77 QWebEnginePage.Feature.MouseLock: "mouse", |
81 QWebEnginePage.Feature.MouseLock: "mouse", |
78 QWebEnginePage.Feature.DesktopVideoCapture: "desktopVideoCapture", |
82 QWebEnginePage.Feature.DesktopVideoCapture: "desktopVideoCapture", |
79 QWebEnginePage.Feature.DesktopAudioVideoCapture: "desktopAudioVideoCapture", |
83 QWebEnginePage.Feature.DesktopAudioVideoCapture: |
|
84 "desktopAudioVideoCapture", |
80 QWebEnginePage.Feature.Notifications: "notification", |
85 QWebEnginePage.Feature.Notifications: "notification", |
81 } |
86 } |
82 |
87 |
83 self.setAutoFillBackground(True) |
88 self.setAutoFillBackground(True) |
84 self.__layout = QHBoxLayout() |
89 self.__layout = QHBoxLayout() |
91 self.__layout.addStretch() |
96 self.__layout.addStretch() |
92 self.__rememberButton = QPushButton(self.tr("Remember"), self) |
97 self.__rememberButton = QPushButton(self.tr("Remember"), self) |
93 self.__rememberButton.setCheckable(True) |
98 self.__rememberButton.setCheckable(True) |
94 self.__allowButton = QPushButton(self.tr("Allow"), self) |
99 self.__allowButton = QPushButton(self.tr("Allow"), self) |
95 self.__denyButton = QPushButton(self.tr("Deny"), self) |
100 self.__denyButton = QPushButton(self.tr("Deny"), self) |
96 self.__discardButton = QPushButton(EricPixmapCache.getIcon("close"), "", self) |
101 self.__discardButton = QPushButton( |
|
102 EricPixmapCache.getIcon("close"), "", self |
|
103 ) |
97 self.__allowButton.clicked.connect(self.__permissionGranted) |
104 self.__allowButton.clicked.connect(self.__permissionGranted) |
98 self.__denyButton.clicked.connect(self.__permissionDenied) |
105 self.__denyButton.clicked.connect(self.__permissionDenied) |
99 self.__discardButton.clicked.connect(self.__permissionUnknown) |
106 self.__discardButton.clicked.connect(self.__permissionUnknown) |
100 self.__layout.addWidget(self.__rememberButton) |
107 self.__layout.addWidget(self.__rememberButton) |
101 self.__layout.addWidget(self.__allowButton) |
108 self.__layout.addWidget(self.__allowButton) |
133 Public slot to hide the animated widget. |
140 Public slot to hide the animated widget. |
134 """ |
141 """ |
135 self.__page.loadStarted.disconnect(self.hide) |
142 self.__page.loadStarted.disconnect(self.hide) |
136 super().hide() |
143 super().hide() |
137 |
144 |
|
145 @pyqtSlot() |
138 def __permissionDenied(self): |
146 def __permissionDenied(self): |
139 """ |
147 """ |
140 Private slot handling the user pressing the deny button. |
148 Private slot handling the user pressing the deny button. |
141 """ |
149 """ |
142 if self.__page is None or self.__manager is None: |
150 if self.__page is None or self.__manager is None: |
177 QWebEnginePage.PermissionPolicy.PermissionGrantedByUser, |
186 QWebEnginePage.PermissionPolicy.PermissionGrantedByUser, |
178 ) |
187 ) |
179 |
188 |
180 self.hide() |
189 self.hide() |
181 |
190 |
|
191 @pyqtSlot() |
182 def __permissionUnknown(self): |
192 def __permissionUnknown(self): |
183 """ |
193 """ |
184 Private slot handling the user closing the dialog without. |
194 Private slot handling the user closing the dialog without a selection. |
185 """ |
195 """ |
186 if self.__page is None or self.__manager is None: |
196 if self.__page is None or self.__manager is None: |
187 return |
197 return |
188 |
198 |
189 self.__page.setFeaturePermission( |
199 self.__page.setFeaturePermission( |