Call adjustSize before showing the timeline widget

remotes/origin/HEAD
Konstantinos Sideris 7 years ago
parent 7e16730692
commit db9c37d336
  1. 26
      src/timeline/TimelineItem.cpp
  2. 25
      src/timeline/TimelineItem.h
  3. 2
      src/timeline/TimelineView.cpp
  4. 7
      src/timeline/TimelineView.h

@ -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…
Cancel
Save