mirror of
https://github.com/LC044/WeChatMsg
synced 2024-11-09 09:31:18 +08:00
合并联系人ui,加快启动速度 #271
This commit is contained in:
parent
1bb5c97274
commit
814f678f48
@ -54,7 +54,9 @@ class ContactInfo(QWidget, Ui_Form):
|
||||
self.toDocxAct.triggered.connect(self.output)
|
||||
self.toCSVAct.triggered.connect(self.output)
|
||||
self.toTxtAct.triggered.connect(self.output)
|
||||
|
||||
def set_contact(self,contact:Contact):
|
||||
self.view_userinfo.set_contact(contact)
|
||||
self.contact = contact
|
||||
def toolButton_show(self):
|
||||
self.toolButton_output.showMenu()
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
from typing import List
|
||||
|
||||
from PyQt5.QtCore import QThread, pyqtSignal
|
||||
from PyQt5.QtWidgets import QWidget, QMessageBox, QAction, QLineEdit
|
||||
from PyQt5.QtWidgets import QWidget, QMessageBox, QAction, QLineEdit, QLabel
|
||||
|
||||
from app.DataBase import micro_msg_db, misc_db
|
||||
from app.components import ContactQListWidgetItem, ScrollBar
|
||||
@ -62,7 +64,9 @@ class ContactWindow(QWidget, Ui_Form):
|
||||
self.setStyleSheet(Stylesheet)
|
||||
self.init_ui()
|
||||
self.contacts = [[], []]
|
||||
self.contacts_list:List[Contact] = []
|
||||
self.show_contacts()
|
||||
self.contact_info_window = None
|
||||
|
||||
def init_ui(self):
|
||||
search_action = QAction(self.lineEdit)
|
||||
@ -120,8 +124,10 @@ class ContactWindow(QWidget, Ui_Form):
|
||||
contact_item = ContactQListWidgetItem(contact.remark, contact.smallHeadImgUrl, contact.smallHeadImgBLOG)
|
||||
self.listWidget.addItem(contact_item)
|
||||
self.listWidget.setItemWidget(contact_item, contact_item.widget)
|
||||
contact_info_window = ContactInfo(contact)
|
||||
self.stackedWidget.addWidget(contact_info_window)
|
||||
self.contacts_list.append(contact)
|
||||
if self.contact_info_window is None:
|
||||
self.contact_info_window = ContactInfo(contact)
|
||||
self.stackedWidget.addWidget(self.contact_info_window)
|
||||
|
||||
def setCurrentIndex(self, row):
|
||||
# print(row)
|
||||
@ -131,7 +137,8 @@ class ContactWindow(QWidget, Ui_Form):
|
||||
item = self.listWidget.item(row)
|
||||
item.select()
|
||||
self.now_index = row
|
||||
self.stackedWidget.setCurrentIndex(row)
|
||||
# self.stackedWidget.setCurrentIndex(row)
|
||||
self.contact_info_window.set_contact(self.contacts_list[row])
|
||||
|
||||
|
||||
class ShowContactThread(QThread):
|
||||
|
@ -1,6 +1,7 @@
|
||||
from PyQt5.QtGui import QPixmap
|
||||
from PyQt5.QtWidgets import *
|
||||
|
||||
from app.person import Contact
|
||||
from app.util.region_conversion import conversion_region_to_chinese
|
||||
from .userinfoUi import Ui_Frame
|
||||
from ...Icon import Icon
|
||||
@ -34,3 +35,28 @@ class UserinfoController(QWidget, Ui_Frame):
|
||||
pixmap = QPixmap(Icon.Woman_Icon_path)
|
||||
self.l_gender.setPixmap(pixmap)
|
||||
# self.l_gender.setText()
|
||||
def set_contact(self,contact:Contact):
|
||||
self.l_remark.setText(contact.remark)
|
||||
self.l_avatar.setPixmap(contact.avatar)
|
||||
self.l_nickname.setText(f'昵称:{contact.nickName}')
|
||||
self.l_username.setText(f'微信号:{contact.alias}')
|
||||
self.lineEdit.setText(contact.remark)
|
||||
# self.l_region.setVisible(False)
|
||||
self.l_contact_label.setText(contact.label_name)
|
||||
if contact.detail:
|
||||
self.l_signature.setText(contact.detail.get('signature'))
|
||||
self.l_tel.setText(contact.detail.get('telephone'))
|
||||
region = contact.detail.get('region')
|
||||
area = conversion_region_to_chinese(region)
|
||||
self.l_region.setText(f'地区:{area}')
|
||||
gender_code = contact.detail.get('gender')
|
||||
gender = ''
|
||||
pixmap = QPixmap()
|
||||
if gender_code == 1:
|
||||
gender = '男'
|
||||
pixmap = QPixmap(Icon.Man_Icon_path)
|
||||
elif gender_code == 2:
|
||||
gender = '女'
|
||||
pixmap = QPixmap(Icon.Woman_Icon_path)
|
||||
self.l_gender.setPixmap(pixmap)
|
||||
# self.l_gender.setText()
|
3
main.py
3
main.py
@ -66,8 +66,9 @@ class ViewController(QWidget):
|
||||
self.viewMainWindow.setWindowTitle(f"留痕-{version}")
|
||||
self.viewMainWindow.show()
|
||||
end = time.time()
|
||||
print('ok', '本次加载用了', end - start, 's')
|
||||
self.viewMainWindow.init_ui()
|
||||
print('ok', '本次加载用了', end - start, 's')
|
||||
|
||||
except Exception as e:
|
||||
print(f"Exception: {e}")
|
||||
logger.error(traceback.print_exc())
|
||||
|
Loading…
Reference in New Issue
Block a user