src/eric7/WebBrowser/WebBrowserWindow.py

branch
eric7
changeset 10246
04f21234f09d
parent 10069
435cc5875135
child 10247
81f8846b62ad
--- 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