diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt
index df4d26450..256bb6646 100644
--- a/UI/CMakeLists.txt
+++ b/UI/CMakeLists.txt
@@ -345,7 +345,6 @@ set(obs_UI
forms/source-toolbar/color-source-toolbar.ui
forms/source-toolbar/text-source-toolbar.ui
forms/source-toolbar/media-controls.ui
- forms/NameDialog.ui
forms/AutoConfigStartPage.ui
forms/AutoConfigVideoPage.ui
forms/AutoConfigStreamPage.ui
diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini
index 1095f5f53..988317099 100644
--- a/UI/data/locale/en-US.ini
+++ b/UI/data/locale/en-US.ini
@@ -430,6 +430,7 @@ Basic.Main.RenameSceneCollection.Title="Rename Scene Collection"
# add profile dialog
AddProfile.Title="Add Profile"
AddProfile.Text="Please enter the name of the profile"
+AddProfile.WizardCheckbox="Show auto-configuration wizard"
# rename profile dialog
RenameProfile.Title="Rename Profile"
diff --git a/UI/forms/NameDialog.ui b/UI/forms/NameDialog.ui
deleted file mode 100644
index cdd244bf4..000000000
--- a/UI/forms/NameDialog.ui
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
- NameDialog
-
-
- Qt::WindowModal
-
-
-
- 0
- 0
- 555
- 102
-
-
-
- Dialog
-
-
- -
-
-
-
- 0
- 0
-
-
-
- TextLabel
-
-
- true
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Qt::Horizontal
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
- true
-
-
-
-
-
-
-
-
- buttonBox
- accepted()
- NameDialog
- accept()
-
-
- 257
- 94
-
-
- 157
- 274
-
-
-
-
- buttonBox
- rejected()
- NameDialog
- reject()
-
-
- 325
- 94
-
-
- 286
- 274
-
-
-
-
-
diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp
index bf5f0cb09..48f07b59f 100644
--- a/UI/obs-app.cpp
+++ b/UI/obs-app.cpp
@@ -1257,6 +1257,8 @@ void OBSApp::AppInit()
Str("Untitled"));
config_set_default_string(globalConfig, "Basic", "SceneCollectionFile",
Str("Untitled"));
+ config_set_default_bool(globalConfig, "Basic", "ConfigOnNewProfile",
+ true);
if (!config_has_user_value(globalConfig, "Basic", "Profile")) {
config_set_string(globalConfig, "Basic", "Profile",
diff --git a/UI/window-basic-main-profiles.cpp b/UI/window-basic-main-profiles.cpp
index b833da05b..86e9631d3 100644
--- a/UI/window-basic-main-profiles.cpp
+++ b/UI/window-basic-main-profiles.cpp
@@ -22,6 +22,7 @@
#include
#include
#include "window-basic-main.hpp"
+#include "window-basic-auto-config.hpp"
#include "window-namedialog.hpp"
#include "qt-wrappers.hpp"
@@ -93,14 +94,25 @@ static bool ProfileExists(const char *findName)
static bool GetProfileName(QWidget *parent, std::string &name,
std::string &file, const char *title,
- const char *text, const char *oldName = nullptr)
+ const char *text, const bool showWizard,
+ bool &wizardChecked, const char *oldName = nullptr)
{
char path[512];
int ret;
for (;;) {
- bool success = NameDialog::AskForName(parent, title, text, name,
- QT_UTF8(oldName));
+ bool success = false;
+
+ if (showWizard) {
+ success = NameDialog::AskForNameWithOption(
+ parent, title, text, name,
+ QTStr("AddProfile.WizardCheckbox"),
+ wizardChecked, QT_UTF8(oldName));
+ } else {
+ success = NameDialog::AskForName(
+ parent, title, text, name, QT_UTF8(oldName));
+ }
+
if (!success) {
return false;
}
@@ -193,9 +205,18 @@ bool OBSBasic::AddProfile(bool create_new, const char *title, const char *text,
std::string newPath;
ConfigFile config;
- if (!GetProfileName(this, newName, newDir, title, text, init_text))
+ bool showWizardChecked = config_get_bool(App()->GlobalConfig(), "Basic",
+ "ConfigOnNewProfile");
+
+ if (!GetProfileName(this, newName, newDir, title, text, create_new,
+ showWizardChecked, init_text))
return false;
+ if (create_new) {
+ config_set_bool(App()->GlobalConfig(), "Basic",
+ "ConfigOnNewProfile", showWizardChecked);
+ }
+
std::string curDir =
config_get_string(App()->GlobalConfig(), "Basic", "ProfileDir");
@@ -258,6 +279,15 @@ bool OBSBasic::AddProfile(bool create_new, const char *title, const char *text,
config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
UpdateTitleBar();
+ // Run auto configuration setup wizard when a new profile is made to assist
+ // setting up blank settings
+ if (create_new && showWizardChecked) {
+ AutoConfig wizard(this);
+ wizard.setModal(true);
+ wizard.show();
+ wizard.exec();
+ }
+
if (api) {
api->on_event(OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED);
api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED);
diff --git a/UI/window-basic-main-transitions.cpp b/UI/window-basic-main-transitions.cpp
index 98b43cdd7..8b491a8cf 100644
--- a/UI/window-basic-main-transitions.cpp
+++ b/UI/window-basic-main-transitions.cpp
@@ -617,37 +617,35 @@ void OBSBasic::RenameTransition()
QTStr("TransitionNameDlg.Text"),
name, placeHolderText);
- if (accepted) {
- if (name.empty()) {
- OBSMessageBox::warning(this,
- QTStr("NoNameEntered.Title"),
- QTStr("NoNameEntered.Text"));
- RenameTransition();
- return;
- }
+ if (!accepted)
+ return;
+ if (name.empty()) {
+ OBSMessageBox::warning(this, QTStr("NoNameEntered.Title"),
+ QTStr("NoNameEntered.Text"));
+ RenameTransition();
+ return;
+ }
- source = FindTransition(name.c_str());
- if (source) {
- OBSMessageBox::warning(this, QTStr("NameExists.Title"),
- QTStr("NameExists.Text"));
+ source = FindTransition(name.c_str());
+ if (source) {
+ OBSMessageBox::warning(this, QTStr("NameExists.Title"),
+ QTStr("NameExists.Text"));
- RenameTransition();
- return;
- }
+ RenameTransition();
+ return;
+ }
- obs_source_set_name(transition, name.c_str());
- int idx = ui->transitions->findData(variant);
- if (idx != -1) {
- ui->transitions->setItemText(idx,
- QT_UTF8(name.c_str()));
+ obs_source_set_name(transition, name.c_str());
+ int idx = ui->transitions->findData(variant);
+ if (idx != -1) {
+ ui->transitions->setItemText(idx, QT_UTF8(name.c_str()));
- if (api)
- api->on_event(
- OBS_FRONTEND_EVENT_TRANSITION_LIST_CHANGED);
+ if (api)
+ api->on_event(
+ OBS_FRONTEND_EVENT_TRANSITION_LIST_CHANGED);
- ClearQuickTransitionWidgets();
- RefreshQuickTransitions();
- }
+ ClearQuickTransitionWidgets();
+ RefreshQuickTransitions();
}
}
diff --git a/UI/window-namedialog.cpp b/UI/window-namedialog.cpp
index 395e659d3..a9d69d340 100644
--- a/UI/window-namedialog.cpp
+++ b/UI/window-namedialog.cpp
@@ -17,17 +17,37 @@
#include "window-namedialog.hpp"
#include "qt-wrappers.hpp"
-#include "ui_NameDialog.h"
#include "obs-app.hpp"
-using namespace std;
+#include
-NameDialog::NameDialog(QWidget *parent)
- : QDialog(parent), ui(new Ui::NameDialog)
+NameDialog::NameDialog(QWidget *parent) : QDialog(parent)
{
- ui->setupUi(this);
-
installEventFilter(CreateShortcutFilter());
+ setModal(true);
+ setWindowModality(Qt::WindowModality::WindowModal);
+ setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
+ setFixedWidth(555);
+ setMinimumHeight(100);
+ QVBoxLayout *layout = new QVBoxLayout;
+ setLayout(layout);
+
+ label = new QLabel(this);
+ layout->addWidget(label);
+ label->setText("Set Text");
+
+ userText = new QLineEdit(this);
+ layout->addWidget(userText);
+
+ checkbox = new QCheckBox(this);
+ layout->addWidget(checkbox);
+
+ QDialogButtonBox *buttonbox = new QDialogButtonBox(
+ QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ layout->addWidget(buttonbox);
+ buttonbox->setCenterButtons(true);
+ connect(buttonbox, &QDialogButtonBox::accepted, this, &QDialog::accept);
+ connect(buttonbox, &QDialogButtonBox::rejected, this, &QDialog::reject);
}
static bool IsWhitespace(char ch)
@@ -35,8 +55,16 @@ static bool IsWhitespace(char ch)
return ch == ' ' || ch == '\t';
}
+static void CleanWhitespace(std::string &str)
+{
+ while (str.size() && IsWhitespace(str.back()))
+ str.erase(str.end() - 1);
+ while (str.size() && IsWhitespace(str.front()))
+ str.erase(str.begin());
+}
+
bool NameDialog::AskForName(QWidget *parent, const QString &title,
- const QString &text, string &str,
+ const QString &text, std::string &userTextInput,
const QString &placeHolder, int maxSize)
{
if (maxSize <= 0 || maxSize > 32767)
@@ -44,22 +72,43 @@ bool NameDialog::AskForName(QWidget *parent, const QString &title,
NameDialog dialog(parent);
dialog.setWindowTitle(title);
- dialog.setWindowFlags(dialog.windowFlags() &
- ~Qt::WindowContextHelpButtonHint);
- dialog.ui->label->setText(text);
- dialog.ui->userText->setMaxLength(maxSize);
- dialog.ui->userText->setText(placeHolder);
- dialog.ui->userText->selectAll();
- bool accepted = (dialog.exec() == DialogCode::Accepted);
- if (accepted) {
- str = QT_TO_UTF8(dialog.ui->userText->text());
+ dialog.checkbox->setHidden(true);
+ dialog.label->setText(text);
+ dialog.userText->setMaxLength(maxSize);
+ dialog.userText->setText(placeHolder);
+ dialog.userText->selectAll();
- while (str.size() && IsWhitespace(str.back()))
- str.erase(str.end() - 1);
- while (str.size() && IsWhitespace(str.front()))
- str.erase(str.begin());
+ if (dialog.exec() != DialogCode::Accepted) {
+ return false;
+ }
+ userTextInput = dialog.userText->text().toUtf8().constData();
+ CleanWhitespace(userTextInput);
+ return true;
+}
+
+bool NameDialog::AskForNameWithOption(QWidget *parent, const QString &title,
+ const QString &text,
+ std::string &userTextInput,
+ const QString &optionLabel,
+ bool &optionChecked,
+ const QString &placeHolder)
+{
+ NameDialog dialog(parent);
+ dialog.setWindowTitle(title);
+
+ dialog.label->setText(text);
+ dialog.userText->setMaxLength(170);
+ dialog.userText->setText(placeHolder);
+ dialog.checkbox->setText(optionLabel);
+ dialog.checkbox->setChecked(optionChecked);
+
+ if (dialog.exec() != DialogCode::Accepted) {
+ return false;
}
- return accepted;
+ userTextInput = dialog.userText->text().toUtf8().constData();
+ CleanWhitespace(userTextInput);
+ optionChecked = dialog.checkbox->isChecked();
+ return true;
}
diff --git a/UI/window-namedialog.hpp b/UI/window-namedialog.hpp
index 0b33da22d..14e9fed71 100644
--- a/UI/window-namedialog.hpp
+++ b/UI/window-namedialog.hpp
@@ -18,22 +18,37 @@
#pragma once
#include
+#include
+#include
+#include
+#include
#include
#include
-#include "ui_NameDialog.h"
-
class NameDialog : public QDialog {
Q_OBJECT
-private:
- std::unique_ptr ui;
-
public:
NameDialog(QWidget *parent);
+ // Returns true if user clicks OK, false otherwise
+ // userTextInput returns string that user typed into dialog
static bool AskForName(QWidget *parent, const QString &title,
- const QString &text, std::string &str,
+ const QString &text, std::string &userTextInput,
const QString &placeHolder = QString(""),
int maxSize = 170);
+
+ // Returns true if user clicks OK, false otherwise
+ // userTextInput returns string that user typed into dialog
+ // userOptionReturn the checkbox was ticked user accepted
+ static bool
+ AskForNameWithOption(QWidget *parent, const QString &title,
+ const QString &text, std::string &userTextInput,
+ const QString &optionLabel, bool &optionChecked,
+ const QString &placeHolder = QString(""));
+
+private:
+ QLabel *label;
+ QLineEdit *userText;
+ QCheckBox *checkbox;
};