diff --git a/source/core/managers/offline_mode_manager.py b/source/core/managers/offline_mode_manager.py index 3d6020a..faa74b4 100644 --- a/source/core/managers/offline_mode_manager.py +++ b/source/core/managers/offline_mode_manager.py @@ -822,35 +822,6 @@ class OfflineModeManager: # 添加到安装任务列表 install_tasks.append((patch_file, game_folder, game_version, _7z_path, plugin_path)) - # 检查是否有未找到离线补丁文件的游戏 - if self.missing_offline_patches: - if debug_mode: - logger.debug(f"DEBUG: 有未找到离线补丁文件的游戏: {self.missing_offline_patches}") - - # 询问用户是否切换到在线模式 - msg_box = msgbox_frame( - f"离线安装信息 - {self.app_name}", - f"\n本地未发现对应离线文件,是否切换为在线模式安装?\n\n以下游戏未找到对应的离线补丁文件:\n\n{chr(10).join(self.missing_offline_patches)}\n", - QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No - ) - result = msg_box.exec() - - if result == QMessageBox.StandardButton.Yes: - if debug_mode: - logger.debug("DEBUG: 用户选择切换到在线模式") - - # 切换到在线模式 - if hasattr(self.main_window, 'ui_manager'): - self.main_window.ui_manager.switch_work_mode("online") - - # 直接启动下载流程 - self.main_window.setEnabled(True) - # 保存当前选择的游戏列表,以便在线模式使用 - missing_games = self.missing_offline_patches.copy() - # 启动下载流程 - QTimer.singleShot(500, lambda: self._start_online_download(missing_games)) - return True - # 开始执行第一个安装任务 if install_tasks: if debug_mode: @@ -923,8 +894,8 @@ class OfflineModeManager: else: installed_msg = "" - # 使用QTimer延迟显示询问对话框,确保安装结果窗口先显示并关闭 - QTimer.singleShot(500, lambda: self._show_missing_patches_dialog(installed_msg)) + # 在安装完成后询问用户是否切换到在线模式 + self._show_missing_patches_dialog(installed_msg) else: # 恢复UI状态 self.main_window.setEnabled(True) diff --git a/source/core/managers/ui_manager.py b/source/core/managers/ui_manager.py index e37acc7..4bb84fc 100644 --- a/source/core/managers/ui_manager.py +++ b/source/core/managers/ui_manager.py @@ -1066,7 +1066,8 @@ class UIManager: self.loading_dialog.show() # force UI update - QMessageBox.QApplication.processEvents() + from PySide6.QtWidgets import QApplication + QApplication.processEvents() def hide_loading_dialog(self): """隐藏并销毁加载对话框.""" diff --git a/source/main_window.py b/source/main_window.py index 04c2183..5be9144 100644 --- a/source/main_window.py +++ b/source/main_window.py @@ -85,6 +85,8 @@ class MainWindow(QMainWindow): self.progress_window = None self.pre_hash_thread = None self.hash_thread = None + self.installed_status = {} + self.hash_msg_box = None # 验证关键资源 self._verify_resources() @@ -468,8 +470,9 @@ class MainWindow(QMainWindow): self.download_manager.graceful_stop_threads(threads_to_stop) - self.download_manager.hosts_manager.restore() - self.download_manager.hosts_manager.check_and_clean_all_entries() + # 移除此处的hosts操作 + # self.download_manager.hosts_manager.restore() + # self.download_manager.hosts_manager.check_and_clean_all_entries() self.debug_manager.stop_logging() if not force_exit: @@ -482,6 +485,14 @@ class MainWindow(QMainWindow): if event: event.ignore() return + + # 用户确认退出后,再执行hosts相关操作 + self.download_manager.hosts_manager.restore() + self.download_manager.hosts_manager.check_and_clean_all_entries() + else: + # 强制退出时,也需执行hosts相关操作 + self.download_manager.hosts_manager.restore() + self.download_manager.hosts_manager.check_and_clean_all_entries() if event: event.accept() @@ -710,6 +721,29 @@ class MainWindow(QMainWindow): logger.error(f"关闭哈希校验窗口时发生错误: {e}") self.hash_msg_box = None + def create_extraction_progress_window(self): + """创建一个用于显示解压进度的窗口 + + Returns: + QDialog: 配置好的解压进度窗口实例 + """ + return self.ui_manager.create_progress_window("解压进度", "正在准备解压...") + + def create_extraction_thread(self, patch_file, game_folder, plugin_path, game_version): + """创建一个解压线程 + + Args: + patch_file: 补丁文件路径 + game_folder: 游戏目录路径 + plugin_path: 插件路径 + game_version: 游戏版本 + + Returns: + ExtractionThread: 配置好的解压线程实例 + """ + from workers.extraction_thread import ExtractionThread + return ExtractionThread(patch_file, game_folder, plugin_path, game_version, self) + \ No newline at end of file