src/eric7/Project/PropertiesDialog.py

branch
eric7-maintenance
changeset 9549
67295777d9fe
parent 9442
906485dcd210
parent 9514
2b104ad132a4
child 9654
7328efba128b
equal deleted inserted replaced
9451:24c847222774 9549:67295777d9fe
13 import trove_classifiers 13 import trove_classifiers
14 14
15 from PyQt6.QtCore import QDir, pyqtSlot 15 from PyQt6.QtCore import QDir, pyqtSlot
16 from PyQt6.QtWidgets import QDialog, QDialogButtonBox 16 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
17 17
18 from eric7 import Preferences, Utilities
19 from eric7.EricGui import EricPixmapCache
18 from eric7.EricWidgets.EricApplication import ericApp 20 from eric7.EricWidgets.EricApplication import ericApp
19 from eric7.EricWidgets.EricPathPicker import EricPathPickerModes 21 from eric7.EricWidgets.EricPathPicker import EricPathPickerModes
22 from eric7.QScintilla.DocstringGenerator import getSupportedDocstringTypes
23 from eric7.Testing.Interfaces import FrameworkNames
20 24
21 from .Ui_PropertiesDialog import Ui_PropertiesDialog 25 from .Ui_PropertiesDialog import Ui_PropertiesDialog
22
23 from eric7.QScintilla.DocstringGenerator import getSupportedDocstringTypes
24
25 from eric7.Testing.Interfaces import FrameworkNames
26
27 from eric7 import Preferences, Utilities
28 from eric7.EricGui import EricPixmapCache
29 26
30 27
31 class PropertiesDialog(QDialog, Ui_PropertiesDialog): 28 class PropertiesDialog(QDialog, Ui_PropertiesDialog):
32 """ 29 """
33 Class implementing the project properties dialog. 30 Class implementing the project properties dialog.
61 self.transPropertiesDlg = None 58 self.transPropertiesDlg = None
62 self.spellPropertiesDlg = None 59 self.spellPropertiesDlg = None
63 self.makePropertiesDlg = None 60 self.makePropertiesDlg = None
64 61
65 patterns = [] 62 patterns = []
66 for pattern, filetype in self.project.pdata["FILETYPES"].items(): 63 for pattern, filetype in self.project.getProjectData(
64 dataKey="FILETYPES"
65 ).items():
67 if filetype == "SOURCES": 66 if filetype == "SOURCES":
68 patterns.append(pattern) 67 patterns.append(pattern)
69 filters = self.tr("Source Files ({0});;All Files (*)").format( 68 filters = self.tr("Source Files ({0});;All Files (*)").format(
70 " ".join(sorted(patterns)) 69 " ".join(sorted(patterns))
71 ) 70 )
91 90
92 if not new: 91 if not new:
93 name = os.path.splitext(self.project.pfile)[0] 92 name = os.path.splitext(self.project.pfile)[0]
94 self.nameEdit.setText(os.path.basename(name)) 93 self.nameEdit.setText(os.path.basename(name))
95 self.languageComboBox.setCurrentIndex( 94 self.languageComboBox.setCurrentIndex(
96 self.languageComboBox.findText(self.project.pdata["PROGLANGUAGE"]) 95 self.languageComboBox.findText(
97 ) 96 self.project.getProjectData(dataKey="PROGLANGUAGE")
98 self.mixedLanguageCheckBox.setChecked(self.project.pdata["MIXEDLANGUAGE"]) 97 )
98 )
99 self.mixedLanguageCheckBox.setChecked(
100 self.project.getProjectData(dataKey="MIXEDLANGUAGE")
101 )
99 curIndex = self.projectTypeComboBox.findData( 102 curIndex = self.projectTypeComboBox.findData(
100 self.project.pdata["PROJECTTYPE"] 103 self.project.getProjectData(dataKey="PROJECTTYPE")
101 ) 104 )
102 if curIndex == -1: 105 if curIndex == -1:
103 curIndex = self.projectTypeComboBox.findData("PyQt6") 106 curIndex = self.projectTypeComboBox.findData("PyQt6")
104 self.projectTypeComboBox.setCurrentIndex(curIndex) 107 self.projectTypeComboBox.setCurrentIndex(curIndex)
105 self.dirPicker.setText(self.project.ppath) 108 self.dirPicker.setText(self.project.ppath)
106 self.versionEdit.setText(self.project.pdata["VERSION"]) 109 self.versionEdit.setText(self.project.getProjectData(dataKey="VERSION"))
107 self.mainscriptPicker.setText(self.project.pdata["MAINSCRIPT"]) 110 self.mainscriptPicker.setText(
108 self.authorEdit.setText(self.project.pdata["AUTHOR"]) 111 self.project.getProjectData(dataKey="MAINSCRIPT")
109 self.emailEdit.setText(self.project.pdata["EMAIL"]) 112 )
110 self.descriptionEdit.setPlainText(self.project.pdata["DESCRIPTION"]) 113 self.authorEdit.setText(self.project.getProjectData(dataKey="AUTHOR"))
111 self.eolComboBox.setCurrentIndex(self.project.pdata["EOL"]) 114 self.emailEdit.setText(self.project.getProjectData(dataKey="EMAIL"))
115 self.descriptionEdit.setPlainText(
116 self.project.getProjectData(dataKey="DESCRIPTION")
117 )
118 self.eolComboBox.setCurrentIndex(self.project.getProjectData(dataKey="EOL"))
112 self.vcsLabel.show() 119 self.vcsLabel.show()
113 if self.project.vcs is not None: 120 if self.project.vcs is not None:
114 vcsSystemsDict = ( 121 vcsSystemsDict = (
115 ericApp() 122 ericApp()
116 .getObject("PluginManager") 123 .getObject("PluginManager")
117 .getPluginDisplayStrings("version_control") 124 .getPluginDisplayStrings("version_control")
118 ) 125 )
119 try: 126 try:
120 vcsSystemDisplay = vcsSystemsDict[self.project.pdata["VCS"]] 127 vcsSystemDisplay = vcsSystemsDict[
128 self.project.getProjectData(dataKey="VCS")
129 ]
121 except KeyError: 130 except KeyError:
122 vcsSystemDisplay = "None" 131 vcsSystemDisplay = "None"
123 self.vcsLabel.setText( 132 self.vcsLabel.setText(
124 self.tr("The project is version controlled by <b>{0}</b>.").format( 133 self.tr("The project is version controlled by <b>{0}</b>.").format(
125 vcsSystemDisplay 134 vcsSystemDisplay
129 else: 138 else:
130 self.vcsLabel.setText(self.tr("The project is not version controlled.")) 139 self.vcsLabel.setText(self.tr("The project is not version controlled."))
131 self.vcsInfoButton.hide() 140 self.vcsInfoButton.hide()
132 self.vcsCheckBox.hide() 141 self.vcsCheckBox.hide()
133 self.makeCheckBox.setChecked( 142 self.makeCheckBox.setChecked(
134 self.project.pdata["MAKEPARAMS"]["MakeEnabled"] 143 self.project.getProjectData(dataKey="MAKEPARAMS")["MakeEnabled"]
135 ) 144 )
136 cindex = self.docstringStyleComboBox.findData( 145 cindex = self.docstringStyleComboBox.findData(
137 self.project.pdata["DOCSTRING"] 146 self.project.getProjectData(dataKey="DOCSTRING")
138 ) 147 )
139 self.docstringStyleComboBox.setCurrentIndex(cindex) 148 self.docstringStyleComboBox.setCurrentIndex(cindex)
140 with contextlib.suppress(KeyError): 149 with contextlib.suppress(KeyError):
141 cindex = self.testingFrameworkComboBox.findData( 150 cindex = self.testingFrameworkComboBox.findData(
142 self.project.pdata["TESTING_FRAMEWORK"] 151 self.project.getProjectData(dataKey="TESTING_FRAMEWORK")
143 ) 152 )
144 self.testingFrameworkComboBox.setCurrentIndex(cindex) 153 self.testingFrameworkComboBox.setCurrentIndex(cindex)
145 with contextlib.suppress(KeyError): 154 with contextlib.suppress(KeyError):
146 self.licenseComboBox.setCurrentText(self.project.pdata["LICENSE"]) 155 self.licenseComboBox.setCurrentText(
147 self.embeddedVenvCheckBox.setChecked(self.project.pdata["EMBEDDED_VENV"]) 156 self.project.getProjectData(dataKey="LICENSE")
157 )
158 self.embeddedVenvCheckBox.setChecked(
159 self.project.getProjectData(dataKey="EMBEDDED_VENV")
160 )
148 else: 161 else:
149 self.languageComboBox.setCurrentText("Python3") 162 self.languageComboBox.setCurrentText("Python3")
150 self.projectTypeComboBox.setCurrentIndex( 163 self.projectTypeComboBox.setCurrentIndex(
151 self.projectTypeComboBox.findData("PyQt6") 164 self.projectTypeComboBox.findData("PyQt6")
152 ) 165 )
219 @pyqtSlot() 232 @pyqtSlot()
220 def on_spellPropertiesButton_clicked(self): 233 def on_spellPropertiesButton_clicked(self):
221 """ 234 """
222 Private slot to display the spelling properties dialog. 235 Private slot to display the spelling properties dialog.
223 """ 236 """
237 from .SpellingPropertiesDialog import SpellingPropertiesDialog
238
224 if self.spellPropertiesDlg is None: 239 if self.spellPropertiesDlg is None:
225 from .SpellingPropertiesDialog import SpellingPropertiesDialog
226
227 self.spellPropertiesDlg = SpellingPropertiesDialog( 240 self.spellPropertiesDlg = SpellingPropertiesDialog(
228 self.project, self.newProject, self 241 self.project, self.newProject, self
229 ) 242 )
230 res = self.spellPropertiesDlg.exec() 243 res = self.spellPropertiesDlg.exec()
231 if res == QDialog.DialogCode.Rejected: 244 if res == QDialog.DialogCode.Rejected:
234 @pyqtSlot() 247 @pyqtSlot()
235 def on_transPropertiesButton_clicked(self): 248 def on_transPropertiesButton_clicked(self):
236 """ 249 """
237 Private slot to display the translations properties dialog. 250 Private slot to display the translations properties dialog.
238 """ 251 """
252 from .TranslationPropertiesDialog import TranslationPropertiesDialog
253
239 if self.transPropertiesDlg is None: 254 if self.transPropertiesDlg is None:
240 from .TranslationPropertiesDialog import TranslationPropertiesDialog
241
242 self.transPropertiesDlg = TranslationPropertiesDialog( 255 self.transPropertiesDlg = TranslationPropertiesDialog(
243 self.project, self.newProject, self 256 self.project, self.newProject, self
244 ) 257 )
245 else: 258 else:
246 self.transPropertiesDlg.initFilters() 259 self.transPropertiesDlg.initFilters()
251 @pyqtSlot() 264 @pyqtSlot()
252 def on_makeButton_clicked(self): 265 def on_makeButton_clicked(self):
253 """ 266 """
254 Private slot to display the make properties dialog. 267 Private slot to display the make properties dialog.
255 """ 268 """
269 from .MakePropertiesDialog import MakePropertiesDialog
270
256 if self.makePropertiesDlg is None: 271 if self.makePropertiesDlg is None:
257 from .MakePropertiesDialog import MakePropertiesDialog
258
259 self.makePropertiesDlg = MakePropertiesDialog( 272 self.makePropertiesDlg = MakePropertiesDialog(
260 self.project, self.newProject, self 273 self.project, self.newProject, self
261 ) 274 )
262 res = self.makePropertiesDlg.exec() 275 res = self.makePropertiesDlg.exec()
263 if res == QDialog.DialogCode.Rejected: 276 if res == QDialog.DialogCode.Rejected:
292 @pyqtSlot() 305 @pyqtSlot()
293 def on_vcsInfoButton_clicked(self): 306 def on_vcsInfoButton_clicked(self):
294 """ 307 """
295 Private slot to display a vcs information dialog. 308 Private slot to display a vcs information dialog.
296 """ 309 """
310 from eric7.VCS.RepositoryInfoDialog import VcsRepositoryInfoDialog
311
297 if self.project.vcs is None: 312 if self.project.vcs is None:
298 return 313 return
299
300 from eric7.VCS.RepositoryInfoDialog import VcsRepositoryInfoDialog
301 314
302 info = self.project.vcs.vcsRepositoryInfos(self.project.ppath) 315 info = self.project.vcs.vcsRepositoryInfos(self.project.ppath)
303 dlg = VcsRepositoryInfoDialog(self, info) 316 dlg = VcsRepositoryInfoDialog(self, info)
304 dlg.exec() 317 dlg.exec()
305 318
331 self.project.name = fn 344 self.project.name = fn
332 fn = "{0}.epj".format(fn) 345 fn = "{0}.epj".format(fn)
333 self.project.pfile = os.path.join(self.project.ppath, fn) 346 self.project.pfile = os.path.join(self.project.ppath, fn)
334 else: 347 else:
335 self.project.pfile = "" 348 self.project.pfile = ""
336 self.project.pdata["VERSION"] = self.versionEdit.text() 349 self.project.setProjectData(self.versionEdit.text(), dataKey="VERSION")
337 fn = self.mainscriptPicker.text() 350 fn = self.mainscriptPicker.text()
338 if fn: 351 if fn:
339 fn = self.project.getRelativePath(fn) 352 fn = self.project.getRelativePath(fn)
340 self.project.pdata["MAINSCRIPT"] = fn 353 self.project.setProjectData(fn, dataKey="MAINSCRIPT")
341 self.project.translationsRoot = os.path.splitext(fn)[0] 354 self.project.translationsRoot = os.path.splitext(fn)[0]
342 else: 355 else:
343 self.project.pdata["MAINSCRIPT"] = "" 356 self.project.setProjectData("", dataKey="MAINSCRIPT")
344 self.project.translationsRoot = "" 357 self.project.translationsRoot = ""
345 self.project.pdata["AUTHOR"] = self.authorEdit.text() 358 self.project.setProjectData(self.authorEdit.text(), dataKey="AUTHOR")
346 self.project.pdata["EMAIL"] = self.emailEdit.text() 359 self.project.setProjectData(self.emailEdit.text(), dataKey="EMAIL")
347 self.project.pdata["DESCRIPTION"] = self.descriptionEdit.toPlainText() 360 self.project.setProjectData(
348 self.project.pdata["PROGLANGUAGE"] = self.languageComboBox.currentText() 361 self.descriptionEdit.toPlainText(), dataKey="DESCRIPTION"
349 self.project.pdata["MIXEDLANGUAGE"] = self.mixedLanguageCheckBox.isChecked() 362 )
363 self.project.setProjectData(
364 self.languageComboBox.currentText(), dataKey="PROGLANGUAGE"
365 )
366 self.project.setProjectData(
367 self.mixedLanguageCheckBox.isChecked(), dataKey="MIXEDLANGUAGE"
368 )
350 projectType = self.getProjectType() 369 projectType = self.getProjectType()
351 if projectType is not None: 370 if projectType is not None:
352 self.project.pdata["PROJECTTYPE"] = projectType 371 self.project.setProjectData(projectType, dataKey="PROJECTTYPE")
353 self.project.pdata["EOL"] = self.eolComboBox.currentIndex() 372 self.project.setProjectData(self.eolComboBox.currentIndex(), dataKey="EOL")
354 373
355 self.project.vcsRequested = self.vcsCheckBox.isChecked() 374 self.project.vcsRequested = self.vcsCheckBox.isChecked()
356 375
357 if self.spellPropertiesDlg is not None: 376 if self.spellPropertiesDlg is not None:
358 self.spellPropertiesDlg.storeData() 377 self.spellPropertiesDlg.storeData()
359 378
360 if self.transPropertiesDlg is not None: 379 if self.transPropertiesDlg is not None:
361 self.transPropertiesDlg.storeData() 380 self.transPropertiesDlg.storeData()
362 381
363 self.project.pdata["MAKEPARAMS"]["MakeEnabled"] = self.makeCheckBox.isChecked() 382 makeParams = self.project.getProjectData(dataKey="MAKEPARAMS")
383 makeParams["MakeEnabled"] = self.makeCheckBox.isChecked()
384 self.project.setProjectData(makeParams, dataKey="MAKEPARAMS")
364 if self.makePropertiesDlg is not None: 385 if self.makePropertiesDlg is not None:
365 self.makePropertiesDlg.storeData() 386 self.makePropertiesDlg.storeData()
366 387
367 self.project.pdata["DOCSTRING"] = self.docstringStyleComboBox.currentData() 388 self.project.setProjectData(
368 389 self.docstringStyleComboBox.currentData(), dataKey="DOCSTRING"
369 self.project.pdata[ 390 )
370 "TESTING_FRAMEWORK" 391
371 ] = self.testingFrameworkComboBox.currentData() 392 self.project.setProjectData(
372 393 self.testingFrameworkComboBox.currentData(), dataKey="TESTING_FRAMEWORK"
373 self.project.pdata["LICENSE"] = self.licenseComboBox.currentText() 394 )
374 395
375 self.project.pdata["EMBEDDED_VENV"] = self.embeddedVenvCheckBox.isChecked() 396 self.project.setProjectData(
397 self.licenseComboBox.currentText(), dataKey="LICENSE"
398 )
399
400 self.project.setProjectData(
401 self.embeddedVenvCheckBox.isChecked(), dataKey="EMBEDDED_VENV"
402 )

eric ide

mercurial