Libksieve

sievescriptdebuggertextedit.cpp
1/*
2 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "sievescriptdebuggertextedit.h"
8
9#include <KLocalizedString>
10
11#include <QAction>
12#include <QMenu>
13
14using namespace KSieveUi;
15
16SieveScriptDebuggerTextEdit::SieveScriptDebuggerTextEdit(QWidget *parent)
17 : KSieveUi::SieveTextEdit(parent)
18{
19 setWordWrapMode(QTextOption::WordWrap);
20}
21
22SieveScriptDebuggerTextEdit::~SieveScriptDebuggerTextEdit() = default;
23
24void SieveScriptDebuggerTextEdit::addExtraMenuEntry(QMenu *menu, QPoint pos)
25{
26 auto separator = new QAction(menu);
27 separator->setSeparator(true);
28 menu->addAction(separator);
29
30 auto addDebugAction = new QAction(i18nc("@action", "Add debug here"), menu);
31 connect(addDebugAction, &QAction::triggered, this, &SieveScriptDebuggerTextEdit::slotAddDebug);
32 menu->addAction(addDebugAction);
33
34 KSieveUi::SieveTextEdit::addExtraMenuEntry(menu, pos);
35}
36
37void SieveScriptDebuggerTextEdit::slotAddDebug()
38{
40 cursor.insertText(QStringLiteral("debug_log \"DEBUG\";\n"));
41 if (!document()->toPlainText().contains(QLatin1StringView("vnd.dovecot.debug"))) {
42 cursor.movePosition(QTextCursor::Start);
43 cursor.insertText(QStringLiteral("require \"vnd.dovecot.debug\";\n"));
44 }
45}
46
47#include "moc_sievescriptdebuggertextedit.cpp"
The SieveTextEdit class.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void triggered(bool checked)
QAction * addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QTextDocument * document() const const
QTextCursor textCursor() const const
QString toPlainText() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.