From 88e9d1d7c5747eaaf4e8b0c771df2d617dc79d39 Mon Sep 17 00:00:00 2001 From: Boris Yumankulov Date: Thu, 26 Jun 2025 14:35:24 +0500 Subject: [PATCH] feat(dialogs): add file extension filters for exe and image selection to File Explorer Signed-off-by: Boris Yumankulov --- portprotonqt/dialogs.py | 11 ++++++++--- portprotonqt/input_manager.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/portprotonqt/dialogs.py b/portprotonqt/dialogs.py index cab1a4d..21136fa 100644 --- a/portprotonqt/dialogs.py +++ b/portprotonqt/dialogs.py @@ -89,9 +89,10 @@ class FileSelectedSignal(QObject): class FileExplorer(QDialog): - def __init__(self, parent=None): + def __init__(self, parent=None, file_filter=None): super().__init__(parent) self.file_signal = FileSelectedSignal() + self.file_filter = file_filter # Store the file filter self.setup_ui() # Настройки окна @@ -187,7 +188,11 @@ class FileExplorer(QDialog): items = os.listdir(self.current_path) dirs = [d for d in items if os.path.isdir(os.path.join(self.current_path, d))] + + # Apply file filter if provided files = [f for f in items if os.path.isfile(os.path.join(self.current_path, f))] + if self.file_filter: + files = [f for f in files if f.lower().endswith(self.file_filter)] for d in sorted(dirs): self.file_list.addItem(f"{d}/") @@ -307,7 +312,7 @@ class AddGameDialog(QDialog): def browseExe(self): """Открывает файловый менеджер для выбора exe-файла""" try: - file_explorer = FileExplorer(self) + file_explorer = FileExplorer(self, file_filter='.exe') file_explorer.file_signal.file_selected.connect(self.onExeSelected) if self.parent(): @@ -332,7 +337,7 @@ class AddGameDialog(QDialog): def browseCover(self): """Открывает файловый менеджер для выбора изображения обложки""" try: - file_explorer = FileExplorer(self) + file_explorer = FileExplorer(self, file_filter=('.png', '.jpg', '.jpeg', '.bmp')) file_explorer.file_signal.file_selected.connect(self.onCoverSelected) if self.parent(): diff --git a/portprotonqt/input_manager.py b/portprotonqt/input_manager.py index d5d6b21..4c9f9b6 100644 --- a/portprotonqt/input_manager.py +++ b/portprotonqt/input_manager.py @@ -209,7 +209,7 @@ class InputManager(QObject): self.stick_value = speed_factor self.stick_activated = True - if nöt self.nav_timer.isActive(): + if not self.nav_timer.isActive(): self.file_explorer.move_selection(self.current_direction) self.last_nav_time = current_time self.nav_timer.start(int(self.initial_nav_delay * 1000))