Commit 9297ee92 authored by Eike Ziller's avatar Eike Ziller
Browse files

Help: Fix destination of index locator filter



When using locator in the external help window, open help pages or show
the topic chooser in the external help window, not the main window.

Change-Id: I792223147f1eb00addafb2618017536c126c71dd
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent b1390a07
......@@ -145,11 +145,7 @@ void HelpIndexFilter::accept(LocatorFilterEntry selection,
Q_UNUSED(selectionLength)
const QString &key = selection.displayName;
const QMap<QString, QUrl> &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<void> &future)
......
......@@ -52,7 +52,6 @@ public:
Q_INVOKABLE QSet<QString> searchMatches(const QString &databaseFilePath,
const QString &term, int limit);
signals:
void linkActivated(const QUrl &link) const;
void linksActivated(const QMap<QString, QUrl> &links, const QString &key) const;
private:
......
......@@ -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<QString, QUrl> &links, const QString &key)
void HelpPlugin::showLinksInCurrentViewer(const QMap<QString, QUrl> &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;
......
......@@ -89,7 +89,7 @@ private:
void saveExternalWindowSettings();
void showLinkInHelpMode(const QUrl &source);
void showLinksInHelpMode(const QMap<QString, QUrl> &links, const QString &key);
void showLinksInCurrentViewer(const QMap<QString, QUrl> &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();
......
......@@ -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<QString, QUrl> &links,
void HelpWidget::showLinks(const QMap<QString, QUrl> &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)
......
......@@ -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<QString, QUrl> &links, const QString &key,
void showLinks(const QMap<QString, QUrl> &links, const QString &key,
bool newPage = false);
void activateSideBarItem(const QString &id);
......
......@@ -198,12 +198,7 @@ void IndexWindow::open(const QModelIndex &index, bool newPage)
{
QString keyword = m_filteredIndexModel->data(index, Qt::DisplayRole).toString();
QMap<QString, QUrl> 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
......
......@@ -88,7 +88,6 @@ public:
void setOpenInNewPageActionVisible(bool visible);
signals:
void linkActivated(const QUrl &link, bool newPage);
void linksActivated(const QMap<QString, QUrl> &links,
const QString &keyword, bool newPage);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment