Skip to content

Commit

Permalink
支持查找功能
Browse files Browse the repository at this point in the history
  • Loading branch information
LC044 committed Nov 19, 2023
1 parent 1995011 commit d6bac16
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 136 deletions.
47 changes: 27 additions & 20 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

103 changes: 0 additions & 103 deletions TEST/mainwindow.ui

This file was deleted.

3 changes: 2 additions & 1 deletion app/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
version = '0.2.2'
version = '0.2.3'
contact = '474379264'
description = [
'1. 支持获取个人信息\n',
'2. 支持显示聊天界面\n',
'3. 支持导出scv格式的聊天记录\n',
'4. 查找联系人\n',
]
14 changes: 10 additions & 4 deletions app/ui_pc/chat/chatUi.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ def setupUi(self, Form):
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")
Expand All @@ -33,14 +34,19 @@ def setupUi(self, Form):
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)
Expand Down
17 changes: 15 additions & 2 deletions app/ui_pc/chat/chatUi.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
<string notr="true">background: rgb(240, 240, 240);</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
<property name="spacing">
<number>6</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
<property name="spacing">
<number>0</number>
<number>6</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down Expand Up @@ -49,7 +52,11 @@
</property>
<property name="styleSheet">
<string notr="true">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);
</string>
Expand All @@ -61,6 +68,12 @@
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
Expand Down
19 changes: 19 additions & 0 deletions app/ui_pc/chat/chat_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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
Expand Down Expand Up @@ -54,13 +55,15 @@ def __init__(self, parent=None):
self.setupUi(self)
self.ok_flag = False
self.setStyleSheet(Stylesheet)
self.contacts = [[], []]
self.init_ui()
self.show_chats()

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)
Expand All @@ -80,7 +83,23 @@ def show_chats(self):
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)
Expand Down
13 changes: 10 additions & 3 deletions app/ui_pc/contact/contactUi.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setupUi(self, Form):
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")
Expand All @@ -33,13 +33,20 @@ def setupUi(self, Form):
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)
Expand Down
Loading

0 comments on commit d6bac16

Please sign in to comment.