272 name = QUrl.fromLocalFile(name.toString()) |
265 name = QUrl.fromLocalFile(name.toString()) |
273 |
266 |
274 if not QFileInfo(name.toLocalFile()).exists(): |
267 if not QFileInfo(name.toLocalFile()).exists(): |
275 E5MessageBox.critical( |
268 E5MessageBox.critical( |
276 self, |
269 self, |
277 self.tr("eric6 Web Browser"), |
270 self.tr("eric Web Browser"), |
278 self.tr( |
271 self.tr( |
279 """<p>The file <b>{0}</b> does not exist.</p>""") |
272 """<p>The file <b>{0}</b> does not exist.</p>""") |
280 .format(name.toLocalFile())) |
273 .format(name.toLocalFile())) |
281 return |
274 return |
282 |
275 |
283 if name.toLocalFile().lower().endswith((".pdf", ".chm")): |
276 if name.toLocalFile().lower().endswith((".pdf", ".chm")): |
284 started = QDesktopServices.openUrl(name) |
277 started = QDesktopServices.openUrl(name) |
285 if not started: |
278 if not started: |
286 E5MessageBox.critical( |
279 E5MessageBox.critical( |
287 self, |
280 self, |
288 self.tr("eric6 Web Browser"), |
281 self.tr("eric Web Browser"), |
289 self.tr( |
282 self.tr( |
290 """<p>Could not start a viewer""" |
283 """<p>Could not start a viewer""" |
291 """ for file <b>{0}</b>.</p>""") |
284 """ for file <b>{0}</b>.</p>""") |
292 .format(name.path())) |
285 .format(name.path())) |
293 return |
286 return |
294 elif name.scheme() in ["mailto"]: |
287 elif name.scheme() in ["mailto"]: |
295 started = QDesktopServices.openUrl(name) |
288 started = QDesktopServices.openUrl(name) |
296 if not started: |
289 if not started: |
297 E5MessageBox.critical( |
290 E5MessageBox.critical( |
298 self, |
291 self, |
299 self.tr("eric6 Web Browser"), |
292 self.tr("eric Web Browser"), |
300 self.tr( |
293 self.tr( |
301 """<p>Could not start an application""" |
294 """<p>Could not start an application""" |
302 """ for URL <b>{0}</b>.</p>""") |
295 """ for URL <b>{0}</b>.</p>""") |
303 .format(name.toString())) |
296 .format(name.toString())) |
304 return |
297 return |
581 |
574 |
582 if not hitTest.isContentEditable() and not hitTest.isContentSelected(): |
575 if not hitTest.isContentEditable() and not hitTest.isContentSelected(): |
583 self.__menu.addSeparator() |
576 self.__menu.addSeparator() |
584 self.__menu.addAction(self.__mw.adBlockIcon().menuAction()) |
577 self.__menu.addAction(self.__mw.adBlockIcon().menuAction()) |
585 |
578 |
586 if ( |
579 self.__menu.addSeparator() |
587 qVersionTuple() >= (5, 11, 0) or |
580 self.__menu.addAction( |
588 Preferences.getWebBrowser("WebInspectorEnabled") |
581 UI.PixmapCache.getIcon("webInspector"), |
589 ): |
582 self.tr("Inspect Element..."), self.__webInspector) |
590 self.__menu.addSeparator() |
|
591 self.__menu.addAction( |
|
592 UI.PixmapCache.getIcon("webInspector"), |
|
593 self.tr("Inspect Element..."), self.__webInspector) |
|
594 |
583 |
595 if not self.__menu.isEmpty(): |
584 if not self.__menu.isEmpty(): |
596 pos = evt.globalPos() |
585 pos = evt.globalPos() |
597 self.__menu.popup(QPoint(pos.x(), pos.y() + 1)) |
586 self.__menu.popup(QPoint(pos.x(), pos.y() + 1)) |
598 |
587 |
2275 |
2263 |
2276 ########################################################################### |
2264 ########################################################################### |
2277 ## Methods below implement slots for Qt 5.11+ |
2265 ## Methods below implement slots for Qt 5.11+ |
2278 ########################################################################### |
2266 ########################################################################### |
2279 |
2267 |
2280 if qVersionTuple() >= (5, 11, 0): |
2268 @pyqtSlot("QWebEngineQuotaRequest") |
2281 @pyqtSlot("QWebEngineQuotaRequest") |
2269 def __quotaRequested(self, quotaRequest): |
2282 def __quotaRequested(self, quotaRequest): |
2270 """ |
2283 """ |
2271 Private slot to handle quota requests of the web page. |
2284 Private slot to handle quota requests of the web page. |
2272 |
|
2273 @param quotaRequest reference to the quota request object |
|
2274 @type QWebEngineQuotaRequest |
|
2275 """ |
|
2276 acceptRequest = Preferences.getWebBrowser("AcceptQuotaRequest") |
|
2277 # map yes/no/ask from (0, 1, 2) |
|
2278 if acceptRequest == 0: |
|
2279 # always yes |
|
2280 ok = True |
|
2281 elif acceptRequest == 1: |
|
2282 # always no |
|
2283 ok = False |
|
2284 else: |
|
2285 # ask user |
|
2286 from .Download.DownloadUtilities import dataString |
|
2287 sizeStr = dataString(quotaRequest.requestedSize()) |
2285 |
2288 |
2286 @param quotaRequest reference to the quota request object |
2289 ok = E5MessageBox.yesNo( |
2287 @type QWebEngineQuotaRequest |
2290 self, |
2288 """ |
2291 self.tr("Quota Request"), |
2289 acceptRequest = Preferences.getWebBrowser("AcceptQuotaRequest") |
2292 self.tr("""<p> Allow the website at <b>{0}</b> to use""" |
2290 # map yes/no/ask from (0, 1, 2) |
2293 """ <b>{1}</b> of persistent storage?</p>""") |
2291 if acceptRequest == 0: |
2294 .format(quotaRequest.origin().host(), sizeStr) |
2292 # always yes |
2295 ) |
2293 ok = True |
2296 |
2294 elif acceptRequest == 1: |
2297 if ok: |
2295 # always no |
2298 quotaRequest.accept() |
2296 ok = False |
2299 else: |
2297 else: |
2300 quotaRequest.reject() |
2298 # ask user |
|
2299 from .Download.DownloadUtilities import dataString |
|
2300 sizeStr = dataString(quotaRequest.requestedSize()) |
|
2301 |
|
2302 ok = E5MessageBox.yesNo( |
|
2303 self, |
|
2304 self.tr("Quota Request"), |
|
2305 self.tr("""<p> Allow the website at <b>{0}</b> to use""" |
|
2306 """ <b>{1}</b> of persistent storage?</p>""") |
|
2307 .format(quotaRequest.origin().host(), sizeStr) |
|
2308 ) |
|
2309 |
|
2310 if ok: |
|
2311 quotaRequest.accept() |
|
2312 else: |
|
2313 quotaRequest.reject() |
|
2314 |
2301 |
2315 ########################################################################### |
2302 ########################################################################### |
2316 ## Methods below implement slots for Qt 5.12+ |
2303 ## Methods below implement slots for Qt 5.12+ |
2317 ########################################################################### |
2304 ########################################################################### |
2318 |
2305 |
2319 if qVersionTuple() >= (5, 12, 0): |
2306 @pyqtSlot("QWebEngineClientCertificateSelection") |
2320 @pyqtSlot("QWebEngineClientCertificateSelection") |
2307 def __selectClientCertificate(self, clientCertificateSelection): |
2321 def __selectClientCertificate(self, clientCertificateSelection): |
2308 """ |
2322 """ |
2309 Private slot to handle the client certificate selection request. |
2323 Private slot to handle the client certificate selection request. |
2310 |
|
2311 @param clientCertificateSelection list of client SSL certificates |
|
2312 found in system's client certificate store |
|
2313 @type QWebEngineClientCertificateSelection |
|
2314 """ |
|
2315 certificates = clientCertificateSelection.certificates() |
|
2316 if len(certificates) == 0: |
|
2317 clientCertificateSelection.selectNone() |
|
2318 elif len(certificates) == 1: |
|
2319 clientCertificateSelection.select(certificates[0]) |
|
2320 else: |
|
2321 certificate = None |
|
2322 from E5Network.E5SslCertificateSelectionDialog import ( |
|
2323 E5SslCertificateSelectionDialog |
|
2324 ) |
|
2325 dlg = E5SslCertificateSelectionDialog(certificates, self) |
|
2326 if dlg.exec() == QDialog.Accepted: |
|
2327 certificate = dlg.getSelectedCertificate() |
2324 |
2328 |
2325 @param clientCertificateSelection list of client SSL certificates |
2329 if certificate is None: |
2326 found in system's client certificate store |
|
2327 @type QWebEngineClientCertificateSelection |
|
2328 """ |
|
2329 certificates = clientCertificateSelection.certificates() |
|
2330 if len(certificates) == 0: |
|
2331 clientCertificateSelection.selectNone() |
2330 clientCertificateSelection.selectNone() |
2332 elif len(certificates) == 1: |
|
2333 clientCertificateSelection.select(certificates[0]) |
|
2334 else: |
2331 else: |
2335 certificate = None |
2332 clientCertificateSelection.select(certificate) |
2336 from E5Network.E5SslCertificateSelectionDialog import ( |
|
2337 E5SslCertificateSelectionDialog |
|
2338 ) |
|
2339 dlg = E5SslCertificateSelectionDialog(certificates, self) |
|
2340 if dlg.exec() == QDialog.Accepted: |
|
2341 certificate = dlg.getSelectedCertificate() |
|
2342 |
|
2343 if certificate is None: |
|
2344 clientCertificateSelection.selectNone() |
|
2345 else: |
|
2346 clientCertificateSelection.select(certificate) |
|