src/eric7/CodeFormatting/BlackConfigurationDialog.py

branch
eric7
changeset 9337
073b872fce59
parent 9222
e384c0e986be
child 9341
3dc887a49403
equal deleted inserted replaced
9336:c94f53ab789a 9337:073b872fce59
29 class BlackConfigurationDialog(QDialog, Ui_BlackConfigurationDialog): 29 class BlackConfigurationDialog(QDialog, Ui_BlackConfigurationDialog):
30 """ 30 """
31 Class implementing a dialog to enter the parameters for a Black formatting run. 31 Class implementing a dialog to enter the parameters for a Black formatting run.
32 """ 32 """
33 33
34 def __init__(self, withProject=True, parent=None): 34 def __init__(self, withProject=True, onlyProject=False, parent=None):
35 """ 35 """
36 Constructor 36 Constructor
37 37
38 @param withProject flag indicating to look for project configurations 38 @param withProject flag indicating to look for project configurations
39 (defaults to True) 39 (defaults to True)
40 @type bool 40 @type bool (optional)
41 @param onlyProject flag indicating to only look for project configurations
42 (defaults to False)
43 @type bool (optional)
41 @param parent reference to the parent widget (defaults to None) 44 @param parent reference to the parent widget (defaults to None)
42 @type QWidget (optional) 45 @type QWidget (optional)
43 """ 46 """
44 super().__init__(parent) 47 super().__init__(parent)
45 self.setupUi(self) 48 self.setupUi(self)
46 49
47 self.__project = ericApp().getObject("Project") if withProject else None 50 self.__project = (
51 ericApp().getObject("Project") if (withProject or onlyProject) else None
52 )
48 53
49 indentTabWidth = ( 54 indentTabWidth = (
50 QFontMetricsF(self.excludeEdit.font()).horizontalAdvance(" ") * 2 55 QFontMetricsF(self.excludeEdit.font()).horizontalAdvance(" ") * 2
51 ) 56 )
52 self.excludeEdit.document().setIndentWidth(indentTabWidth) 57 self.excludeEdit.document().setIndentWidth(indentTabWidth)
82 if self.__project.getData("OTHERTOOLSPARMS", "Black") is not None: 87 if self.__project.getData("OTHERTOOLSPARMS", "Black") is not None:
83 self.__projectData = copy.deepcopy( 88 self.__projectData = copy.deepcopy(
84 self.__project.getData("OTHERTOOLSPARMS", "Black") 89 self.__project.getData("OTHERTOOLSPARMS", "Black")
85 ) 90 )
86 self.sourceComboBox.addItem(self.tr("Project File"), "project") 91 self.sourceComboBox.addItem(self.tr("Project File"), "project")
87 self.sourceComboBox.addItem(self.tr("Defaults"), "default") 92 if not onlyProject:
88 self.sourceComboBox.addItem(self.tr("Configuration Below"), "dialog") 93 self.sourceComboBox.addItem(self.tr("Defaults"), "default")
94 self.sourceComboBox.addItem(self.tr("Configuration Below"), "dialog")
89 95
90 self.__populateTargetVersionsList() 96 self.__populateTargetVersionsList()
91 97
92 if self.__projectData: 98 if self.__projectData:
93 source = self.__projectData.get("source", "") 99 source = self.__projectData.get("source", "")

eric ide

mercurial