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 DeeplEnginePlugin : public TextTranslator::TranslatorEnginePlugin 0015 { 0016 Q_OBJECT 0017 public: 0018 explicit DeeplEnginePlugin(QObject *parent = nullptr); 0019 ~DeeplEnginePlugin() override; 0020 0021 void translate() override; 0022 0023 void slotConfigureChanged(); 0024 0025 protected: 0026 [[nodiscard]] QString languageCode(const QString &langStr) override; 0027 0028 private: 0029 void loadSettings(); 0030 void translateText(); 0031 void parseTranslation(QNetworkReply *reply); 0032 void slotApiKeyRead(QKeychain::Job *baseJob); 0033 QString mServerUrl; 0034 QString mResult; 0035 // TODO load it ? kwallet ? 0036 QString mApiKey; 0037 bool mUseFreeLicense = false; 0038 };