refactor: remove dead code — unused tab_switch_requested signal, scope concept in hotkeys, redundant ipod_tab_index

This commit is contained in:
Maksim Totmin 2026-06-01 20:04:58 +07:00
parent b68b86929b
commit a66446120c
3 changed files with 23 additions and 29 deletions

View File

@ -44,7 +44,6 @@ class MainWindow(QMainWindow):
self.config_loader = ConfigLoader() self.config_loader = ConfigLoader()
self.hotkey_manager: Optional[HotkeyManager] = None self.hotkey_manager: Optional[HotkeyManager] = None
self.device_monitor: Optional[DeviceMonitor] = None self.device_monitor: Optional[DeviceMonitor] = None
self.ipod_tab_index = 1
self.playlist_manager = PlaylistManager() self.playlist_manager = PlaylistManager()
self._sidebar_visible = True self._sidebar_visible = True
@ -287,7 +286,7 @@ class MainWindow(QMainWindow):
"seek_backward": self._seek_backward, "seek_backward": self._seek_backward,
"toggle_sidebar": self._toggle_sidebar, "toggle_sidebar": self._toggle_sidebar,
"tab_library": lambda: self.stack.setCurrentIndex(0), "tab_library": lambda: self.stack.setCurrentIndex(0),
"tab_ipod": lambda: self.stack.setCurrentIndex(self.ipod_tab_index), "tab_ipod": lambda: self.stack.setCurrentIndex(1),
"tab_settings": lambda: self.stack.setCurrentIndex(2), "tab_settings": lambda: self.stack.setCurrentIndex(2),
"search_focus": self.library_tab._focus_search, "search_focus": self.library_tab._focus_search,
"select_all": self.library_tab._select_all_current, "select_all": self.library_tab._select_all_current,

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
""" """
Hotkey Manager for neo-pod-desktop Hotkey Manager for neo-pod-desktop
Provides configurable keyboard shortcuts with scope awareness. Provides configurable keyboard shortcuts.
""" """
import logging import logging
@ -73,28 +73,27 @@ def _is_editable_focused() -> bool:
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Default shortcut definitions # Default shortcut definitions
# (action_name, default_key_string, display_label, scope) # (action_name, default_key_string, display_label)
# scope: "global" — always active; "tab" — handler decides based on current tab
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
DEFAULTS = [ DEFAULTS = [
("play_pause", "Space", "Play / Pause", "global"), ("play_pause", "Space", "Play / Pause"),
("prev_track", "Ctrl+Left", "Previous Track", "global"), ("prev_track", "Ctrl+Left", "Previous Track"),
("next_track", "Ctrl+Right", "Next Track", "global"), ("next_track", "Ctrl+Right", "Next Track"),
("volume_up", "Ctrl+Up", "Volume Up", "global"), ("volume_up", "Ctrl+Up", "Volume Up"),
("volume_down", "Ctrl+Down", "Volume Down", "global"), ("volume_down", "Ctrl+Down", "Volume Down"),
("seek_forward", "Right", "Seek Forward 5s", "global"), ("seek_forward", "Right", "Seek Forward 5s"),
("seek_backward", "Left", "Seek Backward 5s", "global"), ("seek_backward", "Left", "Seek Backward 5s"),
("tab_library", "Ctrl+1", "Switch to Library", "global"), ("tab_library", "Ctrl+1", "Switch to Library"),
("tab_ipod", "Ctrl+2", "Switch to iPod", "global"), ("tab_ipod", "Ctrl+2", "Switch to iPod"),
("tab_settings", "Ctrl+3", "Switch to Settings", "global"), ("tab_settings", "Ctrl+3", "Switch to Settings"),
("search_focus", "Ctrl+F", "Focus Search", "global"), ("search_focus", "Ctrl+F", "Focus Search"),
("select_all", "Ctrl+A", "Select All", "global"), ("select_all", "Ctrl+A", "Select All"),
("library_refresh", "F5", "Refresh Library", "global"), ("library_refresh", "F5", "Refresh Library"),
("ipod_refresh", "Ctrl+R", "Refresh Devices", "global"), ("ipod_refresh", "Ctrl+R", "Refresh Devices"),
("delete_selected", "Delete", "Delete Selected", "global"), ("delete_selected", "Delete", "Delete Selected"),
("edit_metadata", "F2", "Edit Metadata", "global"), ("edit_metadata", "F2", "Edit Metadata"),
("toggle_sidebar", "Ctrl+B", "Toggle Sidebar", "global"), ("toggle_sidebar", "Ctrl+B", "Toggle Sidebar"),
("library_add_files", "Ctrl+O", "Library: Add Files", "global"), ("library_add_files", "Ctrl+O", "Library: Add Files"),
] ]
@ -173,17 +172,15 @@ class HotkeyManager:
self._parent = parent self._parent = parent
self._config_loader = config_loader self._config_loader = config_loader
# action_name → (QShortcut, callback, default_seq, scope) # action_name → (QShortcut, callback, default_seq)
self._shortcuts: Dict[str, QShortcut] = {} self._shortcuts: Dict[str, QShortcut] = {}
self._callbacks: Dict[str, Callable[[], None]] = {} self._callbacks: Dict[str, Callable[[], None]] = {}
self._defaults: Dict[str, QKeySequence] = {} self._defaults: Dict[str, QKeySequence] = {}
self._labels: Dict[str, str] = {} self._labels: Dict[str, str] = {}
self._scopes: Dict[str, str] = {}
for name, key_str, label, scope in DEFAULTS: for name, key_str, label in DEFAULTS:
self._defaults[name] = _build_seq(key_str) self._defaults[name] = _build_seq(key_str)
self._labels[name] = label self._labels[name] = label
self._scopes[name] = scope
# ------------------------------------------------------------------ # ------------------------------------------------------------------
# Registration # Registration
@ -201,7 +198,6 @@ class HotkeyManager:
seq = _build_seq(saved_key) if saved_key else self._defaults.get(action_name, QSeq()) seq = _build_seq(saved_key) if saved_key else self._defaults.get(action_name, QSeq())
self._callbacks[action_name] = callback self._callbacks[action_name] = callback
scope = self._scopes.get(action_name, "global")
context = Qt.ShortcutContext.WindowShortcut context = Qt.ShortcutContext.WindowShortcut
sc = QShortcut(seq, self._parent, context=context) sc = QShortcut(seq, self._parent, context=context)

View File

@ -99,7 +99,6 @@ class LibraryTab(QWidget):
"""Library tab widget with library table, filtering, and transfer workflows.""" """Library tab widget with library table, filtering, and transfer workflows."""
transfer_finished = pyqtSignal() transfer_finished = pyqtSignal()
tab_switch_requested = pyqtSignal(int)
play_requested = pyqtSignal(dict, int, bool) play_requested = pyqtSignal(dict, int, bool)
def __init__(self, config_loader: ConfigLoader, parent=None): def __init__(self, config_loader: ConfigLoader, parent=None):