feat(file-explorer): add automatic scrolling for drives layout
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
This commit is contained in:
@@ -298,6 +298,17 @@ class FileExplorer(QDialog):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error navigating to parent directory: {e}")
|
logger.error(f"Error navigating to parent directory: {e}")
|
||||||
|
|
||||||
|
def ensure_button_visible(self, button):
|
||||||
|
"""Ensure the specified button is visible in the drives_scroll area."""
|
||||||
|
try:
|
||||||
|
if not button or not self.drives_scroll:
|
||||||
|
return
|
||||||
|
# Ensure the button is visible in the scroll area
|
||||||
|
self.drives_scroll.ensureWidgetVisible(button, 50, 50)
|
||||||
|
logger.debug(f"Ensured button {button.text()} is visible in drives_scroll")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error ensuring button visible: {e}")
|
||||||
|
|
||||||
def update_drives_list(self):
|
def update_drives_list(self):
|
||||||
"""Обновление списка смонтированных дисков и избранных папок."""
|
"""Обновление списка смонтированных дисков и избранных папок."""
|
||||||
for i in reversed(range(self.drives_layout.count())):
|
for i in reversed(range(self.drives_layout.count())):
|
||||||
|
@@ -256,14 +256,17 @@ class InputManager(QObject):
|
|||||||
if not isinstance(focused_widget, AutoSizeButton) or focused_widget not in self.file_explorer.drive_buttons:
|
if not isinstance(focused_widget, AutoSizeButton) or focused_widget not in self.file_explorer.drive_buttons:
|
||||||
# If not focused on a drive button, focus the first one
|
# If not focused on a drive button, focus the first one
|
||||||
self.file_explorer.drive_buttons[0].setFocus()
|
self.file_explorer.drive_buttons[0].setFocus()
|
||||||
|
self.file_explorer.ensure_button_visible(self.file_explorer.drive_buttons[0])
|
||||||
return
|
return
|
||||||
current_idx = self.file_explorer.drive_buttons.index(focused_widget)
|
current_idx = self.file_explorer.drive_buttons.index(focused_widget)
|
||||||
if value < 0: # Left
|
if value < 0: # Left
|
||||||
next_idx = max(current_idx - 1, 0)
|
next_idx = max(current_idx - 1, 0)
|
||||||
self.file_explorer.drive_buttons[next_idx].setFocus()
|
self.file_explorer.drive_buttons[next_idx].setFocus()
|
||||||
|
self.file_explorer.ensure_button_visible(self.file_explorer.drive_buttons[next_idx])
|
||||||
elif value > 0: # Right
|
elif value > 0: # Right
|
||||||
next_idx = min(current_idx + 1, len(self.file_explorer.drive_buttons) - 1)
|
next_idx = min(current_idx + 1, len(self.file_explorer.drive_buttons) - 1)
|
||||||
self.file_explorer.drive_buttons[next_idx].setFocus()
|
self.file_explorer.drive_buttons[next_idx].setFocus()
|
||||||
|
self.file_explorer.ensure_button_visible(self.file_explorer.drive_buttons[next_idx])
|
||||||
elif code in (ecodes.ABS_HAT0Y, ecodes.ABS_Y):
|
elif code in (ecodes.ABS_HAT0Y, ecodes.ABS_Y):
|
||||||
if isinstance(focused_widget, AutoSizeButton) and focused_widget in self.file_explorer.drive_buttons:
|
if isinstance(focused_widget, AutoSizeButton) and focused_widget in self.file_explorer.drive_buttons:
|
||||||
# Move focus to file list if navigating down from drive buttons
|
# Move focus to file list if navigating down from drive buttons
|
||||||
|
Reference in New Issue
Block a user