-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathctts_main_window.cpp
More file actions
59 lines (48 loc) · 1.81 KB
/
Copy pathctts_main_window.cpp
File metadata and controls
59 lines (48 loc) · 1.81 KB
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
#include "ctts_main_window.h"
#include "azure.h"
#include "ctts_config_window.h"
#include "ctts_current_service.h"
#include "dummy.h"
#include <QGroupBox>
#include <QVBoxLayout>
#include <memory>
#include <utility>
ctts_mainwindow::ctts_mainwindow()
{
auto* vbox = new QVBoxLayout(nullptr);
auto* mainWidget = new QWidget(this);
TextToSpeechService* newService = GlobalCurrentService->getServiceAccordingToConfigInDisk();
if (newService != nullptr) {
// has_value checks if a type-value is returned
currentService.reset(newService);
} else {
qDebug() << "Failed to get Azure Service";
exit(1);
}
textEdit = new QPlainTextEdit(this);
textEdit->setPlainText("hello");
speakButton = new QPushButton("Speak", this);
configButton = new QPushButton("Config", this);
vbox->addWidget(textEdit.get());
vbox->addWidget(speakButton.get());
vbox->addWidget(configButton.get());
connect(speakButton.get(), &QPushButton::clicked, this,
[this] { currentService->speak(textEdit->toPlainText().toStdString()); });
connect(configButton.get(), &QPushButton::clicked, this, [this] {
auto* cfgWindow = new ctts_config_window(this);
cfgWindow->setWindowModality(Qt::WindowModal);
connect(cfgWindow, &ctts_config_window::finished_config, this, [this] {
auto newService = GlobalCurrentService->getServiceAccordingToConfigInDisk();
if (newService != nullptr) {
// has_value checks if a type-value is returned
this->currentService.reset(newService);
} else {
qDebug() << "Failed to get Azure Service";
exit(1);
}
});
cfgWindow->show();
});
mainWidget->setLayout(vbox);
this->setCentralWidget(mainWidget);
}