feat: translate subtitles with an OpenAI-compatible LLM

This commit is contained in:
tri committed 2026-10-27 22:43:03 +07:00
1 parent 48cac86d60
commit 4665bf632a
21 files changed
+1877 -5

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
#pragma once
#include <QCoroTask>
#include <QObject>
#include <QtQml/qqmlregistration.h>
// Keeps the translation API key in the system keychain (KWallet / Secret Service)
// instead of the plain-text config file.
class ApiKeyStore : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
Q_PROPERTY(bool hasKey READ hasKey NOTIFY hasKeyChanged)
Q_PROPERTY(QString error READ error NOTIFY errorChanged)
public:
struct ReadResult {
QString key;
QString error;
};
explicit ApiKeyStore(QObject *parent = nullptr);
bool hasKey() const;
QString error() const;
// Stores \a key, or removes the stored key when it is empty.
Q_INVOKABLE void setKey(const QString &key);
// An empty key without error means none is stored.
static QCoro::Task<ReadResult> readKey();
Q_SIGNALS:
void hasKeyChanged();
void errorChanged();
private:
QCoro::Task<> refresh();
QCoro::Task<> store(QString key);
void setHasKey(bool hasKey);
void setError(const QString &error);
bool m_hasKey = false;
QString m_error;
};