File indexing completed on 2024-05-19 15:58:56

0001 /*
0002    SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 #include "libruqolacore_export.h"
0009 #include <QDebug>
0010 #include <QObject>
0011 class LIBRUQOLACORE_EXPORT TranslateTextJob : public QObject
0012 {
0013     Q_OBJECT
0014 public:
0015     struct LIBRUQOLACORE_EXPORT TranslateInfo {
0016         QString from;
0017         QString to;
0018         QString inputText;
0019         [[nodiscard]] bool isValid() const;
0020     };
0021     explicit TranslateTextJob(QObject *parent = nullptr);
0022     ~TranslateTextJob() override;
0023 
0024     void translate();
0025 
0026     [[nodiscard]] const TranslateInfo &info() const;
0027     void setInfo(const TranslateInfo &newInfo);
0028 
0029 Q_SIGNALS:
0030     void translateDone(const QString &translatedText);
0031     void translateFailed(const QString &errorMessage = QString());
0032 
0033 private:
0034     LIBRUQOLACORE_NO_EXPORT void initializeTranslateEngine();
0035     TranslateInfo mInfo;
0036 };
0037 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const TranslateTextJob::TranslateInfo &t);