文字消息设置圆角

This commit is contained in:
shuaikangzhou 2023-11-20 19:08:11 +08:00
parent 7dbfc46e14
commit fe859ff2f7
6 changed files with 79 additions and 131 deletions

View File

@ -4,9 +4,11 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="支持查找功能">
<list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="修复修改wixd的bug">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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/decrypt/decrypt.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/decrypt/decrypt.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/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/tool/pc_decrypt/pc_decrypt.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/tool/pc_decrypt/pc_decrypt.py" afterDir="false" />
</list>
@ -104,7 +106,7 @@
<recent name="D:\Project\PythonProject\WeChatMsg\app\Ui" />
</key>
</component>
<component name="RunManager" selected="Python.main_pc">
<component name="RunManager" selected="Python.decrypt_window">
<configuration name="bubble_message" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="WeChatMsg" />
<option name="INTERPRETER_OPTIONS" value="" />
@ -126,6 +128,27 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="decrypt_window" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="WeChatMsg" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/decrypt_window.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="main_pc" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="WeChatMsg" />
<option name="INTERPRETER_OPTIONS" value="" />
@ -168,27 +191,6 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="msg" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="WeChatMsg" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/app/DataBase" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/app/DataBase/msg.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="pc_decrypt" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="WeChatMsg" />
<option name="INTERPRETER_OPTIONS" value="" />
@ -254,11 +256,11 @@
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.decrypt_window" />
<item itemvalue="Python.main_pc" />
<item itemvalue="Python.test (1)" />
<item itemvalue="Python.bubble_message" />
<item itemvalue="Python.test" />
<item itemvalue="Python.msg" />
</list>
</recent_temporary>
</component>
@ -274,13 +276,6 @@
<option name="presentableId" value="Default" />
<updated>1672848140146</updated>
</task>
<task id="LOCAL-00033" summary="增加几个图标">
<created>1698331665669</created>
<option name="number" value="00033" />
<option name="presentableId" value="LOCAL-00033" />
<option name="project" value="LOCAL" />
<updated>1698331665669</updated>
</task>
<task id="LOCAL-00034" summary="修改部分UI">
<created>1698592548209</created>
<option name="number" value="00034" />
@ -617,7 +612,14 @@
<option name="project" value="LOCAL" />
<updated>1700407657926</updated>
</task>
<option name="localTasksCounter" value="82" />
<task id="LOCAL-00082" summary="修复修改wixd的bug">
<created>1700410804351</created>
<option name="number" value="00082" />
<option name="presentableId" value="LOCAL-00082" />
<option name="project" value="LOCAL" />
<updated>1700410804352</updated>
</task>
<option name="localTasksCounter" value="83" />
<servers />
</component>
<component name="UnknownFeatures">
@ -640,7 +642,7 @@
<entry key="branch">
<value>
<list>
<option value="origin/master" />
<option value="origin/dev_zsk" />
</list>
</value>
</entry>
@ -653,7 +655,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="main首次加载解密界面" />
<MESSAGE value="增加日志模块" />
<MESSAGE value="增加PC端微信解密条件的判断" />
<MESSAGE value="删除多余的Word文件" />
@ -678,7 +679,8 @@
<MESSAGE value="修复时间插入位置" />
<MESSAGE value="修复第一次启动的显示问题" />
<MESSAGE value="支持查找功能" />
<option name="LAST_COMMIT_MESSAGE" value="支持查找功能" />
<MESSAGE value="修复修改wixd的bug" />
<option name="LAST_COMMIT_MESSAGE" value="修复修改wixd的bug" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
</component>
@ -697,7 +699,7 @@
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/app/decrypt/decrypt.py</url>
<line>103</line>
<line>105</line>
<option name="timeStamp" value="9" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">

View File

