- 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
56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <QListView>
|
|
#include <QPersistentModelIndex>
|
|
#include <QPoint>
|
|
|
|
struct ChatTextSelection {
|
|
QPersistentModelIndex index;
|
|
QPoint clickPos;
|
|
QPoint dragPos;
|
|
int startChar = -1;
|
|
int endChar = -1;
|
|
bool active = false;
|
|
};
|
|
|
|
class ChatView : public QListView {
|
|
Q_OBJECT
|
|
public:
|
|
explicit ChatView(QWidget *parent = nullptr);
|
|
|
|
void setBackgroundImage(const QString &path);
|
|
|
|
bool hasSelection() const { return m_selStart.isValid(); }
|
|
QModelIndex selStart() const { return QModelIndex(m_selStart); }
|
|
QModelIndex selEnd() const { return QModelIndex(m_selEnd); }
|
|
bool isSelecting() const { return m_selecting; }
|
|
const ChatTextSelection &textSelection() const { return m_textSel; }
|
|
|
|
bool isRowSelected(const QModelIndex &idx) const;
|
|
void setTextSelChars(int start, int end) { m_textSel.startChar = start; m_textSel.endChar = end; }
|
|
|
|
signals:
|
|
void hoveredIndexChanged(const QModelIndex &idx);
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent *event) override;
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
void scrollContentsBy(int dx, int dy) override;
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
void keyPressEvent(QKeyEvent *event) override;
|
|
|
|
private:
|
|
void copySelection();
|
|
|
|
QPixmap m_background;
|
|
QPersistentModelIndex m_selStart;
|
|
QPersistentModelIndex m_selEnd;
|
|
ChatTextSelection m_textSel;
|
|
QPersistentModelIndex m_lastHovered;
|
|
QPersistentModelIndex m_pressIndex;
|
|
QPoint m_pressPos;
|
|
bool m_selecting = false;
|
|
};
|