Thu, 30 Dec 2021 11:20:00 +0100
Updated copyright for 2022.
# -*- coding: utf-8 -*- # Copyright (c) 2013 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing the Django configuration page. """ from EricWidgets.EricApplication import ericApp from EricWidgets.EricPathPicker import EricPathPickerModes from Preferences.ConfigurationPages.ConfigurationPageBase import ( ConfigurationPageBase ) from .Ui_DjangoPage import Ui_DjangoPage from Globals import isWindowsPlatform, isMacPlatform class DjangoPage(ConfigurationPageBase, Ui_DjangoPage): """ Class implementing the Django configuration page. """ def __init__(self, plugin): """ Constructor @param plugin reference to the plugin object """ super().__init__() self.setupUi(self) self.setObjectName("DjangoPage") self.translationsPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) self.translationsPicker.setFilters(self.tr("All Files (*)")) self.__plugin = plugin consoleList = [] if isWindowsPlatform(): consoleList.append("cmd.exe /c") elif isMacPlatform(): consoleList.append("xterm -e") consoleList.append("/opt/X11/bin/xterm -e") else: consoleList.append("@konsole --workdir . -e") # KDE 5 konsole spawns consoleList.append("gnome-terminal -e") consoleList.append("mate-terminal -e") consoleList.append("xfce4-terminal -e") consoleList.append("xterm -e") consoleNoCloseList = [] if isWindowsPlatform(): consoleNoCloseList.append("cmd.exe /k") elif isMacPlatform(): consoleNoCloseList.append("xterm -hold -e") consoleNoCloseList.append("/opt/X11/bin/xterm -hold -e") else: consoleNoCloseList.append("@konsole --noclose --workdir . -e") # KDE 5 konsole spawns consoleNoCloseList.append("gnome-terminal --profile=<noclose> -e") consoleNoCloseList.append("mate-terminal --profile=<noclose> -e") consoleNoCloseList.append("xfce4-terminal --hold -e") consoleNoCloseList.append("xterm -hold -e") self.consoleCommandCombo.addItems(consoleList) self.consoleCommandNoCloseCombo.addItems(consoleNoCloseList) self.py3ShellCombo.addItem(self.tr("Plain Python"), "python") self.py3ShellCombo.addItem(self.tr("IPython"), "ipython") self.py3ShellCombo.addItem(self.tr("bpython"), "bpython") venvManager = ericApp().getObject("VirtualEnvManager") self.py3VenvNameComboBox.addItems( [""] + sorted(venvManager.getVirtualenvNames())) # set initial values self.consoleCommandCombo.setEditText( self.__plugin.getPreferences("ConsoleCommand")) self.consoleCommandNoCloseCombo.setEditText( self.__plugin.getPreferences("ConsoleCommandNoClose")) self.serverAddressEdit.setText( self.__plugin.getPreferences("ServerAddress")) self.ipv6CheckBox.setChecked( self.__plugin.getPreferences("UseIPv6")) self.threadingCheckBox.setChecked( self.__plugin.getPreferences("UseThreading")) self.externalBrowserCheckBox.setChecked( self.__plugin.getPreferences("UseExternalBrowser")) self.appsRecentSpinBox.setValue( self.__plugin.getPreferences("RecentNumberApps")) 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.translationsPicker.setText( self.__plugin.getPreferences("TranslationsEditor")) self.fuzzyTranslationsCheckBox.setChecked( self.__plugin.getPreferences("FuzzyTranslations")) def save(self): """ Public slot to save the Django configuration. """ self.__plugin.setPreferences( "ConsoleCommand", self.consoleCommandCombo.currentText()) self.__plugin.setPreferences( "ConsoleCommandNoClose", self.consoleCommandNoCloseCombo.currentText()) self.__plugin.setPreferences( "ServerAddress", self.serverAddressEdit.text()) self.__plugin.setPreferences( "UseIPv6", self.ipv6CheckBox.isChecked()) self.__plugin.setPreferences( "UseThreading", self.threadingCheckBox.isChecked()) self.__plugin.setPreferences( "UseExternalBrowser", self.externalBrowserCheckBox.isChecked()) self.__plugin.setPreferences( "RecentNumberApps", self.appsRecentSpinBox.value()) self.__plugin.setPreferences( "VirtualEnvironmentNamePy3", self.py3VenvNameComboBox.currentText()) self.__plugin.setPreferences( "Python3ConsoleType", self.py3ShellCombo.itemData(self.py3ShellCombo.currentIndex())) self.__plugin.setPreferences( "TranslationsEditor", self.translationsPicker.text()) self.__plugin.setPreferences( "FuzzyTranslations", self.fuzzyTranslationsCheckBox.isChecked())