mirror of
https://github.com/LC044/WeChatMsg
synced 2025-03-11 14:52:14 +08:00
显示聊天图片
This commit is contained in:
parent
8851406708
commit
01a4733b55
@ -4,16 +4,15 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="文字消息设置圆角">
|
||||
<change afterPath="$PROJECT_DIR$/app/DataBase/hard_link.py" afterDir="false" />
|
||||
<list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="更新wx选择的路径">
|
||||
<change afterPath="$PROJECT_DIR$/app/util/path.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/DataBase/output_pc.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/DataBase/output_pc.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/decrypt/get_wx_info.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/decrypt/get_wx_info.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/person.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/person.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/DataBase/hard_link.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/DataBase/hard_link.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/components/bubble_message.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/components/bubble_message.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/ui_pc/Icon.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/Icon.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/ui_pc/chat/chat_info.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/chat/chat_info.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/ui_pc/mainview.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/mainview.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/ui_pc/tool/pc_decrypt/pc_decrypt.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/tool/pc_decrypt/pc_decrypt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/doc/电脑端使用教程.md" beforeDir="false" afterPath="$PROJECT_DIR$/doc/电脑端使用教程.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/readme.md" beforeDir="false" afterPath="$PROJECT_DIR$/readme.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/util/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/util/__init__.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -122,7 +121,7 @@
|
||||
<recent name="D:\Project\PythonProject\WeChatMsg\app\Ui" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="Python.decrypt_window">
|
||||
<component name="RunManager" selected="Python.main_pc">
|
||||
<configuration name="decrypt_window" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="WeChatMsg" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
@ -251,10 +250,10 @@
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python.decrypt_window" />
|
||||
<item itemvalue="Python.main_pc" />
|
||||
<item itemvalue="Python.hard_link" />
|
||||
<item itemvalue="Python.test" />
|
||||
<item itemvalue="Python.hard_link" />
|
||||
<item itemvalue="Python.decrypt_window" />
|
||||
<item itemvalue="Python.main" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
@ -271,13 +270,6 @@
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1672848140146</updated>
|
||||
</task>
|
||||
<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>
|
||||
<task id="LOCAL-00036" summary="重构一些class,删除一些不必要的文件">
|
||||
<created>1698765961025</created>
|
||||
<option name="number" value="00036" />
|
||||
@ -614,7 +606,14 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1700478493497</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="84" />
|
||||
<task id="LOCAL-00084" summary="更新wx选择的路径">
|
||||
<created>1700490633275</created>
|
||||
<option name="number" value="00084" />
|
||||
<option name="presentableId" value="LOCAL-00084" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1700490633275</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="85" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="UnknownFeatures">
|
||||
@ -650,7 +649,6 @@
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="增加PC端微信解密条件的判断" />
|
||||
<MESSAGE value="删除多余的Word文件" />
|
||||
<MESSAGE value="修复无法查找wxid的bug" />
|
||||
<MESSAGE value="修改UI" />
|
||||
@ -675,7 +673,8 @@
|
||||
<MESSAGE value="支持查找功能" />
|
||||
<MESSAGE value="修复修改wixd的bug" />
|
||||
<MESSAGE value="文字消息设置圆角" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="文字消息设置圆角" />
|
||||
<MESSAGE value="更新wx选择的路径" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="更新wx选择的路径" />
|
||||
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
|
||||
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
|
||||
</component>
|
||||
|
@ -8,7 +8,7 @@ lock = threading.Lock()
|
||||
DB = None
|
||||
cursor = None
|
||||
db_path = "./app/Database/Msg/HardLinkImage.db"
|
||||
root_path = '/MsgAttach/'
|
||||
root_path = 'FileStorage/MsgAttach/'
|
||||
if os.path.exists(db_path):
|
||||
DB = sqlite3.connect(db_path, check_same_thread=False)
|
||||
# '''创建游标'''
|
||||
@ -47,16 +47,16 @@ def get_md5_from_xml(content):
|
||||
root = ET.fromstring(content)
|
||||
# 提取md5的值
|
||||
md5_value = root.find(".//img").get("md5")
|
||||
print(md5_value)
|
||||
# print(md5_value)
|
||||
return md5_value
|
||||
|
||||
|
||||
def get_image(content, thumb=True):
|
||||
def get_image(content, thumb=False):
|
||||
md5 = get_md5_from_xml(content)
|
||||
# md5 = 'bc37a58c32cb203ee9ac587b068e5853'
|
||||
result = get_image_by_md5(binascii.unhexlify(md5))
|
||||
if result:
|
||||
print(result)
|
||||
# print(result)
|
||||
dir1 = result[3]
|
||||
dir2 = result[4]
|
||||
data_image = result[2]
|
||||
|
@ -8,7 +8,7 @@ from PyQt5.QtWidgets import QWidget, QLabel, QHBoxLayout, QSizePolicy, QVBoxLayo
|
||||
|
||||
class MessageType:
|
||||
Text = 1
|
||||
Image = 2
|
||||
Image = 3
|
||||
|
||||
|
||||
class TextMessage(QLabel):
|
||||
@ -104,20 +104,28 @@ class OpenImageThread(QThread):
|
||||
|
||||
|
||||
class ImageMessage(QLabel):
|
||||
def __init__(self, avatar, parent=None):
|
||||
def __init__(self, image, image_link='', max_width=480, max_height=720, parent=None):
|
||||
"""
|
||||
param:image 图像路径或者QPixmap对象
|
||||
param:image_link='' 点击图像打开的文件路径
|
||||
"""
|
||||
super().__init__(parent)
|
||||
self.image = QLabel(self)
|
||||
if isinstance(avatar, str):
|
||||
self.setPixmap(QPixmap(avatar))
|
||||
self.image_path = avatar
|
||||
elif isinstance(avatar, QPixmap):
|
||||
self.setPixmap(avatar)
|
||||
self.setMaximumWidth(480)
|
||||
self.setMaximumHeight(720)
|
||||
self.setScaledContents(True)
|
||||
|
||||
if isinstance(image, str):
|
||||
self.setPixmap(QPixmap(image))
|
||||
self.image_path = image
|
||||
elif isinstance(image, QPixmap):
|
||||
self.setPixmap(image)
|
||||
if image_link:
|
||||
self.image_path = image_link
|
||||
self.setMaximumWidth(max_width)
|
||||
self.setMaximumHeight(max_height)
|
||||
# self.setScaledContents(True)
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
if event.buttons() == Qt.LeftButton: # 左键按下
|
||||
print('打开图像', self.image_path)
|
||||
self.open_image_thread = OpenImageThread(self.image_path)
|
||||
self.open_image_thread.start()
|
||||
|
||||
|
BIN
app/data/icons/404.png
Normal file
BIN
app/data/icons/404.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
@ -3,6 +3,7 @@ from PyQt5.QtGui import QIcon
|
||||
|
||||
class Icon:
|
||||
Default_avatar_path = './app/data/icons/default_avatar.svg'
|
||||
Default_image_path = './app/data/icons/404.png'
|
||||
MainWindow_Icon = QIcon('./app/data/icons/logo.svg')
|
||||
Default_avatar = QIcon(Default_avatar_path)
|
||||
Output = QIcon('./app/data/icons/output.svg')
|
||||
|
@ -1,9 +1,12 @@
|
||||
import traceback
|
||||
|
||||
from PyQt5.QtCore import QThread, pyqtSignal
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QHBoxLayout
|
||||
|
||||
from app.DataBase import msg
|
||||
from app.DataBase import msg, hard_link
|
||||
from app.components.bubble_message import BubbleMessage, ChatWidget, Notice
|
||||
from app.person import MePC
|
||||
from app.util import get_abs_path
|
||||
|
||||
|
||||
class ChatInfo(QWidget):
|
||||
@ -84,7 +87,7 @@ class ChatInfo(QWidget):
|
||||
is_send = message[4]
|
||||
avatar = MePC().avatar if is_send else self.contact.avatar
|
||||
timestamp = message[5]
|
||||
if type_ == 1 or type_ == 3:
|
||||
if type_ == 1:
|
||||
if self.is_5_min(timestamp):
|
||||
time_message = Notice(self.last_str_time)
|
||||
self.last_str_time = str_time
|
||||
@ -96,8 +99,23 @@ class ChatInfo(QWidget):
|
||||
is_send
|
||||
)
|
||||
self.chat_window.add_message_item(bubble_message, 0)
|
||||
elif type_ == 3:
|
||||
if self.is_5_min(timestamp):
|
||||
time_message = Notice(self.last_str_time)
|
||||
self.last_str_time = str_time
|
||||
self.chat_window.add_message_item(time_message, 0)
|
||||
image_path = hard_link.get_image(content=str_content, thumb=False)
|
||||
image_path = get_abs_path(image_path)
|
||||
bubble_message = BubbleMessage(
|
||||
image_path,
|
||||
avatar,
|
||||
type_,
|
||||
is_send
|
||||
)
|
||||
self.chat_window.add_message_item(bubble_message, 0)
|
||||
except:
|
||||
print(message)
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
class ShowChatThread(QThread):
|
||||
|
@ -89,7 +89,6 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
|
||||
me.name = dic.get('name')
|
||||
me.mobile = dic.get('mobile')
|
||||
me.wx_dir = dic.get('wx_dir')
|
||||
|
||||
self.set_my_info(wxid)
|
||||
else:
|
||||
QMessageBox.information(
|
||||
|
@ -0,0 +1 @@
|
||||
from .path import get_abs_path
|
11
app/util/path.py
Normal file
11
app/util/path.py
Normal file
@ -0,0 +1,11 @@
|
||||
import os
|
||||
|
||||
from app.person import MePC
|
||||
|
||||
|
||||
def get_abs_path(path):
|
||||
return os.path.join(os.getcwd(), 'app/data/icons/404.png')
|
||||
if path:
|
||||
return os.path.join(MePC().wx_dir, path)
|
||||
else:
|
||||
return os.path.join(os.getcwd(), 'app/data/icons/404.png')
|
Loading…
Reference in New Issue
Block a user