修改部分UI

This commit is contained in:
shuaikangzhou 2023-12-11 23:04:59 +08:00
parent cdf8a59ae2
commit 8e20452bbb
5 changed files with 27 additions and 71 deletions

View File

@ -29,61 +29,6 @@ def singleton(cls):
return inner
def decompress_CompressContent(data):
"""
解压缩MsgCompressContent内容
:param data:
:return:
"""
if data is None or not isinstance(data, bytes):
return None
try:
dst = lz4.block.decompress(data, uncompressed_size=len(data) << 10)
decoded_string = dst.decode().replace('\x00', '') # Remove any null characters
except lz4.block.LZ4BlockError:
print("Decompression failed: potentially corrupt input or insufficient buffer size.")
return None
# 处理 HTML 转义字符串如 &amp;gt; 等。可能会递归嵌套,我们只考虑原会话和第一级引用会话,不考虑更深的引用,故只执行两遍。
uncompressed_data = html.unescape(decoded_string)
uncompressed_data = html.unescape(uncompressed_data)
return uncompressed_data
def transferMessages(messages, compress_content_column=-1, content_column=7):
"""
MSG 中压缩的聊天内容包含引用的聊天解压后以简单形式放入 content (只取前两级会话主题)
:param compress_content_column: 压缩聊天所在列-1 则为最后一列
:param content_column: 聊天内容所在列
:return:
"""
new_messages = []
for row in messages:
mutable_row = list(row)
type = row[2]
sub_type = row[3]
addition_idx = len(mutable_row) - 1 if compress_content_column == -1 else compress_content_column
if type == 49 and sub_type == 57 and mutable_row[addition_idx] is not None:
decoded_string = decompress_CompressContent(mutable_row[addition_idx])
# 使用正则表达式查找所有的 <title> 标签内容
title_regex = r'<title>(.*?)</title>'
titles = re.findall(title_regex, decoded_string)
if len(titles) >= 2:
# 如果找到了至少两个 title就把他们结合起来
decoded_string = titles[0] + '<br/>引用:' + titles[1]
# 否则,如果只找到一个 title就只保留这一个
elif len(titles) == 1:
decoded_string = titles[0]
mutable_row[content_column] = decoded_string
row = tuple(mutable_row)
new_messages.append(row)
return new_messages
class MsgType:
TEXT = 1
@ -127,7 +72,7 @@ class Msg:
finally:
lock.release()
result.sort(key=lambda x: x[5])
return transferMessages(result)
return result
def get_messages_all(self):
sql = '''
@ -144,7 +89,7 @@ class Msg:
finally:
lock.release()
result.sort(key=lambda x: x[5])
return transferMessages(result)
return result
def get_messages_length(self):
sql = '''
@ -183,7 +128,7 @@ class Msg:
finally:
lock.release()
# result.sort(key=lambda x: x[5])
return transferMessages(result)
return result
def get_messages_by_type(self, username_, type_, is_Annual_report_=False, year_='2023'):
if not self.open_flag:
@ -391,7 +336,6 @@ if __name__ == '__main__':
type_ = r[2]
sub_type = r[3]
if type_ == 49 and sub_type == 57:
# print(r)
# print(r[-1])
print(decompress_CompressContent(r[-1]))
print(r)
print(r[-1])
break

View File

@ -11,7 +11,12 @@ from ...util import search
# 美化样式表
Stylesheet = """
QPushButton{
background-color: transparent;
}
QPushButton:hover {
background-color: lightgray;
}
/*去掉item虚线边框*/
QListWidget, QListView, QTreeWidget, QTreeView {
outline: 0px;

View File

@ -10,12 +10,19 @@ types = {
'表情包': 47,
'拍一拍等系统消息': 10000
}
Stylesheet = """
QPushButton{
background-color: #ffffff;
}
QPushButton:hover {
background-color: lightgray;
}
"""
class ExportDialog(QDialog):
def __init__(self, contact=None, title="选择导出的类型", file_type="csv", parent=None):
super(ExportDialog, self).__init__(parent)
self.setStyleSheet(Stylesheet)
self.contact = contact
if file_type == 'html':
self.export_type = Output.HTML

View File

@ -26,12 +26,7 @@ from ..person_pc import MePC
# 美化样式表
Stylesheet = """
QPushButton{
background-color: transparent;
}
QPushButton:hover {
background-color: lightgray;
}
/*去掉item虚线边框*/
QListWidget, QListView, QTreeWidget, QTreeView {
outline: 0px;

View File

@ -8,7 +8,12 @@ from .toolUI import Ui_Dialog
# 美化样式表
Stylesheet = """
QPushButton{
background-color: #ffffff;
}
QPushButton:hover {
background-color: lightgray;
}
/*去掉item虚线边框*/
QListWidget, QListView, QTreeWidget, QTreeView {
outline: 0px;