5 |
5 |
6 """ |
6 """ |
7 Module implementing the Pyramid configuration page. |
7 Module implementing the Pyramid configuration page. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt5.QtCore import pyqtSlot |
10 from PyQt6.QtCore import pyqtSlot |
11 |
11 |
12 from E5Gui.E5Completers import E5DirCompleter |
12 from EricWidgets.EricApplication import ericApp |
13 from E5Gui import E5FileDialog |
13 from EricWidgets.EricPathPicker import EricPathPickerModes |
14 from E5Gui.E5Application import e5App |
|
15 |
14 |
16 from Preferences.ConfigurationPages.ConfigurationPageBase import ( |
15 from Preferences.ConfigurationPages.ConfigurationPageBase import ( |
17 ConfigurationPageBase |
16 ConfigurationPageBase |
18 ) |
17 ) |
19 from .Ui_PyramidPage import Ui_PyramidPage |
18 from .Ui_PyramidPage import Ui_PyramidPage |
20 |
19 |
21 import Utilities |
|
22 import UI.PixmapCache |
20 import UI.PixmapCache |
23 |
21 |
24 from Globals import isWindowsPlatform, isMacPlatform |
22 from Globals import isWindowsPlatform, isMacPlatform |
25 |
23 |
26 |
24 |
46 elif isMacPlatform(): |
45 elif isMacPlatform(): |
47 consoleList.append("xterm -e") |
46 consoleList.append("xterm -e") |
48 consoleList.append("/opt/X11/bin/xterm -e") |
47 consoleList.append("/opt/X11/bin/xterm -e") |
49 else: |
48 else: |
50 consoleList.append("@konsole --workdir . -e") |
49 consoleList.append("@konsole --workdir . -e") |
51 # KDE4/5 konsole spawns |
50 # KDE 5 konsole spawns |
52 consoleList.append("gnome-terminal -e") |
51 consoleList.append("gnome-terminal -e") |
53 consoleList.append("mate-terminal -e") |
52 consoleList.append("mate-terminal -e") |
54 consoleList.append("xfce4-terminal -e") |
53 consoleList.append("xfce4-terminal -e") |
55 consoleList.append("xterm -e") |
54 consoleList.append("xterm -e") |
56 self.consoleCommandCombo.addItems(consoleList) |
55 self.consoleCommandCombo.addItems(consoleList) |
57 |
56 |
58 self.virtualEnvPy3Button.setIcon(UI.PixmapCache.getIcon("open")) |
|
59 self.translationsButton.setIcon(UI.PixmapCache.getIcon("open")) |
|
60 self.urlResetButton.setIcon(UI.PixmapCache.getIcon("editUndo")) |
57 self.urlResetButton.setIcon(UI.PixmapCache.getIcon("editUndo")) |
61 |
|
62 self.virtualEnvPy3Completer = E5DirCompleter(self.virtualEnvPy3Edit) |
|
63 |
58 |
64 self.py3ShellCombo.addItem(self.tr("Plain Python"), "python") |
59 self.py3ShellCombo.addItem(self.tr("Plain Python"), "python") |
65 self.py3ShellCombo.addItem(self.tr("IPython"), "ipython") |
60 self.py3ShellCombo.addItem(self.tr("IPython"), "ipython") |
66 self.py3ShellCombo.addItem(self.tr("bpython"), "bpython") |
61 self.py3ShellCombo.addItem(self.tr("bpython"), "bpython") |
67 |
62 |
68 venvManager = e5App().getObject("VirtualEnvManager") |
63 venvManager = ericApp().getObject("VirtualEnvManager") |
69 |
64 |
70 self.py3VenvNameComboBox.addItems( |
65 self.py3VenvNameComboBox.addItems( |
71 [""] + sorted(venvManager.getVirtualenvNames())) |
66 [""] + sorted(venvManager.getVirtualenvNames())) |
72 self.pyramidVirtualEnvPy3Group.hide() |
67 |
|
68 self.translationsEditorPicker.setMode( |
|
69 EricPathPickerModes.OPEN_FILE_MODE) |
|
70 self.translationsEditorPicker.setFilters(self.tr("All Files (*)")) |
73 |
71 |
74 # set initial values |
72 # set initial values |
75 self.consoleCommandCombo.setEditText( |
73 self.consoleCommandCombo.setEditText( |
76 self.__plugin.getPreferences("ConsoleCommand")) |
74 self.__plugin.getPreferences("ConsoleCommand")) |
77 |
75 |
89 self.__plugin.getPreferences("Python3ConsoleType"))) |
87 self.__plugin.getPreferences("Python3ConsoleType"))) |
90 |
88 |
91 self.urlEdit.setText( |
89 self.urlEdit.setText( |
92 self.__plugin.getPreferences("PyramidDocUrl")) |
90 self.__plugin.getPreferences("PyramidDocUrl")) |
93 |
91 |
94 self.translationsEdit.setText( |
92 self.translationsEditorPicker.setText( |
95 self.__plugin.getPreferences("TranslationsEditor")) |
93 self.__plugin.getPreferences("TranslationsEditor")) |
96 |
94 |
97 def save(self): |
95 def save(self): |
98 """ |
96 """ |
99 Public slot to save the Pyramid configuration. |
97 Public slot to save the Pyramid configuration. |
113 |
111 |
114 self.__plugin.setPreferences( |
112 self.__plugin.setPreferences( |
115 "PyramidDocUrl", self.urlEdit.text()) |
113 "PyramidDocUrl", self.urlEdit.text()) |
116 |
114 |
117 self.__plugin.setPreferences( |
115 self.__plugin.setPreferences( |
118 "TranslationsEditor", self.translationsEdit.text()) |
116 "TranslationsEditor", self.translationsEditorPicker.text()) |
119 |
|
120 @pyqtSlot() |
|
121 def on_virtualEnvPy3Button_clicked(self): |
|
122 """ |
|
123 Private slot to select the virtual environment for Python 3 via a |
|
124 directory selection dialog. |
|
125 """ |
|
126 vDir = self.virtualEnvPy3Edit.text() |
|
127 if not vDir: |
|
128 vDir = Utilities.getHomeDir() |
|
129 virtualEnv = E5FileDialog.getExistingDirectory( |
|
130 self, |
|
131 self.tr("Select Virtual Environment for Python 3"), |
|
132 vDir, |
|
133 E5FileDialog.Options(E5FileDialog.Option(0))) |
|
134 |
|
135 if virtualEnv: |
|
136 self.virtualEnvPy3Edit.setText(Utilities.toNativeSeparators( |
|
137 virtualEnv)) |
|
138 |
|
139 @pyqtSlot() |
|
140 def on_translationsButton_clicked(self): |
|
141 """ |
|
142 Private slot to select the translations editor via a file selection |
|
143 dialog. |
|
144 """ |
|
145 editor = E5FileDialog.getOpenFileName( |
|
146 self, |
|
147 self.tr("Translations Editor"), |
|
148 self.translationsEdit.text(), |
|
149 self.tr("All Files (*)")) |
|
150 if editor: |
|
151 self.translationsEdit.setText(Utilities.toNativeSeparators(editor)) |
|
152 |
117 |
153 @pyqtSlot() |
118 @pyqtSlot() |
154 def on_urlResetButton_clicked(self): |
119 def on_urlResetButton_clicked(self): |
155 """ |
120 """ |
156 Private slot to reset the Pyramid documentation URL. |
121 Private slot to reset the Pyramid documentation URL. |