mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-21 18:12:18 +08:00
窗口切换,使用stackedWidget
This commit is contained in:
parent
e307794507
commit
6f903a7eff
@ -41,9 +41,11 @@ class ChatController(QWidget, Ui_Form):
|
||||
self.setWindowIcon(QIcon('./app/data/icon.png'))
|
||||
self.initui()
|
||||
self.Me = Me
|
||||
|
||||
self.Thread = ChatMsg(self.Me.username, None)
|
||||
self.Thread.isSend_signal.connect(self.showMsg)
|
||||
self.Thread.okSignal.connect(self.setScrollBarPos)
|
||||
|
||||
self.contacts = {}
|
||||
self.last_btn = None
|
||||
self.chat_flag = True
|
||||
@ -133,7 +135,7 @@ class ChatController(QWidget, Ui_Form):
|
||||
"QPushButton {background-color: rgb(198,198,198);}"
|
||||
"QPushButton:hover{background-color: rgb(209,209,209);}\n"
|
||||
)
|
||||
conRemark = data.get_conRemark(talkerId)
|
||||
conRemark = self.contacts[talkerId].conRemark
|
||||
self.label_remark.setText(conRemark)
|
||||
self.message.clear()
|
||||
self.message.append(talkerId)
|
||||
@ -142,7 +144,7 @@ class ChatController(QWidget, Ui_Form):
|
||||
self.chatroomFlag = True
|
||||
else:
|
||||
self.chatroomFlag = False
|
||||
self.ta_avatar = data.get_avator(talkerId)
|
||||
self.ta_avatar = self.contacts[talkerId].avatar
|
||||
self.textEdit.setFocus()
|
||||
self.Thread.ta_u = talkerId
|
||||
self.Thread.msg_id = 0
|
||||
@ -532,14 +534,14 @@ class Contact(QtWidgets.QPushButton):
|
||||
self.show_info(id)
|
||||
|
||||
def show_info(self, id):
|
||||
avatar = data.get_avator(self.username)
|
||||
self.avatar = data.get_avator(self.username)
|
||||
# print(avatar)
|
||||
remark = data.get_conRemark(self.username)
|
||||
self.conRemark = data.get_conRemark(self.username)
|
||||
time = datetime.datetime.now().strftime("%m-%d %H:%M")
|
||||
msg = '还没说话'
|
||||
pixmap = QPixmap(avatar).scaled(60, 60) # 按指定路径找到图片
|
||||
pixmap = QPixmap(self.avatar).scaled(60, 60) # 按指定路径找到图片
|
||||
self.label_avatar.setPixmap(pixmap) # 在label上显示图片
|
||||
self.label_remark.setText(remark)
|
||||
self.label_remark.setText(self.conRemark)
|
||||
self.label_msg.setText(self.digest)
|
||||
self.label_time.setText(data.timestamp2str(self.conversationTime)[2:])
|
||||
|
||||
|
@ -60,7 +60,7 @@ class AnalysisController(QWidget):
|
||||
self.browser2.load(QUrl('file:///data/聊天统计/wordcloud.html'))
|
||||
self.browser3 = QWebEngineView()
|
||||
self.browser3.load(QUrl('file:///data/聊天统计/time.html'))
|
||||
|
||||
# self.browser3.resize(800, 600)
|
||||
self.browser4 = QWebEngineView()
|
||||
self.browser4.load(QUrl('http://www.baidu.com'))
|
||||
# self.browser4.resize(800, 600)
|
||||
@ -76,40 +76,50 @@ class AnalysisController(QWidget):
|
||||
self.browser9.load(QUrl('file:///data/聊天统计/msg_type_rate.html'))
|
||||
self.browser10 = QWebEngineView()
|
||||
self.browser10.load(QUrl('file:///data/聊天统计/send_recv_rate.html'))
|
||||
|
||||
self.browser10.adjustSize()
|
||||
# self.browser10.
|
||||
main_box.addWidget(self.browser1)
|
||||
|
||||
scrollArea = QScrollArea(self)
|
||||
scrollAreaContent = QWidget(scrollArea)
|
||||
self.scrollArea = QScrollArea(self)
|
||||
self.scrollArea.setEnabled(True)
|
||||
self.scrollArea.adjustSize()
|
||||
self.scrollArea.setWidgetResizable(False)
|
||||
scrollAreaContent = QWidget(self.scrollArea)
|
||||
Vlayout2 = QVBoxLayout(scrollAreaContent)
|
||||
|
||||
splitter2 = QSplitter(Qt.Vertical)
|
||||
splitter2.addWidget(self.browser2)
|
||||
Vlayout2.addWidget(splitter2)
|
||||
# splitter2 = QSplitter(Qt.Vertical)
|
||||
# splitter2.addWidget(self.browser2)
|
||||
# # splitter2.resize(800, 600)
|
||||
# Vlayout2.addWidget(splitter2)
|
||||
#
|
||||
# splitter3 = QSplitter(Qt.Vertical)
|
||||
# splitter3.addWidget(self.browser3)
|
||||
# Vlayout2.addWidget(splitter3)
|
||||
#
|
||||
# splitter4 = QSplitter(Qt.Vertical)
|
||||
# splitter4.addWidget(self.browser4)
|
||||
# Vlayout2.addWidget(splitter4)
|
||||
#
|
||||
# splitter5 = QSplitter(Qt.Vertical)
|
||||
# splitter5.addWidget(self.browser6)
|
||||
# Vlayout2.addWidget(splitter5)
|
||||
|
||||
splitter3 = QSplitter(Qt.Vertical)
|
||||
splitter3.addWidget(self.browser3)
|
||||
Vlayout2.addWidget(splitter3)
|
||||
# Vlayout2.addWidget(self.browser3, stretch=1)
|
||||
# Vlayout2.addWidget(self.browser6, stretch=2)
|
||||
# Vlayout2.addWidget(self.browser5, stretch=3)
|
||||
# Vlayout2.addWidget(self.browser7, stretch=4)
|
||||
# Vlayout2.addWidget(self.browser8, stretch=5)
|
||||
# Vlayout2.addWidget(self.browser9, stretch=6)
|
||||
Vlayout2.addWidget(self.browser10, stretch=7)
|
||||
|
||||
splitter4 = QSplitter(Qt.Vertical)
|
||||
splitter4.addWidget(self.browser4)
|
||||
Vlayout2.addWidget(splitter4)
|
||||
|
||||
splitter5 = QSplitter(Qt.Vertical)
|
||||
splitter5.addWidget(self.browser6)
|
||||
Vlayout2.addWidget(splitter5)
|
||||
|
||||
Vlayout2.addWidget(self.browser3)
|
||||
Vlayout2.addWidget(self.browser6)
|
||||
Vlayout2.addWidget(self.browser5)
|
||||
Vlayout2.addWidget(self.browser7)
|
||||
Vlayout2.addWidget(self.browser8)
|
||||
Vlayout2.addWidget(self.browser9)
|
||||
Vlayout2.addWidget(self.browser10)
|
||||
# Vlayout2.setStretch(0, 1)
|
||||
# Vlayout2.setStretch(1, 10)
|
||||
|
||||
scrollAreaContent.setLayout(Vlayout2)
|
||||
scrollArea.setWidget(scrollAreaContent)
|
||||
main_box.addWidget(scrollArea)
|
||||
# self.scrollArea.setWidget(scrollAreaContent)
|
||||
self.scrollArea.setWidget(self.browser9)
|
||||
main_box.addWidget(self.browser10)
|
||||
main_box.addWidget(self.scrollArea)
|
||||
main_box.setStretch(0, 1)
|
||||
main_box.setStretch(1, 10)
|
||||
'''
|
||||
|
@ -32,10 +32,10 @@ Type = {
|
||||
'436207665': '发红包',
|
||||
'49': '分享链接'
|
||||
}
|
||||
charts_width = 700
|
||||
charts_height = 600
|
||||
wordcloud_width = 700
|
||||
wordcloud_height = 600
|
||||
charts_width = 1000
|
||||
charts_height = 500
|
||||
wordcloud_width = 1000
|
||||
wordcloud_height = 500
|
||||
|
||||
|
||||
def send_recv_rate(username):
|
||||
|
@ -23,6 +23,11 @@ EMOTION = 1
|
||||
ANALYSIS = 2
|
||||
|
||||
|
||||
class StackedWidget():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
class ContactController(QWidget, Ui_Dialog):
|
||||
exitSignal = pyqtSignal()
|
||||
urlSignal = pyqtSignal(QUrl)
|
||||
@ -68,14 +73,16 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
self.btn_emotion.clicked.connect(self.emotionale_Analysis)
|
||||
|
||||
self.lay0 = QVBoxLayout()
|
||||
self.widget.setLayout(self.lay0)
|
||||
self.widget.setStyleSheet('''QWidget{background-color:rgb(255, 255, 255);}''')
|
||||
# self.widget.setLayout(self.lay0)
|
||||
# self.widget.setStyleSheet('''QWidget{background-color:rgb(255, 255, 255);}''')
|
||||
self.stackedWidget.setStyleSheet('''QWidget{background-color:rgb(255, 255, 255);}''')
|
||||
self.frame = QtWidgets.QFrame()
|
||||
self.frame.setObjectName("frame")
|
||||
self.userinfo = userinfoUi.Ui_Frame() # 联系人信息界面
|
||||
self.userinfo.setupUi(self.frame)
|
||||
self.userinfo.progressBar.setVisible(False)
|
||||
self.lay0.addWidget(self.frame)
|
||||
self.stackedWidget.addWidget(self.frame)
|
||||
# self.lay0.addWidget(self.frame)
|
||||
|
||||
def showContact(self):
|
||||
"""
|
||||
@ -111,7 +118,7 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
:return:
|
||||
"""
|
||||
self.now_talkerId = talkerId
|
||||
self.frame.setVisible(True)
|
||||
# self.frame.setVisible(True)
|
||||
self.setViewVisible(self.now_talkerId)
|
||||
# 把当前按钮设置为灰色
|
||||
if self.last_talkerId and self.last_talkerId != talkerId:
|
||||
@ -126,15 +133,17 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
"QPushButton:hover{background-color: rgb(209,209,209);}\n"
|
||||
)
|
||||
# 设置联系人的基本信息
|
||||
conRemark = data.get_conRemark(talkerId)
|
||||
nickname, alias = data.get_nickname(talkerId)
|
||||
conRemark = self.contacts[talkerId].conRemark
|
||||
nickname = self.contacts[talkerId].nickname
|
||||
alias = self.contacts[talkerId].alias
|
||||
|
||||
self.label_remark.setText(conRemark)
|
||||
self.ta_username = talkerId
|
||||
if '@chatroom' in talkerId:
|
||||
self.chatroomFlag = True
|
||||
else:
|
||||
self.chatroomFlag = False
|
||||
self.ta_avatar = data.get_avator(talkerId)
|
||||
self.ta_avatar = self.contacts[talkerId].avatar
|
||||
self.userinfo.l_remark.setText(conRemark)
|
||||
pixmap = QPixmap(self.ta_avatar).scaled(60, 60) # 按指定路径找到图片
|
||||
self.userinfo.l_avatar.setPixmap(pixmap)
|
||||
@ -147,6 +156,7 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
导出聊天记录
|
||||
:return:
|
||||
"""
|
||||
self.setViewVisible(self.now_talkerId)
|
||||
self.outputThread = output.Output(self.Me, self.now_talkerId)
|
||||
self.outputThread.progressSignal.connect(self.output_progress)
|
||||
self.outputThread.rangeSignal.connect(self.set_progressBar_range)
|
||||
@ -187,8 +197,10 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
else:
|
||||
self.setViewVisible(self.now_talkerId)
|
||||
self.view_analysis[self.now_talkerId] = analysis.AnalysisController(self.now_talkerId)
|
||||
self.lay0.addWidget(self.view_analysis[self.now_talkerId])
|
||||
# self.lay0.addWidget(self.view_analysis[self.now_talkerId])
|
||||
self.last_analysis = self.now_talkerId
|
||||
self.stackedWidget.addWidget(self.view_analysis[self.now_talkerId])
|
||||
self.setViewVisible(self.now_talkerId, mod=ANALYSIS)
|
||||
|
||||
def emotionale_Analysis(self):
|
||||
print('情感分析', data.get_conRemark(self.now_talkerId))
|
||||
@ -202,15 +214,34 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
else:
|
||||
self.setViewVisible(self.now_talkerId)
|
||||
self.view_emotion[self.now_talkerId] = emotion.EmotionController(self.ta_username)
|
||||
self.lay0.addWidget(self.view_emotion[self.now_talkerId])
|
||||
# self.lay0.addWidget(self.view_emotion[self.now_talkerId])
|
||||
self.last_analysis = self.now_talkerId
|
||||
self.stackedWidget.addWidget(self.view_emotion[self.now_talkerId])
|
||||
self.setViewVisible(self.now_talkerId, mod=EMOTION)
|
||||
pass
|
||||
|
||||
def showUserinfo(self):
|
||||
self.analysisView = analysis.AnalysisController(self.now_talkerId)
|
||||
self.lay0 = QHBoxLayout()
|
||||
self.widget.setLayout(self.lay0)
|
||||
self.lay0.addWidget(self.analysisView)
|
||||
pass
|
||||
# self.analysisView = analysis.AnalysisController(self.now_talkerId)
|
||||
# # self.lay0 = QHBoxLayout()
|
||||
# # self.widget.setLayout(self.lay0)
|
||||
# self.lay0.addWidget(self.analysisView)
|
||||
|
||||
def setViewVisible(self, wxid: str, mod=None):
|
||||
"""
|
||||
设置当前可见窗口
|
||||
"""
|
||||
match mod:
|
||||
case None:
|
||||
self.stackedWidget.setCurrentWidget(self.frame)
|
||||
case 1:
|
||||
if not self.last_analysis:
|
||||
return False
|
||||
self.stackedWidget.setCurrentWidget(self.view_emotion[self.now_talkerId])
|
||||
case 2:
|
||||
if not self.last_analysis:
|
||||
return False
|
||||
self.stackedWidget.setCurrentWidget(self.view_analysis[self.now_talkerId])
|
||||
|
||||
def back(self):
|
||||
"""
|
||||
@ -219,36 +250,6 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
self.frame.setVisible(True)
|
||||
self.setViewVisible(self.now_talkerId)
|
||||
|
||||
def setViewVisible(self, wxid: str, mod=None):
|
||||
"""将wxid的视图设置为可见"""
|
||||
if not self.last_analysis:
|
||||
return False
|
||||
if mod == EMOTION:
|
||||
for key, value in self.view_emotion.items():
|
||||
# 如果key==wxid则将该视图设置为可见,否则不可见
|
||||
if key == wxid:
|
||||
print(data.get_conRemark(wxid), '视图可见')
|
||||
value.setVisible(True)
|
||||
else:
|
||||
print(data.get_conRemark(key), '视图不可见')
|
||||
value.setVisible(False)
|
||||
for key, value in self.view_analysis.items():
|
||||
value.setVisible(False)
|
||||
elif mod == ANALYSIS:
|
||||
for key, value in self.view_analysis.items():
|
||||
# 如果key==wxid则将该视图设置为可见,否则不可见
|
||||
if key == wxid:
|
||||
value.setVisible(True)
|
||||
else:
|
||||
value.setVisible(False)
|
||||
for key, value in self.view_emotion.items():
|
||||
value.setVisible(False)
|
||||
else:
|
||||
for key, value in self.view_analysis.items():
|
||||
value.setVisible(False)
|
||||
for key, value in self.view_emotion.items():
|
||||
value.setVisible(False)
|
||||
|
||||
|
||||
class Contact(QtWidgets.QPushButton):
|
||||
"""
|
||||
@ -332,14 +333,15 @@ class Contact(QtWidgets.QPushButton):
|
||||
|
||||
def show_info(self, id):
|
||||
|
||||
avatar = data.get_avator(self.username)
|
||||
self.avatar = data.get_avator(self.username)
|
||||
# print(avatar)
|
||||
remark = data.get_conRemark(self.username)
|
||||
self.conRemark = data.get_conRemark(self.username)
|
||||
self.nickname, self.alias = data.get_nickname(self.username)
|
||||
time = datetime.datetime.now().strftime("%m-%d %H:%M")
|
||||
msg = '还没说话'
|
||||
pixmap = QPixmap(avatar).scaled(60, 60) # 按指定路径找到图片
|
||||
pixmap = QPixmap(self.avatar).scaled(60, 60) # 按指定路径找到图片
|
||||
self.label_avatar.setPixmap(pixmap) # 在label上显示图片
|
||||
self.label_remark.setText(remark)
|
||||
self.label_remark.setText(self.conRemark)
|
||||
self.label_msg.setText(self.digest)
|
||||
self.label_time.setText(data.timestamp2str(self.conversationTime)[2:])
|
||||
|
||||
|
@ -29,7 +29,6 @@ class Ui_Dialog(object):
|
||||
self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
|
||||
self.horizontalLayout_2.setSpacing(0)
|
||||
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
|
||||
|
||||
self.scrollArea = QtWidgets.QScrollArea(self.frame_2)
|
||||
self.scrollArea.setEnabled(True)
|
||||
self.scrollArea.setMinimumSize(QtCore.QSize(325, 0))
|
||||
@ -43,11 +42,9 @@ class Ui_Dialog(object):
|
||||
self.scrollArea.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContentsOnFirstShow)
|
||||
self.scrollArea.setWidgetResizable(False)
|
||||
self.scrollArea.setObjectName("scrollArea")
|
||||
|
||||
self.scrollAreaWidgetContents = QtWidgets.QWidget()
|
||||
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 300, 12000))
|
||||
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
|
||||
|
||||
self.pushButton_2 = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
|
||||
self.pushButton_2.setGeometry(QtCore.QRect(0, 0, 300, 80))
|
||||
self.pushButton_2.setLayoutDirection(QtCore.Qt.LeftToRight)
|
||||
@ -58,7 +55,6 @@ class Ui_Dialog(object):
|
||||
self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents)
|
||||
self.label.setGeometry(QtCore.QRect(220, 10, 72, 15))
|
||||
self.label.setObjectName("label")
|
||||
|
||||
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
|
||||
self.horizontalLayout_2.addWidget(self.scrollArea)
|
||||
self.frame = QtWidgets.QFrame(self.frame_2)
|
||||
@ -66,8 +62,6 @@ class Ui_Dialog(object):
|
||||
self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
|
||||
self.frame.setObjectName("frame")
|
||||
self.verticalLayout = QtWidgets.QVBoxLayout(self.frame)
|
||||
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.verticalLayout.setSpacing(0)
|
||||
self.verticalLayout.setObjectName("verticalLayout")
|
||||
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
|
||||
self.horizontalLayout_3.setSpacing(0)
|
||||
@ -93,12 +87,15 @@ class Ui_Dialog(object):
|
||||
self.btn_back.setObjectName("btn_back")
|
||||
self.horizontalLayout_3.addWidget(self.btn_back)
|
||||
self.verticalLayout.addLayout(self.horizontalLayout_3)
|
||||
self.widget = QtWidgets.QWidget(self.frame)
|
||||
self.widget.setAutoFillBackground(True)
|
||||
self.widget.setObjectName("widget")
|
||||
self.verticalLayout.addWidget(self.widget)
|
||||
self.verticalLayout.setStretch(0, 1)
|
||||
self.verticalLayout.setStretch(1, 30)
|
||||
self.stackedWidget = QtWidgets.QStackedWidget(self.frame)
|
||||
self.stackedWidget.setObjectName("stackedWidget")
|
||||
self.page_3 = QtWidgets.QWidget()
|
||||
self.page_3.setObjectName("page_3")
|
||||
self.stackedWidget.addWidget(self.page_3)
|
||||
self.page_4 = QtWidgets.QWidget()
|
||||
self.page_4.setObjectName("page_4")
|
||||
self.stackedWidget.addWidget(self.page_4)
|
||||
self.verticalLayout.addWidget(self.stackedWidget)
|
||||
self.horizontalLayout_2.addWidget(self.frame)
|
||||
self.horizontalLayout.addWidget(self.frame_2)
|
||||
|
||||
|
@ -158,22 +158,7 @@
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,30">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
@ -228,10 +213,9 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<widget class="QWidget" name="page_3"/>
|
||||
<widget class="QWidget" name="page_4"/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
25
app/Ui/contact/test.ui
Normal file
25
app/Ui/contact/test.ui
Normal file
@ -0,0 +1,25 @@
|
||||
<ui version="4.0">
|
||||
<author></author>
|
||||
<comment></comment>
|
||||
<exportmacro></exportmacro>
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QMenuBar" name="menubar"/>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user