tdf#162297 Wrap tooltips in Qt5

Acoording to the Qt documentation, in order to wrap the tooltip a rich-text style needs to be set.

This patch sets a dummy style to make sure the tooltip gets wrapped in LO.

Change-Id: I7e950932572030581abc1c81fb4c146cb4394eb4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171411
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Rafael Lima 2024-08-02 19:30:18 +02:00 committed by Michael Weghorn
parent 644b5130ed
commit fa89130d49

View file

@ -721,8 +721,13 @@ bool QtWidget::handleEvent(QtFrame& rFrame, QWidget& rWidget, QEvent* pEvent)
// Otherwise Qt will continue handling ToolTip events from the "parent" window.
const QtFrame* pPopupFrame = GetQtInstance()->activePopup();
if (!rFrame.m_aTooltipText.isEmpty() && (!pPopupFrame || pPopupFrame == &rFrame))
QToolTip::showText(QCursor::pos(), toQString(rFrame.m_aTooltipText), &rWidget,
rFrame.m_aTooltipArea);
{
// tdf#162297 Use a dummy style to ensure the tooltip is wrapped
QString sTooltipText("<font font-weight=normal>");
sTooltipText += toQString(rFrame.m_aTooltipText);
sTooltipText += "</font>";
QToolTip::showText(QCursor::pos(), sTooltipText, &rWidget, rFrame.m_aTooltipArea);
}
else
{
QToolTip::hideText();