Libksieve

sievescriptdebuggerresulteditor.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 "sievescriptdebuggerresulteditor.h"
8#include <KLocalizedString>
9#include <KStandardActions>
10#include <PimCommon/PimUtil>
11#include <QAction>
12#include <QMenu>
13
14using namespace KSieveUi;
15
16SieveScriptDebuggerResultEditor::SieveScriptDebuggerResultEditor(QWidget *parent)
17 : TextCustomEditor::PlainTextEditor(parent)
18{
19}
20
21SieveScriptDebuggerResultEditor::~SieveScriptDebuggerResultEditor() = default;
22
23void SieveScriptDebuggerResultEditor::addExtraMenuEntry(QMenu *menu, QPoint pos)
24{
25 TextCustomEditor::PlainTextEditor::addExtraMenuEntry(menu, pos);
26 if (isReadOnly() && !document()->isEmpty()) {
27 auto clearAction = new QAction(i18nc("@action", "Clear"), menu);
28 connect(clearAction, &QAction::triggered, this, &SieveScriptDebuggerResultEditor::slotClear);
29 menu->addAction(clearAction);
30 menu->addSeparator();
31 QAction *saveAsAction = KStandardActions::saveAs(this, &SieveScriptDebuggerResultEditor::slotSaveAs, this);
32 menu->addAction(saveAsAction);
33 }
34}
35
36void SieveScriptDebuggerResultEditor::slotSaveAs()
37{
38 const QString filter = i18n("Text Files (*.txt);;All Files (*)");
39 PimCommon::Util::saveTextAs(toPlainText(), filter, this);
40}
41
42void SieveScriptDebuggerResultEditor::slotClear()
43{
44 clear();
45}
46
47#include "moc_sievescriptdebuggerresulteditor.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
void triggered(bool checked)
QAction * addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut)
QAction * addSeparator()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QTextDocument * document() const const
bool isReadOnly() const const
QString toPlainText() const const
QFuture< void > filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.