Allow http request to be opened in the help plugin.

Reviewed-by: ck
This commit is contained in:
kh1
2010-06-14 14:31:34 +02:00
parent dc91a0949a
commit 7d4bbf4934
4 changed files with 24 additions and 15 deletions

View File

@@ -818,16 +818,8 @@ void HelpPlugin::handleHelpRequest(const QUrl &url)
if (HelpViewer::launchWithExternalApp(url)) if (HelpViewer::launchWithExternalApp(url))
return; return;
if (Core::HelpManager::instance()->findFile(url).isValid()) { QString address = url.toString();
if (url.queryItemValue(QLatin1String("view")) == QLatin1String("split")) { if (!Core::HelpManager::instance()->findFile(url).isValid()) {
if (HelpViewer* viewer = viewerForContextMode())
viewer->setSource(url);
} else {
activateHelpMode();
m_centralWidget->setSource(url);
}
} else {
QString address = url.toString();
if (address.startsWith(HelpViewer::NsNokia) if (address.startsWith(HelpViewer::NsNokia)
|| address.startsWith(HelpViewer::NsTrolltech)) { || address.startsWith(HelpViewer::NsTrolltech)) {
// local help not installed, resort to external web help // local help not installed, resort to external web help
@@ -839,7 +831,15 @@ void HelpPlugin::handleHelpRequest(const QUrl &url)
} }
address = urlPrefix + address.mid(address.lastIndexOf(QLatin1Char('/'))); address = urlPrefix + address.mid(address.lastIndexOf(QLatin1Char('/')));
} }
QDesktopServices::openUrl(address); }
const QUrl newUrl(address);
if (newUrl.queryItemValue(QLatin1String("view")) == QLatin1String("split")) {
if (HelpViewer* viewer = viewerForContextMode())
viewer->setSource(newUrl);
} else {
activateHelpMode();
m_centralWidget->setSource(newUrl);
} }
} }

View File

@@ -147,8 +147,6 @@ bool HelpViewer::launchWithExternalApp(const QUrl &url)
actualTmpFile.close(); actualTmpFile.close();
return QDesktopServices::openUrl(QUrl(actualTmpFile.fileName())); return QDesktopServices::openUrl(QUrl(actualTmpFile.fileName()));
} }
} else if (url.scheme() == QLatin1String("http")) {
return QDesktopServices::openUrl(url);
} }
return false; return false;
} }

View File

@@ -144,6 +144,13 @@ QUrl HelpViewer::source() const
void HelpViewer::setSource(const QUrl &url) void HelpViewer::setSource(const QUrl &url)
{ {
const QString &scheme = url.scheme();
if (scheme != QLatin1String("qthelp") && scheme != QLatin1String("about")) {
QTextBrowser::setSource(resolvedUrl);
emit loadFinished(true);
return;
}
const QString &string = url.toString(); const QString &string = url.toString();
if (url.isValid() && string != QLatin1String("help")) { if (url.isValid() && string != QLatin1String("help")) {
if (launchWithExternalApp(url)) if (launchWithExternalApp(url))

View File

@@ -121,9 +121,13 @@ HelpNetworkAccessManager::HelpNetworkAccessManager(QObject *parent)
{ {
} }
QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, QNetworkReply *HelpNetworkAccessManager::createRequest(Operation op,
const QNetworkRequest &request, QIODevice* /*outgoingData*/) const QNetworkRequest &request, QIODevice* outgoingData)
{ {
const QString &scheme = request.url().scheme();
if (scheme != QLatin1String("qthelp") && scheme != QLatin1String("about"))
return QNetworkAccessManager::createRequest(op, request, outgoingData);
QString url = request.url().toString(); QString url = request.url().toString();
const QHelpEngineCore &engine = LocalHelpManager::helpEngine(); const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
// TODO: For some reason the url to load is already wrong (passed from webkit) // TODO: For some reason the url to load is already wrong (passed from webkit)