eric6/WebBrowser/FeaturePermissions/FeaturePermissionsDialog.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
40 if hasattr(QWebEnginePage, "Notifications"): 40 if hasattr(QWebEnginePage, "Notifications"):
41 # this was re-added in Qt 5.13.0 41 # this was re-added in Qt 5.13.0
42 self.notifList = QTreeWidget() 42 self.notifList = QTreeWidget()
43 self.notifList.setAlternatingRowColors(True) 43 self.notifList.setAlternatingRowColors(True)
44 self.notifList.setSelectionMode( 44 self.notifList.setSelectionMode(
45 QAbstractItemView.ExtendedSelection) 45 QAbstractItemView.SelectionMode.ExtendedSelection)
46 self.notifList.setRootIsDecorated(False) 46 self.notifList.setRootIsDecorated(False)
47 self.notifList.setItemsExpandable(False) 47 self.notifList.setItemsExpandable(False)
48 self.notifList.setAllColumnsShowFocus(True) 48 self.notifList.setAllColumnsShowFocus(True)
49 self.notifList.setObjectName("notifList") 49 self.notifList.setObjectName("notifList")
50 self.notifList.setSortingEnabled(True) 50 self.notifList.setSortingEnabled(True)
55 UI.PixmapCache.getIcon("notification"), 55 UI.PixmapCache.getIcon("notification"),
56 self.tr("Notifications")) 56 self.tr("Notifications"))
57 57
58 self.geoList = QTreeWidget() 58 self.geoList = QTreeWidget()
59 self.geoList.setAlternatingRowColors(True) 59 self.geoList.setAlternatingRowColors(True)
60 self.geoList.setSelectionMode(QAbstractItemView.ExtendedSelection) 60 self.geoList.setSelectionMode(
61 QAbstractItemView.SelectionMode.ExtendedSelection)
61 self.geoList.setRootIsDecorated(False) 62 self.geoList.setRootIsDecorated(False)
62 self.geoList.setItemsExpandable(False) 63 self.geoList.setItemsExpandable(False)
63 self.geoList.setAllColumnsShowFocus(True) 64 self.geoList.setAllColumnsShowFocus(True)
64 self.geoList.setObjectName("geoList") 65 self.geoList.setObjectName("geoList")
65 self.geoList.setSortingEnabled(True) 66 self.geoList.setSortingEnabled(True)
70 UI.PixmapCache.getIcon("geolocation"), 71 UI.PixmapCache.getIcon("geolocation"),
71 self.tr("Geolocation")) 72 self.tr("Geolocation"))
72 73
73 self.micList = QTreeWidget() 74 self.micList = QTreeWidget()
74 self.micList.setAlternatingRowColors(True) 75 self.micList.setAlternatingRowColors(True)
75 self.micList.setSelectionMode(QAbstractItemView.ExtendedSelection) 76 self.micList.setSelectionMode(
77 QAbstractItemView.SelectionMode.ExtendedSelection)
76 self.micList.setRootIsDecorated(False) 78 self.micList.setRootIsDecorated(False)
77 self.micList.setItemsExpandable(False) 79 self.micList.setItemsExpandable(False)
78 self.micList.setAllColumnsShowFocus(True) 80 self.micList.setAllColumnsShowFocus(True)
79 self.micList.setObjectName("micList") 81 self.micList.setObjectName("micList")
80 self.micList.setSortingEnabled(True) 82 self.micList.setSortingEnabled(True)
85 UI.PixmapCache.getIcon("audiocapture"), 87 UI.PixmapCache.getIcon("audiocapture"),
86 self.tr("Microphone")) 88 self.tr("Microphone"))
87 89
88 self.camList = QTreeWidget() 90 self.camList = QTreeWidget()
89 self.camList.setAlternatingRowColors(True) 91 self.camList.setAlternatingRowColors(True)
90 self.camList.setSelectionMode(QAbstractItemView.ExtendedSelection) 92 self.camList.setSelectionMode(
93 QAbstractItemView.SelectionMode.ExtendedSelection)
91 self.camList.setRootIsDecorated(False) 94 self.camList.setRootIsDecorated(False)
92 self.camList.setItemsExpandable(False) 95 self.camList.setItemsExpandable(False)
93 self.camList.setAllColumnsShowFocus(True) 96 self.camList.setAllColumnsShowFocus(True)
94 self.camList.setObjectName("camList") 97 self.camList.setObjectName("camList")
95 self.camList.setSortingEnabled(True) 98 self.camList.setSortingEnabled(True)
100 UI.PixmapCache.getIcon("camera"), 103 UI.PixmapCache.getIcon("camera"),
101 self.tr("Camera")) 104 self.tr("Camera"))
102 105
103 self.micCamList = QTreeWidget() 106 self.micCamList = QTreeWidget()
104 self.micCamList.setAlternatingRowColors(True) 107 self.micCamList.setAlternatingRowColors(True)
105 self.micCamList.setSelectionMode(QAbstractItemView.ExtendedSelection) 108 self.micCamList.setSelectionMode(
109 QAbstractItemView.SelectionMode.ExtendedSelection)
106 self.micCamList.setRootIsDecorated(False) 110 self.micCamList.setRootIsDecorated(False)
107 self.micCamList.setItemsExpandable(False) 111 self.micCamList.setItemsExpandable(False)
108 self.micCamList.setAllColumnsShowFocus(True) 112 self.micCamList.setAllColumnsShowFocus(True)
109 self.micCamList.setObjectName("micCamList") 113 self.micCamList.setObjectName("micCamList")
110 self.micCamList.setSortingEnabled(True) 114 self.micCamList.setSortingEnabled(True)
116 self.tr("Microphone && Camera")) 120 self.tr("Microphone && Camera"))
117 121
118 self.mouseLockList = QTreeWidget() 122 self.mouseLockList = QTreeWidget()
119 self.mouseLockList.setAlternatingRowColors(True) 123 self.mouseLockList.setAlternatingRowColors(True)
120 self.mouseLockList.setSelectionMode( 124 self.mouseLockList.setSelectionMode(
121 QAbstractItemView.ExtendedSelection) 125 QAbstractItemView.SelectionMode.ExtendedSelection)
122 self.mouseLockList.setRootIsDecorated(False) 126 self.mouseLockList.setRootIsDecorated(False)
123 self.mouseLockList.setItemsExpandable(False) 127 self.mouseLockList.setItemsExpandable(False)
124 self.mouseLockList.setAllColumnsShowFocus(True) 128 self.mouseLockList.setAllColumnsShowFocus(True)
125 self.mouseLockList.setObjectName("mouseLockList") 129 self.mouseLockList.setObjectName("mouseLockList")
126 self.mouseLockList.setSortingEnabled(True) 130 self.mouseLockList.setSortingEnabled(True)
134 if hasattr(QWebEnginePage, "DesktopVideoCapture"): 138 if hasattr(QWebEnginePage, "DesktopVideoCapture"):
135 # these are shown as of Qt 5.10.0/PyQt 5.10.0 139 # these are shown as of Qt 5.10.0/PyQt 5.10.0
136 self.deskVidList = QTreeWidget() 140 self.deskVidList = QTreeWidget()
137 self.deskVidList.setAlternatingRowColors(True) 141 self.deskVidList.setAlternatingRowColors(True)
138 self.deskVidList.setSelectionMode( 142 self.deskVidList.setSelectionMode(
139 QAbstractItemView.ExtendedSelection) 143 QAbstractItemView.SelectionMode.ExtendedSelection)
140 self.deskVidList.setRootIsDecorated(False) 144 self.deskVidList.setRootIsDecorated(False)
141 self.deskVidList.setItemsExpandable(False) 145 self.deskVidList.setItemsExpandable(False)
142 self.deskVidList.setAllColumnsShowFocus(True) 146 self.deskVidList.setAllColumnsShowFocus(True)
143 self.deskVidList.setObjectName("deskVidList") 147 self.deskVidList.setObjectName("deskVidList")
144 self.deskVidList.setSortingEnabled(True) 148 self.deskVidList.setSortingEnabled(True)
150 self.tr("Desktop Video")) 154 self.tr("Desktop Video"))
151 155
152 self.deskAudVidList = QTreeWidget() 156 self.deskAudVidList = QTreeWidget()
153 self.deskAudVidList.setAlternatingRowColors(True) 157 self.deskAudVidList.setAlternatingRowColors(True)
154 self.deskAudVidList.setSelectionMode( 158 self.deskAudVidList.setSelectionMode(
155 QAbstractItemView.ExtendedSelection) 159 QAbstractItemView.SelectionMode.ExtendedSelection)
156 self.deskAudVidList.setRootIsDecorated(False) 160 self.deskAudVidList.setRootIsDecorated(False)
157 self.deskAudVidList.setItemsExpandable(False) 161 self.deskAudVidList.setItemsExpandable(False)
158 self.deskAudVidList.setAllColumnsShowFocus(True) 162 self.deskAudVidList.setAllColumnsShowFocus(True)
159 self.deskAudVidList.setObjectName("deskAudVidList") 163 self.deskAudVidList.setObjectName("deskAudVidList")
160 self.deskAudVidList.setSortingEnabled(True) 164 self.deskAudVidList.setSortingEnabled(True)
181 else: 185 else:
182 self.setTabOrder(self.mouseLockList, self.removeButton) 186 self.setTabOrder(self.mouseLockList, self.removeButton)
183 self.setTabOrder(self.removeButton, self.removeAllButton) 187 self.setTabOrder(self.removeButton, self.removeAllButton)
184 188
185 self.__permissionStrings = { 189 self.__permissionStrings = {
186 QWebEnginePage.PermissionGrantedByUser: self.tr("Allow"), 190 QWebEnginePage.PermissionPolicy.PermissionGrantedByUser:
187 QWebEnginePage.PermissionDeniedByUser: self.tr("Deny"), 191 self.tr("Allow"),
192 QWebEnginePage.PermissionPolicy.PermissionDeniedByUser:
193 self.tr("Deny"),
188 } 194 }
189 195
190 self.__permissionsLists = { 196 self.__permissionsLists = {
191 QWebEnginePage.Geolocation: self.geoList, 197 QWebEnginePage.Feature.Geolocation: self.geoList,
192 QWebEnginePage.MediaAudioCapture: self.micList, 198 QWebEnginePage.Feature.MediaAudioCapture: self.micList,
193 QWebEnginePage.MediaVideoCapture: self.camList, 199 QWebEnginePage.Feature.MediaVideoCapture: self.camList,
194 QWebEnginePage.MediaAudioVideoCapture: self.micCamList, 200 QWebEnginePage.Feature.MediaAudioVideoCapture: self.micCamList,
195 QWebEnginePage.MouseLock: self.mouseLockList, 201 QWebEnginePage.Feature.MouseLock: self.mouseLockList,
196 } 202 }
197 if hasattr(QWebEnginePage, "DesktopVideoCapture"): 203 if hasattr(QWebEnginePage, "DesktopVideoCapture"):
198 self.__permissionsLists.update({ 204 self.__permissionsLists.update({
199 QWebEnginePage.DesktopVideoCapture: self.deskVidList, 205 QWebEnginePage.Feature.DesktopVideoCapture:
200 QWebEnginePage.DesktopAudioVideoCapture: self.deskAudVidList, 206 self.deskVidList,
207 QWebEnginePage.Feature.DesktopAudioVideoCapture:
208 self.deskAudVidList,
201 }) 209 })
202 if hasattr(QWebEnginePage, "Notifications"): 210 if hasattr(QWebEnginePage, "Notifications"):
203 self.__permissionsLists[QWebEnginePage.Notifications] = ( 211 self.__permissionsLists[QWebEnginePage.Feature.Notifications] = (
204 self.notifList 212 self.notifList
205 ) 213 )
206 214
207 for feature, permissionsList in self.__permissionsLists.items(): 215 for feature, permissionsList in self.__permissionsLists.items():
208 for permission in featurePermissions[feature]: 216 for permission in featurePermissions[feature]:
209 for host in featurePermissions[feature][permission]: 217 for host in featurePermissions[feature][permission]:
210 itm = QTreeWidgetItem( 218 itm = QTreeWidgetItem(
211 permissionsList, 219 permissionsList,
212 [host, self.__permissionStrings[permission]]) 220 [host, self.__permissionStrings[permission]])
213 itm.setData(0, Qt.UserRole, permission) 221 itm.setData(0, Qt.ItemDataRole.UserRole, permission)
214 222
215 self.__previousCurrent = -1 223 self.__previousCurrent = -1
216 self.tabWidget.currentChanged.connect(self.__currentTabChanged) 224 self.tabWidget.currentChanged.connect(self.__currentTabChanged)
217 self.tabWidget.setCurrentIndex(0) 225 self.tabWidget.setCurrentIndex(0)
218 226
283 @rtype dict of dict of list 291 @rtype dict of dict of list
284 """ 292 """
285 featurePermissions = {} 293 featurePermissions = {}
286 for feature, permissionsList in self.__permissionsLists.items(): 294 for feature, permissionsList in self.__permissionsLists.items():
287 featurePermissions[feature] = { 295 featurePermissions[feature] = {
288 QWebEnginePage.PermissionGrantedByUser: [], 296 QWebEnginePage.PermissionPolicy.PermissionGrantedByUser: [],
289 QWebEnginePage.PermissionDeniedByUser: [], 297 QWebEnginePage.PermissionPolicy.PermissionDeniedByUser: [],
290 } 298 }
291 for row in range(permissionsList.topLevelItemCount()): 299 for row in range(permissionsList.topLevelItemCount()):
292 itm = permissionsList.topLevelItem(row) 300 itm = permissionsList.topLevelItem(row)
293 host = itm.text(0) 301 host = itm.text(0)
294 permission = itm.data(0, Qt.UserRole) 302 permission = itm.data(0, Qt.ItemDataRole.UserRole)
295 featurePermissions[feature][permission].append(host) 303 featurePermissions[feature][permission].append(host)
296 304
297 return featurePermissions 305 return featurePermissions

eric ide

mercurial