diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d0c9f5e..bdf2d90 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,11 +4,11 @@ - - @@ -678,7 +676,9 @@ - diff --git a/TEST/mainwindow.ui b/TEST/mainwindow.ui deleted file mode 100644 index b559bba..0000000 --- a/TEST/mainwindow.ui +++ /dev/null @@ -1,103 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 30 - 20 - - - - - - - - PushButton - - - - - - - PushButton - - - - - - - Qt::Horizontal - - - - 29 - 20 - - - - - - - - - - - - 0 - 0 - 800 - 23 - - - - - 你好 - - - - - OK - - - - - - - - - - diff --git a/app/components/bubble_message.py b/app/components/bubble_message.py index 5396abd..708eaf3 100644 --- a/app/components/bubble_message.py +++ b/app/components/bubble_message.py @@ -11,7 +11,7 @@ class TextMessage(QLabel): def __init__(self, text, is_send=False, parent=None): super(TextMessage, self).__init__(text, parent) - self.setFont(QFont('微软雅黑', 12)) + self.setFont(QFont('Microsoft YaHei UI', 12)) self.setWordWrap(True) # self.adjustSize() self.setMaximumWidth(800) @@ -81,7 +81,7 @@ class Notice(QLabel): def __init__(self, text, type_=3, parent=None): super().__init__(text, parent) self.type_ = type_ - self.setFont(QFont('微软雅黑', 12)) + self.setFont(QFont('Microsoft YaHei UI', 12)) self.setWordWrap(True) self.setTextInteractionFlags(Qt.TextSelectableByMouse) self.setAlignment(Qt.AlignCenter) diff --git a/app/config.py b/app/config.py index 6efe682..0ac877c 100644 --- a/app/config.py +++ b/app/config.py @@ -1,7 +1,8 @@ -version = '0.2.2' +version = '0.2.3' contact = '474379264' description = [ '1. 支持获取个人信息\n', '2. 支持显示聊天界面\n', '3. 支持导出scv格式的聊天记录\n', + '4. 查找联系人\n', ] diff --git a/app/ui_pc/chat/chatUi.py b/app/ui_pc/chat/chatUi.py index b617835..ddf83ec 100644 --- a/app/ui_pc/chat/chatUi.py +++ b/app/ui_pc/chat/chatUi.py @@ -17,9 +17,10 @@ class Ui_Form(object): Form.resize(840, 752) Form.setStyleSheet("background: rgb(240, 240, 240);") self.horizontalLayout_2 = QtWidgets.QHBoxLayout(Form) + self.horizontalLayout_2.setSpacing(6) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.verticalLayout_2 = QtWidgets.QVBoxLayout() - self.verticalLayout_2.setSpacing(0) + self.verticalLayout_2.setSpacing(6) self.verticalLayout_2.setObjectName("verticalLayout_2") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") @@ -33,14 +34,19 @@ class Ui_Form(object): self.lineEdit.setMinimumSize(QtCore.QSize(200, 30)) self.lineEdit.setMaximumSize(QtCore.QSize(200, 16777215)) self.lineEdit.setStyleSheet("background:transparent;\n" - " border-width:0;\n" - " border-style:outset;\n" - " background-color:rgb(226,226,226);\n" + "border-radius:5px;\n" + "border-top: 0px solid #b2e281;\n" + "border-bottom: 0px solid #b2e281;\n" + "border-right: 0px solid #b2e281;\n" + "border-left: 0px solid #b2e281;\n" + "border-style:outset;\n" + "background-color:rgb(226,226,226);\n" " ") self.lineEdit.setCursorMoveStyle(QtCore.Qt.VisualMoveStyle) self.lineEdit.setObjectName("lineEdit") self.horizontalLayout.addWidget(self.lineEdit) self.label_2 = QtWidgets.QLabel(Form) + self.label_2.setMinimumSize(QtCore.QSize(30, 0)) self.label_2.setText("") self.label_2.setObjectName("label_2") self.horizontalLayout.addWidget(self.label_2) diff --git a/app/ui_pc/chat/chatUi.ui b/app/ui_pc/chat/chatUi.ui index 116c90c..9a08d97 100644 --- a/app/ui_pc/chat/chatUi.ui +++ b/app/ui_pc/chat/chatUi.ui @@ -17,10 +17,13 @@ background: rgb(240, 240, 240); + + 6 + - 0 + 6 @@ -49,7 +52,11 @@ background:transparent; - border-width:0; + border-radius:5px; + border-top: 0px solid #b2e281; + border-bottom: 0px solid #b2e281; + border-right: 0px solid #b2e281; + border-left: 0px solid #b2e281; border-style:outset; background-color:rgb(226,226,226); @@ -61,6 +68,12 @@ + + + 30 + 0 + + diff --git a/app/ui_pc/chat/chat_info.py b/app/ui_pc/chat/chat_info.py index 66e40b8..1df3bb3 100644 --- a/app/ui_pc/chat/chat_info.py +++ b/app/ui_pc/chat/chat_info.py @@ -84,7 +84,7 @@ class ChatInfo(QWidget): is_send = message[4] avatar = MePC().avatar if is_send else self.contact.avatar timestamp = message[5] - if type_ == 1: + if type_ == 1 or type_ == 3: if self.is_5_min(timestamp): time_message = Notice(self.last_str_time) self.last_str_time = str_time diff --git a/app/ui_pc/chat/chat_window.py b/app/ui_pc/chat/chat_window.py index 02d4db6..b91bbde 100644 --- a/app/ui_pc/chat/chat_window.py +++ b/app/ui_pc/chat/chat_window.py @@ -4,6 +4,7 @@ from PyQt5.QtWidgets import QWidget, QMessageBox, QAction, QLineEdit from app.DataBase import micro_msg, misc from app.components import ContactQListWidgetItem from app.person import ContactPC +from app.util import search from .chatUi import Ui_Form from .chat_info import ChatInfo from ..Icon import Icon @@ -54,6 +55,7 @@ class ChatWindow(QWidget, Ui_Form): self.setupUi(self) self.ok_flag = False self.setStyleSheet(Stylesheet) + self.contacts = [[], []] self.init_ui() self.show_chats() @@ -61,6 +63,7 @@ class ChatWindow(QWidget, Ui_Form): search_action = QAction(self.lineEdit) search_action.setIcon(Icon.Search_Icon) self.lineEdit.addAction(search_action, QLineEdit.LeadingPosition) + self.lineEdit.returnPressed.connect(self.search_contact) self.listWidget.clear() self.listWidget.currentRowChanged.connect(self.setCurrentIndex) self.listWidget.setCurrentRow(0) @@ -80,7 +83,23 @@ class ChatWindow(QWidget, Ui_Form): self.show_thread.start() self.ok_flag = True + def search_contact(self): + content = self.lineEdit.text() + if not content: + return + index = self.search_contact_index(content) + self.select_contact_by_index(index) + + def search_contact_index(self, content: str) -> int: + return search.search_by_content(content, self.contacts) + + def select_contact_by_index(self, index): + self.stackedWidget.setCurrentIndex(index) + self.listWidget.setCurrentRow(index) + def show_chat(self, contact): + self.contacts[0].append(contact.remark) + self.contacts[1].append(contact.nickName) contact_item = ContactQListWidgetItem(contact.remark, contact.smallHeadImgUrl, contact.smallHeadImgBLOG) self.listWidget.addItem(contact_item) self.listWidget.setItemWidget(contact_item, contact_item.widget) diff --git a/app/ui_pc/contact/contactUi.py b/app/ui_pc/contact/contactUi.py index 3c70aca..ff13d8c 100644 --- a/app/ui_pc/contact/contactUi.py +++ b/app/ui_pc/contact/contactUi.py @@ -19,7 +19,7 @@ class Ui_Form(object): self.horizontalLayout_2 = QtWidgets.QHBoxLayout(Form) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.verticalLayout_2 = QtWidgets.QVBoxLayout() - self.verticalLayout_2.setSpacing(0) + self.verticalLayout_2.setSpacing(6) self.verticalLayout_2.setObjectName("verticalLayout_2") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") @@ -33,13 +33,20 @@ class Ui_Form(object): self.lineEdit.setMinimumSize(QtCore.QSize(200, 30)) self.lineEdit.setMaximumSize(QtCore.QSize(200, 16777215)) self.lineEdit.setStyleSheet("background:transparent;\n" - "border-width:0;\n" + "border-radius:5px;\n" + "border-top: 0px solid #b2e281;\n" + "border-bottom: 0px solid #b2e281;\n" + "border-right: 0px solid #b2e281;\n" + "border-left: 0px solid #b2e281;\n" "border-style:outset;\n" - "background-color:rgb(226,226,226);") + "background-color:rgb(226,226,226);\n" + " ") self.lineEdit.setCursorMoveStyle(QtCore.Qt.VisualMoveStyle) self.lineEdit.setObjectName("lineEdit") self.horizontalLayout.addWidget(self.lineEdit) self.label_2 = QtWidgets.QLabel(Form) + self.label_2.setMinimumSize(QtCore.QSize(30, 0)) + self.label_2.setMaximumSize(QtCore.QSize(30, 16777215)) self.label_2.setText("") self.label_2.setObjectName("label_2") self.horizontalLayout.addWidget(self.label_2) diff --git a/app/ui_pc/contact/contactUi.ui b/app/ui_pc/contact/contactUi.ui index 116c90c..fbacbc5 100644 --- a/app/ui_pc/contact/contactUi.ui +++ b/app/ui_pc/contact/contactUi.ui @@ -20,7 +20,7 @@ - 0 + 6 @@ -49,7 +49,11 @@ background:transparent; - border-width:0; + border-radius:5px; + border-top: 0px solid #b2e281; + border-bottom: 0px solid #b2e281; + border-right: 0px solid #b2e281; + border-left: 0px solid #b2e281; border-style:outset; background-color:rgb(226,226,226); @@ -61,6 +65,18 @@ + + + 30 + 0 + + + + + 30 + 16777215 + + diff --git a/app/ui_pc/contact/contact_window.py b/app/ui_pc/contact/contact_window.py index c0d7adc..edac14f 100644 --- a/app/ui_pc/contact/contact_window.py +++ b/app/ui_pc/contact/contact_window.py @@ -7,6 +7,7 @@ from app.person import ContactPC from .contactInfo import ContactInfo from .contactUi import Ui_Form from ..Icon import Icon +from ...util import search # 美化样式表 Stylesheet = """ @@ -55,12 +56,14 @@ class ContactWindow(QWidget, Ui_Form): self.ok_flag = False self.setStyleSheet(Stylesheet) self.init_ui() + self.contacts = [[], []] self.show_contacts() def init_ui(self): search_action = QAction(self.lineEdit) search_action.setIcon(Icon.Search_Icon) self.lineEdit.addAction(search_action, QLineEdit.LeadingPosition) + self.lineEdit.returnPressed.connect(self.search_contact) self.listWidget.clear() self.listWidget.currentRowChanged.connect(self.setCurrentIndex) self.listWidget.setCurrentRow(0) @@ -79,7 +82,16 @@ class ContactWindow(QWidget, Ui_Form): self.show_thread.start() self.ok_flag = True - def show_contact(self, contact): + def search_contact(self): + keyword = self.lineEdit.text() + if keyword: + index = search.search_by_content(keyword, self.contacts) + self.listWidget.setCurrentRow(index) + self.stackedWidget.setCurrentIndex(index) + + def show_contact(self, contact: ContactPC): + self.contacts[0].append(contact.remark) + self.contacts[1].append(contact.nickName) contact_item = ContactQListWidgetItem(contact.remark, contact.smallHeadImgUrl, contact.smallHeadImgBLOG) self.listWidget.addItem(contact_item) self.listWidget.setItemWidget(contact_item, contact_item.widget) diff --git a/app/ui_pc/tool/pc_decrypt/decryptUi.py b/app/ui_pc/tool/pc_decrypt/decryptUi.py index 99579ae..3fed138 100644 --- a/app/ui_pc/tool/pc_decrypt/decryptUi.py +++ b/app/ui_pc/tool/pc_decrypt/decryptUi.py @@ -51,8 +51,16 @@ class Ui_Dialog(object): self.label_7.setObjectName("label_7") self.gridLayout.addWidget(self.label_7, 1, 0, 1, 1) self.lineEdit = QtWidgets.QLineEdit(Dialog) - self.lineEdit.setStyleSheet("\n" - " background:transparent;border-width:0;border-style:outset\n" + self.lineEdit.setStyleSheet("background:transparent;\n" + "\n" + "border-radius:5px;\n" + "border-top: 0px solid #b2e281;\n" + "border-bottom: 2px solid black;\n" + "border-right: 0px solid #b2e281;\n" + "border-left: 0px solid #b2e281;\n" + "\n" + " \n" + "border-style:outset\n" " ") self.lineEdit.setFrame(False) self.lineEdit.setObjectName("lineEdit") diff --git a/app/ui_pc/tool/pc_decrypt/decryptUi.ui b/app/ui_pc/tool/pc_decrypt/decryptUi.ui index 04d9673..dff82c5 100644 --- a/app/ui_pc/tool/pc_decrypt/decryptUi.ui +++ b/app/ui_pc/tool/pc_decrypt/decryptUi.ui @@ -92,8 +92,16 @@ - - background:transparent;border-width:0;border-style:outset + background:transparent; + + border-radius:5px; + border-top: 0px solid #b2e281; + border-bottom: 2px solid black; + border-right: 0px solid #b2e281; + border-left: 0px solid #b2e281; + + + border-style:outset diff --git a/app/ui_pc/tool/pc_decrypt/pc_decrypt.py b/app/ui_pc/tool/pc_decrypt/pc_decrypt.py index 41f19f7..c3e3499 100644 --- a/app/ui_pc/tool/pc_decrypt/pc_decrypt.py +++ b/app/ui_pc/tool/pc_decrypt/pc_decrypt.py @@ -22,6 +22,8 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog): self.pushButton_3.clicked.connect(self.decrypt) self.btn_getinfo.clicked.connect(self.get_info) self.btn_db_dir.clicked.connect(self.select_db_dir) + self.lineEdit.returnPressed.connect(self.set_wxid) + self.lineEdit.textChanged.connect(self.set_wxid_) self.info = {} self.lineEdit.setFocus() self.ready = False @@ -54,6 +56,13 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog): print(e) QMessageBox.critical(self, "错误", "请登录微信") + def set_wxid_(self): + self.info['wxid'] = self.lineEdit.text() + + def set_wxid(self): + self.info['wxid'] = self.lineEdit.text() + QMessageBox.information(self, "ok", f"wxid修改成功{self.info['wxid']}") + def select_db_dir(self): directory = QtWidgets.QFileDialog.getExistingDirectory( self, "选取微信安装目录——能看到All Users文件夹", diff --git a/app/util/search.py b/app/util/search.py new file mode 100644 index 0000000..59e8a00 --- /dev/null +++ b/app/util/search.py @@ -0,0 +1,14 @@ +from typing import List + +from fuzzywuzzy import process + + +def search_by_content(key, choices: List[List]): + result = [] + for i, choice in enumerate(choices): + res = process.extractOne(key, choice) + result.append((res, i)) + result.sort(key=lambda x: x[0][1], reverse=True) + k = result[0][1] + item = result[0][0][0] + return choices[k].index(item) diff --git a/doc/images/chat_.png b/doc/images/chat_.png index 9e3ec20..631722a 100644 Binary files a/doc/images/chat_.png and b/doc/images/chat_.png differ diff --git a/requirements.txt b/requirements.txt index 638c6f7..afa9ee0 100644 Binary files a/requirements.txt and b/requirements.txt differ