summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2014-05-08 14:03:30 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-16 16:57:49 +0200
commitb43774a9b89ed9fe7276b4632ff415bf0b925e41 (patch)
tree5e04ae3fba8b01badb97d2880fdcc7a7c056974e
parent23f035b4975ddd31a5b0a193a4d4dba705c99e98 (diff)
[Widgets] Tooltip word wrap fixup
QTooltip's documentation states that "rich text displayed in a tool tip is implicitly word-wrapped". This seems to be a more desirable behavior for our needs. To mitigate any potential malicious tooltip contents, we escape any eventual html entities, and truncate to a reasonable size. Change-Id: Iae3ea80e7660840aae39d228d1177dcc56f4a032 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index 46f531e5..72db8979 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -50,6 +50,8 @@
#include <private/qsgrenderer_p.h>
#include <private/qwidget_p.h>
+static const int MaxTooltipLength = 1024;
+
RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent)
: QOpenGLWidget(parent)
, m_client(client)
@@ -162,7 +164,10 @@ void RenderWidgetHostViewQtDelegateWidget::inputMethodStateChanged(bool editorVi
void RenderWidgetHostViewQtDelegateWidget::setTooltip(const QString &tooltip)
{
- setToolTip(tooltip);
+ QString wrappedTip;
+ if (!tooltip.isEmpty())
+ wrappedTip = QStringLiteral("<p>") % tooltip.toHtmlEscaped().left(MaxTooltipLength) % QStringLiteral("</p>");
+ setToolTip(wrappedTip);
}
QVariant RenderWidgetHostViewQtDelegateWidget::inputMethodQuery(Qt::InputMethodQuery query) const