Continued implementing the embedded help viewer widget. Added buttons to open a new page and to close the current page. eric7

Mon, 18 Oct 2021 16:44:29 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 18 Oct 2021 16:44:29 +0200
branch
eric7
changeset 8699
8438a5a0437f
parent 8698
b108ff4d845c
child 8700
112271b4a2eb

Continued implementing the embedded help viewer widget. Added buttons to open a new page and to close the current page.

eric7/HelpViewer/HelpViewerWidget.py file | annotate | diff | comparison | revisions
eric7/eric7.py file | annotate | diff | comparison | revisions
--- a/eric7/HelpViewer/HelpViewerWidget.py	Mon Oct 18 16:43:02 2021 +0200
+++ b/eric7/HelpViewer/HelpViewerWidget.py	Mon Oct 18 16:44:29 2021 +0200
@@ -21,7 +21,7 @@
     from PyQt6.QtWebEngineCore import QWebEngineProfile, QWebEngineSettings
     WEBENGINE_AVAILABLE = True
 except ImportError:
-    WEBENGINE_AVAILABLE = True
+    WEBENGINE_AVAILABLE = False
 
 from EricWidgets import EricFileDialog, EricMessageBox
 
@@ -148,8 +148,26 @@
         self.__buttonLine2.setFrameShadow(QFrame.Shadow.Sunken)
         self.__navButtonsLayout.addWidget(self.__buttonLine2)
         
-        # TODO: add plus button to open a new page (about:blank)
-        # TODO: add minus button to close the current page
+        self.__addPageButton = QToolButton(self)
+        self.__addPageButton.setIcon(UI.PixmapCache.getIcon("plus"))
+        self.__addPageButton.setToolTip(
+            self.tr("Add a new empty page"))
+        self.__addPageButton.clicked.connect(self.__addNewPage)
+        self.__navButtonsLayout.addWidget(self.__addPageButton)
+        
+        self.__closePageButton = QToolButton(self)
+        self.__closePageButton.setIcon(UI.PixmapCache.getIcon("minus"))
+        self.__closePageButton.setToolTip(
+            self.tr("Close the current page"))
+        self.__closePageButton.clicked.connect(self.closeCurrentPage)
+        self.__navButtonsLayout.addWidget(self.__closePageButton)
+        
+        self.__buttonLine3 = QFrame(self)
+        self.__buttonLine3.setFrameShape(QFrame.Shape.VLine)
+        self.__buttonLine3.setFrameShadow(QFrame.Shadow.Sunken)
+        self.__navButtonsLayout.addWidget(self.__buttonLine3)
+        
+        # TODO: add find button to show the find widget
         
         self.__navButtonsLayout.addStretch()
         
@@ -396,6 +414,13 @@
         if htmlFile:
             self.currentViewer().setLink(QUrl.fromLocalFile(htmlFile))
     
+    @pyqtSlot()
+    def __addNewPage(self):
+        """
+        Private slot to add a new empty page.
+        """
+        self.addPage()
+    
     def addPage(self, url=None, background=False):
         """
         Public method to add a new help page with the given URL.
@@ -412,7 +437,7 @@
             url = QUrl("about:blank")
         
         viewer = self.__newViewer()
-        viewer.setUrl(url)
+        viewer.setLink(url)
         
         cv = self.currentViewer()
         if background and bool(cv):
--- a/eric7/eric7.py	Mon Oct 18 16:43:02 2021 +0200
+++ b/eric7/eric7.py	Mon Oct 18 16:44:29 2021 +0200
@@ -43,7 +43,8 @@
     sys.exit(100)
 
 try:
-    from PyQt6 import QtWebEngineWidgets    # __IGNORE_WARNING__
+    from PyQt6 import QtWebEngineWidgets
+    # __IGNORE_WARNING__ __IGNORE_EXCEPTION__
     from PyQt6.QtWebEngineCore import QWebEngineUrlScheme
     WEBENGINE_AVAILABLE = True
 except ImportError:

eric ide

mercurial