Commit 021f44e7 authored by Laurent Montel's avatar Laurent Montel 😁

Use QtWebengine

parent a9f0fc4c
......@@ -22,7 +22,7 @@ include(ECMAddTests)
set(KF5_VERSION "5.19.0")
set(LIBKSIEVE_LIB_VERSION "5.2.40")
set(KDEPIMLIBS_LIB_VERSION "5.2.40")
set(QT_REQUIRED_VERSION "5.4.0")
set(QT_REQUIRED_VERSION "5.6.0")
set(KMIME_LIB_VERSION "5.2.40")
set(IDENTITYMANAGEMENT_LIB_VERSION "5.2.40")
set(KMAILTRANSPORT_LIB_VERSION "5.2.40")
......@@ -53,14 +53,7 @@ set_package_properties(Sasl2 PROPERTIES
)
option(QTWEBENGINE_SUPPORT_OPTION "Enable support for QtWebEngine. False by default." FALSE)
if (QTWEBENGINE_SUPPORT_OPTION)
set(QT_REQUIRED_MINIMUM_WEBENGINE_VERSION "5.6")
find_package(Qt5 ${QT_REQUIRED_MINIMUM_WEBENGINE_VERSION} CONFIG REQUIRED WebEngine WebEngineWidgets)
else()
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED WebKitWidgets)
endif()
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED WebEngine WebEngineWidgets)
ecm_setup_version(${LIBKSIEVE_LIB_VERSION} VARIABLE_PREFIX LIBKSIEVE
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/libksieve_version.h"
......
/* The size of a `unsigned long', as computed by sizeof. */
#define SIZEOF_UNSIGNED_LONG ${SIZEOF_UNSIGNED_LONG}
#cmakedefine QTWEBENGINE_SUPPORT_OPTION 1
......@@ -39,17 +39,10 @@ set(ksieveui_vacation_LIB_SRCS
vacation/legacy/vacationutils.cpp
vacation/legacy/vacationscriptextractor.cpp
)
if (QTWEBENGINE_SUPPORT_OPTION)
set(ksieveui_webpageeditor_LIB_SRCS
editor/sieveeditorwebengineview.cpp
)
set(ksieveui_web_LIB Qt5::WebEngineWidgets)
else()
set(ksieveui_webpageeditor_LIB_SRCS
editor/sieveeditorwebview.cpp
)
set(ksieveui_web_LIB Qt5::WebKitWidgets)
endif()
set(ksieveui_webpageeditor_LIB_SRCS
editor/sieveeditorwebengineview.cpp
)
set(ksieveui_web_LIB Qt5::WebEngineWidgets)
set(ksieveui_editor_LIB_SRCS
${ksieveui_webpageeditor_LIB_SRCS}
......
......@@ -18,11 +18,7 @@
#include "sieveeditorhelphtmlwidget.h"
#include "sieveeditorloadprogressindicator.h"
#ifdef QTWEBENGINE_SUPPORT_OPTION
#include "sieveeditorwebengineview.h"
#else
#include "sieveeditorwebview.h"
#endif
#include <QVBoxLayout>
......@@ -41,17 +37,10 @@ SieveEditorHelpHtmlWidget::SieveEditorHelpHtmlWidget(QWidget *parent)
mProgressIndicator = new SieveEditorLoadProgressIndicator(this);
connect(mProgressIndicator, &SieveEditorLoadProgressIndicator::pixmapChanged, this, &SieveEditorHelpHtmlWidget::slotPixmapChanged);
connect(mProgressIndicator, &SieveEditorLoadProgressIndicator::loadFinished, this, &SieveEditorHelpHtmlWidget::slotLoadFinished);
#ifdef QTWEBENGINE_SUPPORT_OPTION
mWebView = new SieveEditorWebEngineView;
connect(mWebView, &SieveEditorWebEngineView::titleChanged, this, &SieveEditorHelpHtmlWidget::slotTitleChanged);
connect(mWebView, &SieveEditorWebEngineView::loadStarted, this, &SieveEditorHelpHtmlWidget::slotLoadStarted);
connect(mWebView, &SieveEditorWebEngineView::loadFinished, this, &SieveEditorHelpHtmlWidget::slotFinished);
#else
mWebView = new SieveEditorWebView;
connect(mWebView, &SieveEditorWebView::titleChanged, this, &SieveEditorHelpHtmlWidget::slotTitleChanged);
connect(mWebView, &SieveEditorWebView::loadStarted, this, &SieveEditorHelpHtmlWidget::slotLoadStarted);
connect(mWebView, &SieveEditorWebView::loadFinished, this, &SieveEditorHelpHtmlWidget::slotFinished);
#endif
QVBoxLayout *lay = new QVBoxLayout;
lay->addWidget(mWebView);
setLayout(lay);
......
......@@ -24,11 +24,7 @@
namespace KSieveUi
{
#ifdef QTWEBENGINE_SUPPORT_OPTION
class SieveEditorWebEngineView;
#else
class SieveEditorWebView;
#endif
class SieveEditorLoadProgressIndicator;
class SieveEditorHelpHtmlWidget : public QWidget
{
......@@ -59,11 +55,7 @@ private Q_SLOTS:
void slotLoadFinished(bool success);
private:
QString mTitle;
#ifdef QTWEBENGINE_SUPPORT_OPTION
SieveEditorWebEngineView *mWebView;
#else
SieveEditorWebView *mWebView;
#endif
SieveEditorLoadProgressIndicator *mProgressIndicator;
qreal mZoomFactor;
};
......
/*
Copyright (c) 2014-2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "sieveeditorwebview.h"
#include <QMenu>
#include <QWebPage>
#include <QContextMenuEvent>
using namespace KSieveUi;
SieveEditorWebView::SieveEditorWebView(QWidget *parent)
: QWebView(parent)
{
}
SieveEditorWebView::~SieveEditorWebView()
{
}
void SieveEditorWebView::contextMenuEvent(QContextMenuEvent *ev)
{
QMenu menu;
QAction *act = pageAction(QWebPage::Back);
if (act->isEnabled()) {
menu.addAction(act);
}
act = pageAction(QWebPage::Forward);
if (act->isEnabled()) {
menu.addAction(act);
}
if (!menu.actions().isEmpty()) {
QAction *separator = new QAction(&menu);
separator->setSeparator(true);
menu.addAction(separator);
}
act = pageAction(QWebPage::Copy);
if (act->isEnabled()) {
menu.addAction(act);
}
if (!menu.actions().isEmpty()) {
QAction *separator = new QAction(&menu);
separator->setSeparator(true);
menu.addAction(separator);
}
act = pageAction(QWebPage::Reload);
if (act->isEnabled()) {
menu.addAction(act);
}
act = pageAction(QWebPage::SelectAll);
if (act->isEnabled()) {
menu.addAction(act);
}
act = pageAction(QWebPage::CopyLinkToClipboard);
if (act->isEnabled()) {
menu.addAction(act);
}
menu.exec(ev->globalPos());
}
/*
Copyright (c) 2014-2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SIEVEEDITORWEBVIEW_H
#define SIEVEEDITORWEBVIEW_H
#include <QWebView>
namespace KSieveUi
{
class SieveEditorWebView : public QWebView
{
Q_OBJECT
public:
explicit SieveEditorWebView(QWidget *parent = Q_NULLPTR);
~SieveEditorWebView();
protected:
void contextMenuEvent(QContextMenuEvent *ev) Q_DECL_OVERRIDE;
};
}
#endif // SIEVEEDITORWEBVIEW_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment