mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 13:07:17 +08:00
✨ 添加功能(chat_page.py, plugin_page.py, chat_page.ui, plugin_page.ui):引入插件页面和对应 UI 文件,实现插件管理功能
This commit is contained in:
@@ -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)
|
||||
|
||||
# 窗口激活时,<EFBFBD><EFBFBD><EFBFBD>输入框的焦点设置到这里
|
||||
# 窗口激活时,输入框的焦点设置到这里
|
||||
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()
|
||||
|
||||
@@ -17,22 +17,6 @@
|
||||
<string notr="true">QTextEdit {border-radius: 10px;}</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<!-- <widget class="QListWidget" name="chat_list">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>0</y>
|
||||
<width>561</width>
|
||||
<height>571</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget> -->
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
@@ -48,6 +32,7 @@
|
||||
<string>文件</string>
|
||||
</property>
|
||||
<addaction name="setting_action"/>
|
||||
<addaction name="plugin"/>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<addaction name="file_menu"/>
|
||||
@@ -58,7 +43,13 @@
|
||||
<string>设置</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="plugin">
|
||||
<property name="text">
|
||||
<string>插件</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
24
pages/plugin_page.py
Normal file
24
pages/plugin_page.py
Normal file
@@ -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")
|
||||
68
pages/plugin_page.ui
Normal file
68
pages/plugin_page.ui
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>802</width>
|
||||
<height>587</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>80</y>
|
||||
<width>661</width>
|
||||
<height>451</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="add_plugin_button">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>50</y>
|
||||
<width>75</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="delete_plugin_button">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>50</y>
|
||||
<width>75</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>802</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user