aboutsummaryrefslogtreecommitdiff
path: root/src/qt/guiutil.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-05-10 23:54:53 -0700
committerWladimir J. van der Laan <laanwj@gmail.com>2012-05-10 23:54:53 -0700
commitb8a5e30d9136673163555615e17098c07b4c821f (patch)
treeffcb6685a887564859e1deae822af46f6b30c5d2 /src/qt/guiutil.cpp
parentf93727aa56d9c38fdaebe7caa227188772ba4ac5 (diff)
parent3793fa09ff920fc720dfad3738f105d2c9563662 (diff)
downloadbitcoin-b8a5e30d9136673163555615e17098c07b4c821f.tar.xz
Merge pull request #1090 from laanwj/2012_04_wraptooltips
Allow Qt to wrap long tooltips (fixes #1063)
Diffstat (limited to 'src/qt/guiutil.cpp')
-rw-r--r--src/qt/guiutil.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index f1e8a5f1bc..3b8f8c76f8 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -214,5 +214,29 @@ bool isObscured(QWidget *w)
&& checkPoint(QPoint(w->width()/2, w->height()/2), w));
}
+ToolTipToRichTextFilter::ToolTipToRichTextFilter(int size_threshold, QObject *parent):
+ size_threshold(size_threshold), QObject(parent)
+{
+
+}
+
+bool ToolTipToRichTextFilter::eventFilter(QObject *obj, QEvent *evt)
+{
+ if(evt->type() == QEvent::ToolTipChange)
+ {
+ QWidget *widget = static_cast<QWidget*>(obj);
+ QString tooltip = widget->toolTip();
+ if(!Qt::mightBeRichText(tooltip) && tooltip.size() > size_threshold)
+ {
+ // Prefix <qt/> to make sure Qt detects this as rich text
+ // Escape the current message as HTML and replace \n by <br>
+ tooltip = "<qt/>" + HtmlEscape(tooltip, true);
+ widget->setToolTip(tooltip);
+ return true;
+ }
+ }
+ return QObject::eventFilter(obj, evt);
+}
+
} // namespace GUIUtil