eric6/UI/UserInterface.py

branch
maintenance
changeset 7214
f434af227a41
parent 7117
4038dc8c58c9
parent 7158
d38750ac8410
child 7286
7eb04391adf7
diff -r c1a8a2cf56d0 -r f434af227a41 eric6/UI/UserInterface.py
--- a/eric6/UI/UserInterface.py	Sat Aug 03 11:34:00 2019 +0200
+++ b/eric6/UI/UserInterface.py	Sat Sep 07 12:59:54 2019 +0200
@@ -281,6 +281,7 @@
         self.numbersViewer = None
         self.pipWidget = None
         self.condaWidget = None
+        self.microPythonWidget = None
         
         self.__webBrowserProcess = None
         self.__webBrowserClient = None
@@ -605,6 +606,8 @@
             e5App().registerObject("Numbers", self.numbersViewer)
         if self.codeDocumentationViewer is not None:
             e5App().registerObject("DocuViewer", self.codeDocumentationViewer)
+        if self.microPythonWidget is not None:
+            e5App().registerObject("MicroPython", self.microPythonWidget)
         
         # list of web addresses serving the versions file
         self.__httpAlternatives = Preferences.getUI("VersionsUrls6")
@@ -906,6 +909,15 @@
                                   UI.PixmapCache.getIcon("irc.png"),
                                   self.tr("IRC"))
         
+        if Preferences.getUI("ShowMicroPython"):
+            # Create the MicroPython part of the user interface
+            logging.debug("Creating MicroPython Widget...")
+            from MicroPython.MicroPythonWidget import MicroPythonWidget
+            self.microPythonWidget = MicroPythonWidget(self)
+            self.rToolbox.addItem(self.microPythonWidget,
+                                  UI.PixmapCache.getIcon("micropython"),
+                                  self.tr("MicroPython"))
+        
         ####################################################
         ## Populate the bottom toolbox
         ####################################################
@@ -1094,6 +1106,15 @@
                 self.irc, UI.PixmapCache.getIcon("irc.png"),
                 self.tr("IRC"))
         
+        if Preferences.getUI("ShowMicroPython"):
+            # Create the MicroPython part of the user interface
+            logging.debug("Creating MicroPython Widget...")
+            from MicroPython.MicroPythonWidget import MicroPythonWidget
+            self.microPythonWidget = MicroPythonWidget(self)
+            self.rightSidebar.addTab(
+                self.microPythonWidget, UI.PixmapCache.getIcon("micropython"),
+                self.tr("MicroPython"))
+        
         ####################################################
         ## Populate the bottom side bar
         ####################################################
@@ -1192,11 +1213,15 @@
         """
         Public method to add a widget to the sides.
         
-        @param side side to add the widget to (UserInterface.LeftSide,
-            UserInterface.BottomSide)
-        @param widget reference to the widget to add (QWidget)
-        @param icon icon to be used (QIcon)
-        @param label label text to be shown (string)
+        @param side side to add the widget to
+        @type int (one of UserInterface.LeftSide, UserInterface.BottomSide,
+            UserInterface.RightSide)
+        @param widget reference to the widget to add
+        @type QWidget
+        @param icon icon to be used
+        @type QIcon
+        @param label label text to be shown
+        @type str
         """
         assert side in [UserInterface.LeftSide, UserInterface.BottomSide,
                         UserInterface.RightSide]
@@ -1215,12 +1240,13 @@
                 self.bottomSidebar.addTab(widget, icon, label)
             elif side == UserInterface.RightSide:
                 self.rightSidebar.addTab(widget, icon, label)
-        
+    
     def removeSideWidget(self, widget):
         """
         Public method to remove a widget added using addSideWidget().
         
-        @param widget reference to the widget to remove (QWidget)
+        @param widget reference to the widget to remove
+        @type QWidget
         """
         if self.__layoutType == "Toolboxes":
             for container in [self.lToolbox, self.hToolbox, self.rToolbox]:
@@ -1233,7 +1259,34 @@
                 index = container.indexOf(widget)
                 if index != -1:
                     container.removeTab(index)
