--- a/src/eric7/Project/AddDirectoryDialog.py Wed Nov 16 11:04:18 2022 +0100 +++ b/src/eric7/Project/AddDirectoryDialog.py Wed Nov 16 18:11:52 2022 +0100 @@ -21,7 +21,7 @@ """ def __init__( - self, pro, fileTypeFilter="source", parent=None, name=None, startdir=None + self, pro, fileTypeFilter="SOURCES", parent=None, name=None, startdir=None ): """ Constructor @@ -42,37 +42,30 @@ self.targetDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) self.targetDirPicker.setDefaultDirectory(startdir) - self.ppath = pro.ppath - self.targetDirPicker.setText(self.ppath) - self.on_filterComboBox_highlighted(0) - # enable all dialog elements - if fileTypeFilter == "source": # it is a source file - self.filterComboBox.addItem(self.tr("Source Files"), "SOURCES") - elif fileTypeFilter == "form": - self.filterComboBox.addItem(self.tr("Forms Files"), "FORMS") - elif fileTypeFilter == "resource": - self.filterComboBox.addItem(self.tr("Resource Files"), "RESOURCES") - elif fileTypeFilter == "interface": - self.filterComboBox.addItem(self.tr("Interface Files"), "INTERFACES") - elif fileTypeFilter == "protocol": - self.filterComboBox.addItem(self.tr("Protocol Files"), "PROTOCOLS") - elif fileTypeFilter == "others": - self.filterComboBox.addItem(self.tr("Other Files (*)"), "OTHERS") - self.on_filterComboBox_highlighted(self.filterComboBox.count() - 1) + self.__project = pro + self.targetDirPicker.setText(self.__project.getProjectPath()) + + if fileTypeFilter and fileTypeFilter != "TRANSLATIONS": + self.filterComboBox.addItem( + self.__project.getFileCategoryString(fileTypeFilter), + fileTypeFilter, + ) else: - self.filterComboBox.addItem(self.tr("Source Files"), "SOURCES") - self.filterComboBox.addItem(self.tr("Forms Files"), "FORMS") - self.filterComboBox.addItem(self.tr("Resource Files"), "RESOURCES") - self.filterComboBox.addItem(self.tr("Interface Files"), "INTERFACES") - self.filterComboBox.addItem(self.tr("Protocol Files"), "PROTOCOLS") - self.filterComboBox.addItem(self.tr("Other Files (*)"), "OTHERS") + for fileCategory in sorted( + c for c in self.__project.getFileCategories() + if c != "TRANSLATIONS" + ): + self.filterComboBox.addItem( + self.__project.getFileCategoryString(fileCategory), + fileCategory, + ) self.filterComboBox.setCurrentIndex(0) msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) @pyqtSlot(int) - def on_filterComboBox_highlighted(self, index): + def on_filterComboBox_currentIndexChanged(self, index): """ Private slot to handle the selection of a file type. @@ -102,7 +95,7 @@ @param directory the text of the source directory line edit (string) """ - if directory.startswith(self.ppath): + if directory.startswith(self.__project.getProjectPath()): self.targetDirPicker.setText(directory) def getData(self):