From a66446120ca8d6e7184476d98122d7f629299c26 Mon Sep 17 00:00:00 2001 From: Maksim Totmin Date: Mon, 1 Jun 2026 20:04:58 +0700 Subject: [PATCH] =?UTF-8?q?refactor:=20remove=20dead=20code=20=E2=80=94=20?= =?UTF-8?q?unused=20tab=5Fswitch=5Frequested=20signal,=20scope=20concept?= =?UTF-8?q?=20in=20hotkeys,=20redundant=20ipod=5Ftab=5Findex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.py | 3 +-- src/hotkeys.py | 48 ++++++++++++++++++++----------------------- src/ui/library_tab.py | 1 - 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/app.py b/src/app.py index d24411f..25fc0be 100644 --- a/src/app.py +++ b/src/app.py @@ -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, diff --git a/src/hotkeys.py b/src/hotkeys.py index 032f68a..1521cb1 100644 --- a/src/hotkeys.py +++ b/src/hotkeys.py @@ -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) diff --git a/src/ui/library_tab.py b/src/ui/library_tab.py index db1741a..7c1cdc3 100644 --- a/src/ui/library_tab.py +++ b/src/ui/library_tab.py @@ -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):