@ -1,53 +1,49 @@
from PIL import Image
from PyQt5 import QtGui
from PyQt5.QtCore import QSize, pyqtSignal, Qt, QThread, QTimer
from PyQt5.QtGui import QPainter, QFont, QColor, QPixmap, QPolygon
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QHBoxLayout, QSizePolicy, QVBoxLayout, QSpacerItem, \
from PyQt5.QtCore import QSize, pyqtSignal, Qt, QThread
from PyQt5.QtGui import QPainter, QFont, QColor, QPixmap, QPolygon, QFontMetrics
from PyQt5.QtWidgets import QWidget, QLabel, QHBoxLayout, QSizePolicy, QVBoxLayout, QSpacerItem, \
QScrollArea, QScrollBar
class MessageType:
Text = 1
Image = 2
class TextMessage(QLabel):
heightSingal = pyqtSignal(int)
def __init__(self, text, is_send=False, parent=None):
super(TextMessage, self).__init__(text, parent)
self.setFont(QFont('Microsoft YaHei UI', 12))
font = QFont('微软雅黑', 12)
self.setFont(font)
self.setWordWrap(True)
# self.adjustSize()
self.setMaximumWidth(800)
self.setMinimumWidth(100)
self.setMinimumHeight(45)
# self.resize(QSize(100,40))
self.setTextInteractionFlags(Qt.TextSelectableByMouse)
self.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
# self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Minimum)
if is_send:
self.setAlignment(Qt.AlignCenter | Qt.AlignRight)
self.setStyleSheet(
'''
background-color:white;
background-color:#b2e281;
border-radius:10px;
border-top: 10px solid white;
border-bottom: 10px solid white;
border-right: 10px solid white;
border-left: 10px solid white;
padding:10px;
'''
)
else:
self.setStyleSheet(
'''
background-color:#b2e281;
background-color:white;
border-radius:10px;
border-top: 10px solid #b2e281;
border-bottom: 10px solid #b2e281;
border-right: 10px solid #b2e281;
border-left: 10px solid #b2e281;
padding:10px;
'''
)
w = len(text) * 16 + 30
if w < self.width():
self.setMaximumWidth(w)
font_metrics = QFontMetrics(font)
rect = font_metrics.boundingRect(text)
self.setMaximumWidth(rect.width() + 30)
def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
super(TextMessage, self).paintEvent(a0)
@ -62,18 +58,17 @@ class Triangle(QLabel):
def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
super(Triangle, self).paintEvent(a0)
if self.Type == 1:
if self.Type == MessageType.Text:
painter = QPainter(self)
triangle = QPolygon()
# print(self.width(), self.height())
if self.is_send:
painter.setPen(QColor('white'))
painter.setBrush(QColor('white'))
triangle.setPoints(0, 20, 0, 35, 6, 25)
else:
painter.setPen(QColor('#b2e281'))
painter.setBrush(QColor('#b2e281'))
triangle.setPoints(0, 25, 6, 20, 6, 35)
triangle.setPoints(0, 20, 0, 34, 6, 27)
else:
painter.setPen(QColor('white'))
painter.setBrush(QColor('white'))
triangle.setPoints(0, 27, 6, 20, 6, 34)
painter.drawPolygon(triangle)
@ -81,7 +76,7 @@ class Notice(QLabel):
def __init__(self, text, type_=3, parent=None):
super().__init__(text, parent)
self.type_ = type_
self.setFont(QFont('Microsoft YaHei UI', 12))
self.setFont(QFont('微软雅黑', 12))
self.setWordWrap(True)
self.setTextInteractionFlags(Qt.TextSelectableByMouse)
self.setAlignment(Qt.AlignCenter)
@ -143,20 +138,14 @@ class BubbleMessage(QWidget):
# self.resize(QSize(200, 50))
self.avatar = Avatar(avatar)
triangle = Triangle(Type, is_send)
if Type == 1:
if Type == MessageType.Text:
self.message = TextMessage(str_content, is_send)
# self.message.setMaximumWidth(int(self.width() * 0.6))
else:
elif Type == MessageType.Image:
self.message = ImageMessage(str_content)
# skin_aio_friend_bubble_pressed.9
'''
border-image:url(./Data/截图222.png) 20 20 20 20;
border-top: 5px transparent;
border-bottom: 5px transparent;
border-right: 5px transparent;
border-left: 5px transparent;
border-radius:10px;
'''
else:
raise ValueError("未知的消息类型")
self.spacerItem = QSpacerItem(45 + 6, 45, QSizePolicy.Expanding, QSizePolicy.Minimum)
if is_send:
layout.addItem(self.spacerItem)
@ -284,55 +273,3 @@ class ChatWidget(QWidget):
self.scrollArea.update()
# self.scrollArea.repaint()
# self.verticalScrollBar().setMaximum(self.scrollAreaWidgetContents.height())
class Test(QWidget):
def __init__(self):
super().__init__()
layout = QVBoxLayout()
self.resize(500, 600)
self.w1 = ChatWidget()
bm1 = BubbleMessage(
'你好啊噜啦噜啦嘞绿噜啦噜啦嘞绿绿噜啦噜啦嘞绿绿绿噜啦噜啦嘞绿绿绿绿',
"D:\Project\Python\PyQt-master\QLabel\Data\\fg1.png",
Type=1,
)
self.w1.add_message_item(bm1)
self.w1.verticalScrollBar().valueChanged.connect(self.value)
for i in range(10):
txt = '''在工具中单击边缘可以添加黑点,单击可以删掉黑点,拖动可以调整黑点长度。勾选等选项可以查看内容、缩放等区域右侧可预览不同拉伸情况下的效果,拖动可以调整预览的拉伸比例'''
avatar = '../data/icons/default_avatar.svg'
bubble_message = BubbleMessage(txt, avatar, Type=1, is_send=False)
# print(bubble_message.height(), '高度')
self.w1.add_message_item(bubble_message, 0)
print('滚动条最大值', self.w1.verticalScrollBar().maximum())
w2 = QLabel("nihao")
layout.addWidget(self.w1)
layout.addWidget(w2)
self.setLayout(layout)
# 使用 QTimer 延迟更新滚动条
QTimer.singleShot(0, lambda: self.w1.update())
print('滚动条最大值001', self.w1.verticalScrollBar().value())
self.w1.verticalScrollBar().setValue(100)
# self.w1.update()
def value(self, val):
print('pos:', val)
print('滚动条最大值', self.w1.verticalScrollBar().maximum())
if __name__ == '__main__':
app = QApplication([])
widget = Test()
widget.w1.update()
# widget = MyWidget()
widget.w1.verticalScrollBar().setValue(200)
print('滚动条最大值002', widget.w1.verticalScrollBar().maximum())
widget.show()
# QThread.sleep(2)
widget.w1.verticalScrollBar().setValue(200)
# widget.w1.verticalScrollBar().setValue(200)
# widget.w1.verticalScrollBar().setValue(200)
app.exec_()

