mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
config: add locale texts for initial password setup
This commit is contained in:
parent
c02382b6e5
commit
c8ca79f00b
@ -15,3 +15,7 @@ OBSWebsocket.Server.StartFailed.Message="The WebSockets server failed to start,
|
|||||||
OBSWebsocket.ProfileChanged.Started="WebSockets server enabled in this profile. Server started."
|
OBSWebsocket.ProfileChanged.Started="WebSockets server enabled in this profile. Server started."
|
||||||
OBSWebsocket.ProfileChanged.Stopped="WebSockets server disabled in this profile. Server stopped."
|
OBSWebsocket.ProfileChanged.Stopped="WebSockets server disabled in this profile. Server stopped."
|
||||||
OBSWebsocket.ProfileChanged.Restarted="WebSockets server port changed in this profile. Server restarted."
|
OBSWebsocket.ProfileChanged.Restarted="WebSockets server port changed in this profile. Server restarted."
|
||||||
|
OBSWebsocket.InitialPasswordSetup.Title="obs-websocket - Server Password Configuration"
|
||||||
|
OBSWebsocket.InitialPasswordSetup.Text="It looks like you are running obs-websocket for the first time. Do you want set a password for the WebSockets server now?"
|
||||||
|
OBSWebsocket.InitialPasswordSetup.SuccessText="Server Password set successfully."
|
||||||
|
OBSWebsocket.InitialPasswordSetup.DismissedText="You can configure a server password anytime in obs-websocket settings (under the Tools menu of OBS Studio)"
|
||||||
|
@ -310,6 +310,12 @@ void Config::OnFrontendEvent(enum obs_frontend_event event, void* param)
|
|||||||
|
|
||||||
void Config::FirstRunPasswordSetup()
|
void Config::FirstRunPasswordSetup()
|
||||||
{
|
{
|
||||||
|
// check if the password is already set
|
||||||
|
auto config = GetConfig();
|
||||||
|
if (!(config->Secret.isEmpty()) && !(config->Salt.isEmpty())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// check if we already showed the auth setup prompt to the user, independently of the current settings (tied to the current profile)
|
// check if we already showed the auth setup prompt to the user, independently of the current settings (tied to the current profile)
|
||||||
config_t* globalConfig = obs_frontend_get_global_config();
|
config_t* globalConfig = obs_frontend_get_global_config();
|
||||||
bool alreadyPrompted = config_get_bool(globalConfig, SECTION_NAME, GLOBAL_AUTH_SETUP_PROMPTED);
|
bool alreadyPrompted = config_get_bool(globalConfig, SECTION_NAME, GLOBAL_AUTH_SETUP_PROMPTED);
|
||||||
@ -322,29 +328,34 @@ void Config::FirstRunPasswordSetup()
|
|||||||
config_save(globalConfig);
|
config_save(globalConfig);
|
||||||
|
|
||||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||||
QString initialPasswordSetupTitle = QObject::tr("OBSWebsocket.InitialPasswordSetup.Title");
|
QString dialogTitle = QObject::tr("OBSWebsocket.InitialPasswordSetup.Title");
|
||||||
QString initialPasswordSetupText = QObject::tr("OBSWebsocket.InitialPasswordSetup.Text");
|
QString dialogText = QObject::tr("OBSWebsocket.InitialPasswordSetup.Text");
|
||||||
QString setupDismissedTitle = QObject::tr("OBSWebsocket.InitialPasswordSetupDismissed.Title");
|
QString successText = QObject::tr("OBSWebsocket.InitialPasswordSetup.SuccessText");
|
||||||
QString setupDismissedText = QObject::tr("OBSWebsocket.InitialPasswordSetupDismissed.Text");
|
QString dismissedText = QObject::tr("OBSWebsocket.InitialPasswordSetup.DismissedText");
|
||||||
|
QString passwordLabel = QObject::tr("OBSWebsocket.Settings.Password");
|
||||||
obs_frontend_pop_ui_translation();
|
obs_frontend_pop_ui_translation();
|
||||||
|
|
||||||
// prompt for a password
|
|
||||||
auto mainWindow = reinterpret_cast<QMainWindow*>(
|
auto mainWindow = reinterpret_cast<QMainWindow*>(
|
||||||
obs_frontend_get_main_window()
|
obs_frontend_get_main_window()
|
||||||
);
|
);
|
||||||
bool promptAccepted = false;
|
|
||||||
QString newPassword = QInputDialog::getText(
|
|
||||||
mainWindow,
|
|
||||||
initialPasswordSetupTitle, initialPasswordSetupText,
|
|
||||||
QLineEdit::PasswordEchoOnEdit, QString::Null(), &promptAccepted
|
|
||||||
);
|
|
||||||
|
|
||||||
if (promptAccepted) {
|
int proceed = QMessageBox::question(mainWindow, dialogTitle, dialogText, QMessageBox::No, QMessageBox::Yes);
|
||||||
// set new password
|
if (proceed) {
|
||||||
GetConfig()->SetPassword(newPassword);
|
bool promptAccepted = false;
|
||||||
} else {
|
QString newPassword = QInputDialog::getText(
|
||||||
// tell the user they still can set the password later in our settings dialog
|
mainWindow,
|
||||||
QMessageBox::information(mainWindow, setupDismissedTitle, setupDismissedText, QMessageBox::Ok);
|
dialogTitle, passwordLabel,
|
||||||
|
QLineEdit::PasswordEchoOnEdit, QString::Null(), &promptAccepted
|
||||||
|
);
|
||||||
|
|
||||||
|
if (promptAccepted) {
|
||||||
|
// set new password
|
||||||
|
GetConfig()->SetPassword(newPassword);
|
||||||
|
QMessageBox::information(mainWindow, dialogTitle, successText);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tell the user they still can set the password later in our settings dialog
|
||||||
|
QMessageBox::information(mainWindow, dialogTitle, dismissedText);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user