diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index d0c9f5e..8af5f9b 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,18 @@
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
@@ -94,7 +101,7 @@
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"last_opened_file_path": "D:/Program Files/Python310/Scripts/pyuic5.exe",
- "settings.editor.selected.configurable": "editor.preferences.tabs"
+ "settings.editor.selected.configurable": "preferences.lookFeel"
}
}]]>
@@ -210,7 +217,7 @@
-
+
@@ -218,14 +225,14 @@
-
+
-
+
-
+
@@ -255,10 +262,10 @@
+
-
@@ -274,13 +281,6 @@
1672848140146
-
- 1698248457797
-
-
-
- 1698248457797
-
1698331547560
@@ -617,7 +617,14 @@
1700309638496
-
+
+ 1700373695942
+
+
+
+ 1700373695942
+
+
@@ -653,7 +660,6 @@
-
@@ -678,7 +684,8 @@
-
+
+
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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
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_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/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