diff --git a/tools/chatgui/Makefile b/tools/chatgui/Makefile new file mode 100644 index 00000000..d9e3d328 --- /dev/null +++ b/tools/chatgui/Makefile @@ -0,0 +1,10 @@ +BUILDDIR := build + +all: + @[ -f $(BUILDDIR)/Makefile ] || cmake -S . -B $(BUILDDIR) + cmake --build $(BUILDDIR) + +clean: + rm -rf $(BUILDDIR) + +.PHONY: all clean diff --git a/tools/chatgui/src/emojipanel.cpp b/tools/chatgui/src/emojipanel.cpp index 1cb6a74b..cceb6d39 100644 --- a/tools/chatgui/src/emojipanel.cpp +++ b/tools/chatgui/src/emojipanel.cpp @@ -27,7 +27,7 @@ EmojiPanel::EmojiPanel(QWidget *parent) void EmojiPanel::showEvent(QShowEvent *event) { if (parentWidget()) { - setFixedHeight(parentWidget()->height() / 2); + setFixedHeight(qBound(200, parentWidget()->height() * 3 / 10, 800)); } QWidget::showEvent(event); } diff --git a/tools/chatgui/src/messagedelegate.cpp b/tools/chatgui/src/messagedelegate.cpp index ae0d5b4d..48172285 100644 --- a/tools/chatgui/src/messagedelegate.cpp +++ b/tools/chatgui/src/messagedelegate.cpp @@ -51,7 +51,8 @@ MessageDelegate::Layout MessageDelegate::calcLayout( } int textH = measureTextHeight(option.font, text, textW); - int bubbleH = kPadTop + (hasQuote ? qH + kQuoteGap : 0) + textH + kStatusH + kPadBot; + int authorH = QFontMetrics(option.font).height(); + int bubbleH = kPadTop + authorH + 2 + (hasQuote ? qH + kQuoteGap : 0) + textH + kStatusH + kPadBot; L.totalHeight = qMax(bubbleH, kAvatar) + kItemGap; int contentLeft = kMarginH + kAvatar + kGap; @@ -60,6 +61,9 @@ MessageDelegate::Layout MessageDelegate::calcLayout( int contentTop = kPadTop; + L.authorRect = QRect(contentLeft + kPadH, contentTop, textW, authorH); + contentTop += authorH + 2; + if (hasQuote) { L.quoteRect = QRect(contentLeft + kPadH, contentTop, bubbleW - 2 * kPadH, qH); L.quoteBarRect = QRect(L.quoteRect.left(), L.quoteRect.top(), @@ -103,6 +107,13 @@ void MessageDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio drawAvatar(painter, L, index); + QFont authorFont = option.font; + authorFont.setBold(true); + painter->setFont(authorFont); + painter->setPen(QColor(0x33, 0x90, 0xEC)); + painter->drawText(L.authorRect, Qt::AlignLeft | Qt::AlignVCenter, + index.data(MsgAuthorRole).toString()); + painter->setPen(option.palette.text().color()); QFont textFont = option.font; textFont.setPointSize(textFont.pointSize()); diff --git a/tools/chatgui/src/messagedelegate.h b/tools/chatgui/src/messagedelegate.h index 68d33326..95c255ed 100644 --- a/tools/chatgui/src/messagedelegate.h +++ b/tools/chatgui/src/messagedelegate.h @@ -30,6 +30,7 @@ private: int bubbleWidth; QRect avatarRect; QRect bubbleRect; + QRect authorRect; QRect quoteRect; QRect quoteBarRect; QRect quoteAuthorRect;