Started implementing the status bar icons for the new web browser.

Mon, 02 May 2016 20:13:41 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 02 May 2016 20:13:41 +0200
changeset 4962
b602ac3fe532
parent 4961
f29e590ec5e0
child 4963
e5e31c75ce00

Started implementing the status bar icons for the new web browser.

WebBrowser/StatusBar/StatusBarIcon.py file | annotate | diff | comparison | revisions
WebBrowser/StatusBar/__init__.py file | annotate | diff | comparison | revisions
eric6.e4p file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebBrowser/StatusBar/StatusBarIcon.py	Mon May 02 20:13:41 2016 +0200
@@ -0,0 +1,85 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2016 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing the status bar icon base class.
+"""
+
+#
+# This is modelled after the code found in Qupzilla
+# Copyright (C) 2014  David Rosca <nowrep@gmail.com>
+#
+
+from __future__ import unicode_literals
+
+from E5Gui.E5ClickableLabel import E5ClickableLabel
+
+
+class StatusBarIcon(E5ClickableLabel):
+    """
+    Class implementing common methods for all status bar icons.
+    """
+    def __init__(self, window):
+        """
+        Constructor
+        
+        @param window reference to the web browser window
+        @type WebBrowserWindow
+        """
+        super(StatusBarIcon, self).__init__(window)
+        
+        self._window = window
+    
+    def _testCurrentPageWebAttribute(self, attr):
+        """
+        Protected method to test a web attribute on the current page.
+        
+        @param attr attribute to test
+        @type QWebEngineSettings.WebAttribute
+        @return flag indicating the attribute is set
+        @rtype bool
+        """
+        settings = self._currentPageSettings()
+        return settings is not None and settings.testAttribute(attr)
+    
+    def _setCurrentPageWebAttribute(self, attr, val):
+        """
+        Protected method to set a web attribute on the current page.
+        
+        @param attr attribute to sett
+        @type QWebEngineSettings.WebAttribute
+        @param val value to be set
+        @type bool
+        """
+        settings = self._currentPageSettings()
+        if settings is not None:
+            settings.setAttribute(attr, val)
+    
+    def _currentPageSettings(self):
+        """
+        Protected method to get a reference to the web settings of the
+        current page.
+        
+        @return reference to the web settings object
+        @rtype QWebEngineSettings
+        """
+        view = self._window.currentBrowser()
+        if view is None:
+            return None
+        
+        return view.page().settings()
+    
+    def _currentPage(self):
+        """
+        Protected method to get a reference to the current page.
+        
+        @return reference to the current page
+        @rtype WebBrowserPage
+        """
+        view = self._window.currentBrowser()
+        if view is None:
+            return None
+        
+        return view.page()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebBrowser/StatusBar/__init__.py	Mon May 02 20:13:41 2016 +0200
@@ -0,0 +1,8 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2016 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Package implementing some status bar icons.
+"""
--- a/eric6.e4p	Mon May 02 20:12:45 2016 +0200
+++ b/eric6.e4p	Mon May 02 20:13:41 2016 +0200
@@ -1406,6 +1406,7 @@
     <Source>WebBrowser/SpeedDial/SpeedDialReader.py</Source>
     <Source>WebBrowser/SpeedDial/SpeedDialWriter.py</Source>
     <Source>WebBrowser/SpeedDial/__init__.py</Source>
+    <Source>WebBrowser/StatusBar/__init__.py</Source>
     <Source>WebBrowser/Sync/DirectorySyncHandler.py</Source>
     <Source>WebBrowser/Sync/FtpSyncHandler.py</Source>
     <Source>WebBrowser/Sync/SyncAssistantDialog.py</Source>

eric ide

mercurial