summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-19 06:01:43 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-19 06:01:43 (GMT)
commit2847f399e9adf6692db16334e0ea82a0963b591b (patch)
treefd8fe6a6d7cf7888bac49337a07033e366575623
parent48af0c033cc376beb3d26e15c8368d9a7fe6b8dd (diff)
Add code from syntax-highlighting but it crashs for the moment. I need to investigate it
-rw-r--r--messageviewer/src/CMakeLists.txt3
-rw-r--r--messageviewer/src/widgets/mailsourcewebengineviewer.cpp24
2 files changed, 27 insertions, 0 deletions
diff --git a/messageviewer/src/CMakeLists.txt b/messageviewer/src/CMakeLists.txt
index 1428375..20d5f7c 100644
--- a/messageviewer/src/CMakeLists.txt
+++ b/messageviewer/src/CMakeLists.txt
@@ -241,6 +241,9 @@ if (WIN32)
else()
target_link_libraries(KF5MessageViewer PUBLIC KF5::Gpgmepp-pthread)
endif()
+if (KDEPIM_KF5SYNTAXHIGHLIGHTING_SUPPORT)
+ target_link_libraries(KF5MessageViewer PRIVATE KF5::SyntaxHighlighting)
+endif()
set_target_properties(KF5MessageViewer PROPERTIES
VERSION ${MESSAGEVIEWER_VERSION_STRING}
diff --git a/messageviewer/src/widgets/mailsourcewebengineviewer.cpp b/messageviewer/src/widgets/mailsourcewebengineviewer.cpp
index 5d8df2a..e4382e0 100644
--- a/messageviewer/src/widgets/mailsourcewebengineviewer.cpp
+++ b/messageviewer/src/widgets/mailsourcewebengineviewer.cpp
@@ -26,6 +26,14 @@ using namespace MessageViewer;
#include "findbar/findbarsourceview.h"
#include <kpimtextedit/htmlhighlighter.h>
#include "kpimtextedit/slidecontainer.h"
+
+#ifdef KDEPIM_KF5SYNTAXHIGHLIGHTING_SUPPORT
+#include <SyntaxHighlighting/Repository>
+#include <SyntaxHighlighting/SyntaxHighlighter>
+#include <SyntaxHighlighting/Definition>
+#include <SyntaxHighlighting/Theme>
+#endif
+
#include "PimCommon/PimUtil"
#include <kiconloader.h>
#include <KLocalizedString>
@@ -62,7 +70,23 @@ MailSourceWebEngineViewer::MailSourceWebEngineViewer(QWidget *parent)
mHtmlBrowser = new MailSourceViewTextBrowserWidget(this);
mTabWidget->addTab(mHtmlBrowser, i18nc("Mail message as shown, in HTML format", "HTML Source"));
mTabWidget->setTabToolTip(1, i18n("HTML code for displaying the message to the user"));
+#if 0 //Disable for the moment.
+#ifdef KDEPIM_KF5SYNTAXHIGHLIGHTING_SUPPORT
+ SyntaxHighlighting::Repository repo;
+ SyntaxHighlighting::Definition def;
+ def = repo.definitionForName(QStringLiteral("HTML"));
+
+ SyntaxHighlighting::SyntaxHighlighter *hl = new SyntaxHighlighting::SyntaxHighlighter(mHtmlBrowser->textBrowser()->document());
+ hl->setTheme((palette().color(QPalette::Base).lightness() < 128)
+ ? repo.theme(QLatin1String("Breeze Dark"))
+ : repo.theme(QLatin1String("Default")));
+ hl->setDefinition(def);
+#else
new KPIMTextEdit::HtmlHighlighter(mHtmlBrowser->textBrowser()->document());
+#endif
+#else
+ new KPIMTextEdit::HtmlHighlighter(mHtmlBrowser->textBrowser()->document());
+#endif
mTabWidget->setCurrentIndex(0);
#else