eric6/Preferences/ConfigurationPages/QtPage.py

changeset 7907
7991ea245c20
parent 7780
41420f82c0ac
child 7911
4621c9082a43
equal deleted inserted replaced
7906:0af028b93cb3 7907:7991ea245c20
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 19
20 20
21 class QtPage(ConfigurationPageBase, Ui_QtPage): 21 class QtPage(ConfigurationPageBase, Ui_QtPage):
22 """ 22 """
23 Class implementing the Qt configuration page. 23 Class implementing the Qt configuration page.
27 Constructor 27 Constructor
28 """ 28 """
29 super(QtPage, self).__init__() 29 super(QtPage, self).__init__()
30 self.setupUi(self) 30 self.setupUi(self)
31 self.setObjectName("QtPage") 31 self.setObjectName("QtPage")
32
33 try:
34 self.__virtualenvManager = e5App().getObject("VirtualEnvManager")
35 except KeyError:
36 from VirtualEnv.VirtualenvManager import VirtualenvManager
37 self.__virtualenvManager = VirtualenvManager()
32 38
33 self.qtTransPicker.setMode(E5PathPickerModes.DirectoryMode) 39 self.qtTransPicker.setMode(E5PathPickerModes.DirectoryMode)
34 self.qtToolsDirPicker.setMode(E5PathPickerModes.DirectoryShowFilesMode) 40 self.qtToolsDirPicker.setMode(E5PathPickerModes.DirectoryShowFilesMode)
35 self.pyqtToolsDirPicker.setMode( 41 self.pyqtToolsDirPicker.setMode(
36 E5PathPickerModes.DirectoryShowFilesMode) 42 E5PathPickerModes.DirectoryShowFilesMode)
43 self.pyqt6ToolsDirPicker.setMode(
44 E5PathPickerModes.DirectoryShowFilesMode)
37 self.pyside2ToolsDirPicker.setMode( 45 self.pyside2ToolsDirPicker.setMode(
38 E5PathPickerModes.DirectoryShowFilesMode) 46 E5PathPickerModes.DirectoryShowFilesMode)
47
48 self.__populateAndSetVenvComboBoxes(True)
39 49
40 # set initial values 50 # set initial values
41 self.qtTransPicker.setText( 51 self.qtTransPicker.setText(
42 Preferences.getQt("Qt5TranslationsDir")) 52 Preferences.getQt("Qt5TranslationsDir"))
53
54 # Qt
43 self.qtToolsDirPicker.setText(Preferences.getQt("QtToolsDir")) 55 self.qtToolsDirPicker.setText(Preferences.getQt("QtToolsDir"))
44 self.qtPrefixEdit.setText(Preferences.getQt("QtToolsPrefix")) 56 self.qtPrefixEdit.setText(Preferences.getQt("QtToolsPrefix"))
45 self.qtPostfixEdit.setText(Preferences.getQt("QtToolsPostfix")) 57 self.qtPostfixEdit.setText(Preferences.getQt("QtToolsPostfix"))
46 self.__updateQtSample() 58 self.__updateQtSample()
47 59
60 # PyQt 5
48 self.pyqtToolsDirPicker.setText(Preferences.getQt("PyQtToolsDir")) 61 self.pyqtToolsDirPicker.setText(Preferences.getQt("PyQtToolsDir"))
49 self.pyuicIndentSpinBox.setValue(Preferences.getQt("PyuicIndent")) 62 self.pyuicIndentSpinBox.setValue(Preferences.getQt("PyuicIndent"))
50 self.pyuicImportsCheckBox.setChecked( 63 self.pyuicImportsCheckBox.setChecked(
51 Preferences.getQt("PyuicFromImports")) 64 Preferences.getQt("PyuicFromImports"))
52 self.pyuicExecuteCheckBox.setChecked( 65 self.pyuicExecuteCheckBox.setChecked(
53 Preferences.getQt("PyuicExecute")) 66 Preferences.getQt("PyuicExecute"))
54 67
68 # PyQt 6
69 self.pyqt6ToolsDirPicker.setText(Preferences.getQt("PyQt6ToolsDir"))
70 self.pyuic6IndentSpinBox.setValue(Preferences.getQt("Pyuic6Indent"))
71 self.pyuic6ExecuteCheckBox.setChecked(
72 Preferences.getQt("Pyuic6Execute"))
73
74 # PySide 2
55 self.pyside2ToolsDirPicker.setText( 75 self.pyside2ToolsDirPicker.setText(
56 Preferences.getQt("PySide2ToolsDir")) 76 Preferences.getQt("PySide2ToolsDir"))
57 self.pyside2uicImportsCheckBox.setChecked( 77 self.pyside2uicImportsCheckBox.setChecked(
58 Preferences.getQt("PySide2FromImports")) 78 Preferences.getQt("PySide2FromImports"))
59 79
60 self.pyside2Group.setEnabled(Utilities.checkPyside())
61
62 def save(self): 80 def save(self):
63 """ 81 """
64 Public slot to save the Qt configuration. 82 Public slot to save the Qt configuration.
65 """ 83 """
66 Preferences.setQt("Qt5TranslationsDir", self.qtTransPicker.text()) 84 Preferences.setQt("Qt5TranslationsDir", self.qtTransPicker.text())
67 Preferences.setQt("QtToolsDir", self.qtToolsDirPicker.text()) 85 Preferences.setQt("QtToolsDir", self.qtToolsDirPicker.text())
68 Preferences.setQt("QtToolsPrefix", self.qtPrefixEdit.text()) 86 Preferences.setQt("QtToolsPrefix", self.qtPrefixEdit.text())
69 Preferences.setQt("QtToolsPostfix", self.qtPostfixEdit.text()) 87 Preferences.setQt("QtToolsPostfix", self.qtPostfixEdit.text())
70 88
89 Preferences.setQt("PyQtVenvName", self.pyqt5VenvComboBox.currentText())
71 Preferences.setQt("PyQtToolsDir", self.pyqtToolsDirPicker.text()) 90 Preferences.setQt("PyQtToolsDir", self.pyqtToolsDirPicker.text())
72 Preferences.setQt("PyuicIndent", self.pyuicIndentSpinBox.value()) 91 Preferences.setQt("PyuicIndent", self.pyuicIndentSpinBox.value())
73 Preferences.setQt("PyuicFromImports", 92 Preferences.setQt("PyuicFromImports",
74 self.pyuicImportsCheckBox.isChecked()) 93 self.pyuicImportsCheckBox.isChecked())
75 Preferences.setQt("PyuicExecute", 94 Preferences.setQt("PyuicExecute",
76 self.pyuicExecuteCheckBox.isChecked()) 95 self.pyuicExecuteCheckBox.isChecked())
77 96
97 Preferences.setQt("PyQt6VenvName",
98 self.pyqt6VenvComboBox.currentText())
99 Preferences.setQt("PyQt6ToolsDir", self.pyqt6ToolsDirPicker.text())
100 Preferences.setQt("Pyuic6Indent", self.pyuic6IndentSpinBox.value())
101 Preferences.setQt("Pyuic6Execute",
102 self.pyuic6ExecuteCheckBox.isChecked())
103
104 Preferences.setQt("PySide2VenvName",
105 self.pyside2VenvComboBox.currentText())
78 Preferences.setQt("PySide2ToolsDir", self.pyside2ToolsDirPicker.text()) 106 Preferences.setQt("PySide2ToolsDir", self.pyside2ToolsDirPicker.text())
79 Preferences.setQt("PySide2FromImports", 107 Preferences.setQt("PySide2FromImports",
80 self.pyside2uicImportsCheckBox.isChecked()) 108 self.pyside2uicImportsCheckBox.isChecked())
81 109
82 def __updateQtSample(self): 110 def __updateQtSample(self):
83 """ 111 """
84 Private slot to update the Qt tools sample label. 112 Private slot to update the Qt tools sample label.
85 """ 113 """
86 self.qtSampleLabel.setText( 114 self.qtSampleLabel.setText(
103 131
104 @param txt the entered string (string) 132 @param txt the entered string (string)
105 """ 133 """
106 self.__updateQtSample() 134 self.__updateQtSample()
107 135
136 def __populateAndSetVenvComboBox(self, comboBox, envKey, initial):
137 """
138 Private method to populate and set the virtual environment combo boxes.
139
140 @param comboBox reference to the combo box to be populated
141 @type QComboBox
142 @param envKey preferences key for the environment
143 @type str
144 @param initial flag indicating an initial population
145 @type bool
146 """
147 if initial:
148 venvName = Preferences.getQt(envKey)
149 else:
150 venvName = comboBox.currentText()
151
152 comboBox.clear()
153 comboBox.addItems(
154 [""] +
155 sorted(self.__virtualenvManager.getVirtualenvNames())
156 )
157
158 if venvName:
159 index = comboBox.findText(venvName)
160 if index < 0:
161 index = 0
162 comboBox.setCurrentIndex(index)
163
164 def __populateAndSetVenvComboBoxes(self, initial):
165 """
166 Private method to populate the virtual environment combo boxes.
167
168 @param initial flag indicating an initial population
169 @type bool
170 """
171 self.__populateAndSetVenvComboBox(
172 self.pyqt5VenvComboBox, "PyQtVenvName", initial)
173 self.__populateAndSetVenvComboBox(
174 self.pyqt6VenvComboBox, "PyQt6VenvName", initial)
175 self.__populateAndSetVenvComboBox(
176 self.pyside2VenvComboBox, "PySide2VenvName", initial)
177
178 def __showVirtualEnvManager(self):
179 """
180 Private method to show the virtual environment manager dialog.
181 """
182 self.__virtualenvManager.showVirtualenvManagerDialog(modal=True)
183 self.__populateAndSetVenvComboBoxes(False)
184 self.activateWindow()
185 self.raise_()
186
187 @pyqtSlot()
188 def on_pyqt5VenvDlgButton_clicked(self):
189 """
190 Private slot to show the virtual environment manager dialog.
191 """
192 self.__showVirtualEnvManager()
193
194 @pyqtSlot()
195 def on_pyqt6VenvDlgButton_clicked(self):
196 """
197 Private slot to show the virtual environment manager dialog.
198 """
199 self.__showVirtualEnvManager()
200
201 @pyqtSlot()
202 def on_pyside2VenvDlgButton_clicked(self):
203 """
204 Private slot to show the virtual environment manager dialog.
205 """
206 self.__showVirtualEnvManager()
207
108 208
109 def create(dlg): 209 def create(dlg):
110 """ 210 """
111 Module function to create the configuration page. 211 Module function to create the configuration page.
112 212

eric ide

mercurial