diff --git a/src/plugins/help/helpindexfilter.cpp b/src/plugins/help/helpindexfilter.cpp index 0428ee9c83d..e808f1b9d11 100644 --- a/src/plugins/help/helpindexfilter.cpp +++ b/src/plugins/help/helpindexfilter.cpp @@ -145,11 +145,7 @@ void HelpIndexFilter::accept(LocatorFilterEntry selection, Q_UNUSED(selectionLength) const QString &key = selection.displayName; const QMap &links = HelpManager::linksForKeyword(key); - - if (links.size() == 1) - emit linkActivated(links.begin().value()); - else - emit linksActivated(links, key); + emit linksActivated(links, key); } void HelpIndexFilter::refresh(QFutureInterface &future) diff --git a/src/plugins/help/helpindexfilter.h b/src/plugins/help/helpindexfilter.h index 1cf1f412975..b8e321cbcb3 100644 --- a/src/plugins/help/helpindexfilter.h +++ b/src/plugins/help/helpindexfilter.h @@ -52,7 +52,6 @@ public: Q_INVOKABLE QSet searchMatches(const QString &databaseFilePath, const QString &term, int limit); signals: - void linkActivated(const QUrl &link) const; void linksActivated(const QMap &links, const QString &key) const; private: diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index ef03175df61..39fe63a376e 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -236,10 +236,8 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) auto helpIndexFilter = new HelpIndexFilter(); addAutoReleasedObject(helpIndexFilter); - connect(helpIndexFilter, &HelpIndexFilter::linkActivated, - this, &HelpPlugin::showLinkInHelpMode); connect(helpIndexFilter, &HelpIndexFilter::linksActivated, - this, &HelpPlugin::showLinksInHelpMode); + this, &HelpPlugin::showLinksInCurrentViewer); RemoteHelpFilter *remoteHelpFilter = new RemoteHelpFilter(); addAutoReleasedObject(remoteHelpFilter); @@ -430,11 +428,12 @@ void HelpPlugin::showLinkInHelpMode(const QUrl &source) showInHelpViewer(source, helpModeHelpViewer()); } -void HelpPlugin::showLinksInHelpMode(const QMap &links, const QString &key) +void HelpPlugin::showLinksInCurrentViewer(const QMap &links, const QString &key) { - activateHelpMode(); - ICore::raiseWindow(m_mode->widget()); - m_centralWidget->showTopicChooser(links, key); + if (links.size() < 1) + return; + HelpWidget *widget = helpWidgetForWindow(QApplication::activeWindow()); + widget->showLinks(links, key); } void HelpPlugin::slotHideRightPane() @@ -499,6 +498,14 @@ HelpViewer *HelpPlugin::helpModeHelpViewer() return viewer; } +HelpWidget *HelpPlugin::helpWidgetForWindow(QWidget *window) +{ + if (m_externalWindow && m_externalWindow->window() == window->window()) + return m_externalWindow; + activateHelpMode(); + return m_centralWidget; +} + HelpViewer *HelpPlugin::viewerForHelpViewerLocation(HelpManager::HelpViewerLocation location) { HelpManager::HelpViewerLocation actualLocation = location; diff --git a/src/plugins/help/helpplugin.h b/src/plugins/help/helpplugin.h index 4e02e5d3fb8..d6985733efb 100644 --- a/src/plugins/help/helpplugin.h +++ b/src/plugins/help/helpplugin.h @@ -89,7 +89,7 @@ private: void saveExternalWindowSettings(); void showLinkInHelpMode(const QUrl &source); - void showLinksInHelpMode(const QMap &links, const QString &key); + void showLinksInCurrentViewer(const QMap &links, const QString &key); void slotHideRightPane(); void updateSideBarSource(const QUrl &newUrl); @@ -109,6 +109,7 @@ private: void createRightPaneContextViewer(); HelpViewer *externalHelpViewer(); HelpViewer *helpModeHelpViewer(); + HelpWidget *helpWidgetForWindow(QWidget *window); void doSetupIfNeeded(); diff --git a/src/plugins/help/helpwidget.cpp b/src/plugins/help/helpwidget.cpp index 207661cec60..b0e6cb3daf7 100644 --- a/src/plugins/help/helpwidget.cpp +++ b/src/plugins/help/helpwidget.cpp @@ -354,10 +354,8 @@ void HelpWidget::addSideBar() auto indexItem = new Core::SideBarItem(indexWindow, Constants::HELP_INDEX); indexWindow->setOpenInNewPageActionVisible(supportsNewPages); indexWindow->setWindowTitle(HelpPlugin::tr(Constants::SB_INDEX)); - connect(indexWindow, &IndexWindow::linkActivated, - this, &HelpWidget::open); connect(indexWindow, &IndexWindow::linksActivated, - this, &HelpWidget::showTopicChooser); + this, &HelpWidget::showLinks); m_indexAction = new QAction(HelpPlugin::tr(Constants::SB_INDEX), this); cmd = Core::ActionManager::registerAction(m_indexAction, Constants::HELP_INDEX, m_context->context()); cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+I") @@ -535,12 +533,18 @@ void HelpWidget::open(const QUrl &url, bool newPage) setSource(url); } -void HelpWidget::showTopicChooser(const QMap &links, +void HelpWidget::showLinks(const QMap &links, const QString &keyword, bool newPage) { - TopicChooser tc(this, keyword, links); - if (tc.exec() == QDialog::Accepted) - open(tc.link(), newPage); + if (links.size() < 1) + return; + if (links.size() == 1) { + open(links.first(), newPage); + } else { + TopicChooser tc(this, keyword, links); + if (tc.exec() == QDialog::Accepted) + open(tc.link(), newPage); + } } void HelpWidget::activateSideBarItem(const QString &id) diff --git a/src/plugins/help/helpwidget.h b/src/plugins/help/helpwidget.h index 5fa1ad1faab..3e27d28619c 100644 --- a/src/plugins/help/helpwidget.h +++ b/src/plugins/help/helpwidget.h @@ -74,7 +74,7 @@ public: void open(const QUrl &url, bool newPage = false); void openFromSearch(const QUrl &url, const QStringList &searchTerms, bool newPage = false); - void showTopicChooser(const QMap &links, const QString &key, + void showLinks(const QMap &links, const QString &key, bool newPage = false); void activateSideBarItem(const QString &id); diff --git a/src/shared/help/indexwindow.cpp b/src/shared/help/indexwindow.cpp index 8ceea1eca56..5139c8574d5 100644 --- a/src/shared/help/indexwindow.cpp +++ b/src/shared/help/indexwindow.cpp @@ -198,12 +198,7 @@ void IndexWindow::open(const QModelIndex &index, bool newPage) { QString keyword = m_filteredIndexModel->data(index, Qt::DisplayRole).toString(); QMap links = LocalHelpManager::helpEngine().indexModel()->linksForKeyword(keyword); - - if (links.size() == 1) { - emit linkActivated(links.first(), newPage); - } else if (links.size() > 1) { - emit linksActivated(links, keyword, newPage); - } + emit linksActivated(links, keyword, newPage); } Qt::DropActions IndexFilterModel::supportedDragActions() const diff --git a/src/shared/help/indexwindow.h b/src/shared/help/indexwindow.h index aa621c22937..1b44c1f5768 100644 --- a/src/shared/help/indexwindow.h +++ b/src/shared/help/indexwindow.h @@ -88,7 +88,6 @@ public: void setOpenInNewPageActionVisible(bool visible); signals: - void linkActivated(const QUrl &link, bool newPage); void linksActivated(const QMap &links, const QString &keyword, bool newPage);