MCPcopy Create free account
hub / github.com/Palm1r/QodeAssist / showError

Method showError

widgets/CompletionErrorHandler.cpp:14–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12namespace QodeAssist {
13
14void CompletionErrorHandler::showError(
15 TextEditor::TextEditorWidget *widget,
16 const QString &errorMessage,
17 int autoHideMs)
18{
19 m_widget = widget;
20 m_errorMessage = errorMessage;
21
22 if (m_widget) {
23 const QRect cursorRect = m_widget->cursorRect(m_widget->textCursor());
24 m_errorPosition = m_widget->viewport()->mapToGlobal(cursorRect.topLeft())
25 - Utils::ToolTip::offsetFromPosition();
26
27 identifyMatch(m_widget, m_widget->textCursor().position(), [this, autoHideMs](auto priority) {
28 if (priority != Priority_None) {
29 if (m_errorWidget) {
30 m_errorWidget->deleteLater();
31 }
32
33 m_errorWidget = new ErrorWidget(m_errorMessage, m_widget);
34
35 const QRect cursorRect = m_widget->cursorRect(m_widget->textCursor());
36 QPoint globalPos = m_widget->viewport()->mapToGlobal(cursorRect.topLeft());
37 QPoint localPos = m_widget->mapFromGlobal(globalPos);
38 localPos.ry() -= m_errorWidget->height() + 5;
39
40 if (localPos.y() < 0) {
41 localPos.ry() = cursorRect.bottom() + 5;
42 }
43
44 m_errorWidget->move(localPos);
45 m_errorWidget->show();
46 m_errorWidget->raise();
47
48 QObject::connect(m_errorWidget, &ErrorWidget::dismissed, m_errorWidget, [this]() {
49 hideError();
50 });
51 }
52 });
53 }
54}
55
56void CompletionErrorHandler::hideError()
57{

Callers 2

handleCompletionsMethod · 0.80

Calls 2

positionMethod · 0.45
raiseMethod · 0.45

Tested by

no test coverage detected