Le 03/07/2016 17:40, Guillaume Munch a écrit :
commit 059ca0f691d567171e7772c1d56a7f96e7867339
Author: Guillaume Munch <g...@lyx.org>
Date:   Sun Jun 5 21:35:35 2016 +0200

     Line breaks in tooltips

     * New function formatToolTip(QString):

     Format text for display as a ToolTip, breaking at lines of a certain
     width. Note: this function is expensive. Better call it in a delayed 
manner,
     i.e. not to fill in a model (see for instance the function
     ToolTipFormatter::eventFilter).

     * Install a global event filter that formats tooltips on-the-fly

     Inspired from
     
https://github.com/bitcoin/bitcoin/pull/1090/commits/3793fa09ff920fc720dfad3738f105d2c9563662
     but much improved.

     When is formatToolTip called automatically? Whenever the tooltip is not 
already
     rich text beginning with <html>, and is defined by the following functions:
      * QWidget::setToolTip(),
      * QAbstractItemModel::setData(..., Qt::ToolTipRole),
      * Inset::toolTip() (added in one of the subsequent patches)

     In other words, tooltips can use Qt html and the tooltip will still be 
correctly
     broken. Moreover, it is possible to specify an entirely custom tooltip (not
     subject to automatic formatting) by giving it in its entirety, i.e. 
starting
     with <html>.


Dear list

Tooltips can now be formatted in rich text using qt's html subset
(https://doc.qt.io/qt-5/richtext-html-subset.html). Before, this would
trigger automatic line breaking with a width which was way too narrow.
The patch above gives control over the width.

This is used to make the tooltips nicer, especially for bibliographic
references in the work area (please try).

Tooltips are also automatically formatted now using an event filter that
intercepts most tooltips before they are displayed, and also for
tooltips in the work area. There is no more need to manually introduce
line breaks. If you feel like doing so anyway in some circumstance,
please consider whether semantic html tags would be more appropriate.

The patch ought to be cross-platform, but if you see anything weird on
your platform let me know.

Sincerely
Guillaume

Reply via email to