diff --git a/pages/chat_page.py b/pages/chat_page.py index 63e04d4..ad8fa9e 100644 --- a/pages/chat_page.py +++ b/pages/chat_page.py @@ -6,6 +6,7 @@ from PyQt6.QtWidgets import QSystemTrayIcon, QMainWindow, QLabel, QTextEdit, QLi from actions.action_util import ActionUtil from agent.woker_agent import WorkerAgent from pages.config_page import ConfigPage +from pages.plugin_page import PluginPage from utils.qt_util import QtUtil class ActionItems(QListWidgetItem): @@ -160,7 +161,7 @@ class ChatInput(QTextEdit): def mousePressEvent(self, event): self.chat_page.action_list.set_visibility(False) - # 窗口激活时,���输入框的焦点设置到这里 + # 窗口激活时,输入框的焦点设置到这里 def event(self, event): if event.type() == QEvent.Type.WindowActivate: # 当窗口激活时,智子根据上下文推送合适的工具 @@ -192,6 +193,10 @@ class ChatPage(QMainWindow, interface_ui): setting_action = self.setting_action setting_action.triggered.connect(self.open_setting_page) + self.plugin = self.plugin + self.plugin.triggered.connect(self.open_plugin_page) + # 添加按钮点击事件,打开添加对话框 + # self.add_action.clicked.connect(self.open_add_dialog) # 设置托盘 self.trayIcon = QSystemTrayIcon(self) # 创建一个系统托盘图标对象 @@ -220,6 +225,10 @@ class ChatPage(QMainWindow, interface_ui): self.showNormal() # 显示窗口的正常模式 self.activateWindow() # 激活窗口,使其获取焦点 + def open_plugin_page(self): + self.plugin_page = PluginPage() + self.plugin_page.show() + def open_setting_page(self): self.setting_page = ConfigPage() self.setting_page.show() diff --git a/pages/chat_page.ui b/pages/chat_page.ui index 56140c0..dd45eaa 100644 --- a/pages/chat_page.ui +++ b/pages/chat_page.ui @@ -17,22 +17,6 @@ QTextEdit {border-radius: 10px;} - @@ -48,6 +32,7 @@ 文件 + @@ -58,7 +43,13 @@ 设置 - - - + + + + 插件 + + + + + diff --git a/pages/plugin_page.py b/pages/plugin_page.py new file mode 100644 index 0000000..e1ce27f --- /dev/null +++ b/pages/plugin_page.py @@ -0,0 +1,24 @@ +from PyQt6.QtWidgets import QMainWindow +from PyQt6 import QtWidgets +from utils.qt_util import QtUtil + +interface_ui = QtUtil.load_ui_type("plugin_page.ui") +class PluginPage(QMainWindow, interface_ui): + def __init__(self, parent=None): + super(PluginPage, self).__init__(parent) + self.setupUi(self) + self.init_ui() + + def init_ui(self): + self.add_plugin_button.clicked.connect(self.add_plugin) + self.delete_plugin_button.clicked.connect(self.delete_plugin) + + def add_plugin(self): + file_dialog = QtWidgets.QFileDialog(self) + file_dialog.setFileMode(QtWidgets.QFileDialog.FileMode.Directory) # 设置为目录选择模式 + if file_dialog.exec(): + selected_folder = file_dialog.selectedFiles() # 这将返回选中的文件夹列表 + print("Selected folder:", selected_folder[0]) + + def delete_plugin(self): + print("delete_plugin") diff --git a/pages/plugin_page.ui b/pages/plugin_page.ui new file mode 100644 index 0000000..6079e5a --- /dev/null +++ b/pages/plugin_page.ui @@ -0,0 +1,68 @@ + + + MainWindow + + + + 0 + 0 + 802 + 587 + + + + MainWindow + + + + + + 60 + 80 + 661 + 451 + + + + + + + 60 + 50 + 75 + 24 + + + + + + + + + + + 140 + 50 + 75 + 24 + + + + - + + + + + + + 0 + 0 + 802 + 22 + + + + + + + +