mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
Call adjustSize before showing the timeline widget
This commit is contained in:
parent
7e16730692
commit
db9c37d336
4 changed files with 34 additions and 26 deletions
|
@ -37,6 +37,32 @@
|
|||
constexpr int MSG_RIGHT_MARGIN = 7;
|
||||
constexpr int MSG_PADDING = 20;
|
||||
|
||||
TextLabel::TextLabel(const QString &text, QWidget *parent)
|
||||
: 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);
|
||||
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
setFixedHeight(0);
|
||||
}
|
||||
|
||||
StatusIndicator::StatusIndicator(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
|
|
|
@ -93,30 +93,7 @@ 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);
|
||||
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
}
|
||||
TextLabel(const QString &text, QWidget *parent = nullptr);
|
||||
|
||||
void wheelEvent(QWheelEvent *event) override { event->ignore(); }
|
||||
|
||||
|
|
|
@ -626,7 +626,7 @@ TimelineView::addTimelineItem(QWidget *item, TimelineDirection direction)
|
|||
auto separator = new DateSeparator(newDate, this);
|
||||
|
||||
if (separator)
|
||||
scroll_layout_->addWidget(separator);
|
||||
pushTimelineItem(separator);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -194,9 +194,14 @@ private:
|
|||
//! of the timeline.
|
||||
void pushTimelineItem(QWidget *item)
|
||||
{
|
||||
setUpdatesEnabled(false);
|
||||
item->hide();
|
||||
scroll_layout_->addWidget(item);
|
||||
QTimer::singleShot(0, this, [item]() { item->show(); });
|
||||
QTimer::singleShot(0, this, [item, this]() {
|
||||
item->show();
|
||||
item->adjustSize();
|
||||
setUpdatesEnabled(true);
|
||||
});
|
||||
};
|
||||
|
||||
//! Decides whether or not to show or hide the scroll down button.
|
||||
|
|
Loading…
Reference in a new issue