KTextAddons

bergamotmarianinterface.h
1/*
2 SPDX-FileCopyrightText: 2023-2025 Laurent Montel <montel@kde.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 <QObject>
14#include <QString>
15#include <condition_variable>
16#include <memory>
17#include <mutex>
18#include <thread>
19struct ModelDescription;
20struct TranslationInput;
21
22class LIBBERGAMOT_EXPORT BergamotMarianInterface : public QObject
23{
24 Q_OBJECT
25public:
26 explicit BergamotMarianInterface(QObject *parent = nullptr);
27 ~BergamotMarianInterface() override;
28
29 void translate(const QString &str);
30 [[nodiscard]] QString model() const;
31
32 void setModel(const QString &pathModelDir, const BergamotEngineUtils::SettingsInfo &settings);
33
35 void translationReady(Translation translation);
36 void pendingChanged(bool isBusy); // Disables issuing another translation while we are busy.
37 void errorText(const QString &message);
38
39private:
40 std::unique_ptr<TranslationInput> mPendingInput;
41 std::unique_ptr<ModelDescription> mPendingModel;
42
43 std::mutex mMutex;
44 std::condition_variable mConditionVariable;
45
46 std::thread mWorke;
47 QString mModelString;
48 bool mPendingShutdown = false;
49};
Wrapper around a translation response from the bergamot service.
Definition translation.h:26
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 3 2025 11:46:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.