chatgui: rlottie animated emoji with hover-to-animate, drag-to-select
- Add LottieIcon class (TGS gzip decompress + rlottie C API render) - Add AnimTimer singleton (33ms tick, activate/deactivate refcount) - Add EmojiButton (hover-triggered animation in emoji picker) - Add AnimatedEmoji support to EmojiData (5 TGS mappings) - MessageDelegate: QTextLayout-based animated emoji overlay (text + reactions) - ChatView: drag-to-select (click deselects, 5px drag starts selection) - ChatView: hoveredIndexChanged signal for hover-triggered animations - MessageList: wire AnimTimer tick to viewport update, hover → activate - CMake: AUTORCC, rlottie, zlib dependencies - Add 5 TGS animations as Qt resources
This commit is contained in:
1 parent
0e2b0e28d8
commit
62b3695a77
42 files changed
+286658
-73
No files matched your search
@@ -50,17 +50,38 @@ void ChannelDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
|
||||
if (!lastMsg.isEmpty()) {
|
||||
QFont msgFont = option.font;
|
||||
msgFont.setPointSize(msgFont.pointSize() - 1);
|
||||
painter->setFont(msgFont);
|
||||
|
||||
QColor msgColor = (option.state & QStyle::State_Selected)
|
||||
? option.palette.highlightedText().color().darker(120)
|
||||
: QColor(128, 128, 128);
|
||||
painter->setPen(msgColor);
|
||||
QColor nickColor(0x33, 0x90, 0xEC);
|
||||
QColor msgColor = (option.state & QStyle::State_Selected)
|
||||
? option.palette.highlightedText().color().darker(120)
|
||||
: QColor(128, 128, 128);
|
||||
if (option.state & QStyle::State_Selected) nickColor = nickColor.lighter(140);
|
||||
|
||||
QRect msgRect(textRect.left(), nameRect.bottom() + 4,
|
||||
textRect.width(), option.rect.bottom() - nameRect.bottom() - margin);
|
||||
QString elidedMsg = painter->fontMetrics().elidedText(lastMsg, Qt::ElideRight, msgRect.width());
|
||||
painter->drawText(msgRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, elidedMsg);
|
||||
QFontMetrics msgFm(msgFont);
|
||||
|
||||
int colon = lastMsg.indexOf(QString::fromUtf8(": "));
|
||||
if (colon >= 0) {
|
||||
QString nick = lastMsg.left(colon + 1);
|
||||
QString body = lastMsg.mid(colon + 2);
|
||||
|
||||
painter->setFont(msgFont);
|
||||
painter->setPen(nickColor);
|
||||
QRect nickRect = msgRect;
|
||||
nickRect.setWidth(msgFm.horizontalAdvance(nick));
|
||||
painter->drawText(nickRect, Qt::AlignLeft | Qt::AlignTop, nick);
|
||||
|
||||
painter->setPen(msgColor);
|
||||
QRect bodyRect(msgRect.left() + nickRect.width(), msgRect.top(),
|
||||
msgRect.width() - nickRect.width(), msgRect.height());
|
||||
QString elidedBody = msgFm.elidedText(body, Qt::ElideRight, bodyRect.width());
|
||||
painter->drawText(bodyRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, elidedBody);
|
||||
} else {
|
||||
painter->setFont(msgFont);
|
||||
painter->setPen(msgColor);
|
||||
QString elided = msgFm.elidedText(lastMsg, Qt::ElideRight, msgRect.width());
|
||||
painter->drawText(msgRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, elided);
|
||||
}
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
|
||||
Reference in new issue
Block a user