forked from qt-creator/qt-creator
Force repaint of litehtml help viewer when font changes
Trigger refresh_styles() and parse_styles() on font change. Change-Id: I3ea667b2d9fb382681ffad2279823500e9e20491 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -1235,6 +1235,12 @@ void DocumentContainer::setDefaultFont(const QFont &font)
|
||||
{
|
||||
d->m_defaultFont = font;
|
||||
d->m_defaultFontFamilyName = d->m_defaultFont.family().toUtf8();
|
||||
// Since font family name and size are read only once, when parsing html,
|
||||
// we need to trigger the reparse of this info.
|
||||
if (d->m_document && d->m_document->root()) {
|
||||
d->m_document->root()->refresh_styles();
|
||||
d->m_document->root()->parse_styles();
|
||||
}
|
||||
}
|
||||
|
||||
QFont DocumentContainer::defaultFont() const
|
||||
|
@@ -464,7 +464,7 @@ bool QLiteHtmlWidget::findText(const QString &text,
|
||||
.findText(text, flags, incremental, wrapped, &success, &oldSelection, &newSelection);
|
||||
// scroll to search result position and/or redraw as necessary
|
||||
QRect newSelectionCombined;
|
||||
for (const QRect &r : newSelection)
|
||||
for (const QRect &r : qAsConst(newSelection))
|
||||
newSelectionCombined = newSelectionCombined.united(r);
|
||||
QScrollBar *vBar = verticalScrollBar();
|
||||
const int top = newSelectionCombined.top();
|
||||
@@ -475,7 +475,7 @@ bool QLiteHtmlWidget::findText(const QString &text,
|
||||
vBar->setValue(bottom);
|
||||
} else {
|
||||
viewport()->update(fromVirtual(newSelectionCombined.translated(-scrollPosition())));
|
||||
for (const QRect &r : oldSelection)
|
||||
for (const QRect &r : qAsConst(oldSelection))
|
||||
viewport()->update(fromVirtual(r.translated(-scrollPosition())));
|
||||
}
|
||||
return success;
|
||||
@@ -483,8 +483,10 @@ bool QLiteHtmlWidget::findText(const QString &text,
|
||||
|
||||
void QLiteHtmlWidget::setDefaultFont(const QFont &font)
|
||||
{
|
||||
d->documentContainer.setDefaultFont(font);
|
||||
render();
|
||||
withFixedTextPosition([this, &font] {
|
||||
d->documentContainer.setDefaultFont(font);
|
||||
render();
|
||||
});
|
||||
}
|
||||
|
||||
QFont QLiteHtmlWidget::defaultFont() const
|
||||
|
Reference in New Issue
Block a user