mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-22 19:02:17 +08:00
新版本更新
This commit is contained in:
parent
a248146e83
commit
6ca36b61b1
@ -4,11 +4,14 @@
|
||||
<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="聊天消息自适应">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/DataBase/msg.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/DataBase/msg.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/config.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/config.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/chat/chat_window.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/chat/chat_window.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/ui_pc/contact/contact_window.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/contact/contact_window.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/ui_pc/mainview.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/mainview.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -274,13 +277,6 @@
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1672848140146</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00025" summary="readme">
|
||||
<created>1684600483941</created>
|
||||
<option name="number" value="00025" />
|
||||
<option name="presentableId" value="LOCAL-00025" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1684600483941</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00026" summary="readme">
|
||||
<created>1684600882947</created>
|
||||
<option name="number" value="00026" />
|
||||
@ -617,7 +613,14 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1700279520681</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="74" />
|
||||
<task id="LOCAL-00074" summary="聊天消息自适应">
|
||||
<created>1700285158430</created>
|
||||
<option name="number" value="00074" />
|
||||
<option name="presentableId" value="LOCAL-00074" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1700285158430</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="75" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="UnknownFeatures">
|
||||
@ -653,7 +656,6 @@
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="修改部分UI" />
|
||||
<MESSAGE value="上传html模板" />
|
||||
<MESSAGE value="增加几个图标" />
|
||||
<MESSAGE value="增加导航按钮效果" />
|
||||
@ -678,7 +680,8 @@
|
||||
<MESSAGE value="将自己的wxid设置为配置文件" />
|
||||
<MESSAGE value="修改聊天记录显示顺序" />
|
||||
<MESSAGE value="聊天记录从后往前显示" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="聊天记录从后往前显示" />
|
||||
<MESSAGE value="聊天消息自适应" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="聊天消息自适应" />
|
||||
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
|
||||
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
|
||||
</component>
|
||||
|
@ -1,6 +1,6 @@
|
||||
from PIL import Image
|
||||
from PyQt5 import QtGui
|
||||
from PyQt5.QtCore import QSize, pyqtSignal, Qt, QThread
|
||||
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, \
|
||||
QScrollArea, QScrollBar
|
||||
@ -265,9 +265,12 @@ class ChatWidget(QWidget):
|
||||
self.layout0.addWidget(bubble_message)
|
||||
else:
|
||||
self.layout0.insertWidget(0, bubble_message)
|
||||
# self.set_scroll_bar_last()
|
||||
|
||||
def set_scroll_bar_last(self):
|
||||
self.scrollArea.verticalScrollBar().setValue(self.scrollArea.widget().height())
|
||||
self.scrollArea.verticalScrollBar().setValue(
|
||||
self.scrollArea.verticalScrollBar().maximum()
|
||||
)
|
||||
|
||||
def set_scroll_bar_value(self, val):
|
||||
self.verticalScrollBar().setValue(val)
|
||||
@ -275,34 +278,61 @@ class ChatWidget(QWidget):
|
||||
def verticalScrollBar(self):
|
||||
return self.scrollArea.verticalScrollBar()
|
||||
|
||||
def update(self) -> None:
|
||||
super().update()
|
||||
self.scrollAreaWidgetContents.adjustSize()
|
||||
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)
|
||||
w1 = ChatWidget()
|
||||
self.w1 = ChatWidget()
|
||||
bm1 = BubbleMessage(
|
||||
'你好啊噜啦噜啦嘞绿噜啦噜啦嘞绿绿噜啦噜啦嘞绿绿绿噜啦噜啦嘞绿绿绿绿',
|
||||
"D:\Project\Python\PyQt-master\QLabel\Data\\fg1.png",
|
||||
Type=1,
|
||||
)
|
||||
w1.add_message_item(bm1)
|
||||
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(), '高度')
|
||||
w1.add_message_item(bubble_message, 0)
|
||||
# print(bubble_message.height(), '高度')
|
||||
self.w1.add_message_item(bubble_message, 0)
|
||||
print('滚动条最大值', self.w1.verticalScrollBar().maximum())
|
||||
w2 = QLabel("nihao")
|
||||
layout.addWidget(w1)
|
||||
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_()
|
||||
|
@ -1,2 +1,7 @@
|
||||
version = '0.2.1'
|
||||
version = '0.2.2'
|
||||
contact = '474379264'
|
||||
description = [
|
||||
'1. 支持获取个人信息\n',
|
||||
'2. 支持显示聊天界面\n',
|
||||
'3. 支持导出scv格式的聊天记录\n',
|
||||
]
|
||||
|
@ -2,13 +2,14 @@ from PyQt5.QtCore import QThread, pyqtSignal
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QHBoxLayout
|
||||
|
||||
from app.DataBase import msg
|
||||
from app.components.bubble_message import BubbleMessage, ChatWidget
|
||||
from app.components.bubble_message import BubbleMessage, ChatWidget, Notice
|
||||
from app.person import MePC
|
||||
|
||||
|
||||
class ChatInfo(QWidget):
|
||||
def __init__(self, contact, parent=None):
|
||||
super().__init__(parent)
|
||||
self.last_timestamp = 0
|
||||
self.last_pos = 0
|
||||
self.contact = contact
|
||||
|
||||
@ -28,17 +29,15 @@ class ChatInfo(QWidget):
|
||||
self.chat_window = ChatWidget()
|
||||
self.chat_window.scrollArea.verticalScrollBar().valueChanged.connect(self.verticalScrollBar)
|
||||
self.vBoxLayout.addWidget(self.chat_window)
|
||||
self.setLayout(self.vBoxLayout)
|
||||
|
||||
def show_chats(self):
|
||||
self.show_chat_thread = ShowChatThread(self.contact)
|
||||
self.show_chat_thread.showSingal.connect(self.show_chat)
|
||||
self.show_chat_thread.showSingal.connect(self.add_message)
|
||||
self.show_chat_thread.finishSingal.connect(self.show_finish)
|
||||
self.show_chat_thread.start()
|
||||
|
||||
def show_finish(self, ok):
|
||||
# self.spacerItem = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
# self.scroolAreaLayout.addItem(self.spacerItem)
|
||||
self.setLayout(self.vBoxLayout)
|
||||
self.setScrollBarPos()
|
||||
|
||||
def verticalScrollBar(self, pos):
|
||||
@ -50,8 +49,12 @@ class ChatInfo(QWidget):
|
||||
# print(pos)
|
||||
if pos > 0:
|
||||
return
|
||||
|
||||
# 记录当前滚动条最大值
|
||||
self.last_pos = self.chat_window.verticalScrollBar().maximum()
|
||||
print('记录当前滚动条位置:', self.last_pos)
|
||||
self.update_history_messages()
|
||||
|
||||
def update_history_messages(self):
|
||||
self.show_chat_thread.start()
|
||||
|
||||
def setScrollBarPos(self):
|
||||
@ -60,23 +63,32 @@ class ChatInfo(QWidget):
|
||||
:param pos:
|
||||
:return:
|
||||
"""
|
||||
print('上次滚动条位置', self.last_pos)
|
||||
self.chat_window.update()
|
||||
self.chat_window.show()
|
||||
pos = self.chat_window.verticalScrollBar().maximum() - self.last_pos
|
||||
|
||||
print('当前滚动条位置:', pos)
|
||||
self.chat_window.set_scroll_bar_value(pos)
|
||||
|
||||
def show_chat(self, message):
|
||||
def is_5_min(self, timestamp):
|
||||
if abs(timestamp - self.last_timestamp) > 300:
|
||||
self.last_timestamp = timestamp
|
||||
return True
|
||||
return False
|
||||
|
||||
def add_message(self, message):
|
||||
try:
|
||||
type_ = message[2]
|
||||
str_content = message[7]
|
||||
str_time = message[8]
|
||||
# print(type_, type(type_))
|
||||
is_send = message[4]
|
||||
avatar = MePC().avatar if is_send else self.contact.avatar
|
||||
timestamp = message[5]
|
||||
if type_ == 1:
|
||||
str_content = message[7]
|
||||
str_time = message[8]
|
||||
if self.is_5_min(timestamp):
|
||||
time_message = Notice(str_time)
|
||||
self.chat_window.add_message_item(time_message, 0)
|
||||
bubble_message = BubbleMessage(
|
||||
str_time + ' ' + str_content,
|
||||
str_content,
|
||||
avatar,
|
||||
type_,
|
||||
is_send
|
||||
|
@ -88,7 +88,7 @@ class ChatWindow(QWidget, Ui_Form):
|
||||
self.stackedWidget.addWidget(chat_info_window)
|
||||
|
||||
def setCurrentIndex(self, row):
|
||||
print(row)
|
||||
# print(row)
|
||||
self.stackedWidget.setCurrentIndex(row)
|
||||
|
||||
def stop_loading(self, a0):
|
||||
|
@ -87,7 +87,7 @@ class ContactWindow(QWidget, Ui_Form):
|
||||
self.stackedWidget.addWidget(contact_info_window)
|
||||
|
||||
def setCurrentIndex(self, row):
|
||||
print(row)
|
||||
# print(row)
|
||||
self.stackedWidget.setCurrentIndex(row)
|
||||
|
||||
|
||||
|
@ -157,9 +157,9 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
|
||||
|
||||
def loading(self, a0):
|
||||
self.load_num += 1
|
||||
print('加载一个了')
|
||||
# print('加载一个了')
|
||||
if self.load_num == 2:
|
||||
print('ok了')
|
||||
# print('ok了')
|
||||
self.label.setVisible(False)
|
||||
|
||||
def about(self):
|
||||
@ -169,7 +169,8 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
|
||||
QMessageBox.about(self, "关于",
|
||||
f"版本:{config.version}\n"
|
||||
f"QQ交流群:{config.contact}\n"
|
||||
"地址:https://github.com/LC044/WeChatMsg"
|
||||
"地址:https://github.com/LC044/WeChatMsg\n"
|
||||
f"新特性:\n{''.join(['*' + i for i in config.description])}"
|
||||
)
|
||||
|
||||
def close(self) -> bool:
|
||||
|
Loading…
Reference in New Issue
Block a user