KTextAddons

managermodeltranslator.h
1/*
2 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6#pragma once
7#include "libbergamot_export.h"
8#include "translator.h"
9#include <QObject>
10
11class LIBBERGAMOT_EXPORT ManagerModelTranslator : public QObject
12{
13 Q_OBJECT
14public:
15 struct ProgressInfo {
16 QString languageName;
17 qint64 bytesReceived = -1;
18 qint64 bytesTotal = -1;
19 };
20 explicit ManagerModelTranslator(QObject *parent = nullptr);
21 ~ManagerModelTranslator() override;
22
23 static ManagerModelTranslator *self();
24
25 void downloadListModels();
26
27 [[nodiscard]] QVector<Translator> translators() const;
28 void setTranslators(const QVector<Translator> &newTranslators);
29
30 void loadModelList(const QString &fileName);
31
32 void downloadLanguage(const QString &url, const QString &checkSum);
33 [[nodiscard]] bool needDownloadModelList() const;
35 void errorText(const QString &str);
36 void progress(const ManagerModelTranslator::ProgressInfo &info);
37 void extractDone();
38 void downLoadModelListDone();
39
40private:
41 LIBBERGAMOT_NO_EXPORT void parseListModel(const QJsonObject &obj);
42 QVector<Translator> mTranslators;
43};
44Q_DECLARE_TYPEINFO(ManagerModelTranslator::ProgressInfo, Q_MOVABLE_TYPE);
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:29:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.