eric7/Project/PropertiesDialog.py

branch
eric7-maintenance
changeset 9111
4ac66b6c33a4
parent 8881
54e42bc2437a
child 9192
a763d57e23bc
equal deleted inserted replaced
9049:2b9bd8f97576 9111:4ac66b6c33a4
5 5
6 """ 6 """
7 Module implementing the project properties dialog. 7 Module implementing the project properties dialog.
8 """ 8 """
9 9
10 import contextlib
10 import os 11 import os
11 12
12 from PyQt6.QtCore import QDir, pyqtSlot 13 from PyQt6.QtCore import QDir, pyqtSlot
13 from PyQt6.QtWidgets import QDialog, QDialogButtonBox 14 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
14 15
16 from EricWidgets.EricPathPicker import EricPathPickerModes 17 from EricWidgets.EricPathPicker import EricPathPickerModes
17 18
18 from .Ui_PropertiesDialog import Ui_PropertiesDialog 19 from .Ui_PropertiesDialog import Ui_PropertiesDialog
19 20
20 from QScintilla.DocstringGenerator import getSupportedDocstringTypes 21 from QScintilla.DocstringGenerator import getSupportedDocstringTypes
22
23 from Testing.Interfaces import FrameworkNames
21 24
22 import Utilities 25 import Utilities
23 import Preferences 26 import Preferences
24 import UI.PixmapCache 27 import UI.PixmapCache
25 28
131 self.makeCheckBox.setChecked( 134 self.makeCheckBox.setChecked(
132 self.project.pdata["MAKEPARAMS"]["MakeEnabled"]) 135 self.project.pdata["MAKEPARAMS"]["MakeEnabled"])
133 cindex = self.docstringStyleComboBox.findData( 136 cindex = self.docstringStyleComboBox.findData(
134 self.project.pdata["DOCSTRING"]) 137 self.project.pdata["DOCSTRING"])
135 self.docstringStyleComboBox.setCurrentIndex(cindex) 138 self.docstringStyleComboBox.setCurrentIndex(cindex)
139 with contextlib.suppress(KeyError):
140 cindex = self.testingFrameworkComboBox.findData(
141 self.project.pdata["TESTING_FRAMEWORK"])
142 self.testingFrameworkComboBox.setCurrentIndex(cindex)
136 else: 143 else:
137 self.languageComboBox.setCurrentIndex( 144 self.languageComboBox.setCurrentIndex(
138 self.languageComboBox.findText("Python3")) 145 self.languageComboBox.findText("Python3"))
139 self.projectTypeComboBox.setCurrentIndex( 146 self.projectTypeComboBox.setCurrentIndex(
140 self.projectTypeComboBox.findData("PyQt6")) 147 self.projectTypeComboBox.findData("PyQt6"))
147 154
148 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( 155 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
149 bool(self.dirPicker.text()) and 156 bool(self.dirPicker.text()) and
150 self.dirPicker.text() not in self.__initPaths) 157 self.dirPicker.text() not in self.__initPaths)
151 158
152 @pyqtSlot(int) 159 @pyqtSlot(str)
153 def on_languageComboBox_currentIndexChanged(self, index): 160 def on_languageComboBox_currentTextChanged(self, language):
154 """ 161 """
155 Private slot handling the selection of a programming language. 162 Private slot handling the selection of a programming language.
156 163
157 @param index index of the current item 164 @param language text of the current item
158 @type int 165 @type str
159 """ 166 """
160 language = self.languageComboBox.itemText(index)
161 curProjectType = self.getProjectType() 167 curProjectType = self.getProjectType()
162 168
163 projectTypes = []
164 for projectTypeItem in self.project.getProjectTypes(language).items():
165 projectTypes.append((projectTypeItem[1], projectTypeItem[0]))
166 self.projectTypeComboBox.clear() 169 self.projectTypeComboBox.clear()
167 for projectType in sorted(projectTypes): 170 for projectType in sorted(
171 self.project.getProjectTypes(language).items(),
172 key=lambda k: k[1]
173 ):
168 self.projectTypeComboBox.addItem( 174 self.projectTypeComboBox.addItem(
169 projectType[0], projectType[1]) 175 projectType[1], projectType[0])
170 176
171 index = self.projectTypeComboBox.findData(curProjectType) 177 index = self.projectTypeComboBox.findData(curProjectType)
172 if index == -1: 178 if index == -1:
173 index = 0 179 index = 0
174 self.projectTypeComboBox.setCurrentIndex(index) 180 self.projectTypeComboBox.setCurrentIndex(index)
181
182 curTestingFramework = self.testingFrameworkComboBox.currentText()
183 self.testingFrameworkComboBox.clear()
184 self.testingFrameworkComboBox.addItem(self.tr("None"), "")
185 with contextlib.suppress(KeyError):
186 for framework in sorted(FrameworkNames[language]):
187 self.testingFrameworkComboBox.addItem(framework, framework)
188 self.testingFrameworkComboBox.setCurrentText(curTestingFramework)
175 189
176 @pyqtSlot(str) 190 @pyqtSlot(str)
177 def on_dirPicker_textChanged(self, txt): 191 def on_dirPicker_textChanged(self, txt):
178 """ 192 """
179 Private slot to handle a change of the project directory. 193 Private slot to handle a change of the project directory.
333 self.makePropertiesDlg.storeData() 347 self.makePropertiesDlg.storeData()
334 348
335 self.project.pdata["DOCSTRING"] = ( 349 self.project.pdata["DOCSTRING"] = (
336 self.docstringStyleComboBox.currentData() 350 self.docstringStyleComboBox.currentData()
337 ) 351 )
352
353 self.project.pdata["TESTING_FRAMEWORK"] = (
354 self.testingFrameworkComboBox.currentData()
355 )

eric ide

mercurial