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

0001 /*
0002   SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "bergamotengineutils.h"
0010 
0011 #include <TextTranslator/TranslatorEngineClient>
0012 
0013 class BergamotEngineClient : public TextTranslator::TranslatorEngineClient
0014 {
0015     Q_OBJECT
0016     Q_PLUGIN_METADATA(IID "org.kde.Translator.bergamot")
0017     Q_INTERFACES(TextTranslator::TranslatorEngineClient)
0018 public:
0019     explicit BergamotEngineClient(QObject *parent = nullptr);
0020     ~BergamotEngineClient() override;
0021 
0022     [[nodiscard]] QString name() const override;
0023     [[nodiscard]] QString translatedName() const override;
0024     [[nodiscard]] TextTranslator::TranslatorEnginePlugin *createTranslator() override;
0025     [[nodiscard]] QMap<TextTranslator::TranslatorUtil::Language, QString> supportedFromLanguages() override;
0026     [[nodiscard]] QMap<TextTranslator::TranslatorUtil::Language, QString> supportedToLanguages() override;
0027 
0028     [[nodiscard]] bool hasConfigurationDialog() const override;
0029 
0030     [[nodiscard]] bool showConfigureDialog(QWidget *parentWidget) override;
0031 
0032     [[nodiscard]] bool hasInvertSupport() const override;
0033 
0034     void generateToListFromCurrentToLanguage(const QString &languageCode) override;
0035 
0036     [[nodiscard]] TextTranslator::TranslatorEngineClient::EngineType engineType() const override;
0037 
0038     void updateListLanguages() override;
0039 
0040 protected:
0041     [[nodiscard]] bool isSupported(TextTranslator::TranslatorUtil::Language lang) const override;
0042 
0043 private:
0044     void updateInstalledLanguage();
0045     void updateFromLanguageList();
0046     void updateToLanguageList();
0047     QMap<TextTranslator::TranslatorUtil::Language, QString> mToLanguages;
0048     QVector<BergamotEngineUtils::LanguageInstalled> mLanguageInstalled;
0049     QString mLanguageCode;
0050 };