Helpviewer/FeaturePermissions/FeaturePermissionManager.py

changeset 4356
975993ebd7fb
parent 4355
40ec6bef4c22
child 4631
5c1a96925da4
equal deleted inserted replaced
4355:40ec6bef4c22 4356:975993ebd7fb
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 from PyQt5.QtCore import QObject 12 from PyQt5.QtCore import QObject
13 from PyQt5.QtWidgets import QDialog
13 from PyQt5.QtWebKitWidgets import QWebPage 14 from PyQt5.QtWebKitWidgets import QWebPage
14 15
15 import Globals 16 import Globals
16 import Preferences 17 import Preferences
17 18
31 """ 32 """
32 super(FeaturePermissionManager, self).__init__(parent) 33 super(FeaturePermissionManager, self).__init__(parent)
33 34
34 self.__featurePermissions = { 35 self.__featurePermissions = {
35 QWebPage.Notifications: { 36 QWebPage.Notifications: {
36 QWebPage.PermissionGrantedByUser: [], 37 QWebPage.PermissionGrantedByUser: [],
37 QWebPage.PermissionDeniedByUser: [], 38 QWebPage.PermissionDeniedByUser: [],
38 }, 39 },
39 QWebPage.Geolocation: { 40 QWebPage.Geolocation: {
40 QWebPage.PermissionGrantedByUser: [], 41 QWebPage.PermissionGrantedByUser: [],
41 QWebPage.PermissionDeniedByUser: [], 42 QWebPage.PermissionDeniedByUser: [],
42 }, 43 },
43 } 44 }
44 self.__featurePermissionsKeys = { 45 self.__featurePermissionsKeys = {
45 (QWebPage.Notifications, QWebPage.PermissionGrantedByUser): 46 (QWebPage.Notifications, QWebPage.PermissionGrantedByUser):
46 "NotificationsGranted", 47 "NotificationsGranted",
47 (QWebPage.Notifications, QWebPage.PermissionDeniedByUser): 48 (QWebPage.Notifications, QWebPage.PermissionDeniedByUser):
48 "NotificationsDenied", 49 "NotificationsDenied",
49 (QWebPage.Geolocation, QWebPage.PermissionGrantedByUser): 50 (QWebPage.Geolocation, QWebPage.PermissionGrantedByUser):
50 "GeolocationGranted", 51 "GeolocationGranted",
51 (QWebPage.Geolocation, QWebPage.PermissionDeniedByUser): 52 (QWebPage.Geolocation, QWebPage.PermissionDeniedByUser):
52 "GeolocationDenied", 53 "GeolocationDenied",
53 } 54 }
54 55
55 self.__loaded = False 56 self.__loaded = False
56 57
57 def requestFeaturePermission(self, page, frame, feature): 58 def requestFeaturePermission(self, page, frame, feature):
58 """ 59 """
59 Private method to request a feature permission. 60 Public method to request a feature permission.
60 61
61 @param page reference to the requesting web page 62 @param page reference to the requesting web page
62 @type QWebPage 63 @type QWebPage
63 @param frame frame sending the request 64 @param frame frame sending the request
64 @type QWebFrame 65 @type QWebFrame
135 def showFeaturePermissionsDialog(self): 136 def showFeaturePermissionsDialog(self):
136 """ 137 """
137 Public method to show a dialog to manage the remembered feature 138 Public method to show a dialog to manage the remembered feature
138 permissions. 139 permissions.
139 """ 140 """
140 # TODO: implement this 141 if not self.__loaded:
141 pass 142 self.__loadSettings()
143
144 from .FeaturePermissionsDialog import FeaturePermissionsDialog
145 dlg = FeaturePermissionsDialog(self.__featurePermissions)
146 if dlg.exec_() == QDialog.Accepted:
147 newFeaturePermissions = dlg.getData()
148 self.__featurePermissions = newFeaturePermissions
149 self.__saveSettings()

eric ide

mercurial