summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2014-03-12 18:36:24 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-14 11:43:31 +0100
commit38b5dc5fbdae25491435395202f6980f44ca8ef5 (patch)
tree4d6f31abad96ea8ed8d61d2d21cec5a19f3328f8 /src
parentc4c163b9ef0cf8a59f683aecf079cadf0e1505d8 (diff)
Tooltip support.
Basic tooltip support for widgets relying on the existing QToolTip mechanism. Left unimplemented on the Qt Quick side for now since ToolTip support is still very much a work in progress there. Change-Id: Ia4bfd715a224e0cbc147c8860e131d1545cebe1e Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/render_widget_host_view_qt.cpp4
-rw-r--r--src/core/render_widget_host_view_qt.h4
-rw-r--r--src/core/render_widget_host_view_qt_delegate.h1
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.h2
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp7
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_popup.cpp6
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_popup.h1
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_webpage.cpp6
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_webpage.h1
9 files changed, 26 insertions, 6 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 6f280fb5..d9822769 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -511,9 +511,9 @@ void RenderWidgetHostViewQt::Destroy()
delete this;
}
-void RenderWidgetHostViewQt::SetTooltipText(const string16&)
+void RenderWidgetHostViewQt::SetTooltipText(const string16 &tooltip_text)
{
- // QT_NOT_YET_IMPLEMENTED
+ m_delegate->setTooltip(toQt(tooltip_text));
}
void RenderWidgetHostViewQt::SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params &params)
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index 6d4e1ba8..541df7d9 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -140,7 +140,7 @@ public:
virtual void DidUpdateBackingStore(const gfx::Rect& scroll_rect, const gfx::Vector2d& scroll_delta, const std::vector<gfx::Rect>& copy_rects, const ui::LatencyInfo&) Q_DECL_OVERRIDE;
virtual void RenderProcessGone(base::TerminationStatus, int) Q_DECL_OVERRIDE;
virtual void Destroy() Q_DECL_OVERRIDE;
- virtual void SetTooltipText(const string16&) Q_DECL_OVERRIDE;
+ virtual void SetTooltipText(const string16 &tooltip_text) Q_DECL_OVERRIDE;
virtual void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params&) Q_DECL_OVERRIDE;
virtual void ScrollOffsetChanged() Q_DECL_OVERRIDE;
virtual void CopyFromCompositingSurface(const gfx::Rect& src_subrect, const gfx::Size& /* dst_size */, const base::Callback<void(bool, const SkBitmap&)>& callback) Q_DECL_OVERRIDE;
@@ -162,7 +162,7 @@ public:
virtual void ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, content::InputEventAckState ack_result) Q_DECL_OVERRIDE;
// Overridden from RenderWidgetHostViewBase.
- virtual void SelectionChanged(const string16 &text, size_t offset, const gfx::Range &range) OVERRIDE;
+ virtual void SelectionChanged(const string16 &text, size_t offset, const gfx::Range &range) Q_DECL_OVERRIDE;
// Overridden from ui::GestureEventHelper.
virtual bool DispatchLongPressGestureEvent(ui::GestureEvent *event) Q_DECL_OVERRIDE;
diff --git a/src/core/render_widget_host_view_qt_delegate.h b/src/core/render_widget_host_view_qt_delegate.h
index e71c7958..08d66745 100644
--- a/src/core/render_widget_host_view_qt_delegate.h
+++ b/src/core/render_widget_host_view_qt_delegate.h
@@ -90,6 +90,7 @@ public:
virtual void move(const QPoint &) = 0;
virtual void inputMethodStateChanged(bool editorVisible) = 0;
virtual bool supportsHardwareAcceleration() const = 0;
+ virtual void setTooltip(const QString &) = 0;
};
#endif // RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_H
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.h b/src/webengine/render_widget_host_view_qt_delegate_quick.h
index 866cf23e..f4d72117 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.h
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.h
@@ -199,6 +199,8 @@ public:
qApp->inputMethod()->setVisible(editorVisible);
}
+ void setTooltip(const QString &) Q_DECL_OVERRIDE {}
+
QVariant inputMethodQuery(Qt::InputMethodQuery query) const
{
return m_client->inputMethodQuery(query);
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index a2934905..3f3fdd7c 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -228,8 +228,11 @@ bool QWebEngineView::event(QEvent *ev)
if (ev->type() == QEvent::ContextMenu) {
ev->accept();
return true;
- } else if (ev->type() == QEvent::MetaCall)
- // Meta calls are not safe to forward to the page, as they could be widget specific (e.g. QWidgetPrivate::_q_showIfNotHidden)
+
+ // Meta calls are not safe to forward to the page, as they could be widget specific (e.g. QWidgetPrivate::_q_showIfNotHidden)
+ // ToolTip events need to be processed at the widget level for the tooltip to show.
+ } else if (ev->type() == QEvent::MetaCall
+ || ev->type() == QEvent::ToolTip)
return QWidget::event(ev);
if (d->page && d->page->event(ev))
return true;
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_popup.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_popup.cpp
index 7900ed9b..eae3b8a6 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_popup.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_popup.cpp
@@ -62,6 +62,7 @@ RenderWidgetHostViewQtDelegatePopup::RenderWidgetHostViewQtDelegatePopup(RenderW
// loses focus, WebKit will cause its associated popups (including this one)
// to be destroyed.
setAttribute(Qt::WA_ShowWithoutActivating);
+ setAttribute(Qt::WA_AlwaysShowToolTips);
setFocusPolicy(Qt::NoFocus);
setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
}
@@ -137,6 +138,11 @@ void RenderWidgetHostViewQtDelegatePopup::move(const QPoint &pos)
QWidget::move(mapped);
}
+void RenderWidgetHostViewQtDelegatePopup::setTooltip(const QString &tooltip)
+{
+ setToolTip(tooltip);
+}
+
void RenderWidgetHostViewQtDelegatePopup::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_popup.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_popup.h
index 330afc25..5f3e6595 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_popup.h
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_popup.h
@@ -74,6 +74,7 @@ public:
virtual void move(const QPoint &) Q_DECL_OVERRIDE;
virtual void inputMethodStateChanged(bool) Q_DECL_OVERRIDE {}
virtual bool supportsHardwareAcceleration() const Q_DECL_OVERRIDE { return false; }
+ virtual void setTooltip(const QString &tooltip) Q_DECL_OVERRIDE;
protected:
void paintEvent(QPaintEvent * event);
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_webpage.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_webpage.cpp
index d6e99f4e..e8a3e7d4 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_webpage.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_webpage.cpp
@@ -139,6 +139,12 @@ bool RenderWidgetHostViewQtDelegateWebPage::supportsHardwareAcceleration() const
return false;
}
+void RenderWidgetHostViewQtDelegateWebPage::setTooltip(const QString &tooltip)
+{
+ if (m_page && m_page->view())
+ m_page->view()->setToolTip(tooltip);
+}
+
void RenderWidgetHostViewQtDelegateWebPage::paint(QPainter *painter, const QRectF &boundingRect)
{
m_client->fetchBackingStore();
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_webpage.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_webpage.h
index 52988aef..80da9d72 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_webpage.h
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_webpage.h
@@ -75,6 +75,7 @@ public:
virtual void move(const QPoint&) Q_DECL_OVERRIDE {}
virtual void inputMethodStateChanged(bool editorVisible) Q_DECL_OVERRIDE;
virtual bool supportsHardwareAcceleration() const Q_DECL_OVERRIDE;
+ virtual void setTooltip(const QString &tooltip) Q_DECL_OVERRIDE;
void paint(QPainter *painter, const QRectF &boundingRect);
void notifyResize();