Prevent users from accidentally enabling action cooldowns

This commit is contained in:
WarmUpTill 2024-07-06 17:24:42 +02:00 committed by WarmUpTill
parent bfc51b2df5
commit 8032dde045
4 changed files with 23 additions and 2 deletions

View File

@ -390,7 +390,7 @@
<item>
<layout class="QHBoxLayout" name="cooldownLayout">
<item>
<widget class="QLabel" name="label">
<widget class="QCheckBox" name="enableCooldown">
<property name="text">
<string>AdvSceneSwitcher.generalTab.generalBehavior.cooldown</string>
</property>

View File

@ -53,6 +53,7 @@ public slots:
void on_noMatchRandomSwitch_clicked();
void NoMatchDelayDurationChanged(const Duration &);
void CooldownDurationChanged(const Duration &);
void on_enableCooldown_stateChanged(int state);
void on_startupBehavior_currentIndexChanged(int index);
void on_logLevel_currentIndexChanged(int index);
void on_autoStartEvent_currentIndexChanged(int index);

View File

@ -91,6 +91,17 @@ void AdvSceneSwitcher::CooldownDurationChanged(const Duration &dur)
switcher->cooldown = dur;
}
void AdvSceneSwitcher::on_enableCooldown_stateChanged(int state)
{
if (loading) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
switcher->enableCooldown = state;
ui->cooldownTime->setEnabled(state);
}
void AdvSceneSwitcher::on_startupBehavior_currentIndexChanged(int index)
{
if (loading) {
@ -505,6 +516,7 @@ void SwitcherData::SaveGeneralSettings(obs_data_t *obj)
noMatchDelay.Save(obj, "noMatchDelay");
cooldown.Save(obj, "cooldown");
obs_data_set_bool(obj, "enableCooldown", enableCooldown);
obs_data_set_bool(obj, "active", sceneColletionStop ? true : !stop);
sceneColletionStop = false;
@ -550,6 +562,11 @@ void SwitcherData::LoadGeneralSettings(obs_data_t *obj)
noMatchDelay.Load(obj, "noMatchDelay");
cooldown.Load(obj, "cooldown");
if (!obs_data_has_user_value(obj, "enableCooldown")) {
enableCooldown = cooldown.Seconds() != 0;
} else {
enableCooldown = obs_data_get_bool(obj, "enableCooldown");
}
obs_data_set_default_bool(obj, "active", true);
stop = !obs_data_get_bool(obj, "active");
@ -653,7 +670,7 @@ void SwitcherData::CheckNoMatchSwitch(bool &match, OBSWeakSource &scene,
void SwitcherData::checkSwitchCooldown(bool &match)
{
if (!match) {
if (!match || !enableCooldown) {
return;
}
@ -822,6 +839,8 @@ void AdvSceneSwitcher::SetupGeneralTab()
ui->checkInterval->setValue(switcher->interval);
ui->enableCooldown->setChecked(switcher->enableCooldown);
ui->cooldownTime->setEnabled(switcher->enableCooldown);
ui->cooldownTime->SetDuration(switcher->cooldown);
ui->cooldownTime->setToolTip(obs_module_text(
"AdvSceneSwitcher.generalTab.generalBehavior.cooldownHint"));

View File

@ -131,6 +131,7 @@ public:
RECORINDG_OR_STREAMING
};
AutoStart autoStartEvent = AutoStart::NEVER;
bool enableCooldown = false;
Duration cooldown;
bool showSystemTrayNotifications = false;
bool transitionOverrideOverride = false;