修复聊天气泡不能更改大小的bug

This commit is contained in:
shuaikangzhou 2023-11-17 22:44:55 +08:00
parent fc0b1250c4
commit a24ce6a14d
8 changed files with 254 additions and 54 deletions

View File

@ -4,19 +4,13 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="update readme"> <list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="数据库加锁避免多线程访问报错">
<change afterPath="$PROJECT_DIR$/app/ui_pc/chat/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/ui_pc/chat/chat_info.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/ui_pc/chat/chat_window.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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/micro_msg.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/DataBase/micro_msg.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/DataBase/micro_msg.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/DataBase/micro_msg.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/DataBase/misc.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/DataBase/misc.py" 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/components/bubble_message.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/components/bubble_message.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/person.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/person.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/ui_pc/contact/contactInfoUi.ui" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/contact/contactInfoUi.ui" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app/ui_pc/chat/chatInfoUi.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/chat/chatInfoUi.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/chat/chat_info.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/chat/chat_info.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/doc/电脑端使用教程.md" beforeDir="false" afterPath="$PROJECT_DIR$/doc/电脑端使用教程.md" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -155,27 +149,6 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </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="true" />
<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"> <configuration name="main_pc" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="WeChatMsg" /> <module name="WeChatMsg" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
@ -260,13 +233,34 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="person" 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" />
<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/person.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="true" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python.main_pc" /> <item itemvalue="Python.main_pc" />
<item itemvalue="Python.person" />
<item itemvalue="Python.bubble_message" /> <item itemvalue="Python.bubble_message" />
<item itemvalue="Python.chat_info" /> <item itemvalue="Python.chat_info" />
<item itemvalue="Python.msg" /> <item itemvalue="Python.msg" />
<item itemvalue="Python.decrypt_window" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>
@ -282,13 +276,6 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1672848140146</updated> <updated>1672848140146</updated>
</task> </task>
<task id="LOCAL-00019" summary="readme">
<created>1684598124207</created>
<option name="number" value="00019" />
<option name="presentableId" value="LOCAL-00019" />
<option name="project" value="LOCAL" />
<updated>1684598124207</updated>
</task>
<task id="LOCAL-00020" summary="readme"> <task id="LOCAL-00020" summary="readme">
<created>1684598177829</created> <created>1684598177829</created>
<option name="number" value="00020" /> <option name="number" value="00020" />
@ -625,7 +612,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1700150198343</updated> <updated>1700150198343</updated>
</task> </task>
<option name="localTasksCounter" value="68" /> <task id="LOCAL-00068" summary="数据库加锁避免多线程访问报错">
<created>1700228064961</created>
<option name="number" value="00068" />
<option name="presentableId" value="LOCAL-00068" />
<option name="project" value="LOCAL" />
<updated>1700228064961</updated>
</task>
<option name="localTasksCounter" value="69" />
<servers /> <servers />
</component> </component>
<component name="UnknownFeatures"> <component name="UnknownFeatures">
@ -661,7 +655,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value="替换chat里的contact" />
<MESSAGE value="增加中文路径提示" /> <MESSAGE value="增加中文路径提示" />
<MESSAGE value="用stackWidget重写contactUI" /> <MESSAGE value="用stackWidget重写contactUI" />
<MESSAGE value="修改联系人视图架构" /> <MESSAGE value="修改联系人视图架构" />
@ -686,7 +679,8 @@
<MESSAGE value="新增聊天记录导出csv格式" /> <MESSAGE value="新增聊天记录导出csv格式" />
<MESSAGE value="导出所有数据库的聊天记录" /> <MESSAGE value="导出所有数据库的聊天记录" />
<MESSAGE value="update readme" /> <MESSAGE value="update readme" />
<option name="LAST_COMMIT_MESSAGE" value="update readme" /> <MESSAGE value="数据库加锁避免多线程访问报错" />
<option name="LAST_COMMIT_MESSAGE" value="数据库加锁避免多线程访问报错" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" /> <option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" /> <option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
</component> </component>
@ -708,6 +702,21 @@
<line>103</line> <line>103</line>
<option name="timeStamp" value="9" /> <option name="timeStamp" value="9" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/app/person.py</url>
<line>116</line>
<option name="timeStamp" value="10" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/app/person.py</url>
<line>114</line>
<option name="timeStamp" value="11" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/app/person.py</url>
<line>115</line>
<option name="timeStamp" value="12" />
</line-breakpoint>
</breakpoints> </breakpoints>
<default-breakpoints> <default-breakpoints>
<breakpoint type="python-exception"> <breakpoint type="python-exception">

