mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
config: simplify initial password setup
This commit is contained in:
parent
38cf0270b1
commit
a8aa34529e
@ -17,6 +17,5 @@ OBSWebsocket.ProfileChanged.Started="WebSockets server enabled in this profile.
|
|||||||
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.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.Text="It looks like you are running obs-websocket for the first time. Do you want to configure a password now for the WebSockets server?"
|
||||||
OBSWebsocket.InitialPasswordSetup.SuccessText="Server Password set successfully."
|
OBSWebsocket.InitialPasswordSetup.DismissedText="You can configure a server password later in obs-websocket settings (under the Tools menu of OBS Studio)"
|
||||||
OBSWebsocket.InitialPasswordSetup.DismissedText="You can configure a server password anytime in obs-websocket settings (under the Tools menu of OBS Studio)"
|
|
||||||
|
@ -310,12 +310,6 @@ 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);
|
||||||
@ -327,12 +321,16 @@ void Config::FirstRunPasswordSetup()
|
|||||||
config_set_bool(globalConfig, SECTION_NAME, GLOBAL_AUTH_SETUP_PROMPTED, true);
|
config_set_bool(globalConfig, SECTION_NAME, GLOBAL_AUTH_SETUP_PROMPTED, true);
|
||||||
config_save(globalConfig);
|
config_save(globalConfig);
|
||||||
|
|
||||||
|
// check if the password is already set
|
||||||
|
auto config = GetConfig();
|
||||||
|
if (!(config->Secret.isEmpty()) && !(config->Salt.isEmpty())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||||
QString dialogTitle = QObject::tr("OBSWebsocket.InitialPasswordSetup.Title");
|
QString dialogTitle = QObject::tr("OBSWebsocket.InitialPasswordSetup.Title");
|
||||||
QString dialogText = QObject::tr("OBSWebsocket.InitialPasswordSetup.Text");
|
QString dialogText = QObject::tr("OBSWebsocket.InitialPasswordSetup.Text");
|
||||||
QString successText = QObject::tr("OBSWebsocket.InitialPasswordSetup.SuccessText");
|
|
||||||
QString dismissedText = QObject::tr("OBSWebsocket.InitialPasswordSetup.DismissedText");
|
QString dismissedText = QObject::tr("OBSWebsocket.InitialPasswordSetup.DismissedText");
|
||||||
QString passwordLabel = QObject::tr("OBSWebsocket.Settings.Password");
|
|
||||||
obs_frontend_pop_ui_translation();
|
obs_frontend_pop_ui_translation();
|
||||||
|
|
||||||
auto mainWindow = reinterpret_cast<QMainWindow*>(
|
auto mainWindow = reinterpret_cast<QMainWindow*>(
|
||||||
@ -341,21 +339,10 @@ void Config::FirstRunPasswordSetup()
|
|||||||
|
|
||||||
QMessageBox::StandardButton response = QMessageBox::question(mainWindow, dialogTitle, dialogText);
|
QMessageBox::StandardButton response = QMessageBox::question(mainWindow, dialogTitle, dialogText);
|
||||||
if (response == QMessageBox::Yes) {
|
if (response == QMessageBox::Yes) {
|
||||||
bool promptAccepted = false;
|
ShowSettingsDialog();
|
||||||
QString newPassword = QInputDialog::getText(
|
}
|
||||||
mainWindow,
|
else {
|
||||||
dialogTitle, passwordLabel,
|
// tell the user they still can set the password later in our settings dialog
|
||||||
QLineEdit::PasswordEchoOnEdit, QString::Null(), &promptAccepted
|
QMessageBox::information(mainWindow, dialogTitle, dismissedText);
|
||||||
);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ OBS_MODULE_USE_DEFAULT_LOCALE("obs-websocket", "en-US")
|
|||||||
ConfigPtr _config;
|
ConfigPtr _config;
|
||||||
WSServerPtr _server;
|
WSServerPtr _server;
|
||||||
WSEventsPtr _eventsSystem;
|
WSEventsPtr _eventsSystem;
|
||||||
|
SettingsDialog* settingsDialog = nullptr;
|
||||||
|
|
||||||
bool obs_module_load(void) {
|
bool obs_module_load(void) {
|
||||||
blog(LOG_INFO, "you can haz websockets (version %s)", OBS_WEBSOCKET_VERSION);
|
blog(LOG_INFO, "you can haz websockets (version %s)", OBS_WEBSOCKET_VERSION);
|
||||||
@ -64,14 +65,14 @@ bool obs_module_load(void) {
|
|||||||
// UI setup
|
// UI setup
|
||||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||||
QMainWindow* mainWindow = (QMainWindow*)obs_frontend_get_main_window();
|
QMainWindow* mainWindow = (QMainWindow*)obs_frontend_get_main_window();
|
||||||
SettingsDialog* settingsDialog = new SettingsDialog(mainWindow);
|
settingsDialog = new SettingsDialog(mainWindow);
|
||||||
obs_frontend_pop_ui_translation();
|
obs_frontend_pop_ui_translation();
|
||||||
|
|
||||||
const char* menuActionText =
|
const char* menuActionText =
|
||||||
obs_module_text("OBSWebsocket.Settings.DialogTitle");
|
obs_module_text("OBSWebsocket.Settings.DialogTitle");
|
||||||
QAction* menuAction =
|
QAction* menuAction =
|
||||||
(QAction*)obs_frontend_add_tools_menu_qaction(menuActionText);
|
(QAction*)obs_frontend_add_tools_menu_qaction(menuActionText);
|
||||||
QObject::connect(menuAction, &QAction::triggered, [settingsDialog] {
|
QObject::connect(menuAction, &QAction::triggered, [] {
|
||||||
// The settings dialog belongs to the main window. Should be ok
|
// The settings dialog belongs to the main window. Should be ok
|
||||||
// to pass the pointer to this QAction belonging to the main window
|
// to pass the pointer to this QAction belonging to the main window
|
||||||
settingsDialog->ToggleShowHide();
|
settingsDialog->ToggleShowHide();
|
||||||
@ -115,3 +116,9 @@ WSServerPtr GetServer() {
|
|||||||
WSEventsPtr GetEventsSystem() {
|
WSEventsPtr GetEventsSystem() {
|
||||||
return _eventsSystem;
|
return _eventsSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShowSettingsDialog() {
|
||||||
|
if (settingsDialog) {
|
||||||
|
settingsDialog->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -55,6 +55,7 @@ typedef std::shared_ptr<WSEvents> WSEventsPtr;
|
|||||||
ConfigPtr GetConfig();
|
ConfigPtr GetConfig();
|
||||||
WSServerPtr GetServer();
|
WSServerPtr GetServer();
|
||||||
WSEventsPtr GetEventsSystem();
|
WSEventsPtr GetEventsSystem();
|
||||||
|
void ShowSettingsDialog();
|
||||||
|
|
||||||
#define OBS_WEBSOCKET_VERSION "4.8.0"
|
#define OBS_WEBSOCKET_VERSION "4.8.0"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user