Copilot: position copilot tooltip above cursor rect

Change-Id: I37c6572000231334b90f38a2b37f5983c80174a5
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
David Schulz
2023-05-30 13:48:01 +02:00
parent 827b8ae376
commit a35fd42364

View File

@@ -147,8 +147,12 @@ void CopilotHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const Q
auto tooltipWidget = new CopilotCompletionToolTip(suggestion->completions(),
suggestion->currentCompletion(),
editorWidget);
const qreal deltay = 2 * editorWidget->textDocument()->fontSettings().lineSpacing();
ToolTip::show(point - QPoint{0, int(deltay)}, tooltipWidget, editorWidget);
const QRect cursorRect = editorWidget->cursorRect(editorWidget->textCursor());
QPoint pos = editorWidget->viewport()->mapToGlobal(cursorRect.topLeft())
- Utils::ToolTip::offsetFromPosition();
pos.ry() -= tooltipWidget->sizeHint().height();
ToolTip::show(pos, tooltipWidget, editorWidget);
}
} // namespace Copilot::Internal