21 |
21 |
22 class QtPage(ConfigurationPageBase, Ui_QtPage): |
22 class QtPage(ConfigurationPageBase, Ui_QtPage): |
23 """ |
23 """ |
24 Class implementing the Qt configuration page. |
24 Class implementing the Qt configuration page. |
25 """ |
25 """ |
|
26 |
26 def __init__(self): |
27 def __init__(self): |
27 """ |
28 """ |
28 Constructor |
29 Constructor |
29 """ |
30 """ |
30 super().__init__() |
31 super().__init__() |
31 self.setupUi(self) |
32 self.setupUi(self) |
32 self.setObjectName("QtPage") |
33 self.setObjectName("QtPage") |
33 |
34 |
34 try: |
35 try: |
35 self.__virtualenvManager = ericApp().getObject("VirtualEnvManager") |
36 self.__virtualenvManager = ericApp().getObject("VirtualEnvManager") |
36 self.__standalone = False |
37 self.__standalone = False |
37 except KeyError: |
38 except KeyError: |
38 from VirtualEnv.VirtualenvManager import VirtualenvManager |
39 from VirtualEnv.VirtualenvManager import VirtualenvManager |
|
40 |
39 self.__virtualenvManager = VirtualenvManager() |
41 self.__virtualenvManager = VirtualenvManager() |
40 self.__standalone = True |
42 self.__standalone = True |
41 |
43 |
42 for button in ( |
44 for button in ( |
43 self.pyqt5VenvDlgButton, self.pyqt6VenvDlgButton, |
45 self.pyqt5VenvDlgButton, |
44 self.pyside2VenvDlgButton, self.pyside6VenvDlgButton, |
46 self.pyqt6VenvDlgButton, |
|
47 self.pyside2VenvDlgButton, |
|
48 self.pyside6VenvDlgButton, |
45 ): |
49 ): |
46 button.setIcon(UI.PixmapCache.getIcon("virtualenv")) |
50 button.setIcon(UI.PixmapCache.getIcon("virtualenv")) |
47 button.clicked.connect(self.__showVirtualEnvManager) |
51 button.clicked.connect(self.__showVirtualEnvManager) |
48 button.setVisible(self.__standalone) |
52 button.setVisible(self.__standalone) |
49 |
53 |
50 for button in ( |
54 for button in ( |
51 self.pyqt5VenvRefreshButton, self.pyqt6VenvRefreshButton, |
55 self.pyqt5VenvRefreshButton, |
52 self.pyside2VenvRefreshButton, self.pyside6VenvRefreshButton, |
56 self.pyqt6VenvRefreshButton, |
|
57 self.pyside2VenvRefreshButton, |
|
58 self.pyside6VenvRefreshButton, |
53 ): |
59 ): |
54 button.setIcon(UI.PixmapCache.getIcon("reload")) |
60 button.setIcon(UI.PixmapCache.getIcon("reload")) |
55 button.clicked.connect(self.__populateAndSetVenvComboBoxes) |
61 button.clicked.connect(self.__populateAndSetVenvComboBoxes) |
56 button.setVisible(not self.__standalone) |
62 button.setVisible(not self.__standalone) |
57 |
63 |
58 self.qtTransPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
64 self.qtTransPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
59 for picker in ( |
65 for picker in ( |
60 self.qtToolsDirPicker, |
66 self.qtToolsDirPicker, |
61 self.pyqtToolsDirPicker, |
67 self.pyqtToolsDirPicker, |
62 self.pyqt6ToolsDirPicker, |
68 self.pyqt6ToolsDirPicker, |
63 self.pyside2ToolsDirPicker, |
69 self.pyside2ToolsDirPicker, |
64 self.pyside6ToolsDirPicker, |
70 self.pyside6ToolsDirPicker, |
65 ): |
71 ): |
66 picker.setMode(EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE) |
72 picker.setMode(EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE) |
67 |
73 |
68 self.__populateAndSetVenvComboBoxes(True) |
74 self.__populateAndSetVenvComboBoxes(True) |
69 |
75 |
70 # set initial values |
76 # set initial values |
71 self.qtTransPicker.setText( |
77 self.qtTransPicker.setText(Preferences.getQt("Qt6TranslationsDir")) |
72 Preferences.getQt("Qt6TranslationsDir")) |
78 |
73 |
|
74 # Qt |
79 # Qt |
75 self.qtToolsDirPicker.setText(Preferences.getQt("QtToolsDir")) |
80 self.qtToolsDirPicker.setText(Preferences.getQt("QtToolsDir")) |
76 self.qtPrefixEdit.setText(Preferences.getQt("QtToolsPrefix")) |
81 self.qtPrefixEdit.setText(Preferences.getQt("QtToolsPrefix")) |
77 self.qtPostfixEdit.setText(Preferences.getQt("QtToolsPostfix")) |
82 self.qtPostfixEdit.setText(Preferences.getQt("QtToolsPostfix")) |
78 self.__updateQtSample() |
83 self.__updateQtSample() |
79 |
84 |
80 # PyQt 5 |
85 # PyQt 5 |
81 self.pyqtToolsDirPicker.setText(Preferences.getQt("PyQtToolsDir")) |
86 self.pyqtToolsDirPicker.setText(Preferences.getQt("PyQtToolsDir")) |
82 self.pyuicIndentSpinBox.setValue(Preferences.getQt("PyuicIndent")) |
87 self.pyuicIndentSpinBox.setValue(Preferences.getQt("PyuicIndent")) |
83 self.pyuicImportsCheckBox.setChecked( |
88 self.pyuicImportsCheckBox.setChecked(Preferences.getQt("PyuicFromImports")) |
84 Preferences.getQt("PyuicFromImports")) |
89 self.pyuicExecuteCheckBox.setChecked(Preferences.getQt("PyuicExecute")) |
85 self.pyuicExecuteCheckBox.setChecked( |
90 |
86 Preferences.getQt("PyuicExecute")) |
|
87 |
|
88 # PyQt 6 |
91 # PyQt 6 |
89 self.pyqt6ToolsDirPicker.setText(Preferences.getQt("PyQt6ToolsDir")) |
92 self.pyqt6ToolsDirPicker.setText(Preferences.getQt("PyQt6ToolsDir")) |
90 self.pyuic6IndentSpinBox.setValue(Preferences.getQt("Pyuic6Indent")) |
93 self.pyuic6IndentSpinBox.setValue(Preferences.getQt("Pyuic6Indent")) |
91 self.pyuic6ExecuteCheckBox.setChecked( |
94 self.pyuic6ExecuteCheckBox.setChecked(Preferences.getQt("Pyuic6Execute")) |
92 Preferences.getQt("Pyuic6Execute")) |
95 |
93 |
|
94 # PySide 2 |
96 # PySide 2 |
95 self.pyside2ToolsDirPicker.setText( |
97 self.pyside2ToolsDirPicker.setText(Preferences.getQt("PySide2ToolsDir")) |
96 Preferences.getQt("PySide2ToolsDir")) |
|
97 self.pyside2uicImportsCheckBox.setChecked( |
98 self.pyside2uicImportsCheckBox.setChecked( |
98 Preferences.getQt("PySide2FromImports")) |
99 Preferences.getQt("PySide2FromImports") |
99 |
100 ) |
|
101 |
100 # PySide 6 |
102 # PySide 6 |
101 self.pyside6ToolsDirPicker.setText( |
103 self.pyside6ToolsDirPicker.setText(Preferences.getQt("PySide6ToolsDir")) |
102 Preferences.getQt("PySide6ToolsDir")) |
|
103 self.pyside6uicImportsCheckBox.setChecked( |
104 self.pyside6uicImportsCheckBox.setChecked( |
104 Preferences.getQt("PySide6FromImports")) |
105 Preferences.getQt("PySide6FromImports") |
105 |
106 ) |
|
107 |
106 def save(self): |
108 def save(self): |
107 """ |
109 """ |
108 Public slot to save the Qt configuration. |
110 Public slot to save the Qt configuration. |
109 """ |
111 """ |
110 Preferences.setQt("Qt6TranslationsDir", self.qtTransPicker.text()) |
112 Preferences.setQt("Qt6TranslationsDir", self.qtTransPicker.text()) |
111 Preferences.setQt("QtToolsDir", self.qtToolsDirPicker.text()) |
113 Preferences.setQt("QtToolsDir", self.qtToolsDirPicker.text()) |
112 Preferences.setQt("QtToolsPrefix", self.qtPrefixEdit.text()) |
114 Preferences.setQt("QtToolsPrefix", self.qtPrefixEdit.text()) |
113 Preferences.setQt("QtToolsPostfix", self.qtPostfixEdit.text()) |
115 Preferences.setQt("QtToolsPostfix", self.qtPostfixEdit.text()) |
114 |
116 |
115 Preferences.setQt("PyQtVenvName", self.pyqt5VenvComboBox.currentText()) |
117 Preferences.setQt("PyQtVenvName", self.pyqt5VenvComboBox.currentText()) |
116 Preferences.setQt("PyQtToolsDir", self.pyqtToolsDirPicker.text()) |
118 Preferences.setQt("PyQtToolsDir", self.pyqtToolsDirPicker.text()) |
117 Preferences.setQt("PyuicIndent", self.pyuicIndentSpinBox.value()) |
119 Preferences.setQt("PyuicIndent", self.pyuicIndentSpinBox.value()) |
118 Preferences.setQt("PyuicFromImports", |
120 Preferences.setQt("PyuicFromImports", self.pyuicImportsCheckBox.isChecked()) |
119 self.pyuicImportsCheckBox.isChecked()) |
121 Preferences.setQt("PyuicExecute", self.pyuicExecuteCheckBox.isChecked()) |
120 Preferences.setQt("PyuicExecute", |
122 |
121 self.pyuicExecuteCheckBox.isChecked()) |
123 Preferences.setQt("PyQt6VenvName", self.pyqt6VenvComboBox.currentText()) |
122 |
|
123 Preferences.setQt("PyQt6VenvName", |
|
124 self.pyqt6VenvComboBox.currentText()) |
|
125 Preferences.setQt("PyQt6ToolsDir", self.pyqt6ToolsDirPicker.text()) |
124 Preferences.setQt("PyQt6ToolsDir", self.pyqt6ToolsDirPicker.text()) |
126 Preferences.setQt("Pyuic6Indent", self.pyuic6IndentSpinBox.value()) |
125 Preferences.setQt("Pyuic6Indent", self.pyuic6IndentSpinBox.value()) |
127 Preferences.setQt("Pyuic6Execute", |
126 Preferences.setQt("Pyuic6Execute", self.pyuic6ExecuteCheckBox.isChecked()) |
128 self.pyuic6ExecuteCheckBox.isChecked()) |
127 |
129 |
128 Preferences.setQt("PySide2VenvName", self.pyside2VenvComboBox.currentText()) |
130 Preferences.setQt("PySide2VenvName", |
|
131 self.pyside2VenvComboBox.currentText()) |
|
132 Preferences.setQt("PySide2ToolsDir", self.pyside2ToolsDirPicker.text()) |
129 Preferences.setQt("PySide2ToolsDir", self.pyside2ToolsDirPicker.text()) |
133 Preferences.setQt("PySide2FromImports", |
130 Preferences.setQt( |
134 self.pyside2uicImportsCheckBox.isChecked()) |
131 "PySide2FromImports", self.pyside2uicImportsCheckBox.isChecked() |
135 |
132 ) |
136 Preferences.setQt("PySide6VenvName", |
133 |
137 self.pyside6VenvComboBox.currentText()) |
134 Preferences.setQt("PySide6VenvName", self.pyside6VenvComboBox.currentText()) |
138 Preferences.setQt("PySide6ToolsDir", self.pyside6ToolsDirPicker.text()) |
135 Preferences.setQt("PySide6ToolsDir", self.pyside6ToolsDirPicker.text()) |
139 Preferences.setQt("PySide6FromImports", |
136 Preferences.setQt( |
140 self.pyside6uicImportsCheckBox.isChecked()) |
137 "PySide6FromImports", self.pyside6uicImportsCheckBox.isChecked() |
141 |
138 ) |
|
139 |
142 def __updateQtSample(self): |
140 def __updateQtSample(self): |
143 """ |
141 """ |
144 Private slot to update the Qt tools sample label. |
142 Private slot to update the Qt tools sample label. |
145 """ |
143 """ |
146 self.qtSampleLabel.setText( |
144 self.qtSampleLabel.setText( |
147 self.tr("Sample: {0}designer{1}").format( |
145 self.tr("Sample: {0}designer{1}").format( |
148 self.qtPrefixEdit.text(), self.qtPostfixEdit.text())) |
146 self.qtPrefixEdit.text(), self.qtPostfixEdit.text() |
149 |
147 ) |
|
148 ) |
|
149 |
150 @pyqtSlot(str) |
150 @pyqtSlot(str) |
151 def on_qtPrefixEdit_textChanged(self, txt): |
151 def on_qtPrefixEdit_textChanged(self, txt): |
152 """ |
152 """ |
153 Private slot to handle a change in the entered Qt directory. |
153 Private slot to handle a change in the entered Qt directory. |
154 |
154 |
155 @param txt the entered string (string) |
155 @param txt the entered string (string) |
156 """ |
156 """ |
157 self.__updateQtSample() |
157 self.__updateQtSample() |
158 |
158 |
159 @pyqtSlot(str) |
159 @pyqtSlot(str) |
160 def on_qtPostfixEdit_textChanged(self, txt): |
160 def on_qtPostfixEdit_textChanged(self, txt): |
161 """ |
161 """ |
162 Private slot to handle a change in the entered Qt directory. |
162 Private slot to handle a change in the entered Qt directory. |
163 |
163 |
164 @param txt the entered string (string) |
164 @param txt the entered string (string) |
165 """ |
165 """ |
166 self.__updateQtSample() |
166 self.__updateQtSample() |
167 |
167 |
168 def __populateAndSetVenvComboBox(self, comboBox, envKey, initial): |
168 def __populateAndSetVenvComboBox(self, comboBox, envKey, initial): |
169 """ |
169 """ |
170 Private method to populate and set the virtual environment combo boxes. |
170 Private method to populate and set the virtual environment combo boxes. |
171 |
171 |
172 @param comboBox reference to the combo box to be populated |
172 @param comboBox reference to the combo box to be populated |
173 @type QComboBox |
173 @type QComboBox |
174 @param envKey preferences key for the environment |
174 @param envKey preferences key for the environment |
175 @type str |
175 @type str |
176 @param initial flag indicating an initial population |
176 @param initial flag indicating an initial population |
177 @type bool |
177 @type bool |
178 """ |
178 """ |
179 venvName = (Preferences.getQt(envKey) if initial |
179 venvName = Preferences.getQt(envKey) if initial else comboBox.currentText() |
180 else comboBox.currentText()) |
180 |
181 |
|
182 comboBox.clear() |
181 comboBox.clear() |
183 comboBox.addItems( |
182 comboBox.addItems([""] + sorted(self.__virtualenvManager.getVirtualenvNames())) |
184 [""] + |
183 |
185 sorted(self.__virtualenvManager.getVirtualenvNames()) |
|
186 ) |
|
187 |
|
188 if venvName: |
184 if venvName: |
189 index = comboBox.findText(venvName) |
185 index = comboBox.findText(venvName) |
190 if index < 0: |
186 if index < 0: |
191 index = 0 |
187 index = 0 |
192 comboBox.setCurrentIndex(index) |
188 comboBox.setCurrentIndex(index) |
193 |
189 |
194 def __populateAndSetVenvComboBoxes(self, initial): |
190 def __populateAndSetVenvComboBoxes(self, initial): |
195 """ |
191 """ |
196 Private method to populate the virtual environment combo boxes. |
192 Private method to populate the virtual environment combo boxes. |
197 |
193 |
198 @param initial flag indicating an initial population |
194 @param initial flag indicating an initial population |
199 @type bool |
195 @type bool |
200 """ |
196 """ |
201 self.__populateAndSetVenvComboBox( |
197 self.__populateAndSetVenvComboBox( |
202 self.pyqt5VenvComboBox, "PyQtVenvName", initial) |
198 self.pyqt5VenvComboBox, "PyQtVenvName", initial |
203 self.__populateAndSetVenvComboBox( |
199 ) |
204 self.pyqt6VenvComboBox, "PyQt6VenvName", initial) |
200 self.__populateAndSetVenvComboBox( |
205 self.__populateAndSetVenvComboBox( |
201 self.pyqt6VenvComboBox, "PyQt6VenvName", initial |
206 self.pyside2VenvComboBox, "PySide2VenvName", initial) |
202 ) |
207 self.__populateAndSetVenvComboBox( |
203 self.__populateAndSetVenvComboBox( |
208 self.pyside6VenvComboBox, "PySide6VenvName", initial) |
204 self.pyside2VenvComboBox, "PySide2VenvName", initial |
209 |
205 ) |
|
206 self.__populateAndSetVenvComboBox( |
|
207 self.pyside6VenvComboBox, "PySide6VenvName", initial |
|
208 ) |
|
209 |
210 def __showVirtualEnvManager(self): |
210 def __showVirtualEnvManager(self): |
211 """ |
211 """ |
212 Private method to show the virtual environment manager dialog. |
212 Private method to show the virtual environment manager dialog. |
213 """ |
213 """ |
214 self.__virtualenvManager.showVirtualenvManagerDialog(modal=True) |
214 self.__virtualenvManager.showVirtualenvManagerDialog(modal=True) |