diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index 6b97535b..08f660d3 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -9,11 +9,14 @@ OBSWebSocket.Settings.DebugEnable="Enable Debug Logging" OBSWebSocket.Settings.DebugEnableHoverText="Enables debug logging for the current instance of OBS. Does not persist on load.\nUse --websocket_debug to enable on load." OBSWebSocket.Settings.ServerSettingsTitle="Server Settings" +OBSWebSocket.Settings.ServerPort="Server Port" +OBSWebSocket.Settings.AllowExternal="Allow External Access" +OBSWebSocket.Settings.AllowExternalHoverText="Allows clients from outside this computer to connect to obs-websocket." OBSWebSocket.Settings.AuthRequired="Enable Authentication" OBSWebSocket.Settings.Password="Server Password" OBSWebSocket.Settings.GeneratePassword="Generate Password" -OBSWebSocket.Settings.ServerPort="Server Port" OBSWebSocket.Settings.ShowConnectInfo="Show Connect Info" +OBSWebSocket.Settings.ShowConnectInfoHoverText="Connect Info is not available if external connections are disabled." OBSWebSocket.Settings.ShowConnectInfoWarningTitle="Warning: Currently Live" OBSWebSocket.Settings.ShowConnectInfoWarningMessage="It appears that an output (stream, recording, etc.) is currently active." OBSWebSocket.Settings.ShowConnectInfoWarningInfoText="Are you sure that you want to show your connect info?" diff --git a/src/forms/SettingsDialog.cpp b/src/forms/SettingsDialog.cpp index 87b44693..bbc9067e 100644 --- a/src/forms/SettingsDialog.cpp +++ b/src/forms/SettingsDialog.cpp @@ -52,7 +52,9 @@ SettingsDialog::SettingsDialog(QWidget* parent) : setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); // Set the appropriate tooltip icon for the theme - ui->enableDebugLoggingToolTipLabel->setText(GetToolTipIconHtml()); + QString toolTipHtml = GetToolTipIconHtml(); + ui->enableDebugLoggingToolTipLabel->setText(toolTipHtml); + ui->allowExternalToolTipLabel->setText(toolTipHtml); connect(sessionTableTimer, &QTimer::timeout, this, &SettingsDialog::FillSessionTable); @@ -83,18 +85,8 @@ void SettingsDialog::showEvent(QShowEvent *) return; } - ui->enableWebSocketServerCheckBox->setChecked(conf->ServerEnabled); - ui->enableSystemTrayAlertsCheckBox->setChecked(conf->AlertsEnabled); - ui->enableDebugLoggingCheckBox->setChecked(conf->DebugEnabled); - ui->enableAuthenticationCheckBox->setChecked(conf->AuthRequired); - ui->serverPasswordLineEdit->setText(conf->ServerPassword); - ui->serverPasswordLineEdit->setEnabled(conf->AuthRequired); - ui->generatePasswordButton->setEnabled(conf->AuthRequired); - ui->serverPortSpinBox->setValue(conf->ServerPort); - - if (conf->PortOverridden) { + if (conf->PortOverridden) ui->serverPortSpinBox->setEnabled(false); - } if (conf->PasswordOverridden) { ui->enableAuthenticationCheckBox->setEnabled(false); @@ -104,7 +96,7 @@ void SettingsDialog::showEvent(QShowEvent *) passwordManuallyEdited = false; - FillSessionTable(); + RefreshData(); sessionTableTimer->start(1000); } @@ -125,6 +117,31 @@ void SettingsDialog::ToggleShowHide() setVisible(false); } +void SettingsDialog::RefreshData() +{ + auto conf = GetConfig(); + if (!conf) { + blog(LOG_ERROR, "[SettingsDialog::RefreshData] Unable to retreive config!"); + return; + } + + ui->enableWebSocketServerCheckBox->setChecked(conf->ServerEnabled); + ui->enableSystemTrayAlertsCheckBox->setChecked(conf->AlertsEnabled); + ui->enableDebugLoggingCheckBox->setChecked(conf->DebugEnabled); + ui->serverPortSpinBox->setValue(conf->ServerPort); + ui->allowExternalCheckBox->setChecked(!conf->BindLoopback); + ui->enableAuthenticationCheckBox->setChecked(conf->AuthRequired); + ui->serverPasswordLineEdit->setText(conf->ServerPassword); + + ui->showConnectInfoButton->setEnabled(!conf->BindLoopback); + ui->serverPasswordLineEdit->setEnabled(conf->AuthRequired); + ui->generatePasswordButton->setEnabled(conf->AuthRequired); + + ui->showConnectInfoButton->setToolTip(ui->allowExternalCheckBox->isChecked() ? "" : obs_module_text("OBSWebSocket.Settings.ShowConnectInfoHoverText")); + + FillSessionTable(); +} + void SettingsDialog::DialogButtonClicked(QAbstractButton *button) { if (button == ui->buttonBox->button(QDialogButtonBox::Ok)) { @@ -173,17 +190,20 @@ void SettingsDialog::SaveFormData() bool needsRestart = (conf->ServerEnabled != ui->enableWebSocketServerCheckBox->isChecked()) || (ui->enableAuthenticationCheckBox->isChecked() && conf->ServerPassword != ui->serverPasswordLineEdit->text()) || + (conf->BindLoopback == ui->allowExternalCheckBox->isChecked()) || (conf->ServerPort != ui->serverPortSpinBox->value()); conf->ServerEnabled = ui->enableWebSocketServerCheckBox->isChecked(); conf->AlertsEnabled = ui->enableSystemTrayAlertsCheckBox->isChecked(); conf->DebugEnabled = ui->enableDebugLoggingCheckBox->isChecked(); + conf->ServerPort = ui->serverPortSpinBox->value(); + conf->BindLoopback = !ui->allowExternalCheckBox->isChecked(); conf->AuthRequired = ui->enableAuthenticationCheckBox->isChecked(); conf->ServerPassword = ui->serverPasswordLineEdit->text(); - conf->ServerPort = ui->serverPortSpinBox->value(); conf->Save(); + RefreshData(); connectInfo->RefreshData(); if (needsRestart) { diff --git a/src/forms/SettingsDialog.h b/src/forms/SettingsDialog.h index 49fd699c..deb008cc 100644 --- a/src/forms/SettingsDialog.h +++ b/src/forms/SettingsDialog.h @@ -37,6 +37,7 @@ public: void showEvent(QShowEvent *event); void hideEvent(QHideEvent *event); void ToggleShowHide(); + void RefreshData(); private Q_SLOTS: void DialogButtonClicked(QAbstractButton *button); diff --git a/src/forms/SettingsDialog.ui b/src/forms/SettingsDialog.ui index 567b3a53..fd51d5e2 100644 --- a/src/forms/SettingsDialog.ui +++ b/src/forms/SettingsDialog.ui @@ -155,21 +155,21 @@ - + OBSWebSocket.Settings.AuthRequired - + OBSWebSocket.Settings.Password - + @@ -187,7 +187,7 @@ - + Qt::Horizontal @@ -203,13 +203,47 @@ - + OBSWebSocket.Settings.ShowConnectInfo + + + + + + OBSWebSocket.Settings.AllowExternal + + + + + + + OBSWebSocket.Settings.AllowExternalHoverText + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/src/websocketserver/WebSocketServer.cpp b/src/websocketserver/WebSocketServer.cpp index ad7b1539..48bf114a 100644 --- a/src/websocketserver/WebSocketServer.cpp +++ b/src/websocketserver/WebSocketServer.cpp @@ -142,7 +142,7 @@ void WebSocketServer::Start() blog(LOG_INFO, "[WebSocketServer::Start] Locked to IPv4 bindings."); } else { _server.listen(conf->ServerPort, errorCode); - blog(LOG_INFO, "[WebSocketServer::Start] Not locked to IPv4 bindings."); + blog(LOG_INFO, "[WebSocketServer::Start] Bound to all interfaces."); } if (errorCode) {