eric6/Preferences/ConfigurationPages/QtPage.py

branch
maintenance
changeset 8043
0acf98cd089a
parent 7924
8a96736d465e
parent 7923
91e843545d9a
child 8273
698ae46f40a4
equal deleted inserted replaced
7991:866adc8c315b 8043:0acf98cd089a
7 Module implementing the Qt configuration page. 7 Module implementing the Qt configuration page.
8 """ 8 """
9 9
10 from PyQt5.QtCore import pyqtSlot 10 from PyQt5.QtCore import pyqtSlot
11 11
12 from E5Gui.E5Application import e5App
12 from E5Gui.E5PathPicker import E5PathPickerModes 13 from E5Gui.E5PathPicker import E5PathPickerModes
13 14
14 from .ConfigurationPageBase import ConfigurationPageBase 15 from .ConfigurationPageBase import ConfigurationPageBase
15 from .Ui_QtPage import Ui_QtPage 16 from .Ui_QtPage import Ui_QtPage
16 17
17 import Preferences 18 import Preferences
18 import Utilities 19 import UI.PixmapCache
19 20
20 21
21 class QtPage(ConfigurationPageBase, Ui_QtPage): 22 class QtPage(ConfigurationPageBase, Ui_QtPage):
22 """ 23 """
23 Class implementing the Qt configuration page. 24 Class implementing the Qt configuration page.
28 """ 29 """
29 super(QtPage, self).__init__() 30 super(QtPage, self).__init__()
30 self.setupUi(self) 31 self.setupUi(self)
31 self.setObjectName("QtPage") 32 self.setObjectName("QtPage")
32 33
34 try:
35 self.__virtualenvManager = e5App().getObject("VirtualEnvManager")
36 except KeyError:
37 from VirtualEnv.VirtualenvManager import VirtualenvManager
38 self.__virtualenvManager = VirtualenvManager()
39
40 for button in (
41 self.pyqt5VenvDlgButton, self.pyqt6VenvDlgButton,
42 self.pyside2VenvDlgButton, self.pyside6VenvDlgButton,
43 ):
44 button.setIcon(UI.PixmapCache.getIcon("virtualenv"))
45
33 self.qtTransPicker.setMode(E5PathPickerModes.DirectoryMode) 46 self.qtTransPicker.setMode(E5PathPickerModes.DirectoryMode)
34 self.qtToolsDirPicker.setMode(E5PathPickerModes.DirectoryShowFilesMode) 47 for picker in (
35 self.pyqtToolsDirPicker.setMode( 48 self.qtToolsDirPicker,
36 E5PathPickerModes.DirectoryShowFilesMode) 49 self.pyqtToolsDirPicker,
37 self.pyside2ToolsDirPicker.setMode( 50 self.pyqt6ToolsDirPicker,
38 E5PathPickerModes.DirectoryShowFilesMode) 51 self.pyside2ToolsDirPicker,
52 self.pyside6ToolsDirPicker,
53 ):
54 picker.setMode(E5PathPickerModes.DirectoryShowFilesMode)
55
56 self.__populateAndSetVenvComboBoxes(True)
39 57
40 # set initial values 58 # set initial values
41 self.qtTransPicker.setText( 59 self.qtTransPicker.setText(
42 Preferences.getQt("Qt5TranslationsDir")) 60 Preferences.getQt("Qt5TranslationsDir"))
61
62 # Qt
43 self.qtToolsDirPicker.setText(Preferences.getQt("QtToolsDir")) 63 self.qtToolsDirPicker.setText(Preferences.getQt("QtToolsDir"))
44 self.qtPrefixEdit.setText(Preferences.getQt("QtToolsPrefix")) 64 self.qtPrefixEdit.setText(Preferences.getQt("QtToolsPrefix"))
45 self.qtPostfixEdit.setText(Preferences.getQt("QtToolsPostfix")) 65 self.qtPostfixEdit.setText(Preferences.getQt("QtToolsPostfix"))
46 self.__updateQtSample() 66 self.__updateQtSample()
47 67
68 # PyQt 5
48 self.pyqtToolsDirPicker.setText(Preferences.getQt("PyQtToolsDir")) 69 self.pyqtToolsDirPicker.setText(Preferences.getQt("PyQtToolsDir"))
49 self.pyuicIndentSpinBox.setValue(Preferences.getQt("PyuicIndent")) 70 self.pyuicIndentSpinBox.setValue(Preferences.getQt("PyuicIndent"))
50 self.pyuicImportsCheckBox.setChecked( 71 self.pyuicImportsCheckBox.setChecked(
51 Preferences.getQt("PyuicFromImports")) 72 Preferences.getQt("PyuicFromImports"))
52 self.pyuicExecuteCheckBox.setChecked( 73 self.pyuicExecuteCheckBox.setChecked(
53 Preferences.getQt("PyuicExecute")) 74 Preferences.getQt("PyuicExecute"))
54 75
76 # PyQt 6
77 self.pyqt6ToolsDirPicker.setText(Preferences.getQt("PyQt6ToolsDir"))
78 self.pyuic6IndentSpinBox.setValue(Preferences.getQt("Pyuic6Indent"))
79 self.pyuic6ExecuteCheckBox.setChecked(
80 Preferences.getQt("Pyuic6Execute"))
81
82 # PySide 2
55 self.pyside2ToolsDirPicker.setText( 83 self.pyside2ToolsDirPicker.setText(
56 Preferences.getQt("PySide2ToolsDir")) 84 Preferences.getQt("PySide2ToolsDir"))
57 self.pyside2uicImportsCheckBox.setChecked( 85 self.pyside2uicImportsCheckBox.setChecked(
58 Preferences.getQt("PySide2FromImports")) 86 Preferences.getQt("PySide2FromImports"))
59 87
60 self.pyside2Group.setEnabled(Utilities.checkPyside()) 88 # PySide 6
61 89 self.pyside6ToolsDirPicker.setText(
90 Preferences.getQt("PySide6ToolsDir"))
91 self.pyside6uicImportsCheckBox.setChecked(
92 Preferences.getQt("PySide6FromImports"))
93
62 def save(self): 94 def save(self):
63 """ 95 """
64 Public slot to save the Qt configuration. 96 Public slot to save the Qt configuration.
65 """ 97 """
66 Preferences.setQt("Qt5TranslationsDir", self.qtTransPicker.text()) 98 Preferences.setQt("Qt5TranslationsDir", self.qtTransPicker.text())
67 Preferences.setQt("QtToolsDir", self.qtToolsDirPicker.text()) 99 Preferences.setQt("QtToolsDir", self.qtToolsDirPicker.text())
68 Preferences.setQt("QtToolsPrefix", self.qtPrefixEdit.text()) 100 Preferences.setQt("QtToolsPrefix", self.qtPrefixEdit.text())
69 Preferences.setQt("QtToolsPostfix", self.qtPostfixEdit.text()) 101 Preferences.setQt("QtToolsPostfix", self.qtPostfixEdit.text())
70 102
103 Preferences.setQt("PyQtVenvName", self.pyqt5VenvComboBox.currentText())
71 Preferences.setQt("PyQtToolsDir", self.pyqtToolsDirPicker.text()) 104 Preferences.setQt("PyQtToolsDir", self.pyqtToolsDirPicker.text())
72 Preferences.setQt("PyuicIndent", self.pyuicIndentSpinBox.value()) 105 Preferences.setQt("PyuicIndent", self.pyuicIndentSpinBox.value())
73 Preferences.setQt("PyuicFromImports", 106 Preferences.setQt("PyuicFromImports",
74 self.pyuicImportsCheckBox.isChecked()) 107 self.pyuicImportsCheckBox.isChecked())
75 Preferences.setQt("PyuicExecute", 108 Preferences.setQt("PyuicExecute",
76 self.pyuicExecuteCheckBox.isChecked()) 109 self.pyuicExecuteCheckBox.isChecked())
77 110
111 Preferences.setQt("PyQt6VenvName",
112 self.pyqt6VenvComboBox.currentText())
113 Preferences.setQt("PyQt6ToolsDir", self.pyqt6ToolsDirPicker.text())
114 Preferences.setQt("Pyuic6Indent", self.pyuic6IndentSpinBox.value())
115 Preferences.setQt("Pyuic6Execute",
116 self.pyuic6ExecuteCheckBox.isChecked())
117
118 Preferences.setQt("PySide2VenvName",
119 self.pyside2VenvComboBox.currentText())
78 Preferences.setQt("PySide2ToolsDir", self.pyside2ToolsDirPicker.text()) 120 Preferences.setQt("PySide2ToolsDir", self.pyside2ToolsDirPicker.text())
79 Preferences.setQt("PySide2FromImports", 121 Preferences.setQt("PySide2FromImports",
80 self.pyside2uicImportsCheckBox.isChecked()) 122 self.pyside2uicImportsCheckBox.isChecked())
81 123
124 Preferences.setQt("PySide6VenvName",
125 self.pyside6VenvComboBox.currentText())
126 Preferences.setQt("PySide6ToolsDir", self.pyside6ToolsDirPicker.text())
127 Preferences.setQt("PySide6FromImports",
128 self.pyside6uicImportsCheckBox.isChecked())
129
82 def __updateQtSample(self): 130 def __updateQtSample(self):
83 """ 131 """
84 Private slot to update the Qt tools sample label. 132 Private slot to update the Qt tools sample label.
85 """ 133 """
86 self.qtSampleLabel.setText( 134 self.qtSampleLabel.setText(
103 151
104 @param txt the entered string (string) 152 @param txt the entered string (string)
105 """ 153 """
106 self.__updateQtSample() 154 self.__updateQtSample()
107 155
156 def __populateAndSetVenvComboBox(self, comboBox, envKey, initial):
157 """
158 Private method to populate and set the virtual environment combo boxes.
159
160 @param comboBox reference to the combo box to be populated
161 @type QComboBox
162 @param envKey preferences key for the environment
163 @type str
164 @param initial flag indicating an initial population
165 @type bool
166 """
167 if initial:
168 venvName = Preferences.getQt(envKey)
169 else:
170 venvName = comboBox.currentText()
171
172 comboBox.clear()
173 comboBox.addItems(
174 [""] +
175 sorted(self.__virtualenvManager.getVirtualenvNames())
176 )
177
178 if venvName:
179 index = comboBox.findText(venvName)
180 if index < 0:
181 index = 0
182 comboBox.setCurrentIndex(index)
183
184 def __populateAndSetVenvComboBoxes(self, initial):
185 """
186 Private method to populate the virtual environment combo boxes.
187
188 @param initial flag indicating an initial population
189 @type bool
190 """
191 self.__populateAndSetVenvComboBox(
192 self.pyqt5VenvComboBox, "PyQtVenvName", initial)
193 self.__populateAndSetVenvComboBox(
194 self.pyqt6VenvComboBox, "PyQt6VenvName", initial)
195 self.__populateAndSetVenvComboBox(
196 self.pyside2VenvComboBox, "PySide2VenvName", initial)
197 self.__populateAndSetVenvComboBox(
198 self.pyside6VenvComboBox, "PySide6VenvName", initial)
199
200 def __showVirtualEnvManager(self):
201 """
202 Private method to show the virtual environment manager dialog.
203 """
204 self.__virtualenvManager.showVirtualenvManagerDialog(modal=True)
205 self.__populateAndSetVenvComboBoxes(False)
206 self.activateWindow()
207 self.raise_()
208
209 @pyqtSlot()
210 def on_pyqt5VenvDlgButton_clicked(self):
211 """
212 Private slot to show the virtual environment manager dialog.
213 """
214 self.__showVirtualEnvManager()
215
216 @pyqtSlot()
217 def on_pyqt6VenvDlgButton_clicked(self):
218 """
219 Private slot to show the virtual environment manager dialog.
220 """
221 self.__showVirtualEnvManager()
222
223 @pyqtSlot()
224 def on_pyside2VenvDlgButton_clicked(self):
225 """
226 Private slot to show the virtual environment manager dialog.
227 """
228 self.__showVirtualEnvManager()
229
230 @pyqtSlot()
231 def on_pyside6VenvDlgButton_clicked(self):
232 """
233 Private slot to show the virtual environment manager dialog.
234 """
235 self.__showVirtualEnvManager()
236
108 237
109 def create(dlg): 238 def create(dlg):
110 """ 239 """
111 Module function to create the configuration page. 240 Module function to create the configuration page.
112 241

eric ide

mercurial