diff --git a/output-dialog.cpp b/output-dialog.cpp index 95fc50c..af0aee0 100644 --- a/output-dialog.cpp +++ b/output-dialog.cpp @@ -93,17 +93,11 @@ QLineEdit *OutputDialog::generateOutputServerField(QPushButton *confirmButton, b } // Helper for generating QComboBoxes for server selection -QComboBox *OutputDialog::generateOutputServerCombo(std::string service, QPushButton *confirmButton) { +QComboBox *OutputDialog::generateOutputServerCombo(std::string service, QPushButton *confirmButton, bool edit) { auto combo = new QComboBox; combo->setMinimumHeight(30); combo->setStyleSheet("padding: 4px 8px;"); - connect(combo, &QComboBox::currentIndexChanged, [this, combo, confirmButton] { - outputServer = combo->currentData().toString(); - validateOutputs(confirmButton); - }); - - auto rawOptions = getService(service); // turn raw options into actual selectable options @@ -117,8 +111,24 @@ QComboBox *OutputDialog::generateOutputServerCombo(std::string service, QPushBut } } + // If we're edit, look up the current value for outputServer and try to set the index + if (edit) { + auto selectionIndex = combo->findData(outputServer); +// blog(LOG_WARNING, "[Aitum Multistream] edit selection %i for value %s", selectionIndex, outputServer.toStdString().c_str()); + if (selectionIndex != -1) { + combo->setCurrentIndex(selectionIndex); + } + + } + + // Hook event up after + connect(combo, &QComboBox::currentIndexChanged, [this, combo, confirmButton] { + outputServer = combo->currentData().toString(); + validateOutputs(confirmButton); + }); + // Set default value for server - outputServer = combo->currentData().toString(); + // outputServer = combo->currentData().toString(); return combo; } @@ -525,12 +535,6 @@ QWidget *OutputDialog::WizardInfoYouTube(bool edit) { // Edit changes if (edit) { outputNameField->setText(outputName); - - auto selectionIndex = serverSelection->findData(outputServer); - if (selectionIndex != -1) { - serverSelection->setCurrentIndex(selectionIndex); - } - outputKeyField->setText(outputKey); } @@ -630,12 +634,6 @@ QWidget *OutputDialog::WizardInfoTwitter(bool edit) { // Edit changes if (edit) { outputNameField->setText(outputName); - - auto selectionIndex = serverSelection->findData(outputServer); - if (selectionIndex != -1) { - serverSelection->setCurrentIndex(selectionIndex); - } - outputKeyField->setText(outputKey); } @@ -773,7 +771,7 @@ QWidget *OutputDialog::WizardInfoTwitch(bool edit) { formLayout->addRow(generateFormLabel("OutputName"), outputNameField); // Server selection - auto serverSelection = generateOutputServerCombo("Twitch", confirmButton); + auto serverSelection = generateOutputServerCombo("Twitch", confirmButton, edit); formLayout->addRow(generateFormLabel("TwitchServer"), serverSelection); // Server info @@ -838,12 +836,6 @@ QWidget *OutputDialog::WizardInfoTwitch(bool edit) { // Edit changes if (edit) { outputNameField->setText(outputName); - - auto selectionIndex = serverSelection->findData(outputServer); - if (selectionIndex != -1) { - serverSelection->setCurrentIndex(selectionIndex); - } - outputKeyField->setText(outputKey); } diff --git a/output-dialog.hpp b/output-dialog.hpp index 2623953..2d59c0e 100644 --- a/output-dialog.hpp +++ b/output-dialog.hpp @@ -45,7 +45,7 @@ private: // Generators QLineEdit *generateOutputNameField(std::string text, QPushButton *confirmButton); QLineEdit *generateOutputServerField(QPushButton *confirmButton, bool locked); - QComboBox *generateOutputServerCombo(std::string service, QPushButton *confirmButton); + QComboBox *generateOutputServerCombo(std::string service, QPushButton *confirmButton, bool edit = false); QLineEdit *generateOutputKeyField(QPushButton *confirmButton); obs_data_t *getService(std::string serviceName);