feat(FileExplorer): add prev dir action on Y and Square thanks to @Vector_null
All checks were successful
Code and build check / Check code (push) Successful in 1m29s
Code and build check / Build with uv (push) Successful in 53s

Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
This commit is contained in:
2025-06-27 10:37:51 +05:00
parent 7fb05322ad
commit 4d7caa33b5
2 changed files with 25 additions and 2 deletions

View File

@ -216,6 +216,26 @@ class FileExplorer(QDialog):
self.file_signal.file_selected.emit(os.path.normpath(full_path))
self.accept()
def previous_dir(self):
"""Возврат к родительской директории"""
try:
if self.current_path == "/":
return # Уже в корне
# Нормализуем путь (убираем конечный слеш, если есть)
normalized_path = os.path.normpath(self.current_path)
# Получаем родительскую директорию
parent_dir = os.path.dirname(normalized_path)
if not parent_dir:
parent_dir = "/"
self.current_path = parent_dir
self.update_file_list()
except Exception as e:
logger.error(f"Error navigating to parent directory: {e}")
def update_drives_list(self):
"""Обновление списка смонтированных дисков"""
for i in reversed(range(self.drives_layout.count())):

View File

@ -44,6 +44,7 @@ BUTTONS = {
'confirm': {ecodes.BTN_SOUTH}, # A (Xbox) / Cross (PS)
'back': {ecodes.BTN_EAST}, # B (Xbox) / Circle (PS)
'add_game': {ecodes.BTN_NORTH}, # X (Xbox) / Triangle (PS)
'prev_dir': {ecodes.BTN_WEST}, # Y (Xbox) / Square (PS)
'prev_tab': {ecodes.BTN_TL}, # LB (Xbox) / L1 (PS)
'next_tab': {ecodes.BTN_TR}, # RB (Xbox) / R1 (PS)
'context_menu': {ecodes.BTN_START}, # Start (Xbox) / Options (PS)
@ -161,10 +162,12 @@ class InputManager(QObject):
if not self.file_explorer or not hasattr(self.file_explorer, 'file_list'):
return
if button_code in BUTTONS['confirm']: # Кнопка A
if button_code in BUTTONS['confirm']:
self.file_explorer.select_item()
elif button_code in BUTTONS['back']: # Кнопка B
elif button_code in BUTTONS['back']:
self.file_explorer.close()
elif button_code in BUTTONS['prev_dir']:
self.file_explorer.previous_dir()
else:
if self.original_button_handler:
self.original_button_handler(button_code)