mirror of
https://gitee.com/Zhaoxin59/my-chat_-client.git
synced 2026-02-14 09:01:50 +08:00
has been completed.
This commit is contained in:
@ -56,9 +56,9 @@ public:
|
||||
|
||||
//添加工厂函数
|
||||
static QWidget* makeTextMessageItem(bool isLeft, const QString& message);
|
||||
static QWidget* makeImageMessageItem();
|
||||
static QWidget* makeFileMessageItem();
|
||||
static QWidget* makeSpeechMessageItem();
|
||||
static QWidget* makeImageMessageItem(bool isLeft, const QString& fileId, const QByteArray& content);
|
||||
static QWidget* makeFileMessageItem(bool isLeft, const Message& message);
|
||||
static QWidget* makeSpeechMessageItem(bool isLeft, const Message& message);
|
||||
|
||||
private:
|
||||
bool isLeft;
|
||||
@ -66,16 +66,55 @@ private:
|
||||
|
||||
////////////////////////////////////////////
|
||||
/// 创建类表示“文本消息”正文部分
|
||||
//也让这个类表示文件消息
|
||||
////////////////////////////////////////////
|
||||
class MessageContentLabel : public QWidget {
|
||||
public:
|
||||
MessageContentLabel(const QString& text, bool isLeft);
|
||||
MessageContentLabel(const QString& text, bool isLeft, model::MessageType messageType, const QString& fileId,
|
||||
const QByteArray& content);
|
||||
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
|
||||
void updateUI(const QString& fileId, const QByteArray& fileContent);
|
||||
void saveAsFile(const QByteArray& content);
|
||||
|
||||
void playDone();
|
||||
|
||||
void contextMenuEvent(QContextMenuEvent* event) override;
|
||||
void speechConverTextDone(const QString& fileId, const QString& text);
|
||||
|
||||
private:
|
||||
QLabel* label;
|
||||
bool isLeft;
|
||||
|
||||
model::MessageType messageType;
|
||||
QString fileId;
|
||||
QByteArray content;
|
||||
QString fileName;
|
||||
|
||||
bool loadContentDone = false;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////
|
||||
/// 创建类表示“图片消息”部分
|
||||
////////////////////////////////////////////
|
||||
class MessageImageLabel : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MessageImageLabel(const QString& fileId, const QByteArray& content, bool isLeft);
|
||||
|
||||
void updateUI(const QString& fileId, const QByteArray& content);
|
||||
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
|
||||
private:
|
||||
QPushButton* imageBtn;
|
||||
|
||||
QString fileId; //该图片在服务器对应的文件id
|
||||
QByteArray content; //图片的二进制数据
|
||||
bool isLeft;
|
||||
};
|
||||
|
||||
#endif // MESSAGESHOWAREA_H
|
||||
|
||||
Reference in New Issue
Block a user