--- a/eric6/WebBrowser/WebBrowserWindow.py Sun Jan 17 13:53:08 2021 +0100 +++ b/eric6/WebBrowser/WebBrowserWindow.py Mon Feb 01 10:38:16 2021 +0100 @@ -38,18 +38,16 @@ from E5Gui.E5ZoomWidget import E5ZoomWidget from E5Gui.E5OverrideCursor import E5OverrideCursor -from E5Network.E5NetworkIcon import E5NetworkIcon - import Preferences from Preferences import Shortcuts import Utilities import Globals -from Globals import qVersionTuple import UI.PixmapCache import UI.Config from UI.Info import Version +from UI.NotificationWidget import NotificationTypes from .Tools import Scripts, WebBrowserTools, WebIconProvider @@ -146,9 +144,9 @@ super(WebBrowserWindow, self).__init__(parent) self.setObjectName(name) if private: - self.setWindowTitle(self.tr("eric6 Web Browser (Private Mode)")) + self.setWindowTitle(self.tr("eric Web Browser (Private Mode)")) else: - self.setWindowTitle(self.tr("eric6 Web Browser")) + self.setWindowTitle(self.tr("eric Web Browser")) self.__settingsDir = settingsDir self.setWindowIcon(UI.PixmapCache.getIcon("ericWeb")) @@ -163,13 +161,6 @@ self.__eventMouseButtons = Qt.NoButton self.__eventKeyboardModifiers = Qt.NoModifier - if ( - qVersionTuple() < (5, 11, 0) and - Preferences.getWebBrowser("WebInspectorEnabled") - ): - os.environ["QTWEBENGINE_REMOTE_DEBUGGING"] = str( - Preferences.getWebBrowser("WebInspectorPort")) - WebBrowserWindow.setUseQtHelp(qthelp or bool(searchWord)) self.webProfile(private) @@ -396,9 +387,6 @@ self.__tabManagerIcon = self.tabManager().createStatusBarIcon() self.statusBar().addPermanentWidget(self.__tabManagerIcon) - self.networkIcon = E5NetworkIcon(self) - self.statusBar().addPermanentWidget(self.networkIcon) - if not Preferences.getWebBrowser("StatusBarVisible"): self.statusBar().hide() @@ -614,77 +602,47 @@ settings.setAttribute( QWebEngineSettings.FullScreenSupportEnabled, Preferences.getWebBrowser("FullScreenSupportEnabled")) - - try: - # Qt 5.7 - settings.setAttribute( - QWebEngineSettings.ScreenCaptureEnabled, - Preferences.getWebBrowser("ScreenCaptureEnabled")) - settings.setAttribute( - QWebEngineSettings.WebGLEnabled, - Preferences.getWebBrowser("WebGLEnabled")) - except (AttributeError, KeyError): - pass - - try: - # Qt 5.8 - settings.setAttribute( - QWebEngineSettings.FocusOnNavigationEnabled, - Preferences.getWebBrowser("FocusOnNavigationEnabled")) - settings.setAttribute( - QWebEngineSettings.PrintElementBackgrounds, - Preferences.getWebBrowser("PrintElementBackgrounds")) - settings.setAttribute( - QWebEngineSettings.AllowRunningInsecureContent, - Preferences.getWebBrowser("AllowRunningInsecureContent")) - except (AttributeError, KeyError): - pass - - try: - # Qt 5.9 - settings.setAttribute( - QWebEngineSettings.AllowGeolocationOnInsecureOrigins, - Preferences.getWebBrowser("AllowGeolocationOnInsecureOrigins")) - except (AttributeError, KeyError): - pass - - try: - # Qt 5.10 - settings.setAttribute( - QWebEngineSettings.AllowWindowActivationFromJavaScript, - Preferences.getWebBrowser( - "AllowWindowActivationFromJavaScript")) - settings.setAttribute( - QWebEngineSettings.ShowScrollBars, - Preferences.getWebBrowser("ShowScrollBars")) - except (AttributeError, KeyError): - pass - - try: - # Qt 5.11 - settings.setAttribute( - QWebEngineSettings.PlaybackRequiresUserGesture, - Preferences.getWebBrowser( - "PlaybackRequiresUserGesture")) - settings.setAttribute( - QWebEngineSettings.JavascriptCanPaste, - Preferences.getWebBrowser( - "JavaScriptCanPaste")) - settings.setAttribute( - QWebEngineSettings.WebRTCPublicInterfacesOnly, - Preferences.getWebBrowser( - "WebRTCPublicInterfacesOnly")) - except (AttributeError, KeyError): - pass - - try: - # Qt 5.12 - settings.setAttribute( - QWebEngineSettings.DnsPrefetchEnabled, - Preferences.getWebBrowser( - "DnsPrefetchEnabled")) - except (AttributeError, KeyError): - pass + settings.setAttribute( + QWebEngineSettings.ScreenCaptureEnabled, + Preferences.getWebBrowser("ScreenCaptureEnabled")) + settings.setAttribute( + QWebEngineSettings.WebGLEnabled, + Preferences.getWebBrowser("WebGLEnabled")) + settings.setAttribute( + QWebEngineSettings.FocusOnNavigationEnabled, + Preferences.getWebBrowser("FocusOnNavigationEnabled")) + settings.setAttribute( + QWebEngineSettings.PrintElementBackgrounds, + Preferences.getWebBrowser("PrintElementBackgrounds")) + settings.setAttribute( + QWebEngineSettings.AllowRunningInsecureContent, + Preferences.getWebBrowser("AllowRunningInsecureContent")) + settings.setAttribute( + QWebEngineSettings.AllowGeolocationOnInsecureOrigins, + Preferences.getWebBrowser("AllowGeolocationOnInsecureOrigins")) + settings.setAttribute( + QWebEngineSettings.AllowWindowActivationFromJavaScript, + Preferences.getWebBrowser( + "AllowWindowActivationFromJavaScript")) + settings.setAttribute( + QWebEngineSettings.ShowScrollBars, + Preferences.getWebBrowser("ShowScrollBars")) + settings.setAttribute( + QWebEngineSettings.PlaybackRequiresUserGesture, + Preferences.getWebBrowser( + "PlaybackRequiresUserGesture")) + settings.setAttribute( + QWebEngineSettings.JavascriptCanPaste, + Preferences.getWebBrowser( + "JavaScriptCanPaste")) + settings.setAttribute( + QWebEngineSettings.WebRTCPublicInterfacesOnly, + Preferences.getWebBrowser( + "WebRTCPublicInterfacesOnly")) + settings.setAttribute( + QWebEngineSettings.DnsPrefetchEnabled, + Preferences.getWebBrowser( + "DnsPrefetchEnabled")) try: # Qt 5.13 @@ -934,10 +892,10 @@ self.tr('&Quit'), QKeySequence(self.tr("Ctrl+Q", "File|Quit")), 0, self, 'webbrowser_file_quit') - self.exitAct.setStatusTip(self.tr('Quit the eric6 Web Browser')) + self.exitAct.setStatusTip(self.tr('Quit the eric Web Browser')) self.exitAct.setWhatsThis(self.tr( """<b>Quit</b>""" - """<p>Quit the eric6 Web Browser.</p>""" + """<p>Quit the eric Web Browser.</p>""" )) self.exitAct.triggered.connect(self.shutdown) self.__actions.append(self.exitAct) @@ -2134,7 +2092,7 @@ menu.addAction(self.showTabManagerAct) menu.addAction(self.showProtocolHandlerManagerAct) if WebBrowserWindow._useQtHelp: - menu.addSeparator() + menu.addSection(self.tr("QtHelp")) menu.addAction(self.showTocAct) menu.addAction(self.showIndexAct) menu.addAction(self.showSearchAct) @@ -2248,7 +2206,7 @@ windowsMenu.addAction(self.showTabManagerAct) windowsMenu.addAction(self.showProtocolHandlerManagerAct) if WebBrowserWindow._useQtHelp: - windowsMenu.addSeparator() + windowsMenu.addSection(self.tr("QtHelp")) windowsMenu.addAction(self.showTocAct) windowsMenu.addAction(self.showIndexAct) windowsMenu.addAction(self.showSearchAct) @@ -2463,7 +2421,7 @@ @param link file to be displayed in the new window (string or QUrl) @param addNextTo reference to the browser to open the tab after (WebBrowserView) - @keyparam background flag indicating to open the tab in the + @param background flag indicating to open the tab in the background (bool) @return reference to the new browser @rtype WebBrowserView @@ -2606,11 +2564,11 @@ ) E5MessageBox.about( self, - self.tr("eric6 Web Browser"), + self.tr("eric Web Browser"), self.tr( - """<b>eric6 Web Browser - {0}</b>""" - """<p>The eric6 Web Browser is a combined help file and HTML""" - """ browser. It is part of the eric6 development""" + """<b>eric Web Browser - {0}</b>""" + """<p>The eric Web Browser is a combined help file and HTML""" + """ browser. It is part of the eric development""" """ toolset.</p>""" """<p>It is based on QtWebEngine {1} and Chrome {2}.</p>""" ).format(Version, webengineVersion, chromeVersion)) @@ -2619,7 +2577,7 @@ """ Private slot to show info about Qt. """ - E5MessageBox.aboutQt(self, self.tr("eric6 Web Browser")) + E5MessageBox.aboutQt(self, self.tr("eric Web Browser")) def setBackwardAvailable(self, b): """ @@ -3640,7 +3598,7 @@ """ E5MessageBox.warning( self, - self.tr("eric6 Web Browser"), + self.tr("eric Web Browser"), message) def __docsInstalled(self, installed): @@ -4761,7 +4719,8 @@ ########################################## @classmethod - def showNotification(cls, icon, heading, text, timeout=None): + def showNotification(cls, icon, heading, text, + kind=NotificationTypes.Information, timeout=None): """ Class method to show a desktop notification. @@ -4771,32 +4730,20 @@ @type str @param text text of the notification @type str + @param kind kind of notification to be shown + @type NotificationTypes @param timeout time in seconds the notification should be shown (None = use configured timeout, 0 = indefinitely) @type int """ - if Preferences.getUI("NotificationsEnabled"): - if cls._notification is None: - from UI.NotificationWidget import NotificationWidget - cls._notification = NotificationWidget() - cls._notification.setPixmap(icon) - cls._notification.setHeading(heading) - cls._notification.setText(text) - if timeout is None: - timeout = Preferences.getUI("NotificationTimeout") - cls._notification.setTimeout(timeout) - cls._notification.move( - Preferences.getUI("NotificationPosition")) - cls._notification.show() - - @classmethod - def notificationsEnabled(cls): - """ - Class method to check, if notifications are enabled. - - @return flag indicating, if notifications are enabled (boolean) - """ - return Preferences.getUI("NotificationsEnabled") + if cls._notification is None: + from UI.NotificationWidget import NotificationWidget + cls._notification = NotificationWidget() + + if timeout is None: + timeout = Preferences.getUI("NotificationTimeout") + cls._notification.showNotification( + icon, heading, text, kind=kind, timeout=timeout) ###################################### ## Support for global status bar below