VirtualEnv/VirtualenvAddEditDialog.py

changeset 6341
a00e63f6d766
parent 6338
104ee21d765d
child 6349
17b3c75913de
--- a/VirtualEnv/VirtualenvAddEditDialog.py	Sun Jun 10 17:21:43 2018 +0200
+++ b/VirtualEnv/VirtualenvAddEditDialog.py	Tue Jun 12 18:59:45 2018 +0200
@@ -63,6 +63,8 @@
         self.nameEdit.setText(venvName)
         self.targetDirectoryPicker.setText(venvDirectory)
         self.pythonExecPicker.setText(venvInterpreter)
+        self.globalCheckBox.setChecked(self.__editMode and
+                                       not bool(venvDirectory))
         
         self.__updateOk()
     
@@ -81,11 +83,16 @@
                 bool(self.nameEdit.text()) and
                 self.__manager.isUnique(self.nameEdit.text())
             )
-            
+        
+        if not self.globalCheckBox.isChecked():
+            enable = (
+                enable and
+                bool(self.targetDirectoryPicker.text()) and
+                os.path.exists(self.targetDirectoryPicker.text())
+            )
+        
         enable = (
             enable and
-            bool(self.targetDirectoryPicker.text()) and
-            os.path.exists(self.targetDirectoryPicker.text()) and
             bool(self.pythonExecPicker.text()) and
             os.access(self.pythonExecPicker.text(), os.X_OK)
         )
@@ -128,6 +135,18 @@
         """
         self.__updateOk()
     
+    @pyqtSlot(bool)
+    def on_globalCheckBox_toggled(self, checked):
+        """
+        Private slot handling a change of the global check box state.
+        
+        @param checked state of the check box
+        @type bool
+        """
+        self.targetDirectoryPicker.setEnabled(not checked)
+        
+        self.__updateOk()
+    
     def getData(self):
         """
         Public method to retrieve the entered data.
@@ -136,8 +155,15 @@
             interpreter of the virtual environment
         @rtype tuple of (str, str, str)
         """
-        return (
-            self.nameEdit.text(),
-            self.targetDirectoryPicker.text(),
-            self.pythonExecPicker.text(),
-        )
+        if self.globalCheckBox.isChecked():
+            return (
+                self.nameEdit.text(),
+                "",
+                self.pythonExecPicker.text(),
+            )
+        else:
+            return (
+                self.nameEdit.text(),
+                self.targetDirectoryPicker.text(),
+                self.pythonExecPicker.text(),
+            )

eric ide

mercurial