tools/chatgui: Qt5 GUI chat app stub with tray, channel list, message bubbles
This commit is contained in:
1 parent
6717c863e7
commit
b667d6f352
20 files changed
+1089
No files matched your search
@@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
enum MessageDataRole {
|
||||
MsgAuthorRole = Qt::UserRole + 1,
|
||||
MsgTextRole = Qt::UserRole + 2,
|
||||
MsgTimeRole = Qt::UserRole + 3,
|
||||
MsgEditedRole = Qt::UserRole + 4,
|
||||
MsgAvatarRole = Qt::UserRole + 5,
|
||||
MsgHasQuoteRole = Qt::UserRole + 6,
|
||||
MsgQuoteAuthorRole = Qt::UserRole + 7,
|
||||
MsgQuoteTextRole = Qt::UserRole + 8,
|
||||
MsgReactionsRole = Qt::UserRole + 9,
|
||||
};
|
||||
|
||||
class MessageDelegate : public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MessageDelegate(QObject *parent = nullptr);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
struct Layout {
|
||||
int viewWidth;
|
||||
int bubbleWidth;
|
||||
QRect avatarRect;
|
||||
QRect bubbleRect;
|
||||
QRect quoteRect;
|
||||
QRect quoteBarRect;
|
||||
QRect quoteAuthorRect;
|
||||
QRect quoteTextRect;
|
||||
QRect textRect;
|
||||
QRect statusRect;
|
||||
int totalHeight;
|
||||
};
|
||||
|
||||
Layout calcLayout(const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
void drawQuote(QPainter *p, const Layout &L,
|
||||
const QModelIndex &index, const QStyleOptionViewItem &opt) const;
|
||||
void drawBubble(QPainter *p, const Layout &L) const;
|
||||
void drawStatusBar(QPainter *p, const Layout &L,
|
||||
const QModelIndex &index, const QStyleOptionViewItem &opt) const;
|
||||
void drawAvatar(QPainter *p, const Layout &L,
|
||||
const QModelIndex &index) const;
|
||||
|
||||
static constexpr int kAvatar = 36;
|
||||
static constexpr int kGap = 8;
|
||||
static constexpr int kRadius = 10;
|
||||
static constexpr int kPadH = 12;
|
||||
static constexpr int kPadTop = 8;
|
||||
static constexpr int kPadBot = 6;
|
||||
static constexpr int kTail = 6;
|
||||
static constexpr int kMarginH = 8;
|
||||
static constexpr int kItemGap = 3;
|
||||
static constexpr int kQuoteGap = 4;
|
||||
static constexpr int kQuotePadH = 6;
|
||||
static constexpr int kQuotePadV = 6;
|
||||
static constexpr int kQuoteBarW = 2;
|
||||
static constexpr int kQuoteAv = 16;
|
||||
static constexpr int kStatusH = 18;
|
||||
};
|
||||
Reference in new issue
Block a user