-        
+    
+    def showSideWidget(self, widget):
+        """
+        Public method to show a specific widget placed in the side widgets.
+        
+        @param widget reference to the widget to be shown
+        @type QWidget
+        """
+        if self.__layoutType == "Toolboxes":
+            for dock in [self.lToolboxDock, self.hToolboxDock,
+                         self.rToolboxDock]:
+                container = dock.widget()
+                index = container.indexOf(widget)
+                if index != -1:
+                    dock.show()
+                    container.setCurrentIndex(index)
+                    dock.raise_()
+        elif self.__layoutType == "Sidebars":
+            for container in [self.leftSidebar, self.bottomSidebar,
+                              self.rightSidebar]:
+                index = container.indexOf(widget)
+                if index != -1:
+                    container.show()
+                    container.setCurrentIndex(index)
+                    container.raise_()
+                    if container.isAutoHiding():
+                        container.setFocus()
+    
     def showLogViewer(self):
         """
         Public method to show the Log-Viewer.
@@ -1820,7 +1873,7 @@
             self.ircActivateAct = E5Action(
                 self.tr('IRC'),
                 self.tr('&IRC'),
-                QKeySequence(self.tr("Meta+Shift+I")),
+                QKeySequence(self.tr("Ctrl+Alt+Shift+I")),
                 0, self,
                 'irc_widget_activate')
             self.ircActivateAct.setStatusTip(self.tr(
@@ -1871,7 +1924,83 @@
                 self.__activateNumbersViewer)
             self.actions.append(self.numbersViewerActivateAct)
             self.addAction(self.numbersViewerActivateAct)
-
+        
+        if self.codeDocumentationViewer is not None:
+            self.codeDocumentationViewerActivateAct = E5Action(
+                self.tr('Code Documentation Viewer'),
+                self.tr('Code Documentation Viewer'),
+                QKeySequence(self.tr("Ctrl+Alt+Shift+D")),
+                0, self,
+                'code_documentation_viewer_activate')
+            self.codeDocumentationViewerActivateAct.setStatusTip(self.tr(
+                "Switch the input focus to the Code Documentation Viewer"
+                " window."))
+            self.codeDocumentationViewerActivateAct.setWhatsThis(self.tr(
+                """<b>Code Documentation Viewer</b>"""
+                """<p>This switches the input focus to the Code"""
+                """ Documentation Viewer window.</p>"""
+            ))
+            self.codeDocumentationViewerActivateAct.triggered.connect(
+                self.activateCodeDocumentationViewer)
+            self.actions.append(self.codeDocumentationViewerActivateAct)
+            self.addAction(self.codeDocumentationViewerActivateAct)
+        
+        if self.pipWidget is not None:
+            self.pipWidgetActivateAct = E5Action(
+                self.tr('PyPI'),
+                self.tr('PyPI'),
+                QKeySequence(self.tr("Ctrl+Alt+Shift+P")),
+                0, self,
+                'pip_widget_activate')
+            self.pipWidgetActivateAct.setStatusTip(self.tr(
+                "Switch the input focus to the PyPI window."))
+            self.pipWidgetActivateAct.setWhatsThis(self.tr(
+                """<b>PyPI</b>"""
+                """<p>This switches the input focus to the PyPI window.</p>"""
+            ))
+            self.pipWidgetActivateAct.triggered.connect(
+                self.__activatePipWidget)
+            self.actions.append(self.pipWidgetActivateAct)
+            self.addAction(self.pipWidgetActivateAct)
+        
+        if self.condaWidget is not None:
+            self.condaWidgetActivateAct = E5Action(
+                self.tr('Conda'),
+                self.tr('Conda'),
+                QKeySequence(self.tr("Ctrl+Alt+Shift+C")),
+                0, self,
+                'conda_widget_activate')
+            self.condaWidgetActivateAct.setStatusTip(self.tr(
+                "Switch the input focus to the Conda window."))
+            self.condaWidgetActivateAct.setWhatsThis(self.tr(
+                """<b>Conda</b>"""
+                """<p>This switches the input focus to the Conda window.</p>"""
+            ))
+            self.condaWidgetActivateAct.triggered.connect(
+                self.__activateCondaWidget)
+            self.actions.append(self.condaWidgetActivateAct)
+            self.addAction(self.condaWidgetActivateAct)
+        
+        # TODO: add action for "MicroPython", Ctrl+Alt+Shift+M
+        if self.microPythonWidget is not None:
+            self.microPythonWidgetActivateAct = E5Action(
+                self.tr('MicroPython'),
+                self.tr('MicroPython'),
+                QKeySequence(self.tr("Ctrl+Alt+Shift+M")),
+                0, self,
+                'micropython_widget_activate')
+            self.microPythonWidgetActivateAct.setStatusTip(self.tr(
+                "Switch the input focus to the MicroPython window."))
+            self.microPythonWidgetActivateAct.setWhatsThis(self.tr(
+                """<b>MicroPython</b>"""
+                """<p>This switches the input focus to the MicroPython"""
+                """ window.</p>"""
+            ))
+            self.microPythonWidgetActivateAct.triggered.connect(
+                self.__activateMicroPython)
+            self.actions.append(self.microPythonWidgetActivateAct)
+            self.addAction(self.microPythonWidgetActivateAct)
+        
         self.whatsThisAct = E5Action(
             self.tr('What\'s This?'),
             UI.PixmapCache.getIcon("whatsThis.png"),
@@ -2466,7 +2595,7 @@
             self.tr('Activate current editor'),
             self.tr('Activate current editor'),
             QKeySequence(self.tr("Alt+Shift+E")),
-            0, self, 'viewmanager_activate', 1)
+            0, self, 'viewmanager_activate')
         self.viewmanagerActivateAct.triggered.connect(
             self.__activateViewmanager)
         self.actions.append(self.viewmanagerActivateAct)
@@ -2993,6 +3122,13 @@
         self.__menus["subwindow"] = QMenu(self.tr("&Windows"),
                                           self.__menus["window"])
         self.__menus["subwindow"].setTearOffEnabled(True)
+        # central park
+        try:
+            self.__menus["subwindow"].addSection(self.tr("Central Park"))
+        except AttributeError:
+            # Qt4
+            self.__menus["subwindow"].addSeparator()
+        self.__menus["subwindow"].addAction(self.viewmanagerActivateAct)
         # left side
         try:
             self.__menus["subwindow"].addSection(self.tr("Left Side"))
@@ -3031,22 +3167,20 @@
             self.__menus["subwindow"].addAction(self.shellActivateAct)
         if self.codeDocumentationViewer is not None:
             self.__menus["subwindow"].addAction(
-                self.tr("Code Documentation Viewer"),
-                self.activateCodeDocumentationViewer)
+                self.codeDocumentationViewerActivateAct)
         self.__menus["subwindow"].addAction(self.debugViewerActivateAct)
         if self.pipWidget is not None:
-            self.__menus["subwindow"].addAction(
-                self.tr("PyPI"),
-                self.__activatePipWidget)
+            self.__menus["subwindow"].addAction(self.pipWidgetActivateAct)
         if self.condaWidget is not None:
-            self.__menus["subwindow"].addAction(
-                self.tr("Conda"),
-                self.__activateCondaWidget)
+            self.__menus["subwindow"].addAction(self.condaWidgetActivateAct)
         if self.cooperation is not None:
             self.__menus["subwindow"].addAction(
                 self.cooperationViewerActivateAct)
         if self.irc is not None:
             self.__menus["subwindow"].addAction(self.ircActivateAct)
+        if self.microPythonWidget is not None:
+            self.__menus["subwindow"].addAction(
+                self.microPythonWidgetActivateAct)
         try:
             self.__menus["subwindow"].addSection(self.tr("Plug-ins"))
         except AttributeError:
@@ -4621,6 +4755,19 @@
                 self.rightSidebar.setCurrentWidget(self.condaWidget)
             self.condaWidget.setFocus(Qt.ActiveWindowFocusReason)
     
+    def __activateMicroPython(self):
+        """
+        Private slot to handle the activation of the MicroPython widget.
+        """
+        if self.microPythonWidget is not None:
+            if self.__layoutType == "Toolboxes":
+                self.rToolboxDock.show()
+                self.rToolbox.setCurrentWidget(self.microPythonWidget)
+            elif self.__layoutType == "Sidebars":
+                self.rightSidebar.show()
+                self.rightSidebar.setCurrentWidget(self.microPythonWidget)
+            self.microPythonWidget.setFocus(Qt.ActiveWindowFocusReason)
+    
     def __toggleWindow(self, w):
         """
         Private method to toggle a workspace editor window.

eric ide

mercurial