eric7/UI/UserInterface.py

branch
eric7
changeset 8678
85a83e4e7f18
parent 8637
394377638256
child 8680
85503ff2fce9
diff -r 2e3d02a0f0b6 -r 85a83e4e7f18 eric7/UI/UserInterface.py
--- a/eric7/UI/UserInterface.py	Wed Oct 06 18:53:50 2021 +0200
+++ b/eric7/UI/UserInterface.py	Wed Oct 06 20:00:29 2021 +0200
@@ -974,6 +974,10 @@
         from VCS.StatusWidget import StatusWidget
         self.__vcsStatusWidget = StatusWidget(
             self.project, self.viewmanager, self)
+        
+        # Create the embedded help viewer
+        from HelpViewer.HelpViewerWidget import HelpViewerWidget
+        self.__helpViewerWidget = HelpViewerWidget(self)
     
     def __createLayout(self):
         """
@@ -1058,23 +1062,31 @@
         ## Populate the left toolbox
         ####################################################
         
+        self.lToolbox.addItem(self.multiProjectBrowser,
+                              UI.PixmapCache.getIcon("multiProjectViewer"),
+                              self.tr("Multiproject-Viewer"))
+        
         self.lToolbox.addItem(self.projectBrowser,
                               UI.PixmapCache.getIcon("projectViewer"),
                               self.tr("Project-Viewer"))
-
+        
+        self.lToolbox.addItem(self.__findFileWidget,
+                              UI.PixmapCache.getIcon("find"),
+                              self.tr("Find/Replace In Files"))
+        
+        self.lToolbox.addItem(self.__findLocationWidget,
+                              UI.PixmapCache.getIcon("findLocation"),
+                              self.tr("Find File"))
+        
         self.lToolbox.addItem(self.__vcsStatusWidget,
                               UI.PixmapCache.getIcon("tbVcsStatus"),
                               self.tr("VCS Status"))
-
-        self.lToolbox.addItem(self.multiProjectBrowser,
-                              UI.PixmapCache.getIcon("multiProjectViewer"),
-                              self.tr("Multiproject-Viewer"))
         
         if self.templateViewer:
             self.lToolbox.addItem(self.templateViewer,
                                   UI.PixmapCache.getIcon("templateViewer"),
                                   self.tr("Template-Viewer"))
-
+        
         if self.browser:
             self.lToolbox.addItem(self.browser,
                                   UI.PixmapCache.getIcon("browser"),
@@ -1089,22 +1101,18 @@
         ## Populate the right toolbox
         ####################################################
         
+        self.rToolbox.addItem(self.debugViewer,
+                              UI.PixmapCache.getIcon("debugViewer"),
+                              self.tr("Debug-Viewer"))
+        
         if self.codeDocumentationViewer:
             self.rToolbox.addItem(self.codeDocumentationViewer,
                                   UI.PixmapCache.getIcon("codeDocuViewer"),
                                   self.tr("Code Documentation Viewer"))
         
-        self.rToolbox.addItem(self.debugViewer,
-                              UI.PixmapCache.getIcon("debugViewer"),
-                              self.tr("Debug-Viewer"))
-        
-        self.rToolbox.addItem(self.__findFileWidget,
-                              UI.PixmapCache.getIcon("find"),
-                              self.tr("Find/Replace In Files"))
-        
-        self.rToolbox.addItem(self.__findLocationWidget,
-                              UI.PixmapCache.getIcon("findLocation"),
-                              self.tr("Find File"))
+        self.rToolbox.addItem(self.__helpViewerWidget,
+                              UI.PixmapCache.getIcon("help"),
+                              self.tr("Help Viewer"))
         
         self.rToolbox.addItem(self.pluginRepositoryViewer,
                               UI.PixmapCache.getIcon("pluginRepository"),
@@ -1113,6 +1121,7 @@
         self.rToolbox.addItem(self.__virtualenvManagerWidget,
                               UI.PixmapCache.getIcon("virtualenv"),
                               self.tr("Virtual Environments"))
+        
         if self.pipWidget:
             self.rToolbox.addItem(self.pipWidget,
                                   UI.PixmapCache.getIcon("pypi"),
@@ -1206,26 +1215,36 @@
         ####################################################
         
         self.leftSidebar.addTab(
+            self.multiProjectBrowser,
+            UI.PixmapCache.getIcon("sbMultiProjectViewer96"),
+            self.tr("Multiproject-Viewer"))
+        
+        self.leftSidebar.addTab(
             self.projectBrowser,
             UI.PixmapCache.getIcon("sbProjectViewer96"),
             self.tr("Project-Viewer"))
-
+        
+        self.leftSidebar.addTab(
+            self.__findFileWidget,
+            UI.PixmapCache.getIcon("sbFind96"),
+            self.tr("Find/Replace In Files"))
+        
+        self.leftSidebar.addTab(
+            self.__findLocationWidget,
+            UI.PixmapCache.getIcon("sbFindLocation96"),
+            self.tr("Find File"))
+        
         self.leftSidebar.addTab(
             self.__vcsStatusWidget,
             UI.PixmapCache.getIcon("sbVcsStatus96"),
             self.tr("VCS Status"))
-
-        self.leftSidebar.addTab(
-            self.multiProjectBrowser,
-            UI.PixmapCache.getIcon("sbMultiProjectViewer96"),
-            self.tr("Multiproject-Viewer"))
-
+        
         if self.templateViewer:
             self.leftSidebar.addTab(
                 self.templateViewer,
                 UI.PixmapCache.getIcon("sbTemplateViewer96"),
                 self.tr("Template-Viewer"))
-
+        
         if self.browser:
             self.leftSidebar.addTab(
                 self.browser,
@@ -1242,6 +1261,11 @@
         ## Populate the right side bar
         ####################################################
         
+        self.rightSidebar.addTab(
+            self.debugViewer,
+            UI.PixmapCache.getIcon("sbDebugViewer96"),
+            self.tr("Debug-Viewer"))
+        
         if self.codeDocumentationViewer:
             self.rightSidebar.addTab(
                 self.codeDocumentationViewer,
@@ -1249,19 +1273,9 @@
                 self.tr("Code Documentation Viewer"))
         
         self.rightSidebar.addTab(
-            self.debugViewer,
-            UI.PixmapCache.getIcon("sbDebugViewer96"),
-            self.tr("Debug-Viewer"))
-        
-        self.rightSidebar.addTab(
-            self.__findFileWidget,
-            UI.PixmapCache.getIcon("sbFind96"),
-            self.tr("Find/Replace In Files"))
-        
-        self.rightSidebar.addTab(
-            self.__findLocationWidget,
-            UI.PixmapCache.getIcon("sbFindLocation96"),
-            self.tr("Find File"))
+            self.__helpViewerWidget,
+            UI.PixmapCache.getIcon("sbHelpViewer96"),
+            self.tr("Help Viewer"))
         
         self.rightSidebar.addTab(
             self.pluginRepositoryViewer,
@@ -2322,6 +2336,26 @@
         self.actions.append(self.vcsStatusListActivateAct)
         self.addAction(self.vcsStatusListActivateAct)
         
+        self.helpViewerActivateAct = EricAction(
+            self.tr("Help Viewer"),
+            self.tr("Help Viewer"),
+            QKeySequence(self.tr("Alt+Shift+H")),
+            0, self,
+            'help_viewer_activate')
+        self.helpViewerActivateAct.setStatusTip(self.tr(
+            "Switch the input focus to the embedded Help Viewer window."))
+        self.helpViewerActivateAct.setWhatsThis(self.tr(
+            """<b>Help Viewer</b>"""
+            """<p>This switches the input focus to the embedded Help Viewer"""
+            """ window. It will show HTML help files and help from Qt help"""
+            """ collections.</p><p>If called with a word selected, this word"""
+            """ is searched in the Qt help collection.</p>"""
+        ))
+        self.helpViewerActivateAct.triggered.connect(
+            self.__activateHelpViewerWidget)
+        self.actions.append(self.helpViewerActivateAct)
+        self.addAction(self.helpViewerActivateAct)
+        
         self.whatsThisAct = EricAction(
             self.tr('What\'s This?'),
             UI.PixmapCache.getIcon("whatsThis"),
@@ -2355,7 +2389,7 @@
             """ has the capability to navigate to links, set bookmarks,"""
             """ print the displayed help and some more features. You may"""
             """ use it to browse the internet as well</p><p>If called"""
-            """ with a word selected, this word is search in the Qt help"""
+            """ with a word selected, this word is searched in the Qt help"""
             """ collection.</p>"""
         ))
         self.helpviewerAct.triggered.connect(self.__helpViewer)
@@ -3396,9 +3430,11 @@
         self.__menus["subwindow"].addSection(self.tr("Left Side"))
         if self.__shellPosition == "left":
             self.__menus["subwindow"].addAction(self.shellActivateAct)
+        self.__menus["subwindow"].addAction(self.mpbActivateAct)
         self.__menus["subwindow"].addAction(self.pbActivateAct)
+        self.__menus["subwindow"].addAction(self.findFileActivateAct)
+        self.__menus["subwindow"].addAction(self.findLocationActivateAct)
         self.__menus["subwindow"].addAction(self.vcsStatusListActivateAct)
-        self.__menus["subwindow"].addAction(self.mpbActivateAct)
         if self.templateViewer is not None:
             self.__menus["subwindow"].addAction(self.templateViewerActivateAct)
         if self.browser is not None:
@@ -3419,12 +3455,12 @@
         self.__menus["subwindow"].addSection(self.tr("Right Side"))
         if self.__shellPosition == "right":
             self.__menus["subwindow"].addAction(self.shellActivateAct)
+        self.__menus["subwindow"].addAction(self.debugViewerActivateAct)
         if self.codeDocumentationViewer is not None:
             self.__menus["subwindow"].addAction(
                 self.codeDocumentationViewerActivateAct)
-        self.__menus["subwindow"].addAction(self.debugViewerActivateAct)
-        self.__menus["subwindow"].addAction(self.findFileActivateAct)
-        self.__menus["subwindow"].addAction(self.findLocationActivateAct)
+        self.__menus["subwindow"].addAction(
+            self.helpViewerActivateAct)
         self.__menus["subwindow"].addAction(
             self.pluginRepositoryViewerActivateAct)
         self.__menus["subwindow"].addAction(self.virtualenvManagerActivateAct)
@@ -3440,6 +3476,8 @@
         if self.microPythonWidget is not None:
             self.__menus["subwindow"].addAction(
                 self.microPythonWidgetActivateAct)
+        
+        # plug-in provided windows
         self.__menus["subwindow"].addSection(self.tr("Plug-ins"))
         
         ##############################################################
@@ -6949,11 +6987,11 @@
         Private slot to activate the Find In Files widget.
         """
         if self.__layoutType == "Toolboxes":