View File

@ -5,6 +5,8 @@ from typing import Union, List
from Cryptodome.Cipher import AES
from app.log import log
# from Crypto.Cipher import AES # 如果上面的导入失败,可以尝试使用这个
SQLITE_FILE_HEADER = "SQLite format 3\x00" # SQLite文件头
@ -15,6 +17,7 @@ DEFAULT_ITER = 64000
# 通过密钥解密数据库
@log
def decrypt(key: str, db_path, out_path):
if not os.path.exists(db_path):
return f"[-] db_path:'{db_path}' File not found!"
@ -55,6 +58,7 @@ def decrypt(key: str, db_path, out_path):
return [True, db_path, out_path, key]
@log
def batch_decrypt(key: str, db_path: Union[str, List[str]], out_path: str):
if not isinstance(key, str) or not isinstance(out_path, str) or not os.path.exists(out_path) or len(key) != 64:
return f"[-] (key:'{key}' or out_path:'{out_path}') Error!"

View File

@ -19,6 +19,7 @@ void_p = ctypes.c_void_p
# 读取内存中的字符串(非key部分)
@log
def get_info_without_key(h_process, address, n_size=64):
array = ctypes.create_string_buffer(n_size)
if ReadProcessMemory(h_process, void_p(address), array, n_size, 0) == 0: return "None"
@ -27,6 +28,7 @@ def get_info_without_key(h_process, address, n_size=64):
return text.strip() if text.strip() != "" else "None"
@log
def get_info_wxid(h_process, n_size=64):
pm = pymem.Pymem("WeChat.exe")
addrs = pymem.pattern.pattern_scan_all(pm.process_handle, b'wxid_', return_multiple=True)
@ -39,6 +41,7 @@ def get_info_wxid(h_process, n_size=64):
# 读取内存中的key
@log
def get_key(h_process, address, address_len=8):
array = ctypes.create_string_buffer(address_len)
if ReadProcessMemory(h_process, void_p(address), array, address_len, 0) == 0: return "None"
@ -50,6 +53,7 @@ def get_key(h_process, address, address_len=8):
# 读取微信信息(account,mobile,name,mail,wxid,key)
@log
def read_info(version_list, is_logging=False):
wechat_process = []
result = []

View File

@ -95,10 +95,7 @@ class ChatInfo(QWidget):
type_,
is_send
)
# print(str_content)
# self.scroolAreaLayout.addWidget(bubble_message)
self.chat_window.add_message_item(bubble_message, 0)
except:
print(message)

View File

@ -1,5 +1,6 @@
import os.path
import time
import traceback
from PyQt5 import QtWidgets
from PyQt5.QtCore import *
@ -7,6 +8,7 @@ from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from app.decrypt import get_wx_info, decrypt
from app.log import logger
from . import decryptUi
@ -55,6 +57,8 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog):
except Exception as e:
print(e)
QMessageBox.critical(self, "错误", "请登录微信")
logger.error(traceback.format_exc())
traceback.print_exc()
def set_wxid_(self):
self.info['wxid'] = self.lineEdit.text()