View File

@ -31,6 +31,7 @@ def get_contact():
from Contact inner join ContactHeadImgUrl on Contact.UserName = ContactHeadImgUrl.usrName from Contact inner join ContactHeadImgUrl on Contact.UserName = ContactHeadImgUrl.usrName
where Type=3 and Alias is not null where Type=3 and Alias is not null
order by PYInitial order by PYInitial
limit 30
''' '''
cursor.execute(sql) cursor.execute(sql)
result = cursor.fetchall() result = cursor.fetchall()

View File

@ -292,6 +292,7 @@ class MyWidget(QWidget):
bubble_message1 = BubbleMessage("D:\Project\Python\PyQt-master\QLabel\Data\\fg1.png", avatar, Type=3, bubble_message1 = BubbleMessage("D:\Project\Python\PyQt-master\QLabel\Data\\fg1.png", avatar, Type=3,
is_send=False) is_send=False)
layout0.addWidget(bubble_message1) layout0.addWidget(bubble_message1)
self.spacerItem = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) self.spacerItem = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding)
layout0.addItem(self.spacerItem) layout0.addItem(self.spacerItem)
# layout.setStretch(0, 1) # layout.setStretch(0, 1)
@ -302,6 +303,7 @@ class Test(QWidget):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
layout = QVBoxLayout() layout = QVBoxLayout()
self.resize(500, 600)
w1 = MyWidget() w1 = MyWidget()
w2 = QLabel("nihao") w2 = QLabel("nihao")
layout.addWidget(w1) layout.addWidget(w1)

View File

@ -13,6 +13,7 @@ from app.Ui.Icon import Icon
class Person: class Person:
def __init__(self, wxid: str): def __init__(self, wxid: str):
self.wxid = wxid self.wxid = wxid
self.conRemark = data.get_conRemark(wxid) self.conRemark = data.get_conRemark(wxid)
self.nickname, self.alias = data.get_nickname(wxid) self.nickname, self.alias = data.get_nickname(wxid)
@ -52,7 +53,15 @@ def singleton(cls):
@singleton @singleton
class MePC: class MePC:
def __init__(self, contact_info: Dict): def __init__(self):
contact_info = {
'UserName': 'contact_info_list[0]',
'Alias': 'contact_info_list[1]',
'Type': 'contact_info_list[2]',
'Remark': 'contact_info_list[3]',
'NickName': 'contact_info_list[4]',
'smallHeadImgUrl': 'contact_info_list[7]'
}
self.wxid = contact_info.get('UserName') self.wxid = contact_info.get('UserName')
self.remark = contact_info.get('Remark') self.remark = contact_info.get('Remark')
# Alias,Type,Remark,NickName,PYInitial,RemarkPYInitial,ContactHeadImgUrl.smallHeadImgUrl,ContactHeadImgUrl,bigHeadImgUrl # Alias,Type,Remark,NickName,PYInitial,RemarkPYInitial,ContactHeadImgUrl.smallHeadImgUrl,ContactHeadImgUrl,bigHeadImgUrl
@ -105,4 +114,6 @@ class Group(Person):
if __name__ == '__main__': if __name__ == '__main__':
pass p1 = MePC()
p2 = MePC()
print(p1 == p2)

View File

@ -14,7 +14,6 @@ from PyQt5 import QtCore, QtWidgets
class Ui_Form(object): class Ui_Form(object):
def setupUi(self, Form): def setupUi(self, Form):
Form.setObjectName("Form") Form.setObjectName("Form")
Form.resize(817, 748)
self.verticalLayout = QtWidgets.QVBoxLayout(Form) self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setSpacing(0) self.verticalLayout.setSpacing(0)

68
app/ui_pc/chat/chatUi.py Normal file
View File

