2023-11-04 21:21:26 +08:00
|
|
|
|
from PyQt5.QtCore import *
|
|
|
|
|
from PyQt5.QtWidgets import *
|
|
|
|
|
|
2023-11-08 00:13:12 +08:00
|
|
|
|
from app import person
|
2023-11-05 21:14:14 +08:00
|
|
|
|
from app.DataBase import output
|
2023-11-08 00:13:12 +08:00
|
|
|
|
from app.Ui.Icon import Icon
|
2023-11-04 21:21:26 +08:00
|
|
|
|
from .analysis import analysis
|
|
|
|
|
from .contactInfoUi import Ui_Form
|
|
|
|
|
from .emotion import emotion
|
|
|
|
|
from .userinfo import userinfo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContactInfo(QWidget, Ui_Form):
|
|
|
|
|
exitSignal = pyqtSignal()
|
|
|
|
|
urlSignal = pyqtSignal(QUrl)
|
|
|
|
|
|
|
|
|
|
# username = ''
|
2023-11-05 21:14:14 +08:00
|
|
|
|
def __init__(self, wxid, me: person.Me, parent=None):
|
2023-11-04 21:21:26 +08:00
|
|
|
|
super(ContactInfo, self).__init__(parent)
|
|
|
|
|
self.setupUi(self)
|
2023-11-08 00:13:12 +08:00
|
|
|
|
self.contact = person.Contact(wxid)
|
2023-11-04 21:21:26 +08:00
|
|
|
|
self.view_userinfo = userinfo.UserinfoController(self.contact)
|
|
|
|
|
self.view_analysis = analysis.AnalysisController(wxid)
|
|
|
|
|
self.view_emotion = emotion.EmotionController(wxid)
|
|
|
|
|
self.btn_analysis.clicked.connect(self.analysis)
|
2023-11-05 21:14:14 +08:00
|
|
|
|
self.btn_emotion.clicked.connect(self.emotionale_Analysis)
|
|
|
|
|
self.btn_report.clicked.connect(self.annual_report)
|
|
|
|
|
self.btn_back.clicked.connect(self.back)
|
|
|
|
|
self.Me = me
|
2023-11-06 21:00:42 +08:00
|
|
|
|
# self.
|
2023-11-04 21:21:26 +08:00
|
|
|
|
self.init_ui()
|
|
|
|
|
|
|
|
|
|
def init_ui(self):
|
2023-11-06 21:00:42 +08:00
|
|
|
|
self.btn_back.setIcon(Icon.Back)
|
2023-11-11 19:35:25 +08:00
|
|
|
|
self.btn_report.setIcon(Icon.Annual_Report_Icon)
|
|
|
|
|
self.btn_analysis.setIcon(Icon.Analysis_Icon)
|
|
|
|
|
self.btn_emotion.setIcon(Icon.Emotion_Icon)
|
2023-11-04 21:21:26 +08:00
|
|
|
|
self.label_remark.setText(self.contact.conRemark)
|
|
|
|
|
self.stackedWidget.addWidget(self.view_userinfo)
|
|
|
|
|
self.stackedWidget.addWidget(self.view_analysis)
|
|
|
|
|
self.stackedWidget.addWidget(self.view_emotion)
|
|
|
|
|
self.stackedWidget.setCurrentWidget(self.view_userinfo)
|
|
|
|
|
menu = QMenu(self)
|
2023-11-09 20:11:01 +08:00
|
|
|
|
self.toDocxAct = QAction(Icon.ToDocx, '导出Docx', self)
|
|
|
|
|
self.toCSVAct = QAction(Icon.ToCSV, '导出CSV', self)
|
|
|
|
|
self.toHtmlAct = QAction(Icon.ToHTML, '导出HTML', self)
|
2023-11-04 21:21:26 +08:00
|
|
|
|
self.toolButton_output.setPopupMode(QToolButton.MenuButtonPopup)
|
2023-11-06 21:00:42 +08:00
|
|
|
|
self.toolButton_output.clicked.connect(self.toolButton_show)
|
2023-11-04 21:21:26 +08:00
|
|
|
|
menu.addAction(self.toDocxAct)
|
|
|
|
|
menu.addAction(self.toCSVAct)
|
|
|
|
|
menu.addAction(self.toHtmlAct)
|
|
|
|
|
self.toolButton_output.setMenu(menu)
|
2023-11-06 21:00:42 +08:00
|
|
|
|
self.toolButton_output.setIcon(Icon.Output)
|
2023-11-04 21:21:26 +08:00
|
|
|
|
# self.toolButton_output.addSeparator()
|
|
|
|
|
self.toHtmlAct.triggered.connect(self.output)
|
|
|
|
|
self.toDocxAct.triggered.connect(self.output)
|
|
|
|
|
self.toCSVAct.triggered.connect(self.output)
|
|
|
|
|
|
2023-11-06 21:00:42 +08:00
|
|
|
|
def toolButton_show(self):
|
|
|
|
|
self.toolButton_output.showMenu()
|
|
|
|
|
|
2023-11-04 21:21:26 +08:00
|
|
|
|
def analysis(self):
|
|
|
|
|
self.stackedWidget.setCurrentWidget(self.view_analysis)
|
|
|
|
|
if 'room' in self.contact.wxid:
|
|
|
|
|
QMessageBox.warning(
|
|
|
|
|
self, '警告',
|
|
|
|
|
'暂不支持群组'
|
|
|
|
|
)
|
|
|
|
|
return
|
|
|
|
|
self.view_analysis.start()
|
|
|
|
|
|
2023-11-05 21:14:14 +08:00
|
|
|
|
def annual_report(self):
|
|
|
|
|
QMessageBox.warning(
|
|
|
|
|
self,
|
|
|
|
|
"提示",
|
|
|
|
|
"敬请期待"
|
|
|
|
|
)
|
2023-11-04 21:21:26 +08:00
|
|
|
|
return
|
2023-11-11 18:58:40 +08:00
|
|
|
|
# self.report = report.ReportController(self.contact)
|
|
|
|
|
# self.report.show()
|
2023-11-05 21:14:14 +08:00
|
|
|
|
|
|
|
|
|
def emotionale_Analysis(self):
|
|
|
|
|
self.stackedWidget.setCurrentWidget(self.view_emotion)
|
|
|
|
|
if 'room' in self.contact.wxid:
|
|
|
|
|
QMessageBox.warning(
|
|
|
|
|
self, '警告',
|
|
|
|
|
'暂不支持群组'
|
|
|
|
|
)
|
|
|
|
|
return
|
|
|
|
|
self.view_emotion.start()
|
|
|
|
|
|
|
|
|
|
def back(self):
|
|
|
|
|
"""
|
|
|
|
|
将userinfo界面设置为可见,其他界面设置为不可见
|
|
|
|
|
"""
|
|
|
|
|
self.stackedWidget.setCurrentWidget(self.view_userinfo)
|
|
|
|
|
|
|
|
|
|
def output(self):
|
|
|
|
|
"""
|
|
|
|
|
导出聊天记录
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
self.stackedWidget.setCurrentWidget(self.view_userinfo)
|
|
|
|
|
if self.sender() == self.toDocxAct:
|
|
|
|
|
self.outputThread = output.Output(self.Me, self.contact.wxid)
|
|
|
|
|
elif self.sender() == self.toCSVAct:
|
|
|
|
|
print('开始导出csv')
|
|
|
|
|
self.outputThread = output.Output(self.Me, self.contact.wxid, type_=output.Output.CSV)
|
|
|
|
|
print('导出csv')
|
|
|
|
|
elif self.sender() == self.toHtmlAct:
|
|
|
|
|
print('功能暂未实现')
|
|
|
|
|
QMessageBox.warning(self,
|
|
|
|
|
"别急别急",
|
|
|
|
|
"马上就实现该功能"
|
|
|
|
|
)
|
|
|
|
|
return
|
|
|
|
|
self.outputThread.progressSignal.connect(self.output_progress)
|
|
|
|
|
self.outputThread.rangeSignal.connect(self.set_progressBar_range)
|
|
|
|
|
self.outputThread.okSignal.connect(self.hide_progress_bar)
|
|
|
|
|
self.outputThread.start()
|
|
|
|
|
|
|
|
|
|
def hide_progress_bar(self, int):
|
|
|
|
|
reply = QMessageBox(self)
|
|
|
|
|
reply.setIcon(QMessageBox.Information)
|
|
|
|
|
reply.setWindowTitle('OK')
|
|
|
|
|
reply.setText(f"导出聊天记录成功\n在.\\data\\目录下")
|
|
|
|
|
reply.addButton("确认", QMessageBox.AcceptRole)
|
|
|
|
|
reply.addButton("取消", QMessageBox.RejectRole)
|
|
|
|
|
api = reply.exec_()
|
|
|
|
|
self.view_userinfo.progressBar.setVisible(False)
|
|
|
|
|
|
|
|
|
|
def output_progress(self, value):
|
|
|
|
|
self.view_userinfo.progressBar.setProperty('value', value)
|
|
|
|
|
|
|
|
|
|
def set_progressBar_range(self, value):
|
|
|
|
|
self.view_userinfo.progressBar.setVisible(True)
|
|
|
|
|
self.view_userinfo.progressBar.setRange(0, value)
|