Make sure we refresh when selecting new options

This commit is contained in:
dazedanon 2025-10-28 12:35:53 -05:00
parent 6438387cbd
commit 399447e3ac

View file

@ -1086,6 +1086,9 @@ class TranslationTab(QWidget):
self.mode_combo.setCurrentIndex(index) self.mode_combo.setCurrentIndex(index)
else: else:
self.mode_combo.setCurrentIndex(0) self.mode_combo.setCurrentIndex(0)
# Refresh file list to show only files matching the selected module's extensions
self.refresh_file_lists()
def _toggle_file_checkbox(self, item): def _toggle_file_checkbox(self, item):
"""Toggle checkbox when clicking anywhere on the item.""" """Toggle checkbox when clicking anywhere on the item."""
@ -1164,11 +1167,27 @@ class TranslationTab(QWidget):
except Exception: except Exception:
pass pass
# Get accepted extensions for the currently selected module
accepted_extensions = []
try:
selected_index = self.module_combo.currentIndex()
if 0 <= selected_index < len(self.modules):
accepted_extensions = self.modules[selected_index][1] # List of extensions like [".json", ".yaml"]
except Exception:
pass
# Rebuild the list using simple QListWidgetItems with checkboxes # Rebuild the list using simple QListWidgetItems with checkboxes
self.file_list.clear() self.file_list.clear()
if self.files_dir.exists(): if self.files_dir.exists():
for file_path in sorted(self.files_dir.iterdir()): for file_path in sorted(self.files_dir.iterdir()):
if file_path.is_file() and file_path.name != '.gitkeep': if file_path.is_file() and file_path.name != '.gitkeep':
# Filter by accepted extensions if any are defined
if accepted_extensions:
file_ext = file_path.suffix.lower()
# Skip files that don't match any accepted extension
if not any(file_ext == ext.lower() for ext in accepted_extensions):
continue
item = QListWidgetItem(file_path.name) item = QListWidgetItem(file_path.name)
# Ensure the item is enabled, selectable, and user-checkable # Ensure the item is enabled, selectable, and user-checkable
item.setFlags(item.flags() | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) item.setFlags(item.flags() | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable)