Added light and dark mode empty documents to the help viewer. eric7

Thu, 23 Jun 2022 17:54:29 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 23 Jun 2022 17:54:29 +0200
branch
eric7
changeset 9172
4bac907a4c74
parent 9169
2d27173dff5f
child 9173
2f1622569c7c

Added light and dark mode empty documents to the help viewer.

eric7/APIs/Python3/eric7.api file | annotate | diff | comparison | revisions
eric7/Documentation/Help/source.qch file | annotate | diff | comparison | revisions
eric7/Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
eric7/Documentation/Source/eric7.HelpViewer.HelpViewerWidget.html file | annotate | diff | comparison | revisions
eric7/HelpViewer/HelpViewerImplQTB.py file | annotate | diff | comparison | revisions
eric7/HelpViewer/HelpViewerImplQWE.py file | annotate | diff | comparison | revisions
eric7/HelpViewer/HelpViewerWidget.py file | annotate | diff | comparison | revisions
--- a/eric7/APIs/Python3/eric7.api	Wed Jun 22 17:53:08 2022 +0200
+++ b/eric7/APIs/Python3/eric7.api	Thu Jun 23 17:54:29 2022 +0200
@@ -2164,6 +2164,8 @@
 eric7.HelpViewer.HelpViewerImplQWE.HelpViewerImplQWE.setLink?4(url)
 eric7.HelpViewer.HelpViewerImplQWE.HelpViewerImplQWE.setScale?4(scale)
 eric7.HelpViewer.HelpViewerImplQWE.HelpViewerImplQWE?1(engine, parent=None)
+eric7.HelpViewer.HelpViewerWidget.HelpViewerWidget.EmpytDocument_Dark?7
+eric7.HelpViewer.HelpViewerWidget.HelpViewerWidget.EmpytDocument_Light?7
 eric7.HelpViewer.HelpViewerWidget.HelpViewerWidget.MaxHistoryItems?7
 eric7.HelpViewer.HelpViewerWidget.HelpViewerWidget.activate?4(searchWord=None, url=None)
 eric7.HelpViewer.HelpViewerWidget.HelpViewerWidget.addPage?4(url=None, background=False)
@@ -2172,6 +2174,7 @@
 eric7.HelpViewer.HelpViewerWidget.HelpViewerWidget.closeCurrentPage?4()
 eric7.HelpViewer.HelpViewerWidget.HelpViewerWidget.closeOtherPages?4()
 eric7.HelpViewer.HelpViewerWidget.HelpViewerWidget.currentViewer?4()
+eric7.HelpViewer.HelpViewerWidget.HelpViewerWidget.emptyDocument?4()
 eric7.HelpViewer.HelpViewerWidget.HelpViewerWidget.openPagesCount?4()
 eric7.HelpViewer.HelpViewerWidget.HelpViewerWidget.openUrl?4(url)
 eric7.HelpViewer.HelpViewerWidget.HelpViewerWidget.openUrlNewBackgroundPage?4(url)
Binary file eric7/Documentation/Help/source.qch has changed
--- a/eric7/Documentation/Help/source.qhp	Wed Jun 22 17:53:08 2022 +0200
+++ b/eric7/Documentation/Help/source.qhp	Thu Jun 23 17:54:29 2022 +0200
@@ -7473,6 +7473,7 @@
       <keyword name="HelpViewerWidget.closeCurrentPage" id="HelpViewerWidget.closeCurrentPage" ref="eric7.HelpViewer.HelpViewerWidget.html#HelpViewerWidget.closeCurrentPage" />
       <keyword name="HelpViewerWidget.closeOtherPages" id="HelpViewerWidget.closeOtherPages" ref="eric7.HelpViewer.HelpViewerWidget.html#HelpViewerWidget.closeOtherPages" />
       <keyword name="HelpViewerWidget.currentViewer" id="HelpViewerWidget.currentViewer" ref="eric7.HelpViewer.HelpViewerWidget.html#HelpViewerWidget.currentViewer" />
+      <keyword name="HelpViewerWidget.emptyDocument" id="HelpViewerWidget.emptyDocument" ref="eric7.HelpViewer.HelpViewerWidget.html#HelpViewerWidget.emptyDocument" />
       <keyword name="HelpViewerWidget.openPagesCount" id="HelpViewerWidget.openPagesCount" ref="eric7.HelpViewer.HelpViewerWidget.html#HelpViewerWidget.openPagesCount" />
       <keyword name="HelpViewerWidget.openUrl" id="HelpViewerWidget.openUrl" ref="eric7.HelpViewer.HelpViewerWidget.html#HelpViewerWidget.openUrl" />
       <keyword name="HelpViewerWidget.openUrlNewBackgroundPage" id="HelpViewerWidget.openUrlNewBackgroundPage" ref="eric7.HelpViewer.HelpViewerWidget.html#HelpViewerWidget.openUrlNewBackgroundPage" />
--- a/eric7/Documentation/Source/eric7.HelpViewer.HelpViewerWidget.html	Wed Jun 22 17:53:08 2022 +0200
+++ b/eric7/Documentation/Source/eric7.HelpViewer.HelpViewerWidget.html	Thu Jun 23 17:54:29 2022 +0200
@@ -43,12 +43,16 @@
 <h3>Class Attributes</h3>
 
 <table>
