From cb62258ee33fc3cc38dceae14a0f6b8c8ff45de9 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 12 Apr 2016 15:26:53 +0200 Subject: [PATCH] Help browser: Fix overlapping images in old docs This works around an issue in Qt where line-height will be interpreted as an absolute height, rather than the minimum, so if images are larger than the specified size, they will overlap the text. The work around is just to change all instances of FixedHeight to MinimumHeight until the default can be changed in Qt. Task-number: QTBUG-51962 Change-Id: I343d30c539d434301866a7a659ef5fc300c364d6 Reviewed-by: Eike Ziller --- src/plugins/help/textbrowserhelpviewer.cpp | 16 ++++++++++++++++ src/plugins/help/textbrowserhelpviewer.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/plugins/help/textbrowserhelpviewer.cpp b/src/plugins/help/textbrowserhelpviewer.cpp index 531cfa5c454..64464f5ca4a 100644 --- a/src/plugins/help/textbrowserhelpviewer.cpp +++ b/src/plugins/help/textbrowserhelpviewer.cpp @@ -448,3 +448,19 @@ void TextBrowserHelpWidget::mouseReleaseEvent(QMouseEvent *e) QTextBrowser::mouseReleaseEvent(e); } + +void TextBrowserHelpWidget::setSource(const QUrl &name) +{ + QTextBrowser::setSource(name); + + QTextCursor cursor(document()); + while (!cursor.atEnd()) { + QTextBlockFormat fmt = cursor.blockFormat(); + if (fmt.hasProperty(QTextFormat::LineHeightType) && fmt.lineHeightType() == QTextBlockFormat::FixedHeight) { + fmt.setProperty(QTextFormat::LineHeightType, QTextBlockFormat::MinimumHeight); + cursor.setBlockFormat(fmt); + } + if (!cursor.movePosition(QTextCursor::NextBlock)) + break; + } +} diff --git a/src/plugins/help/textbrowserhelpviewer.h b/src/plugins/help/textbrowserhelpviewer.h index 11a78819a81..ef777d6a81e 100644 --- a/src/plugins/help/textbrowserhelpviewer.h +++ b/src/plugins/help/textbrowserhelpviewer.h @@ -97,6 +97,8 @@ public: void scaleUp(); void scaleDown(); + void setSource(const QUrl &name); + protected: void contextMenuEvent(QContextMenuEvent *event); bool eventFilter(QObject *obj, QEvent *event);