feat: auto-detect iPod connection via QTimer polling + fix AlreadyMounted in _mount_linux

This commit is contained in:
Maksim Totmin
2026-06-01 12:29:43 +07:00
parent 71d162520c
commit 25bb8105ac
5 changed files with 97 additions and 1 deletions
+15
View File
@@ -11,6 +11,7 @@ from PyQt6.QtWidgets import (
from PyQt6.QtCore import Qt, pyqtSignal
from ipod_device import IPodDevice
from device_monitor import DeviceMonitor
from worker import WorkerThread
logger = logging.getLogger(__name__)
@@ -486,6 +487,20 @@ class iPodTab(QWidget):
QMessageBox.information(self, "Duplicates" if success else "Error", message)
self._cleanup_worker()
def start_monitoring(self, monitor: DeviceMonitor):
monitor.state_changed.connect(self._on_auto_state_changed)
def stop_monitoring(self, monitor: DeviceMonitor):
try:
monitor.state_changed.disconnect(self._on_auto_state_changed)
except TypeError:
pass
def _on_auto_state_changed(self, devices):
if self.worker_thread and self.worker_thread.isRunning():
return
self._on_device_detection_finished(True, f"Found {len(devices)} devices", devices)
def _cleanup_worker(self):
if self.worker_thread:
self.worker_thread.wait(3000)
+3 -1
View File
@@ -20,6 +20,7 @@ class SettingsTab(QWidget):
"""Settings tab widget."""
hide_library_buttons_changed = pyqtSignal(bool)
auto_detect_changed = pyqtSignal(bool)
def __init__(self, parent=None):
super().__init__(parent)
@@ -80,8 +81,9 @@ class SettingsTab(QWidget):
self.clean_temp_check.setChecked(True)
advanced_layout.addWidget(self.clean_temp_check)
self.auto_detect_check = QCheckBox("Auto-Detect iPod on Startup")
self.auto_detect_check = QCheckBox("Auto-Detect iPod")
self.auto_detect_check.setChecked(True)
self.auto_detect_check.toggled.connect(self.auto_detect_changed.emit)
advanced_layout.addWidget(self.auto_detect_check)
self.hide_library_buttons_check = QCheckBox("Hide Library Toolbar Buttons")