Help: Fix issues with scrolling to right position

The different viewer backends have different issues with scrolling to
the right position if the URL contains an anchor. In all combinations of
"viewer was visible/invisible when help was requested" and "viewer last
showed the same/a different page then the requested URL".

Move the special logic from help plugin to the viewer backends.

Task-number: QTCREATORBUG-15548
Change-Id: I962c90695ceaee48800a3590676e1d28343cf790
Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Eike Ziller
2016-03-01 11:43:10 +01:00
parent 9bde122764
commit 727b918773
6 changed files with 12 additions and 21 deletions

View File

@@ -38,6 +38,8 @@
#include <QHelpEngine>
#include <QKeyEvent>
#include <QMenu>
#include <QScrollBar>
#include <QTimer>
#include <QToolTip>
#include <QVBoxLayout>
@@ -145,12 +147,13 @@ void TextBrowserHelpViewer::setSource(const QUrl &url)
slotLoadStarted();
m_textBrowser->setSource(url);
slotLoadFinished();
}
void TextBrowserHelpViewer::scrollToAnchor(const QString &anchor)
{
m_textBrowser->scrollToAnchor(anchor);
QTimer::singleShot(0, this, [this, url]() {
if (!url.fragment().isEmpty())
m_textBrowser->scrollToAnchor(url.fragment());
if (QScrollBar *hScrollBar = m_textBrowser->horizontalScrollBar())
hScrollBar->setValue(0);
slotLoadFinished();
});
}
void TextBrowserHelpViewer::setHtml(const QString &html)