File indexing completed on 2024-11-24 04:16:56

0001 /*
0002   SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <TextTranslator/TranslatorEnginePlugin>
0010 namespace QKeychain
0011 {
0012 class Job;
0013 }
0014 class LibreTranslateEnginePlugin : public TextTranslator::TranslatorEnginePlugin
0015 {
0016     Q_OBJECT
0017 public:
0018     explicit LibreTranslateEnginePlugin(QObject *parent = nullptr);
0019     ~LibreTranslateEnginePlugin() override;
0020 
0021     void translate() override;
0022 
0023     void slotConfigureChanged();
0024 
0025 private:
0026     void loadSettings();
0027     void parseTranslation(QNetworkReply *reply);
0028     void slotApiKeyRead(QKeychain::Job *baseJob);
0029     void translateText();
0030     QString mServerUrl;
0031     QString mResult;
0032     QString mApiKey;
0033     bool mRequiredApiKey = false;
0034 };