Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 65c12bc1 authored by Volker Krause's avatar Volker Krause

Adapt to KPimTextEdit changes

Summary:
This now gives us a KF5::SyntaxHighlighting-based main editor, and thus
for example dark theme support, more precise spell checking areas and
proper style merging between highlighting and spellchecking.

Reviewers: #kde_pim, mlaurent

Reviewed By: #kde_pim, mlaurent

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D7673
parent 022cca27
......@@ -33,7 +33,7 @@ set(QT_REQUIRED_VERSION "5.8.0")
set(KMIME_LIB_VERSION "5.6.40")
set(IDENTITYMANAGEMENT_LIB_VERSION "5.6.40")
set(KMAILTRANSPORT_LIB_VERSION "5.6.40")
set(KPIMTEXTEDIT_LIB_VERSION "5.6.40")
set(KPIMTEXTEDIT_LIB_VERSION "5.6.41")
set(LIBKDEPIM_LIB_VERSION "5.6.40")
set(PIMCOMMON_LIB_VERSION "5.6.41")
set(KIMAP_LIB_VERSION "5.6.40")
......
......@@ -67,7 +67,6 @@ set(ksieveui_editor_LIB_SRCS
editor/sieveeditorutil.cpp
editor/sieveeditormenubar.cpp
editor/sievetexteditorspellcheckdecorator.cpp
editor/sievesyntaxspellcheckinghighlighter.cpp
editor/sievetexteditwidget.cpp
)
......
/*
Copyright (c) 2015-2017 Laurent Montel <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 "sievesyntaxspellcheckinghighlighter.h"
#include "sievetextedit.h"
using namespace KSieveUi;
SieveSyntaxSpellCheckingHighlighter::SieveSyntaxSpellCheckingHighlighter(SieveTextEdit *plainText, const QColor &misspelledColor)
: KPIMTextEdit::PlainTextSyntaxSpellCheckingHighlighter(plainText, misspelledColor)
{
}
SieveSyntaxSpellCheckingHighlighter::~SieveSyntaxSpellCheckingHighlighter()
{
}
bool SieveSyntaxSpellCheckingHighlighter::spellCheckBlock(const QString &text)
{
return text.startsWith(QLatin1Char('#'));
}
/*
Copyright (c) 2015-2017 Laurent Montel <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 SIEVESYNTAXSPELLCHECKINGHIGHLIGHTER_H
#define SIEVESYNTAXSPELLCHECKINGHIGHLIGHTER_H
#include <kpimtextedit/plaintextsyntaxspellcheckinghighlighter.h>
namespace KSieveUi {
class SieveTextEdit;
class SieveSyntaxSpellCheckingHighlighter : public KPIMTextEdit::PlainTextSyntaxSpellCheckingHighlighter
{
Q_OBJECT
public:
explicit SieveSyntaxSpellCheckingHighlighter(SieveTextEdit *plainText, const QColor &misspelledColor = Qt::red);
~SieveSyntaxSpellCheckingHighlighter();
protected:
bool spellCheckBlock(const QString &text) override;
};
}
#endif // SIEVESYNTAXSPELLCHECKINGHIGHLIGHTER_H
......@@ -16,17 +16,22 @@
* Boston, MA 02110-1301, USA.
*/
#include "sievesyntaxspellcheckinghighlighter.h"
#include "sievetextedit.h"
#include "editor/sievelinenumberarea.h"
#include "editor/sieveeditorutil.h"
#include "KPIMTextEdit/EditorUtil"
#include "editor/sievetexteditorspellcheckdecorator.h"
#include "kpimtextedit/plaintextsyntaxspellcheckinghighlighter.h"
#include <KPIMTextEdit/PlainTextSyntaxSpellCheckingHighlighter>
#include <KPIMTextEdit/EditorUtil>
#include <KPIMTextEdit/TextEditorCompleter>
#include <KLocalizedString>
#include <KSyntaxHighlighting/Definition>
#include <KSyntaxHighlighting/Repository>
#include <KSyntaxHighlighting/Theme>
#include <QAction>
#include <QIcon>
#include <QAbstractItemView>
#include <QCompleter>
#include <QStringListModel>
......@@ -36,9 +41,6 @@
#include <QMenu>
#include <QFontDatabase>
#include <KPIMTextEdit/SyntaxHighlighterBase>
#include <KPIMTextEdit/TextEditorCompleter>
using namespace KSieveUi;
class KSieveUi::SieveTextEditPrivate
......@@ -48,9 +50,9 @@ public:
{
}
PimCommon::SieveSyntaxHighlighterRules mSieveHighliterRules;
SieveLineNumberArea *m_sieveLineNumberArea = nullptr;
KPIMTextEdit::TextEditorCompleter *mTextEditorCompleter = nullptr;
KSyntaxHighlighting::Repository mSyntaxRepo;
bool mShowHelpMenu = true;
};
......@@ -83,7 +85,7 @@ SieveTextEdit::~SieveTextEdit()
void SieveTextEdit::updateHighLighter()
{
KSieveUi::SieveSyntaxSpellCheckingHighlighter *hlighter = dynamic_cast<KSieveUi::SieveSyntaxSpellCheckingHighlighter *>(highlighter());
auto hlighter = dynamic_cast<KPIMTextEdit::PlainTextSyntaxSpellCheckingHighlighter*>(highlighter());
if (hlighter) {
hlighter->toggleSpellHighlighting(checkSpellingEnabled());
}
......@@ -96,10 +98,13 @@ void SieveTextEdit::clearDecorator()
void SieveTextEdit::createHighlighter()
{
KSieveUi::SieveSyntaxSpellCheckingHighlighter *highlighter = new KSieveUi::SieveSyntaxSpellCheckingHighlighter(this);
auto highlighter = new KPIMTextEdit::PlainTextSyntaxSpellCheckingHighlighter(this);
highlighter->toggleSpellHighlighting(checkSpellingEnabled());
highlighter->setCurrentLanguage(spellCheckingLanguage());
highlighter->setSyntaxHighlighterRules(d->mSieveHighliterRules.rules());
highlighter->setDefinition(d->mSyntaxRepo.definitionForName(QStringLiteral("Sieve")));
highlighter->setTheme((palette().color(QPalette::Base).lightness() < 128)
? d->mSyntaxRepo.defaultTheme(KSyntaxHighlighting::Repository::DarkTheme)
: d->mSyntaxRepo.defaultTheme(KSyntaxHighlighting::Repository::LightTheme));
setHighlighter(highlighter);
}
......@@ -273,12 +278,6 @@ void SieveTextEdit::keyPressEvent(QKeyEvent *e)
void SieveTextEdit::setSieveCapabilities(const QStringList &capabilities)
{
d->mSieveHighliterRules.addCapabilities(capabilities);
KPIMTextEdit::PlainTextSyntaxSpellCheckingHighlighter *hlighter = dynamic_cast<KPIMTextEdit::PlainTextSyntaxSpellCheckingHighlighter *>(highlighter());
if (hlighter) {
hlighter->setSyntaxHighlighterRules(d->mSieveHighliterRules.rules());
}
setCompleterList(completerList() + capabilities);
}
......
......@@ -23,12 +23,7 @@
#include "kpimtextedit/plaintexteditor.h"
#include <PimCommon/SieveSyntaxHighlighterRules>
class QMenu;
namespace PimCommon {
class SieveSyntaxHighlighterRules;
}
namespace KSieveUi {
class SieveTextEditPrivate;
class KSIEVEUI_EXPORT SieveTextEdit : public KPIMTextEdit::PlainTextEditor
......
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