7#include "speechtotextselectdevicewidget.h"
9#include <KLocalizedString>
10#include <KSharedConfig>
11#include <QAudioDevice>
12#include <QMediaDevices>
18using namespace TextSpeechToText;
21const char mySoundGroupName[] =
"Speech To Text";
23SpeechToTextSelectDeviceWidget::SpeechToTextSelectDeviceWidget(
QWidget *parent)
28 mainLayout->setObjectName(QStringLiteral(
"mainLayout"));
29 mainLayout->setContentsMargins({});
32 label->setObjectName(QStringLiteral(
"label"));
33 mainLayout->addWidget(label);
35 mDeviceComboBox->setObjectName(QStringLiteral(
"mDeviceComboBox"));
36 mainLayout->addWidget(mDeviceComboBox);
40SpeechToTextSelectDeviceWidget::~SpeechToTextSelectDeviceWidget() =
default;
42void SpeechToTextSelectDeviceWidget::loadSettings()
45 const QByteArray deviceIdentifier = group.readEntry(
"SoundDevice", QByteArray());
46 if (!deviceIdentifier.
isEmpty()) {
47 const int nbDevice{mDeviceComboBox->count()};
48 for (
int i = 0; i < nbDevice; ++i) {
49 const QAudioDevice audioDevice = mDeviceComboBox->itemData(i).value<QAudioDevice>();
50 if (audioDevice.id() == deviceIdentifier) {
51 mDeviceComboBox->setCurrentIndex(i);
58void SpeechToTextSelectDeviceWidget::saveSettings()
61 const auto device = mDeviceComboBox->itemData(mDeviceComboBox->currentIndex()).value<QAudioDevice>();
62 if (!device.isNull()) {
63 const QByteArray deviceIdentifier = device.id();
64 group.writeEntry(
"SoundDevice", deviceIdentifier);
68void SpeechToTextSelectDeviceWidget::initializeInput()
70 mDeviceComboBox->addItem(
i18n(
"Default"), QVariant(QString()));
71 for (
const auto &device : QMediaDevices::audioInputs()) {
72 const auto name = device.description();
77#include "moc_speechtotextselectdevicewidget.cpp"
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QString name(StandardAction id)
QString label(StandardShortcut id)
bool isEmpty() const const
QVariant fromValue(T &&value)