ProjectDjango/ConfigurationPage/DjangoPage.py

branch
eric7
changeset 172
ea7980ded4f3
parent 169
b8f263e05c39
child 175
30cb5e553e7e
diff -r af99f0984f20 -r ea7980ded4f3 ProjectDjango/ConfigurationPage/DjangoPage.py
--- a/ProjectDjango/ConfigurationPage/DjangoPage.py	Sat May 29 15:03:26 2021 +0200
+++ b/ProjectDjango/ConfigurationPage/DjangoPage.py	Sat May 29 18:33:03 2021 +0200
@@ -7,11 +7,8 @@
 Module implementing the Django configuration page.
 """
 
-from PyQt5.QtCore import pyqtSlot
-
-from E5Gui import E5FileDialog
-from E5Gui.E5Completers import E5DirCompleter, E5FileCompleter
-from E5Gui.E5Application import e5App
+from EricWidgets.EricApplication import ericApp
+from EricWidgets.EricPathPicker import EricPathPickerModes
 
 from Preferences.ConfigurationPages.ConfigurationPageBase import (
     ConfigurationPageBase
@@ -20,9 +17,6 @@
 
 from Globals import isWindowsPlatform, isMacPlatform
 
-import Utilities
-import UI.PixmapCache
-
 
 class DjangoPage(ConfigurationPageBase, Ui_DjangoPage):
     """
@@ -38,11 +32,8 @@
         self.setupUi(self)
         self.setObjectName("DjangoPage")
         
-        self.virtualEnvPy3Button.setIcon(UI.PixmapCache.getIcon("open"))
-        self.translationsButton.setIcon(UI.PixmapCache.getIcon("open"))
-        
-        self.__virtualEnvPy3Completer = E5DirCompleter(self.virtualEnvPy3Edit)
-        self.__translationsCompleter = E5FileCompleter(self.translationsEdit)
+        self.translationsPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
+        self.translationsPicker.setFilters(self.tr("All Files (*)"))
         
         self.__plugin = plugin
         
@@ -54,7 +45,7 @@
             consoleList.append("/opt/X11/bin/xterm -e")
         else:
             consoleList.append("@konsole --workdir . -e")
-            # KDE4/5 konsole spawns
+            # KDE 5 konsole spawns
             consoleList.append("gnome-terminal -e")
             consoleList.append("mate-terminal -e")
             consoleList.append("xfce4-terminal -e")
@@ -68,7 +59,7 @@
             consoleNoCloseList.append("/opt/X11/bin/xterm -hold -e")
         else:
             consoleNoCloseList.append("@konsole --noclose --workdir . -e")
-            # KDE4/5 konsole spawns
+            # KDE 5 konsole spawns
             consoleNoCloseList.append("gnome-terminal --profile=<noclose> -e")
             consoleNoCloseList.append("mate-terminal --profile=<noclose> -e")
             consoleNoCloseList.append("xfce4-terminal --hold -e")
@@ -81,21 +72,10 @@
         self.py3ShellCombo.addItem(self.tr("IPython"), "ipython")
         self.py3ShellCombo.addItem(self.tr("bpython"), "bpython")
         
-        try:
-            venvManager = e5App().getObject("VirtualEnvManager")
-            
-            self.py3VenvNameComboBox.addItems(
-                [""] + sorted(venvManager.getVirtualenvNames()))
-            
-            self.djangoVirtualEnvPy3Group.hide()
-            
-            self.__hasVirtualEnvironmentManager = True
-        except KeyError:
-            venvManager = None
-            
-            self.djangoVirtualEnvironmentPy3Group.hide()
-            
-            self.__hasVirtualEnvironmentManager = False
+        venvManager = ericApp().getObject("VirtualEnvManager")
+        
+        self.py3VenvNameComboBox.addItems(
+            [""] + sorted(venvManager.getVirtualenvNames()))
         
         # set initial values
         self.consoleCommandCombo.setEditText(
@@ -116,21 +96,18 @@
         self.appsRecentSpinBox.setValue(
             self.__plugin.getPreferences("RecentNumberApps"))
         
-        if venvManager:
-            venvName = self.__plugin.getPreferences(
-                "VirtualEnvironmentNamePy3")
-            if venvName:
-                index = self.py3VenvNameComboBox.findText(venvName)
-                if index < 0:
-                    index = 0
-                self.py3VenvNameComboBox.setCurrentIndex(index)
-        else:
-            self.virtualEnvPy3Edit.setText(
-                self.__plugin.getPreferences("VirtualEnvironmentPy3"))
+        venvName = self.__plugin.getPreferences(
+            "VirtualEnvironmentNamePy3")
+        if venvName:
+            index = self.py3VenvNameComboBox.findText(venvName)
+            if index < 0:
+                index = 0
+            self.py3VenvNameComboBox.setCurrentIndex(index)
+        
         self.py3ShellCombo.setCurrentIndex(self.py3ShellCombo.findData(
             self.__plugin.getPreferences("Python3ConsoleType")))
         
-        self.translationsEdit.setText(
+        self.translationsPicker.setText(
             self.__plugin.getPreferences("TranslationsEditor"))
         self.fuzzyTranslationsCheckBox.setChecked(
             self.__plugin.getPreferences("FuzzyTranslations"))
@@ -159,51 +136,14 @@
         self.__plugin.setPreferences(
             "RecentNumberApps", self.appsRecentSpinBox.value())
         
-        if self.__hasVirtualEnvironmentManager:
-            self.__plugin.setPreferences(
-                "VirtualEnvironmentNamePy3",
-                self.py3VenvNameComboBox.currentText())
-        else:
-            self.__plugin.setPreferences(
-                "VirtualEnvironmentPy3", self.virtualEnvPy3Edit.text())
+        self.__plugin.setPreferences(
+            "VirtualEnvironmentNamePy3",
+            self.py3VenvNameComboBox.currentText())
         self.__plugin.setPreferences(
             "Python3ConsoleType",
             self.py3ShellCombo.itemData(self.py3ShellCombo.currentIndex()))
         
         self.__plugin.setPreferences(
-            "TranslationsEditor", self.translationsEdit.text())
+            "TranslationsEditor", self.translationsPicker.text())
         self.__plugin.setPreferences(
             "FuzzyTranslations", self.fuzzyTranslationsCheckBox.isChecked())
-    
-    @pyqtSlot()
-    def on_virtualEnvPy3Button_clicked(self):
-        """
-        Private slot to select the virtual environment for Python 3 via a
-        directory selection dialog.
-        """
-        vDir = self.virtualEnvPy3Edit.text()
-        if not vDir:
-            vDir = Utilities.getHomeDir()
-        virtualEnv = E5FileDialog.getExistingDirectory(
-            self,
-            self.tr("Select Virtual Environment for Python 3"),
-            vDir,
-            E5FileDialog.Options(E5FileDialog.Option(0)))
-        
-        if virtualEnv:
-            self.virtualEnvPy3Edit.setText(
-                Utilities.toNativeSeparators(virtualEnv))
-    
-    @pyqtSlot()
-    def on_translationsButton_clicked(self):
-        """
-        Private slot to select the translations editor via a file selection
-        dialog.
-        """
-        editor = E5FileDialog.getOpenFileName(
-            self,
-            self.tr("Translations Editor"),
-            self.translationsEdit.text(),
-            self.tr("All Files (*)"))
-        if editor:
-            self.translationsEdit.setText(Utilities.toNativeSeparators(editor))

eric ide

mercurial