diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index d04f1fe80a8..311522d5f9d 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -315,8 +315,8 @@ void HelpPlugin::setupUi() shortcutMap.insert(QLatin1String(Constants::HELP_CONTENTS), cmd); auto searchItem = new SearchSideBarItem; - connect(searchItem, SIGNAL(linkActivated(QUrl)), m_centralWidget, - SLOT(setSourceFromSearch(QUrl))); + connect(searchItem, &SearchSideBarItem::linkActivated, + m_centralWidget, &HelpWidget::openFromSearch); action = new QAction(tr("Activate Help Search View"), m_splitter); cmd = ActionManager::registerAction(action, Constants::HELP_SEARCH, modecontext); diff --git a/src/plugins/help/helpwidget.cpp b/src/plugins/help/helpwidget.cpp index 70004940dea..5eee41b27c8 100644 --- a/src/plugins/help/helpwidget.cpp +++ b/src/plugins/help/helpwidget.cpp @@ -453,13 +453,17 @@ void HelpWidget::setSource(const QUrl &url) viewer->setFocus(Qt::OtherFocusReason); } -void HelpWidget::setSourceFromSearch(const QUrl &url) +void HelpWidget::openFromSearch(const QUrl &url, bool newPage) { - HelpViewer* viewer = currentViewer(); - QTC_ASSERT(viewer, return); - connect(viewer, &HelpViewer::loadFinished, this, &HelpWidget::highlightSearchTerms); - viewer->setSource(url); - viewer->setFocus(Qt::OtherFocusReason); + if (newPage) + OpenPagesManager::instance().createPageFromSearch(url); + else { + HelpViewer* viewer = currentViewer(); + QTC_ASSERT(viewer, return); + connect(viewer, &HelpViewer::loadFinished, this, &HelpWidget::highlightSearchTerms); + viewer->setSource(url); + viewer->setFocus(Qt::OtherFocusReason); + } } void HelpWidget::closeEvent(QCloseEvent *) diff --git a/src/plugins/help/helpwidget.h b/src/plugins/help/helpwidget.h index 0b3688fcdc4..045661e48c4 100644 --- a/src/plugins/help/helpwidget.h +++ b/src/plugins/help/helpwidget.h @@ -81,12 +81,12 @@ public: HelpViewer *viewerAt(int index) const; void open(const QUrl &url, bool newPage = false); + void openFromSearch(const QUrl &url, bool newPage = false); void showTopicChooser(const QMap &links, const QString &key, bool newPage = false); public slots: void setSource(const QUrl &url); - void setSourceFromSearch(const QUrl &url); void updateCloseButton(); protected: diff --git a/src/plugins/help/searchwidget.cpp b/src/plugins/help/searchwidget.cpp index 4f54cb32acb..8122675c284 100644 --- a/src/plugins/help/searchwidget.cpp +++ b/src/plugins/help/searchwidget.cpp @@ -104,7 +104,7 @@ void SearchWidget::showEvent(QShowEvent *event) vLayout->setMargin(0); vLayout->setSpacing(0); - searchEngine = (&LocalHelpManager::helpEngine())->searchEngine(); + searchEngine = new QHelpSearchEngine(&LocalHelpManager::helpEngine(), this); Utils::StyledBar *toolbar = new Utils::StyledBar(this); toolbar->setSingleRow(false); @@ -129,8 +129,10 @@ void SearchWidget::showEvent(QShowEvent *event) setFocusProxy(queryWidget); connect(queryWidget, SIGNAL(search()), this, SLOT(search())); - connect(resultWidget, SIGNAL(requestShowLink(QUrl)), this, - SIGNAL(linkActivated(QUrl))); + connect(resultWidget, &QHelpSearchResultWidget::requestShowLink, this, + [this](const QUrl &url) { + emit linkActivated(url, false/*newPage*/); + }); connect(searchEngine, SIGNAL(searchingStarted()), this, SLOT(searchingStarted())); @@ -224,7 +226,7 @@ bool SearchWidget::eventFilter(QObject *o, QEvent *e) bool controlPressed = me->modifiers() & Qt::ControlModifier; if ((me->button() == Qt::LeftButton && controlPressed) || (me->button() == Qt::MidButton)) { - OpenPagesManager::instance().createPageFromSearch(link); + emit linkActivated(link, true/*newPage*/); } } } @@ -261,9 +263,9 @@ void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent) QAction *usedAction = menu.exec(mapToGlobal(contextMenuEvent->pos())); if (usedAction == openLink) - emit linkActivated(link); + emit linkActivated(link, false/*newPage*/); else if (usedAction == openLinkInNewTab) - OpenPagesManager::instance().createPageFromSearch(link); + emit linkActivated(link, true/*newPage*/); else if (usedAction == copyAnchorAction) QApplication::clipboard()->setText(link.toString()); } @@ -274,7 +276,7 @@ SearchSideBarItem::SearchSideBarItem() : SideBarItem(new SearchWidget, QLatin1String(Constants::HELP_SEARCH)) { widget()->setWindowTitle(tr(Constants::SB_SEARCH)); - connect(widget(), SIGNAL(linkActivated(QUrl)), this, SIGNAL(linkActivated(QUrl))); + connect(widget(), SIGNAL(linkActivated(QUrl,bool)), this, SIGNAL(linkActivated(QUrl,bool))); } QList SearchSideBarItem::createToolBarWidgets() diff --git a/src/plugins/help/searchwidget.h b/src/plugins/help/searchwidget.h index 84f1b296cdb..b14a610b740 100644 --- a/src/plugins/help/searchwidget.h +++ b/src/plugins/help/searchwidget.h @@ -57,7 +57,7 @@ public: QList createToolBarWidgets(); signals: - void linkActivated(const QUrl &url); + void linkActivated(const QUrl &url, bool newPage); }; class SearchWidget : public QWidget @@ -73,7 +73,7 @@ public: void resetZoom(); signals: - void linkActivated(const QUrl &link); + void linkActivated(const QUrl &link, bool newPage); protected: void showEvent(QShowEvent *event);