mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-07 09:05:57 -05:00
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:
@@ -23,8 +23,9 @@ void AdvSceneSwitcher::on_mediaAdd_clicked()
|
||||
void AdvSceneSwitcher::on_mediaRemove_clicked()
|
||||
{
|
||||
QListWidgetItem *item = ui->mediaSwitches->currentItem();
|
||||
if (!item)
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
@@ -39,8 +40,9 @@ void AdvSceneSwitcher::on_mediaRemove_clicked()
|
||||
void AdvSceneSwitcher::on_mediaUp_clicked()
|
||||
{
|
||||
int index = ui->mediaSwitches->currentRow();
|
||||
if (!listMoveUp(ui->mediaSwitches))
|
||||
if (!listMoveUp(ui->mediaSwitches)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MediaSwitchWidget *s1 =
|
||||
(MediaSwitchWidget *)ui->mediaSwitches->itemWidget(
|
||||
@@ -60,8 +62,9 @@ void AdvSceneSwitcher::on_mediaDown_clicked()
|
||||
{
|
||||
int index = ui->mediaSwitches->currentRow();
|
||||
|
||||
if (!listMoveDown(ui->mediaSwitches))
|
||||
if (!listMoveDown(ui->mediaSwitches)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MediaSwitchWidget *s1 =
|
||||
(MediaSwitchWidget *)ui->mediaSwitches->itemWidget(
|
||||
@@ -80,12 +83,14 @@ void AdvSceneSwitcher::on_mediaDown_clicked()
|
||||
void SwitcherData::checkMediaSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
if (MediaSwitch::pause)
|
||||
if (MediaSwitch::pause) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (MediaSwitch &mediaSwitch : mediaSwitches) {
|
||||
if (!mediaSwitch.initialized())
|
||||
if (!mediaSwitch.initialized()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
obs_source_t *source =
|
||||
obs_weak_source_get_source(mediaSwitch.source);
|
||||
@@ -138,8 +143,9 @@ void SwitcherData::checkMediaSwitch(bool &match, OBSWeakSource &scene,
|
||||
(duration - time <= interval * 2);
|
||||
|
||||
// reset
|
||||
if (ended)
|
||||
if (ended) {
|
||||
mediaSwitch.playedToEnd = false;
|
||||
}
|
||||
|
||||
// reset for next check
|
||||
mediaSwitch.stopped = false;
|
||||
@@ -179,14 +185,16 @@ void SwitcherData::checkMediaSwitch(bool &match, OBSWeakSource &scene,
|
||||
scene = mediaSwitch.getScene();
|
||||
transition = mediaSwitch.transition;
|
||||
|
||||
if (verbose)
|
||||
if (verbose) {
|
||||
mediaSwitch.logMatch();
|
||||
}
|
||||
}
|
||||
|
||||
mediaSwitch.matched = matched;
|
||||
|
||||
if (match)
|
||||
if (match) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,10 +264,7 @@ void MediaSwitch::save(obs_data_t *obj)
|
||||
{
|
||||
SceneSwitcherEntry::save(obj);
|
||||
|
||||
obs_source_t *s = obs_weak_source_get_source(source);
|
||||
const char *sourceName = obs_source_get_name(s);
|
||||
obs_data_set_string(obj, "source", sourceName);
|
||||
obs_source_release(s);
|
||||
obs_data_set_string(obj, "source", GetWeakSourceName(source).c_str());
|
||||
|
||||
obs_data_set_int(obj, "state", state);
|
||||
obs_data_set_int(obj, "restriction", restriction);
|
||||
@@ -269,13 +274,15 @@ void MediaSwitch::save(obs_data_t *obj)
|
||||
// To be removed in future version
|
||||
bool loadOldMedia(obs_data_t *obj, MediaSwitch *s)
|
||||
{
|
||||
if (!s)
|
||||
if (!s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *scene = obs_data_get_string(obj, "scene");
|
||||
|
||||
if (strcmp(scene, "") == 0)
|
||||
if (strcmp(scene, "") == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
s->scene = GetWeakSourceByName(scene);
|
||||
|
||||
@@ -296,8 +303,9 @@ bool loadOldMedia(obs_data_t *obj, MediaSwitch *s)
|
||||
void MediaSwitch::load(obs_data_t *obj)
|
||||
{
|
||||
|
||||
if (loadOldMedia(obj, this))
|
||||
if (loadOldMedia(obj, this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SceneSwitcherEntry::load(obj);
|
||||
|
||||
@@ -492,8 +500,9 @@ MediaSwitchWidget::MediaSwitchWidget(QWidget *parent, MediaSwitch *s)
|
||||
states->setCurrentIndex(s->state);
|
||||
timeRestrictions->setCurrentIndex(s->restriction);
|
||||
time->setValue(s->time);
|
||||
if (s->restriction == TIME_RESTRICTION_NONE)
|
||||
if (s->restriction == TIME_RESTRICTION_NONE) {
|
||||
time->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
@@ -535,8 +544,10 @@ void MediaSwitchWidget::swapSwitchData(MediaSwitchWidget *s1,
|
||||
|
||||
void MediaSwitchWidget::SourceChanged(const QString &text)
|
||||
{
|
||||
if (loading || !switchData)
|
||||
if (loading || !switchData) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switchData->clearSignalHandler();
|
||||
switchData->source = GetWeakSourceByQString(text);
|
||||
@@ -545,8 +556,10 @@ void MediaSwitchWidget::SourceChanged(const QString &text)
|
||||
|
||||
void MediaSwitchWidget::StateChanged(int index)
|
||||
{
|
||||
if (loading || !switchData)
|
||||
if (loading || !switchData) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switchData->state = (obs_media_state)index;
|
||||
switchData->anyState = switchData->state == media_any_idx;
|
||||
@@ -554,13 +567,15 @@ void MediaSwitchWidget::StateChanged(int index)
|
||||
|
||||
void MediaSwitchWidget::TimeRestrictionChanged(int index)
|
||||
{
|
||||
if (loading || !switchData)
|
||||
if (loading || !switchData) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((time_restriction)index == TIME_RESTRICTION_NONE)
|
||||
if ((time_restriction)index == TIME_RESTRICTION_NONE) {
|
||||
time->setDisabled(true);
|
||||
else
|
||||
} else {
|
||||
time->setDisabled(false);
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switchData->restriction = (time_restriction)index;
|
||||
@@ -568,8 +583,10 @@ void MediaSwitchWidget::TimeRestrictionChanged(int index)
|
||||
|
||||
void MediaSwitchWidget::TimeChanged(int time)
|
||||
{
|
||||
if (loading || !switchData)
|
||||
if (loading || !switchData) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switchData->time = time;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user