mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-08 01:26:04 -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:
@@ -26,8 +26,9 @@ void AdvSceneSwitcher::UpdateNonMatchingScene(const QString &name)
|
||||
|
||||
void AdvSceneSwitcher::on_noMatchDontSwitch_clicked()
|
||||
{
|
||||
if (loading)
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->switchIfNotMatching = NO_SWITCH;
|
||||
@@ -37,8 +38,9 @@ void AdvSceneSwitcher::on_noMatchDontSwitch_clicked()
|
||||
|
||||
void AdvSceneSwitcher::on_noMatchSwitch_clicked()
|
||||
{
|
||||
if (loading)
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->switchIfNotMatching = SWITCH;
|
||||
@@ -49,8 +51,9 @@ void AdvSceneSwitcher::on_noMatchSwitch_clicked()
|
||||
|
||||
void AdvSceneSwitcher::on_noMatchRandomSwitch_clicked()
|
||||
{
|
||||
if (loading)
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->switchIfNotMatching = RANDOM_SWITCH;
|
||||
@@ -60,16 +63,19 @@ void AdvSceneSwitcher::on_noMatchRandomSwitch_clicked()
|
||||
|
||||
void AdvSceneSwitcher::on_noMatchDelay_valueChanged(double i)
|
||||
{
|
||||
if (loading)
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->noMatchDelay = i;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_startupBehavior_currentIndexChanged(int index)
|
||||
{
|
||||
if (loading)
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->startupBehavior = (StartupBehavior)index;
|
||||
@@ -77,8 +83,9 @@ void AdvSceneSwitcher::on_startupBehavior_currentIndexChanged(int index)
|
||||
|
||||
void AdvSceneSwitcher::on_autoStartEvent_currentIndexChanged(int index)
|
||||
{
|
||||
if (loading)
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->autoStartEvent = static_cast<AutoStartEvent>(index);
|
||||
@@ -87,8 +94,9 @@ void AdvSceneSwitcher::on_autoStartEvent_currentIndexChanged(int index)
|
||||
void AdvSceneSwitcher::on_noMatchSwitchScene_currentTextChanged(
|
||||
const QString &text)
|
||||
{
|
||||
if (loading)
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
UpdateNonMatchingScene(text);
|
||||
@@ -96,16 +104,19 @@ void AdvSceneSwitcher::on_noMatchSwitchScene_currentTextChanged(
|
||||
|
||||
void AdvSceneSwitcher::on_cooldownTime_valueChanged(double i)
|
||||
{
|
||||
if (loading)
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->cooldown = i;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_checkInterval_valueChanged(int value)
|
||||
{
|
||||
if (loading)
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->interval = value;
|
||||
@@ -148,15 +159,19 @@ void AdvSceneSwitcher::closeEvent(QCloseEvent *)
|
||||
|
||||
void AdvSceneSwitcher::on_verboseLogging_stateChanged(int state)
|
||||
{
|
||||
if (loading)
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
switcher->verbose = state;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_uiHintsDisable_stateChanged(int state)
|
||||
{
|
||||
if (loading)
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
switcher->disableHints = state;
|
||||
}
|
||||
|
||||
@@ -165,8 +180,9 @@ void AdvSceneSwitcher::AskBackup(obs_data_t *obj)
|
||||
bool backupSettings = DisplayMessage(
|
||||
obs_module_text("AdvSceneSwitcher.askBackup"), true);
|
||||
|
||||
if (!backupSettings)
|
||||
if (!backupSettings) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString directory = QFileDialog::getSaveFileName(
|
||||
nullptr,
|
||||
@@ -175,12 +191,14 @@ void AdvSceneSwitcher::AskBackup(obs_data_t *obj)
|
||||
QDir::currentPath(),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.saveOrLoadsettings.textType"));
|
||||
if (directory.isEmpty())
|
||||
if (directory.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QFile file(directory);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
return;
|
||||
}
|
||||
|
||||
obs_data_save_json(obj, file.fileName().toUtf8().constData());
|
||||
}
|
||||
@@ -194,12 +212,14 @@ void AdvSceneSwitcher::on_exportSettings_clicked()
|
||||
QDir::currentPath(),
|
||||
tr(obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.saveOrLoadsettings.textType")));
|
||||
if (directory.isEmpty())
|
||||
if (directory.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QFile file(directory);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
return;
|
||||
}
|
||||
|
||||
obs_data_t *obj = obs_data_create();
|
||||
|
||||
@@ -212,7 +232,7 @@ void AdvSceneSwitcher::on_exportSettings_clicked()
|
||||
|
||||
void AdvSceneSwitcher::on_importSettings_clicked()
|
||||
{
|
||||
// scene switcher could be stuck in a sequence
|
||||
// Scene switcher could be stuck in a sequence
|
||||
// so it needs to be stopped before importing new settings
|
||||
bool start = !switcher->stop;
|
||||
switcher->Stop();
|
||||
@@ -226,12 +246,14 @@ void AdvSceneSwitcher::on_importSettings_clicked()
|
||||
QDir::currentPath(),
|
||||
tr(obs_module_text(
|
||||
"AdvSceneSwitcher.generalTab.saveOrLoadsettings.textType")));
|
||||
if (directory.isEmpty())
|
||||
if (directory.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QFile file(directory);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
return;
|
||||
}
|
||||
|
||||
obs_data_t *obj = obs_data_create_from_json_file(
|
||||
file.fileName().toUtf8().constData());
|
||||
@@ -250,9 +272,10 @@ void AdvSceneSwitcher::on_importSettings_clicked()
|
||||
"AdvSceneSwitcher.generalTab.saveOrLoadsettings.loadSuccess"));
|
||||
close();
|
||||
|
||||
// restart scene switcher if it was active
|
||||
if (start)
|
||||
// Restart scene switcher if it was active
|
||||
if (start) {
|
||||
switcher->Start();
|
||||
}
|
||||
}
|
||||
|
||||
int findTabIndex(QTabWidget *tabWidget, int pos)
|
||||
@@ -312,9 +335,10 @@ int findTabIndex(QTabWidget *tabWidget, int pos)
|
||||
if (page) {
|
||||
at = tabWidget->indexOf(page);
|
||||
}
|
||||
if (at == -1)
|
||||
if (at == -1) {
|
||||
blog(LOG_INFO, "failed to find tab %s",
|
||||
tabName.toUtf8().constData());
|
||||
}
|
||||
|
||||
return at;
|
||||
}
|
||||
@@ -325,8 +349,9 @@ void AdvSceneSwitcher::setTabOrder()
|
||||
for (int i = 0; i < bar->count(); ++i) {
|
||||
int curPos = findTabIndex(ui->tabWidget, switcher->tabOrder[i]);
|
||||
|
||||
if (i != curPos && curPos != -1)
|
||||
if (i != curPos && curPos != -1) {
|
||||
bar->moveTab(curPos, i);
|
||||
}
|
||||
}
|
||||
|
||||
connect(bar, &QTabBar::tabMoved, this, &AdvSceneSwitcher::on_tabMoved);
|
||||
@@ -334,8 +359,10 @@ void AdvSceneSwitcher::setTabOrder()
|
||||
|
||||
void AdvSceneSwitcher::on_tabMoved(int from, int to)
|
||||
{
|
||||
if (loading)
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::swap(switcher->tabOrder[from], switcher->tabOrder[to]);
|
||||
}
|
||||
|
||||
@@ -350,8 +377,9 @@ void AdvSceneSwitcher::on_tabWidget_currentChanged(int index)
|
||||
|
||||
void SwitcherData::loadSettings(obs_data_t *obj)
|
||||
{
|
||||
if (!obj)
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
switcher->loadSceneGroups(obj);
|
||||
switcher->loadWindowTitleSwitches(obj);
|
||||
@@ -373,8 +401,9 @@ void SwitcherData::loadSettings(obs_data_t *obj)
|
||||
|
||||
void SwitcherData::saveSettings(obs_data_t *obj)
|
||||
{
|
||||
if (!obj)
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
saveSceneGroups(obj);
|
||||
saveWindowTitleSwitches(obj);
|
||||
@@ -483,10 +512,12 @@ void SwitcherData::loadGeneralSettings(obs_data_t *obj)
|
||||
switcher->stop = !obs_data_get_bool(obj, "active");
|
||||
switcher->startupBehavior =
|
||||
(StartupBehavior)obs_data_get_int(obj, "startup_behavior");
|
||||
if (switcher->startupBehavior == START)
|
||||
if (switcher->startupBehavior == START) {
|
||||
switcher->stop = false;
|
||||
if (switcher->startupBehavior == STOP)
|
||||
}
|
||||
if (switcher->startupBehavior == STOP) {
|
||||
switcher->stop = true;
|
||||
}
|
||||
|
||||
switcher->autoStartEvent = static_cast<AutoStartEvent>(
|
||||
obs_data_get_int(obj, "autoStartEvent"));
|
||||
@@ -625,8 +656,7 @@ void SwitcherData::checkSwitchCooldown(bool &match)
|
||||
}
|
||||
|
||||
match = false;
|
||||
if (verbose)
|
||||
blog(LOG_INFO, "cooldown active - ignoring match");
|
||||
vblog(LOG_INFO, "cooldown active - ignoring match");
|
||||
}
|
||||
|
||||
void populateStartupBehavior(QComboBox *cb)
|
||||
@@ -745,8 +775,9 @@ void AdvSceneSwitcher::setupGeneralTab()
|
||||
ui->autoStartEvent->setCurrentIndex(
|
||||
static_cast<int>(switcher->autoStartEvent));
|
||||
|
||||
if (switcher->th && switcher->th->isRunning())
|
||||
if (switcher->th && switcher->th->isRunning()) {
|
||||
SetStarted();
|
||||
else
|
||||
} else {
|
||||
SetStopped();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user