summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-19 08:01:13 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-19 08:01:13 (GMT)
commit91b27db9063f5565048fc71b5efb9aac58163a0a (patch)
treecaf082f7df7981c925612187486e73aac8ce9766
parent2847f399e9adf6692db16334e0ea82a0963b591b (diff)
Fix crash + activate theme. Repository instance must be keep alive.
Thanks Volker for helping me. Now we can see highlighting here :)
-rw-r--r--messageviewer/src/widgets/mailsourcewebengineviewer.cpp17
-rw-r--r--messageviewer/src/widgets/mailsourcewebengineviewer.h9
2 files changed, 15 insertions, 11 deletions
diff --git a/messageviewer/src/widgets/mailsourcewebengineviewer.cpp b/messageviewer/src/widgets/mailsourcewebengineviewer.cpp
index e4382e0..e216b6e 100644
--- a/messageviewer/src/widgets/mailsourcewebengineviewer.cpp
+++ b/messageviewer/src/widgets/mailsourcewebengineviewer.cpp
@@ -18,7 +18,7 @@
*/
#include "mailsourcewebengineviewer.h"
-#include "config-messageviewer.h"
+
using namespace MessageViewer;
#include "mailsourceviewtextbrowserwidget.h"
@@ -28,7 +28,6 @@ using namespace MessageViewer;
#include "kpimtextedit/slidecontainer.h"
#ifdef KDEPIM_KF5SYNTAXHIGHLIGHTING_SUPPORT
-#include <SyntaxHighlighting/Repository>
#include <SyntaxHighlighting/SyntaxHighlighter>
#include <SyntaxHighlighting/Definition>
#include <SyntaxHighlighting/Theme>
@@ -70,23 +69,19 @@ 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"));
+ def = mRepo.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->setTheme((mHtmlBrowser->textBrowser()->palette().color(QPalette::Base).lightness() < 128)
+ ? mRepo.theme(QLatin1String("Breeze Dark"))
+ : mRepo.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
diff --git a/messageviewer/src/widgets/mailsourcewebengineviewer.h b/messageviewer/src/widgets/mailsourcewebengineviewer.h
index 69c2e1b..b2689ea 100644
--- a/messageviewer/src/widgets/mailsourcewebengineviewer.h
+++ b/messageviewer/src/widgets/mailsourcewebengineviewer.h
@@ -21,8 +21,14 @@
#define MAILSOURCEWEBENGINEVIEWER_H
#include <QDialog>
+#include "config-messageviewer.h"
class QTabWidget;
class QWebEnginePage;
+
+#ifdef KDEPIM_KF5SYNTAXHIGHLIGHTING_SUPPORT
+#include <SyntaxHighlighting/Repository>
+#endif
+
namespace MessageViewer
{
class FindBarSourceView;
@@ -44,6 +50,9 @@ private:
QTabWidget *mTabWidget;
MailSourceViewTextBrowserWidget *mHtmlBrowser;
#endif
+#ifdef KDEPIM_KF5SYNTAXHIGHLIGHTING_SUPPORT
+ SyntaxHighlighting::Repository mRepo;
+#endif
};
}
#endif // MAILSOURCEWEBENGINEVIEWER_H