Merge pull request #121 from haganbmj/toggle-notifications

general(notifications): Toggle tray notifications/alerts (Closes #120)
This commit is contained in:
Stéphane L
2017-09-24 22:53:41 +02:00
committed by GitHub
6 changed files with 27 additions and 6 deletions

View File

@ -26,6 +26,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#define PARAM_ENABLE "ServerEnabled"
#define PARAM_PORT "ServerPort"
#define PARAM_DEBUG "DebugEnabled"
#define PARAM_ALERT "AlertsEnabled"
#define PARAM_AUTHREQUIRED "AuthRequired"
#define PARAM_SECRET "AuthSecret"
#define PARAM_SALT "AuthSalt"
@ -38,6 +39,7 @@ Config::Config() :
ServerEnabled(true),
ServerPort(4444),
DebugEnabled(false),
AlertsEnabled(true),
AuthRequired(false),
Secret(""),
Salt(""),
@ -52,6 +54,8 @@ Config::Config() :
config_set_default_bool(obs_config,
SECTION_NAME, PARAM_DEBUG, DebugEnabled);
config_set_default_bool(obs_config,
SECTION_NAME, PARAM_ALERT, AlertsEnabled);
config_set_default_bool(obs_config,
SECTION_NAME, PARAM_AUTHREQUIRED, AuthRequired);
@ -80,6 +84,7 @@ void Config::Load() {
ServerPort = config_get_uint(obs_config, SECTION_NAME, PARAM_PORT);
DebugEnabled = config_get_bool(obs_config, SECTION_NAME, PARAM_DEBUG);
AlertsEnabled = config_get_bool(obs_config, SECTION_NAME, PARAM_ALERT);
AuthRequired = config_get_bool(obs_config, SECTION_NAME, PARAM_AUTHREQUIRED);
Secret = config_get_string(obs_config, SECTION_NAME, PARAM_SECRET);
@ -93,6 +98,7 @@ void Config::Save() {
config_set_uint(obs_config, SECTION_NAME, PARAM_PORT, ServerPort);
config_set_bool(obs_config, SECTION_NAME, PARAM_DEBUG, DebugEnabled);
config_set_bool(obs_config, SECTION_NAME, PARAM_ALERT, AlertsEnabled);
config_set_bool(obs_config, SECTION_NAME, PARAM_AUTHREQUIRED, AuthRequired);
config_set_string(obs_config, SECTION_NAME, PARAM_SECRET, Secret);

View File

@ -39,6 +39,7 @@ class Config {
uint64_t ServerPort;
bool DebugEnabled;
bool AlertsEnabled;
bool AuthRequired;
const char* Secret;

View File

@ -24,6 +24,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include "obs-websocket.h"
#include "Utils.h"
#include "Config.h"
Q_DECLARE_METATYPE(OBSScene);
@ -379,7 +380,7 @@ QSystemTrayIcon* Utils::GetTrayIcon() {
void Utils::SysTrayNotify(QString &text,
QSystemTrayIcon::MessageIcon icon, QString title) {
if (!QSystemTrayIcon::supportsMessages())
if (!Config::Current()->AlertsEnabled || !QSystemTrayIcon::supportsMessages())
return;
QSystemTrayIcon* trayIcon = GetTrayIcon();

View File

@ -5,6 +5,7 @@ OBSWebsocket.Settings.ServerPort="Server Port"
OBSWebsocket.Settings.AuthRequired="Enable authentication"
OBSWebsocket.Settings.Password="Password"
OBSWebsocket.Settings.DebugEnable="Enable debug logging"
OBSWebsocket.Settings.AlertsEnable="Enable System Tray Alerts"
OBSWebsocket.ConnectNotify.Connected="New WebSocket connection"
OBSWebsocket.ConnectNotify.Disconnected="WebSocket client disconnected"
OBSWebsocket.ConnectNotify.ClientIP="Client Address:"

View File

@ -49,6 +49,7 @@ void SettingsDialog::showEvent(QShowEvent* event)
ui->serverPort->setValue(conf->ServerPort);
ui->debugEnabled->setChecked(conf->DebugEnabled);
ui->alertsEnabled->setChecked(conf->AlertsEnabled);
ui->authRequired->setChecked(conf->AuthRequired);
ui->password->setText(CHANGE_ME);
@ -78,6 +79,7 @@ void SettingsDialog::FormAccepted()
conf->ServerPort = ui->serverPort->value();
conf->DebugEnabled = ui->debugEnabled->isChecked();
conf->AlertsEnabled = ui->alertsEnabled->isChecked();
if (ui->authRequired->isChecked())
{

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>407</width>
<height>175</height>
<height>195</height>
</rect>
</property>
<property name="sizePolicy">
@ -80,6 +80,16 @@
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="alertsEnabled">
<property name="text">
<string>OBSWebsocket.Settings.AlertsEnable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="debugEnabled">
<property name="text">
<string>OBSWebsocket.Settings.DebugEnable</string>
@ -113,11 +123,11 @@
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>274</y>
<y>294</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>294</y>
<y>314</y>
</hint>
</hints>
</connection>
@ -129,11 +139,11 @@
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>280</y>
<y>300</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>294</y>
<y>314</y>
</hint>
</hints>
</connection>