forked from qt-creator/qt-creator
ExternalToolsFilter: Use Acceptor for LocatorFilterEntry
Change-Id: I1d9073f9849be7ada05a9f12237db2a32a5c802b Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include "externaltoolsfilter.h"
|
#include "externaltoolsfilter.h"
|
||||||
|
|
||||||
#include "../coreconstants.h"
|
#include "../coreconstants.h"
|
||||||
|
#include "../coreplugin.h"
|
||||||
#include "../coreplugintr.h"
|
#include "../coreplugintr.h"
|
||||||
#include "../externaltool.h"
|
#include "../externaltool.h"
|
||||||
#include "../externaltoolmanager.h"
|
#include "../externaltoolmanager.h"
|
||||||
@@ -30,26 +31,6 @@ QList<LocatorFilterEntry> ExternalToolsFilter::matchesFor(QFutureInterface<Locat
|
|||||||
return m_results;
|
return m_results;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExternalToolsFilter::accept(const LocatorFilterEntry &selection,
|
|
||||||
QString *newText, int *selectionStart, int *selectionLength) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(newText)
|
|
||||||
Q_UNUSED(selectionStart)
|
|
||||||
Q_UNUSED(selectionLength)
|
|
||||||
|
|
||||||
if (!selection.internalData.isValid()) {
|
|
||||||
ICore::showOptionsDialog(Constants::SETTINGS_ID_TOOLS);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto tool = selection.internalData.value<ExternalTool *>();
|
|
||||||
QTC_ASSERT(tool, return);
|
|
||||||
|
|
||||||
auto runner = new ExternalToolRunner(tool);
|
|
||||||
if (runner->hasError())
|
|
||||||
MessageManager::writeFlashing(runner->errorString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExternalToolsFilter::prepareSearch(const QString &entry)
|
void ExternalToolsFilter::prepareSearch(const QString &entry)
|
||||||
{
|
{
|
||||||
QList<LocatorFilterEntry> bestEntries;
|
QList<LocatorFilterEntry> bestEntries;
|
||||||
@@ -66,8 +47,14 @@ void ExternalToolsFilter::prepareSearch(const QString &entry)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
LocatorFilterEntry filterEntry(this, tool->displayName());
|
LocatorFilterEntry filterEntry;
|
||||||
filterEntry.internalData = QVariant::fromValue(tool);
|
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.extraInfo = tool->description();
|
||||||
filterEntry.highlightInfo = LocatorFilterEntry::HighlightInfo(index, entry.length(), hDataType);
|
filterEntry.highlightInfo = LocatorFilterEntry::HighlightInfo(index, entry.length(), hDataType);
|
||||||
|
|
||||||
@@ -81,6 +68,12 @@ void ExternalToolsFilter::prepareSearch(const QString &entry)
|
|||||||
}
|
}
|
||||||
LocatorFilterEntry configEntry(this, "Configure External Tool...");
|
LocatorFilterEntry configEntry(this, "Configure External Tool...");
|
||||||
configEntry.extraInfo = "Opens External Tool settings";
|
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 = {};
|
||||||
m_results << bestEntries << betterEntries << goodEntries << configEntry;
|
m_results << bestEntries << betterEntries << goodEntries << configEntry;
|
||||||
}
|
}
|
||||||
|
@@ -14,12 +14,9 @@ class ExternalToolsFilter : public ILocatorFilter
|
|||||||
public:
|
public:
|
||||||
ExternalToolsFilter();
|
ExternalToolsFilter();
|
||||||
|
|
||||||
|
void prepareSearch(const QString &entry) override;
|
||||||
QList<LocatorFilterEntry> matchesFor(QFutureInterface<LocatorFilterEntry> &future,
|
QList<LocatorFilterEntry> matchesFor(QFutureInterface<LocatorFilterEntry> &future,
|
||||||
const QString &entry) override;
|
const QString &entry) override;
|
||||||
void accept(const LocatorFilterEntry &selection,
|
|
||||||
QString *newText, int *selectionStart, int *selectionLength) const override;
|
|
||||||
void prepareSearch(const QString &entry) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<LocatorFilterEntry> m_results;
|
QList<LocatorFilterEntry> m_results;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user