mirror of
https://github.com/Omni-guides/Jackify.git
synced 2026-06-17 15:57:44 +02:00
Sync from development - prepare for v0.3.0
This commit is contained in:
155
jackify/frontends/gui/screens/install_ttw_lifecycle.py
Normal file
155
jackify/frontends/gui/screens/install_ttw_lifecycle.py
Normal file
@@ -0,0 +1,155 @@
|
||||
"""Window lifecycle and resize handlers for InstallTTWScreen (Mixin)."""
|
||||
from PySide6.QtCore import QTimer, QSize, Qt
|
||||
from PySide6.QtGui import QResizeEvent
|
||||
from ..utils import set_responsive_minimum
|
||||
|
||||
|
||||
def debug_print(message):
|
||||
"""Print debug message only if debug mode is enabled"""
|
||||
from jackify.backend.handlers.config_handler import ConfigHandler
|
||||
config_handler = ConfigHandler()
|
||||
if config_handler.get('debug_mode', False):
|
||||
print(message)
|
||||
|
||||
|
||||
class TTWLifecycleMixin:
|
||||
"""Mixin providing window lifecycle and resize management for InstallTTWScreen."""
|
||||
|
||||
def force_collapsed_state(self):
|
||||
"""Force the screen into its collapsed state regardless of prior layout.
|
||||
|
||||
This is used to resolve timing/race conditions when navigating here from
|
||||
the end of the Install Modlist workflow, ensuring the UI opens collapsed
|
||||
just like when launched from Additional Tasks.
|
||||
"""
|
||||
try:
|
||||
from PySide6.QtCore import Qt as _Qt
|
||||
# Ensure checkbox is unchecked without emitting user-facing signals
|
||||
if self.show_details_checkbox.isChecked():
|
||||
self.show_details_checkbox.blockSignals(True)
|
||||
self.show_details_checkbox.setChecked(False)
|
||||
self.show_details_checkbox.blockSignals(False)
|
||||
# Apply collapsed layout explicitly
|
||||
self._toggle_console_visibility(_Qt.Unchecked)
|
||||
# Inform parent window to collapse height
|
||||
try:
|
||||
self.resize_request.emit('collapse')
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def resizeEvent(self, event):
|
||||
"""Handle window resize to prioritize form over console"""
|
||||
super().resizeEvent(event)
|
||||
self._adjust_console_for_form_priority()
|
||||
|
||||
def _adjust_console_for_form_priority(self):
|
||||
"""Console now dynamically fills available space with stretch=1, no manual calculation needed"""
|
||||
# The console automatically fills remaining space due to stretch=1 in the layout
|
||||
# Remove any fixed height constraints to allow natural stretching
|
||||
self.console.setMaximumHeight(16777215) # Reset to default maximum
|
||||
# Only enforce a small minimum when details are shown; keep 0 when collapsed
|
||||
if self.console.isVisible():
|
||||
self.console.setMinimumHeight(50)
|
||||
else:
|
||||
self.console.setMinimumHeight(0)
|
||||
|
||||
def showEvent(self, event):
|
||||
"""Called when the widget becomes visible"""
|
||||
super().showEvent(event)
|
||||
debug_print(f"DEBUG: TTW showEvent - integration_mode={self._integration_mode}")
|
||||
|
||||
# Check TTW_Linux_Installer status asynchronously (non-blocking) after screen opens
|
||||
from PySide6.QtCore import QTimer
|
||||
QTimer.singleShot(0, self._check_ttw_installer_status)
|
||||
|
||||
# Ensure initial collapsed layout each time this screen is opened
|
||||
try:
|
||||
from PySide6.QtCore import Qt as _Qt
|
||||
# On Steam Deck: keep expanded layout and hide the details toggle
|
||||
try:
|
||||
is_steamdeck = False
|
||||
# Check our own system_info first
|
||||
if self.system_info and getattr(self.system_info, 'is_steamdeck', False):
|
||||
is_steamdeck = True
|
||||
# Fallback to checking parent window's system_info
|
||||
elif not self.system_info:
|
||||
parent = self.window()
|
||||
if parent and hasattr(parent, 'system_info') and getattr(parent.system_info, 'is_steamdeck', False):
|
||||
is_steamdeck = True
|
||||
|
||||
if is_steamdeck:
|
||||
debug_print("DEBUG: Steam Deck detected, keeping expanded")
|
||||
# Force expanded state and hide checkbox
|
||||
if self.show_details_checkbox.isVisible():
|
||||
self.show_details_checkbox.setVisible(False)
|
||||
# Show console with proper sizing for Steam Deck
|
||||
self.console.setVisible(True)
|
||||
self.console.show()
|
||||
self.console.setMinimumHeight(200)
|
||||
self.console.setMaximumHeight(16777215) # Remove height limit
|
||||
return
|
||||
except Exception as e:
|
||||
debug_print(f"DEBUG: Steam Deck check exception: {e}")
|
||||
pass
|
||||
debug_print(f"DEBUG: Checkbox checked={self.show_details_checkbox.isChecked()}")
|
||||
if self.show_details_checkbox.isChecked():
|
||||
self.show_details_checkbox.blockSignals(True)
|
||||
self.show_details_checkbox.setChecked(False)
|
||||
self.show_details_checkbox.blockSignals(False)
|
||||
|
||||
debug_print("DEBUG: Calling _toggle_console_visibility(Unchecked)")
|
||||
self._toggle_console_visibility(_Qt.Unchecked)
|
||||
# Force the window to compact height to eliminate bottom whitespace
|
||||
main_window = self.window()
|
||||
debug_print(f"DEBUG: main_window={main_window}, size={main_window.size() if main_window else None}")
|
||||
if main_window:
|
||||
# Save original geometry once
|
||||
if self._saved_geometry is None:
|
||||
self._saved_geometry = main_window.geometry()
|
||||
debug_print(f"DEBUG: Saved geometry: {self._saved_geometry}")
|
||||
if self._saved_min_size is None:
|
||||
self._saved_min_size = main_window.minimumSize()
|
||||
debug_print(f"DEBUG: Saved min size: {self._saved_min_size}")
|
||||
|
||||
# Fixed compact size - same as menu screens
|
||||
from PySide6.QtCore import QSize
|
||||
# On Steam Deck, keep fullscreen; on other systems, set normal window state
|
||||
if not (hasattr(main_window, 'system_info') and main_window.system_info.is_steamdeck):
|
||||
main_window.showNormal()
|
||||
# First, completely unlock the window
|
||||
main_window.setMinimumSize(QSize(0, 0))
|
||||
main_window.setMaximumSize(QSize(16777215, 16777215))
|
||||
# Only set minimum size - DO NOT RESIZE
|
||||
set_responsive_minimum(main_window, min_width=960, min_height=420)
|
||||
# DO NOT resize - let window stay at current size
|
||||
# Notify parent to ensure compact
|
||||
try:
|
||||
self.resize_request.emit('collapse')
|
||||
debug_print("DEBUG: Emitted resize_request collapse signal")
|
||||
except Exception as e:
|
||||
debug_print(f"DEBUG: Exception emitting signal: {e}")
|
||||
pass
|
||||
except Exception as e:
|
||||
debug_print(f"DEBUG: showEvent exception: {e}")
|
||||
import traceback
|
||||
debug_print(f"DEBUG: {traceback.format_exc()}")
|
||||
pass
|
||||
|
||||
def hideEvent(self, event):
|
||||
"""Called when the widget becomes hidden - restore window size constraints"""
|
||||
super().hideEvent(event)
|
||||
try:
|
||||
main_window = self.window()
|
||||
if main_window:
|
||||
from PySide6.QtCore import QSize
|
||||
# Clear any size constraints that might have been set to prevent affecting other screens
|
||||
# Important when console is expanded
|
||||
main_window.setMaximumSize(QSize(16777215, 16777215))
|
||||
main_window.setMinimumSize(QSize(0, 0))
|
||||
debug_print("DEBUG: Install TTW hideEvent - cleared window size constraints")
|
||||
except Exception as e:
|
||||
debug_print(f"DEBUG: hideEvent exception: {e}")
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user