31 |
31 |
32 class PropertiesDialog(QDialog, Ui_PropertiesDialog): |
32 class PropertiesDialog(QDialog, Ui_PropertiesDialog): |
33 """ |
33 """ |
34 Class implementing the project properties dialog. |
34 Class implementing the project properties dialog. |
35 """ |
35 """ |
|
36 |
36 def __init__(self, project, new=True, parent=None, name=None): |
37 def __init__(self, project, new=True, parent=None, name=None): |
37 """ |
38 """ |
38 Constructor |
39 Constructor |
39 |
40 |
40 @param project reference to the project object |
41 @param project reference to the project object |
41 @param new flag indicating the generation of a new project |
42 @param new flag indicating the generation of a new project |
42 @param parent parent widget of this dialog (QWidget) |
43 @param parent parent widget of this dialog (QWidget) |
43 @param name name of this dialog (string) |
44 @param name name of this dialog (string) |
44 """ |
45 """ |
45 super().__init__(parent) |
46 super().__init__(parent) |
46 if name: |
47 if name: |
47 self.setObjectName(name) |
48 self.setObjectName(name) |
48 self.setupUi(self) |
49 self.setupUi(self) |
49 |
50 |
50 self.dirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
51 self.dirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
51 self.mainscriptPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
52 self.mainscriptPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
52 |
53 |
53 self.makeButton.setIcon(UI.PixmapCache.getIcon("makefile")) |
54 self.makeButton.setIcon(UI.PixmapCache.getIcon("makefile")) |
54 |
55 |
55 self.docstringStyleComboBox.addItem(self.tr("None"), "") |
56 self.docstringStyleComboBox.addItem(self.tr("None"), "") |
56 for docstringType, docstringStyle in sorted( |
57 for docstringType, docstringStyle in sorted(getSupportedDocstringTypes()): |
57 getSupportedDocstringTypes() |
|
58 ): |
|
59 self.docstringStyleComboBox.addItem(docstringStyle, docstringType) |
58 self.docstringStyleComboBox.addItem(docstringStyle, docstringType) |
60 |
59 |
61 self.project = project |
60 self.project = project |
62 self.newProject = new |
61 self.newProject = new |
63 self.transPropertiesDlg = None |
62 self.transPropertiesDlg = None |
64 self.spellPropertiesDlg = None |
63 self.spellPropertiesDlg = None |
65 self.makePropertiesDlg = None |
64 self.makePropertiesDlg = None |
66 |
65 |
67 patterns = [] |
66 patterns = [] |
68 for pattern, filetype in self.project.pdata["FILETYPES"].items(): |
67 for pattern, filetype in self.project.pdata["FILETYPES"].items(): |
69 if filetype == "SOURCES": |
68 if filetype == "SOURCES": |
70 patterns.append(pattern) |
69 patterns.append(pattern) |
71 filters = self.tr("Source Files ({0});;All Files (*)" |
70 filters = self.tr("Source Files ({0});;All Files (*)").format( |
72 ).format(" ".join(sorted(patterns))) |
71 " ".join(sorted(patterns)) |
|
72 ) |
73 self.mainscriptPicker.setFilters(filters) |
73 self.mainscriptPicker.setFilters(filters) |
74 |
74 |
75 self.languageComboBox.addItems(project.getProgrammingLanguages()) |
75 self.languageComboBox.addItems(project.getProgrammingLanguages()) |
76 |
76 |
77 projectTypes = [] |
77 projectTypes = [] |
78 for projectTypeItem in project.getProjectTypes().items(): |
78 for projectTypeItem in project.getProjectTypes().items(): |
79 projectTypes.append((projectTypeItem[1], projectTypeItem[0])) |
79 projectTypes.append((projectTypeItem[1], projectTypeItem[0])) |
80 self.projectTypeComboBox.clear() |
80 self.projectTypeComboBox.clear() |
81 for projectType in sorted(projectTypes): |
81 for projectType in sorted(projectTypes): |
82 self.projectTypeComboBox.addItem( |
82 self.projectTypeComboBox.addItem(projectType[0], projectType[1]) |
83 projectType[0], projectType[1]) |
83 |
84 |
84 ipath = Preferences.getMultiProject("Workspace") or Utilities.getHomeDir() |
85 ipath = ( |
|
86 Preferences.getMultiProject("Workspace") or |
|
87 Utilities.getHomeDir() |
|
88 ) |
|
89 self.__initPaths = [ |
85 self.__initPaths = [ |
90 Utilities.fromNativeSeparators(ipath), |
86 Utilities.fromNativeSeparators(ipath), |
91 Utilities.fromNativeSeparators(ipath) + "/", |
87 Utilities.fromNativeSeparators(ipath) + "/", |
92 ] |
88 ] |
93 |
89 |
94 self.licenseComboBox.lineEdit().setClearButtonEnabled(True) |
90 self.licenseComboBox.lineEdit().setClearButtonEnabled(True) |
95 self.__populateLicenseComboBox() |
91 self.__populateLicenseComboBox() |
96 |
92 |
97 if not new: |
93 if not new: |
98 name = os.path.splitext(self.project.pfile)[0] |
94 name = os.path.splitext(self.project.pfile)[0] |
99 self.nameEdit.setText(os.path.basename(name)) |
95 self.nameEdit.setText(os.path.basename(name)) |
100 self.languageComboBox.setCurrentIndex( |
96 self.languageComboBox.setCurrentIndex( |
101 self.languageComboBox.findText( |
97 self.languageComboBox.findText(self.project.pdata["PROGLANGUAGE"]) |
102 self.project.pdata["PROGLANGUAGE"])) |
98 ) |
103 self.mixedLanguageCheckBox.setChecked( |
99 self.mixedLanguageCheckBox.setChecked(self.project.pdata["MIXEDLANGUAGE"]) |
104 self.project.pdata["MIXEDLANGUAGE"]) |
|
105 curIndex = self.projectTypeComboBox.findData( |
100 curIndex = self.projectTypeComboBox.findData( |
106 self.project.pdata["PROJECTTYPE"]) |
101 self.project.pdata["PROJECTTYPE"] |
|
102 ) |
107 if curIndex == -1: |
103 if curIndex == -1: |
108 curIndex = self.projectTypeComboBox.findData("PyQt6") |
104 curIndex = self.projectTypeComboBox.findData("PyQt6") |
109 self.projectTypeComboBox.setCurrentIndex(curIndex) |
105 self.projectTypeComboBox.setCurrentIndex(curIndex) |
110 self.dirPicker.setText(self.project.ppath) |
106 self.dirPicker.setText(self.project.ppath) |
111 self.versionEdit.setText(self.project.pdata["VERSION"]) |
107 self.versionEdit.setText(self.project.pdata["VERSION"]) |
112 self.mainscriptPicker.setText(self.project.pdata["MAINSCRIPT"]) |
108 self.mainscriptPicker.setText(self.project.pdata["MAINSCRIPT"]) |
113 self.authorEdit.setText(self.project.pdata["AUTHOR"]) |
109 self.authorEdit.setText(self.project.pdata["AUTHOR"]) |
114 self.emailEdit.setText(self.project.pdata["EMAIL"]) |
110 self.emailEdit.setText(self.project.pdata["EMAIL"]) |
115 self.descriptionEdit.setPlainText( |
111 self.descriptionEdit.setPlainText(self.project.pdata["DESCRIPTION"]) |
116 self.project.pdata["DESCRIPTION"]) |
|
117 self.eolComboBox.setCurrentIndex(self.project.pdata["EOL"]) |
112 self.eolComboBox.setCurrentIndex(self.project.pdata["EOL"]) |
118 self.vcsLabel.show() |
113 self.vcsLabel.show() |
119 if self.project.vcs is not None: |
114 if self.project.vcs is not None: |
120 vcsSystemsDict = ( |
115 vcsSystemsDict = ( |
121 ericApp().getObject("PluginManager") |
116 ericApp() |
|
117 .getObject("PluginManager") |
122 .getPluginDisplayStrings("version_control") |
118 .getPluginDisplayStrings("version_control") |
123 ) |
119 ) |
124 try: |
120 try: |
125 vcsSystemDisplay = vcsSystemsDict[ |
121 vcsSystemDisplay = vcsSystemsDict[self.project.pdata["VCS"]] |
126 self.project.pdata["VCS"]] |
|
127 except KeyError: |
122 except KeyError: |
128 vcsSystemDisplay = "None" |
123 vcsSystemDisplay = "None" |
129 self.vcsLabel.setText( |
124 self.vcsLabel.setText( |
130 self.tr( |
125 self.tr("The project is version controlled by <b>{0}</b>.").format( |
131 "The project is version controlled by <b>{0}</b>.") |
126 vcsSystemDisplay |
132 .format(vcsSystemDisplay)) |
127 ) |
|
128 ) |
133 self.vcsInfoButton.show() |
129 self.vcsInfoButton.show() |
134 else: |
130 else: |
135 self.vcsLabel.setText( |
131 self.vcsLabel.setText(self.tr("The project is not version controlled.")) |
136 self.tr("The project is not version controlled.")) |
|
137 self.vcsInfoButton.hide() |
132 self.vcsInfoButton.hide() |
138 self.vcsCheckBox.hide() |
133 self.vcsCheckBox.hide() |
139 self.makeCheckBox.setChecked( |
134 self.makeCheckBox.setChecked( |
140 self.project.pdata["MAKEPARAMS"]["MakeEnabled"]) |
135 self.project.pdata["MAKEPARAMS"]["MakeEnabled"] |
|
136 ) |
141 cindex = self.docstringStyleComboBox.findData( |
137 cindex = self.docstringStyleComboBox.findData( |
142 self.project.pdata["DOCSTRING"]) |
138 self.project.pdata["DOCSTRING"] |
|
139 ) |
143 self.docstringStyleComboBox.setCurrentIndex(cindex) |
140 self.docstringStyleComboBox.setCurrentIndex(cindex) |
144 with contextlib.suppress(KeyError): |
141 with contextlib.suppress(KeyError): |
145 cindex = self.testingFrameworkComboBox.findData( |
142 cindex = self.testingFrameworkComboBox.findData( |
146 self.project.pdata["TESTING_FRAMEWORK"]) |
143 self.project.pdata["TESTING_FRAMEWORK"] |
|
144 ) |
147 self.testingFrameworkComboBox.setCurrentIndex(cindex) |
145 self.testingFrameworkComboBox.setCurrentIndex(cindex) |
148 with contextlib.suppress(KeyError): |
146 with contextlib.suppress(KeyError): |
149 self.licenseComboBox.setCurrentText( |
147 self.licenseComboBox.setCurrentText(self.project.pdata["LICENSE"]) |
150 self.project.pdata["LICENSE"]) |
|
151 else: |
148 else: |
152 self.languageComboBox.setCurrentText("Python3") |
149 self.languageComboBox.setCurrentText("Python3") |
153 self.projectTypeComboBox.setCurrentIndex( |
150 self.projectTypeComboBox.setCurrentIndex( |
154 self.projectTypeComboBox.findData("PyQt6")) |
151 self.projectTypeComboBox.findData("PyQt6") |
|
152 ) |
155 self.dirPicker.setText(self.__initPaths[0]) |
153 self.dirPicker.setText(self.__initPaths[0]) |
156 self.versionEdit.setText('0.1') |
154 self.versionEdit.setText("0.1") |
157 self.vcsLabel.hide() |
155 self.vcsLabel.hide() |
158 self.vcsInfoButton.hide() |
156 self.vcsInfoButton.hide() |
159 if not self.project.vcsSoftwareAvailable(): |
157 if not self.project.vcsSoftwareAvailable(): |
160 self.vcsCheckBox.hide() |
158 self.vcsCheckBox.hide() |
161 |
159 |
162 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
160 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
163 bool(self.dirPicker.text()) and |
161 bool(self.dirPicker.text()) |
164 self.dirPicker.text() not in self.__initPaths) |
162 and self.dirPicker.text() not in self.__initPaths |
165 |
163 ) |
|
164 |
166 def __populateLicenseComboBox(self): |
165 def __populateLicenseComboBox(self): |
167 """ |
166 """ |
168 Private method to populate the license selector with the list of trove |
167 Private method to populate the license selector with the list of trove |
169 license types. |
168 license types. |
170 """ |
169 """ |
171 self.licenseComboBox.addItem("") |
170 self.licenseComboBox.addItem("") |
172 self.licenseComboBox.addItems(sorted( |
171 self.licenseComboBox.addItems( |
173 classifier.split("::")[-1].strip() |
172 sorted( |
174 for classifier in trove_classifiers.classifiers |
173 classifier.split("::")[-1].strip() |
175 if classifier.startswith("License ::") |
174 for classifier in trove_classifiers.classifiers |
176 )) |
175 if classifier.startswith("License ::") |
177 |
176 ) |
|
177 ) |
|
178 |
178 @pyqtSlot(str) |
179 @pyqtSlot(str) |
179 def on_languageComboBox_currentTextChanged(self, language): |
180 def on_languageComboBox_currentTextChanged(self, language): |
180 """ |
181 """ |
181 Private slot handling the selection of a programming language. |
182 Private slot handling the selection of a programming language. |
182 |
183 |
183 @param language text of the current item |
184 @param language text of the current item |
184 @type str |
185 @type str |
185 """ |
186 """ |
186 curProjectType = self.getProjectType() |
187 curProjectType = self.getProjectType() |
187 |
188 |
188 self.projectTypeComboBox.clear() |
189 self.projectTypeComboBox.clear() |
189 for projectType in sorted( |
190 for projectType in sorted( |
190 self.project.getProjectTypes(language).items(), |
191 self.project.getProjectTypes(language).items(), key=lambda k: k[1] |
191 key=lambda k: k[1] |
|
192 ): |
192 ): |
193 self.projectTypeComboBox.addItem( |
193 self.projectTypeComboBox.addItem(projectType[1], projectType[0]) |
194 projectType[1], projectType[0]) |
194 |
195 |
|
196 index = self.projectTypeComboBox.findData(curProjectType) |
195 index = self.projectTypeComboBox.findData(curProjectType) |
197 if index == -1: |
196 if index == -1: |
198 index = 0 |
197 index = 0 |
199 self.projectTypeComboBox.setCurrentIndex(index) |
198 self.projectTypeComboBox.setCurrentIndex(index) |
200 |
199 |
201 curTestingFramework = self.testingFrameworkComboBox.currentText() |
200 curTestingFramework = self.testingFrameworkComboBox.currentText() |
202 self.testingFrameworkComboBox.clear() |
201 self.testingFrameworkComboBox.clear() |
203 self.testingFrameworkComboBox.addItem(self.tr("None"), "") |
202 self.testingFrameworkComboBox.addItem(self.tr("None"), "") |
204 with contextlib.suppress(KeyError): |
203 with contextlib.suppress(KeyError): |
205 for framework in sorted(FrameworkNames[language]): |
204 for framework in sorted(FrameworkNames[language]): |
206 self.testingFrameworkComboBox.addItem(framework, framework) |
205 self.testingFrameworkComboBox.addItem(framework, framework) |
207 self.testingFrameworkComboBox.setCurrentText(curTestingFramework) |
206 self.testingFrameworkComboBox.setCurrentText(curTestingFramework) |
208 |
207 |
209 @pyqtSlot(str) |
208 @pyqtSlot(str) |
210 def on_dirPicker_textChanged(self, txt): |
209 def on_dirPicker_textChanged(self, txt): |
211 """ |
210 """ |
212 Private slot to handle a change of the project directory. |
211 Private slot to handle a change of the project directory. |
213 |
212 |
214 @param txt name of the project directory (string) |
213 @param txt name of the project directory (string) |
215 """ |
214 """ |
216 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
215 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
217 bool(txt) and |
216 bool(txt) and Utilities.fromNativeSeparators(txt) not in self.__initPaths |
218 Utilities.fromNativeSeparators(txt) not in self.__initPaths) |
217 ) |
219 |
218 |
220 @pyqtSlot() |
219 @pyqtSlot() |
221 def on_spellPropertiesButton_clicked(self): |
220 def on_spellPropertiesButton_clicked(self): |
222 """ |
221 """ |
223 Private slot to display the spelling properties dialog. |
222 Private slot to display the spelling properties dialog. |
224 """ |
223 """ |
225 if self.spellPropertiesDlg is None: |
224 if self.spellPropertiesDlg is None: |
226 from .SpellingPropertiesDialog import SpellingPropertiesDialog |
225 from .SpellingPropertiesDialog import SpellingPropertiesDialog |
|
226 |
227 self.spellPropertiesDlg = SpellingPropertiesDialog( |
227 self.spellPropertiesDlg = SpellingPropertiesDialog( |
228 self.project, self.newProject, self) |
228 self.project, self.newProject, self |
|
229 ) |
229 res = self.spellPropertiesDlg.exec() |
230 res = self.spellPropertiesDlg.exec() |
230 if res == QDialog.DialogCode.Rejected: |
231 if res == QDialog.DialogCode.Rejected: |
231 self.spellPropertiesDlg.initDialog() # reset the dialogs contents |
232 self.spellPropertiesDlg.initDialog() # reset the dialogs contents |
232 |
233 |
233 @pyqtSlot() |
234 @pyqtSlot() |
234 def on_transPropertiesButton_clicked(self): |
235 def on_transPropertiesButton_clicked(self): |
235 """ |
236 """ |
236 Private slot to display the translations properties dialog. |
237 Private slot to display the translations properties dialog. |
237 """ |
238 """ |
238 if self.transPropertiesDlg is None: |
239 if self.transPropertiesDlg is None: |
239 from .TranslationPropertiesDialog import ( |
240 from .TranslationPropertiesDialog import TranslationPropertiesDialog |
240 TranslationPropertiesDialog |
241 |
241 ) |
|
242 self.transPropertiesDlg = TranslationPropertiesDialog( |
242 self.transPropertiesDlg = TranslationPropertiesDialog( |
243 self.project, self.newProject, self) |
243 self.project, self.newProject, self |
|
244 ) |
244 else: |
245 else: |
245 self.transPropertiesDlg.initFilters() |
246 self.transPropertiesDlg.initFilters() |
246 res = self.transPropertiesDlg.exec() |
247 res = self.transPropertiesDlg.exec() |
247 if res == QDialog.DialogCode.Rejected: |
248 if res == QDialog.DialogCode.Rejected: |
248 self.transPropertiesDlg.initDialog() # reset the dialogs contents |
249 self.transPropertiesDlg.initDialog() # reset the dialogs contents |
249 |
250 |
250 @pyqtSlot() |
251 @pyqtSlot() |
251 def on_makeButton_clicked(self): |
252 def on_makeButton_clicked(self): |
252 """ |
253 """ |
253 Private slot to display the make properties dialog. |
254 Private slot to display the make properties dialog. |
254 """ |
255 """ |
255 if self.makePropertiesDlg is None: |
256 if self.makePropertiesDlg is None: |
256 from .MakePropertiesDialog import MakePropertiesDialog |
257 from .MakePropertiesDialog import MakePropertiesDialog |
|
258 |
257 self.makePropertiesDlg = MakePropertiesDialog( |
259 self.makePropertiesDlg = MakePropertiesDialog( |
258 self.project, self.newProject, self) |
260 self.project, self.newProject, self |
|
261 ) |
259 res = self.makePropertiesDlg.exec() |
262 res = self.makePropertiesDlg.exec() |
260 if res == QDialog.DialogCode.Rejected: |
263 if res == QDialog.DialogCode.Rejected: |
261 self.makePropertiesDlg.initDialog() |
264 self.makePropertiesDlg.initDialog() |
262 |
265 |
263 @pyqtSlot(str) |
266 @pyqtSlot(str) |
264 def on_mainscriptPicker_pathSelected(self, script): |
267 def on_mainscriptPicker_pathSelected(self, script): |
265 """ |
268 """ |
266 Private slot to check the selected main script name. |
269 Private slot to check the selected main script name. |
267 |
270 |
268 @param script name of the main script |
271 @param script name of the main script |
269 @type str |
272 @type str |
270 """ |
273 """ |
271 if script: |
274 if script: |
272 ppath = self.dirPicker.text() |
275 ppath = self.dirPicker.text() |
273 if ppath: |
276 if ppath: |
274 ppath = QDir(ppath).absolutePath() + QDir.separator() |
277 ppath = QDir(ppath).absolutePath() + QDir.separator() |
275 script = script.replace(ppath, "") |
278 script = script.replace(ppath, "") |
276 self.mainscriptPicker.setText(script) |
279 self.mainscriptPicker.setText(script) |
277 |
280 |
278 @pyqtSlot() |
281 @pyqtSlot() |
279 def on_mainscriptPicker_aboutToShowPathPickerDialog(self): |
282 def on_mainscriptPicker_aboutToShowPathPickerDialog(self): |
280 """ |
283 """ |
281 Private slot to perform actions before the main script selection dialog |
284 Private slot to perform actions before the main script selection dialog |
282 is shown. |
285 is shown. |
283 """ |
286 """ |
284 path = self.dirPicker.text() |
287 path = self.dirPicker.text() |
285 if not path: |
288 if not path: |
286 path = QDir.currentPath() |
289 path = QDir.currentPath() |
287 self.mainscriptPicker.setDefaultDirectory(path) |
290 self.mainscriptPicker.setDefaultDirectory(path) |
288 |
291 |
289 @pyqtSlot() |
292 @pyqtSlot() |
290 def on_vcsInfoButton_clicked(self): |
293 def on_vcsInfoButton_clicked(self): |
291 """ |
294 """ |
292 Private slot to display a vcs information dialog. |
295 Private slot to display a vcs information dialog. |
293 """ |
296 """ |
294 if self.project.vcs is None: |
297 if self.project.vcs is None: |
295 return |
298 return |
296 |
299 |
297 from VCS.RepositoryInfoDialog import VcsRepositoryInfoDialog |
300 from VCS.RepositoryInfoDialog import VcsRepositoryInfoDialog |
|
301 |
298 info = self.project.vcs.vcsRepositoryInfos(self.project.ppath) |
302 info = self.project.vcs.vcsRepositoryInfos(self.project.ppath) |
299 dlg = VcsRepositoryInfoDialog(self, info) |
303 dlg = VcsRepositoryInfoDialog(self, info) |
300 dlg.exec() |
304 dlg.exec() |
301 |
305 |
302 def getProjectType(self): |
306 def getProjectType(self): |
303 """ |
307 """ |
304 Public method to get the selected project type. |
308 Public method to get the selected project type. |
305 |
309 |
306 @return selected UI type (string) |
310 @return selected UI type (string) |
307 """ |
311 """ |
308 return self.projectTypeComboBox.itemData( |
312 return self.projectTypeComboBox.itemData( |
309 self.projectTypeComboBox.currentIndex()) |
313 self.projectTypeComboBox.currentIndex() |
310 |
314 ) |
|
315 |
311 def getPPath(self): |
316 def getPPath(self): |
312 """ |
317 """ |
313 Public method to get the project path. |
318 Public method to get the project path. |
314 |
319 |
315 @return data of the project directory edit (string) |
320 @return data of the project directory edit (string) |
316 """ |
321 """ |
317 return os.path.abspath(self.dirPicker.text()) |
322 return os.path.abspath(self.dirPicker.text()) |
318 |
323 |
319 def storeData(self): |
324 def storeData(self): |
320 """ |
325 """ |
321 Public method to store the entered/modified data. |
326 Public method to store the entered/modified data. |
322 """ |
327 """ |
323 self.project.ppath = os.path.abspath(self.dirPicker.text()) |
328 self.project.ppath = os.path.abspath(self.dirPicker.text()) |