forked from qt-creator/qt-creator
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 <david.schulz@qt.io>
This commit is contained in:
@@ -145,11 +145,7 @@ void HelpIndexFilter::accept(LocatorFilterEntry selection,
|
|||||||
Q_UNUSED(selectionLength)
|
Q_UNUSED(selectionLength)
|
||||||
const QString &key = selection.displayName;
|
const QString &key = selection.displayName;
|
||||||
const QMap<QString, QUrl> &links = HelpManager::linksForKeyword(key);
|
const QMap<QString, QUrl> &links = HelpManager::linksForKeyword(key);
|
||||||
|
emit linksActivated(links, key);
|
||||||
if (links.size() == 1)
|
|
||||||
emit linkActivated(links.begin().value());
|
|
||||||
else
|
|
||||||
emit linksActivated(links, key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpIndexFilter::refresh(QFutureInterface<void> &future)
|
void HelpIndexFilter::refresh(QFutureInterface<void> &future)
|
||||||
|
@@ -52,7 +52,6 @@ public:
|
|||||||
Q_INVOKABLE QSet<QString> searchMatches(const QString &databaseFilePath,
|
Q_INVOKABLE QSet<QString> searchMatches(const QString &databaseFilePath,
|
||||||
const QString &term, int limit);
|
const QString &term, int limit);
|
||||||
signals:
|
signals:
|
||||||
void linkActivated(const QUrl &link) const;
|
|
||||||
void linksActivated(const QMap<QString, QUrl> &links, const QString &key) const;
|
void linksActivated(const QMap<QString, QUrl> &links, const QString &key) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -236,10 +236,8 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
|
|
||||||
auto helpIndexFilter = new HelpIndexFilter();
|
auto helpIndexFilter = new HelpIndexFilter();
|
||||||
addAutoReleasedObject(helpIndexFilter);
|
addAutoReleasedObject(helpIndexFilter);
|
||||||
connect(helpIndexFilter, &HelpIndexFilter::linkActivated,
|
|
||||||
this, &HelpPlugin::showLinkInHelpMode);
|
|
||||||
connect(helpIndexFilter, &HelpIndexFilter::linksActivated,
|
connect(helpIndexFilter, &HelpIndexFilter::linksActivated,
|
||||||
this, &HelpPlugin::showLinksInHelpMode);
|
this, &HelpPlugin::showLinksInCurrentViewer);
|
||||||
|
|
||||||
RemoteHelpFilter *remoteHelpFilter = new RemoteHelpFilter();
|
RemoteHelpFilter *remoteHelpFilter = new RemoteHelpFilter();
|
||||||
addAutoReleasedObject(remoteHelpFilter);
|
addAutoReleasedObject(remoteHelpFilter);
|
||||||
@@ -430,11 +428,12 @@ void HelpPlugin::showLinkInHelpMode(const QUrl &source)
|
|||||||
showInHelpViewer(source, helpModeHelpViewer());
|
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();
|
if (links.size() < 1)
|
||||||
ICore::raiseWindow(m_mode->widget());
|
return;
|
||||||
m_centralWidget->showTopicChooser(links, key);
|
HelpWidget *widget = helpWidgetForWindow(QApplication::activeWindow());
|
||||||
|
widget->showLinks(links, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPlugin::slotHideRightPane()
|
void HelpPlugin::slotHideRightPane()
|
||||||
@@ -499,6 +498,14 @@ HelpViewer *HelpPlugin::helpModeHelpViewer()
|
|||||||
return viewer;
|
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)
|
HelpViewer *HelpPlugin::viewerForHelpViewerLocation(HelpManager::HelpViewerLocation location)
|
||||||
{
|
{
|
||||||
HelpManager::HelpViewerLocation actualLocation = location;
|
HelpManager::HelpViewerLocation actualLocation = location;
|
||||||
|
@@ -89,7 +89,7 @@ private:
|
|||||||
|
|
||||||
void saveExternalWindowSettings();
|
void saveExternalWindowSettings();
|
||||||
void showLinkInHelpMode(const QUrl &source);
|
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 slotHideRightPane();
|
||||||
|
|
||||||
void updateSideBarSource(const QUrl &newUrl);
|
void updateSideBarSource(const QUrl &newUrl);
|
||||||
@@ -109,6 +109,7 @@ private:
|
|||||||
void createRightPaneContextViewer();
|
void createRightPaneContextViewer();
|
||||||
HelpViewer *externalHelpViewer();
|
HelpViewer *externalHelpViewer();
|
||||||
HelpViewer *helpModeHelpViewer();
|
HelpViewer *helpModeHelpViewer();
|
||||||
|
HelpWidget *helpWidgetForWindow(QWidget *window);
|
||||||
|
|
||||||
void doSetupIfNeeded();
|
void doSetupIfNeeded();
|
||||||
|
|
||||||
|
@@ -354,10 +354,8 @@ void HelpWidget::addSideBar()
|
|||||||
auto indexItem = new Core::SideBarItem(indexWindow, Constants::HELP_INDEX);
|
auto indexItem = new Core::SideBarItem(indexWindow, Constants::HELP_INDEX);
|
||||||
indexWindow->setOpenInNewPageActionVisible(supportsNewPages);
|
indexWindow->setOpenInNewPageActionVisible(supportsNewPages);
|
||||||
indexWindow->setWindowTitle(HelpPlugin::tr(Constants::SB_INDEX));
|
indexWindow->setWindowTitle(HelpPlugin::tr(Constants::SB_INDEX));
|
||||||
connect(indexWindow, &IndexWindow::linkActivated,
|
|
||||||
this, &HelpWidget::open);
|
|
||||||
connect(indexWindow, &IndexWindow::linksActivated,
|
connect(indexWindow, &IndexWindow::linksActivated,
|
||||||
this, &HelpWidget::showTopicChooser);
|
this, &HelpWidget::showLinks);
|
||||||
m_indexAction = new QAction(HelpPlugin::tr(Constants::SB_INDEX), this);
|
m_indexAction = new QAction(HelpPlugin::tr(Constants::SB_INDEX), this);
|
||||||
cmd = Core::ActionManager::registerAction(m_indexAction, Constants::HELP_INDEX, m_context->context());
|
cmd = Core::ActionManager::registerAction(m_indexAction, Constants::HELP_INDEX, m_context->context());
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+I")
|
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+I")
|
||||||
@@ -535,12 +533,18 @@ void HelpWidget::open(const QUrl &url, bool newPage)
|
|||||||
setSource(url);
|
setSource(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpWidget::showTopicChooser(const QMap<QString, QUrl> &links,
|
void HelpWidget::showLinks(const QMap<QString, QUrl> &links,
|
||||||
const QString &keyword, bool newPage)
|
const QString &keyword, bool newPage)
|
||||||
{
|
{
|
||||||
TopicChooser tc(this, keyword, links);
|
if (links.size() < 1)
|
||||||
if (tc.exec() == QDialog::Accepted)
|
return;
|
||||||
open(tc.link(), newPage);
|
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)
|
void HelpWidget::activateSideBarItem(const QString &id)
|
||||||
|
@@ -74,7 +74,7 @@ public:
|
|||||||
|
|
||||||
void open(const QUrl &url, bool newPage = false);
|
void open(const QUrl &url, bool newPage = false);
|
||||||
void openFromSearch(const QUrl &url, const QStringList &searchTerms, 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);
|
bool newPage = false);
|
||||||
void activateSideBarItem(const QString &id);
|
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();
|
QString keyword = m_filteredIndexModel->data(index, Qt::DisplayRole).toString();
|
||||||
QMap<QString, QUrl> links = LocalHelpManager::helpEngine().indexModel()->linksForKeyword(keyword);
|
QMap<QString, QUrl> links = LocalHelpManager::helpEngine().indexModel()->linksForKeyword(keyword);
|
||||||
|
emit linksActivated(links, keyword, newPage);
|
||||||
if (links.size() == 1) {
|
|
||||||
emit linkActivated(links.first(), newPage);
|
|
||||||
} else if (links.size() > 1) {
|
|
||||||
emit linksActivated(links, keyword, newPage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::DropActions IndexFilterModel::supportedDragActions() const
|
Qt::DropActions IndexFilterModel::supportedDragActions() const
|
||||||
|
@@ -88,7 +88,6 @@ public:
|
|||||||
void setOpenInNewPageActionVisible(bool visible);
|
void setOpenInNewPageActionVisible(bool visible);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void linkActivated(const QUrl &link, bool newPage);
|
|
||||||
void linksActivated(const QMap<QString, QUrl> &links,
|
void linksActivated(const QMap<QString, QUrl> &links,
|
||||||
const QString &keyword, bool newPage);
|
const QString &keyword, bool newPage);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user