KTextAddons

texttospeechvoicecombobox.cpp
1/*
2 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "texttospeechvoicecombobox.h"
8#include <QDebug>
9using namespace TextEditTextToSpeech;
10
11TextToSpeechVoiceComboBox::TextToSpeechVoiceComboBox(QWidget *parent)
12 : QComboBox(parent)
13{
14}
15
16TextToSpeechVoiceComboBox::~TextToSpeechVoiceComboBox() = default;
17
18QVoice TextToSpeechVoiceComboBox::currentVoice() const
19{
20 return currentData().value<QVoice>();
21}
22
23void TextToSpeechVoiceComboBox::setCurrentVoice(const QVoice &voice)
24{
25 const int index = findData(QVariant::fromValue(voice));
26 qDebug() << " count " << count();
27 qDebug() << " index " << index;
28 if (index != -1) {
29 setCurrentIndex(index);
30 }
31}
32
33void TextToSpeechVoiceComboBox::updateVoices(const QVector<QVoice> &voices)
34{
35 clear();
36 for (const QVoice &voice : voices) {
37 addItem(voice.name(), QVariant::fromValue(voice));
38 }
40 // Sort it after loading list.
42}
43
44#include "moc_texttospeechvoicecombobox.cpp"
virtual void sort(int column, Qt::SortOrder order)
void addItem(const QIcon &icon, const QString &text, const QVariant &userData)
void clear()
void setCurrentIndex(int index)
int findData(const QVariant &data, int role, Qt::MatchFlags flags) const const
QAbstractItemModel * model() const const
void setSizeAdjustPolicy(SizeAdjustPolicy policy)
AscendingOrder
QVariant fromValue(T &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:51:28 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.