endif()
# For this, the feature info is added after we know if QtWebkit is installed
-option(WITH_WEBKIT "WebKit support (for link previews)" ON)
+option(WITH_WEBKIT "WebKit support (for link previews) (legacy)" ON)
+
+# For this, the feature info is added after we know if QtWebEngine is installed
+option(WITH_WEBENGINE "WebEngine support (for link previews)" ON)
if (APPLE)
# Notification Center is only available in > 10.8, which is Darwin v12
if (WITH_WEBKIT AND Qt5WebKitWidgets_FOUND)
set(HAVE_WEBKIT true)
endif()
- add_feature_info("WITH_WEBKIT, QtWebKit and QtWebKitWidgets modules" HAVE_WEBKIT "Support showing previews for URLs in chat")
+ add_feature_info("WITH_WEBKIT, QtWebKit and QtWebKitWidgets modules" HAVE_WEBKIT "Support showing previews for URLs in chat (legacy)")
+
+ if (WITH_WEBENGINE)
+ find_package(Qt5WebEngine QUIET)
+ set_package_properties(Qt5WebEngine PROPERTIES TYPE RECOMMENDED
+ URL "http://qt.digia.com"
+ DESCRIPTION "a WebEngine implementation for Qt"
+ PURPOSE "Needed for displaying previews for URLs in chat"
+ )
+ if (Qt5WebEngine_FOUND)
+ find_package(Qt5WebEngineWidgets QUIET)
+ set_package_properties(Qt5WebEngineWidgets PROPERTIES TYPE RECOMMENDED
+ URL "http://qt.digia.com"
+ DESCRIPTION "widgets for Qt's WebEngine implementation"
+ PURPOSE "Needed for displaying previews for URLs in chat"
+ )
+ endif()
+ endif()
+
+ if (WITH_WEBENGINE AND Qt5WebEngineWidgets_FOUND)
+ set(HAVE_WEBENGINE true)
+ endif()
+ add_feature_info("WITH_WEBENGINE, QtWebEngine and QtWebEngineWidgets modules" HAVE_WEBENGINE "Support showing previews for URLs in chat")
# KDE Frameworks
################
endif()
endif()
+if (HAVE_WEBENGINE)
+ add_definitions(-DHAVE_WEBENGINE)
+ list(APPEND QT_MODULES WebEngine)
+ if (USE_QT5)
+ list(APPEND QT_MODULES WebEngineWidgets)
+ endif()
+endif()
+
if(HAVE_SSL)
set(SOURCES ${SOURCES} sslinfodlg.cpp)
set(FORMS ${FORMS} sslinfodlg.ui)
void ContentsChatItem::showWebPreview(const Clickable &click)
{
-#ifndef HAVE_WEBKIT
+#if !defined HAVE_WEBKIT && !defined HAVE_WEBENGINE
Q_UNUSED(click);
#else
QTextLine line = layout()->lineForTextPosition(click.start());
void ContentsChatItem::clearWebPreview()
{
-#ifdef HAVE_WEBKIT
+#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE
chatScene()->clearWebPreview(this);
#endif
}
# include <QMenuBar>
#endif
-#ifdef HAVE_WEBKIT
+#ifdef HAVE_WEBENGINE
+# include <QWebEngineView>
+#elif defined HAVE_WEBKIT
# include <QWebView>
#endif
this, SLOT(rowsRemoved()));
connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), SLOT(dataChanged(QModelIndex, QModelIndex)));
-#ifdef HAVE_WEBKIT
+#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE
webPreview.timer.setSingleShot(true);
connect(&webPreview.timer, SIGNAL(timeout()), this, SLOT(webPreviewNextStep()));
#endif
// ========================================
-// Webkit Only stuff
+// Webkit/WebEngine Only stuff
// ========================================
-#ifdef HAVE_WEBKIT
+#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE
void ChatScene::loadWebPreview(ChatItem *parentItem, const QUrl &url, const QRectF &urlRect)
{
if (!_showWebPreview)
void requestBacklog();
-#ifdef HAVE_WEBKIT
+#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE
void loadWebPreview(ChatItem *parentItem, const QUrl &url, const QRectF &urlRect);
void clearWebPreview(ChatItem *parentItem = 0);
#endif
private slots:
void firstHandlePositionChanged(qreal xpos);
void secondHandlePositionChanged(qreal xpos);
-#ifdef HAVE_WEBKIT
+#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE
void webPreviewNextStep();
#endif
void showWebPreviewChanged();
static const int _webSearchSelectionTextMaxVisible = 24;
-#ifdef HAVE_WEBKIT
+#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE
struct WebPreview {
enum PreviewState {
NoPreview,
WebPreview() : parentItem(0), previewItem(0), previewState(NoPreview) {}
};
WebPreview webPreview;
-#endif // HAVE_WEBKIT
+#endif // HAVE_WEBKIT || HAVE_WEBENGINE
};
{
ui.setupUi(this);
-#ifndef HAVE_WEBKIT
+#if !defined HAVE_WEBKIT && !defined HAVE_WEBENGINE
ui.showWebPreview->hide();
ui.showWebPreview->setEnabled(false);
#endif
#include "webpreviewitem.h"
-#ifdef HAVE_WEBKIT
+#ifdef HAVE_WEBENGINE
+#include <QWebEngineView>
+#include <QWebEngineSettings>
+#elif defined HAVE_WEBKIT
+#include <QWebView>
+#include <QWebSettings>
+#endif
+
+#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE
#include <QGraphicsProxyWidget>
#include <QPainter>
-#include <QWebView>
-#include <QWebSettings>
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
{
qreal frameWidth = 5;
+#ifdef HAVE_WEBENGINE
+ QWebEngineView *webView = new QWebEngineView;
+ webView->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
+#elif defined HAVE_WEBKIT
QWebView *webView = new QWebView;
webView->settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
+#endif
webView->load(url);
webView->setDisabled(true);
webView->resize(1000, 750);
}
-#endif //#ifdef HAVE_WEBKIT
+#endif //#ifdef HAVE_WEBKIT || HAVE_WEBENGINE
#ifndef WEBPREVIEWITEM_H
#define WEBPREVIEWITEM_H
-#ifdef HAVE_WEBKIT
+#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE
#include <QGraphicsItem>
};
-#endif //#ifdef HAVE_WEBKIT
+#endif //#ifdef HAVE_WEBKIT || HAVE_WEBENGINE
#endif //WEBPREVIEWITEM_H