mutterkey
KDE-first push-to-talk transcription tool for KDE Plasma
Loading...
Searching...
No Matches
service.h
Go to the documentation of this file.
1#pragma once
2
4#include "clipboardwriter.h"
5#include "config.h"
6#include "hotkeymanager.h"
8
9#include <QClipboard>
10#include <QJsonObject>
11#include <QObject>
12#include <QThread>
13
28class MutterkeyService final : public QObject
29{
30 Q_OBJECT
31
32public:
40 explicit MutterkeyService(const AppConfig &config,
41 std::shared_ptr<const TranscriptionEngine> transcriptionEngine,
42 QClipboard *clipboard,
43 QObject *parent = nullptr);
44
49
50 Q_DISABLE_COPY_MOVE(MutterkeyService)
51
52
57 bool start(QString *errorMessage = nullptr);
58
62 void stop();
63
68 [[nodiscard]] QJsonObject diagnostics() const;
69
75 bool invokeShortcut(QString *errorMessage = nullptr);
76
77signals:
82 void transcriptionReady(const QString &text);
83
89
90private Q_SLOTS:
94 void onShortcutPressed();
95
99 void onShortcutReleased();
100
105 void onTranscriptionReady(const QString &text);
106
111 void onTranscriptionFailed(const RuntimeError &error);
112
113private:
119 bool startTranscriptionWorker(QString *errorMessage = nullptr);
120
124 void stopTranscriptionWorker();
125
130 void transcribeInBackground(Recording recording);
131
133 AppConfig m_config;
135 AudioRecorder m_audioRecorder;
137 std::shared_ptr<const TranscriptionEngine> m_transcriptionEngine;
139 ClipboardWriter m_clipboardWriter;
141 HotkeyManager m_hotkeyManager;
143 QThread m_transcriptionThread;
145 TranscriptionWorker *m_transcriptionWorker = nullptr;
147 bool m_running = false;
149 int m_recordingsStarted = 0;
151 int m_recordingsCompleted = 0;
153 int m_transcriptionsCompleted = 0;
154};
Audio capture primitives for push-to-talk recording.
Captures microphone audio into a Recording value object.
Copies transcription text to the clipboard.
Wraps KGlobalAccel registration for Mutterkey's push-to-talk shortcut.
Coordinates the daemon-mode push-to-talk workflow.
Definition service.h:29
MutterkeyService(const AppConfig &config, std::shared_ptr< const TranscriptionEngine > transcriptionEngine, QClipboard *clipboard, QObject *parent=nullptr)
Creates the service with a fixed runtime configuration.
bool start(QString *errorMessage=nullptr)
Starts the hotkey, worker thread, and optional backend warmup.
void transcriptionFailed(const RuntimeError &error)
Emitted when recording or transcription fails.
void stop()
Stops recording, hotkey registration, and background transcription.
QJsonObject diagnostics() const
Returns current service diagnostics for diagnose mode.
~MutterkeyService() override
Stops background work and joins the transcription thread.
bool invokeShortcut(QString *errorMessage=nullptr)
Invokes the registered shortcut action for diagnostics.
void transcriptionReady(const QString &text)
Emitted when a transcription result has been copied successfully.
Immutable engine configuration that creates backend sessions.
Thread-hosted wrapper around the configured transcription backend.
Clipboard integration with KDE-first and Qt fallback behavior.
Runtime configuration types, defaults, and JSON loading entrypoints.
KDE global shortcut registration and activation tracking.
Top-level runtime configuration snapshot.
Definition config.h:78
Immutable-style value object holding one captured audio segment.
Definition recording.h:14
Structured runtime-layer failure with user-facing and diagnostic text.
Background worker object that performs transcription on a dedicated thread.