Sync from development - prepare for v0.5.0.4

This commit is contained in:
Omni
2026-03-29 15:46:37 +01:00
parent 8e4dd06f11
commit c3551cd269
55 changed files with 334 additions and 333 deletions

View File

@@ -86,6 +86,7 @@ class ConfigureNewModlistDialogsMixin:
def cleanup_processes(self):
"""Clean up any running processes when the window closes or is cancelled"""
self._stop_focus_reclaim()
if hasattr(self, 'file_progress_list'):
self.file_progress_list.stop_cpu_tracking()

View File

@@ -501,6 +501,7 @@ class InstallMO2Screen(ScreenBackMixin, FocusReclaimMixin, QWidget):
def cleanup_processes(self):
"""Stop active MO2 worker and CPU tracking before screen/app shutdown."""
self._stop_focus_reclaim()
try:
self.file_progress_list.stop_cpu_tracking()
except Exception:

View File

@@ -419,6 +419,9 @@ class InstallModlistScreen(ScreenBackMixin, InstallModlistUISetupMixin, ConsoleO
self._vnv_controller.cleanup()
self._vnv_controller = None
self._stop_focus_reclaim()
def _stop_thread(attr_name: str, cancel_method: Optional[str] = None, cooperative_ms: int = 5000, force_ms: int = 10000):
thread = getattr(self, attr_name, None)
if thread is None:

View File

@@ -44,9 +44,7 @@ class ConfigurationPhaseMixin(FocusReclaimMixin, InstallModlistShortcutDialogMix
pass
finally:
self.steam_restart_progress = None
# Controls are managed by the proper control management system.
# Reclaim focus with bounded retries because Steam restart timing varies.
self._start_focus_reclaim_retries()
pass
def _detect_game_type_from_mo2_ini(self, install_dir: str) -> str:
"""Detect game type by checking ModOrganizer.ini for loader executables."""

View File

@@ -15,44 +15,19 @@ class FocusReclaimMixin:
progress messages for STEAM_RESTART_SENTINEL.
"""
def _start_focus_reclaim_retries(self):
try:
if hasattr(self, "_focus_reclaim_timer") and self._focus_reclaim_timer:
self._focus_reclaim_timer.stop()
self._focus_reclaim_timer.deleteLater()
except Exception:
pass
def _stop_focus_reclaim(self):
pass # No timer to stop — single-shot, no state
self._focus_reclaim_attempt = 0
self._focus_reclaim_max_attempts = 12 # ~24 seconds total
self._focus_reclaim_timer = QTimer(self)
self._focus_reclaim_timer.setInterval(2000)
self._focus_reclaim_timer.timeout.connect(self._focus_reclaim_tick)
self._focus_reclaim_timer.start()
self._focus_reclaim_tick()
def _start_focus_reclaim_retries(self):
QTimer.singleShot(500, self._focus_reclaim_tick)
def _focus_reclaim_tick(self):
try:
win = self.window()
if win is None:
return
self._focus_reclaim_attempt += 1
win.raise_()
win.activateWindow()
win.setWindowState(win.windowState() & ~Qt.WindowMinimized | Qt.WindowActive)
if win.isActiveWindow():
logger.info("Foreground focus reclaimed after Steam restart")
self._focus_reclaim_timer.stop()
return
if self._focus_reclaim_attempt >= self._focus_reclaim_max_attempts:
logger.warning("Foreground focus reclaim timed out after Steam restart")
self._focus_reclaim_timer.stop()
except Exception as e:
logger.debug(f"Focus reclaim tick failed: {e}")
try:
self._focus_reclaim_timer.stop()
except Exception:
pass
logger.debug(f"Focus reclaim attempt failed: {e}")

View File

@@ -624,6 +624,9 @@ class WabbajackInstallerScreen(ScreenBackMixin, FocusReclaimMixin, QWidget):
self.collapse_show_details_before_leave()
self.go_back()
def cleanup_processes(self):
self._stop_focus_reclaim()
def showEvent(self, event):
"""Called when widget becomes visible"""
super().showEvent(event)