forked from qt-creator/qt-creator
Help: Make it possible to duplicate search view
Change-Id: I6fac9f721fc3e2f877d9f600f9dea6650558516a Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -453,14 +453,18 @@ void HelpWidget::setSource(const QUrl &url)
|
||||
viewer->setFocus(Qt::OtherFocusReason);
|
||||
}
|
||||
|
||||
void HelpWidget::setSourceFromSearch(const QUrl &url)
|
||||
void HelpWidget::openFromSearch(const QUrl &url, bool newPage)
|
||||
{
|
||||
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 *)
|
||||
{
|
||||
|
||||
@@ -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<QString, QUrl> &links, const QString &key,
|
||||
bool newPage = false);
|
||||
|
||||
public slots:
|
||||
void setSource(const QUrl &url);
|
||||
void setSourceFromSearch(const QUrl &url);
|
||||
void updateCloseButton();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -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<QToolButton *> SearchSideBarItem::createToolBarWidgets()
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
QList<QToolButton *> 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);
|
||||
|
||||
Reference in New Issue
Block a user