Browse Source

tools/chatgui: Makefile cmake wrapper, author name in bubble, emoji panel height ~1/1.7

feature/x25519-migration
Evgeny 3 months ago
parent
commit
0e2b0e28d8
  1. 10
      tools/chatgui/Makefile
  2. 2
      tools/chatgui/src/emojipanel.cpp
  3. 13
      tools/chatgui/src/messagedelegate.cpp
  4. 1
      tools/chatgui/src/messagedelegate.h

10
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

2
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);
}

13
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());

1
tools/chatgui/src/messagedelegate.h

@ -30,6 +30,7 @@ private:
int bubbleWidth;
QRect avatarRect;
QRect bubbleRect;
QRect authorRect;
QRect quoteRect;
QRect quoteBarRect;
QRect quoteAuthorRect;

Loading…
Cancel
Save