mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-16 07:55:41 +00:00
059ca0f691
* 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
3793fa09ff
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>.
38 lines
717 B
C++
38 lines
717 B
C++
// -*- C++ -*-
|
|
/**
|
|
* \file ToolTipFormatter.h
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Guillaume Munch
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#ifndef TOOLTIPFORMATTER_H
|
|
#define TOOLTIPFORMATTER_H
|
|
|
|
#include <QObject>
|
|
|
|
class QEvent;
|
|
|
|
namespace lyx {
|
|
namespace frontend {
|
|
|
|
|
|
/// This event filter intercepts ToolTip events, to format any tooltip
|
|
/// appropriately before display.
|
|
class ToolTipFormatter : public QObject {
|
|
Q_OBJECT
|
|
public:
|
|
ToolTipFormatter(QObject * parent);
|
|
protected:
|
|
bool eventFilter(QObject * o, QEvent * e);
|
|
};
|
|
|
|
|
|
} // namespace frontend
|
|
} // namespace lyx
|
|
|
|
#endif // TOOLTIPFORMATTER_H
|