KTextAddons

bergamotmarianinterface.h
1/*
2 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5
6 Based on translatelocally code
7*/
8
9#pragma once
10#include "bergamotengineutils.h"
11#include "libbergamot_export.h"
12#include "translation.h"
13#include <QList>
14#include <QObject>
15#include <QString>
16#include <condition_variable>
17#include <memory>
18#include <mutex>
19#include <thread>
20struct ModelDescription;
21struct TranslationInput;
22
23class LIBBERGAMOT_EXPORT BergamotMarianInterface : public QObject
24{
25 Q_OBJECT
26public:
27 explicit BergamotMarianInterface(QObject *parent = nullptr);
28 ~BergamotMarianInterface() override;
29
30 void translate(const QString &str);
31 [[nodiscard]] QString model() const;
32
33 void setModel(const QString &pathModelDir, const BergamotEngineUtils::SettingsInfo &settings);
34
36 void translationReady(Translation translation);
37 void pendingChanged(bool isBusy); // Disables issuing another translation while we are busy.
38 void errorText(const QString &message);
39
40private:
41 std::unique_ptr<TranslationInput> mPendingInput;
42 std::unique_ptr<ModelDescription> mPendingModel;
43
44 std::mutex mMutex;
45 std::condition_variable mConditionVariable;
46
47 std::thread mWorke;
48 QString mModelString;
49 bool mPendingShutdown = false;
50};
Wrapper around a translation response from the bergamot service.
Definition translation.h:27
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:51:28 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.