From a16e52a87349d708f85a9a76925dd999709c121c Mon Sep 17 00:00:00 2001 From: Johann Garces Date: Wed, 7 Oct 2020 18:58:11 -0700 Subject: [PATCH] UI: Pre-stream wizard show & hide button correctly Show pre-stream wizard only when in simple mode since it only operates on simple mode for now. Later, will look into expanding capability. Additionally, fix a bug where was making a copy of a QPair instead of creating a reference so settings were not being written. --- UI/common-settings.cpp | 2 +- UI/common-settings.hpp | 1 + UI/pre-stream-wizard/page-select-settings.cpp | 7 +--- UI/streaming-settings-util.cpp | 37 ++----------------- UI/window-basic-settings-stream.cpp | 8 +++- UI/window-basic-settings.cpp | 2 + 6 files changed, 17 insertions(+), 40 deletions(-) diff --git a/UI/common-settings.cpp b/UI/common-settings.cpp index ecfd1dc07845cd..4bd4ab6a49c22a 100644 --- a/UI/common-settings.cpp +++ b/UI/common-settings.cpp @@ -2,7 +2,7 @@ #include "audio-encoders.hpp" -static bool IsAdvancedMode(config_t *config) +bool CommonSettings::IsAdvancedMode(config_t *config) { const char *outputMode = config_get_string(config, "Output", "Mode"); return (strcmp(outputMode, "Advanced") == 0); diff --git a/UI/common-settings.hpp b/UI/common-settings.hpp index 979b6f29ce6ddf..beeecf5514ed37 100644 --- a/UI/common-settings.hpp +++ b/UI/common-settings.hpp @@ -10,6 +10,7 @@ class CommonSettings { public: + static bool IsAdvancedMode(config_t *config); /* Shared Utility Functions --------------------------*/ static OBSData GetDataFromJsonFile(const char *jsonFile); diff --git a/UI/pre-stream-wizard/page-select-settings.cpp b/UI/pre-stream-wizard/page-select-settings.cpp index 383b1c5a72b8ca..fd8be3bf909d59 100644 --- a/UI/pre-stream-wizard/page-select-settings.cpp +++ b/UI/pre-stream-wizard/page-select-settings.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include @@ -167,8 +166,7 @@ void SelectionPage::setSettingsMap(QSharedPointer settingsMap) QVariant data = mapInfo->value(SettingsResponseKeys.streamBufferSize) .first; - QString bufferSizeString = - QString::number(data.toInt()) + " Kb"; + QString bufferSizeString = QString::number(data.toInt()) + "Kb"; addRow(QTStr("Basic.Settings.Output.Mode.StreamBuffer"), bufferSizeString, SettingsResponseKeys.streamBufferSize); } @@ -192,12 +190,11 @@ void SelectionPage::checkboxRowChanged(const char *propertyKey, bool selected) } SettingsMap *mapInfo = settingsMap_.data(); - if (mapInfo == nullptr || !mapInfo->contains(propertyKey)) { return; } - QPair dataPair = mapInfo->value(propertyKey); + QPair &dataPair = (*mapInfo)[propertyKey]; dataPair.second = selected; } diff --git a/UI/streaming-settings-util.cpp b/UI/streaming-settings-util.cpp index 5a598bf1f04636..4010c7bee09f3a 100644 --- a/UI/streaming-settings-util.cpp +++ b/UI/streaming-settings-util.cpp @@ -5,34 +5,6 @@ #include -/* - We are detecting the stream settings so if they're using a large canvas but - already have the rescaler on, they will be streaming correctly. -*/ -void UpdateStreamingResolution(int *resolutionXY, bool isRescaled, - config_t *config) -{ - - // If scaled, that's the stream resolution sent to servers - if (isRescaled) { - // Only use if there is a resolution in text - const char *rescaleRes = - config_get_string(config, "AdvOut", "RescaleRes"); - if (rescaleRes && *rescaleRes) { - int count = sscanf(rescaleRes, "%ux%u", - &resolutionXY[0], &resolutionXY[1]); - // If text was valid, exit - if (count == 2) { - return; - } - } - } - - // Resolution is not rescaled, use "output resolution" from video tab - resolutionXY[0] = (int)config_get_uint(config, "Video", "OutputCX"); - resolutionXY[1] = (int)config_get_uint(config, "Video", "OutputCY"); -}; - QSharedPointer StreamingSettingsUtility::makeEncoderSettingsFromCurrentState(config_t *config) { @@ -45,11 +17,10 @@ StreamingSettingsUtility::makeEncoderSettingsFromCurrentState(config_t *config) // only live and rmpts is supported for now currentSettings->protocol = StreamWizard::StreamProtocol::rtmps; /* Video */ - bool isRescaled = config_get_bool(config, "AdvOut", "Rescale"); - int resolutionXY[2] = {0, 0}; - UpdateStreamingResolution(resolutionXY, isRescaled, config); - currentSettings->videoWidth = resolutionXY[0]; - currentSettings->videoHeight = resolutionXY[1]; + currentSettings->videoWidth = + (int)config_get_uint(config, "Video", "OutputCX"); + currentSettings->videoHeight = + (int)config_get_uint(config, "Video", "OutputCY"); currentSettings->framerate = CommonSettings::GetConfigFPSDouble(config); currentSettings->videoBitrate = diff --git a/UI/window-basic-settings-stream.cpp b/UI/window-basic-settings-stream.cpp index c0b2d372f78cd5..df75849df203cf 100644 --- a/UI/window-basic-settings-stream.cpp +++ b/UI/window-basic-settings-stream.cpp @@ -249,6 +249,8 @@ void OBSBasicSettings::UpdateKeyLink() ui->getStreamKeyButton->setTargetUrl(QUrl(streamKeyLink)); ui->getStreamKeyButton->show(); } + + hasStreamWizard &= ui->outputMode->currentText().contains("Simple"); ui->settingWizardBtn->setHidden(!hasStreamWizard); } @@ -267,6 +269,9 @@ void OBSBasicSettings::preStreamWizardLaunch() return; } + // Save any changes so far since we'll refrence them from config files + SaveSettings(); + QSharedPointer currentSettings = StreamingSettingsUtility::makeEncoderSettingsFromCurrentState( main->Config()); @@ -287,10 +292,11 @@ void OBSBasicSettings::preStreamWizardApplySettings( { blog(LOG_INFO, "OBSBasicSettings::preStreamWizardApplySettings"); - // Apply and reload + // Apply StreamingSettingsUtility::applyWizardSettings(newSettings, main->Config()); + // Reload LoadSettings(false); } diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index fd0fb9b9a4d724..6aa6ecdc66c017 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -660,6 +660,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) SLOT(UpdateStreamDelayEstimate())); connect(ui->outputMode, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateStreamDelayEstimate())); + connect(ui->outputMode, SIGNAL(currentIndexChanged(int)), this, + SLOT(UpdateKeyLink())); connect(ui->simpleOutputVBitrate, SIGNAL(valueChanged(int)), this, SLOT(UpdateStreamDelayEstimate())); connect(ui->simpleOutputABitrate, SIGNAL(currentIndexChanged(int)),