summaryrefslogtreecommitdiff
path: root/src/plugins/help
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2016-03-01 11:43:10 +0100
committerEike Ziller <eike.ziller@theqtcompany.com>2016-03-03 15:10:57 +0000
commit727b9187730a1848e582847669cf765692a2cc5b (patch)
treef2c42849ab34ccd20a7358dfddef97b0ce727815 /src/plugins/help
parent9bde1227644a825767db4d5213b1a59224b2217d (diff)
downloadqt-creator-727b9187730a1848e582847669cf765692a2cc5b.tar.gz
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>
Diffstat (limited to 'src/plugins/help')
-rw-r--r--src/plugins/help/helpplugin.cpp9
-rw-r--r--src/plugins/help/helpviewer.h1
-rw-r--r--src/plugins/help/qtwebkithelpviewer.cpp6
-rw-r--r--src/plugins/help/qtwebkithelpviewer.h1
-rw-r--r--src/plugins/help/textbrowserhelpviewer.cpp15
-rw-r--r--src/plugins/help/textbrowserhelpviewer.h1
6 files changed, 12 insertions, 21 deletions
diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp
index e4ff85fe25..d78cbaa2b8 100644
--- a/src/plugins/help/helpplugin.cpp
+++ b/src/plugins/help/helpplugin.cpp
@@ -593,14 +593,9 @@ void HelpPlugin::showContextHelp()
.arg(contextHelpId)
.arg(creatorTheme()->color(Theme::TextColorNormal).name()));
} else {
- const QUrl &oldSource = viewer->source();
- if (source != oldSource) {
- viewer->stop();
- viewer->setSource(source); // triggers loadFinished which triggers id highlighting
- } else {
- viewer->scrollToAnchor(source.fragment());
- }
viewer->setFocus();
+ viewer->stop();
+ viewer->setSource(source); // triggers loadFinished which triggers id highlighting
ICore::raiseWindow(viewer);
}
}
diff --git a/src/plugins/help/helpviewer.h b/src/plugins/help/helpviewer.h
index 93af29554f..e1f52de833 100644
--- a/src/plugins/help/helpviewer.h
+++ b/src/plugins/help/helpviewer.h
@@ -57,7 +57,6 @@ public:
virtual QUrl source() const = 0;
// metacall in HelpPlugin::updateSideBarSource
Q_INVOKABLE virtual void setSource(const QUrl &url) = 0;
- virtual void scrollToAnchor(const QString &anchor) = 0;
virtual void highlightId(const QString &id) { Q_UNUSED(id) }
virtual void setHtml(const QString &html) = 0;
diff --git a/src/plugins/help/qtwebkithelpviewer.cpp b/src/plugins/help/qtwebkithelpviewer.cpp
index e517ea1d5f..a9ce4ed4c6 100644
--- a/src/plugins/help/qtwebkithelpviewer.cpp
+++ b/src/plugins/help/qtwebkithelpviewer.cpp
@@ -467,16 +467,12 @@ void QtWebKitHelpViewer::setSource(const QUrl &url)
QUrl newWithoutFragment = url;
newWithoutFragment.setFragment(QString());
if (oldWithoutFragment == newWithoutFragment) {
+ m_webView->page()->mainFrame()->scrollToAnchor(url.fragment());
slotLoadStarted();
slotLoadFinished();
}
}
-void QtWebKitHelpViewer::scrollToAnchor(const QString &anchor)
-{
- m_webView->page()->mainFrame()->scrollToAnchor(anchor);
-}
-
void QtWebKitHelpViewer::highlightId(const QString &id)
{
if (m_oldHighlightId == id)
diff --git a/src/plugins/help/qtwebkithelpviewer.h b/src/plugins/help/qtwebkithelpviewer.h
index 2cc93c0aec..2e2b94503b 100644
--- a/src/plugins/help/qtwebkithelpviewer.h
+++ b/src/plugins/help/qtwebkithelpviewer.h
@@ -56,7 +56,6 @@ public:
QUrl source() const;
void setSource(const QUrl &url);
- void scrollToAnchor(const QString &anchor);
void highlightId(const QString &id);
void setHtml(const QString &html);
diff --git a/src/plugins/help/textbrowserhelpviewer.cpp b/src/plugins/help/textbrowserhelpviewer.cpp
index 882beccc28..531cfa5c45 100644
--- a/src/plugins/help/textbrowserhelpviewer.cpp
+++ b/src/plugins/help/textbrowserhelpviewer.cpp
@@ -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)
diff --git a/src/plugins/help/textbrowserhelpviewer.h b/src/plugins/help/textbrowserhelpviewer.h
index bc332b24e6..d71bf2b5ef 100644
--- a/src/plugins/help/textbrowserhelpviewer.h
+++ b/src/plugins/help/textbrowserhelpviewer.h
@@ -55,7 +55,6 @@ public:
QUrl source() const;
void setSource(const QUrl &url);
- void scrollToAnchor(const QString &anchor);
void setHtml(const QString &html);