From 107d16fe34a8a4b93ff0d810799a6f7a0ed79cdf Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 11 Apr 2023 22:42:25 +0200 Subject: [PATCH] ExternalToolsFilter: Use Acceptor for LocatorFilterEntry Change-Id: I1d9073f9849be7ada05a9f12237db2a32a5c802b Reviewed-by: Eike Ziller Reviewed-by: Qt CI Bot Reviewed-by: --- .../locator/externaltoolsfilter.cpp | 37 ++++++++----------- .../coreplugin/locator/externaltoolsfilter.h | 5 +-- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/plugins/coreplugin/locator/externaltoolsfilter.cpp b/src/plugins/coreplugin/locator/externaltoolsfilter.cpp index 7828cc13724..1478cbbc718 100644 --- a/src/plugins/coreplugin/locator/externaltoolsfilter.cpp +++ b/src/plugins/coreplugin/locator/externaltoolsfilter.cpp @@ -4,6 +4,7 @@ #include "externaltoolsfilter.h" #include "../coreconstants.h" +#include "../coreplugin.h" #include "../coreplugintr.h" #include "../externaltool.h" #include "../externaltoolmanager.h" @@ -30,26 +31,6 @@ QList ExternalToolsFilter::matchesFor(QFutureInterface(); - QTC_ASSERT(tool, return); - - auto runner = new ExternalToolRunner(tool); - if (runner->hasError()) - MessageManager::writeFlashing(runner->errorString()); -} - void ExternalToolsFilter::prepareSearch(const QString &entry) { QList bestEntries; @@ -66,8 +47,14 @@ void ExternalToolsFilter::prepareSearch(const QString &entry) } if (index >= 0) { - LocatorFilterEntry filterEntry(this, tool->displayName()); - filterEntry.internalData = QVariant::fromValue(tool); + LocatorFilterEntry filterEntry; + filterEntry.displayName = tool->displayName(); + filterEntry.acceptor = [tool] { + auto runner = new ExternalToolRunner(tool); + if (runner->hasError()) + MessageManager::writeFlashing(runner->errorString()); + return AcceptResult(); + }; filterEntry.extraInfo = tool->description(); filterEntry.highlightInfo = LocatorFilterEntry::HighlightInfo(index, entry.length(), hDataType); @@ -81,6 +68,12 @@ void ExternalToolsFilter::prepareSearch(const QString &entry) } LocatorFilterEntry configEntry(this, "Configure External Tool..."); configEntry.extraInfo = "Opens External Tool settings"; + configEntry.acceptor = [] { + QMetaObject::invokeMethod(CorePlugin::instance(), [] { + ICore::showOptionsDialog(Constants::SETTINGS_ID_TOOLS); + }, Qt::QueuedConnection); + return AcceptResult(); + }; m_results = {}; m_results << bestEntries << betterEntries << goodEntries << configEntry; } diff --git a/src/plugins/coreplugin/locator/externaltoolsfilter.h b/src/plugins/coreplugin/locator/externaltoolsfilter.h index 74d5214aa38..e97c04c2768 100644 --- a/src/plugins/coreplugin/locator/externaltoolsfilter.h +++ b/src/plugins/coreplugin/locator/externaltoolsfilter.h @@ -14,12 +14,9 @@ class ExternalToolsFilter : public ILocatorFilter public: ExternalToolsFilter(); + void prepareSearch(const QString &entry) override; QList matchesFor(QFutureInterface &future, const QString &entry) override; - void accept(const LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const override; - void prepareSearch(const QString &entry) override; - private: QList m_results; };