--- a/eric7/CycloneDXInterface/CycloneDXConfigDialog.py Wed Jun 08 19:13:35 2022 +0200 +++ b/eric7/CycloneDXInterface/CycloneDXConfigDialog.py Thu Jun 09 16:13:18 2022 +0200 @@ -10,7 +10,7 @@ import os from PyQt6.QtCore import pyqtSlot -from PyQt6.QtWidgets import QDialog +from PyQt6.QtWidgets import QDialog, QDialogButtonBox from EricWidgets.EricApplication import ericApp from EricWidgets.EricPathPicker import EricPathPickerModes @@ -60,9 +60,10 @@ self.setupUi(self) if environment == "<project>": - project = ericApp().getObject("Project") - self.__defaultDirectory = project.getProjectPath() + self.__project = ericApp().getObject("Project") + self.__defaultDirectory = self.__project.getProjectPath() else: + self.__project = None venvManager = ericApp().getObject("VirtualEnvManager") self.__defaultDirectory = venvManager.getVirtualenvDirectory( environment) @@ -93,6 +94,12 @@ self.on_fileFormatComboBox_currentTextChanged( CycloneDXConfigDialog.DefaultFileFormat) + self.__metadata = None + self.__metadataButton = self.buttonBox.addButton( + self.tr("Edit Metadata..."), + QDialogButtonBox.ButtonRole.ActionRole) + self.__metadataButton.clicked.connect(self.__editMetaData) + msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) @@ -135,15 +142,44 @@ else: self.filePicker.setFilters(self.tr("All Files (*)")) + @pyqtSlot() + def __editMetaData(self): + """ + Private slot to open a dialog for editing the SBOM metadata. + """ + from .CycloneDXMetaDataDialog import CycloneDXMetaDataDialog + + # populate a metadata dictionary from project data + metadata = ( + { + "Name": self.__project.getProjectName(), + "Type": "", + "Version": self.__project.getProjectVersion(), + "Description": self.__project.getProjectDescription(), + "AuthorName": self.__project.getProjectAuthor(), + "AuthorEmail": self.__project.getProjectAuthorEmail(), + "License": self.__project.getProjectLicense(), + "Manufacturer": "", + "Supplier": "", + } + if self.__metadata is None and self.__project is not None else + self.__metadata + ) + + dlg = CycloneDXMetaDataDialog(metadata=metadata, parent=self) + if dlg.exec() == QDialog.DialogCode.Accepted: + self.__metadata = dlg.getMetaData() + def getData(self): """ Public method to get the SBOM configuration data. @return tuple containing the input source, the input file name, the file format, the schema version, the path of the SBOM file to be - written, a flag indicating to include vulnerability information - and a flag indicating to include dependency information - @rtype tuple of (str, str, str, str, str, bool, bool) + written, a flag indicating to include vulnerability information, + a flag indicating to include dependency information and a + dictionary containing the SBOM meta data + @rtype tuple of (str, str, str, str, str, bool, bool, dict) """ if self.environmentButton.isChecked(): inputSource = "environment" @@ -188,4 +224,5 @@ inputSource, inputFile, fileFormat, schemaVersion, sbomFile, self.vulnerabilityCheckBox.isChecked(), self.dependenciesCheckBox.isChecked(), + self.__metadata )