feat(translate): add per-series glossary with auto extraction

This commit was merged in pull request #2.
This commit is contained in:
tri committed 2026-11-07 13:28:32 +07:00
1 parent 18ba92a6e3
commit 9e55dba687
14 files changed
+380 -12

No files matched your search

+10
View File
@@ -2,6 +2,7 @@
#include "llmclient.h"
#include "subtitleextractor.h"
#include "glossarystore.h"
#include <QCoroTask>
@@ -31,6 +32,8 @@ class TranslationService : public QObject
Q_PROPERTY(QStringList availableModels READ availableModels NOTIFY availableModelsChanged)
Q_PROPERTY(QVariantList translationPresets READ translationPresets CONSTANT)
Q_PROPERTY(bool fetchingModels READ isFetchingModels NOTIFY fetchingModelsChanged)
Q_PROPERTY(QVariantList glossaryEntries READ glossaryEntries NOTIFY glossaryChanged)
Q_PROPERTY(QString glossaryDirectory READ glossaryDirectory NOTIFY glossaryChanged)
public:
explicit TranslationService(QObject *parent = nullptr);
@@ -43,6 +46,8 @@ public:
QStringList availableModels() const;
QVariantList translationPresets() const;
bool isFetchingModels() const;
QVariantList glossaryEntries() const;
QString glossaryDirectory() const;
// \a track is an entry of MpvItem::subtitleTracks.
Q_INVOKABLE void translate(const QUrl &videoUrl, const QVariantMap &track, const QString &mediaTitle);
@@ -50,6 +55,9 @@ public:
// Asks the API configured in the settings for its models.
Q_INVOKABLE void fetchModels();
Q_INVOKABLE void clearError();
Q_INVOKABLE void loadGlossary(const QUrl &videoUrl);
Q_INVOKABLE void saveGlossary(const QVariantList &entries);
Q_INVOKABLE void clearGlossary();
Q_SIGNALS:
void busyChanged();
@@ -58,6 +66,7 @@ Q_SIGNALS:
void errorTextChanged();
void availableModelsChanged();
void fetchingModelsChanged();
void glossaryChanged();
void translated(const QUrl &subtitleUrl, bool fromCache);
private:
@@ -91,4 +100,5 @@ private:
QString m_errorText;
QStringList m_availableModels;
bool m_fetchingModels = false;
GlossaryStore::Glossary m_glossary;
};