mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 14:18: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_RIGHT_MARGIN = 7;
|
||||||
constexpr int MSG_PADDING = 20;
|
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)
|
StatusIndicator::StatusIndicator(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,30 +93,7 @@ class TextLabel : public QTextBrowser
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextLabel(const QString &text, QWidget *parent = 0)
|
TextLabel(const QString &text, QWidget *parent = nullptr);
|
||||||
: 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wheelEvent(QWheelEvent *event) override { event->ignore(); }
|
void wheelEvent(QWheelEvent *event) override { event->ignore(); }
|
||||||
|
|
||||||
|
|
|
@ -626,7 +626,7 @@ TimelineView::addTimelineItem(QWidget *item, TimelineDirection direction)
|
||||||
auto separator = new DateSeparator(newDate, this);
|
auto separator = new DateSeparator(newDate, this);
|
||||||
|
|
||||||
if (separator)
|
if (separator)
|
||||||
scroll_layout_->addWidget(separator);
|
pushTimelineItem(separator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,9 +194,14 @@ private:
|
||||||
//! of the timeline.
|
//! of the timeline.
|
||||||
void pushTimelineItem(QWidget *item)
|
void pushTimelineItem(QWidget *item)
|
||||||
{
|
{
|
||||||
|
setUpdatesEnabled(false);
|
||||||
item->hide();
|
item->hide();
|
||||||
scroll_layout_->addWidget(item);
|
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.
|
//! Decides whether or not to show or hide the scroll down button.
|
||||||
|
|
Loading…
Reference in a new issue