import os import sys import threading import logging from PyQt5.QtWidgets import QApplication, QWidget from PyQt5.QtCore import Qt, QPoint, QRect, QMetaObject, Q_ARG from PyQt5.QtGui import QPainter, QPen, QColor logger = logging.getLogger(__name__) def _setup_qt_env(): """Point Qt at its bundled platform plugins when running as a frozen PyInstaller exe.""" if getattr(sys, 'frozen', False): meipass = getattr(sys, '_MEIPASS', '') if meipass: plugin_path = os.path.join(meipass, 'PyQt5', 'Qt5', 'plugins') if os.path.isdir(plugin_path): os.environ.setdefault('QT_PLUGIN_PATH', plugin_path) logger.info(f"JARVIS 10X: QT_PLUGIN_PATH set to {plugin_path}") else: # No platform plugins bundled — run headless to avoid qFatal abort os.environ.setdefault('QT_QPA_PLATFORM', 'offscreen') logger.warning("JARVIS 10X: Qt platform plugins not found; switching to offscreen mode") _setup_qt_env() class OverlayWindow(QWidget): def __init__(self): super().__init__() self.vectors = [] self.audio_only_mode = False self.initUI() def initUI(self): # Full screen, frameless, transparent, click-through self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Tool | Qt.WindowTransparentForInput) self.setAttribute(Qt.WA_TranslucentBackground) self.setAttribute(Qt.WA_NoSystemBackground) # Enforce strict Windows hooks for true MPO / TopLevel transparency try: import win32gui import win32con hwnd = int(self.winId()) ex_style = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, ex_style | win32con.WS_EX_LAYERED | win32con.WS_EX_TRANSPARENT | win32con.WS_EX_TOPMOST) except Exception as e: logger.error(f"JARVIS 10X Overlay Setup Error: {e}") self.showMaximized() def paintEvent(self, event): if self.audio_only_mode: return painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) # ZERO TEXT UI RULE: Explicitly not implementing drawText # Only tactical vector rendering for vec in self.vectors: color = QColor(vec.get('color', '#00FF00')) pen = QPen(color, vec.get('thickness', 3), Qt.SolidLine) painter.setPen(pen) shape = vec.get('type') if shape == 'line': painter.drawLine(vec['x1'], vec['y1'], vec['x2'], vec['y2']) elif shape == 'rect': painter.drawRect(QRect(vec['x'], vec['y'], vec['w'], vec['h'])) elif shape == 'ellipse': painter.drawEllipse(QPoint(vec['x'], vec['y']), vec['rx'], vec['ry']) def update_vectors(self, vectors): self.vectors = vectors self.update() def update_indicator(self, dqi_score: float, decision_type: str): # ZERO-TEXT UI if dqi_score > 75: self.current_color = '#00FF00' # Green elif dqi_score < 40: self.current_color = '#FF0000' # Red else: self.current_color = '#FFFF00' # Yellow # Add a pulsing ring to the vector queue self.vectors.append({ 'type': 'ellipse', 'x': 50, 'y': 50, 'rx': 30, 'ry': 30, 'color': self.current_color, 'thickness': 4 }) self.update() def make_click_through(self): try: import win32gui import win32con hwnd = int(self.winId()) ex_style = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, ex_style | win32con.WS_EX_LAYERED | win32con.WS_EX_TRANSPARENT | win32con.WS_EX_TOPMOST) except Exception as e: logger.error(f"JARVIS 10X Click-Through Error: {e}") _app = None _windows = [] def start_overlay(): global _app if _app is None: _app = QApplication(sys.argv) from PyQt5.QtWidgets import QDesktopWidget desktop = QDesktopWidget() for i in range(desktop.screenCount()): geometry = desktop.screenGeometry(i) overlay = OverlayWindow() overlay.setGeometry(geometry) overlay.make_click_through() overlay.show() _windows.append(overlay) _app.exec_() def run_overlay_in_background(): t = threading.Thread(target=start_overlay, daemon=True) t.start() logger.info("JARVIS 10X: Top-Level Transparent Overlay (MPO) Started") def push_overlay_vectors(vectors): for w in _windows: QMetaObject.invokeMethod(w, "update_vectors", Qt.QueuedConnection, Q_ARG(list, vectors)) def trigger_failsafe(enabled: bool): pass # Replaced by click-through transparent logic