Minor style changes (#114)

* use GetWeakSourceName() where possible

* add getCurrentScene() to scene group

* silence OBS warning log and fix typo in audio switch

* extract showing initial status of widgets to function in generic switch
This commit is contained in:
WarmUpTill
2021-02-03 20:27:25 +01:00
committed by GitHub
parent a5f0eb8da8
commit a84a205608
28 changed files with 837 additions and 491 deletions

View File

@@ -22,8 +22,9 @@ void AdvSceneSwitcher::on_randomAdd_clicked()
void AdvSceneSwitcher::on_randomRemove_clicked()
{
QListWidgetItem *item = ui->randomSwitches->currentItem();
if (!item)
if (!item) {
return;
}
{
std::lock_guard<std::mutex> lock(switcher->m);
@@ -38,27 +39,32 @@ void AdvSceneSwitcher::on_randomRemove_clicked()
void SwitcherData::checkRandom(bool &match, OBSWeakSource &scene,
OBSWeakSource &transition, int &delay)
{
if (randomSwitches.size() == 0 || RandomSwitch::pause)
if (randomSwitches.size() == 0 || RandomSwitch::pause) {
return;
}
std::deque<RandomSwitch> rs(randomSwitches);
std::random_device rng;
std::mt19937 urng(rng());
std::shuffle(rs.begin(), rs.end(), urng);
for (RandomSwitch &r : rs) {
if (!r.initialized())
if (!r.initialized()) {
continue;
}
if (r.scene == lastRandomScene && randomSwitches.size() != 1)
if (r.scene == lastRandomScene && randomSwitches.size() != 1) {
continue;
}
scene = r.getScene();
transition = r.transition;
delay = (int)r.delay * 1000;
match = true;
lastRandomScene = r.scene;
if (verbose)
if (verbose) {
r.logMatch();
}
break;
}
}
@@ -115,11 +121,12 @@ void AdvSceneSwitcher::setupRandomTab()
ui->randomHelp->setVisible(false);
}
if (switcher->switchIfNotMatching != RANDOM_SWITCH)
if (switcher->switchIfNotMatching != RANDOM_SWITCH) {
PulseWidget(ui->randomDisabledWarning, QColor(Qt::red),
QColor(0, 0, 0, 0), "QLabel ");
else
} else {
ui->randomDisabledWarning->setVisible(false);
}
}
void RandomSwitch::save(obs_data_t *obj)
@@ -185,8 +192,10 @@ void RandomSwitchWidget::swapSwitchData(RandomSwitchWidget *s1,
void RandomSwitchWidget::DelayChanged(double d)
{
if (loading || !switchData)
if (loading || !switchData) {
return;
}
std::lock_guard<std::mutex> lock(switcher->m);
switchData->delay = d;
}