ViewManager/ViewManager.py

branch
maintenance
changeset 5948
6f958d5765f4
parent 5742
dc9cd8059221
child 5949
22657f04f332
--- a/ViewManager/ViewManager.py	Wed Nov 01 19:22:02 2017 +0100
+++ b/ViewManager/ViewManager.py	Fri Nov 03 12:10:16 2017 +0100
@@ -1378,6 +1378,24 @@
         self.calltipsAct.triggered.connect(self.__editShowCallTips)
         self.editActions.append(self.calltipsAct)
         
+        self.codeInfoAct = E5Action(
+            QCoreApplication.translate('ViewManager', 'Code Info'),
+            UI.PixmapCache.getIcon("codeDocuViewer.png"),
+            QCoreApplication.translate('ViewManager', 'Code Info'),
+            QKeySequence(QCoreApplication.translate(
+                'ViewManager', "Ctrl+Alt+I", "Edit|Code Info")),
+            0,
+            self.editActGrp, 'vm_edit_codeinfo')
+        self.codeInfoAct.setStatusTip(QCoreApplication.translate(
+            'ViewManager', 'Show Code Info'))
+        self.codeInfoAct.setWhatsThis(QCoreApplication.translate(
+            'ViewManager',
+            """<b>Code Info</b>"""
+            """<p>Show code information based on the cursor position.</p>"""
+        ))
+        self.codeInfoAct.triggered.connect(self.__editShowCodeInfo)
+        self.editActions.append(self.codeInfoAct)
+        
         self.sortAct = E5Action(
             QCoreApplication.translate('ViewManager', 'Sort'),
             QCoreApplication.translate('ViewManager', 'Sort'),
@@ -2752,6 +2770,7 @@
         menu.addSeparator()
         menu.addMenu(autocompletionMenu)
         menu.addAction(self.calltipsAct)
+        menu.addAction(self.codeInfoAct)
         menu.addSeparator()
         menu.addMenu(searchMenu)
         menu.addSeparator()
@@ -5433,6 +5452,12 @@
         """
         self.activeWindow().callTip()
     
+    def __editShowCodeInfo(self):
+        """
+        Private method to handle the code info action.
+        """
+        self.showEditorInfo(self.activeWindow())
+    
     ##################################################################
     ## Below are the action and utility methods for the search menu
     ##################################################################
@@ -6577,6 +6602,7 @@
             self.autoCompleteAct.setEnabled(
                 editor.canProvideDynamicAutoCompletion())
             self.calltipsAct.setEnabled(editor.canProvideCallTipps())
+            self.codeInfoAct.setEnabled(self.__isEditorInfoSupportedEd(editor))
             
             if editor.isPyFile() or editor.isRubyFile():
                 self.gotoPreviousDefAct.setEnabled(True)
@@ -6782,6 +6808,40 @@
         if editor:
             editor.sortLines()
     
+    def showEditorInfo(self, editor):
+        """
+        Public method to show some information for a given editor.
+        
+        @param editor editor to show information text for
+        @type Editor
+        """
+        self.ui.documentationViewer().showInfo(editor)
+    
+    def isEditorInfoSupported(self, language):
+        """
+        Public method to check, if a language is supported by the
+        documentation viewer.
+        
+        @param language editor programming language to check
+        @type str
+        @return flag indicating the support status
+        @rtype bool
+        """
+        return self.ui.documentationViewer().isSupportedLanguage(language)
+    
+    def __isEditorInfoSupportedEd(self, editor):
+        """
+        Private method to check, if an editor is supported by the
+        documentation viewer.
+        
+        @param editor reference to the editor to check for
+        @type Editor
+        @return flag indicating the support status
+        @rtype bool
+        """
+        language = editor.getLanguage()
+        return self.isEditorInfoSupported(language)
+    
     ##################################################################
     ## Below are protected utility methods
     ##################################################################

eric ide

mercurial