KTextAddons

grammalecteresultjob.h
1/*
2 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "textgrammarcheck_export.h"
10#include <QObject>
11#include <QProcess>
12namespace TextGrammarCheck
13{
14class TEXTGRAMMARCHECK_EXPORT GrammalecteResultJob : public QObject
15{
16 Q_OBJECT
17public:
18 explicit GrammalecteResultJob(QObject *parent = nullptr);
19 ~GrammalecteResultJob() override;
20
21 enum class ErrorType : uint8_t {
22 NoError = 0,
23 TextIsEmpty = 1,
24 PythonPathMissing = 2,
25 GrammalecteMissing = 3,
26 PythonPathNotExist = 4,
27 GrammarlectCliNotExist = 5,
28 Unknown = 6,
29 };
30
31 void start();
32
33 [[nodiscard]] bool canStart();
34
35 [[nodiscard]] QString text() const;
36 void setText(const QString &text);
37
38 [[nodiscard]] QString pythonPath() const;
39 void setPythonPath(const QString &pythonPath);
40
41 [[nodiscard]] QString grammarlecteCliPath() const;
42 void setGrammarlecteCliPath(const QString &grammarlecteCliPath);
43
44 [[nodiscard]] QStringList arguments() const;
45 void setArguments(const QStringList &arguments);
46
47Q_SIGNALS:
48 void finished(const QString &result);
49 void error(GrammalecteResultJob::ErrorType type);
50
51private:
52 TEXTGRAMMARCHECK_NO_EXPORT void slotFinished(int exitCode, QProcess::ExitStatus exitStatus);
53 TEXTGRAMMARCHECK_NO_EXPORT void receivedStdErr();
54 TEXTGRAMMARCHECK_NO_EXPORT void receivedError();
55 TEXTGRAMMARCHECK_NO_EXPORT void receivedStandardOutput();
56 QStringList mArguments;
57 QString mResult;
58 QString mText;
59 QString mPythonPath;
60 QString mGrammarlecteCliPath;
61 QString mLastError;
62 GrammalecteResultJob::ErrorType mErrorType = ErrorType::NoError;
63 QProcess *mProcess = nullptr;
64};
65}
Q_SCRIPTABLE Q_NOREPLY void start()
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:02:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.