@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'chatUi.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(840, 752)
Form.setStyleSheet("background: rgb(240, 240, 240);")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(Form)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
self.verticalLayout_2.setSpacing(0)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(Form)
self.label.setText("")
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.lineEdit = QtWidgets.QLineEdit(Form)
self.lineEdit.setMinimumSize(QtCore.QSize(200, 30))
self.lineEdit.setMaximumSize(QtCore.QSize(200, 16777215))
self.lineEdit.setStyleSheet("background:transparent;\n"
" border-width:0;\n"
" border-style:outset;\n"
" background-color:rgb(226,226,226);\n"
" ")
self.lineEdit.setCursorMoveStyle(QtCore.Qt.VisualMoveStyle)
self.lineEdit.setObjectName("lineEdit")
self.horizontalLayout.addWidget(self.lineEdit)
self.label_2 = QtWidgets.QLabel(Form)
self.label_2.setText("")
self.label_2.setObjectName("label_2")
self.horizontalLayout.addWidget(self.label_2)
self.verticalLayout.addLayout(self.horizontalLayout)
self.verticalLayout_2.addLayout(self.verticalLayout)
self.listWidget = QtWidgets.QListWidget(Form)
self.listWidget.setMinimumSize(QtCore.QSize(250, 0))
self.listWidget.setMaximumSize(QtCore.QSize(250, 16777215))
self.listWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.listWidget.setObjectName("listWidget")
self.verticalLayout_2.addWidget(self.listWidget)
self.verticalLayout_2.setStretch(1, 1)
self.horizontalLayout_2.addLayout(self.verticalLayout_2)
self.stackedWidget = QtWidgets.QStackedWidget(Form)
self.stackedWidget.setObjectName("stackedWidget")
self.horizontalLayout_2.addWidget(self.stackedWidget)
self.horizontalLayout_2.setStretch(1, 1)
self.retranslateUi(Form)
self.stackedWidget.setCurrentIndex(-1)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))

105
app/ui_pc/chat/chatUi.ui Normal file
View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>840</width>
<height>752</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">background: rgb(240, 240, 240);</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
<property name="spacing">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="minimumSize">
<size>
<width>200</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background:transparent;
border-width:0;
border-style:outset;
background-color:rgb(226,226,226);
</string>
</property>
<property name="cursorMoveStyle">
<enum>Qt::VisualMoveStyle</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget">
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>250</width>
<height>16777215</height>
</size>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,36 +1,40 @@
from PyQt5.QtCore import QThread, pyqtSignal, Qt from PyQt5.QtCore import QThread, pyqtSignal, Qt
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QSpacerItem, QSizePolicy from PyQt5.QtWidgets import QWidget, QVBoxLayout, QSpacerItem, QSizePolicy, QLabel, QHBoxLayout
from app.DataBase import msg from app.DataBase import msg
from app.components.bubble_message import BubbleMessage, ScrollBar, ScrollArea, ScrollAreaContent from app.components.bubble_message import BubbleMessage, ScrollBar, ScrollArea, ScrollAreaContent
from .chatInfoUi import Ui_Form
class ChatInfo(QWidget, Ui_Form): class ChatInfo(QWidget):
def __init__(self, contact, parent=None): def __init__(self, contact, parent=None):
super().__init__(parent) super().__init__(parent)
self.scrollArea = None
self.setupUi(self)
self.contact = contact self.contact = contact
self.init_ui() self.init_ui()
self.show_chats() self.show_chats()
def init_ui(self): def init_ui(self):
self.label_reamrk = QLabel(self.contact.remark)
self.hBoxLayout = QHBoxLayout()
self.hBoxLayout.addWidget(self.label_reamrk)
self.vBoxLayout = QVBoxLayout()
self.vBoxLayout.setSpacing(0)
# self.vBoxLayout.addLayout(self.hBoxLayout)
self.label_reamrk.setText(self.contact.remark)
self.scrollArea = ScrollArea() self.scrollArea = ScrollArea()
self.verticalLayout_2.addWidget(self.scrollArea, 1)
self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
scrollBar = ScrollBar() scrollBar = ScrollBar()
self.scrollArea.setVerticalScrollBar(scrollBar) self.scrollArea.setVerticalScrollBar(scrollBar)
self.scrollAreaWidgetContents = ScrollAreaContent() self.scrollAreaWidgetContents = ScrollAreaContent()
self.scrollAreaWidgetContents.setMinimumSize(200, 100) self.scrollAreaWidgetContents.setMinimumSize(200, 10000)
self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.vBoxLayout.addWidget(self.scrollArea)
self.scroolAreaLayout = QVBoxLayout() self.scroolAreaLayout = QVBoxLayout()
self.scroolAreaLayout.setSpacing(0)
self.scrollAreaWidgetContents.setLayout(self.scroolAreaLayout) self.scrollAreaWidgetContents.setLayout(self.scroolAreaLayout)
def show_chats(self): def show_chats(self):
@ -42,6 +46,7 @@ class ChatInfo(QWidget, Ui_Form):
def show_finish(self, ok): def show_finish(self, ok):
self.spacerItem = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) self.spacerItem = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.scroolAreaLayout.addItem(self.spacerItem) self.scroolAreaLayout.addItem(self.spacerItem)
self.setLayout(self.vBoxLayout)
def show_chat(self, message): def show_chat(self, message):
try: try: