Commit d8035bca authored by kh1's avatar kh1

In case of network error print the error string.

Task-number: QTCREATORBUG-3378
parent 80cd57a9
......@@ -868,10 +868,10 @@ void HelpPlugin::activateContext()
if (HelpViewer* viewer = viewerForContextMode()) {
if (links.isEmpty()) {
// No link found or no context object
viewer->setSource(QUrl(Help::Constants::AboutBlank));
viewer->setHtml(tr("<html><head><title>No Documentation</title>"
"</head><body><br/><center><b>%1</b><br/>No documentation "
"available.</center></body></html>").arg(m_idFromContext));
viewer->setSource(QUrl());
} else {
int version = 0;
const QRegExp exp("(\\d+)");
......
......@@ -129,6 +129,9 @@ private slots:
void actionChanged();
void slotLoadStarted();
void slotLoadFinished(bool ok);
#if !defined(QT_NO_WEBKIT)
void slotNetworkReplyFinished(QNetworkReply *reply);
#endif
private:
bool eventFilter(QObject *obj, QEvent *event);
......
......@@ -239,7 +239,10 @@ HelpViewer::HelpViewer(qreal zoom, QWidget *parent)
settings()->setAttribute(QWebSettings::PluginsEnabled, false);
setPage(new HelpPage(this));
page()->setNetworkAccessManager(new HelpNetworkAccessManager(this));
HelpNetworkAccessManager *manager = new HelpNetworkAccessManager(this);
page()->setNetworkAccessManager(manager);
connect(manager, SIGNAL(finished(QNetworkReply*)), this,
SLOT(slotNetworkReplyFinished(QNetworkReply*)));
QAction* action = pageAction(QWebPage::OpenLinkInNewWindow);
action->setText(tr("Open Link as New Page"));
......@@ -433,6 +436,15 @@ void HelpViewer::actionChanged()
emit forwardAvailable(a->isEnabled());
}
void HelpViewer::slotNetworkReplyFinished(QNetworkReply *reply)
{
if (reply && reply->error() != QNetworkReply::NoError) {
setSource(QUrl(Help::Constants::AboutBlank));
setHtml(HelpViewer::PageNotFoundMessage.arg(reply->url().toString()
+ QString::fromLatin1("<br><br>Error: %1").arg(reply->errorString())));
}
}
// -- private
bool HelpViewer::eventFilter(QObject *obj, QEvent *event)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment