]> git.lyx.org Git - features.git/commit
Line breaks in tooltips
authorGuillaume Munch <gm@lyx.org>
Sun, 5 Jun 2016 19:35:35 +0000 (21:35 +0200)
committerGuillaume Munch <gm@lyx.org>
Sun, 3 Jul 2016 15:28:45 +0000 (17:28 +0200)
commit059ca0f691d567171e7772c1d56a7f96e7867339
treedfd727a5b0952327f0ca1522c25227c3e80769ad
parent489dca71cd99bbc78780fa40311a2eb042c0320e
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>.
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/Makefile.am
src/frontends/qt4/ToolTipFormatter.cpp [new file with mode: 0644]
src/frontends/qt4/ToolTipFormatter.h [new file with mode: 0644]
src/frontends/qt4/qt_helpers.cpp
src/frontends/qt4/qt_helpers.h