mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-07 09:05:57 -05:00
UI rework (#44)
* rework general tab UI * rework audio tab UI * rework media tab UI * rework time tab UI * rework random tab UI * rework window tab UI * rework sreen region tab UI * rework sequence tab UI * rework transition tab UI * adjust log messages to new format * fix include path and warning * highlight widgets to guide users (can be disabled) * add helper frame for screen region tab * rename main SceneSwitcher widget to AdvSceneSwitcher to resolve naming conflicts with the frontend tools on certain platforms (e.g. Debian 10) * add media state 'any' * adjust media switch handling to support vlc source
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
#include <obs-module.h>
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "headers/advanced-scene-switcher.hpp"
|
||||
#include "headers/utility.hpp"
|
||||
|
||||
void SceneSwitcher::on_close_clicked()
|
||||
QMetaObject::Connection inactivePluse;
|
||||
|
||||
void AdvSceneSwitcher::on_close_clicked()
|
||||
{
|
||||
done(0);
|
||||
}
|
||||
|
||||
void SceneSwitcher::UpdateNonMatchingScene(const QString &name)
|
||||
void AdvSceneSwitcher::UpdateNonMatchingScene(const QString &name)
|
||||
{
|
||||
obs_source_t *scene = obs_get_source_by_name(name.toUtf8().constData());
|
||||
obs_weak_source_t *ws = obs_source_get_weak_source(scene);
|
||||
@@ -21,7 +22,7 @@ void SceneSwitcher::UpdateNonMatchingScene(const QString &name)
|
||||
obs_source_release(scene);
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_noMatchDontSwitch_clicked()
|
||||
void AdvSceneSwitcher::on_noMatchDontSwitch_clicked()
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
@@ -29,9 +30,10 @@ void SceneSwitcher::on_noMatchDontSwitch_clicked()
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->switchIfNotMatching = NO_SWITCH;
|
||||
ui->noMatchSwitchScene->setEnabled(false);
|
||||
ui->randomDisabledWarning->setVisible(true);
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_noMatchSwitch_clicked()
|
||||
void AdvSceneSwitcher::on_noMatchSwitch_clicked()
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
@@ -40,9 +42,10 @@ void SceneSwitcher::on_noMatchSwitch_clicked()
|
||||
switcher->switchIfNotMatching = SWITCH;
|
||||
ui->noMatchSwitchScene->setEnabled(true);
|
||||
UpdateNonMatchingScene(ui->noMatchSwitchScene->currentText());
|
||||
ui->randomDisabledWarning->setVisible(true);
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_noMatchRandomSwitch_clicked()
|
||||
void AdvSceneSwitcher::on_noMatchRandomSwitch_clicked()
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
@@ -50,9 +53,10 @@ void SceneSwitcher::on_noMatchRandomSwitch_clicked()
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->switchIfNotMatching = RANDOM_SWITCH;
|
||||
ui->noMatchSwitchScene->setEnabled(false);
|
||||
ui->randomDisabledWarning->setVisible(false);
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_startupBehavior_currentIndexChanged(int index)
|
||||
void AdvSceneSwitcher::on_startupBehavior_currentIndexChanged(int index)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
@@ -61,7 +65,8 @@ void SceneSwitcher::on_startupBehavior_currentIndexChanged(int index)
|
||||
switcher->startupBehavior = (StartupBehavior)index;
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_noMatchSwitchScene_currentTextChanged(const QString &text)
|
||||
void AdvSceneSwitcher::on_noMatchSwitchScene_currentTextChanged(
|
||||
const QString &text)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
@@ -70,7 +75,7 @@ void SceneSwitcher::on_noMatchSwitchScene_currentTextChanged(const QString &text
|
||||
UpdateNonMatchingScene(text);
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_checkInterval_valueChanged(int value)
|
||||
void AdvSceneSwitcher::on_checkInterval_valueChanged(int value)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
@@ -79,19 +84,22 @@ void SceneSwitcher::on_checkInterval_valueChanged(int value)
|
||||
switcher->interval = value;
|
||||
}
|
||||
|
||||
void SceneSwitcher::SetStarted()
|
||||
void AdvSceneSwitcher::SetStarted()
|
||||
{
|
||||
ui->toggleStartButton->setText("Stop");
|
||||
ui->pluginRunningText->setText("Active");
|
||||
ui->pluginRunningText->disconnect(inactivePluse);
|
||||
}
|
||||
|
||||
void SceneSwitcher::SetStopped()
|
||||
void AdvSceneSwitcher::SetStopped()
|
||||
{
|
||||
ui->toggleStartButton->setText("Start");
|
||||
ui->pluginRunningText->setText("Inactive");
|
||||
inactivePluse = PulseWidget(ui->pluginRunningText, QColor(Qt::red),
|
||||
QColor(0, 0, 0, 0), "QLabel ");
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_toggleStartButton_clicked()
|
||||
void AdvSceneSwitcher::on_toggleStartButton_clicked()
|
||||
{
|
||||
if (switcher->th && switcher->th->isRunning()) {
|
||||
switcher->Stop();
|
||||
@@ -102,12 +110,12 @@ void SceneSwitcher::on_toggleStartButton_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSwitcher::closeEvent(QCloseEvent *)
|
||||
void AdvSceneSwitcher::closeEvent(QCloseEvent *)
|
||||
{
|
||||
obs_frontend_save();
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_autoStopScenes_currentTextChanged(const QString &text)
|
||||
void AdvSceneSwitcher::on_autoStopScenes_currentTextChanged(const QString &text)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
@@ -116,7 +124,7 @@ void SceneSwitcher::on_autoStopScenes_currentTextChanged(const QString &text)
|
||||
UpdateAutoStopScene(text);
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_autoStopSceneCheckBox_stateChanged(int state)
|
||||
void AdvSceneSwitcher::on_autoStopSceneCheckBox_stateChanged(int state)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
@@ -133,7 +141,7 @@ void SceneSwitcher::on_autoStopSceneCheckBox_stateChanged(int state)
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSwitcher::UpdateAutoStopScene(const QString &name)
|
||||
void AdvSceneSwitcher::UpdateAutoStopScene(const QString &name)
|
||||
{
|
||||
obs_source_t *scene = obs_get_source_by_name(name.toUtf8().constData());
|
||||
obs_weak_source_t *ws = obs_source_get_weak_source(scene);
|
||||
@@ -159,7 +167,7 @@ void SwitcherData::autoStopStreamAndRecording()
|
||||
obs_weak_source_release(ws);
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_autoStartType_currentIndexChanged(int index)
|
||||
void AdvSceneSwitcher::on_autoStartType_currentIndexChanged(int index)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
@@ -167,7 +175,7 @@ void SceneSwitcher::on_autoStartType_currentIndexChanged(int index)
|
||||
switcher->autoStartType = (AutoStartType)index;
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_autoStartScenes_currentTextChanged(const QString &text)
|
||||
void AdvSceneSwitcher::on_autoStartScenes_currentTextChanged(const QString &text)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
@@ -176,7 +184,7 @@ void SceneSwitcher::on_autoStartScenes_currentTextChanged(const QString &text)
|
||||
UpdateAutoStartScene(text);
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_autoStartSceneCheckBox_stateChanged(int state)
|
||||
void AdvSceneSwitcher::on_autoStartSceneCheckBox_stateChanged(int state)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
@@ -196,7 +204,7 @@ void SceneSwitcher::on_autoStartSceneCheckBox_stateChanged(int state)
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSwitcher::UpdateAutoStartScene(const QString &name)
|
||||
void AdvSceneSwitcher::UpdateAutoStartScene(const QString &name)
|
||||
{
|
||||
obs_source_t *scene = obs_get_source_by_name(name.toUtf8().constData());
|
||||
obs_weak_source_t *ws = obs_source_get_weak_source(scene);
|
||||
@@ -231,16 +239,21 @@ void SwitcherData::autoStartStreamRecording()
|
||||
autoStartedRecently = true;
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_verboseLogging_stateChanged(int state)
|
||||
void AdvSceneSwitcher::on_verboseLogging_stateChanged(int state)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->verbose = state;
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_exportSettings_clicked()
|
||||
void AdvSceneSwitcher::on_uiHintsDisable_stateChanged(int state)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
switcher->disableHints = state;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_exportSettings_clicked()
|
||||
{
|
||||
QString directory = QFileDialog::getSaveFileName(
|
||||
this, tr("Export Advanced Scene Switcher settings to file ..."),
|
||||
@@ -274,7 +287,7 @@ void SceneSwitcher::on_exportSettings_clicked()
|
||||
obs_data_release(obj);
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_importSettings_clicked()
|
||||
void AdvSceneSwitcher::on_importSettings_clicked()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
@@ -378,13 +391,13 @@ int findTabIndex(QTabBar *bar, int pos)
|
||||
}
|
||||
}
|
||||
if (at == -1)
|
||||
blog(LOG_INFO, "Advanced Scene Switcher failed to find tab %s",
|
||||
blog(LOG_INFO, "failed to find tab %s",
|
||||
tabName.toUtf8().constData());
|
||||
|
||||
return at;
|
||||
}
|
||||
|
||||
void SceneSwitcher::setTabOrder()
|
||||
void AdvSceneSwitcher::setTabOrder()
|
||||
{
|
||||
QTabBar *bar = ui->tabWidget->tabBar();
|
||||
for (int i = 0; i < bar->count(); ++i) {
|
||||
@@ -394,10 +407,10 @@ void SceneSwitcher::setTabOrder()
|
||||
bar->moveTab(curPos, i);
|
||||
}
|
||||
|
||||
connect(bar, &QTabBar::tabMoved, this, &SceneSwitcher::on_tabMoved);
|
||||
connect(bar, &QTabBar::tabMoved, this, &AdvSceneSwitcher::on_tabMoved);
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_tabMoved(int from, int to)
|
||||
void AdvSceneSwitcher::on_tabMoved(int from, int to)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
@@ -432,6 +445,7 @@ void SwitcherData::saveGeneralSettings(obs_data_t *obj)
|
||||
autoStartSceneName.c_str());
|
||||
|
||||
obs_data_set_bool(obj, "verbose", switcher->verbose);
|
||||
obs_data_set_bool(obj, "disableHints", switcher->disableHints);
|
||||
|
||||
obs_data_set_int(obj, "priority0",
|
||||
switcher->functionNamesByPriority[0]);
|
||||
@@ -503,6 +517,7 @@ void SwitcherData::loadGeneralSettings(obs_data_t *obj)
|
||||
switcher->autoStartScene = GetWeakSourceByName(autoStartScene.c_str());
|
||||
|
||||
switcher->verbose = obs_data_get_bool(obj, "verbose");
|
||||
switcher->disableHints = obs_data_get_bool(obj, "disableHints");
|
||||
|
||||
obs_data_set_default_int(obj, "priority0", default_priority_0);
|
||||
obs_data_set_default_int(obj, "priority1", default_priority_1);
|
||||
@@ -590,7 +605,7 @@ void SwitcherData::loadGeneralSettings(obs_data_t *obj)
|
||||
(int)(obs_data_get_int(obj, "audioTabPos")));
|
||||
}
|
||||
|
||||
void SceneSwitcher::setupGeneralTab()
|
||||
void AdvSceneSwitcher::setupGeneralTab()
|
||||
{
|
||||
populateSceneSelection(ui->noMatchSwitchScene, false);
|
||||
populateSceneSelection(ui->autoStopScenes, false);
|
||||
@@ -638,6 +653,7 @@ void SceneSwitcher::setupGeneralTab()
|
||||
}
|
||||
|
||||
ui->verboseLogging->setChecked(switcher->verbose);
|
||||
ui->uiHintsDisable->setChecked(switcher->disableHints);
|
||||
|
||||
for (int p : switcher->functionNamesByPriority) {
|
||||
std::string s = "";
|
||||
|
||||
Reference in New Issue
Block a user