Libksieve

sievescriptdebuggertextedit.cpp
1 /*
2  SPDX-FileCopyrightText: 2015-2021 Laurent Montel <[email protected]>
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 
14 using namespace KSieveUi;
15 
16 SieveScriptDebuggerTextEdit::SieveScriptDebuggerTextEdit(QWidget *parent)
17  : KSieveUi::SieveTextEdit(parent)
18 {
19  setWordWrapMode(QTextOption::WordWrap);
20 }
21 
22 SieveScriptDebuggerTextEdit::~SieveScriptDebuggerTextEdit()
23 {
24 }
25 
26 void SieveScriptDebuggerTextEdit::addExtraMenuEntry(QMenu *menu, QPoint pos)
27 {
28  auto separator = new QAction(menu);
29  separator->setSeparator(true);
30  menu->addAction(separator);
31 
32  auto addDebugAction = new QAction(i18n("Add debug here"), menu);
33  connect(addDebugAction, &QAction::triggered, this, &SieveScriptDebuggerTextEdit::slotAddDebug);
34  menu->addAction(addDebugAction);
35 
36  KSieveUi::SieveTextEdit::addExtraMenuEntry(menu, pos);
37 }
38 
39 void SieveScriptDebuggerTextEdit::slotAddDebug()
40 {
41  QTextCursor cursor(textCursor());
42  cursor.insertText(QStringLiteral("debug_log \"DEBUG\";\n"));
43  if (!document()->toPlainText().contains(QLatin1String("vnd.dovecot.debug"))) {
44  cursor.movePosition(QTextCursor::Start);
45  cursor.insertText(QStringLiteral("require \"vnd.dovecot.debug\";\n"));
46  }
47 }
void triggered(bool checked)
QAction * addAction(const QString &text)
The SieveTextEdit class.
Definition: sievetextedit.h:20
QString i18n(const char *text, const TYPE &arg...)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 11 2021 23:09:37 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.