diff --git a/config-dialog.cpp b/config-dialog.cpp index db7e657..640beb5 100644 --- a/config-dialog.cpp +++ b/config-dialog.cpp @@ -50,11 +50,11 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent) setMinimumHeight(480); setWindowTitle(obs_module_text("AitumMultistreamSettings")); setSizeGripEnabled(true); - + const auto main_window = static_cast(obs_frontend_get_main_window()); - + listWidget = new QListWidget(this); - + listWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); listWidget->setMaximumWidth(180); QListWidgetItem *listwidgetitem = new QListWidgetItem(listWidget); @@ -62,115 +62,114 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent) //listwidgetitem->setProperty("themeID", QVariant(QString::fromUtf8("configIconSmall"))); //cogsIcon listwidgetitem->setText(QString::fromUtf8(obs_module_text("General"))); - + listwidgetitem = new QListWidgetItem(listWidget); listwidgetitem->setIcon(QIcon(QString::fromUtf8(":/settings/images/settings/stream.svg"))); listwidgetitem->setText(QString::fromUtf8(obs_module_text("MainCanvas"))); - + listwidgetitem = new QListWidgetItem(listWidget); listwidgetitem->setIcon(QIcon(QString::fromUtf8(":/settings/images/settings/stream.svg"))); listwidgetitem->setText(QString::fromUtf8(obs_module_text("VerticalCanvas"))); - + listwidgetitem = new QListWidgetItem(listWidget); listwidgetitem->setIcon(main_window->property("defaultIcon").value()); listwidgetitem->setText(QString::fromUtf8(obs_module_text("SetupTroubleshooter"))); listwidgetitem->setHidden(true); - + listwidgetitem = new QListWidgetItem(listWidget); listwidgetitem->setIcon(main_window->property("defaultIcon").value()); listwidgetitem->setText(QString::fromUtf8(obs_module_text("Help"))); - + listwidgetitem = new QListWidgetItem(listWidget); listwidgetitem->setIcon(QIcon(QString::fromUtf8(":/aitum/media/aitum.png"))); listwidgetitem->setText(QString::fromUtf8(obs_module_text("SupportButton"))); - + listWidget->setCurrentRow(0); listWidget->setSpacing(1); - + auto settingsPages = new QStackedWidget; settingsPages->setContentsMargins(0, 0, 0, 0); settingsPages->setFrameShape(QFrame::NoFrame); settingsPages->setLineWidth(0); - + QWidget *generalPage = new QWidget; auto generalPageLayout = new QVBoxLayout; generalPage->setLayout(generalPageLayout); - + auto infoBox = ConfigUtils::generateSettingsGroupBox(QString::fromUtf8(obs_module_text("WelcomeTitle"))); infoBox->setStyleSheet("padding-top: 12px"); auto infoLayout = new QVBoxLayout; infoBox->setLayout(infoLayout); - + auto infoLabel = new QLabel(QString::fromUtf8(obs_module_text("WelcomeText"))); infoLabel->setWordWrap(true); infoLayout->addWidget(infoLabel, 1); - + auto buttonGroupBox = new QWidget(); auto buttonLayout = new QHBoxLayout; buttonLayout->setSpacing(8); buttonLayout->setAlignment(Qt::AlignCenter); - + generalMainButton = ConfigUtils::generateMenuButton(QString::fromUtf8(obs_module_text("SettingsMainOutputsButton")), - QIcon(QString::fromUtf8(":/settings/images/settings/stream.svg"))); + QIcon(QString::fromUtf8(":/settings/images/settings/stream.svg"))); generalVerticalButton = ConfigUtils::generateMenuButton(QString::fromUtf8(obs_module_text("SettingsVerticalOutputsButton")), - QIcon(QString::fromUtf8(":/settings/images/settings/stream.svg"))); + QIcon(QString::fromUtf8(":/settings/images/settings/stream.svg"))); generalHelpButton = ConfigUtils::generateMenuButton(QString::fromUtf8(obs_module_text("SettingsHelpButton")), - main_window->property("defaultIcon").value()); + main_window->property("defaultIcon").value()); generalSupportAitumButton = ConfigUtils::generateMenuButton(QString::fromUtf8(obs_module_text("SupportButton")), - QIcon(QString::fromUtf8(":/aitum/media/aitum.png"))); - + QIcon(QString::fromUtf8(":/aitum/media/aitum.png"))); + buttonLayout->addWidget(generalMainButton, 0); buttonLayout->addWidget(generalVerticalButton, 0); buttonLayout->addWidget(generalHelpButton, 0); buttonLayout->addWidget(generalSupportAitumButton, 0); - buttonGroupBox->setLayout(buttonLayout); - + generalPageLayout->addWidget(infoBox, 0); generalPageLayout->addWidget(buttonGroupBox, 1); - + QScrollArea *scrollArea = new QScrollArea; scrollArea->setWidget(generalPage); scrollArea->setWidgetResizable(true); scrollArea->setLineWidth(0); scrollArea->setFrameShape(QFrame::NoFrame); settingsPages->addWidget(scrollArea); - + auto mainOutputsPage = new QGroupBox; mainOutputsPage->setProperty("customTitle", QVariant(true)); mainOutputsPage->setStyleSheet(QString("QGroupBox[customTitle=\"true\"]{ padding-top: 4px;}")); mainOutputsPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); - + scrollArea = new QScrollArea; scrollArea->setWidget(mainOutputsPage); scrollArea->setWidgetResizable(true); scrollArea->setLineWidth(0); scrollArea->setFrameShape(QFrame::NoFrame); settingsPages->addWidget(scrollArea); - + auto verticalOutputsPage = new QGroupBox; verticalOutputsPage->setProperty("customTitle", QVariant(true)); verticalOutputsPage->setStyleSheet(QString("QGroupBox[customTitle=\"true\"]{ padding-top: 4px;}")); verticalOutputsPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); - + scrollArea = new QScrollArea; scrollArea->setWidget(verticalOutputsPage); scrollArea->setWidgetResizable(true); scrollArea->setLineWidth(0); scrollArea->setFrameShape(QFrame::NoFrame); settingsPages->addWidget(scrollArea); - + troubleshooterText = new QTextEdit; troubleshooterText->setReadOnly(true); - + scrollArea = new QScrollArea; scrollArea->setWidget(troubleshooterText); scrollArea->setWidgetResizable(true); scrollArea->setLineWidth(0); scrollArea->setFrameShape(QFrame::NoFrame); settingsPages->addWidget(scrollArea); - + auto helpPage = new QWidget; scrollArea = new QScrollArea; scrollArea->setWidget(helpPage); @@ -178,30 +177,30 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent) scrollArea->setLineWidth(0); scrollArea->setFrameShape(QFrame::NoFrame); settingsPages->addWidget(scrollArea); - + //mainOutputsPage - + mainOutputsLayout = new QFormLayout; mainOutputsLayout->setContentsMargins(9, 2, 9, 9); mainOutputsLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); mainOutputsLayout->setLabelAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); - + auto streaming_title_layout = new QHBoxLayout; auto streaming_title = new QLabel(QString::fromUtf8(obs_module_text("MainCanvas"))); streaming_title->setStyleSheet(QString::fromUtf8("font-weight: bold;")); streaming_title_layout->addWidget(streaming_title, 0, Qt::AlignLeft); //auto guide_link = new QLabel(QString::fromUtf8("") + QString::fromUtf8(obs_module_text("ViewGuide")) + QString::fromUtf8("")); //guide_link->setOpenExternalLinks(true); - + auto addButton = new QPushButton(QIcon(":/res/images/plus.svg"), QString::fromUtf8(obs_module_text("AddOutput"))); addButton->setProperty("themeID", QVariant(QString::fromUtf8("addIconSmall"))); - + connect(addButton, &QPushButton::clicked, [this] { auto outputDialog = new OutputDialog(this); - + outputDialog->setWindowModality(Qt::WindowModal); outputDialog->setModal(true); - + if (outputDialog->exec() == QDialog::Accepted) { // create a new output if (!settings) @@ -212,55 +211,55 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent) obs_data_set_array(settings, "outputs", outputs); } auto s = obs_data_create(); - + // Set the info from the output dialog obs_data_set_string(s, "name", outputDialog->outputName.toUtf8().constData()); obs_data_set_string(s, "stream_server", outputDialog->outputServer.toUtf8().constData()); obs_data_set_string(s, "stream_key", outputDialog->outputKey.toUtf8().constData()); - + obs_data_array_push_back(outputs, s); AddServer(mainOutputsLayout, s, outputs); obs_data_array_release(outputs); obs_data_release(s); } - + delete outputDialog; }); - + //streaming_title_layout->addWidget(guide_link, 0, Qt::AlignRight); streaming_title_layout->addWidget(addButton, 0, Qt::AlignRight); - + mainOutputsLayout->addRow(streaming_title_layout); - + auto serverGroup = new QGroupBox; serverGroup->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); serverGroup->setStyleSheet(QString("QGroupBox{background-color: %1; padding-top: 4px;}") - .arg(palette().color(QPalette::ColorRole::Mid).name(QColor::HexRgb))); - + .arg(palette().color(QPalette::ColorRole::Mid).name(QColor::HexRgb))); + auto serverLayout = new QFormLayout; serverLayout->setContentsMargins(9, 2, 9, 9); serverLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); serverLayout->setLabelAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); - + auto mainTitle = new QLabel(QString::fromUtf8(obs_module_text("SettingsMainCanvasTitle"))); mainTitle->setStyleSheet("font-weight: bold;"); serverLayout->addRow(mainTitle); - + auto mainDescription = new QLabel(QString::fromUtf8(obs_module_text("SettingsMainCanvasDescription"))); // mainTitle->setStyleSheet(QString::fromUtf8("font-weight: bold;")); serverLayout->addRow(mainDescription); - + serverGroup->setLayout(serverLayout); - + mainOutputsLayout->addRow(serverGroup); - + mainOutputsPage->setLayout(mainOutputsLayout); - + verticalOutputsLayout = new QFormLayout; verticalOutputsLayout->setContentsMargins(9, 2, 9, 9); verticalOutputsLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); verticalOutputsLayout->setLabelAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); - + streaming_title_layout = new QHBoxLayout; streaming_title = new QLabel(QString::fromUtf8(obs_module_text("VerticalCanvas"))); streaming_title->setStyleSheet(QString::fromUtf8("font-weight: bold;")); @@ -278,16 +277,16 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent) // AddServer(verticalOutputsLayout, s); // obs_data_release(s); // }); - + verticalAddButton = new QPushButton(QIcon(":/res/images/plus.svg"), QString::fromUtf8(obs_module_text("AddOutput"))); verticalAddButton->setProperty("themeID", QVariant(QString::fromUtf8("addIconSmall"))); - + connect(verticalAddButton, &QPushButton::clicked, [this] { auto outputDialog = new OutputDialog(this); - + outputDialog->setWindowModality(Qt::WindowModal); outputDialog->setModal(true); - + if (outputDialog->exec() == QDialog::Accepted) { // create a new output if (!vertical_outputs) @@ -300,26 +299,26 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent) AddServer(verticalOutputsLayout, s, vertical_outputs); obs_data_release(s); } - + delete outputDialog; }); - + streaming_title_layout->addWidget(verticalAddButton, 0, Qt::AlignRight); - + verticalOutputsLayout->addRow(streaming_title_layout); - + verticalOutputsPage->setLayout(verticalOutputsLayout); - + // Support page QWidget *supportPage = new QWidget; auto supportPageLayout = new QVBoxLayout; supportPage->setLayout(supportPageLayout); - + auto supportInfoBox = ConfigUtils::generateSettingsGroupBox(QString::fromUtf8(obs_module_text("SupportTitle"))); supportInfoBox->setStyleSheet("padding-top: 12px"); auto supportLayout = new QVBoxLayout; supportInfoBox->setLayout(supportLayout); - + auto supportLabel = new QLabel(QString::fromUtf8(obs_module_text("SupportText"))); supportLabel->setStyleSheet("font-size: 14px"); supportLabel->setWordWrap(true); @@ -327,55 +326,54 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent) supportLabel->setOpenExternalLinks(true); supportLayout->addWidget(supportLabel, 1); supportPageLayout->addWidget(supportInfoBox, 1, Qt::AlignTop); - + settingsPages->addWidget(supportPage); - + /// const auto version = new QLabel(QString::fromUtf8(obs_module_text("Version")) + " " + QString::fromUtf8(PROJECT_VERSION) + " " + QString::fromUtf8(obs_module_text("MadeBy")) + " Aitum"); version->setOpenExternalLinks(true); version->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); - + newVersion = new QLabel; newVersion->setProperty("themeID", "warning"); newVersion->setVisible(false); newVersion->setOpenExternalLinks(true); newVersion->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); - + auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); - + QHBoxLayout *bottomLayout = new QHBoxLayout; bottomLayout->addWidget(version, 1, Qt::AlignLeft); bottomLayout->addWidget(newVersion, 1, Qt::AlignLeft); bottomLayout->addWidget(buttonBox, 0, Qt::AlignRight); - + QHBoxLayout *contentLayout = new QHBoxLayout; contentLayout->addWidget(listWidget); - + contentLayout->addWidget(settingsPages, 1); - + listWidget->connect(listWidget, &QListWidget::currentRowChanged, settingsPages, &QStackedWidget::setCurrentIndex); listWidget->setCurrentRow(0); - + QVBoxLayout *vlayout = new QVBoxLayout; vlayout->setContentsMargins(11, 11, 11, 11); vlayout->addLayout(contentLayout); vlayout->addLayout(bottomLayout); setLayout(vlayout); - + // Button connects for general page, clean this up in the future when we abstract pages connect(generalMainButton, &QPushButton::clicked, [this] { listWidget->setCurrentRow(1); }); - - connect(generalVerticalButton, &QPushButton::clicked, [this] { listWidget->setCurrentRow(2); }); - - connect(generalHelpButton, &QPushButton::clicked, [this] { listWidget->setCurrentRow(listWidget->count() - 2); }); - - connect(generalSupportAitumButton, &QPushButton::clicked, [this] { listWidget->setCurrentRow(listWidget->count() - 1); }); + connect(generalVerticalButton, &QPushButton::clicked, [this] { listWidget->setCurrentRow(2); }); + + connect(generalHelpButton, &QPushButton::clicked, [this] { listWidget->setCurrentRow(listWidget->count() - 2); }); + + connect(generalSupportAitumButton, &QPushButton::clicked, [this] { listWidget->setCurrentRow(listWidget->count() - 1); }); } OBSBasicSettings::~OBSBasicSettings() @@ -499,10 +497,6 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting streaming_title->setStyleSheet(QString::fromUtf8("font-weight: bold;")); server_title_layout->addWidget(streaming_title, 1, Qt::AlignLeft); - // Config Button - auto configButton = new QPushButton; - configButton->setMinimumHeight(30); - // Advanced settings const bool advanced = obs_data_get_bool(settings, "advanced"); auto advancedGroup = new QGroupBox(QString::fromUtf8(obs_module_text("AdvancedGroupHeader"))); @@ -898,6 +892,7 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting // Reload LoadSettings(this->settings); + LoadVerticalSettings(false); } delete outputDialog; @@ -917,26 +912,28 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting outputsLayout->addRow(serverGroup); } -void OBSBasicSettings::LoadVerticalSettings() +void OBSBasicSettings::LoadVerticalSettings(bool load) { - while (verticalOutputsLayout->rowCount() > 1) { auto i = verticalOutputsLayout->takeRow(1).fieldItem; RemoveLayoutItem(i); verticalOutputsLayout->removeRow(1); } - auto ph = obs_get_proc_handler(); - struct calldata cd; - calldata_init(&cd); - if (!proc_handler_call(ph, "aitum_vertical_get_stream_settings", &cd)) { - // Disable button if we don't have vertical - verticalAddButton->setEnabled(false); + if (load) { + auto ph = obs_get_proc_handler(); + struct calldata cd; + calldata_init(&cd); + if (!proc_handler_call(ph, "aitum_vertical_get_stream_settings", &cd)) { + // Disable button if we don't have vertical + verticalAddButton->setEnabled(false); + calldata_free(&cd); + return; + } + if (vertical_outputs) + obs_data_array_release(vertical_outputs); + vertical_outputs = (obs_data_array_t *)calldata_ptr(&cd, "outputs"); calldata_free(&cd); - return; } - if (vertical_outputs) - obs_data_array_release(vertical_outputs); - vertical_outputs = (obs_data_array_t *)calldata_ptr(&cd, "outputs"); obs_data_array_enum( vertical_outputs, [](obs_data_t *data, void *param) { @@ -944,7 +941,6 @@ void OBSBasicSettings::LoadVerticalSettings() d->AddServer(d->verticalOutputsLayout, data, d->vertical_outputs); }, this); - calldata_free(&cd); } void OBSBasicSettings::SaveVerticalSettings() diff --git a/config-dialog.hpp b/config-dialog.hpp index 96b4c0c..4e15a64 100644 --- a/config-dialog.hpp +++ b/config-dialog.hpp @@ -75,7 +75,7 @@ public: ~OBSBasicSettings(); void LoadSettings(obs_data_t *settings); - void LoadVerticalSettings(); + void LoadVerticalSettings(bool load); void SaveVerticalSettings(); void LoadOutputStats(std::vector *oldVideos); void SetNewerVersion(QString newer_version_available); diff --git a/multistream.cpp b/multistream.cpp index 9f75f1e..0233f8f 100644 --- a/multistream.cpp +++ b/multistream.cpp @@ -288,7 +288,7 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent) if (current_config) obs_data_apply(settings, current_config); configDialog->LoadSettings(settings); - configDialog->LoadVerticalSettings(); + configDialog->LoadVerticalSettings(true); configDialog->LoadOutputStats(&oldVideo); configDialog->SetNewerVersion(newer_version_available); configDialog->setResult(QDialog::Rejected);