refactor: remove dead code — unused tab_switch_requested signal, scope concept in hotkeys, redundant ipod_tab_index
This commit is contained in:
parent
b68b86929b
commit
a66446120c
@ -44,7 +44,6 @@ class MainWindow(QMainWindow):
|
||||
self.config_loader = ConfigLoader()
|
||||
self.hotkey_manager: Optional[HotkeyManager] = None
|
||||
self.device_monitor: Optional[DeviceMonitor] = None
|
||||
self.ipod_tab_index = 1
|
||||
|
||||
self.playlist_manager = PlaylistManager()
|
||||
self._sidebar_visible = True
|
||||
@ -287,7 +286,7 @@ class MainWindow(QMainWindow):
|
||||
"seek_backward": self._seek_backward,
|
||||
"toggle_sidebar": self._toggle_sidebar,
|
||||
"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),
|
||||
"search_focus": self.library_tab._focus_search,
|
||||
"select_all": self.library_tab._select_all_current,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Hotkey Manager for neo-pod-desktop
|
||||
Provides configurable keyboard shortcuts with scope awareness.
|
||||
Provides configurable keyboard shortcuts.
|
||||
"""
|
||||
|
||||
import logging
|
||||
@ -73,28 +73,27 @@ def _is_editable_focused() -> bool:
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Default shortcut definitions
|
||||
# (action_name, default_key_string, display_label, scope)
|
||||
# scope: "global" — always active; "tab" — handler decides based on current tab
|
||||
# (action_name, default_key_string, display_label)
|
||||
# ---------------------------------------------------------------------------
|
||||
DEFAULTS = [
|
||||
("play_pause", "Space", "Play / Pause", "global"),
|
||||
("prev_track", "Ctrl+Left", "Previous Track", "global"),
|
||||
("next_track", "Ctrl+Right", "Next Track", "global"),
|
||||
("volume_up", "Ctrl+Up", "Volume Up", "global"),
|
||||
("volume_down", "Ctrl+Down", "Volume Down", "global"),
|
||||
("seek_forward", "Right", "Seek Forward 5s", "global"),
|
||||
("seek_backward", "Left", "Seek Backward 5s", "global"),
|
||||
("tab_library", "Ctrl+1", "Switch to Library", "global"),
|
||||
("tab_ipod", "Ctrl+2", "Switch to iPod", "global"),
|
||||
("tab_settings", "Ctrl+3", "Switch to Settings", "global"),
|
||||
("search_focus", "Ctrl+F", "Focus Search", "global"),
|
||||
("select_all", "Ctrl+A", "Select All", "global"),
|
||||
("library_refresh", "F5", "Refresh Library", "global"),
|
||||
("ipod_refresh", "Ctrl+R", "Refresh Devices", "global"),
|
||||
("delete_selected", "Delete", "Delete Selected", "global"),
|
||||
("edit_metadata", "F2", "Edit Metadata", "global"),
|
||||
("toggle_sidebar", "Ctrl+B", "Toggle Sidebar", "global"),
|
||||
("library_add_files", "Ctrl+O", "Library: Add Files", "global"),
|
||||
("play_pause", "Space", "Play / Pause"),
|
||||
("prev_track", "Ctrl+Left", "Previous Track"),
|
||||
("next_track", "Ctrl+Right", "Next Track"),
|
||||
("volume_up", "Ctrl+Up", "Volume Up"),
|
||||
("volume_down", "Ctrl+Down", "Volume Down"),
|
||||
("seek_forward", "Right", "Seek Forward 5s"),
|
||||
("seek_backward", "Left", "Seek Backward 5s"),
|
||||
("tab_library", "Ctrl+1", "Switch to Library"),
|
||||
("tab_ipod", "Ctrl+2", "Switch to iPod"),
|
||||
("tab_settings", "Ctrl+3", "Switch to Settings"),
|
||||
("search_focus", "Ctrl+F", "Focus Search"),
|
||||
("select_all", "Ctrl+A", "Select All"),
|
||||
("library_refresh", "F5", "Refresh Library"),
|
||||
("ipod_refresh", "Ctrl+R", "Refresh Devices"),
|
||||
("delete_selected", "Delete", "Delete Selected"),
|
||||
("edit_metadata", "F2", "Edit Metadata"),
|
||||
("toggle_sidebar", "Ctrl+B", "Toggle Sidebar"),
|
||||
("library_add_files", "Ctrl+O", "Library: Add Files"),
|
||||
]
|
||||
|
||||
|
||||
@ -173,17 +172,15 @@ class HotkeyManager:
|
||||
self._parent = parent
|
||||
self._config_loader = config_loader
|
||||
|
||||
# action_name → (QShortcut, callback, default_seq, scope)
|
||||
# action_name → (QShortcut, callback, default_seq)
|
||||
self._shortcuts: Dict[str, QShortcut] = {}
|
||||
self._callbacks: Dict[str, Callable[[], None]] = {}
|
||||
self._defaults: Dict[str, QKeySequence] = {}
|
||||
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._labels[name] = label
|
||||
self._scopes[name] = scope
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Registration
|
||||
@ -201,7 +198,6 @@ class HotkeyManager:
|
||||
seq = _build_seq(saved_key) if saved_key else self._defaults.get(action_name, QSeq())
|
||||
self._callbacks[action_name] = callback
|
||||
|
||||
scope = self._scopes.get(action_name, "global")
|
||||
context = Qt.ShortcutContext.WindowShortcut
|
||||
|
||||
sc = QShortcut(seq, self._parent, context=context)
|
||||
|
||||
@ -99,7 +99,6 @@ class LibraryTab(QWidget):
|
||||
"""Library tab widget with library table, filtering, and transfer workflows."""
|
||||
|
||||
transfer_finished = pyqtSignal()
|
||||
tab_switch_requested = pyqtSignal(int)
|
||||
play_requested = pyqtSignal(dict, int, bool)
|
||||
|
||||
def __init__(self, config_loader: ConfigLoader, parent=None):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user