From 8e20452bbb1163bd628ad2acb0557350960aaeba Mon Sep 17 00:00:00 2001 From: shuaikangzhou <863909694@qq.com> Date: Mon, 11 Dec 2023 23:04:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/msg.py | 66 +++-------------------------- app/ui_pc/contact/contact_window.py | 7 ++- app/ui_pc/contact/export_dialog.py | 11 ++++- app/ui_pc/mainview.py | 7 +-- app/ui_pc/tool/tool_window.py | 7 ++- 5 files changed, 27 insertions(+), 71 deletions(-) diff --git a/app/DataBase/msg.py b/app/DataBase/msg.py index c2cf350..7bbc32e 100644 --- a/app/DataBase/msg.py +++ b/app/DataBase/msg.py @@ -29,61 +29,6 @@ def singleton(cls): return inner -def decompress_CompressContent(data): - """ - 解压缩Msg:CompressContent内容 - :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 转义字符串如 &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_regex = r'<title>(.*?)' - titles = re.findall(title_regex, decoded_string) - - if len(titles) >= 2: - # 如果找到了至少两个 title,就把他们结合起来 - decoded_string = titles[0] + '
引用:' + 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 \ No newline at end of file diff --git a/app/ui_pc/contact/contact_window.py b/app/ui_pc/contact/contact_window.py index 864f3e9..73dab32 100644 --- a/app/ui_pc/contact/contact_window.py +++ b/app/ui_pc/contact/contact_window.py @@ -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; diff --git a/app/ui_pc/contact/export_dialog.py b/app/ui_pc/contact/export_dialog.py index 263b9e8..70349b3 100644 --- a/app/ui_pc/contact/export_dialog.py +++ b/app/ui_pc/contact/export_dialog.py @@ -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 diff --git a/app/ui_pc/mainview.py b/app/ui_pc/mainview.py index 06124d9..289640f 100644 --- a/app/ui_pc/mainview.py +++ b/app/ui_pc/mainview.py @@ -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; diff --git a/app/ui_pc/tool/tool_window.py b/app/ui_pc/tool/tool_window.py index 2b1b72f..af6c549 100644 --- a/app/ui_pc/tool/tool_window.py +++ b/app/ui_pc/tool/tool_window.py @@ -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;