Libksieve

sievescriptdebuggerresulteditor.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 "sievescriptdebuggerresulteditor.h"
8 #include <KLocalizedString>
9 #include <KStandardAction>
10 #include <PimCommon/PimUtil>
11 #include <QAction>
12 #include <QMenu>
13 
14 using namespace KSieveUi;
15 
16 SieveScriptDebuggerResultEditor::SieveScriptDebuggerResultEditor(QWidget *parent)
17  : KPIMTextEdit::PlainTextEditor(parent)
18 {
19 }
20 
21 SieveScriptDebuggerResultEditor::~SieveScriptDebuggerResultEditor()
22 {
23 }
24 
25 void SieveScriptDebuggerResultEditor::addExtraMenuEntry(QMenu *menu, QPoint pos)
26 {
27  KPIMTextEdit::PlainTextEditor::addExtraMenuEntry(menu, pos);
28  if (isReadOnly() && !document()->isEmpty()) {
29  auto clearAction = new QAction(i18n("Clear"), menu);
30  connect(clearAction, &QAction::triggered, this, &SieveScriptDebuggerResultEditor::slotClear);
31  menu->addAction(clearAction);
32  menu->addSeparator();
33  QAction *saveAsAction = KStandardAction::saveAs(this, &SieveScriptDebuggerResultEditor::slotSaveAs, this);
34  menu->addAction(saveAsAction);
35  }
36 }
37 
38 void SieveScriptDebuggerResultEditor::slotSaveAs()
39 {
40  const QString filter = i18n("Text Files (*.txt);;All Files (*)");
41  PimCommon::Util::saveTextAs(toPlainText(), filter, this);
42 }
43 
44 void SieveScriptDebuggerResultEditor::slotClear()
45 {
46  clear();
47 }
void triggered(bool checked)
QAction * saveAs(const QObject *recvr, const char *slot, QObject *parent)
QAction * addAction(const QString &text)
QAction * addSeparator()
QFuture< void > filter(Sequence &sequence, KeepFunctor filterFunction)
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 Fri Apr 16 2021 23:09:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.