Editor: Fix completion tooltip width calculation

Take the offset of the geometry into account when calculating the
available with for the tooltip. This can happen if you have multiple
monitors and the tooltip is positioned on the right monitor.

amends 30cdae912f

Fixes: QTCREATORBUG-26053
Change-Id: I4116547279f3c6708f55a1e1cf7d4ceb76028f9a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
David Schulz
2021-08-11 07:09:09 +02:00
parent 21cb0711c4
commit 1a3b8bf0e7

View File

@@ -143,12 +143,13 @@ public:
// Workaround QTCREATORBUG-11653
void calculateMaximumWidth()
{
const int desktopWidth = screen()->availableGeometry().width();
const QRect screenGeometry = screen()->availableGeometry();
const int xOnScreen = this->pos().x() - screenGeometry.x();
const QMargins widgetMargins = contentsMargins();
const QMargins layoutMargins = layout()->contentsMargins();
const int margins = widgetMargins.left() + widgetMargins.right()
+ layoutMargins.left() + layoutMargins.right();
m_label->setMaximumWidth(desktopWidth - this->pos().x() - margins);
m_label->setMaximumWidth(qMax(0, screenGeometry.width() - xOnScreen - margins));
}
private: