-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
62 lines (53 loc) · 1.27 KB
/
main.cpp
File metadata and controls
62 lines (53 loc) · 1.27 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
60
61
62
#include "mainwindow.h"
#include "sounddevice.h"
#include "sounddeviceenumerator.h"
#include "settings.h"
#include <QApplication>
#include <QMessageBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QCoreApplication::setOrganizationName("SGH");
QCoreApplication::setApplicationName("QtSense");
QCoreApplication::setApplicationVersion(VERSION);
SoundDeviceEnumerator sde;
std::vector<std::string> devices = sde.getSoundDevices();
if(devices.empty())
{
QMessageBox::critical(nullptr,
QObject::tr("Sound System error."),
QObject::tr("No sound devices have been found."));
return a.exec();
}
Set::g_settings->beginGroup("Sound");
std::string prefDevice = Set::stringSetting("SelectedDevice").toStdString();
Set::g_settings->endGroup();
std::string selDevice = devices.front();
for(auto& dev : devices)
{
if(dev == prefDevice)
{
selDevice = std::move(prefDevice);
break;
}
}
SoundDevice sd(nullptr, selDevice);
if(!sd.isReady())
{
QMessageBox::critical(nullptr,
QObject::tr("Sound System error."),
sd.error());
return a.exec();
}
if(!sd.select())
{
QMessageBox::critical(nullptr,
QObject::tr("Sound System error."),
sd.error());
return a.exec();
}
sd.loadEffects();
MainWindow w;
w.show();
return a.exec();
}