Commit f62e7029 authored by Laurent Montel's avatar Laurent Montel 😁

GIT_SILENT: we depend against qt5.7 now. Clean up

parent 20cfe671
......@@ -17,7 +17,7 @@ set(KF5_VERSION "5.32.0")
set(MESSAGELIB_LIB_VERSION ${PIM_VERSION})
set(AKONADIMIME_LIB_VERSION "5.5.40")
set(QT_REQUIRED_VERSION "5.6.0")
set(QT_REQUIRED_VERSION "5.7.0")
set(AKONADI_VERSION "5.5.40")
set(GRANTLEETHEME_LIB_VERSION "5.5.40")
......
......@@ -22,7 +22,7 @@
#include "attachmentcontrollerbase.h"
#include "helper/helper_p.h"
#include <MessageComposer/AttachmentModel>
#include "MessageComposer/AttachmentJob"
......
......@@ -18,7 +18,7 @@
*/
#include "attachmentmodel.h"
#include "helper/helper_p.h"
#include <QMimeData>
#include <QUrl>
......
......@@ -20,7 +20,7 @@
*/
#include "composer.h"
#include "helper_p.h"
#include "job/attachmentjob.h"
#include "part/globalpart.h"
......
/*
Copyright (c) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef _HELPER_H
#define _HELPER_H
#include <qglobal.h>
#if QT_VERSION < QT_VERSION_CHECK(5,7,0)
namespace QtPrivate
{
template <typename T> struct QAddConst {
typedef const T Type;
};
}
// this adds const to non-const objects (like std::as_const)
template <typename T>
Q_DECL_CONSTEXPR typename QtPrivate::QAddConst<T>::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
// prevent rvalue arguments:
template <typename T>
void qAsConst(const T &&) Q_DECL_EQ_DELETE;
#endif
#endif
......@@ -24,7 +24,7 @@
#include "messagefactoryforwardjob.h"
#include "messagefactoryreplyjob.h"
#include "MessageComposer/Util"
#include "helper/helper_p.h"
#include <AkonadiCore/item.h>
#ifndef QT_NO_CURSOR
......
......@@ -46,11 +46,9 @@ void MessageFactoryReplyJob::start()
parser->setIdentityManager(mIdentityManager);
parser->setCharsets(MessageComposerSettings::self()->preferredCharsets());
parser->setWordWrap(MessageComposerSettings::wordWrap(), MessageComposerSettings::lineWrapWidth());
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 1)
if (MessageComposer::MessageComposerSettings::quoteSelectionOnly()) {
parser->setSelection(mSelection);
}
#endif
parser->setAllowDecryption(true);
if (!mTemplate.isEmpty()) {
parser->process(mTemplate, mOrigMsg);
......
......@@ -21,7 +21,7 @@
*/
#include "aliasesexpandjob.h"
#include "helper/helper_p.h"
#include "distributionlistexpandjob.h"
#include <Akonadi/Contact/ContactSearchJob>
......
......@@ -22,7 +22,7 @@
*/
#include "job/emailaddressresolvejob.h"
#include "helper/helper_p.h"
#include "aliasesexpandjob.h"
#include "settings/messagecomposersettings.h"
......
......@@ -19,7 +19,7 @@
#include "job/multipartjob.h"
#include "contentjobbase_p.h"
#include "helper/helper_p.h"
#include "messagecomposer_debug.h"
......
......@@ -20,7 +20,7 @@
*/
#include "distributionlistdialog.h"
#include "helper/helper_p.h"
#include <AkonadiWidgets/collectiondialog.h>
#include <Akonadi/Contact/ContactGroupSearchJob>
#include <Akonadi/Contact/ContactSearchJob>
......
......@@ -23,7 +23,7 @@
#include "utils/util.h"
#include "util_p.h"
#include "helper/helper_p.h"
#include "composer/composer.h"
#include "job/singlepartjob.h"
......
......@@ -20,7 +20,7 @@
#include "core/filter.h"
#include "core/messageitem.h"
#include "helper_p.h"
#include <AkonadiSearch/PIM/emailquery.h>
#include <AkonadiSearch/PIM/resultiterator.h>
......
......@@ -19,7 +19,7 @@
#include "searchcollectionindexingwarning.h"
#include "messagelist_debug.h"
#include "helper_p.h"
#include <AkonadiCore/persistentsearchattribute.h>
#include <AkonadiCore/collectionfetchjob.h>
......
......@@ -16,7 +16,7 @@
*/
#include "searchlinestatus.h"
#include "helper_p.h"
#include <KLocalizedString>
#include <QAction>
#include <QStandardPaths>
......
/*
Copyright (c) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef _HELPER_H
#define _HELPER_H
#include <qglobal.h>
#if QT_VERSION < QT_VERSION_CHECK(5,7,0)
namespace QtPrivate
{
template <typename T> struct QAddConst {
typedef const T Type;
};
}
// this adds const to non-const objects (like std::as_const)
template <typename T>
Q_DECL_CONSTEXPR typename QtPrivate::QAddConst<T>::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
// prevent rvalue arguments:
template <typename T>
void qAsConst(const T &&) Q_DECL_EQ_DELETE;
#endif
#endif
......@@ -17,7 +17,7 @@
*/
#include "pane.h"
#include "helper_p.h"
#include <KActionCollection>
#include <KActionMenu>
......
......@@ -18,7 +18,7 @@
*/
#include "aggregationcombobox.h"
#include "aggregationcombobox_p.h"
#include "helper_p.h"
#include "core/aggregation.h"
#include "core/manager.h"
......
......@@ -20,7 +20,7 @@
#include "utils/themecombobox.h"
#include "utils/themecombobox_p.h"
#include "helper_p.h"
#include "storagemodel.h"
#include "core/manager.h"
#include "core/theme.h"
......
......@@ -23,7 +23,7 @@
#include "settings/messageviewersettings.h"
#include "utils/iconnamecache.h"
#include "config-messageviewer.h"
#include "utils/helper_p.h"
#include <MessageCore/StringUtil>
......
......@@ -24,7 +24,7 @@
#include "kxface.h"
#include "header/headerstyle.h"
#include "utils/helper_p.h"
#include "utils/iconnamecache.h"
#include "settings/messageviewersettings.h"
......
......@@ -20,7 +20,7 @@
#include "headerstyle.h"
#include "headerstyleinterface.h"
#include "headerstyleplugin.h"
#include "utils/helper_p.h"
#include <KActionMenu>
#include <QAction>
#include <KToggleAction>
......
......@@ -8,8 +8,8 @@ set(webengineparthtmlwritertestdebug_SRCS)
ecm_qt_declare_logging_category(webengineparthtmlwritertestdebug_SRCS HEADER messageviewer_debug.h IDENTIFIER MESSAGEVIEWER_LOG CATEGORY_NAME org.kde.pim.messageviewer)
ecm_add_test(webengineparthtmlwritertest.cpp ../webengineembedpart.cpp ../webengineparthtmlwriter.cpp ${webengineparthtmlwritertestdebug_SRCS}
TEST_NAME webengineparthtmlwritertest
NAME_PREFIX "messageviewer-webengine-"
LINK_LIBRARIES Qt5::Test Qt5::Core KF5::MimeTreeParser KF5::MessageViewer KF5::WebEngineViewer
)
#ecm_add_test(webengineparthtmlwritertest.cpp ../webengineembedpart.cpp ../webengineparthtmlwriter.cpp ${webengineparthtmlwritertestdebug_SRCS}
# TEST_NAME webengineparthtmlwritertest
# NAME_PREFIX "messageviewer-webengine-"
# LINK_LIBRARIES Qt5::Test Qt5::Core KF5::MimeTreeParser KF5::MessageViewer KF5::WebEngineViewer
# )
......@@ -61,9 +61,6 @@ void WebEnginePartHtmlWriter::end()
insertExtraHead();
mExtraHead.clear();
}
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
mHtml = removeJscripts(mHtml);
#endif
mHtmlView->setHtml(mHtml, QUrl(QStringLiteral("file:///")));
mHtmlView->show();
mHtml.clear();
......@@ -74,35 +71,6 @@ void WebEnginePartHtmlWriter::end()
Q_EMIT finished();
}
QString WebEnginePartHtmlWriter::removeJscripts(QString str)
{
//Remove regular <script>...</script>
const QRegularExpression regScript(QStringLiteral("<script[^>]*>.*?</script\\s*>"), QRegularExpression::CaseInsensitiveOption);
str.remove(regScript);
//Remove string as <script src=http://.../>
const QRegularExpression regScript2(QStringLiteral("<script[^>]*/>"), QRegularExpression::CaseInsensitiveOption);
str.remove(regScript2);
//Multiline script
const QRegularExpression regScriptStart(QStringLiteral("<script[^>]*>"), QRegularExpression::CaseInsensitiveOption);
const QRegularExpression regScriptEnd(QStringLiteral("</script\\s*>"), QRegularExpression::CaseInsensitiveOption);
int indexStartScriptFound = -1;
int indexEndScriptFound = -1;
int scriptIndexPos = 0;
QRegularExpressionMatch matchScriptStart;
QRegularExpressionMatch matchScriptEnd;
while ((indexStartScriptFound = str.indexOf(regScriptStart, scriptIndexPos, &matchScriptStart)) != -1) {
indexEndScriptFound = str.indexOf(regScriptEnd, indexStartScriptFound + matchScriptStart.capturedLength(), &matchScriptEnd);
if (indexEndScriptFound != -1) {
str.remove(indexStartScriptFound, (indexEndScriptFound + matchScriptEnd.capturedLength() - indexStartScriptFound));
} else {
qCWarning(MESSAGEVIEWER_LOG) << "no end script tag";
break;
}
scriptIndexPos = indexStartScriptFound;
}
return str;
}
void WebEnginePartHtmlWriter::reset()
{
if (mState != Ended) {
......
......@@ -48,8 +48,6 @@ public:
void embedPart(const QByteArray &contentId, const QString &url) Q_DECL_OVERRIDE;
void extraHead(const QString &str) Q_DECL_OVERRIDE;
static QString removeJscripts(QString str);
Q_SIGNALS:
void finished();
......
......@@ -85,13 +85,9 @@ ScamDetectionWebEngine::~ScamDetectionWebEngine()
void ScamDetectionWebEngine::scanPage(QWebEnginePage *page)
{
if (MessageViewer::MessageViewerSettings::self()->scamDetectionEnabled()) {
#if QT_VERSION >= 0x050700
page->runJavaScript(WebEngineViewer::WebEngineScript::findAllAnchorsAndForms(),
WebEngineViewer::WebEngineManageScript::scriptWordId(),
invoke(this, &ScamDetectionWebEngine::handleScanPage));
#else
page->runJavaScript(WebEngineViewer::WebEngineScript::findAllAnchorsAndForms(), invoke(this, &ScamDetectionWebEngine::handleScanPage));
#endif
}
}
......
/*
Copyright (c) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef _HELPER_H
#define _HELPER_H
#include <qglobal.h>
#if QT_VERSION < QT_VERSION_CHECK(5,7,0)
namespace QtPrivate
{
template <typename T> struct QAddConst {
typedef const T Type;
};
}
// this adds const to non-const objects (like std::as_const)
template <typename T>
Q_DECL_CONSTEXPR typename QtPrivate::QAddConst<T>::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
// prevent rvalue arguments:
template <typename T>
void qAsConst(const T &&) Q_DECL_EQ_DELETE;
#endif
#endif
......@@ -44,7 +44,7 @@
#include "MessageCore/MessageCoreSettings"
#include "MessageCore/NodeHelper"
#include "MessageCore/StringUtil"
#include "utils/helper_p.h"
#include "PimCommon/RenameFileDialog"
......
......@@ -653,11 +653,7 @@ QList<QAction *> Viewer::interceptorUrlActions(const WebEngineViewer::WebHitTest
void Viewer::runJavaScript(const QString &code)
{
Q_D(Viewer);
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
d->mViewer->page()->runJavaScript(code, WebEngineViewer::WebEngineManageScript::scriptWordId());
#else
d->mViewer->page()->runJavaScript(code);
#endif
}
void Viewer::setPrintElementBackground(bool printElementBackground)
......
......@@ -22,7 +22,7 @@
//#define MESSAGEVIEWER_READER_HTML_DEBUG 1
#include "viewer_p.h"
#include "viewer.h"
#include "helper_p.h"
#include "messageviewer_debug.h"
#include "utils/mimetype.h"
#include "viewer/objecttreeemptysource.h"
......
......@@ -48,10 +48,8 @@ bool BlockExternalResourcesUrlInterceptor::interceptRequest(QWebEngineUrlRequest
resourceType == QWebEngineUrlRequestInfo::ResourceTypeSharedWorker ||
resourceType == QWebEngineUrlRequestInfo::ResourceTypeWorker ||
resourceType == QWebEngineUrlRequestInfo::ResourceTypeSubResource ||
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
resourceType == QWebEngineUrlRequestInfo::ResourceTypePluginResource ||
resourceType == QWebEngineUrlRequestInfo::ResourceTypeCspReport ||
#endif
resourceType == QWebEngineUrlRequestInfo::ResourceTypeUnknown) {
return true;
} else if (navigationType == QWebEngineUrlRequestInfo::NavigationTypeFormSubmitted) {
......
......@@ -43,11 +43,7 @@ MailWebEnginePage::~MailWebEnginePage()
void MailWebEnginePage::initialize()
{
profile()->setHttpCacheType(QWebEngineProfile::MemoryHttpCache);
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
#else
settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
#endif
settings()->setAttribute(QWebEngineSettings::PluginsEnabled, false);
settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, false);
settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, false);
......@@ -58,12 +54,10 @@ void MailWebEnginePage::initialize()
settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
settings()->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, false);
settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, false);
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
settings()->setAttribute(QWebEngineSettings::WebGLEnabled, false);
settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, false);
settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, false);
settings()->setAttribute(QWebEngineSettings::WebGLEnabled, false);
#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false);
......
......@@ -109,9 +109,7 @@ MailWebEngineView::MailWebEngineView(KActionCollection *ac, QWidget *parent)
d->mNetworkAccessManager->addInterceptor(blockExternalUrl);
setFocusPolicy(Qt::WheelFocus);
connect(d->mPageEngine, &MailWebEnginePage::urlClicked, this, &MailWebEngineView::openUrl);
#if QT_VERSION >= 0x050700
connect(page(), &QWebEnginePage::scrollPositionChanged, d->mWebViewAccessKey, &WebEngineViewer::WebEngineAccessKey::hideAccessKeys);
#endif
initializeScripts();
}
......@@ -289,13 +287,9 @@ void MailWebEngineView::hideAccessKeys()
void MailWebEngineView::isScrolledToBottom()
{
#if QT_VERSION >= 0x050700
page()->runJavaScript(WebEngineViewer::WebEngineScript::isScrolledToBottom(),
WebEngineViewer::WebEngineManageScript::scriptWordId(),
invoke(this, &MailWebEngineView::handleIsScrolledToBottom));
#else
page()->runJavaScript(WebEngineViewer::WebEngineScript::isScrolledToBottom(), invoke(this, &MailWebEngineView::handleIsScrolledToBottom));
#endif
}
void MailWebEngineView::setElementByIdVisible(const QString &id, bool visible)
......
......@@ -76,20 +76,12 @@ void TestMailWebEngine::slotOpenUrl(const QUrl &url)
void TestMailWebEngine::slotScrollDown()
{
#if QT_VERSION >= 0x050700
mTestWebEngine->page()->runJavaScript(WebEngineViewer::WebEngineScript::scrollDown(10), WebEngineViewer::WebEngineManageScript::scriptWordId());
#else
mTestWebEngine->page()->runJavaScript(WebEngineViewer::WebEngineScript::scrollDown(10));
#endif
}
void TestMailWebEngine::slotScrollUp()
{
#if QT_VERSION >= 0x050700
mTestWebEngine->page()->runJavaScript(WebEngineViewer::WebEngineScript::scrollUp(10), WebEngineViewer::WebEngineManageScript::scriptWordId());
#else
mTestWebEngine->page()->runJavaScript(WebEngineViewer::WebEngineScript::scrollUp(10));
#endif
}
void TestMailWebEngine::slotZoomDown()
......
......@@ -21,7 +21,7 @@
#include "viewerpluginmanager.h"
#include "viewerplugin.h"
#include "viewerplugininterface.h"
#include "utils/helper_p.h"
#include <QVector>
......
......@@ -22,7 +22,7 @@
#include "globalsettings_templateparser.h"
#include "ui_customtemplates_base.h"
#include "kpimtextedit/plaintexteditor.h"
#include "helper_p.h"
#include <KIconLoader>
#include <KLocalizedString>
......
/*
Copyright (c) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef _HELPER_H
#define _HELPER_H
#include <qglobal.h>
#if QT_VERSION < QT_VERSION_CHECK(5,7,0)
namespace QtPrivate
{
template <typename T> struct QAddConst {
typedef const T Type;
};
}
// this adds const to non-const objects (like std::as_const)
template <typename T>
Q_DECL_CONSTEXPR typename QtPrivate::QAddConst<T>::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
// prevent rvalue arguments:
template <typename T>
void qAsConst(const T &&) Q_DECL_EQ_DELETE;
#endif
#endif
......@@ -83,13 +83,9 @@ QString extractHeaderBodyScript()
void TemplateExtractHtmlElementWebEngineView::slotLoadFinished(bool success)
{
if (success) {
#if QT_VERSION >= 0x050700