From 11eb20de2bbc2bb0809a0238d3124613ffac6ed4 Mon Sep 17 00:00:00 2001 From: kh Date: Thu, 23 Apr 2009 15:11:16 +0200 Subject: make sure we wait until the page has fully loaded before duplicating --- tools/assistant/tools/assistant/centralwidget.cpp | 4 ++++ tools/assistant/tools/assistant/helpviewer.cpp | 12 +++++++++++- tools/assistant/tools/assistant/helpviewer.h | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 1b0e671..633747a 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -277,7 +277,11 @@ CentralWidget *CentralWidget::instance() void CentralWidget::newTab() { HelpViewer* viewer = currentHelpViewer(); +#if !defined(QT_NO_WEBKIT) + if (viewer && viewer->hasLoadFinished()) +#else if (viewer) +#endif setSourceInNewTab(viewer->source()); } diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index f7225fa..5ce6e14 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -269,7 +269,10 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, } HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent) - : QWebView(parent), helpEngine(engine), parentWidget(parent) + : QWebView(parent) + , helpEngine(engine) + , parentWidget(parent) + , loadFinished(false) { setAcceptDrops(false); @@ -295,10 +298,12 @@ HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent) connect(page(), SIGNAL(linkHovered(QString, QString, QString)), this, SIGNAL(highlighted(QString))); connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); + connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); } void HelpViewer::setSource(const QUrl &url) { + loadFinished = false; if (url.toString() == QLatin1String("help")) { load(QUrl(QLatin1String("qthelp://com.trolltech.com." "assistantinternal_1.0.0/assistant/assistant.html"))); @@ -385,6 +390,11 @@ void HelpViewer::mousePressEvent(QMouseEvent *event) QWebView::mousePressEvent(event); } +void HelpViewer::setLoadFinished(bool ok) +{ + loadFinished = ok; +} + #else // !defined(QT_NO_WEBKIT) HelpViewer::HelpViewer(QHelpEngine *engine, CentralWidget *parent) diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index eea7340..c66b69c 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -92,6 +92,8 @@ public: { return pageAction(QWebPage::Forward)->isEnabled(); } inline bool isBackwardAvailable() const { return pageAction(QWebPage::Back)->isEnabled(); } + inline bool hasLoadFinished() const + { return loadFinished; } public Q_SLOTS: void home(); @@ -111,10 +113,12 @@ protected: private Q_SLOTS: void actionChanged(); + void setLoadFinished(bool ok); private: QHelpEngine *helpEngine; CentralWidget* parentWidget; + bool loadFinished; }; #else -- cgit v0.12