|
|
|
@ -17,6 +17,7 @@ |
|
|
|
|
|
|
|
|
|
#pragma once |
|
|
|
|
|
|
|
|
|
#include <QAbstractTextDocumentLayout> |
|
|
|
|
#include <QDateTime> |
|
|
|
|
#include <QHBoxLayout> |
|
|
|
|
#include <QLabel> |
|
|
|
@ -24,6 +25,8 @@ |
|
|
|
|
#include <QSettings> |
|
|
|
|
#include <QStyle> |
|
|
|
|
#include <QStyleOption> |
|
|
|
|
#include <QTextBrowser> |
|
|
|
|
#include <QTimer> |
|
|
|
|
|
|
|
|
|
#include "AvatarProvider.h" |
|
|
|
|
#include "RoomInfoListItem.h" |
|
|
|
@ -39,6 +42,48 @@ class VideoItem; |
|
|
|
|
class FileItem; |
|
|
|
|
class Avatar; |
|
|
|
|
|
|
|
|
|
class TextLabel : public QTextBrowser |
|
|
|
|
{ |
|
|
|
|
Q_OBJECT |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
TextLabel(const QString &text, QWidget *parent = 0) |
|
|
|
|
: QTextBrowser(parent) |
|
|
|
|
{ |
|
|
|
|
setText(text); |
|
|
|
|
setOpenExternalLinks(true); |
|
|
|
|
|
|
|
|
|
// Make it look and feel like an ordinary label.
|
|
|
|
|
setReadOnly(true); |
|
|
|
|
setFrameStyle(QFrame::NoFrame); |
|
|
|
|
QPalette pal = palette(); |
|
|
|
|
pal.setColor(QPalette::Base, Qt::transparent); |
|
|
|
|
setPalette(pal); |
|
|
|
|
|
|
|
|
|
// Wrap anywhere but prefer words, adjust minimum height on the fly.
|
|
|
|
|
setLineWrapMode(QTextEdit::WidgetWidth); |
|
|
|
|
setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); |
|
|
|
|
connect(document()->documentLayout(), |
|
|
|
|
&QAbstractTextDocumentLayout::documentSizeChanged, |
|
|
|
|
this, |
|
|
|
|
&TextLabel::adjustHeight); |
|
|
|
|
document()->setDocumentMargin(0); |
|
|
|
|
|
|
|
|
|
setFixedHeight(document()->size().height()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QSize sizeHint() const override |
|
|
|
|
{ |
|
|
|
|
ensurePolished(); |
|
|
|
|
return document()->size().toSize(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void wheelEvent(QWheelEvent *event) override { event->ignore(); } |
|
|
|
|
|
|
|
|
|
private slots: |
|
|
|
|
void adjustHeight(const QSizeF &size) { setFixedHeight(size.height()); } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class TimelineItem : public QWidget |
|
|
|
|
{ |
|
|
|
|
Q_OBJECT |
|
|
|
@ -174,7 +219,7 @@ private: |
|
|
|
|
QLabel *timestamp_; |
|
|
|
|
QLabel *checkmark_; |
|
|
|
|
QLabel *userName_; |
|
|
|
|
QLabel *body_; |
|
|
|
|
TextLabel *body_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template<class Widget> |
|
|
|
|