-
Notifications
You must be signed in to change notification settings - Fork 26
/
chatmessage.h
61 lines (52 loc) · 1.4 KB
/
chatmessage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef CHATMESSAGE_H
#define CHATMESSAGE_H
#include <QWidget>
#include <QLabel>
class ChatMessage:public QWidget
{
Q_OBJECT
public:
explicit ChatMessage(QWidget *parent = nullptr);
enum User_Type{
User_System,//系统
User_Me, //自己
User_She, //用户
User_Time, //时间
};
void setTextSuccess();
void setText(QString text, QString time, QSize allSize, QString ip = "", User_Type userType = User_Time);
QSize getRealString(QString src);
QSize fontRect(QString str);
inline QString text() {return m_msg;}
inline QString time() {return m_time;}
inline User_Type userType() {return m_userType;}
protected:
void paintEvent(QPaintEvent *event);
private:
QString m_msg;
QString m_time;
QString m_curTime;
QString m_ip;
QSize m_allSize;
User_Type m_userType = User_System;
int m_kuangWidth;
int m_textWidth;
int m_spaceWid;
int m_lineHeight;
QRect m_ipLeftRect;
QRect m_ipRightRect;
QRect m_iconLeftRect;
QRect m_iconRightRect;
QRect m_sanjiaoLeftRect;
QRect m_sanjiaoRightRect;
QRect m_kuangLeftRect;
QRect m_kuangRightRect;
QRect m_textLeftRect;
QRect m_textRightRect;
QPixmap m_leftPixmap;
QPixmap m_rightPixmap;
QLabel* m_loading = Q_NULLPTR;
QMovie* m_loadingMovie = Q_NULLPTR;
bool m_isSending = false;
};
#endif // CHATMESSAGE_H