Commit 1292151e authored by Volker Krause's avatar Volker Krause

Port to KF5::SyntaxHighlighting

Summary:
Most importantly, this results in much better readability when using a
dark color scheme.

Reviewers: #kde_pim, mlaurent

Reviewed By: #kde_pim, mlaurent

Subscribers: mlaurent

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D7657
parent 5e602916
......@@ -57,6 +57,7 @@ find_package(KF5WidgetsAddons ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5WindowSystem ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5XmlGui ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5DBusAddons ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5SyntaxHighlighting ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED)
find_package(KF5AkonadiMime ${AKONADIMIME_LIB_VERSION} CONFIG REQUIRED)
......
......@@ -241,6 +241,7 @@ PRIVATE
KF5::IconThemes
KF5::Archive
KF5::ItemViews
KF5::SyntaxHighlighting
)
target_include_directories(KF5MailCommon INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/MailCommon/;${KDE_INSTALL_INCLUDEDIR_KF5}/mailcommon>")
target_include_directories(KF5MailCommon PUBLIC "$<BUILD_INTERFACE:${mailcommon_SOURCE_DIR}/src;${mailcommon_BINARY_DIR}/src;${mailcommon_SOURCE_DIR}/src/search>")
......
set(mailcommon_filter_test_LIBS Qt5::Test Qt5::Gui KF5::AkonadiCore KF5::AkonadiMime
KF5::LibkdepimAkonadi KF5::MailCommon KF5::PimCommon Phonon::phonon4qt5
KF5::KIOWidgets KF5::IconThemes KF5::TemplateParser
KF5::MailTransport KF5::I18n
KF5::MailTransport KF5::I18n KF5::SyntaxHighlighting
)
add_definitions(-DTEST_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}\")
......
......@@ -16,13 +16,14 @@
*/
#include "filterconverttosieveresultdialog.h"
#include "PimCommon/SieveSyntaxHighlighter"
#include "PimCommon/SieveSyntaxHighlighterUtil"
#include "kpimtextedit/plaintexteditor.h"
#include "kpimtextedit/plaintexteditorwidget.h"
#include <PimCommon/PimUtil>
#include <KLocalizedString>
#include <KSyntaxHighlighting/Definition>
#include <KSyntaxHighlighting/SyntaxHighlighter>
#include <KSyntaxHighlighting/Theme>
#include <QHBoxLayout>
......@@ -53,10 +54,11 @@ FilterConvertToSieveResultDialog::FilterConvertToSieveResultDialog(QWidget *pare
mEditor = new KPIMTextEdit::PlainTextEditorWidget;
mEditor->editor()->setSpellCheckingSupport(false);
mEditor->setObjectName(QStringLiteral("editor"));
PimCommon::SieveSyntaxHighlighter *syntaxHighlighter = new PimCommon::SieveSyntaxHighlighter(mEditor->editor()->document());
PimCommon::SieveSyntaxHighlighterUtil sieveHighlighterutil;
const QStringList capabilities = sieveHighlighterutil.fullCapabilities();
syntaxHighlighter->addCapabilities(capabilities);
auto syntaxHighlighter = new KSyntaxHighlighting::SyntaxHighlighter(mEditor->editor()->document());
syntaxHighlighter->setDefinition(mSyntaxRepo.definitionForName(QStringLiteral("Sieve")));
syntaxHighlighter->setTheme((palette().color(QPalette::Base).lightness() < 128)
? mSyntaxRepo.defaultTheme(KSyntaxHighlighting::Repository::DarkTheme)
: mSyntaxRepo.defaultTheme(KSyntaxHighlighting::Repository::LightTheme));
topLayout->addWidget(mEditor);
topLayout->addWidget(buttonBox);
......
......@@ -18,6 +18,7 @@
#ifndef FILTERCONVERTTOSIEVERESULTDIALOG_H
#define FILTERCONVERTTOSIEVERESULTDIALOG_H
#include <KSyntaxHighlighting/Repository>
#include <QDialog>
namespace KPIMTextEdit {
......@@ -41,6 +42,7 @@ private:
void readConfig();
void writeConfig();
KPIMTextEdit::PlainTextEditorWidget *mEditor = nullptr;
KSyntaxHighlighting::Repository mSyntaxRepo;
};
}
......
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