Web Browser eric7

Fri, 13 Oct 2023 15:32:00 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 13 Oct 2023 15:32:00 +0200
branch
eric7
changeset 10246
04f21234f09d
parent 10245
98b54c6e523b
child 10247
81f8846b62ad

Web Browser
- Added code to show browser notifications in our internal notification system.

src/eric7/Documentation/Help/source.qch file | annotate | diff | comparison | revisions
src/eric7/Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
src/eric7/Documentation/Source/eric7.WebBrowser.WebBrowserWindow.html file | annotate | diff | comparison | revisions
src/eric7/UI/NotificationWidget.py file | annotate | diff | comparison | revisions
src/eric7/WebBrowser/WebBrowserWindow.py file | annotate | diff | comparison | revisions
Binary file src/eric7/Documentation/Help/source.qch has changed
--- a/src/eric7/Documentation/Help/source.qhp	Fri Oct 13 15:30:02 2023 +0200
+++ b/src/eric7/Documentation/Help/source.qhp	Fri Oct 13 15:32:00 2023 +0200
@@ -18970,6 +18970,7 @@
       <keyword name="WebBrowserWindow.__showToolbarsMenu" id="WebBrowserWindow.__showToolbarsMenu" ref="eric7.WebBrowser.WebBrowserWindow.html#WebBrowserWindow.__showToolbarsMenu" />
       <keyword name="WebBrowserWindow.__showUserAgentsDialog" id="WebBrowserWindow.__showUserAgentsDialog" ref="eric7.WebBrowser.WebBrowserWindow.html#WebBrowserWindow.__showUserAgentsDialog" />
       <keyword name="WebBrowserWindow.__showWebIconsDialog" id="WebBrowserWindow.__showWebIconsDialog" ref="eric7.WebBrowser.WebBrowserWindow.html#WebBrowserWindow.__showWebIconsDialog" />
+      <keyword name="WebBrowserWindow.__showWebNotification" id="WebBrowserWindow.__showWebNotification" ref="eric7.WebBrowser.WebBrowserWindow.html#WebBrowserWindow.__showWebNotification" />
       <keyword name="WebBrowserWindow.__showZoomValuesDialog" id="WebBrowserWindow.__showZoomValuesDialog" ref="eric7.WebBrowser.WebBrowserWindow.html#WebBrowserWindow.__showZoomValuesDialog" />
       <keyword name="WebBrowserWindow.__shutdownWindow" id="WebBrowserWindow.__shutdownWindow" ref="eric7.WebBrowser.WebBrowserWindow.html#WebBrowserWindow.__shutdownWindow" />
       <keyword name="WebBrowserWindow.__stopLoading" id="WebBrowserWindow.__stopLoading" ref="eric7.WebBrowser.WebBrowserWindow.html#WebBrowserWindow.__stopLoading" />
--- a/src/eric7/Documentation/Source/eric7.WebBrowser.WebBrowserWindow.html	Fri Oct 13 15:30:02 2023 +0200
+++ b/src/eric7/Documentation/Source/eric7.WebBrowser.WebBrowserWindow.html	Fri Oct 13 15:32:00 2023 +0200
@@ -74,6 +74,10 @@
 <table>
 
 <tr>
+<td><a href="#WebBrowserWindow.__showWebNotification">__showWebNotification</a></td>
+<td>Class method to show a notification sent by Chromium.</td>
+</tr>
+<tr>
 <td><a href="#WebBrowserWindow.adBlockManager">adBlockManager</a></td>
 <td>Class method to get a reference to the AdBlock manager.</td>
 </tr>
@@ -853,6 +857,20 @@
 <tr><td>None</td></tr>
 </table>
 
+<a NAME="WebBrowserWindow.__showWebNotification" ID="WebBrowserWindow.__showWebNotification"></a>
+<h4>WebBrowserWindow.__showWebNotification (class method)</h4>
+<b>__showWebNotification</b>(<i>webNotification</i>)
+
+<p>
+        Class method to show a notification sent by Chromium.
+</p>
+<dl>
+
+<dt><i>webNotification</i> (QWebEngineNotification)</dt>
+<dd>
+notification sent by Chromium
+</dd>
+</dl>
 <a NAME="WebBrowserWindow.adBlockManager" ID="WebBrowserWindow.adBlockManager"></a>
 <h4>WebBrowserWindow.adBlockManager (class method)</h4>
 <b>adBlockManager</b>(<i></i>)
--- a/src/eric7/UI/NotificationWidget.py	Fri Oct 13 15:30:02 2023 +0200
+++ b/src/eric7/UI/NotificationWidget.py	Fri Oct 13 15:32:00 2023 +0200
@@ -69,7 +69,7 @@
             icon = NotificationFrame.getIcon(kind)
         self.icon.setPixmap(icon)
 
-        self.heading.setText(heading)
+        self.heading.setText("<b>{0}</b>".format(heading))
         self.text.setText(text)
 
         self.show()
--- a/src/eric7/WebBrowser/WebBrowserWindow.py	Fri Oct 13 15:30:02 2023 +0200
+++ b/src/eric7/WebBrowser/WebBrowserWindow.py	Fri Oct 13 15:32:00 2023 +0200
@@ -24,7 +24,14 @@
     pyqtSignal,
     pyqtSlot,
 )
-from PyQt6.QtGui import QAction, QDesktopServices, QFont, QFontMetrics, QKeySequence
+from PyQt6.QtGui import (
+    QAction,
+    QDesktopServices,
+    QFont,
+    QFontMetrics,
+    QKeySequence,
+    QPixmap,
+)
 from PyQt6.QtWebEngineCore import (
     QWebEnginePage,
     QWebEngineProfile,
@@ -5213,6 +5220,22 @@
             icon, heading, text, kind=kind, timeout=timeout
         )
 
+    @classmethod
+    def __showWebNotification(cls, webNotification):
+        """
+        Class method to show a notification sent by Chromium.
+
+        @param webNotification notification sent by Chromium
+        @type QWebEngineNotification
+        """
+        cls.showNotification(
+            QPixmap.fromImage(webNotification.icon()),
+            webNotification.title(),
+            webNotification.message(),
+            kind=NotificationTypes.OTHER,
+            timeout=0,
+        )
+
     ######################################
     ## Support for global status bar below
     ######################################
@@ -5308,6 +5331,9 @@
                     Preferences.getWebBrowser("SpellCheckLanguages")
                 )
 
+            # configure notifications
+            cls._webProfile.setNotificationPresenter(cls.__showWebNotification)
+
             # Setup QWebChannel user scripts
             # WebChannel for SafeJsWorld
             script = QWebEngineScript()

eric ide

mercurial