diff --git a/src/general.cpp b/src/general.cpp index 162fabc6..cc7b6867 100644 --- a/src/general.cpp +++ b/src/general.cpp @@ -129,6 +129,7 @@ void AdvSceneSwitcher::SetStarted() ui->pluginRunningText->setText( obs_module_text("AdvSceneSwitcher.status.active")); ui->pluginRunningText->disconnect(inactivePluse); + currentStatusActive = true; } void AdvSceneSwitcher::SetStopped() @@ -139,6 +140,7 @@ void AdvSceneSwitcher::SetStopped() obs_module_text("AdvSceneSwitcher.status.inactive")); inactivePluse = PulseWidget(ui->pluginRunningText, QColor(Qt::red), QColor(0, 0, 0, 0), "QLabel "); + currentStatusActive = false; } void AdvSceneSwitcher::on_toggleStartButton_clicked() @@ -681,6 +683,21 @@ void populateAutoStartEventSelection(QComboBox *cb) "AdvSceneSwitcher.generalTab.status.autoStart.recordingAndStreaming")); } +void AdvSceneSwitcher::updateStatus() +{ + if (switcher->th && switcher->th->isRunning()) { + if (currentStatusActive) { + return; + } + SetStarted(); + } else { + if (!currentStatusActive) { + return; + } + SetStopped(); + } +} + void AdvSceneSwitcher::setupGeneralTab() { populateSceneSelection(ui->noMatchSwitchScene, false); @@ -780,4 +797,10 @@ void AdvSceneSwitcher::setupGeneralTab() } else { SetStopped(); } + + // Updates the UI status element if the status changed externally + // (e.g. via hotkeys) + QTimer *statusTimer = new QTimer(this); + connect(statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); + statusTimer->start(1000); } diff --git a/src/headers/advanced-scene-switcher.hpp b/src/headers/advanced-scene-switcher.hpp index 394ced97..04e5c331 100644 --- a/src/headers/advanced-scene-switcher.hpp +++ b/src/headers/advanced-scene-switcher.hpp @@ -23,6 +23,7 @@ class AdvSceneSwitcher : public QDialog { public: std::unique_ptr ui; bool loading = true; + bool currentStatusActive = false; AdvSceneSwitcher(QWidget *parent); @@ -219,6 +220,7 @@ public slots: void on_threadPriority_currentTextChanged(const QString &text); void updateScreenRegionCursorPos(); + void updateStatus(); void on_close_clicked();