-WebPreviewItem::WebPreviewItem(const QUrl &url)
- : QGraphicsItem(0), // needs to be a top level item as we otherwise cannot guarantee that it's on top of other chatlines
+# include <QGraphicsProxyWidget>
+# include <QPainter>
+
+# ifdef HAVE_WEBENGINE
+// QGraphicsProxyWidget does not stay synced with QWebEngineView, therefore we modify QWebEngineView
+// and manually trigger an update of the proxyItem on UpdateRequest Event. See: http://stackoverflow.com/a/30920209
+// and http://lists.qt-project.org/pipermail/development/2016-March/025280.html (At least in Qt5.6)
+class CustomWebView : public QWebEngineView
+{
+private:
+ QGraphicsProxyWidget* proxyItem;
+
+public:
+ CustomWebView(QGraphicsProxyWidget* pItem) { proxyItem = pItem; }
+ bool event(QEvent* event) override
+ {
+ if (event->type() == QEvent::UpdateRequest) {
+ proxyItem->update();
+ }
+
+ return QWebEngineView::event(event);
+ }
+};
+# endif
+
+WebPreviewItem::WebPreviewItem(const QUrl& url)
+ : QGraphicsItem(nullptr)
+ , // needs to be a top level item as we otherwise cannot guarantee that it's on top of other chatlines