Core: Return context help id by callback

...to support asynchronous providers.

Change-Id: I483489c74e7886d5bc2bf00b65540c3d2c7afee0
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Nikolai Kosjar
2018-01-17 16:06:13 +01:00
parent 9990fff2c8
commit dd06a4188d
27 changed files with 96 additions and 75 deletions

View File

@@ -194,7 +194,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
Context(kToolTipHelpContext, Core::Constants::C_GLOBAL));
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
connect(action, &QAction::triggered, this, &HelpPlugin::showContextHelp);
connect(action, &QAction::triggered, this, &HelpPlugin::requestContextHelp);
action = new QAction(tr("Technical Support"), this);
cmd = ActionManager::registerAction(action, "Help.TechSupport");
@@ -573,14 +573,19 @@ static QUrl findBestLink(const QMap<QString, QUrl> &links, QString *highlightId)
return source;
}
void HelpPlugin::showContextHelp()
void HelpPlugin::requestContextHelp()
{
// Find out what to show
QString contextHelpId = Utils::ToolTip::contextHelpId();
IContext *context = ICore::currentContextObject();
if (contextHelpId.isEmpty() && context)
contextHelpId = context->contextHelpId();
context->contextHelpId([this](const QString &id) { showContextHelp(id); });
else
showContextHelp(contextHelpId);
}
void HelpPlugin::showContextHelp(const QString &contextHelpId)
{
// get the viewer after getting the help id,
// because a new window might be opened and therefore focus be moved
HelpViewer *viewer = viewerForContextHelp();