13 |
13 |
14 from E5Gui import E5FileDialog |
14 from E5Gui import E5FileDialog |
15 from E5Gui.E5Completers import E5DirCompleter, E5FileCompleter |
15 from E5Gui.E5Completers import E5DirCompleter, E5FileCompleter |
16 from E5Gui.E5Application import e5App |
16 from E5Gui.E5Application import e5App |
17 |
17 |
18 from Preferences.ConfigurationPages.ConfigurationPageBase import \ |
18 from Preferences.ConfigurationPages.ConfigurationPageBase import ( |
19 ConfigurationPageBase |
19 ConfigurationPageBase |
|
20 ) |
20 from .Ui_DjangoPage import Ui_DjangoPage |
21 from .Ui_DjangoPage import Ui_DjangoPage |
21 |
22 |
22 from Globals import isWindowsPlatform, isMacPlatform |
23 from Globals import isWindowsPlatform, isMacPlatform |
23 |
24 |
24 import Utilities |
25 import Utilities |
38 super(DjangoPage, self).__init__() |
39 super(DjangoPage, self).__init__() |
39 self.setupUi(self) |
40 self.setupUi(self) |
40 self.setObjectName("DjangoPage") |
41 self.setObjectName("DjangoPage") |
41 |
42 |
42 self.virtualEnvPy3Button.setIcon(UI.PixmapCache.getIcon("open")) |
43 self.virtualEnvPy3Button.setIcon(UI.PixmapCache.getIcon("open")) |
43 self.virtualEnvPy2Button.setIcon(UI.PixmapCache.getIcon("open")) |
|
44 self.translationsButton.setIcon(UI.PixmapCache.getIcon("open")) |
44 self.translationsButton.setIcon(UI.PixmapCache.getIcon("open")) |
45 |
45 |
46 self.__virtualEnvPy3Completer = E5DirCompleter(self.virtualEnvPy3Edit) |
46 self.__virtualEnvPy3Completer = E5DirCompleter(self.virtualEnvPy3Edit) |
47 self.__virtualEnvPy2Completer = E5DirCompleter(self.virtualEnvPy2Edit) |
|
48 self.__translationsCompleter = E5FileCompleter(self.translationsEdit) |
47 self.__translationsCompleter = E5FileCompleter(self.translationsEdit) |
49 |
48 |
50 self.__plugin = plugin |
49 self.__plugin = plugin |
51 |
50 |
52 consoleList = [] |
51 consoleList = [] |
78 consoleNoCloseList.append("xterm -hold -e") |
77 consoleNoCloseList.append("xterm -hold -e") |
79 |
78 |
80 self.consoleCommandCombo.addItems(consoleList) |
79 self.consoleCommandCombo.addItems(consoleList) |
81 self.consoleCommandNoCloseCombo.addItems(consoleNoCloseList) |
80 self.consoleCommandNoCloseCombo.addItems(consoleNoCloseList) |
82 |
81 |
83 self.py2ShellCombo.addItem(self.tr("Plain Python"), "python") |
|
84 self.py2ShellCombo.addItem(self.tr("IPython"), "ipython") |
|
85 self.py2ShellCombo.addItem(self.tr("bpython"), "bpython") |
|
86 |
|
87 self.py3ShellCombo.addItem(self.tr("Plain Python"), "python") |
82 self.py3ShellCombo.addItem(self.tr("Plain Python"), "python") |
88 self.py3ShellCombo.addItem(self.tr("IPython"), "ipython") |
83 self.py3ShellCombo.addItem(self.tr("IPython"), "ipython") |
89 self.py3ShellCombo.addItem(self.tr("bpython"), "bpython") |
84 self.py3ShellCombo.addItem(self.tr("bpython"), "bpython") |
90 |
85 |
91 try: |
86 try: |
92 venvManager = e5App().getObject("VirtualEnvManager") |
87 venvManager = e5App().getObject("VirtualEnvManager") |
93 |
88 |
94 self.py2VenvNameComboBox.addItems( |
|
95 [""] + sorted(venvManager.getVirtualenvNamesForVariant(2))) |
|
96 self.py3VenvNameComboBox.addItems( |
89 self.py3VenvNameComboBox.addItems( |
97 [""] + sorted(venvManager.getVirtualenvNamesForVariant(3))) |
90 [""] + sorted(venvManager.getVirtualenvNamesForVariant(3))) |
98 |
91 |
99 self.djangoVirtualEnvPy2Group.hide() |
|
100 self.djangoVirtualEnvPy3Group.hide() |
92 self.djangoVirtualEnvPy3Group.hide() |
101 |
93 |
102 self.__hasVirtualEnvironmentManager = True |
94 self.__hasVirtualEnvironmentManager = True |
103 except KeyError: |
95 except KeyError: |
104 venvManager = None |
96 venvManager = None |
105 |
97 |
106 self.djangoVirtualEnvironmentPy2Group.hide() |
|
107 self.djangoVirtualEnvironmentPy3Group.hide() |
98 self.djangoVirtualEnvironmentPy3Group.hide() |
108 |
99 |
109 self.__hasVirtualEnvironmentManager = False |
100 self.__hasVirtualEnvironmentManager = False |
110 |
101 |
111 # set initial values |
102 # set initial values |
124 self.externalBrowserCheckBox.setChecked( |
115 self.externalBrowserCheckBox.setChecked( |
125 self.__plugin.getPreferences("UseExternalBrowser")) |
116 self.__plugin.getPreferences("UseExternalBrowser")) |
126 |
117 |
127 self.appsRecentSpinBox.setValue( |
118 self.appsRecentSpinBox.setValue( |
128 self.__plugin.getPreferences("RecentNumberApps")) |
119 self.__plugin.getPreferences("RecentNumberApps")) |
129 |
|
130 if venvManager: |
|
131 venvName = self.__plugin.getPreferences( |
|
132 "VirtualEnvironmentNamePy2") |
|
133 if venvName: |
|
134 index = self.py2VenvNameComboBox.findText(venvName) |
|
135 if index < 0: |
|
136 index = 0 |
|
137 self.py2VenvNameComboBox.setCurrentIndex(index) |
|
138 else: |
|
139 self.virtualEnvPy2Edit.setText( |
|
140 self.__plugin.getPreferences("VirtualEnvironmentPy2")) |
|
141 self.py2ShellCombo.setCurrentIndex(self.py2ShellCombo.findData( |
|
142 self.__plugin.getPreferences("Python2ConsoleType"))) |
|
143 |
120 |
144 if venvManager: |
121 if venvManager: |
145 venvName = self.__plugin.getPreferences( |
122 venvName = self.__plugin.getPreferences( |
146 "VirtualEnvironmentNamePy3") |
123 "VirtualEnvironmentNamePy3") |
147 if venvName: |
124 if venvName: |
184 self.__plugin.setPreferences( |
161 self.__plugin.setPreferences( |
185 "RecentNumberApps", self.appsRecentSpinBox.value()) |
162 "RecentNumberApps", self.appsRecentSpinBox.value()) |
186 |
163 |
187 if self.__hasVirtualEnvironmentManager: |
164 if self.__hasVirtualEnvironmentManager: |
188 self.__plugin.setPreferences( |
165 self.__plugin.setPreferences( |
189 "VirtualEnvironmentNamePy2", |
|
190 self.py2VenvNameComboBox.currentText()) |
|
191 else: |
|
192 self.__plugin.setPreferences( |
|
193 "VirtualEnvironmentPy2", self.virtualEnvPy2Edit.text()) |
|
194 self.__plugin.setPreferences( |
|
195 "Python2ConsoleType", |
|
196 self.py2ShellCombo.itemData(self.py2ShellCombo.currentIndex())) |
|
197 |
|
198 if self.__hasVirtualEnvironmentManager: |
|
199 self.__plugin.setPreferences( |
|
200 "VirtualEnvironmentNamePy3", |
166 "VirtualEnvironmentNamePy3", |
201 self.py3VenvNameComboBox.currentText()) |
167 self.py3VenvNameComboBox.currentText()) |
202 else: |
168 else: |
203 self.__plugin.setPreferences( |
169 self.__plugin.setPreferences( |
204 "VirtualEnvironmentPy3", self.virtualEnvPy3Edit.text()) |
170 "VirtualEnvironmentPy3", self.virtualEnvPy3Edit.text()) |
229 if virtualEnv: |
195 if virtualEnv: |
230 self.virtualEnvPy3Edit.setText( |
196 self.virtualEnvPy3Edit.setText( |
231 Utilities.toNativeSeparators(virtualEnv)) |
197 Utilities.toNativeSeparators(virtualEnv)) |
232 |
198 |
233 @pyqtSlot() |
199 @pyqtSlot() |
234 def on_virtualEnvPy2Button_clicked(self): |
|
235 """ |
|
236 Private slot to select the virtual environment for Python 2 via a |
|
237 directory selection dialog. |
|
238 """ |
|
239 vDir = self.virtualEnvPy2Edit.text() |
|
240 if not vDir: |
|
241 vDir = Utilities.getHomeDir() |
|
242 virtualEnv = E5FileDialog.getExistingDirectory( |
|
243 self, |
|
244 self.tr("Select Virtual Environment for Python 2"), |
|
245 vDir, |
|
246 E5FileDialog.Options(E5FileDialog.Option(0))) |
|
247 |
|
248 if virtualEnv: |
|
249 self.virtualEnvPy2Edit.setText( |
|
250 Utilities.toNativeSeparators(virtualEnv)) |
|
251 |
|
252 @pyqtSlot() |
|
253 def on_translationsButton_clicked(self): |
200 def on_translationsButton_clicked(self): |
254 """ |
201 """ |
255 Private slot to select the translations editor via a file selection |
202 Private slot to select the translations editor via a file selection |
256 dialog. |
203 dialog. |
257 """ |
204 """ |