mutterkey
KDE-first push-to-talk transcription tool for KDE Plasma
Loading...
Searching...
No Matches
config.h File Reference

Runtime configuration types, defaults, and JSON loading entrypoints. More...

#include <QByteArray>
#include <QJsonObject>
#include <QString>
#include <QStringList>

Go to the source code of this file.

Classes

struct  ShortcutConfig
 Global shortcut registration settings. More...
 
struct  AudioConfig
 Audio capture configuration passed to the recorder. More...
 
struct  TranscriberConfig
 Transcription runtime configuration. More...
 
struct  AppConfig
 Top-level runtime configuration snapshot. More...
 

Functions

QString defaultConfigPath ()
 Returns the default runtime config path.
 
QString defaultModelPath ()
 Returns the default model artifact path used for fallback config values.
 
AppConfig defaultAppConfig ()
 Returns the built-in runtime defaults.
 
AppConfig loadConfig (const QString &path, QString *errorMessage=nullptr)
 Loads a config file and applies repo-defined fallback defaults.
 
AppConfig loadConfigObject (const QJsonObject &root, const QString &sourceName=QStringLiteral("<in-memory config>"))
 Loads a config object and applies the same fallback rules as file loading.
 
QByteArray serializeConfig (const AppConfig &config)
 Serializes a config snapshot to indented JSON.
 
QJsonObject configToJsonObject (const AppConfig &config)
 Converts a config snapshot to the saved JSON object shape.
 
bool saveConfig (const QString &path, const AppConfig &config, QString *errorMessage=nullptr)
 Saves a config snapshot to disk, creating parent directories as needed.
 
QStringList supportedConfigKeys ()
 Returns the supported dotted keys for config mutation.
 
bool applyConfigValue (AppConfig *config, QStringView key, const QString &value, QString *errorMessage=nullptr)
 Applies a single dotted-key config value with validation.
 

Detailed Description

Runtime configuration types, defaults, and JSON loading entrypoints.

Definition in file config.h.

Function Documentation

◆ applyConfigValue()

bool applyConfigValue ( AppConfig config,
QStringView  key,
const QString &  value,
QString *  errorMessage = nullptr 
)

Applies a single dotted-key config value with validation.

Parameters
configConfig snapshot to mutate.
keyCanonical dotted config key.
valueText value to parse and validate.
errorMessageOptional output for validation failures.
Returns
true when the key is supported and the value is valid.

◆ configToJsonObject()

QJsonObject configToJsonObject ( const AppConfig config)

Converts a config snapshot to the saved JSON object shape.

Parameters
configConfig snapshot to convert.
Returns
JSON object matching the on-disk config structure.

◆ defaultAppConfig()

AppConfig defaultAppConfig ( )

Returns the built-in runtime defaults.

Returns
Application config initialized with repo-defined defaults.

◆ defaultConfigPath()

QString defaultConfigPath ( )

Returns the default runtime config path.

Runtime defaults are intentionally centralized here so the loader, tests, and any future CLI or config UI work from the same baseline values.

Returns
Default path to config.json.

◆ defaultModelPath()

QString defaultModelPath ( )

Returns the default model artifact path used for fallback config values.

Returns
Default path to the expected local model artifact.

◆ loadConfig()

AppConfig loadConfig ( const QString &  path,
QString *  errorMessage = nullptr 
)

Loads a config file and applies repo-defined fallback defaults.

Invalid or missing values are handled permissively where possible so runtime startup can continue with safe defaults and warnings.

Parameters
pathPath to the JSON config file.
errorMessageOptional output for fatal load or parse failures.
Returns
Resolved application config snapshot.

◆ loadConfigObject()

AppConfig loadConfigObject ( const QJsonObject &  root,
const QString &  sourceName = QStringLiteral("<in-memory config>") 
)

Loads a config object and applies the same fallback rules as file loading.

This is primarily used by in-memory control-plane payloads so the tray and daemon share one config contract instead of maintaining parallel JSON readers.

Parameters
rootJSON object shaped like the saved config file.
sourceNameHuman-readable source label used in warning messages.
Returns
Resolved application config snapshot.

◆ saveConfig()

bool saveConfig ( const QString &  path,
const AppConfig config,
QString *  errorMessage = nullptr 
)

Saves a config snapshot to disk, creating parent directories as needed.

Parameters
pathDestination config path.
configConfig snapshot to save.
errorMessageOptional output for write failures.
Returns
true on success.

◆ serializeConfig()

QByteArray serializeConfig ( const AppConfig config)

Serializes a config snapshot to indented JSON.

Parameters
configConfig snapshot to serialize.
Returns
UTF-8 JSON payload.

◆ supportedConfigKeys()

QStringList supportedConfigKeys ( )

Returns the supported dotted keys for config mutation.

Returns
Supported config keys in user-facing display order.