WebBrowserPage: added support for the printRequested signal as of Qt 5.12.

Wed, 16 Jan 2019 19:25:34 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 16 Jan 2019 19:25:34 +0100
changeset 6656
273a2130adbe
parent 6655
0c948fbab480
child 6657
c6a93bbd66a5

WebBrowserPage: added support for the printRequested signal as of Qt 5.12.

WebBrowser/WebBrowserPage.py file | annotate | diff | comparison | revisions
WebBrowser/WebBrowserTabWidget.py file | annotate | diff | comparison | revisions
WebBrowser/WebBrowserView.py file | annotate | diff | comparison | revisions
--- a/WebBrowser/WebBrowserPage.py	Wed Jan 16 19:16:23 2019 +0100
+++ b/WebBrowser/WebBrowserPage.py	Wed Jan 16 19:25:34 2019 +0100
@@ -33,6 +33,7 @@
 from Globals import qVersionTuple
 
 
+# TODO: add support for 'selectClientCertificate()' signal of Qt 5.12
 class WebBrowserPage(QWebEnginePage):
     """
     Class implementing an enhanced web page.
@@ -41,8 +42,8 @@
         browsing event
     @signal safeBrowsingBad(threatType, threatMessages) emitted to indicate a
         malicious web site as determined by safe browsing
-    @signal printRequested() emitted to indicate a print request of the shown
-        web page
+    @signal printPageRequested() emitted to indicate a print request of the
+        shown web page
     @signal navigationRequestAccepted(url, navigation type, main frame) emitted
         to signal an accepted navigation request
     """
@@ -56,7 +57,7 @@
     safeBrowsingAbort = pyqtSignal()
     safeBrowsingBad = pyqtSignal(str, str)
     
-    printRequested = pyqtSignal()
+    printPageRequested = pyqtSignal()
     navigationRequestAccepted = pyqtSignal(QUrl, QWebEnginePage.NavigationType,
                                            bool)
     
@@ -155,7 +156,7 @@
                     QUrl(query.queryItemValue("url")))
                 return False
             elif url.path() == "PrintPage":
-                self.printRequested.emit()
+                self.printPageRequested.emit()
                 return False
         
         # Safe Browsing
--- a/WebBrowser/WebBrowserTabWidget.py	Wed Jan 16 19:16:23 2019 +0100
+++ b/WebBrowser/WebBrowserTabWidget.py	Wed Jan 16 19:25:34 2019 +0100
@@ -444,6 +444,12 @@
             browser.page().recentlyAudibleChanged.connect(
                 lambda audible: self.__recentlyAudibleChanged(
                     audible, browser.page()))
+        try:
+            browser.page().printRequested.connect(
+                lambda: self.printBrowser(browser))
+        except AttributeError:
+            # pre Qt 5.12
+            pass
         
         if position == -1:
             index = self.addTab(browser, self.tr("..."))
--- a/WebBrowser/WebBrowserView.py	Wed Jan 16 19:16:23 2019 +0100
+++ b/WebBrowser/WebBrowserView.py	Wed Jan 16 19:25:34 2019 +0100
@@ -154,7 +154,7 @@
         
         self.__page.safeBrowsingAbort.connect(self.safeBrowsingAbort)
         self.__page.safeBrowsingBad.connect(self.safeBrowsingBad)
-        self.__page.printRequested.connect(self.__printPage)
+        self.__page.printPageRequested.connect(self.__printPage)
         try:
             self.__page.quotaRequested.connect(self.__quotaRequested)
             self.__page.registerProtocolHandlerRequested.connect(

eric ide

mercurial