mirror of
https://github.com/Omni-guides/Jackify.git
synced 2026-06-17 21:57:45 +02:00
Sync from development - prepare for v0.4.0
This commit is contained in:
@@ -28,22 +28,17 @@ from ..dialogs import SuccessDialog
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from jackify.frontends.gui.services.message_service import MessageService
|
||||
from jackify.shared.resolution_utils import get_resolution_fallback
|
||||
from jackify.shared.errors import configuration_failed
|
||||
from .configure_new_modlist_ui_setup import ConfigureNewModlistUISetupMixin
|
||||
from .configure_new_modlist_console import ConfigureNewModlistConsoleMixin
|
||||
from .configure_new_modlist_workflow import ConfigureNewModlistWorkflowMixin
|
||||
from .configure_new_modlist_dialogs import ConfigureNewModlistDialogsMixin, ModlistFetchThread, SelectionDialog
|
||||
from .screen_back_mixin import ScreenBackMixin
|
||||
from .install_modlist_ttw import TTWIntegrationMixin
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
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 ConfigureNewModlistScreen(ScreenBackMixin, ConfigureNewModlistUISetupMixin, ConfigureNewModlistConsoleMixin, ConfigureNewModlistWorkflowMixin, ConfigureNewModlistDialogsMixin, QWidget):
|
||||
class ConfigureNewModlistScreen(ScreenBackMixin, TTWIntegrationMixin, ConfigureNewModlistUISetupMixin, ConfigureNewModlistConsoleMixin, ConfigureNewModlistWorkflowMixin, ConfigureNewModlistDialogsMixin, QWidget):
|
||||
resize_request = Signal(str)
|
||||
|
||||
def cancel_and_cleanup(self):
|
||||
@@ -79,8 +74,20 @@ class ConfigureNewModlistScreen(ScreenBackMixin, ConfigureNewModlistUISetupMixin
|
||||
self._enable_controls_after_operation()
|
||||
|
||||
if success:
|
||||
raw = self.install_dir_edit.text().strip()
|
||||
install_dir = os.path.dirname(raw) if raw.endswith('ModOrganizer.exe') else raw
|
||||
|
||||
if install_dir:
|
||||
game_type = self._detect_game_type_from_mo2_ini(install_dir)
|
||||
if game_type in ('falloutnv', 'fallout_new_vegas'):
|
||||
from jackify.backend.utils.modlist_meta import get_modlist_name
|
||||
identified_name = get_modlist_name(install_dir)
|
||||
if identified_name and self._check_ttw_eligibility(identified_name, game_type, install_dir):
|
||||
self._cleanup_config_thread()
|
||||
self._initiate_ttw_workflow(identified_name, install_dir)
|
||||
return
|
||||
|
||||
# Check for VNV post-install automation after configuration
|
||||
install_dir = self.install_dir_edit.text().strip()
|
||||
if install_dir:
|
||||
self._check_and_run_vnv_automation(modlist_name, install_dir)
|
||||
|
||||
@@ -111,8 +118,8 @@ class ConfigureNewModlistScreen(ScreenBackMixin, ConfigureNewModlistUISetupMixin
|
||||
logger.warning(f"Failed to show ENB dialog: {e}")
|
||||
else:
|
||||
self._safe_append_text(f"Configuration failed: {message}")
|
||||
MessageService.critical(self, "Configuration Failed",
|
||||
f"Configuration failed: {message}", safety_level="medium")
|
||||
MessageService.show_error(self, configuration_failed(str(message)))
|
||||
self._cleanup_config_thread()
|
||||
|
||||
def on_configuration_error(self, error_message):
|
||||
"""Handle configuration error"""
|
||||
@@ -120,11 +127,27 @@ class ConfigureNewModlistScreen(ScreenBackMixin, ConfigureNewModlistUISetupMixin
|
||||
self._enable_controls_after_operation()
|
||||
|
||||
self._safe_append_text(f"Configuration error: {error_message}")
|
||||
MessageService.critical(self, "Configuration Error", f"Configuration failed: {error_message}", safety_level="medium")
|
||||
MessageService.show_error(self, configuration_failed(str(error_message)))
|
||||
self._cleanup_config_thread()
|
||||
|
||||
def _cleanup_config_thread(self):
|
||||
"""Safely stop and release configuration thread."""
|
||||
if not hasattr(self, 'config_thread') or self.config_thread is None:
|
||||
return
|
||||
|
||||
try:
|
||||
self.config_thread.progress_update.disconnect()
|
||||
self.config_thread.configuration_complete.disconnect()
|
||||
self.config_thread.error_occurred.disconnect()
|
||||
except (RuntimeError, TypeError):
|
||||
pass
|
||||
|
||||
if self.config_thread.isRunning():
|
||||
self.config_thread.quit()
|
||||
self.config_thread.wait(5000)
|
||||
|
||||
self.config_thread.deleteLater()
|
||||
self.config_thread = None
|
||||
|
||||
def reset_screen_to_defaults(self):
|
||||
"""Reset the screen to default state when navigating back from main menu"""
|
||||
@@ -149,28 +172,28 @@ class ConfigureNewModlistScreen(ScreenBackMixin, ConfigureNewModlistUISetupMixin
|
||||
|
||||
def cleanup(self):
|
||||
"""Clean up any running threads when the screen is closed"""
|
||||
debug_print("DEBUG: cleanup called - cleaning up threads")
|
||||
logger.debug("DEBUG: cleanup called - cleaning up threads")
|
||||
|
||||
# Clean up automated prefix thread if running
|
||||
if hasattr(self, 'automated_prefix_thread') and self.automated_prefix_thread and self.automated_prefix_thread.isRunning():
|
||||
debug_print("DEBUG: Terminating AutomatedPrefixThread")
|
||||
logger.debug("DEBUG: Terminating AutomatedPrefixThread")
|
||||
try:
|
||||
self.automated_prefix_thread.progress_update.disconnect()
|
||||
self.automated_prefix_thread.workflow_complete.disconnect()
|
||||
self.automated_prefix_thread.error_occurred.disconnect()
|
||||
except:
|
||||
except (RuntimeError, TypeError):
|
||||
pass
|
||||
self.automated_prefix_thread.terminate()
|
||||
self.automated_prefix_thread.wait(2000) # Wait up to 2 seconds
|
||||
|
||||
# Clean up config thread if running
|
||||
if hasattr(self, 'config_thread') and self.config_thread and self.config_thread.isRunning():
|
||||
debug_print("DEBUG: Terminating ConfigThread")
|
||||
logger.debug("DEBUG: Terminating ConfigThread")
|
||||
try:
|
||||
self.config_thread.progress_update.disconnect()
|
||||
self.config_thread.configuration_complete.disconnect()
|
||||
self.config_thread.error_occurred.disconnect()
|
||||
except:
|
||||
except (RuntimeError, TypeError):
|
||||
pass
|
||||
self.config_thread.terminate()
|
||||
self.config_thread.wait(2000) # Wait up to 2 seconds
|
||||
self.config_thread.wait(2000) # Wait up to 2 seconds
|
||||
|
||||
Reference in New Issue
Block a user