forked from qt-creator/qt-creator
Help: Lookup in index if ID is not found
And if multiple topics are found in the index, show the topic chooser dialog that we already have for the help index. Fixes: QTCREATORBUG-12704 Task-number: QTCREATORBUG-15959 Change-Id: I7afa6f44bbecc12f602aaaa4a11209ec72399689 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include "searchwidget.h"
|
||||
#include "searchtaskhandler.h"
|
||||
#include "textbrowserhelpviewer.h"
|
||||
#include "topicchooser.h"
|
||||
|
||||
#ifdef QTC_MAC_NATIVE_HELPVIEWER
|
||||
#include "macwebkithelpviewer.h"
|
||||
@@ -636,8 +637,8 @@ void HelpPluginPrivate::requestContextHelp()
|
||||
|
||||
void HelpPluginPrivate::showContextHelp(const HelpItem &contextHelp)
|
||||
{
|
||||
const QUrl source = contextHelp.bestLink();
|
||||
if (!source.isValid()) {
|
||||
const HelpItem::Links links = contextHelp.bestLinks();
|
||||
if (links.empty()) {
|
||||
// No link found or no context object
|
||||
HelpViewer *viewer = showHelpUrl(QUrl(Help::Constants::AboutBlank),
|
||||
LocalHelpManager::contextHelpOption());
|
||||
@@ -653,8 +654,19 @@ void HelpPluginPrivate::showContextHelp(const HelpItem &contextHelp)
|
||||
.arg(contextHelp.helpIds().join(", "))
|
||||
.arg(HelpPlugin::tr("No documentation available.")));
|
||||
}
|
||||
} else if (links.size() == 1) {
|
||||
showHelpUrl(links.front().second, LocalHelpManager::contextHelpOption());
|
||||
} else {
|
||||
showHelpUrl(source, LocalHelpManager::contextHelpOption());
|
||||
QMap<QString, QUrl> map;
|
||||
for (const HelpItem::Link &link : links)
|
||||
map.insert(link.first, link.second);
|
||||
auto tc = new TopicChooser(ICore::dialogParent(), contextHelp.keyword(), map);
|
||||
tc->setModal(true);
|
||||
connect(tc, &QDialog::accepted, this, [this, tc] {
|
||||
showHelpUrl(tc->link(), LocalHelpManager::contextHelpOption());
|
||||
});
|
||||
connect(tc, &QDialog::finished, tc, [tc] { tc->deleteLater(); });
|
||||
tc->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user