From 5a409347d5bf7dec50c41641660a131c265fb4ad Mon Sep 17 00:00:00 2001 From: tytan652 Date: Wed, 21 Sep 2022 07:53:47 +0200 Subject: [PATCH] UI: Refactor Qt slots in stream settings page --- UI/window-basic-settings-stream.cpp | 81 ++++++++++++++--------------- UI/window-basic-settings.hpp | 13 +++-- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/UI/window-basic-settings-stream.cpp b/UI/window-basic-settings-stream.cpp index f691baefce4f47..6dd8ecdbd9d615 100644 --- a/UI/window-basic-settings-stream.cpp +++ b/UI/window-basic-settings-stream.cpp @@ -78,29 +78,10 @@ void OBSBasicSettings::InitStreamPage() ui->twitchAddonDropdown->addItem( QTStr("Basic.Settings.Stream.TTVAddon.Both")); - connect(ui->service, SIGNAL(currentIndexChanged(int)), this, - SLOT(UpdateServerList())); - connect(ui->service, SIGNAL(currentIndexChanged(int)), this, - SLOT(UpdateKeyLink())); - connect(ui->service, SIGNAL(currentIndexChanged(int)), this, - SLOT(UpdateVodTrackSetting())); - connect(ui->service, SIGNAL(currentIndexChanged(int)), this, - SLOT(UpdateServiceRecommendations())); - connect(ui->service, SIGNAL(currentIndexChanged(int)), this, - SLOT(UpdateResFPSLimits())); - connect(ui->customServer, SIGNAL(textChanged(const QString &)), this, - SLOT(UpdateKeyLink())); connect(ui->ignoreRecommended, SIGNAL(clicked(bool)), this, SLOT(DisplayEnforceWarning(bool))); connect(ui->ignoreRecommended, SIGNAL(toggled(bool)), this, SLOT(UpdateResFPSLimits())); - connect(ui->service, SIGNAL(currentIndexChanged(int)), this, - SLOT(UpdateMoreInfoLink())); - - connect(ui->service, SIGNAL(currentIndexChanged(int)), this, - SLOT(UpdateAdvNetworkGroup())); - connect(ui->customServer, SIGNAL(textChanged(const QString &)), this, - SLOT(UpdateAdvNetworkGroup())); } void OBSBasicSettings::LoadStream1Settings() @@ -458,13 +439,37 @@ void OBSBasicSettings::UseStreamKeyAdvClicked() ui->streamKeyWidget->setVisible(true); } -void OBSBasicSettings::on_service_currentIndexChanged(int) +void OBSBasicSettings::on_service_currentIndexChanged(int idx) { - bool showMore = ui->service->currentData().toInt() == - (int)ListOpt::ShowAll; - if (showMore) + if (ui->service->currentData().toInt() == (int)ListOpt::ShowAll) { + LoadServices(true); + ui->service->showPopup(); return; + } + + ServiceChanged(); + + UpdateMoreInfoLink(); + UpdateServerList(); + UpdateKeyLink(); + UpdateServiceRecommendations(); + + UpdateVodTrackSetting(); + UpdateAdvNetworkGroup(); + + if (ServiceSupportsCodecCheck() && UpdateResFPSLimits()) + lastServiceIdx = idx; +} +void OBSBasicSettings::on_customServer_textChanged(const QString &) +{ + UpdateKeyLink(); + + UpdateAdvNetworkGroup(); +} + +void OBSBasicSettings::ServiceChanged() +{ std::string service = QT_TO_UTF8(ui->service->currentText()); bool custom = IsCustomService(); @@ -518,16 +523,8 @@ void OBSBasicSettings::on_service_currentIndexChanged(int) void OBSBasicSettings::UpdateServerList() { QString serviceName = ui->service->currentText(); - bool showMore = ui->service->currentData().toInt() == - (int)ListOpt::ShowAll; - if (showMore) { - LoadServices(true); - ui->service->showPopup(); - return; - } else { - lastService = serviceName; - } + lastService = serviceName; obs_properties_t *props = obs_get_service_properties("rtmp_common"); obs_property_t *services = obs_properties_get(props, "service"); @@ -985,17 +982,14 @@ extern void set_closest_res(int &cx, int &cy, * which as of this writing, and hopefully for the foreseeable future, there is * only one. */ -void OBSBasicSettings::UpdateResFPSLimits() +bool OBSBasicSettings::UpdateResFPSLimits() { if (loading) - return; - - if (!ServiceSupportsCodecCheck()) - return; + return false; int idx = ui->service->currentIndex(); if (idx == -1) - return; + return false; bool ignoreRecommended = ui->ignoreRecommended->isChecked(); BPtr res_list; @@ -1073,8 +1067,7 @@ void OBSBasicSettings::UpdateResFPSLimits() ui->ignoreRecommended->setProperty("changed", true); stream1Changed = true; EnableApplyButton(true); - UpdateResFPSLimits(); - return; + return UpdateResFPSLimits(); } QMessageBox::StandardButton button; @@ -1106,7 +1099,7 @@ void OBSBasicSettings::UpdateResFPSLimits() "setChecked", Qt::QueuedConnection, Q_ARG(bool, true)); - return; + return false; } } @@ -1187,7 +1180,8 @@ void OBSBasicSettings::UpdateResFPSLimits() /* ------------------------------------ */ lastIgnoreRecommended = (int)ignoreRecommended; - lastServiceIdx = idx; + + return true; } bool OBSBasicSettings::IsServiceOutputHasNetworkFeatures() @@ -1287,6 +1281,9 @@ static QString get_simple_fallback(const QString &enc) bool OBSBasicSettings::ServiceSupportsCodecCheck() { + if (loading) + return false; + if (ServiceAndCodecCompatible()) { if (lastServiceIdx != ui->service->currentIndex()) ResetEncoders(true); diff --git a/UI/window-basic-settings.hpp b/UI/window-basic-settings.hpp index 51f00336f8e98c..7c2a9e2b0a793c 100644 --- a/UI/window-basic-settings.hpp +++ b/UI/window-basic-settings.hpp @@ -263,14 +263,18 @@ class OBSBasicSettings : public QDialog { QString lastService; int prevLangIndex; bool prevBrowserAccel; -private slots: + + void ServiceChanged(); void UpdateServerList(); void UpdateKeyLink(); void UpdateVodTrackSetting(); void UpdateServiceRecommendations(); - void RecreateOutputResolutionWidget(); - void UpdateResFPSLimits(); void UpdateMoreInfoLink(); + void UpdateAdvNetworkGroup(); + +private slots: + void RecreateOutputResolutionWidget(); + bool UpdateResFPSLimits(); void DisplayEnforceWarning(bool checked); void on_show_clicked(); void on_authPwShow_clicked(); @@ -382,6 +386,7 @@ private slots: void on_buttonBox_clicked(QAbstractButton *button); void on_service_currentIndexChanged(int idx); + void on_customServer_textChanged(const QString &text); void on_simpleOutputBrowse_clicked(); void on_advOutRecPathBrowse_clicked(); void on_advOutFFPathBrowse_clicked(); @@ -435,8 +440,6 @@ private slots: void UpdateStreamDelayEstimate(); - void UpdateAdvNetworkGroup(); - void UpdateAutomaticReplayBufferCheckboxes(); void AdvOutSplitFileChanged();