forked from Boria138/PortProtonQt
Compare commits
2 Commits
48048a3f50
...
03e15d1759
Author | SHA1 | Date | |
---|---|---|---|
03e15d1759
|
|||
0694ea2638
|
@@ -177,6 +177,7 @@ class FileExplorer(QDialog):
|
||||
self.file_list = QListWidget()
|
||||
self.file_list.setStyleSheet(self.theme.FILE_EXPLORER_STYLE)
|
||||
self.file_list.itemClicked.connect(self.handle_item_click)
|
||||
self.file_list.itemDoubleClicked.connect(self.handle_item_double_click) # Подключение двойного клика
|
||||
self.main_layout.addWidget(self.file_list)
|
||||
|
||||
# Кнопки
|
||||
@@ -203,10 +204,33 @@ class FileExplorer(QDialog):
|
||||
self.file_list.scrollToItem(self.file_list.currentItem())
|
||||
|
||||
def handle_item_click(self, item):
|
||||
"""Обработка клика мышью"""
|
||||
"""Обработка одинарного клика мышью"""
|
||||
try:
|
||||
self.file_list.setCurrentItem(item)
|
||||
self.path_history[self.current_path] = item.text() # Save the selected item
|
||||
self.select_item()
|
||||
self.path_history[self.current_path] = item.text() # Сохраняем выбранный элемент
|
||||
logger.debug("Selected item: %s", item.text())
|
||||
except Exception as e:
|
||||
logger.error("Error in handle_item_click: %s", e)
|
||||
|
||||
def handle_item_double_click(self, item):
|
||||
"""Обработка двойного клика мышью по элементу списка"""
|
||||
try:
|
||||
self.file_list.setCurrentItem(item)
|
||||
self.path_history[self.current_path] = item.text() # Сохраняем выбранный элемент
|
||||
selected = item.text()
|
||||
full_path = os.path.join(self.current_path, selected)
|
||||
if os.path.isdir(full_path):
|
||||
if selected == "../":
|
||||
# Переходим в родительскую директорию
|
||||
self.previous_dir()
|
||||
else:
|
||||
# Открываем директорию
|
||||
self.current_path = os.path.normpath(full_path)
|
||||
self.update_file_list()
|
||||
else:
|
||||
logger.debug("Double-clicked item is not a directory, ignoring: %s", full_path)
|
||||
except Exception as e:
|
||||
logger.error("Error in handle_item_double_click: %s", e)
|
||||
|
||||
def select_item(self):
|
||||
"""Обработка выбора файла/папки"""
|
||||
|
@@ -158,7 +158,6 @@ class InputManager(QObject):
|
||||
logger.error(f"Error restoring gamepad handlers: {e}")
|
||||
|
||||
def handle_file_explorer_button(self, button_code):
|
||||
"""Обработка кнопок геймпада для FileExplorer"""
|
||||
try:
|
||||
if not self.file_explorer or not hasattr(self.file_explorer, 'file_list'):
|
||||
return
|
||||
@@ -183,8 +182,12 @@ class InputManager(QObject):
|
||||
# Открываем директорию
|
||||
self.file_explorer.current_path = os.path.normpath(full_path)
|
||||
self.file_explorer.update_file_list()
|
||||
elif not self.file_explorer.directory_only:
|
||||
# Выбираем файл, если directory_only=False
|
||||
self.file_explorer.file_signal.file_selected.emit(os.path.normpath(full_path))
|
||||
self.file_explorer.accept()
|
||||
else:
|
||||
logger.debug("Selected item is not a directory, cannot open: %s", full_path)
|
||||
logger.debug("Selected item is not a directory, cannot select: %s", full_path)
|
||||
elif button_code in BUTTONS['back']:
|
||||
self.file_explorer.close()
|
||||
elif button_code in BUTTONS['prev_dir']:
|
||||
|
Reference in New Issue
Block a user