mirror of
https://github.com/Aitum/obs-aitum-multistream.git
synced 2024-11-23 19:02:59 +01:00
Validate output name unique
This commit is contained in:
parent
bf56b6f853
commit
6c4d065cb3
@ -196,7 +196,19 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent)
|
||||
addButton->setProperty("themeID", QVariant(QString::fromUtf8("addIconSmall")));
|
||||
|
||||
connect(addButton, &QPushButton::clicked, [this] {
|
||||
auto outputDialog = new OutputDialog(this);
|
||||
QStringList otherNames;
|
||||
auto outputs = obs_data_get_array(settings, "outputs");
|
||||
obs_data_array_enum(
|
||||
outputs,
|
||||
[](obs_data_t *data, void *param) {
|
||||
auto otherNames = (QStringList *)param;
|
||||
otherNames->append(QString::fromUtf8(obs_data_get_string(data, "name")));
|
||||
},
|
||||
&otherNames);
|
||||
obs_data_array_release(outputs);
|
||||
otherNames.removeDuplicates();
|
||||
otherNames.removeOne(QString::fromUtf8(obs_data_get_string(settings, "name")));
|
||||
auto outputDialog = new OutputDialog(this, otherNames);
|
||||
|
||||
outputDialog->setWindowModality(Qt::WindowModal);
|
||||
outputDialog->setModal(true);
|
||||
@ -282,7 +294,17 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent)
|
||||
verticalAddButton->setProperty("themeID", QVariant(QString::fromUtf8("addIconSmall")));
|
||||
|
||||
connect(verticalAddButton, &QPushButton::clicked, [this] {
|
||||
auto outputDialog = new OutputDialog(this);
|
||||
QStringList otherNames;
|
||||
obs_data_array_enum(
|
||||
vertical_outputs,
|
||||
[](obs_data_t *data, void *param) {
|
||||
auto otherNames = (QStringList *)param;
|
||||
otherNames->append(QString::fromUtf8(obs_data_get_string(data, "name")));
|
||||
},
|
||||
&otherNames);
|
||||
otherNames.removeDuplicates();
|
||||
otherNames.removeOne(QString::fromUtf8(obs_data_get_string(settings, "name")));
|
||||
auto outputDialog = new OutputDialog(this, otherNames);
|
||||
|
||||
outputDialog->setWindowModality(Qt::WindowModal);
|
||||
outputDialog->setModal(true);
|
||||
@ -875,10 +897,20 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
|
||||
auto editButton = new QPushButton(QString::fromUtf8(obs_module_text("EditServerSettings")));
|
||||
editButton->setProperty("themeID", "configIconSmall");
|
||||
|
||||
connect(editButton, &QPushButton::clicked, [this, settings] {
|
||||
connect(editButton, &QPushButton::clicked, [this, settings, outputs] {
|
||||
QStringList otherNames;
|
||||
obs_data_array_enum(
|
||||
outputs,
|
||||
[](obs_data_t *data, void *param) {
|
||||
auto otherNames = (QStringList *)param;
|
||||
otherNames->append(QString::fromUtf8(obs_data_get_string(data, "name")));
|
||||
},
|
||||
&otherNames);
|
||||
otherNames.removeDuplicates();
|
||||
otherNames.removeOne(QString::fromUtf8(obs_data_get_string(settings, "name")));
|
||||
auto outputDialog = new OutputDialog(this, obs_data_get_string(settings, "name"),
|
||||
obs_data_get_string(settings, "stream_server"),
|
||||
obs_data_get_string(settings, "stream_key"));
|
||||
obs_data_get_string(settings, "stream_key"), otherNames);
|
||||
|
||||
outputDialog->setWindowModality(Qt::WindowModal);
|
||||
outputDialog->setModal(true);
|
||||
|
@ -55,7 +55,6 @@ bool version_info_downloaded(void *param, struct file_download_data *file)
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
//return true;
|
||||
blog(LOG_INFO, "[Aitum-Multistream] loaded version %s", PROJECT_VERSION);
|
||||
|
||||
const auto main_window = static_cast<QMainWindow *>(obs_frontend_get_main_window());
|
||||
|
@ -33,7 +33,7 @@ void OutputDialog::acceptOutputs()
|
||||
void OutputDialog::validateOutputs(QPushButton *confirmButton)
|
||||
{
|
||||
|
||||
if (outputName.isEmpty()) {
|
||||
if (outputName.isEmpty() || otherNames.contains(outputName)) {
|
||||
confirmButton->setEnabled(false);
|
||||
} else if (outputServer.isEmpty()) {
|
||||
confirmButton->setEnabled(false);
|
||||
@ -241,7 +241,7 @@ obs_data_t *OutputDialog::getService(std::string serviceName)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
OutputDialog::OutputDialog(QDialog *parent) : QDialog(parent)
|
||||
OutputDialog::OutputDialog(QDialog *parent, QStringList _otherNames) : QDialog(parent), otherNames(_otherNames)
|
||||
{
|
||||
// Load the services from rtmp-services plugin
|
||||
auto servicesPath = obs_module_get_config_path(obs_get_module("rtmp-services"), "services.json");
|
||||
@ -293,7 +293,9 @@ OutputDialog::OutputDialog(QDialog *parent) : QDialog(parent)
|
||||
}
|
||||
|
||||
// Edit mode
|
||||
OutputDialog::OutputDialog(QDialog *parent, QString name, QString server, QString key) : QDialog(parent)
|
||||
OutputDialog::OutputDialog(QDialog *parent, QString name, QString server, QString key, QStringList _otherNames)
|
||||
: QDialog(parent),
|
||||
otherNames(_otherNames)
|
||||
{
|
||||
|
||||
// Load the services from rtmp-services plugin
|
||||
|
@ -54,10 +54,11 @@ private:
|
||||
obs_data_t *getService(std::string serviceName);
|
||||
|
||||
QStackedWidget *stackedWidget;
|
||||
QStringList otherNames;
|
||||
|
||||
public:
|
||||
OutputDialog(QDialog *parent);
|
||||
OutputDialog(QDialog *parent, QString name, QString server, QString key);
|
||||
OutputDialog(QDialog *parent, QStringList otherNames);
|
||||
OutputDialog(QDialog *parent, QString name, QString server, QString key, QStringList otherNames);
|
||||
|
||||
QString outputName;
|
||||
QString outputServer;
|
||||
|
Loading…
Reference in New Issue
Block a user