This commit is contained in:
ChenXL97 2023-11-27 14:09:51 +08:00
parent 6ce9b1966f
commit e652cfeb9a
4 changed files with 16 additions and 67 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 122 KiB

View File

@ -120,24 +120,26 @@ class UI(QMainWindow, Ui_MainWindow):
else:
new_chat = f'Robot:\n {content}\n'
self.edit_global_history.append(f'{new_chat}')
self.history_dict[customer_name] += new_chat + "\n"
self.history_dict["Global"] += new_chat + "\n"
items = self.list_customer.findItems(customer_name, Qt.MatchExactly)
if items:
index = self.list_customer.indexFromItem(items[0])
self.list_customer.setCurrentIndex(index)
self.edit_local_history.clear()
self.edit_local_history.append(self.history_dict[customer_name])
self.edit_local_history.append(self.history_dict["Global"])
def reset(self):
self.history_dict = {
"System": ""
"Global":"",
"System": "",
}
self.edit_local_history.clear()
self.edit_global_history.clear()
self.list_customer.clear()
item = QListWidgetItem("System")
self.list_customer.addItem(item)
item = QListWidgetItem("Global")
self.list_customer.addItem(item)

View File

@ -9,26 +9,8 @@
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QPainter
from PyQt5.QtWidgets import QGraphicsView
class GraphicsView(QGraphicsView):
def __init__(self, parent=None):
super(GraphicsView, self).__init__(parent)
self.setRenderHint(QPainter.Antialiasing)
self.setOptimizationFlag(QGraphicsView.DontAdjustForAntialiasing, True)
self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)
self.setDragMode(QGraphicsView.ScrollHandDrag)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
def wheelEvent(self, event):
factor = 1.15
if event.angleDelta().y() > 0:
self.scale(factor, factor)
else:
self.scale(1.0 / factor, 1.0 / factor)
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
@ -131,13 +113,6 @@ class Ui_MainWindow(object):
self.label_11.setFont(font)
self.label_11.setObjectName("label_11")
self.horizontalLayout_2.addWidget(self.label_11)
self.label_12 = QtWidgets.QLabel(self.centralwidget)
font = QtGui.QFont()
font.setFamily("黑体")
font.setPointSize(14)
self.label_12.setFont(font)
self.label_12.setObjectName("label_12")
self.horizontalLayout_2.addWidget(self.label_12)
self.gridLayout.addLayout(self.horizontalLayout_2, 1, 1, 1, 3)
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
@ -148,6 +123,8 @@ class Ui_MainWindow(object):
self.list_customer.setObjectName("list_customer")
item = QtWidgets.QListWidgetItem()
self.list_customer.addItem(item)
item = QtWidgets.QListWidgetItem()
self.list_customer.addItem(item)
self.horizontalLayout_3.addWidget(self.list_customer)
self.edit_local_history = QtWidgets.QTextEdit(self.centralwidget)
self.edit_local_history.setEnabled(True)
@ -157,14 +134,6 @@ class Ui_MainWindow(object):
self.edit_local_history.setReadOnly(True)
self.edit_local_history.setObjectName("edit_local_history")
self.horizontalLayout_3.addWidget(self.edit_local_history)
self.edit_global_history = QtWidgets.QTextEdit(self.centralwidget)
self.edit_global_history.setEnabled(True)
font = QtGui.QFont()
font.setPointSize(11)
self.edit_global_history.setFont(font)
self.edit_global_history.setReadOnly(True)
self.edit_global_history.setObjectName("edit_global_history")
self.horizontalLayout_3.addWidget(self.edit_global_history)
self.gridLayout.addLayout(self.horizontalLayout_3, 2, 1, 1, 3)
self.gridLayout_4.addLayout(self.gridLayout, 0, 0, 1, 1)
self.gridLayout_3 = QtWidgets.QGridLayout()
@ -178,7 +147,7 @@ class Ui_MainWindow(object):
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.verticalLayout_2.addWidget(self.label_5)
self.img_view_bt = GraphicsView(self.centralwidget)
self.img_view_bt = QtWidgets.QGraphicsView(self.centralwidget)
self.img_view_bt.setObjectName("img_view_bt")
self.verticalLayout_2.addWidget(self.img_view_bt)
self.gridLayout_3.addLayout(self.verticalLayout_2, 1, 0, 1, 1)
@ -292,10 +261,11 @@ class Ui_MainWindow(object):
self.btn_reset.setText(_translate("MainWindow", "重置"))
self.label_10.setText(_translate("MainWindow", "顾客列表:"))
self.label_11.setText(_translate("MainWindow", "顾客历史对话:"))
self.label_12.setText(_translate("MainWindow", "全局历史对话:"))
__sortingEnabled = self.list_customer.isSortingEnabled()
self.list_customer.setSortingEnabled(False)
item = self.list_customer.item(0)
item.setText(_translate("MainWindow", "Global"))
item = self.list_customer.item(1)
item.setText(_translate("MainWindow", "System"))
self.list_customer.setSortingEnabled(__sortingEnabled)
self.label_5.setText(_translate("MainWindow", "当前行为树"))

View File

@ -184,19 +184,6 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_12">
<property name="font">
<font>
<family>黑体</family>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>全局历史对话:</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1" colspan="3">
@ -208,6 +195,11 @@
<pointsize>11</pointsize>
</font>
</property>
<item>
<property name="text">
<string>Global</string>
</property>
</item>
<item>
<property name="text">
<string>System</string>
@ -230,21 +222,6 @@
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="edit_global_history">
<property name="enabled">
<bool>true</bool>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>