diff --git a/plugins/skill_scanner/plugin.py b/plugins/skill_scanner/plugin.py index bb724c6..f4690aa 100644 --- a/plugins/skill_scanner/plugin.py +++ b/plugins/skill_scanner/plugin.py @@ -150,6 +150,9 @@ class SkillScannerPlugin(BasePlugin): description = "Uses core OCR and Log services" hotkey = "ctrl+shift+s" + # Signal for thread-safe hotkey scanning + hotkey_triggered = pyqtSignal() + def initialize(self): """Setup skill scanner.""" self.data_file = Path("data/skill_tracker.json") @@ -164,6 +167,9 @@ class SkillScannerPlugin(BasePlugin): self.current_scan_session = {} # Skills collected in current multi-page scan self.pages_scanned = 0 + # Connect hotkey signal + self.hotkey_triggered.connect(self._scan_page_for_multi) + # Subscribe to skill gain events from core Log service try: from core.plugin_api import get_api @@ -756,12 +762,9 @@ class SkillScannerPlugin(BasePlugin): self.auto_scan_active = False def _hotkey_scan(self): - """Scan triggered by F12 hotkey.""" - from PyQt6.QtCore import QMetaObject, Qt, Q_ARG - QMetaObject.invokeMethod( - self, "_scan_page_for_multi", - Qt.ConnectionType.QueuedConnection - ) + """Scan triggered by F12 hotkey - thread safe via signal.""" + # Emit signal to safely call from hotkey thread + self.hotkey_triggered.emit() def _check_for_page_change(self): """Auto-detect page changes by monitoring page number area."""