config(profile change): fix notifications

This commit is contained in:
Stéphane L 2019-04-22 15:26:26 +02:00
parent 14a43a9cd2
commit 1c17eee125

View File

@ -204,24 +204,37 @@ void Config::OnFrontendEvent(enum obs_frontend_event event, void* param)
auto config = reinterpret_cast<Config*>(param); auto config = reinterpret_cast<Config*>(param);
if (event == OBS_FRONTEND_EVENT_PROFILE_CHANGED) { if (event == OBS_FRONTEND_EVENT_PROFILE_CHANGED) {
auto server = WSServer::Current(); auto previousEnabled = config->ServerEnabled;
server->stop(); auto previousPort = config->ServerPort;
config->SetDefaults(); config->SetDefaults();
config->Load(); config->Load();
if (config->ServerEnabled != previousEnabled || config->ServerPort != previousPort) {
auto server = WSServer::Current();
server->stop();
if (config->ServerEnabled) { if (config->ServerEnabled) {
server->start(config->ServerPort); server->start(config->ServerPort);
if (previousEnabled != config->ServerEnabled) {
Utils::SysTrayNotify( Utils::SysTrayNotify(
QString("Profile changed, WebSockets server restarted"), QString("WebSockets server enabled in this profile. Server started."),
QSystemTrayIcon::MessageIcon::Information QSystemTrayIcon::MessageIcon::Information
); );
} else { } else {
Utils::SysTrayNotify( Utils::SysTrayNotify(
QString("Profile changed, WebSockets server stopped"), QString("WebSockets server port changed in this profile. Server restarted."),
QSystemTrayIcon::MessageIcon::Information QSystemTrayIcon::MessageIcon::Information
); );
} }
} else {
Utils::SysTrayNotify(
QString("WebSockets server disabled in this profile. Server stopped."),
QSystemTrayIcon::MessageIcon::Information
);
}
}
} }
} }