eric7/UI/UserInterface.py

branch
eric7
changeset 8610
c9cd21bcbe33
parent 8595
ce2034bc1c6e
child 8614
4a3a68e51b92
diff -r fd6b68a0a2df -r c9cd21bcbe33 eric7/UI/UserInterface.py
--- a/eric7/UI/UserInterface.py	Thu Sep 16 19:23:07 2021 +0200
+++ b/eric7/UI/UserInterface.py	Thu Sep 16 19:31:00 2021 +0200
@@ -281,8 +281,8 @@
         # Generate the debug server object
         logging.debug("Creating Debug Server...")
         from Debugger.DebugServer import DebugServer
-        debugServer = DebugServer(self.__originalPathString,
-                                  project=self.project, parent=self)
+        self.__debugServer = DebugServer(
+            self.__originalPathString, project=self.project, parent=self)
         
         # Create the background service object
         from Utilities.BackgroundService import BackgroundService
@@ -302,7 +302,7 @@
         self.__webBrowserSAName = QUuid.createUuid().toString()[1:-1]
         
         logging.debug("Creating Application Objects...")
-        self.__createObjects(debugServer)
+        self.__createObjects()
         
         # Create the main window now so that we can connect QActions to it.
         logging.debug("Creating Layout...")
@@ -313,7 +313,7 @@
         # Generate the debugger part of the ui
         logging.debug("Creating Debugger UI...")
         from Debugger.DebugUI import DebugUI