-            self.rToolboxDock.show()
-            self.rToolbox.setCurrentWidget(self.__findFileWidget)
+            self.lToolboxDock.show()
+            self.lToolbox.setCurrentWidget(self.__findFileWidget)
         elif self.__layoutType == "Sidebars":
-            self.rightSidebar.show()
-            self.rightSidebar.setCurrentWidget(self.__findFileWidget)
+            self.leftSidebar.show()
+            self.leftSidebar.setCurrentWidget(self.__findFileWidget)
         self.__findFileWidget.setFocus(
             Qt.FocusReason.ActiveWindowFocusReason)
         
@@ -6970,11 +7008,11 @@
         Private method to activate the Find File widget.
         """
         if self.__layoutType == "Toolboxes":
-            self.rToolboxDock.show()
-            self.rToolbox.setCurrentWidget(self.__findLocationWidget)
+            self.lToolboxDock.show()
+            self.lToolbox.setCurrentWidget(self.__findLocationWidget)
         elif self.__layoutType == "Sidebars":
-            self.rightSidebar.show()
-            self.rightSidebar.setCurrentWidget(self.__findLocationWidget)
+            self.leftSidebar.show()
+            self.leftSidebar.setCurrentWidget(self.__findLocationWidget)
         self.__findLocationWidget.setFocus(
             Qt.FocusReason.ActiveWindowFocusReason)
         
@@ -6993,6 +7031,24 @@
         self.__vcsStatusWidget.setFocus(
             Qt.FocusReason.ActiveWindowFocusReason)
     
+    def __activateHelpViewerWidget(self):
+        """
+        Private method to activate the embedded Help Viewer window.
+        """
+        if self.__layoutType == "Toolboxes":
+            self.rToolboxDock.show()
+            self.rToolbox.setCurrentWidget(self.__helpViewerWidget)
+        elif self.__layoutType == "Sidebars":
+            self.rightSidebar.show()
+            self.rightSidebar.setCurrentWidget(self.__helpViewerWidget)
+        self.__helpViewerWidget.setFocus(
+            Qt.FocusReason.ActiveWindowFocusReason)
+            
+        searchWord = self.viewmanager.textForFind(False)
+        if searchWord == "":
+            searchWord = None
+        self.__helpViewerWidget.activate(searchWord=searchWord)
+    
     ##########################################################
     ## Below are slots to handle StdOut and StdErr
     ##########################################################

eric ide

mercurial