UI: Run Autoconfig Wizard on New Profile Creation
New profile state is similar to first start: settings are wiped, encoders not setup. It may make sense to show the auto configuration wizard when a new profile is made as well. There is a checkbox option to show the wizard. If a profile is created with the checkbox off, the checkbox will remain defaulted to off next prompt.master
parent
c16517ca83
commit
ade4c4cf49
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NameDialog</class>
|
||||
<widget class="QDialog" name="NameDialog">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::WindowModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>555</width>
|
||||
<height>102</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="userText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>NameDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>257</x>
|
||||
<y>94</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>NameDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>325</x>
|
||||
<y>94</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -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",
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QVariant>
|
||||
#include <QFileDialog>
|
||||
#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);
|
||||
|
|
|
@ -617,10 +617,10 @@ void OBSBasic::RenameTransition()
|
|||
QTStr("TransitionNameDlg.Text"),
|
||||
name, placeHolderText);
|
||||
|
||||
if (accepted) {
|
||||
if (!accepted)
|
||||
return;
|
||||
if (name.empty()) {
|
||||
OBSMessageBox::warning(this,
|
||||
QTStr("NoNameEntered.Title"),
|
||||
OBSMessageBox::warning(this, QTStr("NoNameEntered.Title"),
|
||||
QTStr("NoNameEntered.Text"));
|
||||
RenameTransition();
|
||||
return;
|
||||
|
@ -638,8 +638,7 @@ void OBSBasic::RenameTransition()
|
|||
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()));
|
||||
ui->transitions->setItemText(idx, QT_UTF8(name.c_str()));
|
||||
|
||||
if (api)
|
||||
api->on_event(
|
||||
|
@ -649,7 +648,6 @@ void OBSBasic::RenameTransition()
|
|||
RefreshQuickTransitions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OBSBasic::on_transitionProps_clicked()
|
||||
{
|
||||
|
|
|
@ -17,17 +17,37 @@
|
|||
|
||||
#include "window-namedialog.hpp"
|
||||
#include "qt-wrappers.hpp"
|
||||
#include "ui_NameDialog.h"
|
||||
#include "obs-app.hpp"
|
||||
|
||||
using namespace std;
|
||||
#include <QVBoxLayout>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return accepted;
|
||||
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;
|
||||
}
|
||||
|
||||
userTextInput = dialog.userText->text().toUtf8().constData();
|
||||
CleanWhitespace(userTextInput);
|
||||
optionChecked = dialog.checkbox->isChecked();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -18,22 +18,37 @@
|
|||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QCheckBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include "ui_NameDialog.h"
|
||||
|
||||
class NameDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::NameDialog> 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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue