KTextAddons

translatorengineplugin.h
1/*
2 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "texttranslator_export.h"
10#include <QNetworkReply>
11#include <QObject>
12#include <QString>
13#include <TextTranslator/TranslatorUtil>
14#include <memory>
15
16namespace TextTranslator
17{
18class TranslatorEnginePluginPrivate;
19class TEXTTRANSLATOR_EXPORT TranslatorEnginePlugin : public QObject
20{
21 Q_OBJECT
22public:
23 explicit TranslatorEnginePlugin(QObject *parent = nullptr);
24 ~TranslatorEnginePlugin() override;
25
26 virtual void translate() = 0;
27
28 [[nodiscard]] QString resultTranslate() const;
29 void setInputText(const QString &text);
30 void setFrom(const QString &language);
31 void setTo(const QString &language);
32 void setResult(const QString &result);
33 void setJsonDebug(const QString &debug);
34
35 [[nodiscard]] QString inputText() const;
36 [[nodiscard]] QString from() const;
37 [[nodiscard]] QString to() const;
38 [[nodiscard]] QString result() const;
39 [[nodiscard]] QString jsonDebug() const;
40
41 void clear();
42
43Q_SIGNALS:
44 void translateDone();
45 void translateFailed(const QString &errorMessage);
46 void languagesChanged();
47
48protected:
49 void appendResult(const QString &result);
50 void slotError(QNetworkReply::NetworkError error);
51 [[nodiscard]] bool verifyFromAndToLanguage();
52 [[nodiscard]] bool hasDebug() const;
53
54 [[nodiscard]] virtual QString languageCode(const QString &langStr);
55
56private:
57 std::unique_ptr<TranslatorEnginePluginPrivate> const d;
58};
59}
KGuiItem clear()
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.