feat: Add cancel function for progress indicator

This commit is contained in:
Petr Mironychev
2025-11-16 11:24:36 +01:00
parent 6f680e3974
commit 31e3d9db7c
7 changed files with 148 additions and 25 deletions

View File

@ -60,6 +60,11 @@ void CompletionProgressHandler::hideProgress()
Utils::ToolTip::hideImmediately();
}
void CompletionProgressHandler::setCancelCallback(std::function<void()> callback)
{
m_cancelCallback = callback;
}
void CompletionProgressHandler::identifyMatch(
TextEditor::TextEditorWidget *editorWidget, int pos, ReportPriority report)
{
@ -83,6 +88,11 @@ void CompletionProgressHandler::operateTooltip(
m_progressWidget = new ProgressWidget(editorWidget);
// Set cancel callback for the widget
if (m_cancelCallback) {
m_progressWidget->setCancelCallback(m_cancelCallback);
}
const QRect cursorRect = editorWidget->cursorRect(editorWidget->textCursor());
QPoint globalPos = editorWidget->viewport()->mapToGlobal(cursorRect.topLeft());
QPoint localPos = editorWidget->mapFromGlobal(globalPos);