diff --git a/.gitignore b/.gitignore index 1c4ba46..528ee26 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ __pycache__/ .kiro/* +client_gui.log \ No newline at end of file diff --git a/client_gui.log b/client_gui.log index 709fc66..9664703 100644 --- a/client_gui.log +++ b/client_gui.log @@ -58,3 +58,56 @@ 2025-12-26 22:56:09,112 - __main__ - INFO - Connected to server 2025-12-26 22:56:09,132 - client.app - INFO - Online users updated: 1 users 2025-12-26 22:56:09,133 - __main__ - INFO - Online users: 1 +2025-12-26 22:56:09,633 - client.app - INFO - Online users updated: 1 users +2025-12-26 22:56:09,634 - __main__ - INFO - Online users: 1 +2025-12-26 22:58:17,789 - client.ui.main_window - INFO - MainWindow cleanup +2025-12-26 22:58:17,802 - __main__ - INFO - Cleaning up resources... +2025-12-26 22:58:17,803 - __main__ - ERROR - Worker error: Event loop stopped before Future completed. +2025-12-26 22:58:17,806 - __main__ - ERROR - Error stopping client: Event loop is closed +2025-12-26 22:58:17,806 - __main__ - INFO - Cleanup completed +2025-12-26 22:58:17,893 - asyncio - ERROR - Task was destroyed but it is pending! +task: wait_for=<_OverlappedFuture cancelled> cb=[_release_waiter()() at E:\Miniconda3\Lib\asyncio\tasks.py:431]> +2025-12-26 22:58:17,894 - asyncio - ERROR - Task was destroyed but it is pending! +task: wait_for=> +2025-12-26 22:58:17,894 - asyncio - ERROR - Task was destroyed but it is pending! +task: wait_for=> +2025-12-26 22:58:17,895 - asyncio - ERROR - Task was destroyed but it is pending! +task: wait_for=> +2025-12-26 23:03:26,489 - client.ui.login_dialog - INFO - LoginDialog initialized +2025-12-26 23:03:33,742 - client.ui.login_dialog - INFO - User logged in: ybw +2025-12-26 23:03:34,455 - client.ui.main_window - INFO - MainWindow initialized +2025-12-26 23:03:34,456 - client.ui.main_window - INFO - Current user set: ybw +2025-12-26 23:03:34,469 - client.ui.system_tray - INFO - SystemTrayManager initialized +2025-12-26 23:03:34,526 - client.connection_manager - INFO - ConnectionManager initialized +2025-12-26 23:03:34,529 - client.file_transfer - INFO - FileTransferModule initialized +2025-12-26 23:03:34,529 - client.image_processor - INFO - ImageProcessor initialized +2025-12-26 23:03:34,530 - client.media_player - INFO - AudioPlayer initialized +2025-12-26 23:03:34,530 - client.media_player - INFO - VideoPlayer initialized +2025-12-26 23:03:34,530 - client.media_player - INFO - MediaPlayer initialized +2025-12-26 23:03:34,530 - client.app - INFO - P2PClientApp initialized +2025-12-26 23:03:34,537 - client.connection_manager - INFO - Connection state changed: disconnected -> connecting (Connecting to server) +2025-12-26 23:03:34,537 - client.app - INFO - Connection state changed: connecting (Connecting to server) +2025-12-26 23:03:34,579 - client.connection_manager - INFO - Connection state changed: connecting -> connected (Connected to server) +2025-12-26 23:03:34,579 - client.app - INFO - Connection state changed: connected (Connected to server) +2025-12-26 23:03:34,580 - client.connection_manager - INFO - LAN listener started on port 8889 +2025-12-26 23:03:34,580 - client.connection_manager - INFO - Connected to server 113.45.148.222:8888 +2025-12-26 23:03:34,580 - client.app - INFO - Client started for user: ybw +2025-12-26 23:03:34,580 - client.voice_chat - INFO - VoiceChatModule initialized +2025-12-26 23:03:34,582 - __main__ - INFO - Connected to server +2025-12-26 23:03:34,602 - client.app - INFO - Online users updated: 2 users +2025-12-26 23:03:34,602 - __main__ - INFO - Online users: 2 +2025-12-26 23:03:35,103 - client.app - INFO - Online users updated: 2 users +2025-12-26 23:03:35,104 - __main__ - INFO - Online users: 2 +2025-12-26 23:07:22,202 - client.ui.main_window - INFO - MainWindow cleanup +2025-12-26 23:07:22,214 - __main__ - INFO - Cleaning up resources... +2025-12-26 23:07:22,214 - __main__ - ERROR - Worker error: Event loop stopped before Future completed. +2025-12-26 23:07:22,219 - __main__ - ERROR - Error stopping client: Event loop is closed +2025-12-26 23:07:22,219 - __main__ - INFO - Cleanup completed +2025-12-26 23:07:22,329 - asyncio - ERROR - Task was destroyed but it is pending! +task: wait_for=<_OverlappedFuture cancelled> cb=[_release_waiter()() at E:\Miniconda3\Lib\asyncio\tasks.py:431]> +2025-12-26 23:07:22,331 - asyncio - ERROR - Task was destroyed but it is pending! +task: wait_for=> +2025-12-26 23:07:22,332 - asyncio - ERROR - Task was destroyed but it is pending! +task: wait_for=> +2025-12-26 23:07:22,334 - asyncio - ERROR - Task was destroyed but it is pending! +task: wait_for=> diff --git a/run_client_gui.py b/run_client_gui.py index 5205490..e03442a 100644 --- a/run_client_gui.py +++ b/run_client_gui.py @@ -222,6 +222,15 @@ class P2PChatGUI(QObject): if self._current_user: self.main_window.set_current_user(self._current_user) + # 创建并设置联系人列表组件 + self._contact_list_widget = ContactListWidget() + self.main_window.set_contact_list_widget(self._contact_list_widget) + + # 连接联系人列表信号 + self._contact_list_widget.contact_selected.connect(self._on_contact_selected) + self._contact_list_widget.contact_double_clicked.connect(self._on_contact_double_clicked) + self._contact_list_widget.refresh_requested.connect(self._refresh_users) + # 设置系统托盘 try: tray = SystemTrayManager(self.main_window) @@ -331,6 +340,16 @@ class P2PChatGUI(QObject): self.main_window._statusbar.showMessage( f"在线用户: {len(users)}", 3000 ) + + # 更新联系人列表(排除自己) + if hasattr(self, '_contact_list_widget') and self._contact_list_widget: + # 过滤掉当前用户自己 + other_users = [ + user for user in users + if self._current_user is None or user.user_id != self._current_user.user_id + ] + self._contact_list_widget.set_contacts(other_users) + logger.info(f"Contact list updated: {len(other_users)} contacts") def _on_state_changed(self, state: str, reason: str): """状态变化回调""" @@ -384,6 +403,18 @@ class P2PChatGUI(QObject): self.main_window._statusbar.showMessage(f"正在呼叫...") # TODO: 实现语音通话 + def _on_contact_selected(self, user_id: str): + """联系人选中回调""" + self._current_chat_peer = user_id + logger.debug(f"Contact selected: {user_id}") + + def _on_contact_double_clicked(self, user_id: str): + """联系人双击回调 - 打开聊天""" + self._current_chat_peer = user_id + logger.info(f"Opening chat with: {user_id}") + # TODO: 打开聊天窗口 + self.main_window._statusbar.showMessage(f"与 {user_id} 聊天", 3000) + def cleanup(self): """清理资源""" logger.info("Cleaning up resources...")