-<tr><td>MaxHistoryItems</td></tr>
+<tr><td>EmpytDocument_Dark</td></tr><tr><td>EmpytDocument_Light</td></tr><tr><td>MaxHistoryItems</td></tr>
 </table>
 <h3>Class Methods</h3>
 
 <table>
-<tr><td>None</td></tr>
+
+<tr>
+<td><a href="#HelpViewerWidget.emptyDocument">emptyDocument</a></td>
+<td>Class method to get the HTML code for an empty page.</td>
+</tr>
 </table>
 <h3>Methods</h3>
 
@@ -301,6 +305,25 @@
 <tr><td>None</td></tr>
 </table>
 
+<a NAME="HelpViewerWidget.emptyDocument" ID="HelpViewerWidget.emptyDocument"></a>
+<h4>HelpViewerWidget.emptyDocument (class method)</h4>
+<b>emptyDocument</b>(<i></i>)
+
+<p>
+        Class method to get the HTML code for an empty page.
+</p>
+<dl>
+<dt>Return:</dt>
+<dd>
+HTML code for an empty page.
+</dd>
+</dl>
+<dl>
+<dt>Return Type:</dt>
+<dd>
+str
+</dd>
+</dl>
 <a NAME="HelpViewerWidget.__init__" ID="HelpViewerWidget.__init__"></a>
 <h4>HelpViewerWidget (Constructor)</h4>
 <b>HelpViewerWidget</b>(<i>parent=None</i>)
--- a/eric7/HelpViewer/HelpViewerImplQTB.py	Wed Jun 22 17:53:08 2022 +0200
+++ b/eric7/HelpViewer/HelpViewerImplQTB.py	Thu Jun 23 17:54:29 2022 +0200
@@ -73,7 +73,10 @@
         @param url source of the document
         @type QUrl
         """
-        self.setSource(url)
+        if url.toString() == "about:blank":
+            self.setHtml(self.__helpViewerWidget.emptyDocument())
+        else:
+            self.setSource(url)
     
     def link(self):
         """
--- a/eric7/HelpViewer/HelpViewerImplQWE.py	Wed Jun 22 17:53:08 2022 +0200
+++ b/eric7/HelpViewer/HelpViewerImplQWE.py	Thu Jun 23 17:54:29 2022 +0200
@@ -101,7 +101,10 @@
         @param url URL of the document
         @type QUrl
         """
-        super().setUrl(url)
+        if url.toString() == "about:blank":
+            self.setHtml(self.__helpViewerWidget.emptyDocument())
+        else:
+            super().setUrl(url)
     
     def link(self):
         """
--- a/eric7/HelpViewer/HelpViewerWidget.py	Wed Jun 22 17:53:08 2022 +0200
+++ b/eric7/HelpViewer/HelpViewerWidget.py	Thu Jun 23 17:54:29 2022 +0200
@@ -24,6 +24,7 @@
     WEBENGINE_AVAILABLE = False
 
 from EricWidgets import EricFileDialog, EricMessageBox
+from EricWidgets.EricApplication import ericApp
 from EricWidgets.EricTextEditSearchWidget import (
     EricTextEditSearchWidget, EricTextEditType
 )
@@ -46,6 +47,39 @@
     """
     MaxHistoryItems = 20    # max. number of history items to be shown
     
+    EmpytDocument_Light = (
+        '''<!DOCTYPE html>\n'''
+        '''<html lang="EN">\n'''
+        '''<head>\n'''
+        '''<style type="text/css">\n'''
+        '''html {background-color: #ffffff;}\n'''
+        '''body {background-color: #ffffff;\n'''
+        '''      color: #000000;\n'''
+        '''      margin: 10px 10px 10px 10px;\n'''
+        '''}\n'''
+        '''</style'''
+        '''</head>\n'''
+        '''<body>\n'''
+        '''</body>\n'''
+        '''</html>'''
+    )
+    EmpytDocument_Dark = (
+        '''<!DOCTYPE html>\n'''
+        '''<html lang="EN">\n'''
+        '''<head>\n'''
+        '''<style type="text/css">\n'''
+        '''html {background-color: #262626;}\n'''
+        '''body {background-color: #262626;\n'''
+        '''      color: #ffffff;\n'''
+        '''      margin: 10px 10px 10px 10px;\n'''
+        '''}\n'''
+        '''</style'''
+        '''</head>\n'''
+        '''<body>\n'''
+        '''</body>\n'''
+        '''</html>'''
+    )
+    
     def __init__(self, parent=None):
         """
         Constructor
@@ -429,6 +463,8 @@
         if urlStr:
             url = QUrl(urlStr)
             self.openUrl(url)
+        else:
+            self.openUrl(QUrl("about:blank"))
     
     def activate(self, searchWord=None, url=None):
         """
@@ -481,7 +517,9 @@
         """
         Private slot to add a new empty page.
         """
-        self.addPage()
+        urlStr = self.__helpSelector.currentData()
+        url = QUrl(urlStr) if bool(urlStr) else None
+        self.addPage(url=url)
     
     def addPage(self, url=None, background=False):
         """
@@ -1284,3 +1322,16 @@
         @rtype int
         """
         return self.__helpStack.count()
+    
+    @classmethod
+    def emptyDocument(cls):
+        """
+        Class method to get the HTML code for an empty page.
+        
+        @return HTML code for an empty page.
+        @rtype str
+        """
+        if ericApp().usesDarkPalette():
+            return cls.EmpytDocument_Dark
+        else:
+            return cls.EmpytDocument_Light

eric ide

mercurial