mirror of
https://github.com/LC044/WeChatMsg
synced 2024-11-14 05:21:41 +08:00
重构一些class,删除一些不必要的文件
This commit is contained in:
parent
3fb4e8149d
commit
2472d3bce2
@ -4,11 +4,12 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="修改部分UI">
|
||||
<change afterPath="$PROJECT_DIR$/app/util/__init__.py" afterDir="false" />
|
||||
<list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="update readme">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/utils/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/person.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/readme.md" beforeDir="false" afterPath="$PROJECT_DIR$/readme.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/DataBase/data.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/DataBase/data.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/Ui/MyComponents/Contact.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/Ui/MyComponents/Contact.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/Ui/contact/contact.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/Ui/contact/contact.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/person.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/person.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -129,7 +130,7 @@
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="true" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
@ -437,7 +438,14 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1698592548210</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="35" />
|
||||
<task id="LOCAL-00035" summary="update readme">
|
||||
<created>1698681328723</created>
|
||||
<option name="number" value="00035" />
|
||||
<option name="presentableId" value="LOCAL-00035" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1698681328723</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="36" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="UnknownFeatures">
|
||||
@ -487,12 +495,12 @@
|
||||
<MESSAGE value="readme" />
|
||||
<MESSAGE value="mainwindows文件修正" />
|
||||
<MESSAGE value="match语法说明" />
|
||||
<MESSAGE value="update readme" />
|
||||
<MESSAGE value="增加群二维码" />
|
||||
<MESSAGE value="支持导出csv格式聊天记录" />
|
||||
<MESSAGE value="增加几个图标" />
|
||||
<MESSAGE value="修改部分UI" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="修改部分UI" />
|
||||
<MESSAGE value="update readme" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="update readme" />
|
||||
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
|
||||
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
|
||||
</component>
|
||||
|
@ -101,9 +101,10 @@ def is_db_exist() -> bool:
|
||||
cursor.execute(sql)
|
||||
result = cursor.fetchone()
|
||||
me = Me(result[2])
|
||||
return True
|
||||
except Exception as e:
|
||||
return False
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def init_database():
|
||||
@ -211,7 +212,7 @@ def avatar_md5(wxid):
|
||||
|
||||
def get_avator(wxid):
|
||||
if wxid == None:
|
||||
return
|
||||
return './app/data/icons/default_avatar.svg'
|
||||
wxid = str(wxid)
|
||||
avatar = avatar_md5(wxid)
|
||||
avatar_path = r"./app/data/avatar/"
|
||||
|
@ -1,18 +1,44 @@
|
||||
from datetime import datetime
|
||||
|
||||
from PyQt5 import QtWidgets
|
||||
from PyQt5 import QtWidgets, QtGui, QtCore
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtGui import *
|
||||
|
||||
import app.DataBase.data as data
|
||||
from app.person import Contact
|
||||
|
||||
|
||||
class Contact(QtWidgets.QPushButton):
|
||||
class ContactUi(QtWidgets.QPushButton):
|
||||
"""
|
||||
联系人类,继承自pyqt的按钮,里面封装了联系人头像等标签
|
||||
"""
|
||||
usernameSingal = pyqtSignal(str)
|
||||
|
||||
def __init__(self, Ui, id=None, contact=None):
|
||||
super(Contact, self).__init__(Ui)
|
||||
def __init__(self, Ui, id=None, rconversation=None):
|
||||
super(ContactUi, self).__init__(Ui)
|
||||
self.contact: Contact = Contact(rconversation[1])
|
||||
self.init_ui(Ui)
|
||||
self.msgCount = rconversation[0]
|
||||
self.username = rconversation[1]
|
||||
self.conversationTime = rconversation[6]
|
||||
self.msgType = rconversation[7]
|
||||
self.digest = rconversation[8]
|
||||
hasTrunc = rconversation[10]
|
||||
attrflag = rconversation[11]
|
||||
if hasTrunc == 0:
|
||||
if attrflag == 0:
|
||||
self.digest = '[动画表情]'
|
||||
elif attrflag == 67108864:
|
||||
try:
|
||||
remark = data.get_conRemark(rconversation[9])
|
||||
msg = self.digest.split(':')[1].strip('\n').strip()
|
||||
self.digest = f'{remark}:{msg}'
|
||||
except Exception as e:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
self.show_info(id)
|
||||
|
||||
def init_ui(self, Ui):
|
||||
self.layoutWidget = QtWidgets.QWidget(Ui)
|
||||
self.layoutWidget.setObjectName("layoutWidget")
|
||||
self.gridLayout1 = QtWidgets.QGridLayout(self.layoutWidget)
|
||||
@ -62,37 +88,12 @@ class Contact(QtWidgets.QPushButton):
|
||||
"QPushButton {background-color: rgb(220,220,220);}"
|
||||
"QPushButton:hover{background-color: rgb(208,208,208);}\n"
|
||||
)
|
||||
self.msgCount = contact[0]
|
||||
self.username = contact[1]
|
||||
self.conversationTime = contact[6]
|
||||
self.msgType = contact[7]
|
||||
self.digest = contact[8]
|
||||
hasTrunc = contact[10]
|
||||
attrflag = contact[11]
|
||||
if hasTrunc == 0:
|
||||
if attrflag == 0:
|
||||
self.digest = '[动画表情]'
|
||||
elif attrflag == 67108864:
|
||||
try:
|
||||
remark = data.get_conRemark(contact[9])
|
||||
msg = self.digest.split(':')[1].strip('\n').strip()
|
||||
self.digest = f'{remark}:{msg}'
|
||||
except Exception as e:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
self.show_info(id)
|
||||
|
||||
def show_info(self, id):
|
||||
self.avatar = data.get_avator(self.username)
|
||||
# print(avatar)
|
||||
self.conRemark = data.get_conRemark(self.username)
|
||||
self.nickname, self.alias = data.get_nickname(self.username)
|
||||
time = datetime.now().strftime("%m-%d %H:%M")
|
||||
msg = '还没说话'
|
||||
pixmap = QPixmap(self.avatar).scaled(60, 60) # 按指定路径找到图片
|
||||
self.label_avatar.setPixmap(pixmap) # 在label上显示图片
|
||||
self.label_remark.setText(self.conRemark)
|
||||
self.label_avatar.setPixmap(self.contact.avatar) # 在label上显示图片
|
||||
self.label_remark.setText(self.contact.conRemark)
|
||||
self.label_msg.setText(self.digest)
|
||||
self.label_time.setText(data.timestamp2str(self.conversationTime)[2:])
|
||||
|
||||
|
@ -7,12 +7,13 @@
|
||||
@Version : Python3.10
|
||||
@comment : ···
|
||||
"""
|
||||
import datetime
|
||||
from typing import Dict
|
||||
|
||||
from PyQt5.QtCore import *
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtWidgets import *
|
||||
|
||||
import app.Ui.MyComponents.Contact as MyLabel
|
||||
from .analysis import analysis
|
||||
from .contactUi import *
|
||||
from .emotion import emotion
|
||||
@ -48,7 +49,7 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
self.initui()
|
||||
self.Me = Me
|
||||
self.Thread = ChatMsg(self.Me.username, None)
|
||||
self.contacts = {}
|
||||
self.contacts: Dict[str, MyLabel.ContactUi] = {}
|
||||
self.last_btn = None
|
||||
self.chat_flag = True
|
||||
self.show_flag = False
|
||||
@ -120,7 +121,8 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
username = rconversation[1]
|
||||
# 创建联系人按钮对象
|
||||
# 将实例化对象添加到self.contacts储存起来
|
||||
pushButton_2 = Contact(self.scrollAreaWidgetContents, i, rconversation)
|
||||
# pushButton_2 = Contact(self.scrollAreaWidgetContents, i, rconversation)
|
||||
pushButton_2 = MyLabel.ContactUi(self.scrollAreaWidgetContents, i, rconversation)
|
||||
pushButton_2.setGeometry(QtCore.QRect(0, 80 * i, 300, 80))
|
||||
pushButton_2.setLayoutDirection(QtCore.Qt.LeftToRight)
|
||||
pushButton_2.clicked.connect(pushButton_2.show_msg)
|
||||
@ -149,9 +151,9 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
"QPushButton:hover{background-color: rgb(209,209,209);}\n"
|
||||
)
|
||||
# 设置联系人的基本信息
|
||||
conRemark = self.contacts[talkerId].conRemark
|
||||
nickname = self.contacts[talkerId].nickname
|
||||
alias = self.contacts[talkerId].alias
|
||||
conRemark = self.contacts[talkerId].contact.conRemark
|
||||
nickname = self.contacts[talkerId].contact.nickname
|
||||
alias = self.contacts[talkerId].contact.alias
|
||||
|
||||
self.label_remark.setText(conRemark)
|
||||
self.ta_username = talkerId
|
||||
@ -159,9 +161,8 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
self.chatroomFlag = True
|
||||
else:
|
||||
self.chatroomFlag = False
|
||||
self.ta_avatar = self.contacts[talkerId].avatar
|
||||
self.userinfo.l_remark.setText(conRemark)
|
||||
pixmap = QPixmap(self.ta_avatar).scaled(60, 60) # 按指定路径找到图片
|
||||
pixmap = self.contacts[talkerId].contact.avatar
|
||||
self.userinfo.l_avatar.setPixmap(pixmap)
|
||||
self.userinfo.l_nickname.setText(f'昵称:{nickname}')
|
||||
self.userinfo.l_username.setText(f'微信号:{alias}')
|
||||
@ -291,104 +292,6 @@ class ContactController(QWidget, Ui_Dialog):
|
||||
self.setViewVisible(self.now_talkerId)
|
||||
|
||||
|
||||
class Contact(QtWidgets.QPushButton):
|
||||
"""
|
||||
联系人类,继承自pyqt的按钮,里面封装了联系人头像等标签
|
||||
"""
|
||||
usernameSingal = pyqtSignal(str)
|
||||
|
||||
def __init__(self, Ui, id=None, contact=None):
|
||||
super(Contact, self).__init__(Ui)
|
||||
self.layoutWidget = QtWidgets.QWidget(Ui)
|
||||
self.layoutWidget.setObjectName("layoutWidget")
|
||||
self.gridLayout1 = QtWidgets.QGridLayout(self.layoutWidget)
|
||||
self.gridLayout1.setSizeConstraint(QtWidgets.QLayout.SetMaximumSize)
|
||||
self.gridLayout1.setContentsMargins(10, 10, 10, 10)
|
||||
self.gridLayout1.setSpacing(10)
|
||||
self.gridLayout1.setObjectName("gridLayout1")
|
||||
self.label_time = QtWidgets.QLabel(self.layoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(8)
|
||||
self.label_time.setFont(font)
|
||||
self.label_time.setLayoutDirection(QtCore.Qt.RightToLeft)
|
||||
self.label_time.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
|
||||
self.label_time.setObjectName("label_time")
|
||||
self.gridLayout1.addWidget(self.label_time, 0, 2, 1, 1)
|
||||
self.label_remark = QtWidgets.QLabel(self.layoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Adobe 黑体 Std R")
|
||||
font.setPointSize(10)
|
||||
self.label_remark.setFont(font)
|
||||
self.label_remark.setObjectName("label_remark")
|
||||
self.gridLayout1.addWidget(self.label_remark, 0, 1, 1, 1)
|
||||
self.label_msg = QtWidgets.QLabel(self.layoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(8)
|
||||
self.label_msg.setFont(font)
|
||||
self.label_msg.setObjectName("label_msg")
|
||||
self.gridLayout1.addWidget(self.label_msg, 1, 1, 1, 2)
|
||||
self.label_avatar = QtWidgets.QLabel(self.layoutWidget)
|
||||
self.label_avatar.setMinimumSize(QtCore.QSize(60, 60))
|
||||
self.label_avatar.setMaximumSize(QtCore.QSize(60, 60))
|
||||
self.label_avatar.setLayoutDirection(QtCore.Qt.RightToLeft)
|
||||
self.label_avatar.setAutoFillBackground(False)
|
||||
self.label_avatar.setStyleSheet("background-color: #ffffff;")
|
||||
self.label_avatar.setInputMethodHints(QtCore.Qt.ImhNone)
|
||||
self.label_avatar.setFrameShape(QtWidgets.QFrame.NoFrame)
|
||||
self.label_avatar.setFrameShadow(QtWidgets.QFrame.Plain)
|
||||
self.label_avatar.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
self.label_avatar.setObjectName("label_avatar")
|
||||
self.gridLayout1.addWidget(self.label_avatar, 0, 0, 2, 1)
|
||||
self.gridLayout1.setColumnStretch(0, 1)
|
||||
self.gridLayout1.setColumnStretch(1, 6)
|
||||
self.gridLayout1.setRowStretch(0, 5)
|
||||
self.gridLayout1.setRowStretch(1, 3)
|
||||
self.setLayout(self.gridLayout1)
|
||||
self.setStyleSheet(
|
||||
"QPushButton {background-color: rgb(220,220,220);}"
|
||||
"QPushButton:hover{background-color: rgb(208,208,208);}\n"
|
||||
)
|
||||
self.msgCount = contact[0]
|
||||
self.username = contact[1]
|
||||
self.conversationTime = contact[6]
|
||||
self.msgType = contact[7]
|
||||
self.digest = contact[8]
|
||||
hasTrunc = contact[10]
|
||||
attrflag = contact[11]
|
||||
if hasTrunc == 0:
|
||||
if attrflag == 0:
|
||||
self.digest = '[动画表情]'
|
||||
elif attrflag == 67108864:
|
||||
try:
|
||||
remark = data.get_conRemark(contact[9])
|
||||
msg = self.digest.split(':')[1].strip('\n').strip()
|
||||
self.digest = f'{remark}:{msg}'
|
||||
except Exception as e:
|
||||
# print(self.digest)
|
||||
# print(e)
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
self.show_info(id)
|
||||
|
||||
def show_info(self, id):
|
||||
|
||||
self.avatar = data.get_avator(self.username)
|
||||
# print(avatar)
|
||||
self.conRemark = data.get_conRemark(self.username)
|
||||
self.nickname, self.alias = data.get_nickname(self.username)
|
||||
time = datetime.datetime.now().strftime("%m-%d %H:%M")
|
||||
msg = '还没说话'
|
||||
pixmap = QPixmap(self.avatar).scaled(60, 60) # 按指定路径找到图片
|
||||
self.label_avatar.setPixmap(pixmap) # 在label上显示图片
|
||||
self.label_remark.setText(self.conRemark)
|
||||
self.label_msg.setText(self.digest)
|
||||
self.label_time.setText(data.timestamp2str(self.conversationTime)[2:])
|
||||
|
||||
def show_msg(self):
|
||||
self.usernameSingal.emit(self.username)
|
||||
|
||||
|
||||
class ChatMsg(QThread):
|
||||
"""
|
||||
发送信息线程
|
||||
|
@ -1,8 +1,29 @@
|
||||
from PyQt5.QtGui import QPixmap
|
||||
|
||||
import app.DataBase.data as data
|
||||
|
||||
|
||||
class Person:
|
||||
def __init__(self, wxid: str):
|
||||
self.wxid = wxid
|
||||
self.username = data.get_conRemark(wxid)
|
||||
self.conRemark = data.get_conRemark(wxid)
|
||||
self.nickname, self.alias = data.get_nickname(wxid)
|
||||
self.avatar_path = data.get_avator(wxid)
|
||||
self.avatar = QPixmap(self.avatar_path).scaled(60, 60)
|
||||
|
||||
|
||||
class Me(Person):
|
||||
def __init__(self, wxid: str):
|
||||
super(Me, self).__init__(wxid)
|
||||
self.city = None
|
||||
self.province = None
|
||||
|
||||
|
||||
class Contact(Person):
|
||||
def __init__(self, wxid: str):
|
||||
super(Contact, self).__init__(wxid)
|
||||
|
||||
|
||||
class Group(Person):
|
||||
def __init__(self, wxid: str):
|
||||
super(Group, self).__init__(wxid)
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user