diff --git a/app/ui/contact/contactInfo.py b/app/ui/contact/contactInfo.py index b885a47..1b26047 100644 --- a/app/ui/contact/contactInfo.py +++ b/app/ui/contact/contactInfo.py @@ -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() diff --git a/app/ui/contact/contact_window.py b/app/ui/contact/contact_window.py index 8e69af0..c89de47 100644 --- a/app/ui/contact/contact_window.py +++ b/app/ui/contact/contact_window.py @@ -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): diff --git a/app/ui/contact/userinfo/userinfo.py b/app/ui/contact/userinfo/userinfo.py index c0359fe..1ce0b3a 100644 --- a/app/ui/contact/userinfo/userinfo.py +++ b/app/ui/contact/userinfo/userinfo.py @@ -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() \ No newline at end of file diff --git a/main.py b/main.py index 8d175cb..a19e6a9 100644 --- a/main.py +++ b/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())