-
Notifications
You must be signed in to change notification settings - Fork 1
/
ConfigDialog.cpp
159 lines (146 loc) · 4.33 KB
/
ConfigDialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include "ConfigDialog.h"
#include "ui_ConfigDialog.h"
#include "QDebug"
ConfigDialog::ConfigDialog(QWidget *parent, ConfigFile *config) :
QDialog(parent),
ui(new Ui::ConfigDialog)
{
ui->setupUi(this);
otherTTSInit();
/////////////////////////////////////////////////////
//
speakConfig = config;
speakMethode = speakConfig->getSpeakMethod();
if(speakMethode == "eSpeakTTS")
{
qDebug() << QString("默认的发音引擎为:%1").arg(speakMethode);
ui->ESpeakTTSRadioButton->setChecked(true);
}
else if(speakMethode == "GoogleTTS")
{
qDebug() << QString("默认的发音引擎为:%1").arg(speakMethode);
ui->GoogleTTSRadioButton->setChecked(true);
}
else if(speakMethode == "OtherTTS")
{
qDebug() << QString("默认的发音引擎为:%1").arg(speakMethode);
ui->OtherRadioButton->setChecked(true);
QtSpeakTTS = speakConfig->getQtSpeakTTS();
qDebug() << QString("第三方发音引擎为:%1").arg(QtSpeakTTS);
initTTSCombox();
if(QtSpeakTTS != "")
{
QtSpeakTTSID = ui->TTSComboBox->findText(QtSpeakTTS);
qDebug() << QString("第三方发音引擎的ID为: %1").arg(QtSpeakTTSID);
ui->TTSComboBox->setCurrentIndex(QtSpeakTTSID);
qDebug() << QString("设置下拉选择框的当前索引值为: %1").arg(QtSpeakTTSID);
ui->RateHorizontalSlider->setValue(config->getSpeakSpeed().toInt());
}
}
else
{
qDebug() << QString("无法读取发音方法配置信息");
}
}
ConfigDialog::~ConfigDialog()
{
speakConfig = NULL;
delete ui;
}
void ConfigDialog::initTTSCombox()
{
ui->TTSComboBox->setEnabled(true);
ui->RateHorizontalSlider->setEnabled(true);
////////////////////////////////////////////////////
//
foreach(QtSpeech::VoiceName v, QtSpeech::voices())
{
qDebug() << "id:" << v.id;
qDebug() << "name:" << v.name;
// if(v.name == QtSpeakTTS)
// {
// QtSpeakTTSID = v.id.toInt();
// qDebug() << QString("第三方发音引擎的ID为: %1").arg(QtSpeakTTSID);
// }
if(v.name == QString("Microsoft Mary") ||
v.name == QString("Microsoft Mike") ||
v.name == QString("Sample TTS Voice"))
{
qDebug() << QString("忽略Microsoft Mary , Microsoft Mike 和 Sample TTS Voice");
qDebug() << QString("忽略: %1 成功").arg(v.name);
}
else
{
ui->TTSComboBox->addItem(v.name);
}
}
}
void ConfigDialog::otherTTSInit()
{
ui->TTSComboBox->setEnabled(false);
ui->RateHorizontalSlider->setEnabled(false);
}
void ConfigDialog::on_ApplyButton_clicked()
{
if(ui->GoogleTTSRadioButton->isChecked())
{
speakConfig->setSpeakMethod(QString("GoogleTTS"));
}
if(ui->ESpeakTTSRadioButton->isChecked())
{
speakConfig->setSpeakMethod(QString("eSpeakTTS"));
}
if(ui->OtherRadioButton->isChecked())
{
speakConfig->setSpeakMethod(QString("OtherTTS"));
qDebug() << QString("第三方发音引擎成功设为:%1").arg(ui->TTSComboBox->currentText());
speakConfig->setQtSpeakTTS(ui->TTSComboBox->currentText());
qDebug() << QString("第三方发音引擎发音速度成功设为:%1").arg(ui->RateHorizontalSlider->value());
speakConfig->setSpeakSpeed(QString::number(ui->RateHorizontalSlider->value(),'i',0));
}
accept();
}
void ConfigDialog::on_CancelButton_clicked()
{
reject();
}
QString ConfigDialog::voiceMethode()
{
if(ui->GoogleTTSRadioButton->isChecked())
{
return QString("GoogleTTS");
}
if(ui->ESpeakTTSRadioButton->isChecked())
{
return QString("eSpeakTTS");
}
return QString("eSpeakTTS");
}
void ConfigDialog::on_ESpeakTTSRadioButton_clicked(bool checked)
{
if(checked == true)
{
qDebug() << QString("选择eSpeakTTS");
otherTTSInit();
}
}
void ConfigDialog::on_GoogleTTSRadioButton_clicked(bool checked)
{
if(checked == true)
{
qDebug() << QString("选择GoogleTTS");
otherTTSInit();
}
}
void ConfigDialog::on_OtherRadioButton_clicked(bool checked)
{
if(checked == true)
{
qDebug() << QString("选择OtherTTS");
initTTSCombox();
}
}
void ConfigDialog::on_RateHorizontalSlider_valueChanged(int value)
{
qDebug() << QString("当前的放音速度为:%1").arg(value);
}