diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c51249f..9cca919 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,13 +4,10 @@
-
+
-
-
-
-
-
+
+
@@ -39,6 +36,9 @@
"state": "OPEN"
}
}
+
+
+
@@ -554,7 +561,6 @@
-
@@ -563,7 +569,8 @@
-
+
+
@@ -577,7 +584,7 @@
file://$PROJECT_DIR$/main.py
- 18
+ 19
diff --git a/app/Ui/contact/contact.py b/app/Ui/contact/contact.py
index 6caa187..df62d7e 100644
--- a/app/Ui/contact/contact.py
+++ b/app/Ui/contact/contact.py
@@ -44,37 +44,33 @@ class ContactController(QWidget, Ui_Dialog):
self.show_flag = False
self.last_talkerId = None
self.now_talkerId = None
- self.showContact()
+ # self.showContact()
+ self.show_thread = ShowContactThread()
+ self.show_thread.showSingal.connect(self.showContact)
+ self.show_thread.heightSingal.connect(self.setScreenAreaHeight)
+ self.show_thread.start()
- def showContact(self):
+ def showContact(self, data_):
"""
+ data:Tuple[rconversation,index:int]
显示联系人
:return:
"""
- print('show')
- if self.show_flag:
- return
- self.show_flag = True
- rconversations = data.get_rconversation()
- max_hight = max(len(rconversations) * 80, 680)
- # 设置滚动区域的高度
- self.scrollAreaWidgetContents.setGeometry(
- QtCore.QRect(0, 0, 300, max_hight))
+ rconversation, i = data_
+ username = rconversation[1]
+ # print(username)
+ pushButton_2 = MyLabel.ContactUi(self.scrollAreaWidgetContents, i, rconversation)
+ pushButton_2.setGeometry(QtCore.QRect(0, 80 * i, 300, 80))
+ pushButton_2.setLayoutDirection(QtCore.Qt.LeftToRight)
+ pushButton_2.clicked.connect(pushButton_2.show_msg)
+ pushButton_2.usernameSingal.connect(self.Contact)
+ self.contacts[username] = pushButton_2
+ self.contactInfo[username] = ContactInfo(username, self.Me)
+ self.stackedWidget.addWidget(self.contactInfo[username])
- for i in range(len(rconversations)):
- rconversation = rconversations[i]
- username = rconversation[1]
- # 创建联系人按钮对象
- # 将实例化对象添加到self.contacts储存起来
- # pushButton_2 = Contact(self.scrollAreaWidgetContents, i, rconversation)
- pushButton_2 = MyLabel.ContactUi(self.scrollAreaWidgetContents, i, rconversation)
- pushButton_2.setGeometry(QtCore.QRect(0, 80 * i, 300, 80))
- pushButton_2.setLayoutDirection(QtCore.Qt.LeftToRight)
- pushButton_2.clicked.connect(pushButton_2.show_msg)
- pushButton_2.usernameSingal.connect(self.Contact)
- self.contacts[username] = pushButton_2
- self.contactInfo[username] = ContactInfo(username, self.Me)
- self.stackedWidget.addWidget(self.contactInfo[username])
+ def setScreenAreaHeight(self, height: int):
+ self.scrollAreaWidgetContents.setGeometry(
+ QtCore.QRect(0, 0, 300, height))
def Contact(self, talkerId):
"""
@@ -101,3 +97,19 @@ class ContactController(QWidget, Ui_Dialog):
self.chatroomFlag = True
else:
self.chatroomFlag = False
+
+
+class ShowContactThread(QThread):
+ showSingal = pyqtSignal(tuple)
+ heightSingal = pyqtSignal(int)
+
+ def __init__(self):
+ super().__init__()
+
+ def run(self) -> None:
+ rconversations = data.get_rconversation()
+ max_height = max(len(rconversations) * 80, 680)
+ # 设置滚动区域的高度
+ self.heightSingal.emit(max_height)
+ for i in range(len(rconversations)):
+ self.showSingal.emit((rconversations[i], i))
diff --git a/app/Ui/mainview.py b/app/Ui/mainview.py
index abd9842..5aa9ce9 100644
--- a/app/Ui/mainview.py
+++ b/app/Ui/mainview.py
@@ -104,7 +104,6 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
"QPushButton:hover{background-color: rgb(209,209,209);}\n")
self.last_btn = self.btn_contact
self.stackedWidget.setCurrentIndex(1)
- self.contactView.showContact()
def myInfo(self):
"""
diff --git a/main.py b/main.py
index 20ef920..3b48bdd 100644
--- a/main.py
+++ b/main.py
@@ -1,4 +1,5 @@
import sys
+import time
from PyQt5.QtWidgets import *
@@ -42,12 +43,15 @@ class ViewController:
:return:
"""
username = ''
+ start = time.time()
self.viewMainWIn = mainview.MainWinController(username=username)
self.viewMainWIn.setWindowTitle("Chat")
# print(username)
self.viewMainWIn.username = username
# self.viewMainWIn.exitSignal.connect(self.loadDecryptView) # 不需要回到登录界面可以省略
self.viewMainWIn.show()
+ end = time.time()
+ print('ok', end - start)
# self.viewMainWIn.signUp()