Skip to content

Commit

Permalink
UI: Refactor Qt slots in stream settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
tytan652 committed Mar 19, 2023
1 parent 48dc6dd commit 5a40934
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 47 deletions.
81 changes: 39 additions & 42 deletions UI/window-basic-settings-stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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<obs_service_resolution> res_list;
Expand Down Expand Up @@ -1073,8 +1067,7 @@ void OBSBasicSettings::UpdateResFPSLimits()
ui->ignoreRecommended->setProperty("changed", true);
stream1Changed = true;
EnableApplyButton(true);
UpdateResFPSLimits();
return;
return UpdateResFPSLimits();
}

QMessageBox::StandardButton button;
Expand Down Expand Up @@ -1106,7 +1099,7 @@ void OBSBasicSettings::UpdateResFPSLimits()
"setChecked",
Qt::QueuedConnection,
Q_ARG(bool, true));
return;
return false;
}
}

Expand Down Expand Up @@ -1187,7 +1180,8 @@ void OBSBasicSettings::UpdateResFPSLimits()
/* ------------------------------------ */

lastIgnoreRecommended = (int)ignoreRecommended;
lastServiceIdx = idx;

return true;
}

bool OBSBasicSettings::IsServiceOutputHasNetworkFeatures()
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 8 additions & 5 deletions UI/window-basic-settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -435,8 +440,6 @@ private slots:

void UpdateStreamDelayEstimate();

void UpdateAdvNetworkGroup();

void UpdateAutomaticReplayBufferCheckboxes();

void AdvOutSplitFileChanged();
Expand Down

0 comments on commit 5a40934

Please sign in to comment.