diff --git a/saoriview.cpp b/saoriview.cpp index aa05350..b30bea1 100644 --- a/saoriview.cpp +++ b/saoriview.cpp @@ -79,14 +79,6 @@ return nullptr; } -void SaoriView::resizeEvent(QResizeEvent *e) -{ - for(auto entry:m_entries) { - entry->resized(); - } - QWidget::resizeEvent(e); -} - void SaoriView::reload() { qDebug() << "reload."; diff --git a/saoriview.h b/saoriview.h index 42c7d40..1632318 100644 --- a/saoriview.h +++ b/saoriview.h @@ -55,7 +55,6 @@ static QList m_viewList; protected: - virtual void resizeEvent(QResizeEvent *e); void reload(); const QString statusParser(const QJsonObject json); const QString accountParser(const QJsonObject json); diff --git a/saoriviewentry.cpp b/saoriviewentry.cpp index a751589..61ef611 100644 --- a/saoriviewentry.cpp +++ b/saoriviewentry.cpp @@ -37,7 +37,7 @@ setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); - setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); + setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); setOpenLinks(false); setOpenExternalLinks(false); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -57,9 +57,9 @@ m_urlmap[i] = SaoriApplication::saori()->cache()->fileCache(QUrl(i)); } setText(designedText()); - update(); - document()->adjustSize(); - setFixedHeight(document()->size().height()); + // QTextBrowserのサイズを確定させるトリック。 + QResizeEvent e(size(),size()); + resizeEvent(&e); } qlonglong SaoriViewEntry::id() @@ -67,10 +67,11 @@ return m_id; } -void SaoriViewEntry::resized() +void SaoriViewEntry::resizeEvent(QResizeEvent *e) { - document()->adjustSize(); - setFixedHeight(document()->size().height() + 10); + QTextBrowser::resizeEvent(e); + document()->setTextWidth(qreal(e->size().width())); + setMinimumHeight(document()->size().height() + 5); } const QString SaoriViewEntry::designedText() diff --git a/saoriviewentry.h b/saoriviewentry.h index a42e861..89941de 100644 --- a/saoriviewentry.h +++ b/saoriviewentry.h @@ -39,9 +39,9 @@ SaoriViewEntry(qlonglong id,QWidget *parent = nullptr); void setContent(const QString content); qlonglong id(); - void resized(); protected: + virtual void resizeEvent(QResizeEvent *e); const QString designedText(); const QString imageReplacer();