-        self.debuggerUI = DebugUI(self, self.viewmanager, debugServer,
+        self.debuggerUI = DebugUI(self, self.viewmanager, self.__debugServer,
                                   self.debugViewer, self.project)
         self.debugViewer.setDebugger(self.debuggerUI)
         self.shell.setDebuggerUI(self.debuggerUI)
@@ -453,11 +453,11 @@
         self.debuggerUI.executeMake.connect(self.project.executeMake)
         self.debuggerUI.appendStdout.connect(self.appendToStdout)
         
-        debugServer.clientDisassembly.connect(
+        self.__debugServer.clientDisassembly.connect(
             self.debugViewer.disassemblyViewer.showDisassembly)
-        debugServer.clientProcessStdout.connect(self.appendToStdout)
-        debugServer.clientProcessStderr.connect(self.appendToStderr)
-        debugServer.appendStdout.connect(self.appendToStdout)
+        self.__debugServer.clientProcessStdout.connect(self.appendToStdout)
+        self.__debugServer.clientProcessStderr.connect(self.appendToStderr)
+        self.__debugServer.appendStdout.connect(self.appendToStdout)
         
         self.stdout.appendStdout.connect(self.appendToStdout)
         self.stderr.appendStderr.connect(self.appendToStderr)
@@ -488,7 +488,7 @@
         self.preferencesChanged.connect(
             self.taskViewer.handlePreferencesChanged)
         self.preferencesChanged.connect(self.pluginManager.preferencesChanged)
-        self.preferencesChanged.connect(debugServer.preferencesChanged)
+        self.preferencesChanged.connect(self.__debugServer.preferencesChanged)
         self.preferencesChanged.connect(self.debugViewer.preferencesChanged)
         self.preferencesChanged.connect(
             self.backgroundService.preferencesOrProjectChanged)
@@ -521,7 +521,7 @@
             self.debuggerUI.debuggingStarted.connect(
                 self.browser.handleProgramChange)
             
-            debugServer.clientInterpreterChanged.connect(
+            self.__debugServer.clientInterpreterChanged.connect(
                 self.browser.handleInterpreterChanged)
             
             self.preferencesChanged.connect(
@@ -597,7 +597,7 @@
         splash.showMessage(self.tr("Registering Objects..."))
         ericApp().registerObject("UserInterface", self)
         ericApp().registerObject("DebugUI", self.debuggerUI)
-        ericApp().registerObject("DebugServer", debugServer)
+        ericApp().registerObject("DebugServer", self.__debugServer)
         ericApp().registerObject("BackgroundService", self.backgroundService)
         ericApp().registerObject("ViewManager", self.viewmanager)
         ericApp().registerObject("ProjectBrowser", self.projectBrowser)
@@ -728,11 +728,11 @@
         # environment
         splash.showMessage(self.tr("Starting Debugger..."))
         if Preferences.getShell("StartWithMostRecentlyUsedEnvironment"):
-            debugServer.startClient(
+            self.__debugServer.startClient(
                 False, venvName=Preferences.getShell("LastVirtualEnvironment")
             )
         else:
-            debugServer.startClient(False)
+            self.__debugServer.startClient(False)
         
         # attributes for the network objects
         self.__networkManager = QNetworkAccessManager(self)
@@ -779,18 +779,15 @@
         """
         return self.__networkManager
     
-    def __createObjects(self, debugServer):
-        """
-        Private method to create the various objects of the application.
-        
-        @param debugServer reference to the debug server object
-        @type DebugServer
+    def __createObjects(self):
+        """
+        Private method to create the various application objects.
         """
         # Create the view manager depending on the configuration setting
         logging.debug("Creating Viewmanager...")
         import ViewManager
         self.viewmanager = ViewManager.factory(
-            self, self, debugServer, self.pluginManager)
+            self, self, self.__debugServer, self.pluginManager)
         
         # Create previewer
         logging.debug("Creating Previewer...")
@@ -831,13 +828,13 @@
         # Create the debug viewer
         logging.debug("Creating Debug Viewer...")
         from Debugger.DebugViewer import DebugViewer
-        self.debugViewer = DebugViewer(debugServer)
+        self.debugViewer = DebugViewer(self.__debugServer)
         
         # Create the shell
         logging.debug("Creating Shell...")
         from QScintilla.Shell import ShellAssembly
         self.shellAssembly = ShellAssembly(
-            debugServer, self.viewmanager, self.project, True)
+            self.__debugServer, self.viewmanager, self.project, True)
         self.shell = self.shellAssembly.shell()
         
         if Preferences.getUI("ShowTemplateViewer"):
@@ -943,6 +940,11 @@
             self.pluginManager, integrated=True, parent=self)
         self.pluginRepositoryViewer.closeAndInstall.connect(
             self.__installDownloadedPlugins)
+        
+        # Create the virtual environments management widget
+        from VirtualEnv.VirtualenvManagerWidgets import VirtualenvManagerWidget
+        self.__virtualenvManagerWidget = VirtualenvManagerWidget(
+            self.virtualenvManager, self)
     
     def __createLayout(self):
         """
@@ -1067,6 +1069,9 @@
                               UI.PixmapCache.getIcon("pluginRepository"),
                               self.tr("Plugin Repository"))
         
+        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,6 +1211,11 @@
             UI.PixmapCache.getIcon("sbPluginRepository96"),
             self.tr("Plugin Repository"))
         
+        self.rightSidebar.addTab(
+            self.__virtualenvManagerWidget,
+            UI.PixmapCache.getIcon("sbVirtenvManager96"),
+            self.tr("Virtual Environments"))
+        
         if self.pipWidget:
             self.rightSidebar.addTab(
                 self.pipWidget, UI.PixmapCache.getIcon("sbPyPI96"),
@@ -2182,6 +2192,25 @@
         self.actions.append(self.pluginRepositoryViewerActivateAct)
         self.addAction(self.pluginRepositoryViewerActivateAct)
         
+        self.virtualenvManagerActivateAct = EricAction(
+            self.tr('Virtual Environments'),
+            self.tr('Virtual Environments'),
+            QKeySequence(self.tr("Ctrl+Alt+V")),
+            0, self,
+            'virtualenv_manager_activate')
+        self.virtualenvManagerActivateAct.setStatusTip(self.tr(
+            "Switch the input focus to the Virtual Environments Manager"
+            " window."))
+        self.virtualenvManagerActivateAct.setWhatsThis(self.tr(
+            """<b>Virtual Environments</b>"""
+            """<p>This switches the input focus to the Virtual Environments"""
+            """ Manager window.</p>"""
+        ))
+        self.virtualenvManagerActivateAct.triggered.connect(
+            self.activateVirtualenvManager)
+        self.actions.append(self.virtualenvManagerActivateAct)
+        self.addAction(self.virtualenvManagerActivateAct)
+        
         self.whatsThisAct = EricAction(
             self.tr('What\'s This?'),
             UI.PixmapCache.getIcon("whatsThis"),
@@ -2873,41 +2902,6 @@
         self.pluginRepoAct.triggered.connect(self.__showPluginsAvailable)
         self.actions.append(self.pluginRepoAct)
         
-        self.virtualenvManagerAct = EricAction(
-            self.tr('Virtualenv Manager'),
-            UI.PixmapCache.getIcon("virtualenv"),
-            self.tr('&Virtualenv Manager...'),
-            0, 0, self,
-            'virtualenv_manager')
-        self.virtualenvManagerAct.setStatusTip(self.tr(
-            'Virtualenv Manager'))
-        self.virtualenvManagerAct.setWhatsThis(self.tr(
-            """<b>Virtualenv Manager</b>"""
-            """<p>This opens a dialog to manage the defined Python virtual"""
-            """ environments.</p>"""
-        ))
-        self.virtualenvManagerAct.triggered.connect(
-            self.virtualenvManager.showVirtualenvManagerDialog)
-        self.actions.append(self.virtualenvManagerAct)
-        
-        self.virtualenvConfigAct = EricAction(
-            self.tr('Virtualenv Configurator'),
-            UI.PixmapCache.getIcon("virtualenvConfig"),
-            self.tr('Virtualenv &Configurator...'),
-            0, 0, self,
-            'virtualenv_configurator')
-        self.virtualenvConfigAct.setStatusTip(self.tr(
-            'Virtualenv Configurator'))
-        self.virtualenvConfigAct.setWhatsThis(self.tr(
-            """<b>Virtualenv Configurator</b>"""
-            """<p>This opens a dialog for entering all the parameters"""
-            """ needed to create a Python virtual environment using"""
-            """ virtualenv or pyvenv.</p>"""
-        ))
-        self.virtualenvConfigAct.triggered.connect(
-            self.virtualenvManager.createVirtualEnv)
-        self.actions.append(self.virtualenvConfigAct)
-        
         # initialize viewmanager actions
         self.viewmanager.initActions()
         
@@ -3190,14 +3184,6 @@
         self.__menus["extras"].addSeparator()
         
         ##############################################################
-        ## Extras/VirtualEnv Manager menu entries
-        ##############################################################
-        
-        self.__menus["extras"].addAction(self.virtualenvManagerAct)
-        self.__menus["extras"].addAction(self.virtualenvConfigAct)
-        self.__menus["extras"].addSeparator()
-        
-        ##############################################################
         ## Extras/Plugins menu
         ##############################################################
         
@@ -3327,6 +3313,7 @@
         self.__menus["subwindow"].addAction(self.debugViewerActivateAct)
         self.__menus["subwindow"].addAction(
             self.pluginRepositoryViewerActivateAct)
+        self.__menus["subwindow"].addAction(self.virtualenvManagerActivateAct)
         if self.pipWidget is not None:
             self.__menus["subwindow"].addAction(self.pipWidgetActivateAct)
         if self.condaWidget is not None:
@@ -3474,9 +3461,6 @@
         toolstb.addAction(self.hexEditorAct)
         toolstb.addAction(self.iconEditorAct)
         toolstb.addAction(self.snapshotAct)
-        toolstb.addSeparator()
-        toolstb.addAction(self.virtualenvManagerAct)
-        toolstb.addAction(self.virtualenvConfigAct)
         if self.webBrowserAct:
             toolstb.addSeparator()
             toolstb.addAction(self.webBrowserAct)
@@ -5016,7 +5000,7 @@
         if self.unittestDialog is None:
             from PyUnit.UnittestDialog import UnittestDialog
             self.unittestDialog = UnittestDialog(
-                None, self.debuggerUI.debugServer, self)
+                None, self.__debugServer, self)
             self.unittestDialog.unittestFile.connect(
                 self.viewmanager.setFileLine)
             self.unittestDialog.unittestStopped.connect(self.__unittestStopped)
@@ -6507,7 +6491,7 @@
         """
         from Debugger.DebugClientCapabilities import HasUnittest
         self.__setWindowCaption(project=self.project.name)
-        cap = ericApp().getObject("DebugServer").getClientCapabilities(
+        cap = self.__debugServer.getClientCapabilities(
             self.project.getProjectLanguage())
         self.utProjectAct.setEnabled(cap & HasUnittest)
         self.utProjectOpen = cap & HasUnittest
@@ -6559,7 +6543,7 @@
             len(self.__menus["wizards"].actions()) > 0)
         
         if fn and str(fn) != "None":
-            dbs = ericApp().getObject("DebugServer")
+            dbs = self.__debugServer
             for language in dbs.getSupportedLanguages():
                 exts = dbs.getExtensions(language)
                 if fn.endswith(exts):
@@ -6582,7 +6566,7 @@
         fn = editor.getFileName() if editor else None
         
         if fn:
-            dbs = ericApp().getObject("DebugServer")
+            dbs = self.__debugServer
             for language in dbs.getSupportedLanguages():
                 exts = dbs.getExtensions(language)
                 if fn.endswith(exts):
@@ -7106,8 +7090,6 @@
         
         self.pluginManager.doShutdown()
         
-        self.virtualenvManager.shutdown()
-        
         if self.SAServer is not None:
             self.SAServer.shutdown()
             self.SAServer = None
@@ -7702,3 +7684,21 @@
                 # We did not get permission to interact, play it safe and
                 # save all data.
                 self.viewmanager.saveAllEditors()
+    
+    ############################################################
+    ## Interface to the virtual environment manager widget below
+    ############################################################
+    
+    @pyqtSlot()
+    def activateVirtualenvManager(self):
+        """
+        Public slot to activate the virtual environments manager widget.
+        """
+        if self.__layoutType == "Toolboxes":
+            self.rToolboxDock.show()
+            self.rToolbox.setCurrentWidget(self.__virtualenvManagerWidget)
+        elif self.__layoutType == "Sidebars":
+            self.rightSidebar.show()
+            self.rightSidebar.setCurrentWidget(self.__virtualenvManagerWidget)
+        self.__virtualenvManagerWidget.setFocus(
+            Qt.FocusReason.ActiveWindowFocusReason)

eric ide

mercurial